Skip to content

Commit

Permalink
Match most of 1EC0F10.c, finish 1E965B0.c, attempt func_800C0BC0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Wiseguy committed Sep 22, 2024
1 parent 378adf9 commit 98c8dfd
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 32 deletions.
2 changes: 1 addition & 1 deletion include/gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ u32 func_80014EC8();

// RSP Segments
typedef enum {
RSP_SEGMENT_FACE_CULLING = 7,
RSP_SEGMENT_FACE_CULLING = 7
} RSPSegmentId;

#endif
14 changes: 12 additions & 2 deletions src/core2/1E965B0.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,19 @@ void func_800BCF90(unkfunc_800BCE84* arg0, f32* joystick_values_out) {
joystick_values_out[1] = joystick_values[1];
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E965B0/func_800BCFC4.s")
int func_800BCFC4(unkfunc_800BCE84* arg0, ButtonId button) {
ButtonData* temp_v0;

temp_v0 = func_800BCCC0(arg0, arg0->unk8[button]);
return !temp_v0->data[button].pressed && (arg0->counter - temp_v0->data[button].timestamp) == 1;
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E965B0/func_800BD030.s")
int func_800BD030(unkfunc_800BCE84* arg0, ButtonId button) {
ButtonData* temp_v0;

temp_v0 = func_800BCCC0(arg0, arg0->unk8[button]);
return temp_v0->data[button].pressed && (arg0->counter - temp_v0->data[button].timestamp) == 1;
}

void func_800BD09C(unkfunc_800BCE84* arg0) {
heap_free(arg0);
Expand Down
44 changes: 43 additions & 1 deletion src/core2/1E99980.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "common.h"
#include <ultra64.h>
#include "gfx.h"

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E99980/func_800C0090.s")

Expand Down Expand Up @@ -69,7 +70,48 @@ void func_800C0A2C(void) {

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E99980/func_800C0BB4.s")

// Probably a file split here based on bk decomp and bss (D_80128AF4)

extern Gfx D_8011A7E0[];
extern Gfx D_8011A840[];

#define ROUND_UP_DIVIDE(x, y) (((x) + (y) - 1) / (y))

#if 0
// Scratch: https://decomp.me/scratch/iFD8T
// Much higher percent scratch with expanded macros: https://decomp.me/scratch/cyGKA

// copy_framebuffer
void func_800C0BC0(Gfx** gfx, void* destination, void* source) {
s32 row;
s32 col;
Gfx* cur_gfx = *gfx;

gSPDisplayList(cur_gfx++, OS_K0_TO_PHYSICAL(D_8011A7E0));
gDPSetColorImage(cur_gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, OS_K0_TO_PHYSICAL(destination));

for (row = 0; row < ROUND_UP_DIVIDE(SCREEN_HEIGHT, 32); row++) {
for (col = 0; col < ROUND_UP_DIVIDE(SCREEN_WIDTH, 32); col++) {
gDPLoadTextureTile(cur_gfx++, osVirtualToPhysical(source), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, SCREEN_HEIGHT,
(col * 32), (row * 32), ((col + 1) * 32 - 1), ((row + 1) * 32 - 1), 0,
G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gSPScisTextureRectangle(cur_gfx++,
(col * 32) * 4, (row * 32) * 4,
((col + 1) * 32) * 4, ((row + 1) * 32) * 4,
0,
(col * 32) << 5, (row * 32) << 5,
1 << 10, 1 << 10);
}
}

gSPDisplayList(cur_gfx++, OS_K0_TO_PHYSICAL(D_8011A840));
gDPSetColorImage(cur_gfx++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, OS_K0_TO_PHYSICAL(func_80014F00()));

*gfx = cur_gfx;
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E99980/func_800C0BC0.s")
#endif

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1E99980/func_800C0F8C.s")

Expand Down
23 changes: 9 additions & 14 deletions src/core2/1EBCFC0.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern Mtx* D_8012D558;

s32 func_80018BC4();
s32 func_800A89F8();
s32 func_800C4C34(s32, s32, s32, s32);
s32 func_800C4C34(s32, s32, s32, s32*);
void func_800CA314(s32, s32);
s32 func_800CA334();
void func_800CA364(s32);
Expand Down Expand Up @@ -101,21 +101,16 @@ void func_800E443C(MtxF*, f32[3], f32);

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EBCFC0/func_800E40DC.s")

#if 0
u32 func_800E4140(s32 arg0, s32 arg1) {
u32 ret;
u32 sp20;
ret = func_800C4C34(func_800A89F8(), arg0, arg1, &sp20) != 0;
if (!ret) {
ret = sp20 != 0;
}
return ret;
int func_800E4140(s32 arg0, s32 arg1) {
int temp_t6;
s32 sp20;
int var_v0;

temp_t6 = func_800C4C34(func_800A89F8(), arg0, arg1, &sp20);
return temp_t6 && sp20;
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EBCFC0/func_800E4140.s")
#endif

void func_800E4190(s32 arg0, s32 arg1, s32 arg2) {
void func_800E4190(s32 arg0, s32 arg1, s32* arg2) {
func_800C4C34(func_800A89F8(), arg0, arg1, arg2);
}

Expand Down
158 changes: 146 additions & 12 deletions src/core2/1EC0F10.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,159 @@
#include "common.h"
#include <ultra64.h>

// compare_vec4i
int func_800F371C(u32[4], u32[4]);
// copy_vec4i
void func_800F2E7C(u32[4], u32[4]);

typedef struct {
/* 0x00 */ u32 prim_color[4];
/* 0x10 */ u32 texture_lut;
/* 0x14 */ u32 cycle_type;
/* 0x18 */ u32 filtering_mode;
/* 0x1C */ u32 texture_persp;
/* 0x20 */ u32 combiner;
/* 0x24 */ u8 needs_pipesync;
/* 0x25 */ u8 unk25;
} unkD_8012D580;

extern unkD_8012D580 D_8012D580;

#ifdef NON_MATCHING
// regalloc
void func_800E7620(void) {
unkD_8012D580* state = &D_8012D580;

state->prim_color[0] =
state->prim_color[1] =
state->prim_color[2] =
state->prim_color[3] =
state->cycle_type =
state->combiner =
state->filtering_mode = (u32)-1;

state->texture_lut = 0;
state->texture_persp = G_TP_PERSP;
state->needs_pipesync = FALSE;
}
#else
#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7620.s")
#endif

// do_pipesync
void func_800E765C(Gfx** gfx) {
if (D_8012D580.needs_pipesync) {
gDPPipeSync((*gfx)++);
D_8012D580.needs_pipesync = FALSE;
}
}

// set_needs_pipesync
void func_800E7694() {
D_8012D580.needs_pipesync = TRUE;
}

// set_combiner
void func_800E76A4(Gfx** gfx, s32 arg1) {
if (D_8012D580.combiner != arg1) {
D_8012D580.combiner = arg1;
func_800E765C(gfx);
switch (arg1) {
case 0:
gDPSetCombineLERP((*gfx)++,
TEXEL0, 0, PRIMITIVE, 0,
TEXEL0, 0, PRIMITIVE, 0,
TEXEL0, 0, PRIMITIVE, 0,
TEXEL0, 0, PRIMITIVE, 0);
break;
case 1:
gDPSetCombineLERP((*gfx)++,
0, 0, 0, TEXEL0,
TEXEL0, 0, TEXEL1, 0,
COMBINED, 0, PRIMITIVE, 0,
COMBINED, 0, PRIMITIVE, 0);
break;
case 2:
gDPSetCombineLERP((*gfx)++,
0, 0, 0, PRIMITIVE,
0, 0, 0, PRIMITIVE,
0, 0, 0, PRIMITIVE,
0, 0, 0, PRIMITIVE);
break;
}
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E765C.s")
// set_cycle_type
void func_800E7778(Gfx** gfx, u32 cycle_type) {
if (D_8012D580.cycle_type != cycle_type) {
D_8012D580.cycle_type = cycle_type;
func_800E765C(gfx);
gDPSetCycleType((*gfx)++, cycle_type);

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7694.s")
// Pick a render mode suitable for the cycle type.
if (cycle_type == G_CYC_1CYCLE) {
gDPSetRenderMode((*gfx)++, G_RM_XLU_SURF | ZMODE_XLU, G_RM_XLU_SURF2 | ZMODE_XLU);
}
else {
gDPSetRenderMode((*gfx)++, G_RM_PASS, G_RM_XLU_SURF2 | ZMODE_XLU);
}
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E76A4.s")
// set_primitive_color
void func_800E7828(Gfx** gfx, u8 color[4]) {
u32 color_u32[4];
func_800F2EFC(color_u32, color);
if (!func_800F371C(D_8012D580.prim_color, color_u32)) {
func_800F2E7C(D_8012D580.prim_color, color_u32);
func_800E765C(gfx);

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7778.s")
gDPSetPrimColor((*gfx)++, 0, 0, color_u32[0], color_u32[1], color_u32[2], color_u32[3]);
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7828.s")
// set_texture_filtering_mode
void func_800E78C8(Gfx** gfx, u32 mode) {
if (D_8012D580.filtering_mode != mode) {
D_8012D580.filtering_mode = mode;
func_800E765C(gfx);
gDPSetTextureFilter((*gfx)++, mode);
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E78C8.s")
// set_texture_lut
void func_800E7928(Gfx** gfx, u32 texture_lut) {
if (D_8012D580.texture_lut != texture_lut) {
D_8012D580.texture_lut = texture_lut;
func_800E765C(gfx);
gDPSetTextureLUT((*gfx)++, texture_lut);
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7928.s")
// set_texture_persp
void func_800E7988(Gfx** gfx, u32 texture_persp) {
if (D_8012D580.texture_persp != texture_persp) {
D_8012D580.texture_persp = texture_persp;
func_800E765C(gfx);
gDPSetTexturePersp((*gfx)++, texture_persp);
}
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7988.s")
extern Gfx D_80123310[];

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E79E8.s")
void func_800E79E8(Gfx** gfx) {
gSPDisplayList((*gfx)++, OS_K0_TO_PHYSICAL(D_80123310));
func_800E7620();
D_8012D580.unk25 = 1;
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7A2C.s")
void func_800E7A2C(Gfx** gfx) {
func_800E7620();
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1EC0F10/func_800E7A4C.s")
void func_800E7A4C(Gfx** gfx) {
func_800E7928(gfx, G_TT_NONE);
func_800E7988(gfx, G_TP_PERSP);
func_800E78C8(gfx, G_TF_BILERP);
D_8012D580.unk25 = 0;
}
11 changes: 9 additions & 2 deletions src/core2/1ECBCC0.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ void func_800F2E60(s32 arg0[3], s32 arg1[3]) {
arg0[2] = arg1[2];
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1ECBCC0/func_800F2E7C.s")
void func_800F2E7C(s32 arg0[4], s32 arg1[4]) {
arg0[0] = arg1[0];
arg0[1] = arg1[1];
arg0[2] = arg1[2];
arg0[3] = arg1[3];
}

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1ECBCC0/func_800F2EA0.s")

Expand Down Expand Up @@ -86,4 +91,6 @@ void func_800F2E60(s32 arg0[3], s32 arg1[3]) {

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1ECBCC0/func_800F36D4.s")

#pragma GLOBAL_ASM("asm/nonmatchings/core2/1ECBCC0/func_800F371C.s")
int func_800F371C(u32 arg0[4], u32 arg1[4]) {
return arg0[0] == arg1[0] && arg0[1] == arg1[1] && arg0[2] == arg1[2] && arg0[3] == arg1[3];
}

0 comments on commit 98c8dfd

Please sign in to comment.