From a61dd30afe10810507a9db5e489e22f180cfecd2 Mon Sep 17 00:00:00 2001 From: Darren Alton Date: Sat, 26 Jul 2008 05:52:59 +0000 Subject: [PATCH] Some debug work on the video driver, shows an error in the BG's vertical placement --- src/video/nds/SDL_ndsrender.c | 22 +++++++++++++++------- src/video/nds/SDL_ndsvideo.c | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/video/nds/SDL_ndsrender.c b/src/video/nds/SDL_ndsrender.c index f4d982dff..23d87e935 100644 --- a/src/video/nds/SDL_ndsrender.c +++ b/src/video/nds/SDL_ndsrender.c @@ -100,7 +100,6 @@ typedef struct bg_attribute *bg; u8 bg_taken[4]; int sub; - SDL_DirtyRectList dirty; } NDS_RenderData; typedef struct @@ -249,6 +248,7 @@ NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; NDS_TextureData *txdat = NULL; + int i; printf("+NDS_CreateTexture\n"); if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { SDL_SetError("Unsupported texture format"); @@ -299,6 +299,10 @@ printf("+NDS_CreateTexture\n"); txdat->dim.bpp = bpp; txdat->vram = (u16*)(data->sub ? BG_BMP_RAM_SUB(whichbg) : BG_BMP_RAM(whichbg)); + for(i = 0; i < 256*256; ++i) { + txdat->vram[i] = 0x8000|RGB15(0,31,31); + } + for(i = 0; i < 60; ++i) swiWaitForVBlank(); } else { SDL_SetError("Out of NDS backgrounds."); } @@ -439,7 +443,7 @@ printf("+NDS_LockTexture\n"); NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; if (markDirty) { - SDL_AddDirtyRect(&txdat->dirty, rect); + /*SDL_AddDirtyRect(&txdat->dirty, rect);*/ } *pixels = (void *) ((u8 *)txdat->vram + rect->y * txdat->dim.pitch @@ -496,9 +500,13 @@ NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; // SDL_Window *window = SDL_GetWindowFromID(renderer->window); // SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); - + int i; printf("+NDS_RenderCopy\n"); - + for(i = 0; i <= 0xFFFF; ++i) { + txdat->vram[i] = 0x8000|i; + } + printf("/txdat->hw_index = %d\n", txdat->hw_index); +#if 0 if (txdat->dirty.list) { SDL_DirtyRect *dirty; void *pixels; @@ -518,9 +526,9 @@ printf("+NDS_RenderCopy\n"); } SDL_ClearDirtyRects(&txdat->dirty); } - +#endif printf("-NDS_RenderCopy\n"); - return status; + return 0; } @@ -547,7 +555,7 @@ printf("+NDS_DestroyTexture\n"); } else { /* free anything else allocated for texture */ NDS_TextureData *txdat = texture->driverdata; - SDL_FreeDirtyRects(&txdat->dirty); + /*SDL_FreeDirtyRects(&txdat->dirty);*/ SDL_free(txdat); } printf("-NDS_DestroyTexture\n"); diff --git a/src/video/nds/SDL_ndsvideo.c b/src/video/nds/SDL_ndsvideo.c index 6676acf42..c81875814 100644 --- a/src/video/nds/SDL_ndsvideo.c +++ b/src/video/nds/SDL_ndsvideo.c @@ -199,11 +199,11 @@ NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode) printf("+NDS_SetDisplayMode\n"); /* right now this function is just hard-coded for 256x192 ABGR1555 */ videoSetMode(MODE_5_2D | - DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE + DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_ACTIVE); /* display on main core */ videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub */ vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, - VRAM_C_SUB_BG_0x06200000, VRAM_D_SUB_BG_0x06220000); + VRAM_C_SUB_BG_0x06200000, VRAM_D_MAIN_BG_0x06040000); vramSetBankE(VRAM_E_MAIN_SPRITE); /* set up console for debug text 'n stuff */ SUB_BG0_CR = BG_MAP_BASE(31);