1 /*---------------------------------------------------------------------------*
2 Project: Dolphin DEMO library
3 File: demo.h
4
5 Copyright 1998-2006 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: demo.h,v $
14 Revision 1.9.16.1 2008/07/29 09:26:56 nakano_yoshinobu
15 Added DemoUseMEM_HEAP_OPT_THREAD_SAFE option.
16 This option uses MEMCreateExpHeapEx(..., MEM_HEAP_OPT_THREAD_SAFE) in DEMOInit().
17
18 Revision 1.9 2007/06/15 23:04:30 carlmu
19 Allow XFB to be allocated from MEM2.
20
21 Revision 1.8 2007/02/07 23:54:31 johnc
22 Removed static scope from functions and variables inside DEMOInit.
23
24 Revision 1.7 2006/08/11 09:28:45 yasumoto_yoshitaka
25 surpress unused warning
26
27 Revision 1.6 2006/03/11 06:55:23 hirose
28 Integrated MEMAllocator, added switch to use heap defined in MEM library.
29 Moved easy-packed tpl functions from <revolution/tpl.h>
30
31 Revision 1.5 2006/02/04 13:05:44 hashida
32 (none)
33
34 Revision 1.4 2006/01/07 06:47:13 hirose
35 Reconstruction from simpler form.
36
37 Revision 1.3 2005/12/20 05:26:36 hirose
38 (none)
39
40 Revision 1.2 2005/08/03 02:52:20 hirose
41 Substitution of obsolete charPipeline libs by new tpl library.
42
43 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to
44
45 $NoKeywords: $
46 *---------------------------------------------------------------------------*/
47
48 #ifndef __DEMO_H__
49 #define __DEMO_H__
50
51 /*---------------------------------------------------------------------------*/
52 #include <revolution.h>
53 #include <stdio.h>
54
55 #include <revolution/mem.h>
56 #include <revolution/tpl.h>
57
58 #include <demo/DEMOPad.h>
59 #include <demo/DEMOPuts.h>
60 /*---------------------------------------------------------------------------*/
61
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66
67 /*---------------------------------------------------------------------------*
68 DEMOInit.c
69 *---------------------------------------------------------------------------*/
70 // Global variables
71 extern MEMAllocator DemoAllocator1; // For MEM1
72 extern MEMAllocator DemoAllocator2; // For MEM2
73
74 // Function prototypes
75 extern void DEMOInit_Real ( GXRenderModeObj* mode );
76 extern void DEMOBeforeRender ( void );
77 extern void DEMODoneRender ( void );
78 extern void DEMOSwapBuffers ( void );
79 extern GXRenderModeObj* DEMOGetRenderModeObj( void );
80 extern void* DEMOGetCurrentBuffer( void );
81 extern void DEMOReInit ( GXRenderModeObj *mode );
82
83 extern void DEMOSetRenderMode ( GXRenderModeObj* mode );
84 extern void DEMOConfigureMem ( void );
85 extern void DEMOInitGX ( void );
86 extern void DEMOStartVI ( void );
87
88
89 // Definition of DEMOInit()
90 //
91 // If compiler switch 'DEMO_USE_MEMLIB' is defined, set DemoUseMEMHeap
92 // flag inside the library before DEMOInit_Real() is called.
93 extern u32 DemoUseMEMHeap;
94
95 #ifdef DEMO_USE_MEMLIB
96 #define DEMOInit(mode) \
97 { \
98 DemoUseMEMHeap = 1; \
99 DEMOInit_Real(mode); \
100 }
101 #else
102 #define DEMOInit(mode) \
103 { \
104 DemoUseMEMHeap = 0; \
105 DEMOInit_Real(mode); \
106 }
107 #endif
108
109 // Switch to put External Frame Buffers in MEM2.
110 // If desired, set this to TRUE before calling DEMOInit.
111 extern BOOL DemoUseMEM2XFB;
112
113 // Switch to use MEM_HEAP_OPT_THREAD_SAFE in MEMCreateExpHeapEx.
114 // If desired, set this to TRUE before calling DEMOInit.
115 extern BOOL DemoUseMEM_HEAP_OPT_THREAD_SAFE;
116
117 /*---------------------------------------------------------------------------*
118 Extension of <revolution/tpl.h>
119 Easy-packed TPL file access functions (inlined)
120 *---------------------------------------------------------------------------*/
TPLGetPalette(TPLPalettePtr * pal,char * name)121 inline void TPLGetPalette ( TPLPalettePtr *pal, char *name )
122 {
123 DVDFileInfo dfi;
124
125 (void)DVDOpen(name, &dfi);
126 (*pal) = (TPLPalettePtr)MEMAllocFromAllocator(&DemoAllocator1, OSRoundUp32B(dfi.length));
127 (void)DVDRead(&dfi, (*pal), (s32)OSRoundUp32B(dfi.length), 0);
128 (void)DVDClose(&dfi);
129
130 TPLBind(*pal);
131 }
132
133 /*---------------------------------------------------------------------------*/
TPLReleasePalette(TPLPalettePtr * pal)134 inline void TPLReleasePalette ( TPLPalettePtr *pal )
135 {
136 if ( pal )
137 {
138 MEMFreeToAllocator(&DemoAllocator1, *pal);
139 *pal = 0;
140 }
141 }
142 /*---------------------------------------------------------------------------*/
143
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif // __DEMO_H__
150
151 /*===========================================================================*/
152