Further documentations have been made:

- src/fight: named more variables and functions, named some parameters
- src/core1, src/core2: named some dummy functions, documented a bit of the graphics stack
This commit is contained in:
mariob92
2024-09-06 19:37:28 +02:00
parent fbeb744fc6
commit 539d6f4804
25 changed files with 521 additions and 505 deletions

View File

@@ -5,7 +5,7 @@
#include "gc/gctransition.h"
void func_8023E00C(enum map_e);
void setBootMap(enum map_e);
void func_8023DFF0(s32);
@@ -27,8 +27,8 @@ u8 pad_8027A138[0x400];
u64 D_8027A538;
u8 pad_8027A540[0x17F8];
OSThread s_MainThread;
s32 D_8027BEE8;
s32 D_8027BEEC;
s32 gBootMap;
s32 gDisableInput;
u64 D_8027BEF0;
extern u8 core2_TEXT_START[];
@@ -60,12 +60,12 @@ void func_8023DA9C(s32 arg0){
func_8023DA74();
D_8027A130 = arg0;
if (D_8027A130 == 3){
func_802E4214(D_8027BEE8);
func_802E4214(gBootMap);
}
if (D_8027A130 == 4){
func_802E35D0();
dummy_func_802E35D0();
}
func_80255CD8();
dummy_func_80255CD8();
}
u32 globalTimer_getTimeMasked(u32 mask){
@@ -80,40 +80,40 @@ void globalTimer_reset(void){
gGlobalTimer = 0;
}
s32 func_8023DB74(void){
enum map_e getSpecialBootMap(void){
return (DEBUG_use_special_bootmap())? MAP_80_GL_FF_ENTRANCE : MAP_91_FILE_SELECT;
}
s32 func_8023DBA4(void){
enum map_e getDefaultBootMap(void){
return MAP_1F_CS_START_RAREWARE;
}
void func_8023DBAC(void){
func_8023E00C(func_8023DBA4());
setBootMap(getDefaultBootMap());
func_8023DFF0(3);
}
void func_8023DBDC(void){
func_8023E00C(func_8023DB74());
setBootMap(getSpecialBootMap());
func_8023DFF0(3);
}
void core1_init(void){
func_80255C30();
func_8023E00C(func_8023DBA4());
setBootMap(getDefaultBootMap());
rarezip_init(); //initialize decompressor's huft table
func_8024BE30();
overlayManagerloadCore2();
D_8027BEF0 = D_8027A538;
heap_init();
func_80254028();
func_8025AFB0();
func_8033EF58();
dummy_func_8025AFB0();
allocUnusedBlock();
assetCache_init();
pfsManager_init();
rumbleManager_init();
audioManager_init();
func_8025425C();
graphicsCache_init();
ml_init();
gctransition_reset();
D_8027A130 = 0;
@@ -143,9 +143,10 @@ void mainLoop(void){
if(D_8027A130 != 3 || getGameMode() != GAME_MODE_4_PAUSED)
globalTimer_incTimer();
if(!D_8027BEEC)
if(!gDisableInput)
pfsManager_update();
D_8027BEEC = 0;
gDisableInput = 0;
rumbleManager_80250C08();
if(!mapSpecificFlags_validateCRC1()){
@@ -161,7 +162,7 @@ void mainLoop(void){
func_80255ACC();
spawnQueue_func_802C3A18();
if(func_802E4424())
func_802E3F8C(0);
game_draw(0);
spawnQueue_flush();
break;
}//L8023DE34
@@ -211,8 +212,8 @@ s32 func_8023E000(void){
return D_8027A130;
}
void func_8023E00C(enum map_e map_id){
D_8027BEE8 = map_id;
void setBootMap(enum map_e map_id){
gBootMap = map_id;
}
void mainThread_create(void){
@@ -225,6 +226,6 @@ OSThread *mainThread_get(void){
return &s_MainThread;
}
void func_8023E06C(void){
D_8027BEEC = 1;
void disableInput_set(void){
gDisableInput = 1;
}

View File

@@ -3,9 +3,9 @@
#include "variables.h"
struct {
u16 *unk0;
u16 *data;
int unk4;
} D_80282FE0;
} gzBuffer;
extern u8 D_8000E800;
extern u16 D_803A5D00[2][0xF660];
@@ -13,14 +13,14 @@ extern u16 D_803A5D00[2][0xF660];
void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer);
void func_80253190(Gfx **gdl){
func_80253208(gdl, 0, 0, framebuffer_width, framebuffer_height, D_803A5D00[func_8024BDA0()]);
func_80253208(gdl, 0, 0, framebuffer_width, framebuffer_height, D_803A5D00[getActiveFramebuffer()]);
}
void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer){
if( D_80282FE0.unk0 != NULL && (getGameMode() != GAME_MODE_4_PAUSED || func_80335134())){
if( gzBuffer.data != NULL && (getGameMode() != GAME_MODE_4_PAUSED || func_80335134())){
//draw z_buffer
gDPPipeSync((*gdl)++);
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(D_80282FE0.unk0));
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(gzBuffer.data));
gDPSetCycleType((*gdl)++, G_CYC_FILL);
gDPSetRenderMode((*gdl)++, G_RM_NOOP, G_RM_NOOP2);
gDPSetFillColor((*gdl)++, 0xFFFCFFFC);
@@ -33,44 +33,42 @@ void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer){
}
int func_80253400(void){
return D_80282FE0.unk4;
return gzBuffer.unk4;
}
int func_8025340C(void){
return D_80282FE0.unk0 != NULL;
return gzBuffer.data != NULL;
}
void func_80253420(void){}
void dummy_func_80253420(void){}
void func_80253428(int arg0) {
u16 *var_v0;
int new_var;
if (arg0) {
var_v0 = (D_80282FE0.unk0 = &D_8000E800);
while (((s32) D_80282FE0.unk0) % 0x40) {\
var_v0 = (D_80282FE0.unk0 = var_v0 + 1);
var_v0 = (gzBuffer.data = &D_8000E800);
while (((s32) gzBuffer.data) % 0x40) {\
var_v0 = (gzBuffer.data = var_v0 + 1);
}
do { } while ((&D_8000E800 && 1) * 0); //remove this
}else{
D_80282FE0.unk0 = 0;
gzBuffer.data = 0;
}
D_80282FE0.unk4 = 0;
gzBuffer.unk4 = 0;
}
void func_802534A8(int arg0){
D_80282FE0.unk4 = (D_80282FE0.unk0 != NULL && arg0);
gzBuffer.unk4 = (gzBuffer.data != NULL && arg0);
}
//zBuffer_set
void func_802534CC(Gfx **gdl){
if(D_80282FE0.unk0 && getGameMode() != GAME_MODE_4_PAUSED){
void zBuffer_set(Gfx **gdl){
if(gzBuffer.data && getGameMode() != GAME_MODE_4_PAUSED){
gDPPipeSync((*gdl)++);
gDPSetDepthImage((*gdl)++, D_80282FE0.unk0);
gDPSetDepthImage((*gdl)++, gzBuffer.data);
}
}
//zBuffer_get
void *func_80253540(void){
return D_80282FE0.unk0;
void *zBuffer_get(void){
return gzBuffer.data;
}

View File

@@ -14,28 +14,28 @@ typedef struct {
extern u8 D_803A5D00[2][0x1ecc0];
/* .data */
Gfx *D_80276580[2] = {NULL, NULL};
Gfx *gGfxStack[2] = {NULL, NULL};
s32 framebuffer_width = 292;
s32 framebuffer_height = 216;
/* .bss */
Mtx *D_80282FF0[2];
Vtx *D_80282FF8[2];
s32 D_80283000;
s32 D_80283004;
Mtx *gMtxStack[2];
Vtx *gVtxStack[2];
s32 gStackSelector;
s32 gTextureFilterPoint;
Struct_Core1_15B30 D_80283008[20];
s32 D_802831E8;
OSMesgQueue D_802831F0;
OSMesg D_80283208;
u16 D_8028320C;
u16 D_8028320E;
u16 D_80283210;
u16 D_80283212;
u16 gScissorBoxLeft;
u16 gScissorBoxRight;
u16 gScissorBoxTop;
u16 gScissorBoxBottom;
Gfx *D_80283214;
/* .h */
void func_80254348(void);
void func_80254464(void);
void scissorBox_setDefault(void);
void dummy_func_80254464(void);
/* .code */
void func_80253550(void){
@@ -71,13 +71,13 @@ void func_80253640(Gfx ** gdl, void *arg1){
gDPPipelineMode((*gdl)++, G_PM_NPRIMITIVE);
gDPSetAlphaCompare((*gdl)++, G_AC_NONE);
gDPSetColorDither((*gdl)++, G_CD_MAGICSQ);
gDPSetScissor((*gdl)++, G_SC_NON_INTERLACE, D_8028320C, D_8028320E, D_80283210, D_80283212);
gDPSetScissor((*gdl)++, G_SC_NON_INTERLACE, gScissorBoxLeft, gScissorBoxRight, gScissorBoxTop, gScissorBoxBottom);
func_80253208(gdl, 0, 0, framebuffer_width, framebuffer_height, arg1);
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(arg1));
gDPSetCycleType((*gdl)++, G_CYC_1CYCLE);
gDPSetTextureConvert((*gdl)++, G_TC_FILT);
gDPSetTextureDetail((*gdl)++, G_TD_CLAMP);
if(D_80283004){
if(gTextureFilterPoint){
gDPSetTextureFilter((*gdl)++, G_TF_POINT);
}else{
gDPSetTextureFilter((*gdl)++, G_TF_BILERP);
@@ -85,24 +85,24 @@ void func_80253640(Gfx ** gdl, void *arg1){
gDPSetTextureLOD((*gdl)++, G_TL_TILE);
gDPSetTextureLUT((*gdl)++, G_TT_NONE);
gDPSetTexturePersp((*gdl)++, G_TP_PERSP);
func_802534CC(gdl);
zBuffer_set(gdl);
}
void func_802539AC(Gfx **gdl, s32 arg1){
void scissorBox_SetForGameMode(Gfx **gdl, s32 framebuffer_idx) {
if(getGameMode() == GAME_MODE_8_BOTTLES_BONUS || getGameMode() == GAME_MODE_A_SNS_PICTURE)
{
func_8030C710();
scissorBox_setSmall();
func_80253640(gdl, func_8030C704());
}
else{
func_80254348();
func_80253640(gdl, D_803A5D00[arg1]);
scissorBox_setDefault();
func_80253640(gdl, D_803A5D00[framebuffer_idx]);
}
}
void func_80253A58(Gfx **gfx, s32 arg1){
void setupScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_address){
gSPSegment((*gfx)++, 0x00, 0x00000000);
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_PHYSICAL_TO_K0(arg1));
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_PHYSICAL_TO_K0(framebuffer_address));
gSPClearGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
gSPTexture((*gfx)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
gSPSetGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH);
@@ -113,20 +113,20 @@ void func_80253A58(Gfx **gfx, s32 arg1){
gDPSetColorDither((*gfx)++, G_CD_DISABLE);
gDPSetRenderMode((*gfx)++, G_RM_AA_ZB_XLU_LINE, G_RM_AA_ZB_XLU_LINE2);
gSPClipRatio((*gfx)++, FRUSTRATIO_1);
gDPSetScissor((*gfx)++, G_SC_NON_INTERLACE, D_8028320C, D_8028320E, D_80283210, D_80283212);
gDPSetScissor((*gfx)++, G_SC_NON_INTERLACE, gScissorBoxLeft, gScissorBoxRight, gScissorBoxTop, gScissorBoxBottom);
gDPPipeSync((*gfx)++);
}
void func_80253D60(Gfx **gfx, s32 arg1){
func_80254348();
func_80253A58(gfx, D_803A5D00[arg1]);
void setupDefaultScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_idx){
scissorBox_setDefault();
setupScissorBoxAndFramebuffer(gfx, D_803A5D00[framebuffer_idx]);
}
void func_80253DC0(Gfx **gfx){
func_802476EC(gfx);
}
void func_80253DE0(Gfx **gdl) {
void finishFrame(Gfx **gdl) {
gDPFullSync((*gdl)++);
gSPEndDisplayList((*gdl)++);
}
@@ -174,11 +174,11 @@ void func_80253F94(Gfx **arg0, Gfx **arg1){
func_80253EE4(arg0, arg1, 0x40000000);
}
void func_80253FB4(u32 *arg0, u32 *arg1, u32 *arg2, u32 *arg3){
*arg0 = D_8028320C;
*arg1 = D_80283210;
*arg2 = D_8028320E;
*arg3 = D_80283212;
void scissorBox_get(u32 *left, u32 *top, u32 *right, u32 *bottom){
*left = gScissorBoxLeft;
*top = gScissorBoxTop;
*right = gScissorBoxRight;
*bottom = gScissorBoxBottom;
}
void func_80253FE8(void){
@@ -194,10 +194,10 @@ void func_80254028(void){
osCreateMesgQueue(&D_802831F0, &D_80283208, 1);
osSendMesg(&D_802831F0, NULL, 1);
func_80247560();
func_80254348();
scissorBox_setDefault();
}
void func_80254084(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b){
void drawRectangle2D(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b){
gDPPipeSync((*gfx)++);
gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE);
gDPSetCycleType((*gfx)++, G_CYC_FILL);
@@ -206,45 +206,45 @@ void func_80254084(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b){
gDPScisFillRectangle((*gfx)++, x, y, x + w -1, y + h -1);
}
void func_802541E8(void){
if(D_80276580[0]){
free(D_80276580[0]);
free(D_80276580[1]);
free(D_80282FF0[0]);
free(D_80282FF0[1]);
free(D_80282FF8[0]);
free(D_80282FF8[1]);
D_80276580[0] = NULL;
void graphicsCache_release(void){
if(gGfxStack[0]){
free(gGfxStack[0]);
free(gGfxStack[1]);
free(gMtxStack[0]);
free(gMtxStack[1]);
free(gVtxStack[0]);
free(gVtxStack[1]);
gGfxStack[0] = NULL;
}
}
void func_8025425C(void){
if(D_80276580[0] == NULL){
D_80276580[0] = (Gfx *)malloc(29600);
D_80276580[1] = (Gfx *)malloc(29600);
D_80282FF0[0] = (Mtx *)malloc(44800);
D_80282FF0[1] = (Mtx *)malloc(44800);
D_80282FF8[0] = (Vtx *)malloc(6880);
D_80282FF8[1] = (Vtx *)malloc(6880);
func_80254464();
void graphicsCache_init(void){
if(gGfxStack[0] == NULL){
gGfxStack[0] = (Gfx *)malloc(29600); // 3700 dlist commands
gGfxStack[1] = (Gfx *)malloc(29600);
gMtxStack[0] = (Mtx *)malloc(44800); // 700 matrices
gMtxStack[1] = (Mtx *)malloc(44800);
gVtxStack[0] = (Vtx *)malloc(6880); // 430 vertices
gVtxStack[1] = (Vtx *)malloc(6880);
dummy_func_80254464();
}
D_80283000 = 0;
D_80283004 = 0;
gStackSelector = 0;
gTextureFilterPoint = 0;
}
void func_802542F4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) {
D_8028320C = arg0;
D_80283210 = arg1;
D_8028320E = arg2;
D_80283212 = arg3;
framebuffer_width = arg1 - arg0;
framebuffer_height = arg3 - arg2;
void scissorBox_set(s32 left, s32 top, s32 right, s32 bottom) {
gScissorBoxLeft = left;
gScissorBoxTop = top;
gScissorBoxRight = right;
gScissorBoxBottom = bottom;
framebuffer_width = top - left;
framebuffer_height = bottom - right;
func_8024CC5C();
}
void func_80254348(void){
func_802542F4(0, 0x124, 0, 0xd8);
void scissorBox_setDefault(void){
scissorBox_set(0, 292, 0, 216);
}
void func_80254374(s32 arg0) {
@@ -259,16 +259,16 @@ void func_80254374(s32 arg0) {
func_80246670(sp1C);
}
void func_802543EC(void){
u32 ret_val = D_80283004;
D_80283004 = ret_val < 1;
void toggleTextureFilterPoint(void){
u32 ret_val = gTextureFilterPoint;
gTextureFilterPoint = ret_val < 1;
}
void func_80254404(Gfx **gfx, Mtx **mtx, Vtx **vtx){
D_80283000 = (1 - D_80283000);
*gfx = D_80276580[D_80283000];
*mtx = D_80282FF0[D_80283000];
*vtx = D_80282FF8[D_80283000];
void getGraphicsStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx){
gStackSelector = (1 - gStackSelector);
*gfx = gGfxStack[gStackSelector];
*mtx = gMtxStack[gStackSelector];
*vtx = gVtxStack[gStackSelector];
}
void func_80254464(void){}
void dummy_func_80254464(void){}

View File

@@ -18,7 +18,7 @@ void func_80255C30(void) {
}
}
void func_80255CD8(void){}
void dummy_func_80255CD8(void){}
void func_80255CE0(void){
osPiReadIo(0, NULL);

View File

@@ -3,13 +3,13 @@
#include "variables.h"
void func_8025AFB0(void) {}
void dummy_func_8025AFB0(void) {}
void func_8025AFB8(void) {}
void dummy_func_8025AFB8(void) {}
void func_8025AFC0(Gfx **arg0, Mtx **arg1, Vtx **arg2) {}
void dummy_func_8025AFC0(Gfx **arg0, Mtx **arg1, Vtx **arg2) {}
s32 func_8025AFD0(void)
s32 dummy_func_8025AFD0(void)
{
return 0;
}

View File

@@ -245,7 +245,7 @@ void func_80246D78(void){
osDpSetStatus(DPC_CLR_FREEZE);
D_8027FC14 = D_8027FC18;
func_8025AFB8();
dummy_func_8025AFB8();
if(D_8027FC14 & 1){
D_80275998 = 0x1E;

View File

@@ -56,7 +56,7 @@ OSViMode D_80275CD0 = {
// C3A68832 DDC3A724 00000000 00000000
u32 D_80280720;
u32 gActiveFramebuffer;
u32 D_80280724;
u32 D_80280728;
struct1 D_80280730[8];
@@ -80,15 +80,15 @@ void func_8024C428(void);
/* .code */
bool func_8024BD80(void){
sizeof(OSThread);
return NOT(D_80280720);
return NOT(gActiveFramebuffer);
}
s32 func_8024BD94(void){
return D_80280724;
}
s32 func_8024BDA0(void){
return D_80280720;
s32 getActiveFramebuffer(void){
return gActiveFramebuffer;
}
void func_8024BDAC(OSMesgQueue *mq, OSMesg msg){
@@ -107,7 +107,7 @@ void func_8024BE30(void){
s32 i;
func_8024C428();
osCreateViManager(0xfe);
osCreateViManager(OS_PRIORITY_VIMGR);
if(osTvType != OS_TV_NTSC)
osViSetMode(&D_80275CD0); //PAL
else
@@ -120,7 +120,7 @@ void func_8024BE30(void){
osCreateMesgQueue(&D_802807B0, D_802807C8, 1);
osCreateMesgQueue(&D_802807D0, D_802807E8, 60);
osViSetEvent(&D_80280770,NULL,1);
D_80280720 = 0;
gActiveFramebuffer = 0;
D_80280724 = 1;
D_80280728 = 0;
for(i = 0; i<8; i++){
@@ -162,7 +162,7 @@ void func_8024BFD8(s32 arg0){
osRecvMesg(&D_802807D0, NULL, OS_MESG_NOBLOCK);
}
osViSwapBuffer(D_803A5D00[D_80280720 = func_8024BD80()]);
osViSwapBuffer(D_803A5D00[gActiveFramebuffer = func_8024BD80()]);
D_80280E90 = 0;
while(!(osDpGetStatus() & 2) && osViGetCurrentFramebuffer() != osViGetNextFramebuffer()){
osRecvMesg(&D_802807D0, NULL, OS_MESG_BLOCK);
@@ -177,7 +177,7 @@ void func_8024BFD8(s32 arg0){
void func_8024C1B4(void){
func_8024BFD8(0);
func_8025AFB8();
dummy_func_8025AFB8();
}
void func_8024C1DC(void){
@@ -195,8 +195,8 @@ void func_8024C1FC(OSMesgQueue *mq, OSMesg msg){
}
void func_8024C2A0(s32 arg0) {
D_80280720 = arg0;
osViSwapBuffer(D_803A5D00[D_80280720]);
gActiveFramebuffer = arg0;
osViSwapBuffer(D_803A5D00[gActiveFramebuffer]);
}
void func_8024C2F8(void *arg0){

View File

@@ -804,7 +804,7 @@ void func_80255A3C(void){
if(!func_802559A0()){
ml_defrag();
func_80254464();
dummy_func_80254464();
}
}