Name and document frame buffer copy/filter functions (#587)

* Name and document frame buffer copy/filter functions

* 0/1 naming of variables to match pass 0 and pass 1
This commit is contained in:
Zelllll 2021-12-28 19:29:24 -06:00 committed by GitHub
parent d22bd18f98
commit 8dcb7f1ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 35 deletions

View File

@ -353,25 +353,26 @@ void gfx_init_state(void) {
gSPDisplayList(gMasterGfxPos++, OS_K0_TO_PHYSICAL(D_80074210));
}
s32 func_800271FC(const u16* framebuf1, const u16* framebuf2, s32 y, s32 x, u8* out) {
s32 gfx_frame_filter_pass_0(const u16* frameBuffer0, const u16* frameBuffer1, s32 y, s32 x, u8* out) {
s32 pixel = SCREEN_WIDTH * y + x;
out[3] = (framebuf2[pixel] >> 2) & 0xF;
out[0] = framebuf1[pixel] >> 11; // red
out[1] = (framebuf1[pixel] >> 6) & 0x1F; // green
out[2] = (framebuf1[pixel] >> 1) & 0x1F; // blue
out[3] = (frameBuffer1[pixel] >> 2) & 0xF;
out[0] = frameBuffer0[pixel] >> 11; // red
out[1] = (frameBuffer0[pixel] >> 6) & 0x1F; // green
out[2] = (frameBuffer0[pixel] >> 1) & 0x1F; // blue
}
void func_8002725C(u8*, u32, u16*);
INCLUDE_ASM(void, "main_loop", func_8002725C, u8* arg0, u32 arg1, u16* arg2);
void gfx_frame_filter_pass_1(u8* filterBuf0, u32 filterBuf1, u16* out);
INCLUDE_ASM(void, "main_loop", gfx_frame_filter_pass_1, u8* filterBuf0, u32 filterBuf1, u16* out);
INCLUDE_ASM(s32, "main_loop", func_80027600);
INCLUDE_ASM(s32, "main_loop", func_80027774);
void func_800279B4(u16* arg0, u16* arg1, u16* arg2) {
u8 filterBuf[0x18];
u8 sp30[4];
// transfers the framebuffer into the depth buffer and applies filters
void gfx_transfer_frame_to_depth(u16* frameBuffer0, u16* frameBuffer1, u16* zBuffer) {
u8 filterBuf0[24];
u8 filterBuf1[4];
s32 y;
s32 x;
@ -379,18 +380,18 @@ void func_800279B4(u16* arg0, u16* arg1, u16* arg2) {
for (x = 2; x < SCREEN_WIDTH - 2; x++) {
s32 pixel = SCREEN_WIDTH * y + x;
if (((arg1[pixel] >> 2) & 0xF) < 8) {
func_800271FC(arg0, arg1, y - 1, x - 1, &filterBuf[0x00]);
func_800271FC(arg0, arg1, y - 1, x + 1, &filterBuf[0x04]);
func_800271FC(arg0, arg1, y, x - 2, &filterBuf[0x08]);
func_800271FC(arg0, arg1, y, x + 2, &filterBuf[0x0C]);
func_800271FC(arg0, arg1, y + 1, x - 1, &filterBuf[0x10]);
func_800271FC(arg0, arg1, y + 1, x + 1, &filterBuf[0x14]);
func_800271FC(arg0, arg1, y, x, &sp30);
func_8002725C(&filterBuf, (sp30[0] << 24) | (sp30[1] << 16) | (sp30[2] << 8) | sp30[3], &arg2[pixel]);
if (((frameBuffer1[pixel] >> 2) & 0xF) < 8) {
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y - 1, x - 1, &filterBuf0[0]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y - 1, x + 1, &filterBuf0[4]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y, x - 2, &filterBuf0[8]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y, x + 2, &filterBuf0[12]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y + 1, x - 1, &filterBuf0[16]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y + 1, x + 1, &filterBuf0[20]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y, x, &filterBuf1[0]);
gfx_frame_filter_pass_1(&filterBuf0, (filterBuf1[0] << 24) | (filterBuf1[1] << 16) | (filterBuf1[2] << 8) | filterBuf1[3], &zBuffer[pixel]);
} else {
// Edge
arg2[pixel] = arg0[pixel] | 1;
// Don't apply any filters to the edges of the screen
zBuffer[pixel] = frameBuffer0[pixel] | 1;
}
}
}
@ -450,10 +451,11 @@ void gfx_draw_background(void) {
gGameStatusPtr->enableBackground |= 0x20;
break;
case 0x20:
func_800279B4(nuGfxCfb[0], nuGfxCfb[1], nuGfxZBuffer);
gfx_transfer_frame_to_depth(nuGfxCfb[0], nuGfxCfb[1], nuGfxZBuffer); // applies filters to the framebuffer
D_800741F8 = 0;
gGameStatusPtr->enableBackground &= ~0xF0;
gGameStatusPtr->enableBackground |= 0x30;
// fall through
case 0x30:
D_800741F8 += 0x10;
if (D_800741F8 > 0x80) {

View File

@ -54,14 +54,14 @@ glabel func_80027774
/* 2C2C 8002782C 2650FFFF */ addiu $s0, $s2, -1
/* 2C30 80027830 8FA80040 */ lw $t0, 0x40($sp)
/* 2C34 80027834 0200382D */ daddu $a3, $s0, $zero
/* 2C38 80027838 0C009C7F */ jal func_800271FC
/* 2C38 80027838 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2C3C 8002783C AFA80010 */ sw $t0, 0x10($sp)
/* 2C40 80027840 0280202D */ daddu $a0, $s4, $zero
/* 2C44 80027844 02A0282D */ daddu $a1, $s5, $zero
/* 2C48 80027848 03C0302D */ daddu $a2, $fp, $zero
/* 2C4C 8002784C 0240382D */ daddu $a3, $s2, $zero
/* 2C50 80027850 27A2001C */ addiu $v0, $sp, 0x1c
/* 2C54 80027854 0C009C7F */ jal func_800271FC
/* 2C54 80027854 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2C58 80027858 AFA20010 */ sw $v0, 0x10($sp)
/* 2C5C 8002785C 0280202D */ daddu $a0, $s4, $zero
/* 2C60 80027860 02A0282D */ daddu $a1, $s5, $zero
@ -69,49 +69,49 @@ glabel func_80027774
/* 2C68 80027868 26510001 */ addiu $s1, $s2, 1
/* 2C6C 8002786C 0220382D */ daddu $a3, $s1, $zero
/* 2C70 80027870 27A20020 */ addiu $v0, $sp, 0x20
/* 2C74 80027874 0C009C7F */ jal func_800271FC
/* 2C74 80027874 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2C78 80027878 AFA20010 */ sw $v0, 0x10($sp)
/* 2C7C 8002787C 0280202D */ daddu $a0, $s4, $zero
/* 2C80 80027880 02A0282D */ daddu $a1, $s5, $zero
/* 2C84 80027884 0260302D */ daddu $a2, $s3, $zero
/* 2C88 80027888 0200382D */ daddu $a3, $s0, $zero
/* 2C8C 8002788C 27A20024 */ addiu $v0, $sp, 0x24
/* 2C90 80027890 0C009C7F */ jal func_800271FC
/* 2C90 80027890 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2C94 80027894 AFA20010 */ sw $v0, 0x10($sp)
/* 2C98 80027898 0280202D */ daddu $a0, $s4, $zero
/* 2C9C 8002789C 02A0282D */ daddu $a1, $s5, $zero
/* 2CA0 800278A0 0260302D */ daddu $a2, $s3, $zero
/* 2CA4 800278A4 0240382D */ daddu $a3, $s2, $zero
/* 2CA8 800278A8 27A20028 */ addiu $v0, $sp, 0x28
/* 2CAC 800278AC 0C009C7F */ jal func_800271FC
/* 2CAC 800278AC 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2CB0 800278B0 AFA20010 */ sw $v0, 0x10($sp)
/* 2CB4 800278B4 0280202D */ daddu $a0, $s4, $zero
/* 2CB8 800278B8 02A0282D */ daddu $a1, $s5, $zero
/* 2CBC 800278BC 0260302D */ daddu $a2, $s3, $zero
/* 2CC0 800278C0 0220382D */ daddu $a3, $s1, $zero
/* 2CC4 800278C4 27A2002C */ addiu $v0, $sp, 0x2c
/* 2CC8 800278C8 0C009C7F */ jal func_800271FC
/* 2CC8 800278C8 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2CCC 800278CC AFA20010 */ sw $v0, 0x10($sp)
/* 2CD0 800278D0 0280202D */ daddu $a0, $s4, $zero
/* 2CD4 800278D4 02A0282D */ daddu $a1, $s5, $zero
/* 2CD8 800278D8 02E0302D */ daddu $a2, $s7, $zero
/* 2CDC 800278DC 0200382D */ daddu $a3, $s0, $zero
/* 2CE0 800278E0 27A20030 */ addiu $v0, $sp, 0x30
/* 2CE4 800278E4 0C009C7F */ jal func_800271FC
/* 2CE4 800278E4 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2CE8 800278E8 AFA20010 */ sw $v0, 0x10($sp)
/* 2CEC 800278EC 0280202D */ daddu $a0, $s4, $zero
/* 2CF0 800278F0 02A0282D */ daddu $a1, $s5, $zero
/* 2CF4 800278F4 02E0302D */ daddu $a2, $s7, $zero
/* 2CF8 800278F8 0240382D */ daddu $a3, $s2, $zero
/* 2CFC 800278FC 27A20034 */ addiu $v0, $sp, 0x34
/* 2D00 80027900 0C009C7F */ jal func_800271FC
/* 2D00 80027900 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2D04 80027904 AFA20010 */ sw $v0, 0x10($sp)
/* 2D08 80027908 0280202D */ daddu $a0, $s4, $zero
/* 2D0C 8002790C 02A0282D */ daddu $a1, $s5, $zero
/* 2D10 80027910 02E0302D */ daddu $a2, $s7, $zero
/* 2D14 80027914 0220382D */ daddu $a3, $s1, $zero
/* 2D18 80027918 27A20038 */ addiu $v0, $sp, 0x38
/* 2D1C 8002791C 0C009C7F */ jal func_800271FC
/* 2D1C 8002791C 0C009C7F */ jal gfx_frame_filter_pass_0
/* 2D20 80027920 AFA20010 */ sw $v0, 0x10($sp)
/* 2D24 80027924 00162840 */ sll $a1, $s6, 1
/* 2D28 80027928 8FA80078 */ lw $t0, 0x78($sp)

View File

@ -1,7 +1,7 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_8002725C
glabel gfx_frame_filter_pass_1
/* 265C 8002725C 27BDFF88 */ addiu $sp, $sp, -0x78
/* 2660 80027260 0080582D */ daddu $t3, $a0, $zero
/* 2664 80027264 AFA5007C */ sw $a1, 0x7c($sp)

View File

@ -16,11 +16,11 @@ load_engine_data = 0x80026DDC; // type:func rom:0x21DC
set_time_freeze_mode = 0x80027088; // type:func rom:0x2488
get_time_freeze_mode = 0x80027190; // type:func rom:0x2590
gfx_init_state = 0x800271A0; // type:func rom:0x25A0
func_800271FC = 0x800271FC; // type:func rom:0x25FC
func_8002725C = 0x8002725C; // type:func rom:0x265C
gfx_frame_filter_pass_0 = 0x800271FC; // type:func rom:0x25FC
gfx_frame_filter_pass_1 = 0x8002725C; // type:func rom:0x265C
func_80027600 = 0x80027600; // type:func rom:0x2A00
func_80027774 = 0x80027774; // type:func rom:0x2B74
func_800279B4 = 0x800279B4; // type:func rom:0x2DB4
gfx_transfer_frame_to_depth = 0x800279B4; // type:func rom:0x2DB4
func_80027BAC = 0x80027BAC; // type:func rom:0x2FAC
gfx_draw_background = 0x80027E10; // type:func rom:0x3210
func_800287F0 = 0x800287F0; // type:func rom:0x3BF0