This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
/
SDL_ndsrender.c
659 lines (587 loc) · 21.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include <stdio.h>
#include <stdlib.h>
#include <nds.h>
26
27
28
#include <nds/arm9/video.h>
#include <nds/arm9/sprite.h>
#include <nds/arm9/trig_lut.h>
29
30
31
32
33
34
35
36
#include "SDL_config.h"
#include "SDL_video.h"
#include "../SDL_sysvideo.h"
#include "../SDL_yuv_sw_c.h"
#include "../SDL_renderer_sw.h"
37
38
#define TRACE
//#define TRACE printf
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* NDS sprite-related functions */
#define SPRITE_DMA_CHANNEL 3
#define SPRITE_ANGLE_MASK 0x01FF
void
NDS_OAM_Update(tOAM *oam)
{
DC_FlushAll();
dmaCopyHalfWords(SPRITE_DMA_CHANNEL, oam->spriteBuffer, OAM,
SPRITE_COUNT * sizeof(SpriteEntry));
}
void
NDS_OAM_RotateSprite(SpriteRotation *spriteRotation, u16 angle)
{
s16 s = SIN[angle & SPRITE_ANGLE_MASK] >> 4;
s16 c = COS[angle & SPRITE_ANGLE_MASK] >> 4;
spriteRotation->hdx = c;
spriteRotation->hdy = s;
spriteRotation->vdx = -s;
spriteRotation->vdy = c;
}
void
NDS_OAM_Init(tOAM *oam)
{
int i;
for(i = 0; i < SPRITE_COUNT; i++) {
oam->spriteBuffer[i].attribute[0] = ATTR0_DISABLED;
oam->spriteBuffer[i].attribute[1] = 0;
oam->spriteBuffer[i].attribute[2] = 0;
}
for(i = 0; i < MATRIX_COUNT; i++) {
NDS_OAM_RotateSprite(&(oam->matrixBuffer[i]), 0);
}
swiWaitForVBlank();
NDS_OAM_Update(oam);
}
void
NDS_OAM_HideSprite(SpriteEntry *spriteEntry)
{
spriteEntry->isRotoscale = 0;
spriteEntry->isHidden = 1;
}
void
NDS_OAM_ShowSprite(SpriteEntry *spriteEntry, int affine, int double_bound)
{
if (affine) {
spriteEntry->isRotoscale = 1;
spriteEntry->rsDouble = double_bound;
} else {
spriteEntry->isHidden = 0;
}
}
99
/* SDL NDS renderer implementation */
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags);
static int NDS_ActivateRenderer(SDL_Renderer * renderer);
static int NDS_DisplayModeChanged(SDL_Renderer * renderer);
static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int NDS_QueryTexturePixels(SDL_Renderer * renderer,
SDL_Texture * texture, void **pixels,
int *pitch);
static int NDS_SetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture,
const SDL_Color * colors, int firstcolor,
int ncolors);
static int NDS_GetTexturePalette(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Color * colors,
int firstcolor, int ncolors);
static int NDS_SetTextureColorMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_SetTextureBlendMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_SetTextureScaleMode(SDL_Renderer * renderer,
SDL_Texture * texture);
static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
124
125
const SDL_Rect * rect, const void *pixels,
int pitch);
126
127
128
129
130
131
132
133
static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, int markDirty, void **pixels,
int *pitch);
static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static void NDS_DirtyTexture(SDL_Renderer * renderer,
SDL_Texture * texture, int numrects,
const SDL_Rect * rects);
static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
134
Uint8 b, Uint8 a, const SDL_Rect * rect);
135
static int NDS_RenderCopy(SDL_Renderer * renderer,
136
137
138
SDL_Texture * texture,
const SDL_Rect * srcrect,
const SDL_Rect * dstrect);
139
140
141
static void NDS_RenderPresent(SDL_Renderer * renderer);
static void NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static void NDS_DestroyRenderer(SDL_Renderer * renderer);
142
143
144
145
SDL_RenderDriver NDS_RenderDriver = {
NDS_CreateRenderer,
146
{ "nds", /* char* name */
147
148
149
150
(SDL_RENDERER_SINGLEBUFFER |
SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTDISCARD |
SDL_RENDERER_PRESENTVSYNC), /* u32 flags */
151
(SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */
152
153
(SDL_TEXTUREBLENDMODE_MASK), /* u32 blend_modes */
(SDL_TEXTURESCALEMODE_FAST), /* u32 scale_modes */
154
155
156
3, /* u32 num_texture_formats */
{
SDL_PIXELFORMAT_INDEX8,
157
158
SDL_PIXELFORMAT_ABGR1555,
SDL_PIXELFORMAT_BGR555,
159
160
161
162
}, /* u32 texture_formats[20] */
(256), /* int max_texture_width */
(256), /* int max_texture_height */
}
163
164
165
166
};
typedef struct
{
167
168
bg_attribute *bg; /* backgrounds */
tOAM oam_copy; /* sprites */
169
170
u8 bg_taken[4];
int sub;
171
} NDS_RenderData;
172
173
174
typedef struct
{
175
176
177
178
179
180
181
182
183
184
enum { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */
int hw_index; /* sprite: index in the OAM. bg: 2 or 3. */
struct
{
int hdx, hdy, vdx, vdy; /* affine transformation, used for scaling. */
int pitch, bpp; /* some useful info */
} dim;
u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */
u16 *vram_palette; /* where the palette data is stored if it's indexed.*/
/*int size;*/
185
} NDS_TextureData;
186
187
188
189
SDL_Renderer *
190
NDS_CreateRenderer(SDL_Window * window, Uint32 flags)
191
192
193
194
{
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayMode *displayMode = &display->current_mode;
SDL_Renderer *renderer;
195
NDS_RenderData *data;
196
int i, n;
197
int bpp;
198
Uint32 Rmask, Gmask, Bmask, Amask;
199
200
TRACE("+NDS_CreateRenderer\n");
201
if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp,
202
203
204
205
&Rmask, &Gmask, &Bmask, &Amask)) {
SDL_SetError("Unknown display format");
return NULL;
}
206
207
208
209
210
211
212
213
214
215
switch(displayMode->format) {
case SDL_PIXELFORMAT_INDEX8:
case SDL_PIXELFORMAT_ABGR1555:
case SDL_PIXELFORMAT_BGR555:
/* okay */
break;
default:
printf("DEBUG: wrong display format!\n");
break;
}
216
217
218
219
220
221
222
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
if (!renderer) {
SDL_OutOfMemory();
return NULL;
}
223
data = (NDS_RenderData *) SDL_malloc(sizeof(*data));
224
if (!data) {
225
NDS_DestroyRenderer(renderer);
226
227
228
229
230
SDL_OutOfMemory();
return NULL;
}
SDL_zerop(data);
231
232
233
234
235
renderer->RenderFill = NDS_RenderFill;
renderer->RenderCopy = NDS_RenderCopy;
renderer->RenderPresent = NDS_RenderPresent;
renderer->DestroyRenderer = NDS_DestroyRenderer;
renderer->info.name = NDS_RenderDriver.info.name;
236
237
238
renderer->info.flags = 0;
renderer->window = window->id;
renderer->driverdata = data;
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
renderer->CreateTexture = NDS_CreateTexture;
renderer->QueryTexturePixels = NDS_QueryTexturePixels;
renderer->SetTexturePalette = NDS_SetTexturePalette;
renderer->GetTexturePalette = NDS_GetTexturePalette;
renderer->SetTextureColorMod = NDS_SetTextureColorMod;
renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod;
renderer->SetTextureBlendMode = NDS_SetTextureBlendMode;
renderer->SetTextureScaleMode = NDS_SetTextureScaleMode;
renderer->UpdateTexture = NDS_UpdateTexture;
renderer->LockTexture = NDS_LockTexture;
renderer->UnlockTexture = NDS_UnlockTexture;
renderer->DirtyTexture = NDS_DirtyTexture;
renderer->DestroyTexture = NDS_DestroyTexture;
renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes;
renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes;
renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes;
renderer->info.num_texture_formats =
NDS_RenderDriver.info.num_texture_formats;
SDL_memcpy(renderer->info.texture_formats,
NDS_RenderDriver.info.texture_formats,
260
261
262
sizeof(renderer->info.texture_formats));
renderer->info.max_texture_width =
NDS_RenderDriver.info.max_texture_width;
263
264
265
renderer->info.max_texture_height =
NDS_RenderDriver.info.max_texture_height;
266
267
268
data->sub = 0; /* TODO: this is hard-coded to the "main" screen.
figure out how to detect whether to set it to
"sub" screen. window->id, perhaps? */
269
270
271
272
273
274
275
if(!data->sub) {
data->bg = &BACKGROUND;
} else {
data->bg = &BACKGROUND_SUB;
}
data->bg_taken[2] = data->bg_taken[3] = 0;
NDS_OAM_Init(&(data->oam_copy)); /* init sprites. */
276
277
TRACE("-NDS_CreateRenderer\n");
278
printf("renderer is %x\n", (u32)(renderer->UpdateTexture));
279
280
281
return renderer;
}
282
283
284
285
static int
NDS_ActivateRenderer(SDL_Renderer * renderer)
{
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
286
TRACE("!NDS_ActivateRenderer\n");
287
288
289
290
291
292
293
return 0;
}
static int
NDS_DisplayModeChanged(SDL_Renderer * renderer)
{
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
294
TRACE("!NDS_DisplayModeChanged\n");
295
296
297
298
299
300
301
return 0;
}
static int
NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
302
NDS_TextureData *txdat = NULL;
303
int i;
304
305
306
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
307
TRACE("+NDS_CreateTexture\n");
308
309
310
if (!SDL_PixelFormatEnumToMasks
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
SDL_SetError("Unknown texture format");
311
return -1;
312
}
313
314
315
316
317
318
319
320
321
/* conditional statements on w/h to place it as bg/sprite
depending on which one it fits. */
if(texture->w <= 64 && texture->h <= 64) {
/* TODO: implement sprites similar to how BG's are.
they have a similar affine transformation matrix
(hdx,hdy,vdx,vdy) as the backgrounds, so it should
be similar enough to handle with the same driverdata. */
printf("Tried to make a sprite.\n");
322
txdat->type = NDSTX_SPR;
323
} else if(texture->w <= 256 && texture->h <= 256) {
324
int whichbg = -1, base = 0;
325
326
if(!data->bg_taken[2]) {
whichbg = 2;
327
328
329
330
331
332
data->bg->bg2_rotation.xdx = 0x100;
data->bg->bg2_rotation.xdy = 0;
data->bg->bg2_rotation.ydx = 0;
data->bg->bg2_rotation.ydy = 0x100;
data->bg->bg2_rotation.centerX = 0;
data->bg->bg2_rotation.centerY = 0;
333
334
} else if(!data->bg_taken[3]) {
whichbg = 3;
335
336
337
338
339
340
data->bg->bg3_rotation.xdx = 0x100;
data->bg->bg3_rotation.xdy = 0;
data->bg->bg3_rotation.ydx = 0;
data->bg->bg3_rotation.ydy = 0x100;
data->bg->bg3_rotation.centerX = 0;
data->bg->bg3_rotation.centerY = 0;
341
base = 4;
342
}
343
if(whichbg >= 0) {
344
345
346
347
348
349
350
texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData));
txdat = (NDS_TextureData*)texture->driverdata;
if(!txdat) {
SDL_OutOfMemory();
return -1;
}
351
352
/* TODO: maybe this should be in RenderPresent or RenderCopy
instead, copying from a malloc'd system RAM pixel buffer. */
353
/* this is hard-coded to being 256x256 for now. */
354
355
data->bg->control[whichbg] = (bpp == 8) ?
BG_BMP8_256x256 : BG_BMP16_256x256;
356
357
358
data->bg->control[whichbg] |= BG_BMP_BASE(base);
359
360
data->bg->scroll[whichbg].x = 0;
data->bg->scroll[whichbg].y = 0;
361
362
363
364
365
txdat->type = NDSTX_BG;
txdat->hw_index = whichbg;
txdat->dim.hdx = 0x100; txdat->dim.hdy = 0;
txdat->dim.vdx = 0; txdat->dim.vdy = 0x100;
366
txdat->dim.pitch = 256 * ((bpp+1)/8);
367
txdat->dim.bpp = bpp;
368
369
txdat->vram_pixels = (u16*)(data->sub ?
BG_BMP_RAM_SUB(base) : BG_BMP_RAM(base));
370
371
372
373
374
375
376
377
378
379
380
381
382
/* TESTING PURPOSES ONLY!!!
shows that the texture is set up properly on the screen. */
for(i = 0; i < 256*192; ++i) {
txdat->vram_pixels[i] = RGB15(31,31,0)|0x8000;
}
printf("--one... two...\n");
for(i = 0; i < 120; ++i) {
swiWaitForVBlank();
}
for(i = 0; i < 256*192; ++i) {
txdat->vram_pixels[i] = 0;
}
383
/*txdat->size = txdat->dim.pitch * texture->h;*/
384
} else {
385
386
SDL_SetError("Out of NDS backgrounds.");
printf("ran out.\n");
387
}
388
389
} else {
SDL_SetError("Texture too big for NDS hardware.");
390
391
}
392
TRACE("-NDS_CreateTexture\n");
393
if (!texture->driverdata) {
394
SDL_SetError("Couldn't create NDS render driver data.");
395
396
return -1;
}
397
398
399
400
401
402
403
404
return 0;
}
static int
NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch)
{
405
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
406
407
TRACE("+NDS_QueryTexturePixels\n");
*pixels = txdat->vram_pixels;
408
*pitch = txdat->dim.pitch;
409
TRACE("-NDS_QueryTexturePixels\n");
410
return 0;
411
412
413
414
415
416
}
static int
NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, int pitch)
{
417
NDS_TextureData *txdat;
418
419
Uint8 *src, *dst;
int row; size_t length;
420
TRACE("+NDS_UpdateTexture\n");
421
422
if(!texture) { printf("OH BOY!!!\n"); return -1; }
txdat = (NDS_TextureData *) texture->driverdata;
423
424
425
src = (Uint8 *) pixels;
dst =
426
(Uint8 *) txdat->vram_pixels + rect->y * txdat->dim.pitch +
427
428
rect->x * ((txdat->dim.bpp+1)/8);
length = rect->w * ((txdat->dim.bpp+1)/8);
429
430
431
432
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, src, length);
src += pitch;
dst += txdat->dim.pitch;
433
}
434
435
TRACE("-NDS_UpdateTexture\n");
436
return 0;
437
438
439
440
441
442
443
}
static int
NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, int markDirty, void **pixels,
int *pitch)
{
444
445
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
int i;
446
TRACE("+NDS_LockTexture\n");
447
448
449
450
if (markDirty) {
printf("wanted to mark dirty\n");
/* TODO: figure out how to handle this! */
/*SDL_AddDirtyRect(&txdat->dirty, rect);*/
451
}
452
453
*pixels = (void *) ((u8 *)txdat->vram_pixels + rect->y
454
* txdat->dim.pitch + rect->x * ((txdat->dim.bpp+1)/8));
455
*pitch = txdat->dim.pitch;
456
TRACE("-NDS_LockTexture\n");
457
return 0;
458
459
460
461
462
}
static void
NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
463
TRACE("+NDS_UnlockTexture\n");
464
465
/* TODO: should I be doing something here, somehow, now that the pixels
should have been "written" between LockTexture and this? */
466
TRACE("-NDS_UnlockTexture\n");
467
468
469
470
471
}
static void
NDS_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
int numrects, const SDL_Rect * rects)
472
473
{
/* stub */
474
TRACE("!NDS_DirtyTexture\n");
475
476
}
477
static int
478
NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
479
Uint8 a, const SDL_Rect * rect)
480
{
481
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
482
SDL_Rect real_rect = *rect;
483
484
485
u16 color;
int i, j;
486
TRACE("+NDS_RenderFill\n");
487
color = RGB8(r,g,b); /* <-- macro in libnds that makes an ARGB1555 pixel */
488
/* TODO: make a single-color sprite and stretch it.
489
490
491
492
493
494
495
496
calculate the "HDX" width modifier of the sprite by:
let S be the actual sprite's width (like, 32 pixels for example)
let R be the rectangle's width (maybe 50 pixels)
HDX = (R<<8) / S;
(it's fixed point, hence the bit shift. same goes for vertical.
be sure to use 32-bit int's for the bit shift before the division!)
*/
497
TRACE("-NDS_RenderFill\n");
498
return 0;
499
}
500
501
static int
502
NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
503
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
504
{
505
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
506
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
507
508
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
509
int i;
510
511
int bpp = SDL_BYTESPERPIXEL(texture->format);
int pitch = txdat->dim.pitch;
512
513
TRACE("+NDS_RenderCopy\n");
514
515
516
517
518
519
520
521
522
523
524
if(txdat->type == NDSTX_BG) {
bg_rotation *tmpbg = (txdat->hw_index == 2) ?
&(data->bg->bg2_rotation) : &(data->bg->bg3_rotation);
tmpbg->xdx = txdat->dim.hdx;
tmpbg->xdy = txdat->dim.hdy;
tmpbg->ydx = txdat->dim.vdx;
tmpbg->ydy = txdat->dim.vdy;
tmpbg->centerX = 0;
tmpbg->centerY = 0;
} else {
/* sprites not implemented yet */
525
printf("tried to RenderCopy a sprite.\n");
526
}
527
528
TRACE("-NDS_RenderCopy\n");
529
return 0;
530
531
}
532
533
static void
534
NDS_RenderPresent(SDL_Renderer * renderer)
535
{
536
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
537
538
539
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
int i;
540
TRACE("+NDS_RenderPresent\n");
541
542
{
543
544
SDL_Texture * tx = display->textures[i];
NDS_TextureData * txdat = (NDS_TextureData*)tx->driverdata;
545
546
547
548
549
/* Send the data to the display TODO :
shouldn't it already be there at this point? from lock/unlock
giving it the direct address in VRAM of the bg's.
I guess set the BG's and sprites "visible" flags here,
if applicable. */
550
551
}
552
/* vsync for NDS */
553
554
if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
swiWaitForVBlank();
555
}
556
TRACE("-NDS_RenderPresent\n");
557
558
}
559
560
561
static void
NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
562
TRACE("+NDS_DestroyTexture\n");
563
564
565
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("Unsupported texture format");
} else {
566
/* free anything else allocated for texture */
567
NDS_TextureData *txdat = texture->driverdata;
568
/*SDL_FreeDirtyRects(&txdat->dirty);*/
569
SDL_free(txdat);
570
}
571
TRACE("-NDS_DestroyTexture\n");
572
573
}
574
static void
575
NDS_DestroyRenderer(SDL_Renderer * renderer)
576
{
577
NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
578
579
/*SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);*/
580
581
int i;
582
TRACE("+NDS_DestroyRenderer\n");
583
if (data) {
584
/* TODO: free anything else relevant. */
585
/*for (i = 0; i < SDL_arraysize(data->texture); ++i) {
586
587
if (data->texture[i]) {
DestroyTexture(data->renderer, data->texture[i]);
588
}
589
590
591
592
593
594
595
596
597
}
if (data->surface.format) {
SDL_SetSurfacePalette(&data->surface, NULL);
SDL_FreeFormat(data->surface.format);
}
if (display->palette) {
SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged,
data);
}
598
SDL_FreeDirtyRects(&data->dirty);*/
599
600
601
SDL_free(data);
}
SDL_free(renderer);
602
TRACE("-NDS_DestroyRenderer\n");
603
604
}
605
606
607
608
static int
NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Color * colors, int firstcolor, int ncolors)
{
609
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
610
TRACE("+NDS_SetTexturePalette\n");
611
612
/* set 8-bit modes in the background control registers
for backgrounds, BGn_CR |= BG_256_COLOR */
613
TRACE("-NDS_SetTexturePalette\n");
614
return 0;
615
616
617
618
619
620
}
static int
NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
621
TRACE("+NDS_GetTexturePalette\n");
622
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
623
TRACE("-NDS_GetTexturePalette\n");
624
return 0;
625
626
627
628
629
}
static int
NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
630
TRACE("!NDS_SetTextureColorMod\n");
631
/* stub! */
632
633
634
635
636
637
return 0;
}
static int
NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
638
TRACE("!NDS_SetTextureAlphaMod\n");
639
/* stub! */
640
641
642
643
644
645
return 0;
}
static int
NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
646
TRACE("!NDS_SetTextureBlendMode\n");
647
/* stub! */
648
649
650
651
652
653
return 0;
}
static int
NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
654
TRACE("!NDS_SetTextureScaleMode\n");
655
/* stub! (note: NDS hardware scaling is nearest neighbor.) */
656
657
658
return 0;
}
659
/* vi: set ts=4 sw=4 expandtab: */