annotate src/video/nds/SDL_ndsvideo.c @ 2688:71c56e900f8b gsoc2008_nds

Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
author Darren Alton <dalton@stevens.edu>
date Fri, 15 Aug 2008 10:17:07 +0000
parents f7594fc66bda
children ca01c20274c0
rev   line source
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
1 /*
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
4
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
9
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
13 Lesser General Public License for more details.
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
14
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
18
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
19 Sam Lantinga
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
20 slouken@libsdl.org
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
21 */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
22 #include "SDL_config.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
23
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
24 /* SDL Nintendo DS video driver implementation
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
25 * based on dummy driver:
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
26 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
27 * of this was cut-and-pasted from Stephane Peter's work in the AAlib
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
28 * SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
29 */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
30
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
31 #include <stdio.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
32 #include <stdlib.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
33 #include <nds.h>
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
34 #include <nds/arm9/video.h>
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
35
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
36 #include "SDL_video.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
37 #include "SDL_mouse.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
38 #include "../SDL_sysvideo.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
39 #include "../SDL_pixels_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
40 #include "../../events/SDL_events_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
41
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
42 #include "SDL_ndsvideo.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
43 #include "SDL_ndsevents_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
44 #include "SDL_ndsrender_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
45
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
46 #define NDSVID_DRIVER_NAME "nds"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
47
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
48 /* Initialization/Query functions */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
49 static int NDS_VideoInit(_THIS);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
50 static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
51 static void NDS_VideoQuit(_THIS);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
52
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
53
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
54 /* SDL NDS driver bootstrap functions */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
55 static int
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
56 NDS_Available(void)
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
57 {
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
58 /*const char *envr = SDL_getenv("SDL_VIDEODRIVER");*/
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
59 /*printf("NDS_Available()\n"); */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
60 return (1);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
61 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
62
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
63 static void
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
64 NDS_DeleteDevice(SDL_VideoDevice * device)
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
65 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
66 SDL_free(device);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
67 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
68
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
69 static SDL_VideoDevice *
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
70 NDS_CreateDevice(int devindex)
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
71 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
72 SDL_VideoDevice *device;
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
73 /*printf("NDS_CreateDevice(%d)\n", devindex); */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
74
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
75 printf("+NDS_CreateDevice\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
76 /* Initialize all variables that we clean on shutdown */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
77 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
78 if (!device) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
79 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
80 if (device) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
81 SDL_free(device);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
82 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
83 return (0);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
84 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
85
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
86 /* Set the function pointers */
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
87 device->VideoInit = NDS_VideoInit;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
88 device->VideoQuit = NDS_VideoQuit;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
89 device->SetDisplayMode = NDS_SetDisplayMode;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
90 device->PumpEvents = NDS_PumpEvents;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
91
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
92 device->num_displays = 2; /* DS = dual screens */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
93
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
94 device->free = NDS_DeleteDevice;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
95
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
96 printf("-NDS_CreateDevice\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
97 return device;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
98 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
99
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
100 VideoBootStrap NDS_bootstrap = {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
101 NDSVID_DRIVER_NAME, "SDL NDS video driver",
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
102 NDS_Available, NDS_CreateDevice
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
103 };
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
104
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
105 int
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
106 NDS_VideoInit(_THIS)
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
107 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
108 SDL_DisplayMode mode;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
109 int i;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
110
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
111 printf("+NDS_VideoInit\n");
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
112 /* simple 256x192x16x60 for now */
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
113 mode.w = 256;
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
114 mode.h = 192;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
115 mode.format = SDL_PIXELFORMAT_ABGR1555;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
116 mode.refresh_rate = 60;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
117 mode.driverdata = NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
118
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
119 SDL_AddBasicVideoDisplay(&mode);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
120 SDL_AddRenderDriver(0, &NDS_RenderDriver);
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
121 /*SDL_AddBasicVideoDisplay(&mode); two screens, same mode. uncomment later
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
122 SDL_AddRenderDriver(1, &NDS_RenderDriver);*/
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
123
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
124 SDL_zero(mode);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
125 SDL_AddDisplayMode(0, &mode);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
126
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
127 /* hackish stuff to get things up and running for now, and for a console */
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
128 powerON(POWER_ALL_2D);
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
129 irqInit();
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
130 irqEnable(IRQ_VBLANK);
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
131 NDS_SetDisplayMode(_this, &mode);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
132 printf("-NDS_VideoInit\n");
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
133 return 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
134 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
135
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
136 static int
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
137 NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
138 {
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
139 printf("+NDS_SetDisplayMode\n");
2681
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
140 /* right now this function is just hard-coded for 256x192 ABGR1555 */
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
141 videoSetMode(MODE_5_2D |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
142 DISPLAY_BG2_ACTIVE |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
143 DISPLAY_BG3_ACTIVE |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
144 DISPLAY_BG_EXT_PALETTE |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
145 DISPLAY_SPR_1D_LAYOUT |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
146 DISPLAY_SPR_ACTIVE |
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
147 DISPLAY_SPR_EXT_PALETTE); /* display on main core
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
148 with lots of flags set for
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
149 flexibility/capacity to render */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
150
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
151 /* hopefully these cover all the various things we might need to do */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
152 vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
153 vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
154 vramSetBankC(VRAM_C_SUB_BG_0x06200000);
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents: 2679
diff changeset
155 vramSetBankD(VRAM_D_MAIN_BG_0x06040000); /* not a typo. vram d can't sub */
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
156 vramSetBankE(VRAM_E_MAIN_SPRITE);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
157 vramSetBankF(VRAM_F_OBJ_EXT_PALETTE);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
158 vramSetBankG(VRAM_G_BG_EXT_PALETTE);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
159 vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
160 vramSetBankI(VRAM_I_SUB_SPRITE);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
161
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
162 videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
163 TODO: this will change
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
164 when multi-head is
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
165 introduced in render */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
166
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
167 printf("-NDS_SetDisplayMode\n");
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
168 return 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
169 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
170
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
171 void
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
172 NDS_VideoQuit(_THIS)
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
173 {
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
174 printf("+NDS_VideoQuit\n");
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
175 videoSetMode(DISPLAY_SCREEN_OFF);
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
176 videoSetModeSub(DISPLAY_SCREEN_OFF);
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
177 vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
178 vramSetBankE(VRAM_E_LCD);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
179 vramSetBankF(VRAM_F_LCD);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
180 vramSetBankG(VRAM_G_LCD);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
181 vramSetBankH(VRAM_H_LCD);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2682
diff changeset
182 vramSetBankI(VRAM_I_LCD);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
183 printf("-NDS_VideoQuit\n");
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
184 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
185