comparison src/video/nds/SDL_ndsrender.c @ 2682:f7594fc66bda gsoc2008_nds

Some debug work on the video driver, shows an error in the BG's vertical placement
author Darren Alton <dalton@stevens.edu>
date Sat, 26 Jul 2008 05:52:59 +0000
parents c15b6c758be5
children e858ac8868b6
comparison
equal deleted inserted replaced
2681:c15b6c758be5 2682:f7594fc66bda
98 typedef struct 98 typedef struct
99 { 99 {
100 bg_attribute *bg; 100 bg_attribute *bg;
101 u8 bg_taken[4]; 101 u8 bg_taken[4];
102 int sub; 102 int sub;
103 SDL_DirtyRectList dirty;
104 } NDS_RenderData; 103 } NDS_RenderData;
105 104
106 typedef struct 105 typedef struct
107 { 106 {
108 enum { NDSTX_BG, NDSTX_SPR } type; 107 enum { NDSTX_BG, NDSTX_SPR } type;
247 static int 246 static int
248 NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 247 NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
249 { 248 {
250 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; 249 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
251 NDS_TextureData *txdat = NULL; 250 NDS_TextureData *txdat = NULL;
251 int i;
252 printf("+NDS_CreateTexture\n"); 252 printf("+NDS_CreateTexture\n");
253 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 253 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
254 SDL_SetError("Unsupported texture format"); 254 SDL_SetError("Unsupported texture format");
255 return -1; 255 return -1;
256 } else { 256 } else {
297 txdat->dim.h = texture->h; 297 txdat->dim.h = texture->h;
298 txdat->dim.pitch = 256 * (bpp/8); 298 txdat->dim.pitch = 256 * (bpp/8);
299 txdat->dim.bpp = bpp; 299 txdat->dim.bpp = bpp;
300 txdat->vram = (u16*)(data->sub ? 300 txdat->vram = (u16*)(data->sub ?
301 BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg)); 301 BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg));
302 for(i = 0; i < 256*256; ++i) {
303 txdat->vram[i] = 0x8000|RGB15(0,31,31);
304 }
305 for(i = 0; i < 60; ++i) swiWaitForVBlank();
302 } else { 306 } else {
303 SDL_SetError("Out of NDS backgrounds."); 307 SDL_SetError("Out of NDS backgrounds.");
304 } 308 }
305 } else { 309 } else {
306 SDL_SetError("Texture too big for NDS hardware."); 310 SDL_SetError("Texture too big for NDS hardware.");
437 return -1; 441 return -1;
438 } else { 442 } else {
439 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; 443 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
440 444
441 if (markDirty) { 445 if (markDirty) {
442 SDL_AddDirtyRect(&txdat->dirty, rect); 446 /*SDL_AddDirtyRect(&txdat->dirty, rect);*/
443 } 447 }
444 448
445 *pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch 449 *pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch
446 + rect->x * (txdat->dim.bpp/8)); 450 + rect->x * (txdat->dim.bpp/8));
447 *pitch = txdat->dim.pitch; 451 *pitch = txdat->dim.pitch;
494 { 498 {
495 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; 499 NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata;
496 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; 500 NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
497 // SDL_Window *window = SDL_GetWindowFromID(renderer->window); 501 // SDL_Window *window = SDL_GetWindowFromID(renderer->window);
498 // SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 502 // SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
499 503 int i;
500 printf("+NDS_RenderCopy\n"); 504 printf("+NDS_RenderCopy\n");
501 505 for(i = 0; i <= 0xFFFF; ++i) {
506 txdat->vram[i] = 0x8000|i;
507 }
508 printf("/txdat->hw_index = %d\n", txdat->hw_index);
509 #if 0
502 if (txdat->dirty.list) { 510 if (txdat->dirty.list) {
503 SDL_DirtyRect *dirty; 511 SDL_DirtyRect *dirty;
504 void *pixels; 512 void *pixels;
505 int bpp = SDL_BYTESPERPIXEL(texture->format); 513 int bpp = SDL_BYTESPERPIXEL(texture->format);
506 int pitch = txdat->pitch; 514 int pitch = txdat->pitch;
516 rect->w, rect->h, texturedata->format, 524 rect->w, rect->h, texturedata->format,
517 texturedata->formattype, pixels);*/ 525 texturedata->formattype, pixels);*/
518 } 526 }
519 SDL_ClearDirtyRects(&txdat->dirty); 527 SDL_ClearDirtyRects(&txdat->dirty);
520 } 528 }
521 529 #endif
522 printf("-NDS_RenderCopy\n"); 530 printf("-NDS_RenderCopy\n");
523 return status; 531 return 0;
524 } 532 }
525 533
526 534
527 static void 535 static void
528 NDS_RenderPresent(SDL_Renderer * renderer) 536 NDS_RenderPresent(SDL_Renderer * renderer)
545 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 553 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
546 SDL_SetError("Unsupported texture format"); 554 SDL_SetError("Unsupported texture format");
547 } else { 555 } else {
548 /* free anything else allocated for texture */ 556 /* free anything else allocated for texture */
549 NDS_TextureData *txdat = texture->driverdata; 557 NDS_TextureData *txdat = texture->driverdata;
550 SDL_FreeDirtyRects(&txdat->dirty); 558 /*SDL_FreeDirtyRects(&txdat->dirty);*/
551 SDL_free(txdat); 559 SDL_free(txdat);
552 } 560 }
553 printf("-NDS_DestroyTexture\n"); 561 printf("-NDS_DestroyTexture\n");
554 } 562 }
555 563