annotate src/video/nds/SDL_ndsrender.c @ 2696:0b395a60deff gsoc2008_nds

Timers work now.
author Darren Alton <dalton@stevens.edu>
date Mon, 18 Aug 2008 07:29:52 +0000
parents c04a266c277a
children e1da92da346c
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
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
23 #include <stdio.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
24 #include <stdlib.h>
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
25 #include <nds.h>
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
26 #include <nds/arm9/video.h>
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
27 #include <nds/arm9/sprite.h>
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
28 #include <nds/arm9/trig_lut.h>
2670
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 #include "SDL_config.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
31
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
32 #include "SDL_video.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
33 #include "../SDL_sysvideo.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
34 #include "../SDL_yuv_sw_c.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
35 #include "../SDL_renderer_sw.h"
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
36
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
37 #define TRACE
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
38 //#define TRACE printf
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
39
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
40 /* NDS sprite-related functions */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
41 #define SPRITE_DMA_CHANNEL 3
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
42 #define SPRITE_ANGLE_MASK 0x01FF
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
43
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
44 void
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
45 NDS_OAM_Update(tOAM *oam, int 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: 2687
diff changeset
46 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
47 DC_FlushAll();
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
48 dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer, sub?OAM_SUB:OAM,
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
49 SPRITE_COUNT * sizeof(SpriteEntry));
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
50 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
51
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
52 void
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
53 NDS_OAM_RotateSprite(SpriteRotation *spriteRotation, u16 angle)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
54 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
55 s16 s = SIN[angle & SPRITE_ANGLE_MASK] >> 4;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
56 s16 c = COS[angle & SPRITE_ANGLE_MASK] >> 4;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
57
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
58 spriteRotation->hdx = c;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
59 spriteRotation->hdy = s;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
60 spriteRotation->vdx = -s;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
61 spriteRotation->vdy = c;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
62 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
63
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
64 void
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
65 NDS_OAM_Init(tOAM *oam, int 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: 2687
diff changeset
66 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
67 int i;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
68 for(i = 0; i < SPRITE_COUNT; i++) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
69 oam->spriteBuffer[i].attribute[0] = ATTR0_DISABLED;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
70 oam->spriteBuffer[i].attribute[1] = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
71 oam->spriteBuffer[i].attribute[2] = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
72 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
73 for(i = 0; i < MATRIX_COUNT; i++) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
74 NDS_OAM_RotateSprite(&(oam->matrixBuffer[i]), 0);
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
75 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
76 swiWaitForVBlank();
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
77 NDS_OAM_Update(oam, 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: 2687
diff changeset
78 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
79
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
80 void
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
81 NDS_OAM_HideSprite(SpriteEntry *spriteEntry)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
82 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
83 spriteEntry->isRotoscale = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
84 spriteEntry->isHidden = 1;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
85 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
86
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
87 void
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
88 NDS_OAM_ShowSprite(SpriteEntry *spriteEntry, int affine, int double_bound)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
89 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
90 if (affine) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
91 spriteEntry->isRotoscale = 1;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
92 spriteEntry->rsDouble = double_bound;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
93 } else {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
94 spriteEntry->isHidden = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
95 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
96 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
97
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
98
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
99 /* SDL NDS renderer implementation */
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
100
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
101 static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
102 static int NDS_ActivateRenderer(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
103 static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
104 static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
105 static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
106 SDL_Texture * texture, void **pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
107 int *pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
108 static int NDS_SetTexturePalette(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
109 SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
110 const SDL_Color * colors, int firstcolor,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
111 int ncolors);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
112 static int NDS_GetTexturePalette(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
113 SDL_Texture * texture, SDL_Color * colors,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
114 int firstcolor, int ncolors);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
115 static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
116 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
117 static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
118 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
119 static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
120 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
121 static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
122 SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
123 static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
124 const SDL_Rect * rect, const void *pixels,
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
125 int pitch);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
126 static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
127 const SDL_Rect * rect, int markDirty, void **pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
128 int *pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
129 static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
130 static void NDS_DirtyTexture(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
131 SDL_Texture * texture, int numrects,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
132 const SDL_Rect * rects);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
133 static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
134 Uint8 b, Uint8 a, const SDL_Rect * rect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
135 static int NDS_RenderCopy(SDL_Renderer * renderer,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
136 SDL_Texture * texture,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
137 const SDL_Rect * srcrect,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
138 const SDL_Rect * dstrect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
139 static void NDS_RenderPresent(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
140 static void NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
141 static void NDS_DestroyRenderer(SDL_Renderer * renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
142
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
143
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
144 SDL_RenderDriver NDS_RenderDriver = {
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
145 NDS_CreateRenderer,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
146 { "nds", /* char* name */
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
147 (SDL_RENDERER_SINGLEBUFFER |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
148 SDL_RENDERER_ACCELERATED |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
149 SDL_RENDERER_PRESENTDISCARD |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
150 SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
151 (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
152 (SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
153 (SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
154 3, /* u32 num_texture_formats */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
155 {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
156 SDL_PIXELFORMAT_INDEX8,
2681
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
157 SDL_PIXELFORMAT_ABGR1555,
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
158 SDL_PIXELFORMAT_BGR555,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
159 }, /* u32 texture_formats[20] */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
160 (256), /* int max_texture_width */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
161 (256), /* int max_texture_height */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
162 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
163 };
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
164
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
165 typedef struct
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
166 {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
167 bg_attribute *bg; /* backgrounds */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
168 tOAM oam_copy; /* sprites */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
169 u8 bg_taken[4];
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
170 int sub;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
171 } NDS_RenderData;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
172
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
173 typedef struct
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
174 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
175 enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
176 int hw_index; /* sprite: index in the OAM. / bg: 2 or 3. */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
177 struct
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
178 {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
179 int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
180 int pitch, bpp; /* some useful info */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
181 } dim;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
182 u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
183 u16 *vram_palette; /* where the palette data is stored if it's indexed.*/
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
184 /*int size;*/
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
185 } NDS_TextureData;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
186
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
187
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
188
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
189 SDL_Renderer *
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
190 NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
191 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
192 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
193 SDL_DisplayMode *displayMode = &display->current_mode;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
194 SDL_Renderer *renderer;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
195 NDS_RenderData *data;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
196 int i, n;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
197 int bpp;
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
198 Uint32 Rmask, Gmask, Bmask, Amask;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
199
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
200 TRACE("+NDS_CreateRenderer\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
201 if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
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
202 &Rmask, &Gmask, &Bmask, &Amask)) {
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
203 SDL_SetError("Unknown display format");
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
204 return NULL;
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
205 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
206 switch(displayMode->format) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
207 case SDL_PIXELFORMAT_INDEX8:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
208 case SDL_PIXELFORMAT_ABGR1555:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
209 case SDL_PIXELFORMAT_BGR555:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
210 /* okay */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
211 break;
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
212 case SDL_PIXELFORMAT_RGB555:
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
213 case SDL_PIXELFORMAT_RGB565:
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
214 case SDL_PIXELFORMAT_ARGB1555:
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
215 /* we'll take these too for now */
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
216 break;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
217 default:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
218 printf("DEBUG: wrong display format!\n");
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
219 break;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
220 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
221
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
222 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
223 if (!renderer) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
224 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
225 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
226 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
227
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
228 data = (NDS_RenderData *) SDL_malloc(sizeof(*data));
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
229 if (!data) {
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
230 NDS_DestroyRenderer(renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
231 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
232 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
233 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
234 SDL_zerop(data);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
235
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
236 renderer->RenderFill = NDS_RenderFill;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
237 renderer->RenderCopy = NDS_RenderCopy;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
238 renderer->RenderPresent = NDS_RenderPresent;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
239 renderer->DestroyRenderer = NDS_DestroyRenderer;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
240 renderer->info.name = NDS_RenderDriver.info.name;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
241 renderer->info.flags = 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
242 renderer->window = window->id;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
243 renderer->driverdata = data;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
244 renderer->CreateTexture = NDS_CreateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
245 renderer->QueryTexturePixels = NDS_QueryTexturePixels;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
246 renderer->SetTexturePalette = NDS_SetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
247 renderer->GetTexturePalette = NDS_GetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
248 renderer->SetTextureColorMod = NDS_SetTextureColorMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
249 renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
250 renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
251 renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
252 renderer->UpdateTexture = NDS_UpdateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
253 renderer->LockTexture = NDS_LockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
254 renderer->UnlockTexture = NDS_UnlockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
255 renderer->DirtyTexture = NDS_DirtyTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
256 renderer->DestroyTexture = NDS_DestroyTexture;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
257
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
258 renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
259 renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
260 renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
261 renderer->info.num_texture_formats =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
262 NDS_RenderDriver.info.num_texture_formats;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
263 SDL_memcpy(renderer->info.texture_formats,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
264 NDS_RenderDriver.info.texture_formats,
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
265 sizeof(renderer->info.texture_formats));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
266 renderer->info.max_texture_width =
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
267 NDS_RenderDriver.info.max_texture_width;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
268 renderer->info.max_texture_height =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
269 NDS_RenderDriver.info.max_texture_height;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
270
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
271 data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
272 figure out how to detect whether to set it to
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
273 "sub" screen. window->id, perhaps? */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
274 if(!data->sub) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
275 data->bg = &BACKGROUND;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
276 } else {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
277 data->bg = &BACKGROUND_SUB;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
278 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
279 data->bg_taken[2] = data->bg_taken[3] = 0;
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
280
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
281 NDS_OAM_Init(&(data->oam_copy), data->sub); /* init sprites. */
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
282
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
283 TRACE("-NDS_CreateRenderer\n");
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
284 return renderer;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
285 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
286
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
287 static int
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
288 NDS_ActivateRenderer(SDL_Renderer * renderer)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
289 {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
290 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
291 TRACE("!NDS_ActivateRenderer\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
292 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
293 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
294
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
295 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
296 NDS_DisplayModeChanged(SDL_Renderer * renderer)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
297 {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
298 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
299 TRACE("!NDS_DisplayModeChanged\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
300 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
301 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
302
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
303 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
304 NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
305 {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
306 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
307 NDS_TextureData *txdat = NULL;
2682
f7594fc66bda Some debug work on the video driver, shows an error in the BG's vertical placement
Darren Alton <dalton@stevens.edu>
parents: 2681
diff changeset
308 int i;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
309 int bpp;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
310 Uint32 Rmask, Gmask, Bmask, Amask;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
311
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
312 TRACE("+NDS_CreateTexture\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
313 if (!SDL_PixelFormatEnumToMasks
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
314 (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
315 SDL_SetError("Unknown texture format");
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
316 return -1;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
317 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
318
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
319 /* conditional statements on w/h to place it as bg/sprite
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
320 depending on which one it fits. */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
321 if(texture->w <= 64 && texture->h <= 64) {
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
322 int whichspr = -1;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
323 printf("Tried to make a sprite.\n");
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
324 txdat->type = NDSTX_SPR;
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
325 for(i = 0; i < SPRITE_COUNT; ++i) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
326 if(data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
327 whichspr = i;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
328 break;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
329 }
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
330 }
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
331 if(whichspr >= 0) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
332 SpriteEntry *sprent = &(data->oam_copy.spriteBuffer[whichspr]);
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
333 int maxside = texture->w > texture->h ? texture->w : texture->h;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
334 int pitch;
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
335
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
336 texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
337 txdat = (NDS_TextureData*)texture->driverdata;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
338 if(!txdat) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
339 SDL_OutOfMemory();
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
340 return -1;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
341 }
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
342
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
343 sprent->objMode = OBJMODE_BITMAP;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
344 sprent->posX = 0; sprent->posY = 0;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
345 sprent->colMode = OBJCOLOR_16; /* OBJCOLOR_256 for INDEX8 */
2694
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
346
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
347 /* the first 32 sprites get transformation matrices.
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
348 first come, first served */
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
349 if(whichspr < MATRIX_COUNT) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
350 sprent->isRotoscale = 1;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
351 sprent->rsMatrixIdx = whichspr;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
352 }
2694
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
353
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
354 /* containing shape (square or 2:1 rectangles) */
2694
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
355 sprent->objShape = OBJSHAPE_SQUARE;
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
356 if(texture->w/2 >= texture->h) {
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
357 sprent->objShape = OBJSHAPE_WIDE;
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
358 } else if(texture->h/2 >= texture->w) {
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
359 sprent->objShape = OBJSHAPE_TALL;
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
360 }
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
361
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
362 /* size in pixels */
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
363 /* FIXME: "pitch" is hardcoded for 2bytes per pixel. */
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
364 sprent->objSize = OBJSIZE_64;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
365 pitch = 128;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
366 if(maxside <= 8) {
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
367 sprent->objSize = OBJSIZE_8;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
368 pitch = 16;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
369 } else if(maxside <= 16) {
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
370 sprent->objSize = OBJSIZE_16;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
371 pitch = 32;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
372 } else if(maxside <= 32) {
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
373 sprent->objSize = OBJSIZE_32;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
374 pitch = 64;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
375 }
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
376
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
377 /* FIXME: this is hard-coded and will obviously only work for one
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
378 sprite-texture. tells it to look at the beginning of SPRITE_GFX
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
379 for its pixels. */
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
380 sprent->tileIdx = 0;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
381
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
382 /* now for the texture data */
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
383 txdat->type = NDSTX_SPR;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
384 txdat->hw_index = whichspr;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
385 txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
386 txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
387 txdat->dim.pitch = pitch;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
388 txdat->dim.bpp = bpp;
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
389 txdat->vram_pixels = (u16*)(data->sub ?
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
390 SPRITE_GFX_SUB : SPRITE_GFX); /* FIXME: use tileIdx*boundary
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
391 to point to proper location */
2694
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
392 } else {
c1c7cb1b5a47 More sprite-work in the render driver, and some updates to the nds-test-progs.
Darren Alton <dalton@stevens.edu>
parents: 2693
diff changeset
393 SDL_SetError("Out of NDS sprites.");
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
394 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
395 } else if(texture->w <= 256 && texture->h <= 256) {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
396 int whichbg = -1, base = 0;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
397 if(!data->bg_taken[2]) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
398 whichbg = 2;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
399 } else if(!data->bg_taken[3]) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
400 whichbg = 3;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
401 base = 4;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
402 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
403 if(whichbg >= 0) {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
404 texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
405 txdat = (NDS_TextureData*)texture->driverdata;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
406 if(!txdat) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
407 SDL_OutOfMemory();
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
408 return -1;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
409 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
410
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
411 /* this is hard-coded to being 256x256 ABGR1555 for now. */
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
412 data->bg->control[whichbg] = (bpp == 8) ?
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
413 BG_BMP8_256x256 : BG_BMP16_256x256;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
414
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
415 data->bg->control[whichbg] |= BG_BMP_BASE(base);
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
416
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
417 data->bg->scroll[whichbg].x = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
418 data->bg->scroll[whichbg].y = 0;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
419
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
420 txdat->type = NDSTX_BG;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
421 txdat->hw_index = whichbg;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
422 txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
423 txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
424 txdat->dim.pitch = 512;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
425 txdat->dim.bpp = bpp;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
426 txdat->vram_pixels = (u16*)(data->sub ?
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
427 BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
428
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
429 /*txdat->size = txdat->dim.pitch * texture->h;*/
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
430 } else {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
431 SDL_SetError("Out of NDS backgrounds.");
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
432 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
433 } else {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
434 SDL_SetError("Texture too big for NDS hardware.");
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
435 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
436
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
437 TRACE("-NDS_CreateTexture\n");
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
438 if (!texture->driverdata) {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
439 return -1;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
440 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
441
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
442 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
443 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
444
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
445 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
446 NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
447 void **pixels, int *pitch)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
448 {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
449 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
450 TRACE("+NDS_QueryTexturePixels\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
451 *pixels = txdat->vram_pixels;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
452 *pitch = txdat->dim.pitch;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
453 TRACE("-NDS_QueryTexturePixels\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
454 return 0;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
455 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
456
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
457 static int
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
458 NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
459 const SDL_Rect * rect, const void *pixels, int pitch)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
460 {
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
461 NDS_TextureData *txdat;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
462 Uint8 *src, *dst;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
463 int row; size_t length;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
464 TRACE("+NDS_UpdateTexture\n");
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
465
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
466 txdat = (NDS_TextureData *) texture->driverdata;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
467
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
468 src = (Uint8 *) pixels;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
469 dst =
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
470 (Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
471 rect->x * ((txdat->dim.bpp+1)/8);
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
472 length = rect->w * ((txdat->dim.bpp+1)/8);
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
473
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
474 if(rect->w == texture->w) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
475 dmaCopy(src, dst, length*rect->h);
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
476 } else {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
477 for (row = 0; row < rect->h; ++row) {
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
478 dmaCopy(src, dst, length);
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
479 src += pitch;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
480 dst += txdat->dim.pitch;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
481 }
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
482 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
483
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
484 TRACE("-NDS_UpdateTexture\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
485 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
486 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
487
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
488 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
489 NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
490 const SDL_Rect * rect, int markDirty, void **pixels,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
491 int *pitch)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
492 {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
493 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
494 TRACE("+NDS_LockTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
495
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
496 *pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
497 * txdat->dim.pitch + rect->x * ((txdat->dim.bpp+1)/8));
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
498 *pitch = txdat->dim.pitch;
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
499
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
500 TRACE("-NDS_LockTexture\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
501 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
502 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
503
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
504 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
505 NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
506 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
507 TRACE("+NDS_UnlockTexture\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
508 TRACE("-NDS_UnlockTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
509 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
510
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
511 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
512 NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
513 int numrects, const SDL_Rect * rects)
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
514 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
515 /* stub */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
516 TRACE("!NDS_DirtyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
517 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
518
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
519 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
520 NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
521 Uint8 a, const SDL_Rect * rect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
522 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
523 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
524 SDL_Rect real_rect = *rect;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
525 u16 color;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
526 int i, j;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
527
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
528 TRACE("+NDS_RenderFill\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
529 color = RGB8(r,g,b); /* <-- macro in libnds that makes an ARGB1555 pixel */
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
530 /* TODO: make a single-color sprite and stretch it.
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
531 calculate the "HDX" width modifier of the sprite by:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
532 let S be the actual sprite's width (like, 32 pixels for example)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
533 let R be the rectangle's width (maybe 50 pixels)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
534 HDX = (R<<8) / S;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
535 (it's fixed point, hence the bit shift. same goes for vertical.
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
536 be sure to use 32-bit int's for the bit shift before the division!)
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
537 */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
538
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
539 TRACE("-NDS_RenderFill\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
540 return 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
541 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
542
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
543 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
544 NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
545 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
546 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
547 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
548 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2687
5166b19b6808 renderer: Added a separate copy of texture pixels in system RAM, copied into VRAM during RenderPresent. Still trying to fix rendering.
Darren Alton <dalton@stevens.edu>
parents: 2685
diff changeset
549 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
5166b19b6808 renderer: Added a separate copy of texture pixels in system RAM, copied into VRAM during RenderPresent. Still trying to fix rendering.
Darren Alton <dalton@stevens.edu>
parents: 2685
diff changeset
550 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
551 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
552 int bpp = SDL_BYTESPERPIXEL(texture->format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
553 int pitch = txdat->dim.pitch;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
554
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
555 TRACE("+NDS_RenderCopy\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
556 if(txdat->type == NDSTX_BG) {
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
557 bg_rotation *bgrot = (txdat->hw_index == 2) ?
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
558 &(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
559 bgrot->xdx = txdat->dim.hdx;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
560 bgrot->xdy = txdat->dim.hdy;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
561 bgrot->ydx = txdat->dim.vdx;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
562 bgrot->ydy = txdat->dim.vdy;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
563 bgrot->centerX = 0;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
564 bgrot->centerY = 0;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
565
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
566 data->bg->scroll[txdat->hw_index].x = dstrect->x;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
567 data->bg->scroll[txdat->hw_index].y = dstrect->y;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
568 } else {
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
569 /* sprites not fully implemented yet */
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
570 SpriteEntry *spr = &(data->oam_copy.spriteBuffer[txdat->hw_index]);
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
571 spr->posX = dstrect->x;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
572 spr->posY = dstrect->y;
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
573 if(txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) {
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
574 SpriteRotation *sprot = &(data->oam_copy.matrixBuffer[txdat->hw_index]);
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
575 sprot->hdx = txdat->dim.hdx;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
576 sprot->hdy = txdat->dim.hdy;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
577 sprot->vdx = txdat->dim.vdx;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
578 sprot->vdy = txdat->dim.vdy;
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
579 }
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
580 printf("tried to RenderCopy a sprite.\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
581 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
582 TRACE("-NDS_RenderCopy\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
583
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
584 return 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
585 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
586
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
587
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
588 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
589 NDS_RenderPresent(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
590 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
591 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2687
5166b19b6808 renderer: Added a separate copy of texture pixels in system RAM, copied into VRAM during RenderPresent. Still trying to fix rendering.
Darren Alton <dalton@stevens.edu>
parents: 2685
diff changeset
592 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
5166b19b6808 renderer: Added a separate copy of texture pixels in system RAM, copied into VRAM during RenderPresent. Still trying to fix rendering.
Darren Alton <dalton@stevens.edu>
parents: 2685
diff changeset
593 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
594
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
595 TRACE("+NDS_RenderPresent\n");
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
596 /* update sprites */
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
597 NDS_OAM_Update(&(data->oam_copy), data->sub);
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
598 /* vsync for NDS */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
599 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
600 swiWaitForVBlank();
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
601 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
602 TRACE("-NDS_RenderPresent\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
603 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
604
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
605 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
606 NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
607 {
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
608 NDS_TextureData *txdat = texture->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
609 TRACE("+NDS_DestroyTexture\n");
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
610 /* free anything else allocated for texture */
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
611 /*SDL_FreeDirtyRects(&txdat->dirty);*/
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
612 SDL_free(txdat);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
613 TRACE("-NDS_DestroyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
614 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
615
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
616 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
617 NDS_DestroyRenderer(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
618 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
619 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
620 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
621 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
622 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
623
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
624 TRACE("+NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
625 if (data) {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
626 /* TODO: free anything else relevant. */
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
627 /*if (data->surface.format) {
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
628 SDL_SetSurfacePalette(&data->surface, NULL);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
629 SDL_FreeFormat(data->surface.format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
630 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
631 if (display->palette) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
632 SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
633 data);
2693
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
634 }*/
bae97b6ac32b Beginnings of sprite support.
Darren Alton <dalton@stevens.edu>
parents: 2692
diff changeset
635 /*SDL_FreeDirtyRects(&data->dirty);*/
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
636 SDL_free(data);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
637 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
638 SDL_free(renderer);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
639 TRACE("-NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
640 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
641
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
642 static int
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
643 NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
644 const SDL_Color * colors, int firstcolor, int ncolors)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
645 {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
646 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
647 TRACE("+NDS_SetTexturePalette\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
648 /* set 8-bit modes in the background control registers
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
649 for backgrounds, BGn_CR |= BG_256_COLOR */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
650 TRACE("-NDS_SetTexturePalette\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
651 return 0;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
652 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
653
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
654 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
655 NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
656 SDL_Color * colors, int firstcolor, int ncolors)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
657 {
2695
c04a266c277a More sprite-driven texture work in the render/video drivers.
Darren Alton <dalton@stevens.edu>
parents: 2694
diff changeset
658 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
2696
0b395a60deff Timers work now.
Darren Alton <dalton@stevens.edu>
parents: 2695
diff changeset
659 TRACE("!NDS_GetTexturePalette\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
660 return 0;
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
661 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
662
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
663 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
664 NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
665 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
666 TRACE("!NDS_SetTextureColorMod\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
667 /* stub! */
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
668 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
669 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
670
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
671 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
672 NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
673 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
674 TRACE("!NDS_SetTextureAlphaMod\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
675 /* stub! */
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
676 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
677 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
679 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
680 NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
681 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
682 TRACE("!NDS_SetTextureBlendMode\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
683 /* stub! */
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
684 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
685 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
686
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
687 static int
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
688 NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
689 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
690 TRACE("!NDS_SetTextureScaleMode\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
691 /* stub! (note: NDS hardware scaling is nearest neighbor.) */
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
692 return 0;
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
693 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
694
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
695 /* vi: set ts=4 sw=4 expandtab: */