diff --git a/decompile/General/231/231_014_RB_Potion_ThTick_InAir.c b/decompile/General/231/231_014_RB_Potion_ThTick_InAir.c index 7bc48305b..cdad706f5 100644 --- a/decompile/General/231/231_014_RB_Potion_ThTick_InAir.c +++ b/decompile/General/231/231_014_RB_Potion_ThTick_InAir.c @@ -54,7 +54,7 @@ void DECOMP_RB_Potion_ThTick_InAir(struct Thread* t) SPS->ptr_mesh_info = gGT->level1->ptr_mesh_info; - COLL_SearchBSP_CallbackQUADBLK((u_int*)&posBottom, (u_int*)&posTop, SPS, 0); //the method signature goes posTop, posBottom? is this a bug? + COLL_SearchBSP_CallbackQUADBLK(posBottom, posTop, SPS, 0); //the method signature goes posTop, posBottom? is this a bug? RB_MakeInstanceReflective(SPS, inst); @@ -115,7 +115,7 @@ void DECOMP_RB_Potion_ThTick_InAir(struct Thread* t) posBottom[1] = inst->matrix.t[1] - 0x900; posBottom[2] = inst->matrix.t[2]; - COLL_SearchBSP_CallbackQUADBLK((u_int*)&posBottom, (u_int*)&posTop, SPS, 0); + COLL_SearchBSP_CallbackQUADBLK(posBottom, posTop, SPS, 0); // quadblock exists far below potion, dont destroy if (SPS->boolDidTouchQuadblock != 0) return; diff --git a/decompile/General/231/231_024_RB_MovingExplosive_ThTick.c b/decompile/General/231/231_024_RB_MovingExplosive_ThTick.c index f8d8d865d..cdbe1e179 100644 --- a/decompile/General/231/231_024_RB_MovingExplosive_ThTick.c +++ b/decompile/General/231/231_024_RB_MovingExplosive_ThTick.c @@ -278,7 +278,7 @@ LAB_800adc08:; sps->ptr_mesh_info = gGT->level1->ptr_mesh_info; - COLL_SearchBSP_CallbackQUADBLK((u_int*)&posA, (u_int*)&posB, sps, 0); + COLL_SearchBSP_CallbackQUADBLK(posA, posB, sps, 0); RB_MakeInstanceReflective(sps,inst); @@ -309,7 +309,7 @@ LAB_800adc08:; posA[1] = inst->matrix.t[1] - 0x900; posA[2] = inst->matrix.t[2]; - COLL_SearchBSP_CallbackQUADBLK((u_int*)&posA, (u_int*)&posB, sps, 0); + COLL_SearchBSP_CallbackQUADBLK(posA, posB, sps, 0); // if still nothing, then explode if (sps->boolDidTouchQuadblock == 0) diff --git a/decompile/General/231/231_073_RB_Default_LInB.c b/decompile/General/231/231_073_RB_Default_LInB.c index a8d0ea7d3..ce81a5332 100644 --- a/decompile/General/231/231_073_RB_Default_LInB.c +++ b/decompile/General/231/231_073_RB_Default_LInB.c @@ -27,7 +27,7 @@ void DECOMP_RB_Default_LInB(struct Instance* inst) *(short*)&scratch[0x112] = var + 0x80; COLL_SearchBSP_CallbackQUADBLK( - (u_int*)&scratch[0x108], (u_int*)&scratch[0x110], (struct ScratchpadStruct*)&scratch[0x118], 0); //this scratchpadstruct is +0x118 from 0x1f800000, that may be a problem? all other function calls I've seen just pass 0x1f800000 + (short*)&scratch[0x108], (short*)&scratch[0x110], (struct ScratchpadStruct*)&scratch[0x118], 0); //this scratchpadstruct is +0x118 from 0x1f800000, that may be a problem? all other function calls I've seen just pass 0x1f800000 RB_MakeInstanceReflective((struct ScratchpadStruct*)&scratch[0x118], inst); } \ No newline at end of file diff --git a/decompile/General/233/233_33_CS_Podium_FullScene_Init.c b/decompile/General/233/233_33_CS_Podium_FullScene_Init.c index 3cef1c009..1600f3fc7 100644 --- a/decompile/General/233/233_33_CS_Podium_FullScene_Init.c +++ b/decompile/General/233/233_33_CS_Podium_FullScene_Init.c @@ -2,7 +2,6 @@ void CS_Podium_Stand_Init(u_short *); void CS_Podium_Prize_Init(u_int, char*, short *); -int CS_Thread_Init(u_int, char*, short *, short, u_int); void CS_Camera_ThTick_Podium(int param_1); void DECOMP_CS_Podium_FullScene_Init() diff --git a/decompile/General/BOTS/BOTS_13_CollideWithOtherAI.c b/decompile/General/BOTS/BOTS_13_CollideWithOtherAI.c index 8b4dd417b..791d92830 100644 --- a/decompile/General/BOTS/BOTS_13_CollideWithOtherAI.c +++ b/decompile/General/BOTS/BOTS_13_CollideWithOtherAI.c @@ -23,7 +23,7 @@ void DECOMP_BOTS_CollideWithOtherAI(struct Driver* robot_1, struct Driver* robot short botPathIndex = robot_1->botData.botPath; // pointer to navFrame - nfCurr = &robot_1->botData.botNavFrame; + nfCurr = robot_1->botData.botNavFrame; nfNext = nfCurr + 1; // iVar4 @@ -33,13 +33,13 @@ void DECOMP_BOTS_CollideWithOtherAI(struct Driver* robot_1, struct Driver* robot if (sdata->NavPath_ptrHeader[botPathIndex]->last <= (struct NavFrame*)nfNext) { // loop back to first navFrame - nfNext = &sdata->NavPath_ptrNavFrameArray[botPathIndex]; + nfNext = sdata->NavPath_ptrNavFrameArray[botPathIndex]; } } else { // pointer to nav frame - nfNext = &robot_1->botData.botNavFrame; + nfNext = robot_1->botData.botNavFrame; // iVar4 estimatePos = robot_1->botData.estimatePos; diff --git a/decompile/General/BOTS/BOTS_16_Driver_Convert.c b/decompile/General/BOTS/BOTS_16_Driver_Convert.c index 93a3612e7..4b87f7464 100644 --- a/decompile/General/BOTS/BOTS_16_Driver_Convert.c +++ b/decompile/General/BOTS/BOTS_16_Driver_Convert.c @@ -32,7 +32,7 @@ void DECOMP_BOTS_Driver_Convert(struct Driver* d) // If all 3 are checked, quit if (navPathIndex == initialNavPathIndex) - return NULL; + return; } memset(&d->botData, 0, sizeof(struct BotData)); diff --git a/decompile/General/CAMERA/CAM_17_FollowDriver_Normal.c b/decompile/General/CAMERA/CAM_17_FollowDriver_Normal.c index 6ae9cadb1..2975427d9 100644 --- a/decompile/General/CAMERA/CAM_17_FollowDriver_Normal.c +++ b/decompile/General/CAMERA/CAM_17_FollowDriver_Normal.c @@ -1,6 +1,6 @@ #include -void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, struct PushBuffer* pb, int scratchpad, struct ZoomData *zoom) +void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, struct PushBuffer* pb, struct ScratchpadStructExtended* scratchpad, struct ZoomData *zoom) { struct GameTracker *gGT = sdata->gGT; struct GamepadBuffer *pad = &sdata->gGamepads->gamepad[d->driverID]; @@ -99,11 +99,12 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru uVar8 = 0xff9c; } - *(short *)(scratchpad + 0x20c) = uVar8; + //scratchpad->bspSearchTriangle[0].quadblock = (struct QuadBlock*)uVar8; + *(short *)(((int)scratchpad) + 0x20c) = uVar8; // 0x20e // camera RotY - *(u_short *)(scratchpad + 0x20e) = + *(u_short *)(((int)scratchpad) + 0x20e) = ( d->rotCurr.w + d->angle + @@ -111,18 +112,18 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru sVar10 ) & 0xfff; - *(short *)(scratchpad + 0x210) = cDC->desiredRot[0] * -2; + *(short *)(((int)scratchpad) + 0x210) = cDC->desiredRot[0] * -2; // convert 3 rotation shorts into rotation matrix - ConvertRotToMatrix(scratchpad + 0x220, scratchpad + 0x20c); + ConvertRotToMatrix(((int)scratchpad) + 0x220, ((int)scratchpad) + 0x20c); if (((cDC->flags & 0x80) != 0) && (x = (int)((u_int)d->fireSpeedCap << 0x10) >> 0x14, *(int*)&cDC->unk_b8[4] < x)) { *(int*)&cDC->unk_b8[4] = x; } - *(short *)(scratchpad + 0x20c) = 0; - *(short *)(scratchpad + 0x20e) = 0; + *(short *)(((int)scratchpad) + 0x20c) = 0; + *(short *)(((int)scratchpad) + 0x20e) = 0; uVar8 = DECOMP_VehCalc_MapToRange ( @@ -131,7 +132,7 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru (int)zoom->distMin, (int)zoom->distMax ); - *(short *)(scratchpad + 0x210) = uVar8; + *(short *)(((int)scratchpad) + 0x210) = uVar8; if (*(int*)&cDC->unk_b8[4] == 0) { @@ -153,56 +154,56 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru if (*(int*)&cDC->unk_b8[4] < 0) *(int*)&cDC->unk_b8[4] = 0; } - *(short *)(scratchpad + 0x210) += *(int*)&cDC->unk_b8[0] >> 8; + *(short *)(((int)scratchpad) + 0x210) += *(int*)&cDC->unk_b8[0] >> 8; - gte_SetRotMatrix((MATRIX *)(scratchpad + 0x220)); - psVar12 = (SVECTOR *)(scratchpad + 0x20c); + gte_SetRotMatrix((MATRIX *)(((int)scratchpad) + 0x220)); + psVar12 = (SVECTOR *)(((int)scratchpad) + 0x20c); gte_ldv0(psVar12); gte_rtv0(); - gte_stlvnl((VECTOR *)(scratchpad + 0x240)); + gte_stlvnl((VECTOR *)(((int)scratchpad) + 0x240)); - *(short *)(scratchpad + 0x20c) = 0; - *(short *)(scratchpad + 0x20e) = 0x40; - *(short *)(scratchpad + 0x210) = 0; + *(short *)(((int)scratchpad) + 0x20c) = 0; + *(short *)(((int)scratchpad) + 0x20e) = 0x40; + *(short *)(((int)scratchpad) + 0x210) = 0; gte_ldv0(psVar12); gte_rtv0(); - gte_stlvnl((VECTOR *)(scratchpad + 0x27c)); + gte_stlvnl((VECTOR *)(((int)scratchpad) + 0x27c)); - *(int *)(scratchpad + 600) = d->posCurr.x >> 8; - *(int *)(scratchpad + 0x25c) = d->posCurr.y >> 8; - *(int *)(scratchpad + 0x260) = d->posCurr.z >> 8; + *(int *)(((int)scratchpad) + 600) = d->posCurr.x >> 8; + *(int *)(((int)scratchpad) + 0x25c) = d->posCurr.y >> 8; + *(int *)(((int)scratchpad) + 0x260) = d->posCurr.z >> 8; - *(int *)(scratchpad + 600) += *(int *)(scratchpad + 0x27c); - *(int *)(scratchpad + 0x260) += *(int *)(scratchpad + 0x284); - *(int *)(scratchpad + 0x240) += *(int *)(scratchpad + 600); + *(int *)(((int)scratchpad) + 600) += *(int *)(((int)scratchpad) + 0x27c); + *(int *)(((int)scratchpad) + 0x260) += *(int *)(((int)scratchpad) + 0x284); + *(int *)(((int)scratchpad) + 0x240) += *(int *)(((int)scratchpad) + 600); // mask-grab if ((cDC->flags & 0x10) != 0) { - *(int *)(scratchpad + 0x244) = (d->quadBlockHeight >> 8) + (int)cDC->unk98 + (int)zoom->vertDistance; + *(int *)(((int)scratchpad) + 0x244) = (d->quadBlockHeight >> 8) + (int)cDC->unk98 + (int)zoom->vertDistance; } else { - *(int *)(scratchpad + 0x244) += *(int *)(scratchpad + 0x25c) + (int)zoom->vertDistance; + *(int *)(((int)scratchpad) + 0x244) += *(int *)(((int)scratchpad) + 0x25c) + (int)zoom->vertDistance; } - *(int *)(scratchpad + 0x248) += *(int *)(scratchpad + 0x260); + *(int *)(((int)scratchpad) + 0x248) += *(int *)(((int)scratchpad) + 0x260); uVar8 = 0; if (gGT->numPlyrCurrGame != 2) uVar8 = 0xff9c; // rotX - *(short *)(scratchpad + 0x20c) = uVar8; + *(short *)(((int)scratchpad) + 0x20c) = uVar8; // rotZ - *(short *)(scratchpad + 0x210) = 0; + *(short *)(((int)scratchpad) + 0x210) = 0; // rotY - *(u_short *)(scratchpad + 0x20e) = + *(u_short *)(((int)scratchpad) + 0x20e) = ( d->rotCurr.w + d->angle + @@ -212,7 +213,7 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru ) & 0xfff; // convert 3 rotation shorts into rotation matrix - ConvertRotToMatrix(scratchpad + 0x220, scratchpad + 0x20c); + ConvertRotToMatrix(((int)scratchpad) + 0x220, ((int)scratchpad) + 0x20c); // if racer is not damaged, // slight-down view angle @@ -233,21 +234,21 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru } // Z, Y, X - *(short *)(scratchpad + 0x210) = cDC->unk1A; - *(short *)(scratchpad + 0x20e) = 0; - *(short *)(scratchpad + 0x20c) = 0; + *(short *)(((int)scratchpad) + 0x210) = cDC->unk1A; + *(short *)(((int)scratchpad) + 0x20e) = 0; + *(short *)(((int)scratchpad) + 0x20c) = 0; - gte_SetRotMatrix((MATRIX *)(scratchpad + 0x220)); + gte_SetRotMatrix((MATRIX *)(((int)scratchpad) + 0x220)); - psVar12 = (SVECTOR *)(scratchpad + 0x20c); + psVar12 = (SVECTOR *)(((int)scratchpad) + 0x20c); gte_ldv0(psVar12); gte_rtv0(); gte_stsv(psVar12); - *(int *)(scratchpad + 600) += (int)*(short *)(scratchpad + 0x20c); - *(int *)(scratchpad + 0x260) += (int)*(short *)(scratchpad + 0x210); - *(int *)(scratchpad + 0x25c) += (int)*(short *)(scratchpad + 0x20e) + (int)zoom->angle[2]; + *(int *)(((int)scratchpad) + 600) += (int)*(short *)(((int)scratchpad) + 0x20c); + *(int *)(((int)scratchpad) + 0x260) += (int)*(short *)(((int)scratchpad) + 0x210); + *(int *)(((int)scratchpad) + 0x25c) += (int)*(short *)(((int)scratchpad) + 0x20e) + (int)zoom->angle[2]; cDC->desiredRot[0] = ( @@ -262,9 +263,9 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru if (state == KS_MASK_GRABBED) { // pushBuffer position - *(int *)(scratchpad + 0x240) = (int)pb->pos[0]; - *(int *)(scratchpad + 0x244) = (int)pb->pos[1]; - *(int *)(scratchpad + 0x248) = (int)pb->pos[2]; + *(int *)(((int)scratchpad) + 0x240) = (int)pb->pos[0]; + *(int *)(((int)scratchpad) + 0x244) = (int)pb->pos[1]; + *(int *)(((int)scratchpad) + 0x248) = (int)pb->pos[2]; // reset camera interpolation *(short *)((int)cDC + 0xc0) = 0; @@ -288,13 +289,13 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru { cDC->BlastedLerp.boolLerpPending = 0; - cDC->BlastedLerp.desiredRot[0] = cDC->unkTriplet3[0] - *(short *)(scratchpad + 600); - cDC->BlastedLerp.desiredRot[1] = cDC->unkTriplet3[1] - *(short *)(scratchpad + 0x25c); - cDC->BlastedLerp.desiredRot[2] = cDC->unkTriplet3[2] - *(short *)(scratchpad + 0x260); + cDC->BlastedLerp.desiredRot[0] = cDC->unkTriplet3[0] - *(short *)(((int)scratchpad) + 600); + cDC->BlastedLerp.desiredRot[1] = cDC->unkTriplet3[1] - *(short *)(((int)scratchpad) + 0x25c); + cDC->BlastedLerp.desiredRot[2] = cDC->unkTriplet3[2] - *(short *)(((int)scratchpad) + 0x260); - cDC->BlastedLerp.desiredPos[0] = cDC->unkTriplet2[0] - *(short *)(scratchpad + 0x240); - cDC->BlastedLerp.desiredPos[1] = cDC->unkTriplet2[1] - *(short *)(scratchpad + 0x244); - cDC->BlastedLerp.desiredPos[2] = cDC->unkTriplet2[2] - *(short *)(scratchpad + 0x248); + cDC->BlastedLerp.desiredPos[0] = cDC->unkTriplet2[0] - *(short *)(((int)scratchpad) + 0x240); + cDC->BlastedLerp.desiredPos[1] = cDC->unkTriplet2[1] - *(short *)(((int)scratchpad) + 0x244); + cDC->BlastedLerp.desiredPos[2] = cDC->unkTriplet2[2] - *(short *)(((int)scratchpad) + 0x248); cDC->BlastedLerp.framesRemaining = FPS_DOUBLE(8); } @@ -317,11 +318,11 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru cDC->BlastedLerp.boolLerpPending = 1; - if (((int)cDC->unkTriplet2[1] < *(int *)(scratchpad + 0x244)) && + if (((int)cDC->unkTriplet2[1] < *(int *)(((int)scratchpad) + 0x244)) && (x = (int)*(short *)((int)cDC + 0xca) + (d->quadBlockHeight >> 8), - x < *(int *)(scratchpad + 0x244))) + x < *(int *)(((int)scratchpad) + 0x244))) { - *(int *)(scratchpad + 0x244) = x; + *(int *)(((int)scratchpad) + 0x244) = x; } LAB_8001a8b0: @@ -337,13 +338,13 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru { cDC->BlastedLerp.boolLerpPending = 0; - cDC->BlastedLerp.desiredRot[0] = cDC->unkTriplet3[0] - *(short *)(scratchpad + 0x258); - cDC->BlastedLerp.desiredRot[1] = cDC->unkTriplet3[1] - *(short *)(scratchpad + 0x25c); - cDC->BlastedLerp.desiredRot[2] = cDC->unkTriplet3[2] - *(short *)(scratchpad + 0x260); + cDC->BlastedLerp.desiredRot[0] = cDC->unkTriplet3[0] - *(short *)(((int)scratchpad) + 0x258); + cDC->BlastedLerp.desiredRot[1] = cDC->unkTriplet3[1] - *(short *)(((int)scratchpad) + 0x25c); + cDC->BlastedLerp.desiredRot[2] = cDC->unkTriplet3[2] - *(short *)(((int)scratchpad) + 0x260); - cDC->BlastedLerp.desiredPos[0] = cDC->unkTriplet2[0] - *(short *)(scratchpad + 0x240); - cDC->BlastedLerp.desiredPos[1] = cDC->unkTriplet2[1] - *(short *)(scratchpad + 0x244); - cDC->BlastedLerp.desiredPos[2] = cDC->unkTriplet2[2] - *(short *)(scratchpad + 0x248); + cDC->BlastedLerp.desiredPos[0] = cDC->unkTriplet2[0] - *(short *)(((int)scratchpad) + 0x240); + cDC->BlastedLerp.desiredPos[1] = cDC->unkTriplet2[1] - *(short *)(((int)scratchpad) + 0x244); + cDC->BlastedLerp.desiredPos[2] = cDC->unkTriplet2[2] - *(short *)(((int)scratchpad) + 0x248); cDC->BlastedLerp.framesRemaining = FPS_DOUBLE(8); @@ -355,82 +356,82 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru // if frame countdown is not finished if (cDC->BlastedLerp.framesRemaining != 0) { - *(int *)(scratchpad + 0x240) += (cDC->BlastedLerp.desiredPos[0] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); - *(int *)(scratchpad + 0x244) += (cDC->BlastedLerp.desiredPos[1] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); - *(int *)(scratchpad + 0x248) += (cDC->BlastedLerp.desiredPos[2] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x240) += (cDC->BlastedLerp.desiredPos[0] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x244) += (cDC->BlastedLerp.desiredPos[1] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x248) += (cDC->BlastedLerp.desiredPos[2] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); - *(int *)(scratchpad + 0x258) += (cDC->BlastedLerp.desiredRot[0] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); - *(int *)(scratchpad + 0x25c) += (cDC->BlastedLerp.desiredRot[1] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); - *(int *)(scratchpad + 0x260) += (cDC->BlastedLerp.desiredRot[2] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x258) += (cDC->BlastedLerp.desiredRot[0] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x25c) += (cDC->BlastedLerp.desiredRot[1] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); + *(int *)(((int)scratchpad) + 0x260) += (cDC->BlastedLerp.desiredRot[2] * cDC->BlastedLerp.framesRemaining) >> FPS_RIGHTSHIFT(3); // decrease frame countdown cDC->BlastedLerp.framesRemaining--; } } - CAM_FindClosestQuadblock(scratchpad, cDC, d, scratchpad + 0x240); + CAM_FindClosestQuadblock(((int)scratchpad), cDC, d, ((int)scratchpad) + 0x240); if ( - (*(short *)(scratchpad + 0x3e) == 0) || + (*(short *)(((int)scratchpad) + 0x3e) == 0) || // quadblock->quadFlags & 0x4100 - ((*(u_short *)(*(int *)(scratchpad + 0x80) + 0x12) & 0x4100) != 0)) + ((*(u_short *)(*(int *)(((int)scratchpad) + 0x80) + 0x12) & 0x4100) != 0)) { - if (*(int *)(scratchpad + 0x244) < (int)cDC->framesZoomingOut + (d->posCurr.y >> 8)) + if (*(int *)(((int)scratchpad) + 0x244) < (int)cDC->framesZoomingOut + (d->posCurr.y >> 8)) { *(short *)((int)cDC + 0xc2) = 8; *(short *)((int)cDC + 0xc0) = cDC->framesZoomingOut; - *(int *)(scratchpad + 0x244) = (int)cDC->framesZoomingOut + (d->posCurr.y >> 8); + *(int *)(((int)scratchpad) + 0x244) = (int)cDC->framesZoomingOut + (d->posCurr.y >> 8); goto LAB_8001ab04; } *(short *)((int)cDC + 0xc2) = 8; - *(short *)((int)cDC + 0xc0) = *(short *)(scratchpad + 0x244) - (short)(d->posCurr.y >> 8); + *(short *)((int)cDC + 0xc0) = *(short *)(((int)scratchpad) + 0x244) - (short)(d->posCurr.y >> 8); } else { // quadblock->terrainFlags - state = *(char *)(*(int *)(scratchpad + 0x80) + 0x38); + state = *(char *)(*(int *)(((int)scratchpad) + 0x80) + 0x38); // Mud, Water, or FastWater if (((state == 0xe) || (state == 4)) || (state == 0xd)) { - *(short *)(scratchpad + 0x1e) = 0; + *(short *)(((int)scratchpad) + 0x1e) = 0; } - x = (int)*(short *)(scratchpad + 0x1e) + (int)zoom->vertDistance; - if (*(int *)(scratchpad + 0x244) < x) + x = (int)*(short *)(((int)scratchpad) + 0x1e) + (int)zoom->vertDistance; + if (*(int *)(((int)scratchpad) + 0x244) < x) { - *(int *)(scratchpad + 0x244) = x; + *(int *)(((int)scratchpad) + 0x244) = x; } x = (int)*(short *)((int)cDC + 0xc2); if (x != 0) { - *(int *)(scratchpad + 0x244) = + *(int *)(((int)scratchpad) + 0x244) = - (8 - x) * *(int *)(scratchpad + 0x244) + + (8 - x) * *(int *)(((int)scratchpad) + 0x244) + x * ((int)*(short *)((int)cDC + 0xc0) + (d->posCurr.y >> 8)) >> 3; *(short *)((int)cDC + 0xc2) += -1; } } - cDC->framesZoomingOut = *(short *)(scratchpad + 0x244) - (d->posCurr.y >> 8); + cDC->framesZoomingOut = *(short *)(((int)scratchpad) + 0x244) - (d->posCurr.y >> 8); LAB_8001ab04: // if mask grabs you when you're underwater if (((gGT->level1->configFlags & 2) != 0) && - (*(int *)(scratchpad + 0x244) < zoom->vertDistance)) + (*(int *)(((int)scratchpad) + 0x244) < zoom->vertDistance)) { - *(int *)(scratchpad + 0x244) = zoom->vertDistance; + *(int *)(((int)scratchpad) + 0x244) = zoom->vertDistance; } if (cDC->BlastedLerp.boolLerpPending != 0) { - *(int *)(scratchpad + 0x25c) = *(int *)(scratchpad + 0x244) + (int)*(short *)((int)cDC + 0xc8); + *(int *)(((int)scratchpad) + 0x25c) = *(int *)(((int)scratchpad) + 0x244) + (int)*(short *)((int)cDC + 0xc8); } if (d->kartState == KS_MASK_GRABBED) @@ -438,13 +439,13 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru pb->rot[2] -= (pb->rot[2] >> 3); // camera dirX, cameraPosX minus driverPosX - *(int *)(scratchpad + 0x24c) = (int)pb->pos[0] - (d->posCurr.x >> 8); + *(int *)(((int)scratchpad) + 0x24c) = (int)pb->pos[0] - (d->posCurr.x >> 8); // camera dirY, cameraPosY minus driverPosY, plus something else - *(int *)(scratchpad + 0x250) = (int)pb->pos[1] - ((d->posCurr.y >> 8) + (int)zoom->angle[2]); + *(int *)(((int)scratchpad) + 0x250) = (int)pb->pos[1] - ((d->posCurr.y >> 8) + (int)zoom->angle[2]); // camera dirZ, cameraPosZ minus driverPosZ - *(int *)(scratchpad + 0x254) = (int)pb->pos[2] - (d->posCurr.z >> 8); + *(int *)(((int)scratchpad) + 0x254) = (int)pb->pos[2] - (d->posCurr.z >> 8); if (pb->rot[0] < 0x800) { @@ -457,36 +458,36 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru // if not mask grab else { - x = *(int *)(scratchpad + 0x248) - *(int *)(scratchpad + 0x260); + x = *(int *)(((int)scratchpad) + 0x248) - *(int *)(((int)scratchpad) + 0x260); // camera direction - *(int *)(scratchpad + 0x254) = x; - *(int *)(scratchpad + 0x24c) = *(int *)(scratchpad + 0x240) - *(int *)(scratchpad + 600); - *(int *)(scratchpad + 0x250) = *(int *)(scratchpad + 0x244) - *(int *)(scratchpad + 0x25c); + *(int *)(((int)scratchpad) + 0x254) = x; + *(int *)(((int)scratchpad) + 0x24c) = *(int *)(((int)scratchpad) + 0x240) - *(int *)(((int)scratchpad) + 600); + *(int *)(((int)scratchpad) + 0x250) = *(int *)(((int)scratchpad) + 0x244) - *(int *)(((int)scratchpad) + 0x25c); // camera rotation - x_00 = ratan2(*(long *)(scratchpad + 0x24c), x); + x_00 = ratan2(*(long *)(((int)scratchpad) + 0x24c), x); pb->rot[1] = (short)x_00; x_00 = SquareRoot0_stub( - *(int *)(scratchpad + 0x24c) * *(int *)(scratchpad + 0x24c) + - *(int *)(scratchpad + 0x254) * *(int *)(scratchpad + 0x254) + *(int *)(((int)scratchpad) + 0x24c) * *(int *)(((int)scratchpad) + 0x24c) + + *(int *)(((int)scratchpad) + 0x254) * *(int *)(((int)scratchpad) + 0x254) ); - x_00 = ratan2(*(long *)(scratchpad + 0x250), x_00); + x_00 = ratan2(*(long *)(((int)scratchpad) + 0x250), x_00); pb->rot[0] = 0x800 - (short)x_00; pb->rot[2] = (short)((u_int)((int)zoom->angle[0] * (int)cDC->desiredRot[0]) >> 8); } // something with pushBuffer position - *(int *)(scratchpad + 0x214) = *(int *)(scratchpad + 0x240) - (int)pb->pos[0]; - *(int *)(scratchpad + 0x218) = *(int *)(scratchpad + 0x244) - (int)pb->pos[1]; - *(int *)(scratchpad + 0x21c) = *(int *)(scratchpad + 0x248) - (int)pb->pos[2]; + *(int *)(((int)scratchpad) + 0x214) = *(int *)(((int)scratchpad) + 0x240) - (int)pb->pos[0]; + *(int *)(((int)scratchpad) + 0x218) = *(int *)(((int)scratchpad) + 0x244) - (int)pb->pos[1]; + *(int *)(((int)scratchpad) + 0x21c) = *(int *)(((int)scratchpad) + 0x248) - (int)pb->pos[2]; - cDC->unkTriplet1[0] -= (*(int *)(scratchpad + 0x240) - *(int *)((int)cDC + 0x58)); - cDC->unkTriplet1[1] -= (*(int *)(scratchpad + 0x244) - *(int *)((int)cDC + 0x5c)); - cDC->unkTriplet1[2] -= (*(int *)(scratchpad + 0x248) - *(int *)((int)cDC + 0x60)); + cDC->unkTriplet1[0] -= (*(int *)(((int)scratchpad) + 0x240) - *(int *)((int)cDC + 0x58)); + cDC->unkTriplet1[1] -= (*(int *)(((int)scratchpad) + 0x244) - *(int *)((int)cDC + 0x5c)); + cDC->unkTriplet1[2] -= (*(int *)(((int)scratchpad) + 0x248) - *(int *)((int)cDC + 0x60)); if (cDC->unkTriplet1[0] > 2) cDC->unkTriplet1[0] = 2; if (cDC->unkTriplet1[1] > 2) cDC->unkTriplet1[1] = 2; @@ -499,17 +500,17 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru if (d->kartState != KS_MASK_GRABBED) { // pushBuffer position - pb->pos[0] += *(short *)(scratchpad + 0x214) + cDC->unkTriplet1[0]; - pb->pos[1] += *(short *)(scratchpad + 0x218) + cDC->unkTriplet1[1]; - pb->pos[2] += *(short *)(scratchpad + 0x21c) + cDC->unkTriplet1[2]; + pb->pos[0] += *(short *)(((int)scratchpad) + 0x214) + cDC->unkTriplet1[0]; + pb->pos[1] += *(short *)(((int)scratchpad) + 0x218) + cDC->unkTriplet1[1]; + pb->pos[2] += *(short *)(((int)scratchpad) + 0x21c) + cDC->unkTriplet1[2]; } - cDC->unkTriplet2[0] = *(int *)(scratchpad + 0x240); - cDC->unkTriplet2[1] = *(int *)(scratchpad + 0x244); - cDC->unkTriplet2[2] = *(int *)(scratchpad + 0x248); - cDC->unkTriplet3[0] = *(int *)(scratchpad + 0x258); - cDC->unkTriplet3[1] = *(int *)(scratchpad + 0x25c); - cDC->unkTriplet3[2] = *(int *)(scratchpad + 0x260); + cDC->unkTriplet2[0] = *(int *)(((int)scratchpad) + 0x240); + cDC->unkTriplet2[1] = *(int *)(((int)scratchpad) + 0x244); + cDC->unkTriplet2[2] = *(int *)(((int)scratchpad) + 0x248); + cDC->unkTriplet3[0] = *(int *)(((int)scratchpad) + 0x258); + cDC->unkTriplet3[1] = *(int *)(((int)scratchpad) + 0x25c); + cDC->unkTriplet3[2] = *(int *)(((int)scratchpad) + 0x260); // backup flags (again) backupFlags = cDC->flags; @@ -530,7 +531,7 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru // if end-of-race battle if ((backupFlags & 4) != 0) { - DECOMP_CAM_FollowDriver_Spin360(cDC, scratchpad, d, &local_40[0], &local_38[0]); + DECOMP_CAM_FollowDriver_Spin360(cDC, ((int)scratchpad), d, &local_40[0], &local_38[0]); // reverse interpolation of fly-in [0x1000 to 0] x = 0x1000 - cDC->unk8C; @@ -621,11 +622,11 @@ void DECOMP_CAM_FollowDriver_Normal(struct CameraDC *cDC, struct Driver *d, stru &pb->pos[0], &pb->rot[0], x); - *(int *)(scratchpad + 0x240) = (int)pb->pos[0]; - *(int *)(scratchpad + 0x244) = (int)pb->pos[1]; - *(int *)(scratchpad + 0x248) = (int)pb->pos[2]; + *(int *)(((int)scratchpad) + 0x240) = (int)pb->pos[0]; + *(int *)(((int)scratchpad) + 0x244) = (int)pb->pos[1]; + *(int *)(((int)scratchpad) + 0x248) = (int)pb->pos[2]; - CAM_FindClosestQuadblock(scratchpad, cDC, d, scratchpad + 0x240); + CAM_FindClosestQuadblock(((int)scratchpad), cDC, d, ((int)scratchpad) + 0x240); x = cDC->frameCounterTransition; iVar14 = cDC->frameCounterTransition; diff --git a/decompile/General/CDSYS/CDSYS_07_SpuCallbackIRQ.c b/decompile/General/CDSYS/CDSYS_07_SpuCallbackIRQ.c index 870e63f07..aef826c87 100644 --- a/decompile/General/CDSYS/CDSYS_07_SpuCallbackIRQ.c +++ b/decompile/General/CDSYS/CDSYS_07_SpuCallbackIRQ.c @@ -17,7 +17,7 @@ half. // from TOMB5 // https://github.com/TOMB5/TOMB5/blob/master/EMULATOR/LIBSPU.H #define SPU_CDONLY 5 - SpuReadDecodedData(&sdata->SpuDecodedBuf[0], SPU_CDONLY); + SpuReadDecodedData((short*)&sdata->SpuDecodedBuf[0], SPU_CDONLY); if( (sdata->XA_boolFinished == 0) && diff --git a/decompile/General/CDSYS/CDSYS_11_SpuGetMaxSample.c b/decompile/General/CDSYS/CDSYS_11_SpuGetMaxSample.c index ae14b3930..2fdd3f96f 100644 --- a/decompile/General/CDSYS/CDSYS_11_SpuGetMaxSample.c +++ b/decompile/General/CDSYS/CDSYS_11_SpuGetMaxSample.c @@ -8,7 +8,7 @@ void DECOMP_CDSYS_SpuGetMaxSample(void) max = 0; short* ptrSpuBuf = - &sdata->SpuDecodedBuf[sdata->irqAddr << 9]; + (short*)&sdata->SpuDecodedBuf[sdata->irqAddr << 9]; // absolute value, find max in block for (int i = 0; i < 0x100; i++) diff --git a/decompile/General/LOAD/LOAD_08_Callback_PatchMem.c b/decompile/General/LOAD/LOAD_08_Callback_PatchMem.c index 8466e05ed..40c9f4eec 100644 --- a/decompile/General/LOAD/LOAD_08_Callback_PatchMem.c +++ b/decompile/General/LOAD/LOAD_08_Callback_PatchMem.c @@ -12,12 +12,12 @@ void DECOMP_LOAD_Callback_PatchMem() // it loads one ReadFile for PtrMap with AllocHighMem // that's why patchPtr is here - patchPtr = sdata->PatchMem_Ptr; + patchPtr = (char*)sdata->PatchMem_Ptr; patchStart = &patchPtr[4]; patchSize = *(int*)&patchPtr[0]; patchNum = patchSize >> 2; - DECOMP_LOAD_RunPtrMap((int)sdata->ptrLevelFile, (int*)patchStart, patchNum); + DECOMP_LOAD_RunPtrMap((char*)sdata->ptrLevelFile, (int*)patchStart, patchNum); return; } \ No newline at end of file diff --git a/decompile/General/LOAD/LOAD_16_DramFileCallback.c b/decompile/General/LOAD/LOAD_16_DramFileCallback.c index e28a3f491..50b9bcbcc 100644 --- a/decompile/General/LOAD/LOAD_16_DramFileCallback.c +++ b/decompile/General/LOAD/LOAD_16_DramFileCallback.c @@ -19,7 +19,7 @@ void DECOMP_LOAD_DramFileCallback(struct LoadQueueSlot* lqs) { struct DramPointerMap* dpm = (struct DramPointerMap*)&realFileBuf[ptrMapOffset]; - DECOMP_LOAD_RunPtrMap((int)realFileBuf, (int*)DRAM_GETOFFSETS(dpm), dpm->numBytes>>2); + DECOMP_LOAD_RunPtrMap(realFileBuf, (int*)DRAM_GETOFFSETS(dpm), dpm->numBytes>>2); DRAM_SET_PATCHED(fileBuf); diff --git a/decompile/General/LOAD/LOAD_18_VramFileCallback.c b/decompile/General/LOAD/LOAD_18_VramFileCallback.c index 57294a1be..13f14fcb3 100644 --- a/decompile/General/LOAD/LOAD_18_VramFileCallback.c +++ b/decompile/General/LOAD/LOAD_18_VramFileCallback.c @@ -26,7 +26,7 @@ void DECOMP_LOAD_VramFileCallback(struct LoadQueueSlot* lqs) LoadImage(&vh->rect, VRAMHEADER_GETPIXLES(vh)); // goto next - vramBuf = (u_int)vh + size; + vramBuf = (int*)((int)vh + size); size = vramBuf[0]; vh = (struct VramHeader*)&vramBuf[1]; diff --git a/decompile/General/LOAD/LOAD_28_RunPtrMap.c b/decompile/General/LOAD/LOAD_28_RunPtrMap.c index a256b92ed..ec04f18a5 100644 --- a/decompile/General/LOAD/LOAD_28_RunPtrMap.c +++ b/decompile/General/LOAD/LOAD_28_RunPtrMap.c @@ -11,6 +11,6 @@ void DECOMP_LOAD_RunPtrMap(char* origin, int* patchArr, int numPtrs) ) { *(int*)&origin[*ptrCurrOffset] = - *(int*)&origin[*ptrCurrOffset] + origin; + (int)(*(int*)&origin[*ptrCurrOffset] + origin); } } \ No newline at end of file diff --git a/decompile/General/LOAD/LOAD_31_DriverMPK.c b/decompile/General/LOAD/LOAD_31_DriverMPK.c index 7e54e46a7..1f1f9d20d 100644 --- a/decompile/General/LOAD/LOAD_31_DriverMPK.c +++ b/decompile/General/LOAD/LOAD_31_DriverMPK.c @@ -1,6 +1,6 @@ #include -static int cbDRAM = DECOMP_LOAD_DramFileCallback; +static void(*cbDRAM)(struct LoadQueueSlot*) = DECOMP_LOAD_DramFileCallback; #ifdef USE_DRIVERRND diff --git a/decompile/General/LOAD/LOAD_36_NextQueuedFile.c b/decompile/General/LOAD/LOAD_36_NextQueuedFile.c index 24c4a65b0..7755323e7 100644 --- a/decompile/General/LOAD/LOAD_36_NextQueuedFile.c +++ b/decompile/General/LOAD/LOAD_36_NextQueuedFile.c @@ -39,17 +39,16 @@ void DECOMP_LOAD_NextQueuedFile() // BEFORE calling ReadFile, which may change it int* prevValue = curr->ptrDestination; - int forceSetAddr = 0; + int* forceSetAddr = (int*)0; if ((curr->flags & LT_SETADDR) != 0) forceSetAddr = prevValue; DECOMP_LOAD_ReadFile(0, curr->flags | LT_ASYNC, - curr->subfileIndex, forceSetAddr); + curr->subfileIndex, (void*)forceSetAddr); if ((curr->flags & LT_GETADDR) != 0) { - *prevValue = curr->ptrDestination; - *prevValue = *prevValue + 4; + *prevValue = (int)curr->ptrDestination + 4; } } \ No newline at end of file diff --git a/decompile/General/LOAD/LOAD_37_Hub_ReadFile.c b/decompile/General/LOAD/LOAD_37_Hub_ReadFile.c index f8a52402c..3711f137f 100644 --- a/decompile/General/LOAD/LOAD_37_Hub_ReadFile.c +++ b/decompile/General/LOAD/LOAD_37_Hub_ReadFile.c @@ -1,7 +1,7 @@ #include // packID will always be 3-gGT->activeMempackIndex -void DECOMP_LOAD_Hub_ReadFile(int bigfile, int levID, int packID) +void DECOMP_LOAD_Hub_ReadFile(struct BigHeader* bigfile, int levID, int packID) { int iVar2; struct GameTracker* gGT = sdata->gGT; diff --git a/decompile/General/LOAD/LOAD_38_Hub_SwapNow.c b/decompile/General/LOAD/LOAD_38_Hub_SwapNow.c index 43aa54563..ebf371b8f 100644 --- a/decompile/General/LOAD/LOAD_38_Hub_SwapNow.c +++ b/decompile/General/LOAD/LOAD_38_Hub_SwapNow.c @@ -67,7 +67,7 @@ void DECOMP_LOAD_Hub_SwapNow() { DECOMP_LibraryOfModels_Store( gGT, level1->numModels, - (int*)level1->ptrModelsPtrArray); + level1->ptrModelsPtrArray); DECOMP_INSTANCE_LevInitAll( level1->ptrInstDefs, @@ -75,7 +75,7 @@ void DECOMP_LOAD_Hub_SwapNow() DECOMP_LevInstDef_UnPack(level1->ptr_mesh_info); - DECOMP_DecalGlobal_Store(gGT, (struct Icon*)level1->levTexLookup); //2nd param might be `level1->levTexLookup->firstIcon` + DECOMP_DecalGlobal_Store(gGT, level1->levTexLookup); } #ifndef REBUILD_PS1 diff --git a/decompile/General/LOAD/LOAD_39_Hub_Main.c b/decompile/General/LOAD/LOAD_39_Hub_Main.c index d20c0b157..6aceb08c2 100644 --- a/decompile/General/LOAD/LOAD_39_Hub_Main.c +++ b/decompile/General/LOAD/LOAD_39_Hub_Main.c @@ -1,6 +1,6 @@ #include -void DECOMP_LOAD_Hub_Main(int bigfilePtr) +void DECOMP_LOAD_Hub_Main(struct BigHeader* bigfilePtr) { struct GameTracker* gGT; diff --git a/decompile/General/LOAD/LOAD_44_TenStages.c b/decompile/General/LOAD/LOAD_44_TenStages.c index 3458ce249..b45fc282d 100644 --- a/decompile/General/LOAD/LOAD_44_TenStages.c +++ b/decompile/General/LOAD/LOAD_44_TenStages.c @@ -682,7 +682,7 @@ int DECOMP_LOAD_TenStages(struct GameTracker* gGT, int loadingStage, struct BigH // podium first place u_char* ptrIndexArr = &gGT->podium_modelIndex_First; - int* ptrModelPtrArr = &data.podiumModel_firstPlace; + struct Model** ptrModelPtrArr = &data.podiumModel_firstPlace; int baseIndexPM = BI_DANCEMODELWIN; // Fix for Oxide (faster than OG code that does nothing) @@ -691,7 +691,7 @@ int DECOMP_LOAD_TenStages(struct GameTracker* gGT, int loadingStage, struct BigH baseIndexPM = BI_DANCEMODELLOSE; int fileIndex; - int drmCb = DECOMP_LOAD_DramFileCallback; + void (*drmCb)(struct LoadQueueSlot*) = DECOMP_LOAD_DramFileCallback; // Loop through 3 podium models for(int i = 0; i < 3; i++) diff --git a/decompile/General/MEMPACK/MEMPACK_00_Init.c b/decompile/General/MEMPACK/MEMPACK_00_Init.c index 85f909212..d04330879 100644 --- a/decompile/General/MEMPACK/MEMPACK_00_Init.c +++ b/decompile/General/MEMPACK/MEMPACK_00_Init.c @@ -15,7 +15,7 @@ void OVR_Region3(); void DECOMP_MEMPACK_Init(int ramSize) { - unsigned int startPtr; + char* startPtr; int packSize; #ifdef REBUILD_PC @@ -53,8 +53,8 @@ void DECOMP_MEMPACK_Init(int ramSize) // Original game allocated 0x800 to stack, // but now Stack is relocated to kernel memory - startPtr = ((u_int)OVR_Region3 + Aligned231); - packSize = ramSize - (int)(startPtr & 0xffffff); + startPtr = (char*)((u_int)OVR_Region3 + Aligned231); + packSize = ramSize - (int)((int)startPtr & 0xffffff); #endif DECOMP_MEMPACK_NewPack(startPtr, packSize); diff --git a/decompile/General/RECTMENU/RECTMENU_02_DrawTime.c b/decompile/General/RECTMENU/RECTMENU_02_DrawTime.c index 1e3b3d65c..d7aee979c 100644 --- a/decompile/General/RECTMENU/RECTMENU_02_DrawTime.c +++ b/decompile/General/RECTMENU/RECTMENU_02_DrawTime.c @@ -10,7 +10,7 @@ u_char* DECOMP_RECTMENU_DrawTime(int milliseconds) // the original game actually did this char* str = &sdata->mempack[4]; #else - char* str = 0x1f800000; + char* str = (char*)0x1f800000; #endif // build a string diff --git a/decompile/General/RaceFlag/RaceFlag_13_DrawSelf.c b/decompile/General/RaceFlag/RaceFlag_13_DrawSelf.c index 629755e38..d20fae448 100644 --- a/decompile/General/RaceFlag/RaceFlag_13_DrawSelf.c +++ b/decompile/General/RaceFlag/RaceFlag_13_DrawSelf.c @@ -123,7 +123,7 @@ void DECOMP_RaceFlag_DrawSelf() toggle = toggle ^ 1; posR = (u_int *)(0x1f800000 + toggle * 0x78); local = (u_int *)(0x1f8000F0); - pos = (u_int *)(0x1f800108); + pos = (SVECTOR *)(0x1f800108); #endif local[0] = data.checkerFlagVariables[0]; diff --git a/decompile/General/UI/UI_51_VsQuipDrawAll.c b/decompile/General/UI/UI_51_VsQuipDrawAll.c index a7780d215..2d12cecb3 100644 --- a/decompile/General/UI/UI_51_VsQuipDrawAll.c +++ b/decompile/General/UI/UI_51_VsQuipDrawAll.c @@ -43,7 +43,7 @@ void DECOMP_UI_VsQuipDrawAll(void) else { // Add two strings together - sprintf(0x1f800000, + sprintf((char*)0x1f800000, // Contains '%s' format: // Original end-of-race comment @@ -55,7 +55,7 @@ void DECOMP_UI_VsQuipDrawAll(void) sdata->lngStrings[data.MetaDataCharacters[d->EndOfRaceComment_characterID].name_LNG_long]); // Overwrite the stack pointer to print - print = 0x1f800000; + print = (char*)0x1f800000; } // get current player's pushBuffer diff --git a/decompile/General/UI/UI_52_VsWaitForPressX.c b/decompile/General/UI/UI_52_VsWaitForPressX.c index 503791ff4..fefdc9b5a 100644 --- a/decompile/General/UI/UI_52_VsWaitForPressX.c +++ b/decompile/General/UI/UI_52_VsWaitForPressX.c @@ -87,7 +87,7 @@ void DECOMP_UI_VsWaitForPressX(void) if (numPlyr == 2) { - shortArr = &sdata->Battle_EndOfRace.textFlags1_2P; + shortArr = sdata->Battle_EndOfRace.textFlags1_2P; } // YOU HIT THEM @@ -104,7 +104,7 @@ void DECOMP_UI_VsWaitForPressX(void) // only 8 bytes, use scratchpad - sprintf(0x1f800000, "p%d:%2.02d", + sprintf((char*)0x1f800000, "p%d:%2.02d", // basically, j + 1 // which is (1, 2, 3, 4) @@ -120,7 +120,7 @@ void DECOMP_UI_VsWaitForPressX(void) local_78 = (sVar4 + 0x18U | 0x8000); - DecalFont_DrawLine(0x1f800000, + DecalFont_DrawLine((char*)0x1f800000, // midpoint between Start X and Size X (r->x + shortArr[j*2+0]), @@ -140,7 +140,7 @@ void DECOMP_UI_VsWaitForPressX(void) // 4-byte RGBA = black *(int*)0x1f800000 = 0; - DECOMP_CTR_Box_DrawClearBox(r, 0x1f800000, 0, gGT->backBuffer->otMem.startPlusFour); + DECOMP_CTR_Box_DrawClearBox(r, (Color*)0x1f800000, 0, gGT->backBuffer->otMem.startPlusFour); // Allow Go-Back option to YouHit/HitYou if ((tap & BTN_SQUARE) != 0) diff --git a/decompile/General/Vehicle/VehBirth_0_TeleportSelf.c b/decompile/General/Vehicle/VehBirth_0_TeleportSelf.c index b2b909c76..c82efe56a 100644 --- a/decompile/General/Vehicle/VehBirth_0_TeleportSelf.c +++ b/decompile/General/Vehicle/VehBirth_0_TeleportSelf.c @@ -184,7 +184,7 @@ void DECOMP_VehBirth_TeleportSelf(struct Driver *d, u_char spawnFlag, int spawnP #endif // get coords where driver based on driver order (0-7) - posRot = &level1->DriverSpawn[sdata->kartSpawnOrderArray[d->driverID]]; + posRot = (struct PosRot*)&level1->DriverSpawn[sdata->kartSpawnOrderArray[d->driverID]]; rotArr = &posRot->rot[0]; rotDeltaY = 0x400; } @@ -234,7 +234,7 @@ void DECOMP_VehBirth_TeleportSelf(struct Driver *d, u_char spawnFlag, int spawnP sps->Union.QuadBlockColl.searchFlags = (gGT->numPlyrCurrGame > 3) ? 2 : 0; sps->ptr_mesh_info = level1->ptr_mesh_info; - COLL_SearchBSP_CallbackQUADBLK(&posTop[0], &posBottom[0], sps, 0); + COLL_SearchBSP_CallbackQUADBLK(posTop, posBottom, sps, 0); // if collision was not found if (sps->boolDidTouchQuadblock == 0) diff --git a/decompile/General/Vehicle/VehPickupItem_4_ShootNow.c b/decompile/General/Vehicle/VehPickupItem_4_ShootNow.c index 28e9c03eb..e796c49e4 100644 --- a/decompile/General/Vehicle/VehPickupItem_4_ShootNow.c +++ b/decompile/General/Vehicle/VehPickupItem_4_ShootNow.c @@ -348,7 +348,7 @@ void DECOMP_VehPickupItem_ShootNow(struct Driver* d, int weaponID, int flags) sps->ptr_mesh_info = gGT->level1->ptr_mesh_info; - COLL_SearchBSP_CallbackQUADBLK((u_int*)pos1, (u_int*)pos2, sps, 0x40); + COLL_SearchBSP_CallbackQUADBLK(pos1, pos2, sps, 0x40); if(sps->boolDidTouchHitbox != 0) { @@ -375,7 +375,7 @@ void DECOMP_VehPickupItem_ShootNow(struct Driver* d, int weaponID, int flags) } sps->Union.QuadBlockColl.searchFlags = 0; - COLL_SearchBSP_CallbackQUADBLK((u_int*)pos1, (u_int*)pos2, sps, 0); + COLL_SearchBSP_CallbackQUADBLK(pos1, pos2, sps, 0); } RB_MakeInstanceReflective(sps, weaponInst); diff --git a/decompile/General/zGlobal_DCACHE.c b/decompile/General/zGlobal_DCACHE.c new file mode 100644 index 000000000..02fd10d05 --- /dev/null +++ b/decompile/General/zGlobal_DCACHE.c @@ -0,0 +1,3 @@ +//Since ps1 doesn't initialize this space, we don't include this in buildList.txt. However, this file is used for the PC port (to allocate the space). + +struct DCACHE dcache_static; //represents 0x1f800000 \ No newline at end of file diff --git a/decompile/WorkInProgress/src/COLL/COLL_20_MOVED_FindScrub_attempt_2.c b/decompile/WorkInProgress/src/COLL/COLL_20_MOVED_FindScrub_attempt_2.c new file mode 100644 index 000000000..21a1b8ed3 --- /dev/null +++ b/decompile/WorkInProgress/src/COLL/COLL_20_MOVED_FindScrub_attempt_2.c @@ -0,0 +1,51 @@ +#include + +void DECOMP_COLL_MOVED_FindScrub(struct QuadBlock* quadblock, int triangleID, struct ScratchpadStructExtended* spse) { + //unsigned short searchFlags = spse->scratchpadStruct.Union.QuadBlockColl.searchFlags; //uVar1 + + if (quadblock == NULL) + { + spse->scratchpadStruct.Union.QuadBlockColl.searchFlags &= 0xffdf; + + *(short*)(((int)spse) + 0xe) = 0; + + spse->numTriangles = 0; + + return; + } + + for (char i = spse->numTriangles - 1; i >= 0; i--) + { + struct BspSearchTriangle* searchTriangle = &spse->bspSearchTriangle[i]; + + if (searchTriangle->quadblock == quadblock && searchTriangle->triangleID == triangleID) + { + if (searchTriangle->numCollision < 0x401) + { + searchTriangle->numCollision += 0x100; + } + + spse->scratchpadStruct.Union.QuadBlockColl.searchFlags |= 0x20; + + *(short*)(((int)spse) + 0xe) = (short)searchTriangle->numCollision; + + return; + } + } + + //it looks like the original game doesn't bounds check this. Is that a problem? + + struct BspSearchTriangle* newSearchTriangle = &spse->bspSearchTriangle[spse->numTriangles]; + + newSearchTriangle->quadblock = quadblock; + newSearchTriangle->triangleID = triangleID; + newSearchTriangle->numCollision = 0; + + spse->scratchpadStruct.Union.QuadBlockColl.searchFlags &= 0xffdf; + + *(short*)(((int)spse) + 0xe) = 0; + + spse->numTriangles++; + + return; +} \ No newline at end of file diff --git a/decompile/buildList.txt b/decompile/buildList.txt index 9e788d67a..06a5b44d4 100644 --- a/decompile/buildList.txt +++ b/decompile/buildList.txt @@ -361,7 +361,7 @@ common, exe, COLL_FIXED_BotsSearch, 0x0, General/COLL/COLL_03 //common, exe, COLL_MOVED_TRIANGL_TestPoint, 0x0, General/COLL/COLL_17_MOVED_TRIANGL_TestPoint.c //TODO //common, exe, COLL_MOVED_QUADBLK_TestTriangles, 0x0, General/COLL/COLL_18_MOVED_QUADBLK_TestTriangles.c //over budget, but assumed working //common, exe, COLL_MOVED_BSPLEAF_TestQuadblocks, 0x0, General/COLL/COLL_19_MOVED_BSPLEAF_TestQuadblocks.c //over budget, but assumed working -//common, exe, COLL_MOVED_FindScrub, 0x0, General/COLL/COLL_20_MOVED_FindScrub.c //TODO +//common, exe, COLL_MOVED_FindScrub, 0x0, General/COLL/COLL_20_MOVED_FindScrub.c //over budget, needs testing //common, exe, COLL_MOVED_PlayerSearch, 0x0, General/COLL/COLL_21_MOVED_PlayerSearch.c //TODO //common, exe, COLL_MOVED_ScrubImpact, 0x0, General/COLL/COLL_22_MOVED_ScrubImpact.c //TODO diff --git a/include/decomp_functions.h b/include/decomp_functions.h index ade680273..b69a3535c 100644 --- a/include/decomp_functions.h +++ b/include/decomp_functions.h @@ -907,4 +907,8 @@ u_int DECOMP_BOTS_ChangeState(struct Driver* driverVictim, int damageType, struc void DECOMP_BOTS_Killplane(struct Thread* botThread); void DECOMP_COLL_FIXED_BotsSearch(short* posCurr, short* posPrev, struct ScratchpadStruct* sps); void DECOMP_BOTS_LevInstColl(struct Thread* param_1); -void DECOMP_CS_LoadBoss(struct BossCutsceneData* bcd); \ No newline at end of file +void DECOMP_CS_LoadBoss(struct BossCutsceneData* bcd); +void DECOMP_LOAD_Hub_Main(struct BigHeader* bigfilePtr); +void DECOMP_LOAD_Hub_ReadFile(struct BigHeader* bigfilePtr, int levID, int packID); +void DECOMP_LOAD_Hub_SwapNow(void); +void DECOMP_COLL_MOVED_FindScrub(struct QuadBlock* quadblock, int triangleID, struct ScratchpadStructExtended* spse); \ No newline at end of file diff --git a/include/functions.h b/include/functions.h index ecbbb715a..354782317 100644 --- a/include/functions.h +++ b/include/functions.h @@ -74,7 +74,7 @@ u_int COLL_FIXED_INSTANC_TestPoint(struct ScratchpadStruct* param_1, struct BSP* void COLL_FIXED_BSPLEAF_TestInstance(struct BSP* node, struct ScratchpadStruct *sps); void COLL_FIXED_BotsSearch(short* posCurr, short* posPrev, short* param_3); void COLL_FIXED_PlayerSearch(struct Thread* t, struct Driver* d); -void COLL_SearchBSP_CallbackQUADBLK(u_int* posTop, u_int* posBottom, struct ScratchpadStruct* sps, int param_4); //posTop/posButtom may be backwards, also may have 6 params not 4??? +void COLL_SearchBSP_CallbackQUADBLK(short posTop[3], short posBottom[3], struct ScratchpadStruct* sps, int param_4); //posTop/posButtom may be backwards, also may have 6 params not 4??? void COLL_SearchBSP_CallbackPARAM(struct BSP* param_1, struct BoundingBox* bbox, void (*callback)(struct BSP*, struct ScratchpadStruct*), short* param_4); //4th param might be `struct ScratchpadStruct*` u_int FUN_8001ede4(u_short* param_1, short* param_2, short* param_3, short* param_4); void FUN_8001ef1c(); @@ -983,7 +983,7 @@ void VehPhysCrash_ConvertVecToSpeed(struct Driver* d, int* v); //VehPhysCrash_AI() //VehPhysCrash_Attack() void VehPhysCrash_AnyTwoCars(struct Thread* thread, u_short* param_2, int* param_3); -void VehPhysForce_ConvertSpeedToVec(struct Driver* d, short* velArr, int x); +void VehPhysForce_ConvertSpeedToVec(struct Driver* d, Vec3* velArr, int x); //VehPhysForce_OnGravity() void VehPhysForce_OnApplyForces(struct Thread* t, struct Driver* d); void VehPhysForce_CollideDrivers(struct Thread* t, struct Driver* d); @@ -1338,4 +1338,5 @@ void SelectProfile_Init(u_short flags); void Seal_CheckColl(struct Instance* sealInst, struct Thread* sealTh, int damage, int radius, int sound); void DotLights_AudioAndVideo(struct GameTracker* gGT); void EngineSound_NearestAIs(void); -void VehStuckProc_Tumble_PhysLinear(struct Thread* t, struct Driver* d); \ No newline at end of file +void VehStuckProc_Tumble_PhysLinear(struct Thread* t, struct Driver* d); +struct Thread* CS_Thread_Init(short modelID, char* name, short* param_3, short param_4, struct Thread* parent); \ No newline at end of file diff --git a/include/namespace_Coll.h b/include/namespace_Coll.h index 07a6d1419..0d4b123b2 100644 --- a/include/namespace_Coll.h +++ b/include/namespace_Coll.h @@ -70,7 +70,7 @@ struct ScratchpadStruct short hitPos[3]; // 0x22 - short searchFlags; + unsigned short searchFlags; // 0x24 int qbFlagsWanted; @@ -252,7 +252,20 @@ struct ScratchpadStructExtended // 1f800400 end of memory }; +struct DCACHE +{ + union { + struct { + char beginning108[0x108]; //maybe make a "pre-scratchpad" struct (spiders use this area). + struct ScratchpadStructExtended spse; + }; + char raw[1024]; //forces `struct DCACHE` to be >= 1024 bytes (exact size of ps1 dcache). + }; +}; + _Static_assert(sizeof(struct BoundingBox) == 0xC); _Static_assert(sizeof(struct BspSearchVertex) == 0x14); _Static_assert(sizeof(struct BspSearchTriangle) == 0xC); -_Static_assert(sizeof(struct ScratchpadStruct) == 0x20C); \ No newline at end of file +_Static_assert(sizeof(struct ScratchpadStruct) == 0x20C); +_Static_assert(sizeof(struct DCACHE) == 1024); +_Static_assert(offsetof(struct DCACHE, spse) == 0x108); \ No newline at end of file diff --git a/include/regionsEXE.h b/include/regionsEXE.h index e759e0296..810974ae9 100644 --- a/include/regionsEXE.h +++ b/include/regionsEXE.h @@ -1658,7 +1658,7 @@ struct Data int driverModelExtras[3]; //maybe should be `struct Model**[3]` // 80083a1c - int podiumModel_firstPlace; + struct Model* podiumModel_firstPlace; int podiumModel_secondPlace; int podiumModel_thirdPlace; int podiumModel_tawna; @@ -3453,8 +3453,8 @@ struct sData // 8008d568 // Normal flags are in registers, // while 2P flags are from RAM - u_int textFlags1_2P; - u_int textFlags2_2P; + short* textFlags1_2P; + short* textFlags2_2P; } Battle_EndOfRace; @@ -4510,7 +4510,7 @@ struct sData #if BUILD == SepReview char SpuDecodedBuf[0x1000]; #elif BUILD >= UsaRetail - char SpuDecodedBuf[0x800]; + char SpuDecodedBuf[0x800]; //maybe should be short[0x400] #endif // 8008E528 @@ -5058,6 +5058,12 @@ extern struct sData sdata_static; // 0x8008d668 - 0x8009f6fc extern struct BSS bss; +// represents 0x1f800000 1kb dcache. +extern struct DCACHE dcache_static; + +// no reserved register for dcache, not used often enough (atm) +struct DCACHE* dcache = &dcache_static; + #ifndef REBUILD_PC // optimal use for modding register struct sData* sdata asm("$gp"); diff --git a/rebuild_PC/CrashTeamRacingPC.c b/rebuild_PC/CrashTeamRacingPC.c index 68c3bcc8f..6a734dcc3 100644 --- a/rebuild_PC/CrashTeamRacingPC.c +++ b/rebuild_PC/CrashTeamRacingPC.c @@ -73,6 +73,7 @@ typedef enum { #include "../rebuild_PS1/main.c" #include "../decompile/General/zGlobal_DATA.c" #include "../decompile/General/zGlobal_SDATA.c" +#include "../decompile/General/zGlobal_DCACHE.c" // ======= PC-Specific Code ============= diff --git a/symbols/gcc-syms926.txt b/symbols/gcc-syms926.txt index b88d6b073..5fdb746df 100644 --- a/symbols/gcc-syms926.txt +++ b/symbols/gcc-syms926.txt @@ -1,3 +1,4 @@ +dcache_static = 0x1f800000; rdata = 0x80010000; rdata_free = 0x800100cc; BOTS_SetGlobalNavData = 0x800123e0; @@ -74,6 +75,7 @@ COLL_FIXED_QUADBLK_LoadScratchpadVerts = 0x8001f7f0; COLL_MOVED_TRIANGL_TestPoint = 0x8001fc40; COLL_MOVED_QUADBLK_TestTriangles = 0x80020064; COLL_MOVED_BSPLEAF_TestQuadblocks = 0x800202a8; +COLL_MOVED_FindScrub = 0x80020334; COLL_MOVED_PlayerSearch = 0x80020410; COLL_MOVED_ScrubImpact = 0x80020c58; CTR_Box_DrawWirePrims = 0x80021500;