Skip to content

Commit

Permalink
full-range 24-bit colour
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Mar 27, 2024
1 parent f965d0c commit 0055b8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions source/3ds/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ void video_init() {
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE * 4);
finalScreen[0] = C3D_RenderTargetCreate(240, 400, GPU_RB_RGB8, -1);
C3D_RenderTargetSetOutput(finalScreen[0], GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
finalScreen[1] = C3D_RenderTargetCreate(240, 400, GPU_RB_RGB8, -1);
C3D_RenderTargetSetOutput(finalScreen[1], GFX_TOP, GFX_RIGHT, DISPLAY_TRANSFER_FLAGS);

sFinal_dvlb = DVLB_ParseFile((u32 *)final_shbin, final_shbin_size);
shaderProgramInit(&sFinal);
Expand All @@ -190,6 +186,15 @@ void video_init() {

video_hard_init();
video_soft_init();

// The hardware renderer creates 1 * 0.75MB + 4 * 1MB framebuffers.
// The 3DS has two 3MB VRAM banks, so for this to work, 3 framebuffers must go into one bank.
// However, the allocator alternates between banks, so we need to allocate those first,
// before even the final render targets.
finalScreen[0] = C3D_RenderTargetCreate(240, 400, GPU_RB_RGB8, -1);
C3D_RenderTargetSetOutput(finalScreen[0], GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
finalScreen[1] = C3D_RenderTargetCreate(240, 400, GPU_RB_RGB8, -1);
C3D_RenderTargetSetOutput(finalScreen[1], GFX_TOP, GFX_RIGHT, DISPLAY_TRANSFER_FLAGS);
}

void video_render(int alt_buf) {
Expand Down
6 changes: 4 additions & 2 deletions source/3ds/video_hard.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ void video_hard_init() {

params.width = 512;
params.height = 512;
params.format = GPU_RGBA4;
params.format = GPU_RGB8;
params.onVram = true;
C3D_TexInitWithParams(&screenTexHard, NULL, params);
screenTarget = C3D_RenderTargetCreateFromTex(&screenTexHard, GPU_TEX_2D, 0, GPU_RB_DEPTH16);
// Drawing backwards with a depth buffer isn't faster, so omit the depth buffer.
screenTarget = C3D_RenderTargetCreateFromTex(&screenTexHard, GPU_TEX_2D, 0, -1);
C3D_RenderTargetClear(screenTarget, C3D_CLEAR_ALL, 0, 0);

params.width = 512;
params.height = 512;
params.format = GPU_RGBA8;
for (int i = 0; i < AFFINE_CACHE_SIZE; i++) {
C3D_TexInitWithParams(&tileMapCache[i].tex, NULL, params);
tileMapCache[i].target = C3D_RenderTargetCreateFromTex(&tileMapCache[i].tex, GPU_TEX_2D, 0, -1);
Expand Down

0 comments on commit 0055b8f

Please sign in to comment.