Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Some debug work on the video driver, shows an error in the BG's verti…
Browse files Browse the repository at this point in the history
…cal placement
  • Loading branch information
Darren Alton committed Jul 26, 2008
1 parent b1aa35f commit a61dd30
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions src/video/nds/SDL_ndsrender.c
Expand Up @@ -100,7 +100,6 @@ typedef struct
bg_attribute *bg;
u8 bg_taken[4];
int sub;
SDL_DirtyRectList dirty;
} NDS_RenderData;

typedef struct
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -518,9 +526,9 @@ printf("+NDS_RenderCopy\n");
}
SDL_ClearDirtyRects(&txdat->dirty);
}

#endif
printf("-NDS_RenderCopy\n");
return status;
return 0;
}


Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/video/nds/SDL_ndsvideo.c
Expand Up @@ -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);
Expand Down

0 comments on commit a61dd30

Please sign in to comment.