comparison src/video/nds/SDL_ndsvideo.c @ 2690:ca01c20274c0 gsoc2008_nds

More work and some bugfixes on the graphics driver.
author Darren Alton <dalton@stevens.edu>
date Sat, 16 Aug 2008 07:44:35 +0000
parents 71c56e900f8b
children c04a266c277a
comparison
equal deleted inserted replaced
2689:e065c9f6a393 2690:ca01c20274c0
41 41
42 #include "SDL_ndsvideo.h" 42 #include "SDL_ndsvideo.h"
43 #include "SDL_ndsevents_c.h" 43 #include "SDL_ndsevents_c.h"
44 #include "SDL_ndsrender_c.h" 44 #include "SDL_ndsrender_c.h"
45 45
46
47
48 #define TRACE
49 //#define TRACE printf
50
51
52
46 #define NDSVID_DRIVER_NAME "nds" 53 #define NDSVID_DRIVER_NAME "nds"
47 54
48 /* Initialization/Query functions */ 55 /* Initialization/Query functions */
49 static int NDS_VideoInit(_THIS); 56 static int NDS_VideoInit(_THIS);
50 static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode); 57 static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
70 NDS_CreateDevice(int devindex) 77 NDS_CreateDevice(int devindex)
71 { 78 {
72 SDL_VideoDevice *device; 79 SDL_VideoDevice *device;
73 /*printf("NDS_CreateDevice(%d)\n", devindex); */ 80 /*printf("NDS_CreateDevice(%d)\n", devindex); */
74 81
75 printf("+NDS_CreateDevice\n"); 82 TRACE("+NDS_CreateDevice\n");
76 /* Initialize all variables that we clean on shutdown */ 83 /* Initialize all variables that we clean on shutdown */
77 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); 84 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
78 if (!device) { 85 if (!device) {
79 SDL_OutOfMemory(); 86 SDL_OutOfMemory();
80 if (device) { 87 if (device) {
91 98
92 device->num_displays = 2; /* DS = dual screens */ 99 device->num_displays = 2; /* DS = dual screens */
93 100
94 device->free = NDS_DeleteDevice; 101 device->free = NDS_DeleteDevice;
95 102
96 printf("-NDS_CreateDevice\n"); 103 TRACE("-NDS_CreateDevice\n");
97 return device; 104 return device;
98 } 105 }
99 106
100 VideoBootStrap NDS_bootstrap = { 107 VideoBootStrap NDS_bootstrap = {
101 NDSVID_DRIVER_NAME, "SDL NDS video driver", 108 NDSVID_DRIVER_NAME, "SDL NDS video driver",
106 NDS_VideoInit(_THIS) 113 NDS_VideoInit(_THIS)
107 { 114 {
108 SDL_DisplayMode mode; 115 SDL_DisplayMode mode;
109 int i; 116 int i;
110 117
111 printf("+NDS_VideoInit\n"); 118 TRACE("+NDS_VideoInit\n");
112 /* simple 256x192x16x60 for now */ 119 /* simple 256x192x16x60 for now */
113 mode.w = 256; 120 mode.w = 256;
114 mode.h = 192; 121 mode.h = 192;
115 mode.format = SDL_PIXELFORMAT_ABGR1555; 122 mode.format = SDL_PIXELFORMAT_ABGR1555;
116 mode.refresh_rate = 60; 123 mode.refresh_rate = 60;
127 /* hackish stuff to get things up and running for now, and for a console */ 134 /* hackish stuff to get things up and running for now, and for a console */
128 powerON(POWER_ALL_2D); 135 powerON(POWER_ALL_2D);
129 irqInit(); 136 irqInit();
130 irqEnable(IRQ_VBLANK); 137 irqEnable(IRQ_VBLANK);
131 NDS_SetDisplayMode(_this, &mode); 138 NDS_SetDisplayMode(_this, &mode);
132 printf("-NDS_VideoInit\n"); 139
140 TRACE("-NDS_VideoInit\n");
133 return 0; 141 return 0;
134 } 142 }
135 143
136 static int 144 static int
137 NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode) 145 NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
138 { 146 {
139 printf("+NDS_SetDisplayMode\n"); 147 TRACE("+NDS_SetDisplayMode\n");
140 /* right now this function is just hard-coded for 256x192 ABGR1555 */ 148 /* right now this function is just hard-coded for 256x192 ABGR1555 */
141 videoSetMode(MODE_5_2D | 149 videoSetMode(MODE_5_2D |
142 DISPLAY_BG2_ACTIVE | 150 DISPLAY_BG2_ACTIVE |
143 DISPLAY_BG3_ACTIVE | 151 DISPLAY_BG3_ACTIVE |
144 DISPLAY_BG_EXT_PALETTE | 152 DISPLAY_BG_EXT_PALETTE |
162 videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub 170 videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub
163 TODO: this will change 171 TODO: this will change
164 when multi-head is 172 when multi-head is
165 introduced in render */ 173 introduced in render */
166 174
167 printf("-NDS_SetDisplayMode\n"); 175 TRACE("-NDS_SetDisplayMode\n");
168 return 0; 176 return 0;
169 } 177 }
170 178
171 void 179 void
172 NDS_VideoQuit(_THIS) 180 NDS_VideoQuit(_THIS)
173 { 181 {
174 printf("+NDS_VideoQuit\n"); 182 TRACE("+NDS_VideoQuit\n");
175 videoSetMode(DISPLAY_SCREEN_OFF); 183 videoSetMode(DISPLAY_SCREEN_OFF);
176 videoSetModeSub(DISPLAY_SCREEN_OFF); 184 videoSetModeSub(DISPLAY_SCREEN_OFF);
177 vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD); 185 vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
178 vramSetBankE(VRAM_E_LCD); 186 vramSetBankE(VRAM_E_LCD);
179 vramSetBankF(VRAM_F_LCD); 187 vramSetBankF(VRAM_F_LCD);
180 vramSetBankG(VRAM_G_LCD); 188 vramSetBankG(VRAM_G_LCD);
181 vramSetBankH(VRAM_H_LCD); 189 vramSetBankH(VRAM_H_LCD);
182 vramSetBankI(VRAM_I_LCD); 190 vramSetBankI(VRAM_I_LCD);
183 printf("-NDS_VideoQuit\n"); 191 TRACE("-NDS_VideoQuit\n");
184 } 192 }
185 193
186 /* vi: set ts=4 sw=4 expandtab: */ 194 /* vi: set ts=4 sw=4 expandtab: */