annotate src/video/nds/SDL_ndsrender.c @ 2690:ca01c20274c0 gsoc2008_nds

More work and some bugfixes on the graphics driver.
author Darren Alton <dalton@stevens.edu>
date Sat, 16 Aug 2008 07:44:35 +0000
parents 71c56e900f8b
children 87cfb5fde5db
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
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
45 NDS_OAM_Update(tOAM *oam)
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();
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
48 dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer, OAM,
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
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
65 NDS_OAM_Init(tOAM *oam)
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();
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
77 NDS_OAM_Update(oam);
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,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
124 const SDL_Rect * rect, const void *pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
125 int pitch);
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 */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
147 (SDL_RENDERER_SINGLEBUFFER|SDL_RENDERER_ACCELERATED), /* u32 flags */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
148 (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
149 (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
150 (SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
151 3, /* u32 num_texture_formats */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
152 {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
153 SDL_PIXELFORMAT_INDEX8,
2681
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
154 SDL_PIXELFORMAT_ABGR1555,
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
155 SDL_PIXELFORMAT_BGR555,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
156 }, /* u32 texture_formats[20] */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
157 (256), /* int max_texture_width */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
158 (256), /* int max_texture_height */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
159 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
160 };
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
161
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
162 typedef struct
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
163 {
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
164 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
165 tOAM oam_copy; /* sprites */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
166 u8 bg_taken[4];
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
167 int sub;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
168 } NDS_RenderData;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
169
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
170 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
171 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
172 enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
173 int hw_index; /* sprite: index in the OAM. bg: 2 or 3. */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
174 struct
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
175 {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
176 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
177 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
178 } dim;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
179 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
180 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
181 /*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
182 } NDS_TextureData;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
183
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
184
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
185
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
186 void sdlds_splash() {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
187 int i;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
188 printf("splash!\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
189 BG3_CR = BG_BMP16_256x256|BG_BMP_BASE(0);
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
190 BG3_XDX = 1 << 8; BG3_XDY = 0 << 8;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
191 BG3_YDX = 0 << 8; BG3_YDY = 1 << 8;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
192 BG3_CX = 0 << 8; BG3_CY = 0 << 8;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
193 for(i = 0; i < 256*192; ++i) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
194 ((u16*)BG_BMP_RAM(0))[i] = i|0x8000;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
195 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
196 printf("one... two...\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
197 for(i = 0; i < 120; ++i) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
198 swiWaitForVBlank();
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
199 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
200 for(i = 0; i < 256*192; ++i) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
201 ((u16*)BG_BMP_RAM(0))[i] = 0;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
202 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
203 BG3_CR = 0;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
204 printf("done splash!\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
205 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
206
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
207
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
208 SDL_Renderer *
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
209 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
210 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
211 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
212 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
213 SDL_Renderer *renderer;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
214 NDS_RenderData *data;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
215 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
216 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
217 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
218
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
219 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
220 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
221 &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
222 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
223 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
224 }
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
225 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
226 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
227 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
228 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
229 /* 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
230 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
231 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
232 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
233 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
234 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
235
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
236 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
237 if (!renderer) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
238 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
239 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
240 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
241
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
242 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
243 if (!data) {
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
244 NDS_DestroyRenderer(renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
245 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
246 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
247 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
248 SDL_zerop(data);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
249
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
250 renderer->RenderFill = NDS_RenderFill;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
251 renderer->RenderCopy = NDS_RenderCopy;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
252 renderer->RenderPresent = NDS_RenderPresent;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
253 renderer->DestroyRenderer = NDS_DestroyRenderer;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
254 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
255 renderer->info.flags = 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
256 renderer->window = window->id;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
257 renderer->driverdata = data;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
258 renderer->CreateTexture = NDS_CreateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
259 renderer->QueryTexturePixels = NDS_QueryTexturePixels;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
260 renderer->SetTexturePalette = NDS_SetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
261 renderer->GetTexturePalette = NDS_GetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
262 renderer->SetTextureColorMod = NDS_SetTextureColorMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
263 renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
264 renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
265 renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
266 renderer->UpdateTexture = NDS_UpdateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
267 renderer->LockTexture = NDS_LockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
268 renderer->UnlockTexture = NDS_UnlockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
269 renderer->DirtyTexture = NDS_DirtyTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
270 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
271
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
272 renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
273 renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
274 renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
275 renderer->info.num_texture_formats =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
276 NDS_RenderDriver.info.num_texture_formats;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
277 SDL_memcpy(renderer->info.texture_formats,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
278 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
279 sizeof(renderer->info.texture_formats));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
280 renderer->info.max_texture_width =
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
281 NDS_RenderDriver.info.max_texture_width;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
282 renderer->info.max_texture_height =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
283 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
284
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
285 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
286 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
287 "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
288 if(!data->sub) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
289 data->bg = &BACKGROUND;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
290 } else {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
291 data->bg = &BACKGROUND_SUB;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
292 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
293 data->bg_taken[2] = data->bg_taken[3] = 0;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
294 NDS_OAM_Init(&(data->oam_copy)); /* init sprites. */
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
295
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
296 sdlds_splash();
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
297
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
298 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
299 return renderer;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
300 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
301
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
302 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
303 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
304 {
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 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
306 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
307 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
308 }
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
309
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
310 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
311 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
312 {
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
313 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
314 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
315 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
316 }
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 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
319 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
320 {
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
321 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
322 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
323 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
324 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
325 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
326
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
327 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
328 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
329 (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
330 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
331 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
332 }
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
333
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
334 /* 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
335 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
336 if(texture->w <= 64 && texture->h <= 64) {
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
337 /* TODO: implement sprites similar to how BG's are.
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
338 they have a similar affine transformation matrix
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
339 (hdx,hdy,vdx,vdy) as the backgrounds, so it should
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
340 be similar enough to handle with the same driverdata. */
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
341 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
342 txdat->type = NDSTX_SPR;
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
343 } 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
344 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
345 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
346 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
347 } 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
348 whichbg = 3;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
349 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
350 }
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
351 if(whichbg >= 0) {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
352 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
353 txdat = (NDS_TextureData*)texture->driverdata;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
354 if(!txdat) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
355 SDL_OutOfMemory();
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
356 return -1;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
357 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
358
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
359 /* TODO: maybe this should be in RenderPresent or RenderCopy
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
360 instead, copying from a malloc'd system RAM pixel buffer. */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
361 /* this is hard-coded to being 256x256 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
362 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
363 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
364
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
365 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
366
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
367 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
368 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
369
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
370 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
371 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
372 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
373 txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
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
374 txdat->dim.pitch = 256 * (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
375 txdat->dim.bpp = bpp;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
376 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
377 BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
378 /*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
379 } 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
380 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
381 printf("ran out.\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
382 }
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
383 } 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
384 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
385 }
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
386
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
387 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
388 if (!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
389 SDL_SetError("Couldn't create NDS render driver data.");
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
390 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
391 }
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
392
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
393 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
394 }
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
395
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
396 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
397 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
398 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
399 {
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
400 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
401 TRACE("+NDS_QueryTexturePixels\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
402 *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
403 *pitch = txdat->dim.pitch;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
404 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
405 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
406 }
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
407
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
408 static int
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
409 NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
410 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
411 {
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 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
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 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
414 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
415 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
416
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 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
418 dst =
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
419 (Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
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 rect->x * (txdat->dim.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
421 length = rect->w * (txdat->dim.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
422 for (row = 0; row < rect->h; ++row) {
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 SDL_memcpy(dst, src, length);
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
424 src += pitch;
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 dst += txdat->dim.pitch;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
426 }
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
427
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
428 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
429 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
430 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
431
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
432 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
433 NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
434 const SDL_Rect * rect, int markDirty, void **pixels,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
435 int *pitch)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
436 {
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
437 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
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
438 int i;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
439 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
440 if (markDirty) {
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 printf("wanted to mark dirty\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
442 /* TODO: figure out how to handle this! */
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
443 /*SDL_AddDirtyRect(&txdat->dirty, rect);*/
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
444 }
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
445
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
446 *pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
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
447 * txdat->dim.pitch + rect->x * (txdat->dim.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
448 *pitch = txdat->dim.pitch;
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 printf(" pixels = %08x\n", (u32)*pixels);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
450 printf(" vram = %08x\n", (u32)(txdat->vram_pixels));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
451 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
452 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
453 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
454
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
455 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
456 NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
457 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
458 TRACE("+NDS_UnlockTexture\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
459 /* TODO: should I be doing something here, somehow, now that the 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
460 should have been "written" between LockTexture and this? */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
461 TRACE("-NDS_UnlockTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
462 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
463
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
464 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
465 NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
466 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
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 /* stub */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
469 TRACE("!NDS_DirtyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
470 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
471
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
472 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
473 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
474 Uint8 a, const SDL_Rect * rect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
475 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
476 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
477 SDL_Rect real_rect = *rect;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
478 u16 color;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
479 int i, j;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
480
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
481 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
482 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
483 /* 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
484 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
485 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
486 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
487 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
488 (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
489 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
490 */
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
491
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
492 TRACE("-NDS_RenderFill\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
493 return 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
494 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
495
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
496 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
497 NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
498 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
499 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
500 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
501 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
502 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
503 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
504 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
505 int bpp = SDL_BYTESPERPIXEL(texture->format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
506 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
507
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
508 TRACE("+NDS_RenderCopy\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
509 if(txdat->type == NDSTX_BG) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
510 bg_rotation *tmpbg = (txdat->hw_index == 2) ?
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
511 &(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
512 tmpbg->xdx = txdat->dim.hdx;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
513 tmpbg->xdy = txdat->dim.hdy;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
514 tmpbg->ydx = txdat->dim.vdx;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
515 tmpbg->ydy = txdat->dim.vdy;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
516 tmpbg->centerX = 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
517 tmpbg->centerY = 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
518 } else {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
519 /* sprites not implemented yet */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
520 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
521 printf(" txdat->hw_index = %d\n", txdat->hw_index);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
522 TRACE("-NDS_RenderCopy\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
523
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
524 return 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
525 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
526
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
527
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
528 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
529 NDS_RenderPresent(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
530 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
531 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
532 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
533 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(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
534 int i;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
535 TRACE("+NDS_RenderPresent\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
536
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
537 {
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
538 SDL_Texture * tx = display->textures[i];
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
539 NDS_TextureData * txdat = (NDS_TextureData*)tx->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
540 /* Send the data to the display TODO :
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
541 shouldn't it already be there at this point? from lock/unlock
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
542 giving it the direct address in VRAM of the bg'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
543 I guess set the BG's and sprites "visible" flags here,
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
544 if applicable. */
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
545 }
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
546
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
547 /* vsync for NDS */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
548 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
549 swiWaitForVBlank();
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
550 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
551 TRACE("-NDS_RenderPresent\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
552 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
553
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
554 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
555 NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
556 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
557 TRACE("+NDS_DestroyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
558 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
559 SDL_SetError("Unsupported texture format");
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
560 } else {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
561 /* free anything else allocated for texture */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
562 NDS_TextureData *txdat = texture->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
563 /*SDL_FreeDirtyRects(&txdat->dirty);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
564 SDL_free(txdat);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
565 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
566 TRACE("-NDS_DestroyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
567 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
568
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
569 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
570 NDS_DestroyRenderer(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
571 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
572 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
573 /*SDL_Window *window = SDL_GetWindowFromID(renderer->window);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
574 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
575 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
576
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
577 TRACE("+NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
578 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
579 /* TODO: free anything else relevant. */
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
580 /*for (i = 0; i < SDL_arraysize(data->texture); ++i) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
581 if (data->texture[i]) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
582 DestroyTexture(data->renderer, data->texture[i]);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
583 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
584 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
585 if (data->surface.format) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
586 SDL_SetSurfacePalette(&data->surface, NULL);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
587 SDL_FreeFormat(data->surface.format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
588 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
589 if (display->palette) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
590 SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
591 data);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
592 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
593 SDL_FreeDirtyRects(&data->dirty);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
594 SDL_free(data);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
595 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
596 SDL_free(renderer);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
597 TRACE("-NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
598 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
599
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
600 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
601 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
602 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
603 {
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
604 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
605 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
606 /* 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
607 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
608 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
609 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
610 }
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
611
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
612 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
613 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
614 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
615 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
616 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
617 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
618 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
619 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
620 }
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
621
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
622 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
623 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
624 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
625 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
626 /* 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
627 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
628 }
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
629
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
630 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
631 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
632 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
633 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
634 /* 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
635 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
636 }
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
637
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
638 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
639 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
640 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
641 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
642 /* 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
643 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
644 }
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
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
646 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
647 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
648 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
649 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
650 /* 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
651 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
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
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
654 /* vi: set ts=4 sw=4 expandtab: */