annotate src/video/nds/SDL_ndsrender.c @ 2691:87cfb5fde5db gsoc2008_nds

Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
author Darren Alton <dalton@stevens.edu>
date Sat, 16 Aug 2008 11:05:50 +0000
parents ca01c20274c0
children cd8978f47849
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,
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
124 const SDL_Rect * rect, const void *pixels,
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
125 int pitch);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
126 static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
127 const SDL_Rect * rect, int markDirty, void **pixels,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
128 int *pitch);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
129 static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
130 static void NDS_DirtyTexture(SDL_Renderer * renderer,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
131 SDL_Texture * texture, int numrects,
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
132 const SDL_Rect * rects);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
133 static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
134 Uint8 b, Uint8 a, const SDL_Rect * rect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
135 static int NDS_RenderCopy(SDL_Renderer * renderer,
2671
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
136 SDL_Texture * texture,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
137 const SDL_Rect * srcrect,
c3e7c0698cbb some changes to the dummy driver for debug purposes that should be reverted.
Darren Alton <dalton@stevens.edu>
parents: 2670
diff changeset
138 const SDL_Rect * dstrect);
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
139 static void NDS_RenderPresent(SDL_Renderer * renderer);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
140 static void NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
141 static void NDS_DestroyRenderer(SDL_Renderer * renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
142
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
143
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
144 SDL_RenderDriver NDS_RenderDriver = {
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
145 NDS_CreateRenderer,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
146 { "nds", /* char* name */
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
147 (SDL_RENDERER_SINGLEBUFFER |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
148 SDL_RENDERER_ACCELERATED |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
149 SDL_RENDERER_PRESENTDISCARD |
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
150 SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
151 (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
152 (SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
153 (SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
154 3, /* u32 num_texture_formats */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
155 {
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
156 SDL_PIXELFORMAT_INDEX8,
2681
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
157 SDL_PIXELFORMAT_ABGR1555,
c15b6c758be5 Some small bug fixes and more work on video
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
158 SDL_PIXELFORMAT_BGR555,
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
159 }, /* u32 texture_formats[20] */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
160 (256), /* int max_texture_width */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
161 (256), /* int max_texture_height */
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
162 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
163 };
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
164
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
165 typedef struct
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
166 {
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
167 bg_attribute *bg; /* backgrounds */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
168 tOAM oam_copy; /* sprites */
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
169 u8 bg_taken[4];
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
170 int sub;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
171 } NDS_RenderData;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
172
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
173 typedef struct
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
174 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
175 enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
176 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
177 struct
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
178 {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
179 int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
180 int pitch, bpp; /* some useful info */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
181 } dim;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
182 u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
183 u16 *vram_palette; /* where the palette data is stored if it's indexed.*/
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
184 /*int size;*/
2678
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
185 } NDS_TextureData;
2672
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
186
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
187
74ac057679d5 NDS video driver is now functional, using software rendering and framebuffer.
Darren Alton <dalton@stevens.edu>
parents: 2671
diff changeset
188
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
189 SDL_Renderer *
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
190 NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
191 {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
192 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
193 SDL_DisplayMode *displayMode = &display->current_mode;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
194 SDL_Renderer *renderer;
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
195 NDS_RenderData *data;
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
196 int i, n;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
197 int bpp;
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
198 Uint32 Rmask, Gmask, Bmask, Amask;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
199
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
200 TRACE("+NDS_CreateRenderer\n");
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
201 if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
2673
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
202 &Rmask, &Gmask, &Bmask, &Amask)) {
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
203 SDL_SetError("Unknown display format");
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
204 return NULL;
24a6b3588eac Cleaned up and added joypad support from 1.2.9 NDS port. Also some minor video driver bugfixes.
Darren Alton <dalton@stevens.edu>
parents: 2672
diff changeset
205 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
206 switch(displayMode->format) {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
207 case SDL_PIXELFORMAT_INDEX8:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
208 case SDL_PIXELFORMAT_ABGR1555:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
209 case SDL_PIXELFORMAT_BGR555:
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
210 /* okay */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
211 break;
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
212 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
213 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
214 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
215 }
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
216
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
217 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
218 if (!renderer) {
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
219 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
220 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
221 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
222
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
223 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
224 if (!data) {
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
225 NDS_DestroyRenderer(renderer);
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
226 SDL_OutOfMemory();
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
227 return NULL;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
228 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
229 SDL_zerop(data);
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
230
2677
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
231 renderer->RenderFill = NDS_RenderFill;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
232 renderer->RenderCopy = NDS_RenderCopy;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
233 renderer->RenderPresent = NDS_RenderPresent;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
234 renderer->DestroyRenderer = NDS_DestroyRenderer;
6386764eb222 Starting to work on a more complete video driver.
Darren Alton <dalton@stevens.edu>
parents: 2673
diff changeset
235 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
236 renderer->info.flags = 0;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
237 renderer->window = window->id;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
238 renderer->driverdata = data;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
239 renderer->CreateTexture = NDS_CreateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
240 renderer->QueryTexturePixels = NDS_QueryTexturePixels;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
241 renderer->SetTexturePalette = NDS_SetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
242 renderer->GetTexturePalette = NDS_GetTexturePalette;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
243 renderer->SetTextureColorMod = NDS_SetTextureColorMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
244 renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
245 renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
246 renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
247 renderer->UpdateTexture = NDS_UpdateTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
248 renderer->LockTexture = NDS_LockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
249 renderer->UnlockTexture = NDS_UnlockTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
250 renderer->DirtyTexture = NDS_DirtyTexture;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
251 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
252
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
253 renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
254 renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
255 renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
256 renderer->info.num_texture_formats =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
257 NDS_RenderDriver.info.num_texture_formats;
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
258 SDL_memcpy(renderer->info.texture_formats,
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
259 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
260 sizeof(renderer->info.texture_formats));
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
261 renderer->info.max_texture_width =
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
262 NDS_RenderDriver.info.max_texture_width;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
263 renderer->info.max_texture_height =
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
264 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
265
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
266 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
267 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
268 "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
269 if(!data->sub) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
270 data->bg = &BACKGROUND;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
271 } else {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
272 data->bg = &BACKGROUND_SUB;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
273 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
274 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
275 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
276
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
277 TRACE("-NDS_CreateRenderer\n");
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
278 printf("renderer is %x\n", (u32)(renderer->UpdateTexture));
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
279 return renderer;
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
280 }
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
281
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
282 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
283 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
284 {
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
285 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
286 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
287 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
288 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
289
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
290 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
291 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
292 {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
293 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
294 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
295 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
296 }
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
297
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
298 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
299 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
300 {
3895761db26a Removed old touchscreen system, starting to implement mouse-based touchscreen. Also, more work on a non-software-rendering video driver
Darren Alton <dalton@stevens.edu>
parents: 2677
diff changeset
301 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2679
bc3e3e889f6d More NDS video driver work.
Darren Alton <dalton@stevens.edu>
parents: 2678
diff changeset
302 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
303 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
304 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
305 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
306
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
307 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
308 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
309 (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
310 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
311 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
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
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
314 /* 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
315 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
316 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
317 /* 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
318 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
319 (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
320 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
321 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
322 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
323 } 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
324 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
325 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
326 whichbg = 2;
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
327 data->bg->bg2_rotation.xdx = 0x100;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
328 data->bg->bg2_rotation.xdy = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
329 data->bg->bg2_rotation.ydx = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
330 data->bg->bg2_rotation.ydy = 0x100;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
331 data->bg->bg2_rotation.centerX = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
332 data->bg->bg2_rotation.centerY = 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
333 } 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
334 whichbg = 3;
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
335 data->bg->bg3_rotation.xdx = 0x100;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
336 data->bg->bg3_rotation.xdy = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
337 data->bg->bg3_rotation.ydx = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
338 data->bg->bg3_rotation.ydy = 0x100;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
339 data->bg->bg3_rotation.centerX = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
340 data->bg->bg3_rotation.centerY = 0;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
341 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
342 }
71c56e900f8b Cleaning 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 if(whichbg >= 0) {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
344 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
345 txdat = (NDS_TextureData*)texture->driverdata;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
346 if(!txdat) {
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
347 SDL_OutOfMemory();
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
348 return -1;
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
349 }
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
350
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
351 /* 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
352 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
353 /* 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
354 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
355 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
356
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
357 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
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 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
360 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
361
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 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
363 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
364 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
365 txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
366 txdat->dim.pitch = 256 * ((bpp+1)/8);
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
367 txdat->dim.bpp = bpp;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
368 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
369 BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
370
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
371 /* TESTING PURPOSES ONLY!!!
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
372 shows that the texture is set up properly on the screen. */
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
373 for(i = 0; i < 256*192; ++i) {
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
374 txdat->vram_pixels[i] = RGB15(31,31,0)|0x8000;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
375 }
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
376 printf("--one... two...\n");
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
377 for(i = 0; i < 120; ++i) {
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
378 swiWaitForVBlank();
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
379 }
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
380 for(i = 0; i < 256*192; ++i) {
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
381 txdat->vram_pixels[i] = 0;
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
382 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
383 /*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
384 } 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
385 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
386 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
387 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
388 } 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
389 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
390 }
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
391
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
392 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
393 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
394 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
395 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
396 }
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
397
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
398 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
399 }
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
400
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
401 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
402 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
403 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
404 {
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 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
406 TRACE("+NDS_QueryTexturePixels\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
407 *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
408 *pitch = txdat->dim.pitch;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
409 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
410 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
411 }
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
412
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
413 static int
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
414 NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
415 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
416 {
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
417 NDS_TextureData *txdat;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
418 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
419 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
420 TRACE("+NDS_UpdateTexture\n");
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
421 if(!texture) { printf("OH BOY!!!\n"); return -1; }
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
422 txdat = (NDS_TextureData *) texture->driverdata;
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
423
71c56e900f8b Cleaning 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 = (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
425 dst =
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
426 (Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
427 rect->x * ((txdat->dim.bpp+1)/8);
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
428 length = rect->w * ((txdat->dim.bpp+1)/8);
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
429 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
430 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
431 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
432 dst += txdat->dim.pitch;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
433 }
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
434
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
435 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
436 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
437 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
438
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
439 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
440 NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
441 const SDL_Rect * rect, int markDirty, void **pixels,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
442 int *pitch)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
443 {
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
444 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
445 int i;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
446 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
447 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
448 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
449 /* 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
450 /*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
451 }
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
452
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
453 *pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
454 * txdat->dim.pitch + rect->x * ((txdat->dim.bpp+1)/8));
2688
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
455 *pitch = txdat->dim.pitch;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
456 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
457 return 0;
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
458 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
459
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
460 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
461 NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
462 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
463 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
464 /* 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
465 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
466 TRACE("-NDS_UnlockTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
467 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
468
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
469 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
470 NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
471 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
472 {
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
473 /* stub */
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
474 TRACE("!NDS_DirtyTexture\n");
2685
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
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
477 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
478 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
479 Uint8 a, const SDL_Rect * rect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
480 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
481 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
482 SDL_Rect real_rect = *rect;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
483 u16 color;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
484 int i, j;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
485
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
486 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
487 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
488 /* 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
489 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
490 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
491 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
492 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
493 (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
494 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
495 */
71c56e900f8b Cleaning up the renderer code to hopefully squish any problems. Starting to incorporate sprites, as well
Darren Alton <dalton@stevens.edu>
parents: 2687
diff changeset
496
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
497 TRACE("-NDS_RenderFill\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
498 return 0;
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
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
501 static int
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
502 NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
503 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
504 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
505 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
506 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
507 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
508 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
509 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
510 int bpp = SDL_BYTESPERPIXEL(texture->format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
511 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
512
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
513 TRACE("+NDS_RenderCopy\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
514 if(txdat->type == NDSTX_BG) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
515 bg_rotation *tmpbg = (txdat->hw_index == 2) ?
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
516 &(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
517 tmpbg->xdx = txdat->dim.hdx;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
518 tmpbg->xdy = txdat->dim.hdy;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
519 tmpbg->ydx = txdat->dim.vdx;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
520 tmpbg->ydy = txdat->dim.vdy;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
521 tmpbg->centerX = 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
522 tmpbg->centerY = 0;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
523 } else {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
524 /* sprites not implemented yet */
2691
87cfb5fde5db Rendering now partially works! (Some BIZARRE bug that I inadvertently fixed.)
Darren Alton <dalton@stevens.edu>
parents: 2690
diff changeset
525 printf("tried to RenderCopy a sprite.\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
526 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
527 TRACE("-NDS_RenderCopy\n");
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
528
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
529 return 0;
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
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
532
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
533 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
534 NDS_RenderPresent(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
535 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
536 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
537 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
538 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
539 int i;
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
540 TRACE("+NDS_RenderPresent\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
541
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
542 {
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
543 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
544 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
545 /* 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
546 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
547 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
548 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
549 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
550 }
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
551
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
552 /* vsync for NDS */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
553 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
554 swiWaitForVBlank();
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
555 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
556 TRACE("-NDS_RenderPresent\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
557 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
558
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
559 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
560 NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
561 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
562 TRACE("+NDS_DestroyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
563 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
564 SDL_SetError("Unsupported texture format");
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
565 } else {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
566 /* free anything else allocated for texture */
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
567 NDS_TextureData *txdat = texture->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
568 /*SDL_FreeDirtyRects(&txdat->dirty);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
569 SDL_free(txdat);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
570 }
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
571 TRACE("-NDS_DestroyTexture\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
572 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
573
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
574 static void
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
575 NDS_DestroyRenderer(SDL_Renderer * renderer)
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
576 {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
577 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
578 /*SDL_Window *window = SDL_GetWindowFromID(renderer->window);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
579 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
580 int i;
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
581
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
582 TRACE("+NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
583 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
584 /* TODO: free anything else relevant. */
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
585 /*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
586 if (data->texture[i]) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
587 DestroyTexture(data->renderer, data->texture[i]);
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 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
590 if (data->surface.format) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
591 SDL_SetSurfacePalette(&data->surface, NULL);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
592 SDL_FreeFormat(data->surface.format);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
593 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
594 if (display->palette) {
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
595 SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
596 data);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
597 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
598 SDL_FreeDirtyRects(&data->dirty);*/
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
599 SDL_free(data);
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
600 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
601 SDL_free(renderer);
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
602 TRACE("-NDS_DestroyRenderer\n");
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
603 }
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
604
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2683
diff changeset
605 static 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
606 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
607 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
608 {
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 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
610 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
611 /* 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
612 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
613 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
614 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
615 }
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
616
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
617 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
618 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
619 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
620 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
621 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
622 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
623 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
624 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
625 }
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
626
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 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
628 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
629 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
630 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
631 /* 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
632 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
633 }
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
634
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 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
636 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
637 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
638 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
639 /* 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
640 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
641 }
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
642
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 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
644 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
645 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
646 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
647 /* 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
648 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
649 }
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
650
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 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
652 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
653 {
2690
ca01c20274c0 More work and some bugfixes on the graphics driver.
Darren Alton <dalton@stevens.edu>
parents: 2688
diff changeset
654 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
655 /* 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
656 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
657 }
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
658
2670
6e4669f4db49 Fix for the previous commit: actually 'svn add'ed some files.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
659 /* vi: set ts=4 sw=4 expandtab: */