Mercurial > sdl-ios-xcode
annotate src/video/nds/SDL_ndsrender.c @ 5144:31e7f523ab3d
Making the API simpler, texture color and alpha modulation are supported by all renderers.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 31 Jan 2011 23:37:30 -0800 |
parents | e743b9c3f6d6 |
children | c8e049de174c |
rev | line source |
---|---|
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include <stdio.h> |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include <stdlib.h> |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include <nds.h> |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
26 //#include <nds/arm9/video.h> |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
27 //#include <nds/arm9/sprite.h> |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
28 //#include <nds/arm9/trig_lut.h> |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "SDL_config.h" |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include "SDL_video.h" |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #include "../SDL_sysvideo.h" |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include "../SDL_yuv_sw_c.h" |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #include "../SDL_renderer_sw.h" |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 /* SDL NDS renderer implementation */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 static int NDS_ActivateRenderer(SDL_Renderer * renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 static int NDS_DisplayModeChanged(SDL_Renderer * renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 static int NDS_QueryTexturePixels(SDL_Renderer * renderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 SDL_Texture * texture, void **pixels, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 int *pitch); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 static int NDS_SetTexturePalette(SDL_Renderer * renderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 const SDL_Color * colors, int firstcolor, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 int ncolors); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 static int NDS_GetTexturePalette(SDL_Renderer * renderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 SDL_Texture * texture, SDL_Color * colors, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 int firstcolor, int ncolors); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 const SDL_Rect * rect, const void *pixels, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 int pitch); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 const SDL_Rect * rect, int markDirty, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 void **pixels, int *pitch); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 Uint8 b, Uint8 a, const SDL_Rect * rect); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 static int NDS_RenderCopy(SDL_Renderer * renderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 static void NDS_RenderPresent(SDL_Renderer * renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 static void NDS_DestroyTexture(SDL_Renderer * renderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 SDL_Texture * texture); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 static void NDS_DestroyRenderer(SDL_Renderer * renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 SDL_RenderDriver NDS_RenderDriver = { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 NDS_CreateRenderer, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 {"nds", /* char* name */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), /* u32 flags */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 3, /* u32 num_texture_formats */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 SDL_PIXELFORMAT_INDEX8, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 SDL_PIXELFORMAT_ABGR1555, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 SDL_PIXELFORMAT_BGR555, |
3139 | 80 }, /* u32 texture_formats[20] */ |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 (256), /* int max_texture_width */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 (256), /* int max_texture_height */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 }; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 typedef struct |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 u8 bg_taken[4]; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
89 OamState *oam; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 int sub; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 } NDS_RenderData; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 typedef struct |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 enum |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */ |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
97 int hw_index; /* index of sprite in OAM or bg from libnds */ |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
98 int pitch, bpp; /* useful information about the texture */ |
3139 | 99 struct |
100 { | |
101 int x, y; | |
102 } scale; /* x/y stretch (24.8 fixed point) */ | |
103 struct | |
104 { | |
105 int x, y; | |
106 } scroll; /* x/y offset */ | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
107 int rotate; /* -32768 to 32767, texture rotation */ |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 u16 *vram_palette; /* where the palette data is stored if it's indexed. */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 /*int size; */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 } NDS_TextureData; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 SDL_Renderer * |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 NDS_CreateRenderer(SDL_Window * window, Uint32 flags) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
118 SDL_VideoDisplay *display = window->display; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 SDL_DisplayMode *displayMode = &display->current_mode; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 SDL_Renderer *renderer; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 NDS_RenderData *data; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 int i, n; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 int bpp; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 Uint32 Rmask, Gmask, Bmask, Amask; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 &Rmask, &Gmask, &Bmask, &Amask)) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 SDL_SetError("Unknown display format"); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 return NULL; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 switch (displayMode->format) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 case SDL_PIXELFORMAT_INDEX8: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 case SDL_PIXELFORMAT_ABGR1555: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 case SDL_PIXELFORMAT_BGR555: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 /* okay */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 break; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 case SDL_PIXELFORMAT_RGB555: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 case SDL_PIXELFORMAT_RGB565: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 case SDL_PIXELFORMAT_ARGB1555: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 /* we'll take these too for now */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 break; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 default: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 SDL_SetError("Warning: wrong display format for NDS!\n"); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 break; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if (!renderer) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 SDL_OutOfMemory(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 return NULL; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 data = (NDS_RenderData *) SDL_malloc(sizeof(*data)); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 if (!data) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 NDS_DestroyRenderer(renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 SDL_OutOfMemory(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 return NULL; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 SDL_zerop(data); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 renderer->RenderFill = NDS_RenderFill; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 renderer->RenderCopy = NDS_RenderCopy; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 renderer->RenderPresent = NDS_RenderPresent; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 renderer->DestroyRenderer = NDS_DestroyRenderer; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 renderer->info.name = NDS_RenderDriver.info.name; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 renderer->info.flags = 0; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
167 renderer->window = window; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 renderer->driverdata = data; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 renderer->CreateTexture = NDS_CreateTexture; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 renderer->QueryTexturePixels = NDS_QueryTexturePixels; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 renderer->SetTexturePalette = NDS_SetTexturePalette; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 renderer->GetTexturePalette = NDS_GetTexturePalette; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 renderer->UpdateTexture = NDS_UpdateTexture; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 renderer->LockTexture = NDS_LockTexture; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 renderer->UnlockTexture = NDS_UnlockTexture; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 renderer->DestroyTexture = NDS_DestroyTexture; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 renderer->info.num_texture_formats = |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 NDS_RenderDriver.info.num_texture_formats; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 SDL_memcpy(renderer->info.texture_formats, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 NDS_RenderDriver.info.texture_formats, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 sizeof(renderer->info.texture_formats)); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 renderer->info.max_texture_width = |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 NDS_RenderDriver.info.max_texture_width; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 renderer->info.max_texture_height = |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 NDS_RenderDriver.info.max_texture_height; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
3139 | 188 data->sub = 0; /* TODO: this is hard-coded to the "main" screen. |
189 figure out how to detect whether to set it to | |
190 "sub" screen. window->id, perhaps? */ | |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 data->bg_taken[2] = data->bg_taken[3] = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 return renderer; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 NDS_ActivateRenderer(SDL_Renderer * renderer) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 NDS_DisplayModeChanged(SDL_Renderer * renderer) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 NDS_TextureData *txdat = NULL; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 int i; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 int bpp; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 Uint32 Rmask, Gmask, Bmask, Amask; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 if (!SDL_PixelFormatEnumToMasks |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 SDL_SetError("Unknown texture format"); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 return -1; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 /* conditional statements on w/h to place it as bg/sprite |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 depending on which one it fits. */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 if (texture->w <= 64 && texture->h <= 64) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 int whichspr = -1; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
231 printf("NDS_CreateTexture: Tried to make a sprite.\n"); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 txdat->type = NDSTX_SPR; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
233 #if 0 |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 for (i = 0; i < SPRITE_COUNT; ++i) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 if (data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 whichspr = i; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 break; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 if (whichspr >= 0) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 SpriteEntry *sprent = &(data->oam_copy.spriteBuffer[whichspr]); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 int maxside = texture->w > texture->h ? texture->w : texture->h; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 int pitch; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 if (!txdat) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 SDL_OutOfMemory(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 return -1; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 sprent->objMode = OBJMODE_BITMAP; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 sprent->posX = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 sprent->posY = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 sprent->colMode = OBJCOLOR_16; /* OBJCOLOR_256 for INDEX8 */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 /* the first 32 sprites get transformation matrices. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 first come, first served */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 if (whichspr < MATRIX_COUNT) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 sprent->isRotoscale = 1; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 sprent->rsMatrixIdx = whichspr; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 /* containing shape (square or 2:1 rectangles) */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 sprent->objShape = OBJSHAPE_SQUARE; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 if (texture->w / 2 >= texture->h) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 sprent->objShape = OBJSHAPE_WIDE; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 } else if (texture->h / 2 >= texture->w) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 sprent->objShape = OBJSHAPE_TALL; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 /* size in pixels */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 /* FIXME: "pitch" is hardcoded for 2bytes per pixel. */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 sprent->objSize = OBJSIZE_64; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 pitch = 128; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 if (maxside <= 8) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 sprent->objSize = OBJSIZE_8; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 pitch = 16; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 } else if (maxside <= 16) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 sprent->objSize = OBJSIZE_16; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 pitch = 32; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 } else if (maxside <= 32) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 sprent->objSize = OBJSIZE_32; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 pitch = 64; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 /* FIXME: this is hard-coded and will obviously only work for one |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 sprite-texture. tells it to look at the beginning of SPRITE_GFX |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 for its pixels. */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 sprent->tileIdx = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 /* now for the texture data */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 txdat->type = NDSTX_SPR; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 txdat->hw_index = whichspr; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 txdat->dim.hdx = 0x100; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 txdat->dim.hdy = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 txdat->dim.vdx = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 txdat->dim.vdy = 0x100; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 txdat->dim.pitch = pitch; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 txdat->dim.bpp = bpp; |
3139 | 301 txdat->vram_pixels = |
302 (u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX); | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
303 /* FIXME: use tileIdx*boundary |
3139 | 304 to point to proper location */ |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 } else { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 SDL_SetError("Out of NDS sprites."); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 } |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
308 #endif |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 } else if (texture->w <= 256 && texture->h <= 256) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 int whichbg = -1, base = 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 if (!data->bg_taken[2]) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 whichbg = 2; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 } else if (!data->bg_taken[3]) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 whichbg = 3; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 base = 4; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 if (whichbg >= 0) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 if (!txdat) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 SDL_OutOfMemory(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 return -1; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
324 // hard-coded for 256x256 for now... |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
325 // TODO: a series of if-elseif-else's to find the closest but larger size. |
3139 | 326 if (!data->sub) { |
327 if (bpp == 8) { | |
328 txdat->hw_index = | |
329 bgInit(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, 0); | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
330 } else { |
3139 | 331 txdat->hw_index = |
332 bgInit(whichbg, BgType_Bmp16, BgSize_B16_256x256, 0, | |
333 0); | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
334 } |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
335 } else { |
3139 | 336 if (bpp == 8) { |
337 txdat->hw_index = | |
338 bgInitSub(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, | |
339 0); | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
340 } else { |
3139 | 341 txdat->hw_index = |
342 bgInitSub(whichbg, BgType_Bmp16, BgSize_B16_256x256, | |
343 0, 0); | |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
344 } |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
345 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
347 /* useful functions |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
348 bgGetGfxPtr(bg3); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
349 bgSetCenter(bg3, rcX, rcY); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
350 bgSetRotateScale(bg3, angle, scaleX, scaleY); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
351 bgSetScroll(bg3, scrollX, scrollY); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
352 bgUpdate(bg3); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
353 */ |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 txdat->type = NDSTX_BG; |
3139 | 355 txdat->pitch = (texture->w) * (bpp / 8); |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
356 txdat->bpp = bpp; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
357 txdat->rotate = 0; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
358 txdat->scale.x = 0x100; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
359 txdat->scale.y = 0x100; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
360 txdat->scroll.x = 0; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
361 txdat->scroll.y = 0; |
3139 | 362 txdat->vram_pixels = (u16 *) bgGetGfxPtr(txdat->hw_index); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
364 bgSetCenter(txdat->hw_index, 0, 0); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
365 bgSetRotateScale(txdat->hw_index, txdat->rotate, txdat->scale.x, |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
366 txdat->scale.y); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
367 bgSetScroll(txdat->hw_index, txdat->scroll.x, txdat->scroll.y); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
368 bgUpdate(txdat->hw_index); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
369 |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
370 data->bg_taken[whichbg] = 1; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 /*txdat->size = txdat->dim.pitch * texture->h; */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 } else { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 SDL_SetError("Out of NDS backgrounds."); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 } else { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 SDL_SetError("Texture too big for NDS hardware."); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 if (!texture->driverdata) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 return -1; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 void **pixels, int *pitch) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 *pixels = txdat->vram_pixels; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
392 *pitch = txdat->pitch; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 const SDL_Rect * rect, const void *pixels, int pitch) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 NDS_TextureData *txdat; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 Uint8 *src, *dst; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 int row; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 size_t length; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 src = (Uint8 *) pixels; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 dst = |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
409 (Uint8 *) txdat->vram_pixels + rect->y * txdat->pitch + rect->x * |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
410 ((txdat->bpp + 1) / 8); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
411 length = rect->w * ((txdat->bpp + 1) / 8); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 if (rect->w == texture->w) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 dmaCopy(src, dst, length * rect->h); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 } else { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 for (row = 0; row < rect->h; ++row) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 dmaCopy(src, dst, length); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 src += pitch; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
419 dst += txdat->pitch; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 const SDL_Rect * rect, int markDirty, void **pixels, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 int *pitch) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
433 *pixels = (void *) ((u8 *) txdat->vram_pixels + rect->y * txdat->pitch + |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
434 rect->x * ((txdat->bpp + 1) / 8)); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
435 *pitch = txdat->pitch; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 static void |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 /* stub! */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 Uint8 a, const SDL_Rect * rect) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 SDL_Rect real_rect = *rect; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 u16 color; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 int i, j; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
455 printf("NDS_RenderFill: stub\n"); |
3139 | 456 color = RGB8(r, g, b); /* macro in libnds that makes an ARGB1555 pixel */ |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 /* TODO: make a single-color sprite and stretch it. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 calculate the "HDX" width modifier of the sprite by: |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 let S be the actual sprite's width (like, 32 pixels for example) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 let R be the rectangle's width (maybe 50 pixels) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 HDX = (R<<8) / S; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 (it's fixed point, hence the bit shift. same goes for vertical. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 be sure to use 32-bit int's for the bit shift before the division!) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
475 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
476 SDL_VideoDisplay *display = window->display; |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
477 int Bpp = SDL_BYTESPERPIXEL(texture->format); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 if (txdat->type == NDSTX_BG) { |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
480 txdat->scroll.x = dstrect->x; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
481 txdat->scroll.y = dstrect->y; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 } else { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 /* sprites not fully implemented yet */ |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
484 printf("NDS_RenderCopy: used sprite!\n"); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
485 // SpriteEntry *spr = &(data->oam_copy.spriteBuffer[txdat->hw_index]); |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
486 // spr->posX = dstrect->x; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
487 // spr->posY = dstrect->y; |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
488 // if (txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) { |
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
489 // } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 static void |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 NDS_RenderPresent(SDL_Renderer * renderer) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
500 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
501 SDL_VideoDisplay *display = window->display; |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 /* update sprites */ |
3073
c5280d33c32a
NDS compiles again, but may not yet work. Sprite support has been removed for the time being while it is re-worked.
Darren Alton <dalton@stevens.edu>
parents:
2884
diff
changeset
|
504 // NDS_OAM_Update(&(data->oam_copy), data->sub); |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 /* vsync for NDS */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 swiWaitForVBlank(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 static void |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 NDS_TextureData *txdat = texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 /* free anything else allocated for texture */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 SDL_free(txdat); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 static void |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 NDS_DestroyRenderer(SDL_Renderer * renderer) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 int i; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 if (data) { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 /* free anything else relevant if anything else is allocated. */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 SDL_free(data); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 SDL_free(renderer); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 const SDL_Color * colors, int firstcolor, int ncolors) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 /* set 8-bit modes in the background control registers |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 for backgrounds, BGn_CR |= BG_256_COLOR */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 static int |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 SDL_Color * colors, int firstcolor, int ncolors) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 { |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 /* stub! */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 return 0; |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 } |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 /* vi: set ts=4 sw=4 expandtab: */ |