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.7 2006/08/11 09:28:45 yasumoto_yoshitaka
15 suppress unused warning
16
17 Revision 1.6 03/11/2006 06:55:23 hirose
18 Integrated MEMAllocator, added switch to use heap defined in MEM library.
19 Moved easy-packed tpl functions from <revolution/tpl.h>
20
21 Revision 1.5 2006/02/04 13:05:44 hashida
22 (none)
23
24 Revision 1.4 01/07/2006 06:47:13 hirose
25 Reconstruction from simpler form.
26
27 Revision 1.3 12/20/2005 05:26:36 hirose
28 (none)
29
30 Revision 1.2 08/03/2005 02:52:20 hirose
31 Substitution of obsolete charPipeline libs by new tpl library.
32
33 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to
34
35 $NoKeywords: $
36 *---------------------------------------------------------------------------*/
37
38 #ifndef __DEMO_H__
39 #define __DEMO_H__
40
41 /*---------------------------------------------------------------------------*/
42 #include <revolution.h>
43 #include <stdio.h>
44
45 #include <revolution/mem.h>
46 #include <revolution/tpl.h>
47
48 #include <demo/DEMOPad.h>
49 #include <demo/DEMOPuts.h>
50 /*---------------------------------------------------------------------------*/
51
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 /*---------------------------------------------------------------------------*
58 DEMOInit.c
59 *---------------------------------------------------------------------------*/
60 // Global variables
61 extern MEMAllocator DemoAllocator1; // For MEM1
62 extern MEMAllocator DemoAllocator2; // For MEM2
63
64 // Function prototypes
65 extern void DEMOInit_Real ( GXRenderModeObj* mode );
66 extern void DEMOBeforeRender ( void );
67 extern void DEMODoneRender ( void );
68 extern void DEMOSwapBuffers ( void );
69 extern GXRenderModeObj* DEMOGetRenderModeObj( void );
70 extern void* DEMOGetCurrentBuffer( void );
71 extern void DEMOReInit ( GXRenderModeObj *mode );
72
73 // Definition of DEMOInit()
74 //
75 // If compiler switch 'DEMO_USE_MEMLIB' is defined, set DemoUseMEMHeap
76 // flag inside the library before DEMOInit_Real() is called.
77 extern u32 DemoUseMEMHeap;
78
79 #ifdef DEMO_USE_MEMLIB
80 #define DEMOInit(mode) \
81 { \
82 DemoUseMEMHeap = 1; \
83 DEMOInit_Real(mode); \
84 }
85 #else
86 #define DEMOInit(mode) \
87 { \
88 DemoUseMEMHeap = 0; \
89 DEMOInit_Real(mode); \
90 }
91 #endif
92
93
94 /*---------------------------------------------------------------------------*
95 Extension of <revolution/tpl.h>
96 Easy-packed TPL file access functions (inline)
97 *---------------------------------------------------------------------------*/
TPLGetPalette(TPLPalettePtr * pal,char * name)98 inline void TPLGetPalette ( TPLPalettePtr *pal, char *name )
99 {
100 DVDFileInfo dfi;
101
102 (void)DVDOpen(name, &dfi);
103 (*pal) = (TPLPalettePtr)MEMAllocFromAllocator(&DemoAllocator1, OSRoundUp32B(dfi.length));
104 (void)DVDRead(&dfi, (*pal), (s32)OSRoundUp32B(dfi.length), 0);
105 (void)DVDClose(&dfi);
106
107 TPLBind(*pal);
108 }
109
110 /*---------------------------------------------------------------------------*/
TPLReleasePalette(TPLPalettePtr * pal)111 inline void TPLReleasePalette ( TPLPalettePtr *pal )
112 {
113 if ( pal )
114 {
115 MEMFreeToAllocator(&DemoAllocator1, *pal);
116 *pal = 0;
117 }
118 }
119 /*---------------------------------------------------------------------------*/
120
121
122 #ifdef __cplusplus
123 }
124 #endif
125
126 #endif // __DEMO_H__
127
128 /*===========================================================================*/
129