diff --git a/include/PR/n_libaudio.h b/include/PR/n_libaudio.h index 58708fe68..4f82c2471 100644 --- a/include/PR/n_libaudio.h +++ b/include/PR/n_libaudio.h @@ -208,7 +208,7 @@ struct fx { s16 unk00; s16 unk02; s32 unk04; - s16 unk08[8]; + s16 unk08[16]; }; typedef struct N_ALVoiceState_s { diff --git a/port/src/pdmain.c b/port/src/pdmain.c index 7554507d6..1b95d1a80 100644 --- a/port/src/pdmain.c +++ b/port/src/pdmain.c @@ -325,7 +325,7 @@ void mainLoop(void) argGetLevel(&g_StageNum); if (g_DoBootPakMenu) { - g_Vars.unk0004e4 = 0xfd; + g_Vars.pakstocheck = 0xfd; g_StageNum = STAGE_BOOTPAKMENU; } diff --git a/port/src/preprocess.c b/port/src/preprocess.c index d589c8cb4..386366ac6 100644 --- a/port/src/preprocess.c +++ b/port/src/preprocess.c @@ -11,17 +11,6 @@ #include "romdata.h" #include "game/setuputils.h" -/* -#define PD_SWAP_VAL(x) -#define PD_SWAP_VAL(x) -#define PD_SWAP_VAL(u32 *)&x) -#define PD_SWAP_PTR(x) x = (void *)PD_BE32((u32)x) -#define PD_SWAP_VAL(v) \ - PD_SWAP_VAL(v.x); \ - PD_SWAP_VAL(v.y); \ - PD_SWAP_VAL(v.z) -*/ - static inline f32 swapF32(f32 x) { *(u32 *)&x = PD_BE32(*(u32 *)&x); return x; } static inline u32 swapU32(u32 x) { return PD_BE32(x); } static inline s32 swapS32(s32 x) { return PD_BE32(x); } @@ -489,19 +478,7 @@ static inline void preprocessTvScreenPropObj(struct tvscreen *scr) static inline void preprocessHovPropObj(struct hov *hov) { - PD_SWAP_VAL(hov->unk04); - PD_SWAP_VAL(hov->unk08); - PD_SWAP_VAL(hov->unk0c); - PD_SWAP_VAL(hov->unk10); - PD_SWAP_VAL(hov->unk14); - PD_SWAP_VAL(hov->unk18); - PD_SWAP_VAL(hov->unk1c); - PD_SWAP_VAL(hov->unk20); - PD_SWAP_VAL(hov->unk24); - PD_SWAP_VAL(hov->unk28); - PD_SWAP_VAL(hov->unk2c); - PD_SWAP_VAL(hov->unk30); - PD_SWAP_VAL(hov->ground); + // don't think anything actually has to be swapped here } static void preprocessPropObj(struct defaultobj *obj) diff --git a/src/game/bg.c b/src/game/bg.c index 7b26251dd..0717a83b8 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -89,12 +89,12 @@ u32 var800a4920; u32 g_BgSection3; struct room *g_Rooms; u8 *g_MpRoomVisibility; -s16 g_BgForceOnscreenRooms[350]; +RoomNum g_BgForceOnscreenRooms[350]; s32 g_BgNumForceOnscreenRooms; u16 g_BgUnloadDelay240; u16 g_BgUnloadDelay240_2; u32 var800a4bf4; -s16 g_GlareRooms[100]; +RoomNum g_GlareRooms[100]; u32 *g_BgPrimaryData2; struct bgroom *g_BgRooms; struct bgportal *g_BgPortals; @@ -138,7 +138,7 @@ void bgUnpausePropsInRoom(u32 roomnum, bool tintedglassonly) struct prop *prop; struct defaultobj *obj; s16 *propnumptr; - s16 rooms[2]; + RoomNum rooms[2]; s16 propnums[256]; rooms[0] = roomnum; @@ -872,11 +872,11 @@ Gfx *bgRenderRoomInXray(Gfx *gdl, s32 roomnum) Gfx *bgRenderSceneInXray(Gfx *gdl) { - s16 *roomnumptr; - s16 *room; + RoomNum *roomnumptr; + RoomNum *room; s16 i; s32 j; - s16 roomnumsbyprop[200]; + RoomNum roomnumsbyprop[200]; struct prop *prop; struct prop **ptr; s32 k; @@ -972,15 +972,15 @@ Gfx *bgRenderScene(Gfx *gdl) s32 firstroomnum = -1; s32 i; s32 roomnum; - s16 roomnumsbyprop[200]; + RoomNum roomnumsbyprop[200]; struct prop **ptr; struct drawslot *thing; - s16 *roomnumptr; + RoomNum *roomnumptr; struct prop *prop; s16 tmp; - s16 *room; + RoomNum *room; s16 roomorder[60]; - s16 roomnums[60]; + RoomNum roomnums[60]; g_NumRoomsWithGlares = 0; @@ -4649,7 +4649,7 @@ bool bgRoomIsLoaded(s32 room) return g_Rooms[room].loaded240; } -bool bgRoomContainsCoord(struct coord *pos, s16 roomnum) +bool bgRoomContainsCoord(struct coord *pos, RoomNum roomnum) { struct coord copy; copy.x = pos->x; @@ -4676,7 +4676,7 @@ bool bgRoomContainsCoord(struct coord *pos, s16 roomnum) * - The normal points towards the front of the portal. * - The room on the front side is roomnum2. */ -bool bgTestPosInRoomCheap(struct coord *pos, s16 roomnum) +bool bgTestPosInRoomCheap(struct coord *pos, RoomNum roomnum) { s32 i; @@ -4702,7 +4702,7 @@ bool bgTestPosInRoomCheap(struct coord *pos, s16 roomnum) return true; } -bool bgTestPosInRoomExpensive(struct coord *pos, s16 roomnum) +bool bgTestPosInRoomExpensive(struct coord *pos, RoomNum roomnum) { s32 t5; struct coord *next; @@ -4810,7 +4810,7 @@ bool bgTestPosInRoomExpensive(struct coord *pos, s16 roomnum) return true; } -bool bgTestPosInRoom(struct coord *pos, s16 roomnum) +bool bgTestPosInRoom(struct coord *pos, RoomNum roomnum) { if (g_Rooms[roomnum].flags & ROOMFLAG_COMPLICATEDPORTALS) { return bgTestPosInRoomExpensive(pos, roomnum); @@ -4839,7 +4839,7 @@ bool bgTestPosInRoom(struct coord *pos, s16 roomnum) * to pos and writes the room number to the bestroom pointer. The bestroom * pointer is a pointer to a single s16 rather than an array. */ -void bgFindRoomsByPos(struct coord *posarg, s16 *inrooms, s16 *aboverooms, s32 max, s16 *bestroom) +void bgFindRoomsByPos(struct coord *posarg, RoomNum *inrooms, RoomNum *aboverooms, s32 max, RoomNum *bestroom) { s32 inlen = 0; s32 abovelen = 0; @@ -5362,7 +5362,7 @@ void bgTickPortalsXray(void) bgChooseRoomsToLoad(); } -void bgAddToSnake(s16 fromroomnum, s16 roomnum, s16 depth, struct screenbox *box) +void bgAddToSnake(RoomNum fromroomnum, RoomNum roomnum, s16 depth, struct screenbox *box) { struct bgsnakeitem *item; s32 i; @@ -5449,10 +5449,10 @@ void bgConsumeSnakeItem(struct bgsnakeitem *item) s32 i; s16 portalnum; s16 prevvalidcount; - s16 prevfoundroom; - s16 newfoundroom; + RoomNum prevfoundroom; + RoomNum newfoundroom; s16 side; - s16 tmp; + RoomNum tmp; bool pass; struct portalmetric *metric; struct screenbox prevbox; @@ -5862,7 +5862,7 @@ Gfx *bgRenderSceneAndLoadCandidate(Gfx *gdl) return gdl; } -s32 bgGetForceOnscreenRooms(s16 *rooms, s32 len) +s32 bgGetForceOnscreenRooms(RoomNum *rooms, s32 len) { s32 i; @@ -5875,7 +5875,7 @@ s32 bgGetForceOnscreenRooms(s16 *rooms, s32 len) return i; } -s32 bgRoomGetNeighbours(s32 roomnum, s16 *dstrooms, s32 len) +s32 bgRoomGetNeighbours(s32 roomnum, RoomNum *dstrooms, s32 len) { s32 count = 0; s32 i; @@ -6021,7 +6021,7 @@ bool bgPortalExists(s32 portalnum) void bgPortalSwapRooms(s32 portal) { - s16 tmp = g_BgPortals[portal].roomnum1; + RoomNum tmp = g_BgPortals[portal].roomnum1; g_BgPortals[portal].roomnum1 = g_BgPortals[portal].roomnum2; g_BgPortals[portal].roomnum2 = tmp; } @@ -6240,10 +6240,10 @@ void bgCalculatePortalBbox(s32 portalnum, struct coord *bbmin, struct coord *bbm } } -void bgFindEnteredRooms(struct coord *bbmin, struct coord *bbmax, s16 *rooms, s32 maxlen, bool arg4) +void bgFindEnteredRooms(struct coord *bbmin, struct coord *bbmax, RoomNum *rooms, s32 maxlen, bool arg4) { - s16 room; - s16 otherroom; + RoomNum room; + RoomNum otherroom; s32 portalnum; struct coord propbbmin; struct coord propbbmax; diff --git a/src/game/body.c b/src/game/body.c index 38c313aba..5d272d3d7 100644 --- a/src/game/body.c +++ b/src/game/body.c @@ -346,7 +346,7 @@ s32 bodyChooseHead(s32 bodynum) void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) { struct pad pad; - s16 rooms[2]; + RoomNum rooms[2]; struct chrdata *chr; struct modeldef *headmodeldef; struct model *model; @@ -531,9 +531,9 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex) } } -struct prop *bodyAllocateEyespy(struct pad *pad, s16 room) +struct prop *bodyAllocateEyespy(struct pad *pad, RoomNum room) { - s16 rooms[2]; + RoomNum rooms[2]; struct prop *prop; struct chrdata *chr; struct model *model; diff --git a/src/game/bondbike.c b/src/game/bondbike.c index 5b33c3feb..7c83d4f5d 100644 --- a/src/game/bondbike.c +++ b/src/game/bondbike.c @@ -107,7 +107,7 @@ void bbikeTryDismountAngle(f32 relativeangle, f32 distance) struct hoverbikeobj *bike; f32 angle; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; s32 result; f32 ymax; f32 ymin; @@ -281,10 +281,10 @@ void bbikeApplyMoveData(struct movedata *data) sp3c = -bike->exreal; - if (bike->hov.unk14 < M_PI) { - sp3c += -bike->hov.unk14 * 0.8f; + if (bike->hov.bobpitchcur < M_PI) { + sp3c += -bike->hov.bobpitchcur * 0.8f; } else { - sp3c += (M_BADTAU - bike->hov.unk14) * 0.8f; + sp3c += (M_BADTAU - bike->hov.bobpitchcur) * 0.8f; } if (sp3c < 0) { @@ -371,11 +371,11 @@ s32 bbikeCalculateNewPosition(struct coord *vel, f32 angledelta) { s32 result = CDRESULT_NOCOLLISION; struct coord dstpos; - s16 dstrooms[8]; + RoomNum dstrooms[8]; struct hov hov; bool hasvel = false; struct hoverbikeobj *bike = (struct hoverbikeobj *) g_Vars.currentplayer->hoverbike->obj; - s16 spa8[20]; + RoomNum spa8[20]; f32 xdiff; f32 zdiff; f32 ymax; @@ -530,7 +530,7 @@ void bbikeUpdateVertical(struct coord *pos) { struct defaultobj *bike = g_Vars.currentplayer->hoverbike->obj; f32 angle; - s16 newrooms[8]; + RoomNum newrooms[8]; bool newinlift; struct prop *lift = NULL; f32 ground; diff --git a/src/game/bondeyespy.c b/src/game/bondeyespy.c index 7d4ace04e..9dd2b7f43 100644 --- a/src/game/bondeyespy.c +++ b/src/game/bondeyespy.c @@ -39,7 +39,7 @@ u32 g_EyespyMaxFallSpeed = 3000; * position 50 units above the current position, or less if the eyespy is near * the top of its height range. */ -f32 eyespyFindGround(s16 *floorroom) +f32 eyespyFindGround(RoomNum *floorroom) { struct prop *prop = g_Vars.currentplayer->eyespy->prop; s32 inlift; @@ -75,7 +75,7 @@ s32 eyespyTryMoveUpwards(f32 yvel) struct prop *prop = g_Vars.currentplayer->eyespy->prop; struct chrdata *chr = prop->chr; struct coord dstpos; - s16 dstrooms[8]; + RoomNum dstrooms[8]; s32 types; u32 stack; f32 f0; @@ -118,9 +118,9 @@ s32 eyespyCalculateNewPosition(struct coord *vel) struct prop *eyespyprop = g_Vars.currentplayer->eyespy->prop; struct chrdata *chr = eyespyprop->chr; struct coord dstpos; - s16 dstrooms[8]; - s16 floorroom; - s16 sp74[24]; + RoomNum dstrooms[8]; + RoomNum floorroom; + RoomNum sp74[24]; s32 types; s32 i; f32 ymin; @@ -713,7 +713,7 @@ void eyespyProcessInput(bool allowbuttons) f32 angle; f32 ascendspeed = 0.0f; f32 prevverta = g_Vars.currentplayer->eyespy->verta; - s16 prevrooms[8]; + RoomNum prevrooms[8]; s32 contpad2; u32 stack[5]; f32 tmp; diff --git a/src/game/bondgrab.c b/src/game/bondgrab.c index 1388160ec..cfca0b60f 100644 --- a/src/game/bondgrab.c +++ b/src/game/bondgrab.c @@ -84,7 +84,7 @@ void bgrabInit(void) if (hov) { g_Vars.currentplayer->grabbedrotoffset = - hov->unk10 - (M_BADTAU - (g_Vars.currentplayer->vv_theta * M_BADTAU) / 360.0f); + hov->yrot - (M_BADTAU - (g_Vars.currentplayer->vv_theta * M_BADTAU) / 360.0f); if (g_Vars.currentplayer->grabbedrotoffset >= M_BADTAU) { g_Vars.currentplayer->grabbedrotoffset -= M_BADTAU; @@ -284,7 +284,7 @@ bool bgrabTryMoveUpwards(f32 y) { bool result; struct coord newpos; - s16 rooms[8]; + RoomNum rooms[8]; f32 ymax; f32 ymin; f32 radius; @@ -320,7 +320,7 @@ s32 bgrabCalculateNewPosition(struct coord *delta, f32 angle, bool arg2) s32 cdresult = CDRESULT_NOCOLLISION; s32 i; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; bool ismoving = false; f32 ymax; f32 ymin; @@ -448,7 +448,7 @@ s32 bgrabCalculateNewPosition(struct coord *delta, f32 angle, bool arg2) - g_Vars.currentplayer->vv_theta * M_BADTAU / 360.0f + -angle + g_Vars.currentplayer->grabbedrotoffset - - hov->unk10 + - hov->yrot + rotextra; while (sp78 >= M_PI) { @@ -1038,7 +1038,7 @@ void bgrab0f0ce924(void) g_Vars.currentplayer->speedforwards += sp70; g_Vars.currentplayer->speedsideways += sp6c; - mult = var80075c00[1].unk0c * 0.5f * g_Vars.lvupdate60freal; + mult = g_HeadAnims[HEADANIM_MOVING].translateperframe * 0.5f * g_Vars.lvupdate60freal; sp88 = mult * g_Vars.currentplayer->speedsideways; speedsideways = g_Vars.currentplayer->speedsideways * 0.8f; @@ -1149,7 +1149,7 @@ void bgrab0f0ce924(void) sp3c = -1.0f; } - if (g_Vars.currentplayer->headanim == 1) { + if (g_Vars.currentplayer->headanim == HEADANIM_MOVING) { breathing *= 1.2f; } @@ -1207,7 +1207,7 @@ void bgrabTick(void) if (g_Vars.currentplayer->grabbedprop) { // Determine if the grabbed prop should be force released f32 ydiff = g_Vars.currentplayer->grabbedprop->pos.y - - objGetHov04(g_Vars.currentplayer->grabbedprop->obj) + - objGetHovBobOffsetY(g_Vars.currentplayer->grabbedprop->obj) - g_Vars.currentplayer->vv_manground; struct prop *grabbedprop = g_Vars.currentplayer->grabbedprop; diff --git a/src/game/bondgun.c b/src/game/bondgun.c index c3444a893..169989963 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -4280,7 +4280,7 @@ struct modeldef *bgunGetCartModeldef(void) return g_Vars.currentplayer->gunctrl.cartmodeldef; } -void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos) +void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, RoomNum *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos) { struct prop *objprop = obj->prop; @@ -4325,7 +4325,7 @@ void bgun0f09ed2c(struct defaultobj *obj, struct coord *newpos, Mtxf *arg2, stru { struct prop *objprop = obj->prop; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; if (objprop) { struct prop *playerprop = g_Vars.currentplayer->prop; @@ -4348,7 +4348,7 @@ void bgun0f09ed2c(struct defaultobj *obj, struct coord *newpos, Mtxf *arg2, stru } } -struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *velocity) +struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, RoomNum *rooms, Mtxf *arg4, struct coord *velocity) { struct defaultobj *obj = NULL; struct weaponfunc *basefunc; @@ -4457,7 +4457,7 @@ void bgunCreateThrownProjectile(s32 handnum, struct gset *gset) struct weaponobj *weapon; struct coord muzzlepos; struct coord spawnpos; - s16 spawnrooms[8]; + RoomNum spawnrooms[8]; bool droppinggrenade = false; struct hand *hand; struct coord aimpos; @@ -6748,7 +6748,7 @@ void bgunUpdateSmoke(struct hand *hand, s32 handnum, s32 weaponnum, struct weapo if (hand->createsmoke && (hand->state != HANDSTATE_ATTACK || hand->forcecreatesmoke)) { struct coord smokepos; - s16 smokerooms[2]; + RoomNum smokerooms[2]; s32 smoketype = SMOKETYPE_MUZZLE_AUTOMATIC; switch (weaponnum) { @@ -11415,7 +11415,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) #endif } -void bgunPlayGlassHitSound(struct coord *pos, s16 *rooms, s32 texturenum) +void bgunPlayGlassHitSound(struct coord *pos, RoomNum *rooms, s32 texturenum) { if (g_Vars.lvupdate240 > 0) { struct sndstate **handle = bgunAllocateAudioHandle(); @@ -11430,7 +11430,7 @@ void bgunPlayGlassHitSound(struct coord *pos, s16 *rooms, s32 texturenum) } } -void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, s16 *rooms) +void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, RoomNum *rooms) { #if VERSION >= VERSION_NTSC_1_0 struct sndstate **handle; diff --git a/src/game/bondhead.c b/src/game/bondhead.c index c574ed8c5..75c2b4b15 100644 --- a/src/game/bondhead.c +++ b/src/game/bondhead.c @@ -11,13 +11,11 @@ #include "data.h" #include "types.h" -struct var80075c00 var80075c00[] = { +struct headanim g_HeadAnims[] = { { ANIM_002B, 9.5, 27, 0, 0, 1.5 }, { ANIM_0029, 7.5, 17, 0, 1.5, 100 }, }; -struct coord var80075c30 = {0, 0, 0}; - void bheadFlipAnimation(void) { g_Vars.currentplayer->model.anim->flip = !g_Vars.currentplayer->model.anim->flip; @@ -96,7 +94,7 @@ void bheadUpdateRot(struct coord *lookvel, struct coord *upvel) g_Vars.currentplayer->headup.z = g_Vars.currentplayer->headupsum.z * (1.0f - g_Vars.currentplayer->headdamp); } -void bheadSetdamp(f32 headdamp) +void bheadSetDamp(f32 headdamp) { if (headdamp != g_Vars.currentplayer->headdamp) { f32 divisor = 1.0f - headdamp; @@ -112,7 +110,7 @@ void bheadSetdamp(f32 headdamp) void bheadUpdate(f32 arg0, f32 arg1) { - struct coord headpos = var80075c30; + struct coord headpos = {0, 0, 0}; struct coord lookvel = {0, 0, 1}; struct coord upvel = {0, 1, 0}; f32 animspeed = 0; @@ -120,7 +118,7 @@ void bheadUpdate(f32 arg0, f32 arg1) if (animHasFrames(g_Vars.currentplayer->model.anim->animnum)) { animspeed = modelGetAbsAnimSpeed(&g_Vars.currentplayer->model); - if (g_Vars.currentplayer->headanim == 0) { + if (g_Vars.currentplayer->headanim == HEADANIM_RESTING) { if (animspeed > 0.69999998807907f) { g_Vars.currentplayer->headamplitude = 1; } else if (animspeed > 0.1f) { @@ -131,7 +129,7 @@ void bheadUpdate(f32 arg0, f32 arg1) g_Vars.currentplayer->sideamplitude = g_Vars.currentplayer->headamplitude; } else { - if (g_Vars.currentplayer->headanim == 1) { + if (g_Vars.currentplayer->headanim == HEADANIM_MOVING) { g_Vars.currentplayer->headamplitude = 0.89999997615814f; g_Vars.currentplayer->sideamplitude = 0.5f; } else { @@ -197,9 +195,9 @@ void bheadUpdate(f32 arg0, f32 arg1) g_Vars.currentplayer->headwalkingtime60 += g_Vars.lvupdate60; if (g_Vars.currentplayer->headwalkingtime60 > TICKS(60)) { - bheadSetdamp(PAL ? 0.9785f : 0.982f); + bheadSetDamp(PAL ? 0.9785f : 0.982f); } else { - bheadSetdamp(PAL ? 0.99699f : 0.99748998880386f); + bheadSetDamp(PAL ? 0.99699f : 0.99748998880386f); } } else { lookvel.x = g_Vars.currentplayer->bondheadmatrices[0].m[2][0]; @@ -210,7 +208,7 @@ void bheadUpdate(f32 arg0, f32 arg1) upvel.y = g_Vars.currentplayer->bondheadmatrices[0].m[1][1]; upvel.z = g_Vars.currentplayer->bondheadmatrices[0].m[1][2]; - bheadSetdamp(PAL ? 0.952f : 0.96f); + bheadSetDamp(PAL ? 0.952f : 0.96f); } } else { g_Vars.currentplayer->headbodyoffset.x = g_Vars.currentplayer->standbodyoffset.x; @@ -222,7 +220,7 @@ void bheadUpdate(f32 arg0, f32 arg1) headpos.z = 0; g_Vars.currentplayer->headwalkingtime60 = 0; - bheadSetdamp(PAL ? 0.99699f : 0.99748998880386f); + bheadSetDamp(PAL ? 0.99699f : 0.99748998880386f); if (bmoveGetCrouchPos() != CROUCHPOS_SQUAT) { g_Vars.currentplayer->standfrac += @@ -261,31 +259,31 @@ void bheadAdjustAnimation(f32 speed) struct chrdata *chr = g_Vars.currentplayer->prop->chr; s32 i; - speed *= var80075c00[1].unk0c; + speed *= g_HeadAnims[HEADANIM_MOVING].translateperframe; - for (i = 0; i < 2; i++) { - if (var80075c00[i].unk14 * var80075c00[i].unk0c >= speed) { - s32 headanim = g_Vars.currentplayer->headanim; + for (i = 0; i < ARRAYCOUNT(g_HeadAnims); i++) { + if (g_HeadAnims[i].maxspeed * g_HeadAnims[i].translateperframe >= speed) { + s32 prevheadanim = g_Vars.currentplayer->headanim; - if (i != headanim) { + if (i != prevheadanim) { f32 startframe = 0.0f; - if (headanim >= 0) { - startframe = (g_Vars.currentplayer->model.anim->frame - var80075c00[headanim].loopframe) - / (var80075c00[headanim].endframe - var80075c00[headanim].loopframe); - startframe = var80075c00[i].loopframe + (var80075c00[i].endframe - var80075c00[i].loopframe) * startframe; + if (prevheadanim >= 0) { + startframe = (g_Vars.currentplayer->model.anim->frame - g_HeadAnims[prevheadanim].loopframe) + / (g_HeadAnims[prevheadanim].endframe - g_HeadAnims[prevheadanim].loopframe); + startframe = g_HeadAnims[i].loopframe + (g_HeadAnims[i].endframe - g_HeadAnims[i].loopframe) * startframe; } - modelSetAnimation(&g_Vars.currentplayer->model, var80075c00[i].animnum, + modelSetAnimation(&g_Vars.currentplayer->model, g_HeadAnims[i].animnum, g_Vars.currentplayer->model.anim->flip, startframe, 0.5f, 12); - modelSetAnimLooping(&g_Vars.currentplayer->model, var80075c00[i].loopframe, false); - modelSetAnimEndFrame(&g_Vars.currentplayer->model, var80075c00[i].endframe); + modelSetAnimLooping(&g_Vars.currentplayer->model, g_HeadAnims[i].loopframe, false); + modelSetAnimEndFrame(&g_Vars.currentplayer->model, g_HeadAnims[i].endframe); modelSetAnimFlipFunction(&g_Vars.currentplayer->model, bheadFlipAnimation); g_Vars.currentplayer->headanim = i; } - speed = speed / var80075c00[i].unk0c; + speed = speed / g_HeadAnims[i].translateperframe; modelSetAnimSpeed(&g_Vars.currentplayer->model, speed * 0.5f, 0); break; @@ -309,11 +307,11 @@ void bheadSetSpeed(f32 speed) f32 bheadGetBreathingValue(void) { if (g_Vars.currentplayer->headanim >= 0) { - f32 a = g_Vars.currentplayer->bondbreathing * 0.012500001f + 0.004166667f; + f32 a = g_Vars.currentplayer->bondbreathing * 0.012500001f + (1.0f / 240.0f); f32 b = modelGetAbsAnimSpeed(&g_Vars.currentplayer->model); if (b > 0) { - f32 c = b / (var80075c00[g_Vars.currentplayer->headanim].endframe - var80075c00[g_Vars.currentplayer->headanim].loopframe); + f32 c = b / (g_HeadAnims[g_Vars.currentplayer->headanim].endframe - g_HeadAnims[g_Vars.currentplayer->headanim].loopframe); if (c < a) { c = a; diff --git a/src/game/bondheadreset.c b/src/game/bondheadreset.c index b313ec01f..2d75461f4 100644 --- a/src/game/bondheadreset.c +++ b/src/game/bondheadreset.c @@ -39,7 +39,7 @@ void bheadReset(void) modelSetScale(&g_Vars.currentplayer->model, 0.1000000089407f); modelSetAnimPlaySpeed(&g_Vars.currentplayer->model, (PAL ? 1.2f : 1), 0); - g_Vars.currentplayer->headanim = 0; + g_Vars.currentplayer->headanim = HEADANIM_RESTING; g_Vars.currentplayer->headdamp = (PAL ? 0.9166f : 0.93f); g_Vars.currentplayer->headwalkingtime60 = 0; g_Vars.currentplayer->headamplitude = 1; @@ -87,10 +87,10 @@ void bheadReset(void) g_Vars.currentplayer->standup[1].z = 0; g_Vars.currentplayer->standcnt = 0; - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAYCOUNT(g_HeadAnims); i++) { s32 translate[3]; - func0f0125a0(var80075c00[i].animnum, var80075c00[i].loopframe, var80075c00[i].endframe, translate); - var80075c00[i].unk0c = (translate[2] * 0.1000000089407f) / (var80075c00[i].endframe - var80075c00[i].loopframe); + func0f0125a0(g_HeadAnims[i].animnum, g_HeadAnims[i].loopframe, g_HeadAnims[i].endframe, translate); + g_HeadAnims[i].translateperframe = (translate[2] * 0.1000000089407f) / (g_HeadAnims[i].endframe - g_HeadAnims[i].loopframe); } { @@ -112,17 +112,13 @@ void bheadReset(void) g_Vars.currentplayer->standbodyoffset.z = g_Vars.currentplayer->bondheadmatrices[1].m[3][2] - g_Vars.currentplayer->bondheadmatrices[0].m[3][2]; modelSetAnimation(&g_Vars.currentplayer->model, - var80075c00[g_Vars.currentplayer->headanim].animnum, + g_HeadAnims[g_Vars.currentplayer->headanim].animnum, 0, - var80075c00[g_Vars.currentplayer->headanim].loopframe, + g_HeadAnims[g_Vars.currentplayer->headanim].loopframe, 0.5f, 0); - modelSetAnimLooping(&g_Vars.currentplayer->model, - var80075c00[g_Vars.currentplayer->headanim].loopframe, 0); - - modelSetAnimEndFrame(&g_Vars.currentplayer->model, - var80075c00[g_Vars.currentplayer->headanim].endframe); - + modelSetAnimLooping(&g_Vars.currentplayer->model, g_HeadAnims[g_Vars.currentplayer->headanim].loopframe, 0); + modelSetAnimEndFrame(&g_Vars.currentplayer->model, g_HeadAnims[g_Vars.currentplayer->headanim].endframe); modelSetAnimFlipFunction(&g_Vars.currentplayer->model, bheadFlipAnimation); bheadUpdateIdleRoll(); diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 3a873c3e8..5740d543e 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -397,7 +397,7 @@ f32 bmoveCalculateLookahead(void) struct coord sp100; u32 stack; struct coord spf0; - s16 spe0[8]; + RoomNum spe0[8]; s32 i; f32 angle; f32 value; @@ -406,9 +406,9 @@ f32 bmoveCalculateLookahead(void) u32 stack6; struct coord spbc; struct coord spb0; - s16 spa0[8]; - s16 sp90[8]; - s16 sp80[8]; + RoomNum spa0[8]; + RoomNum sp90[8]; + RoomNum sp80[8]; s32 j; f32 sp78; s32 indextoremove; @@ -1850,7 +1850,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } -void bmoveFindEnteredRoomsByPos(struct player *player, struct coord *mid, s16 *rooms) +void bmoveFindEnteredRoomsByPos(struct player *player, struct coord *mid, RoomNum *rooms) { struct coord bbmin; struct coord bbmax; @@ -1868,7 +1868,7 @@ void bmoveFindEnteredRoomsByPos(struct player *player, struct coord *mid, s16 *r bgFindEnteredRooms(&bbmin, &bbmax, rooms, 7, false); } -void bmoveFindEnteredRooms(struct player *player, s16 *rooms) +void bmoveFindEnteredRooms(struct player *player, RoomNum *rooms) { bmoveFindEnteredRoomsByPos(player, &player->prop->pos, rooms); } diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index 545e7d779..2e87123ab 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -187,7 +187,7 @@ s32 bwalkTryMoveUpwards(f32 amount) { bool result; struct coord newpos; - s16 rooms[8]; + RoomNum rooms[8]; u32 stack; u32 types; f32 ymax; @@ -235,9 +235,9 @@ bool bwalkCalculateNewPosition(struct coord *vel, f32 rotateamount, bool apply, s32 result = CDRESULT_NOCOLLISION; f32 halfradius; struct coord dstpos; - s16 dstrooms[8]; + RoomNum dstrooms[8]; bool copyrooms = false; - s16 sp64[22]; + RoomNum sp64[22]; s32 types; f32 ymax; f32 ymin; @@ -392,7 +392,7 @@ bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bo } else if (obstacle->type == PROPTYPE_CHR) { struct chrdata *chr = obstacle->chr; struct coord newpos; - s16 newrooms[8]; + RoomNum newrooms[8]; f32 movingdist; f32 xdist; f32 zdist; @@ -713,10 +713,10 @@ void bwalkUpdateVertical(void) f32 ground; bool onladder; bool onladder2 = false; - s16 rooms[8]; + RoomNum rooms[8]; struct coord testpos; struct coord newpos; - s16 newrooms[8]; + RoomNum newrooms[8]; s32 newinlift; struct prop *lift = NULL; f32 sumground; @@ -1543,7 +1543,7 @@ void bwalk0f0c69b8(void) g_Vars.currentplayer->bondbreathing = 1.0f; } - mult = var80075c00[1].unk0c * 0.5f * g_Vars.lvupdate60freal; + mult = g_HeadAnims[HEADANIM_MOVING].translateperframe * 0.5f * g_Vars.lvupdate60freal; spe0 = (g_Vars.currentplayer->speedsideways * spc0 + spc4) * mult; #if VERSION >= VERSION_NTSC_1_0 @@ -1728,7 +1728,7 @@ void bwalk0f0c69b8(void) sp40 = -1.0f; } - if (g_Vars.currentplayer->headanim == 1) { + if (g_Vars.currentplayer->headanim == HEADANIM_MOVING) { breathing *= 1.2f; } diff --git a/src/game/bot.c b/src/game/bot.c index 9c017c7d8..017405eec 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -227,7 +227,7 @@ void botSpawn(struct chrdata *chr, u8 respawning) struct defaultobj *obj; struct aibot *aibot = chr->aibot; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; if (chr->prop) { prop = chr->prop->child; @@ -660,8 +660,8 @@ void botCheckPickups(struct chrdata *chr) s32 i; s16 *propnumptr; s16 propnums[260]; - s16 allrooms[22]; - s16 neighbours[12]; + RoomNum allrooms[22]; + RoomNum neighbours[12]; roomsCopy(chr->prop->rooms, allrooms); @@ -1208,7 +1208,7 @@ void botApplyProtect(struct chrdata *chr, struct prop *prop) chr->aibot->forcemainloop = true; } -void botApplyDefend(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle) +void botApplyDefend(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle) { chr->aibot->command = AIBOTCMD_DEFEND; chr->aibot->defendholdpos.x = pos->x; @@ -1219,7 +1219,7 @@ void botApplyDefend(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle chr->aibot->forcemainloop = true; } -void botApplyHold(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle) +void botApplyHold(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle) { chr->aibot->command = AIBOTCMD_HOLD; chr->aibot->defendholdpos.x = pos->x; @@ -1521,7 +1521,7 @@ void botChooseGeneralTarget(struct chrdata *botchr) s32 i; s32 j; bool distancesdone[MAX_MPCHRS]; - s16 room = -1; + RoomNum room = -1; struct chrdata *trychr; s32 playernum; diff --git a/src/game/botact.c b/src/game/botact.c index 5d5a78fe9..f691b305e 100644 --- a/src/game/botact.c +++ b/src/game/botact.c @@ -440,7 +440,7 @@ s32 botactGetShootInterval60(s32 weaponnum, s32 funcnum) * * Return true if a route was found, false if not. */ -bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct projectile *projectile) +bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct coord *topos, RoomNum *fromrooms, RoomNum *torooms, struct projectile *projectile) { struct waypoint *from = waypointFindClosestToPos(frompos, fromrooms); struct waypoint *to = waypointFindClosestToPos(topos, torooms); @@ -479,7 +479,7 @@ bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct co void botactGetRocketNextStepPos(u16 padnum, struct coord *pos) { struct pad pad; - s16 rooms[2]; + RoomNum rooms[2]; padUnpack(padnum, PADFIELD_ROOM | PADFIELD_POS, &pad); diff --git a/src/game/botmgr.c b/src/game/botmgr.c index 595c7c43c..59778fbff 100644 --- a/src/game/botmgr.c +++ b/src/game/botmgr.c @@ -28,7 +28,7 @@ void botmgrRemoveAll(void) void botmgrAllocateBot(s32 chrnum, s32 aibotnum) { - s16 rooms[1]; + RoomNum rooms[1]; struct prop *prop; struct chrdata *chr; struct aibot *aibot; diff --git a/src/game/botroom.c b/src/game/botroom.c index e72898295..b27308f13 100644 --- a/src/game/botroom.c +++ b/src/game/botroom.c @@ -46,16 +46,16 @@ * It's likely that these don't ever overflow, or they overflow minimally which * has no serious effect, but this should be investigated further. */ -bool botroomFindPos(s16 room, struct coord *pos, f32 *angleptr, s32 *padnumptr, s32 *covernumptr) +bool botroomFindPos(RoomNum room, struct coord *pos, f32 *angleptr, s32 *padnumptr, s32 *covernumptr) { s32 i; struct waypoint *waypoint; s32 waypointnum; - s32 covernums[40]; /// written to stack + s32 covernums[40]; s32 covercount; - struct cover cover; // written to stack - s16 rooms[2]; // written to stack - s32 padnums[40]; // written to stack + struct cover cover; + RoomNum rooms[2]; + s32 padnums[40]; s32 padcount; s32 totalcount; struct pad pad; diff --git a/src/game/camdraw.c b/src/game/camdraw.c index 58592eba4..97498ec6e 100644 --- a/src/game/camdraw.c +++ b/src/game/camdraw.c @@ -948,7 +948,7 @@ void func0f14aee0(void) thing->unk078 = 0; pak0f117150(i, thing->unk0d8); - pak0f1171b4(SAVEDEVICE_CONTROLLERPAK1, 3, 0); + pak0f1171b4(SAVEDEVICE_CONTROLLERPAK1, PAK00C_03, 0); func0f14aed0(i); thing->unk094 = 0; @@ -1200,7 +1200,7 @@ void func0f14b8ac(s32 index) } switch (pakGetUnk008(func0f14a5a4())) { - case 12: + case PAK008_12: func0f14a95c(); func0f14aa48(); func0f14e790(var800a45a0->unk470); @@ -1209,10 +1209,10 @@ void func0f14b8ac(s32 index) func0f14a16c(1); func0f14bc04(); break; - case 1: + case PAK008_01: pak0f11d4dc(func0f14a5a4()); break; - case 11: + case PAK008_11: pak0f11d9c4(func0f14a5a4(), var800a45a0->unk470, 0, 0); func0f14d064(index, var800a45a0->unk470); pak0f11d478(func0f14a5a4()); @@ -1320,7 +1320,7 @@ void func0f14bd34(s32 index) struct var8007f8dc *thing = &var8007f8dc[index]; if (thing->unk080 != -1) { - pak0f1171b4(func0f14a5a4(), 3, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_03, 0); pak0f11d540(func0f14a5a4(), thing->unk0b6[thing->unk080]); } } @@ -1402,7 +1402,7 @@ void func0f14bec8(s32 index) for (i = 0; i < ARRAYCOUNT(thing->unk0b6); i++); - pak0f1171b4(func0f14a5a4(), 3, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_03, 0); pak0f11d478(func0f14a5a4()); break; case 3: @@ -1446,7 +1446,7 @@ void func0f14c1cc(s32 index) switch (thing->unk0f4) { case 0: - pak0f1171b4(func0f14a5a4(), 0, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_00, 0); pak0f11d5b0(func0f14a5a4()); thing->unk0f4 = 1; break; @@ -1510,13 +1510,13 @@ void func0f14c3a4(s32 index) pak0f11d620(func0f14a5a4()); switch (pakGetUnk008(func0f14a5a4())) { - case 1: + case PAK008_01: func0f14c1cc(index); break; - case 11: + case PAK008_11: func0f14bec8(index); break; - case 12: + case PAK008_12: func0f14bdbc(index); break; } @@ -1712,7 +1712,7 @@ void func0f14cdb8(s32 index, u8 *arg1) void func0f14ce84(void) { if (pak0f11d3f8(func0f14a5a4())) { - if (pakGetUnk008(func0f14a5a4()) != 12) { + if (pakGetUnk008(func0f14a5a4()) != PAK008_12) { var8007f8dc[func0f14a5a4()].unk0f8 = 1; var8007f8dc[func0f14a5a4()].unk0d4_00 = false; @@ -1739,7 +1739,7 @@ void func0f14cf6c(void) case 4: case 5: case 6: - pak0f1171b4(func0f14a5a4(), 3, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_03, 0); g_MpPlayerNum = 0; menuSetBanner(-1, false); break; @@ -1762,7 +1762,7 @@ void func0f14d064(s32 index, u8 *arg1) g_MpPlayerNum = index; menuSetBanner(MENUBANNER_CALIBRATINGCAMERA, false); func0f14a16c(1); - pak0f1171b4(func0f14a5a4(), 1, 1); + pak0f1171b4(func0f14a5a4(), PAK00C_01, 1); thing->unk0f8 = 3; return; } @@ -1801,12 +1801,12 @@ void func0f14d064(s32 index, u8 *arg1) } if (thing->unk0f8 == 6) { - pak0f1171b4(func0f14a5a4(), 3, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_03, 0); thing->unk0f8 = 6; thing->unk100 = thing->unk0fc; g_MpPlayerNum = index; menuSetBanner(-1, false); - pak0f1171b4(func0f14a5a4(), 3, 0); + pak0f1171b4(func0f14a5a4(), PAK00C_03, 0); var8007f8dc[var800a45a0->unk000].unk0d4_04 = true; thing->unk0f8 = 0; } diff --git a/src/game/camera.c b/src/game/camera.c index 3a4b5ee14..2c1f833de 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -597,10 +597,10 @@ bool camIsPosInScreenBox(struct coord *pos, f32 arg1, struct drawslot *drawslot) * correct address to camIsPosInScreenBox so it can interpret the pointer as a * drawslot. */ -bool camIsPosInFovAndVisibleRoom(s16 *rooms, struct coord *pos, f32 arg2) +bool camIsPosInFovAndVisibleRoom(RoomNum *rooms, struct coord *pos, f32 arg2) { s32 i; - s16 room; + RoomNum room; bool hasdata = false; struct drawslot *thisthing; struct screenbox box; @@ -640,5 +640,5 @@ bool camIsPosInFovAndVisibleRoom(s16 *rooms, struct coord *pos, f32 arg2) return false; } - return camIsPosInScreenBox(pos, arg2, (struct drawslot *) (&box.array[-1][0])); + return camIsPosInScreenBox(pos, arg2, (struct drawslot *) &(((u8 *) &box)[-((uintptr_t) &(((struct drawslot *)0)->box))])); } diff --git a/src/game/chr.c b/src/game/chr.c index 398b5f169..c91af0795 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -197,7 +197,7 @@ void chrSetPerimEnabled(struct chrdata *chr, bool enable) * pos and rooms for the chr. It does collision checks and updates dstpos and * dstrooms to valid ones if needed. */ -void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstrooms, bool arg3) +void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, RoomNum *dstrooms, bool arg3) { f32 ymax; f32 ymin; @@ -210,7 +210,7 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom f32 halfradius; struct defaultobj *chair = NULL; s32 cdresult; - s16 sp84[20]; + RoomNum sp84[20]; #if VERSION < VERSION_NTSC_1_0 s32 i; #endif @@ -478,14 +478,14 @@ void chrCalculatePushPos(struct chrdata *chr, struct coord *dstpos, s16 *dstroom } #if VERSION >= VERSION_NTSC_1_0 -bool chr0f01f264(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 arg3, bool arg4) +bool chr0f01f264(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 arg3, bool arg4) #else -bool chr0f01f264(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 arg3) +bool chr0f01f264(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 arg3) #endif { bool result; struct coord newpos; - s16 newrooms[8]; + RoomNum newrooms[8]; f32 ymax; f32 ymin; f32 radius; @@ -520,7 +520,7 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 struct prop *lift; s32 i; f32 ground; - s16 spfc[8]; + RoomNum spfc[8]; f32 manground = chr->manground; s32 race = CHRRACE(chr); f32 yincrement = 0.0f; @@ -531,7 +531,7 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 f32 lvupdate60f; f32 lvupdate60freal; struct coord spd0; - s16 spc0[8]; + RoomNum spc0[8]; #endif // NTSC beta reads g_Vars lvupdate properties throughout this function, @@ -640,8 +640,8 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 bmove0f0cb904(&chr->aibot->shotspeed); - arg2->x += chr->aibot->shotspeed.x * var80075c00[1].unk0c * VAR(lvupdate60freal) * 0.5f; - arg2->z += chr->aibot->shotspeed.z * var80075c00[1].unk0c * VAR(lvupdate60freal) * 0.5f; + arg2->x += chr->aibot->shotspeed.x * g_HeadAnims[HEADANIM_MOVING].translateperframe * VAR(lvupdate60freal) * 0.5f; + arg2->z += chr->aibot->shotspeed.z * g_HeadAnims[HEADANIM_MOVING].translateperframe * VAR(lvupdate60freal) * 0.5f; } if (chr->actiontype == ACT_DIE && chr->act_die.timeextra > 0.0f) { @@ -775,9 +775,9 @@ bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f3 arg2->y -= chr->manground; } else { struct coord *sp98; - s16 *sp94; + RoomNum *sp94; struct coord sp88; - s16 sp78[8]; + RoomNum sp78[8]; f32 ground; struct modelnode *node; u16 nodetype; @@ -1290,7 +1290,7 @@ void chrInit(struct prop *prop, u8 *ailist) } struct prop *chr0f020b14(struct prop *prop, struct model *model, - struct coord *pos, s16 *rooms, f32 faceangle, u8 *ailist) + struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist) { struct chrdata *chr; struct coord testpos; @@ -1345,7 +1345,7 @@ struct prop *chr0f020b14(struct prop *prop, struct model *model, return prop; } -struct prop *chrAllocate(struct model *model, struct coord *pos, s16 *rooms, f32 faceangle, u8 *ailist) +struct prop *chrAllocate(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist) { struct prop *prop = propAllocate(); @@ -1871,7 +1871,7 @@ void chrHandleJointPositioned(s32 joint, Mtxf *mtx) } } -void chr0f021fa8(struct chrdata *chr, struct coord *pos, s16 *rooms) +void chr0f021fa8(struct chrdata *chr, struct coord *pos, RoomNum *rooms) { struct coord lower; struct coord upper; @@ -1904,7 +1904,7 @@ void chr0f021fa8(struct chrdata *chr, struct coord *pos, s16 *rooms) bgFindEnteredRooms(&lower, &upper, rooms, 7, true); } -void chr0f022084(struct chrdata *chr, s16 *room) +void chr0f022084(struct chrdata *chr, RoomNum *room) { chr0f021fa8(chr, &chr->prop->pos, room); } diff --git a/src/game/chraction.c b/src/game/chraction.c index 65b834e5a..4ca511b18 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -1520,7 +1520,7 @@ f32 chrGetAttackEntityRelativeAngle(struct chrdata *chr, s32 attackflags, s32 en { f32 angle; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; if (attackflags & ATTACKFLAG_AIMFORWARD) { return 0; @@ -5109,13 +5109,13 @@ void chrDie(struct chrdata *chr, s32 aplayernum) } } -bool func0f03645c(struct chrdata *chr, struct coord *arg1, s16 *arg2, struct coord *arg3, struct coord *arg4, s32 arg5) +bool func0f03645c(struct chrdata *chr, struct coord *arg1, RoomNum *arg2, struct coord *arg3, struct coord *arg4, s32 arg5) { bool result = false; f32 ymax; f32 ymin; f32 radius; - s16 rooms[8]; + RoomNum rooms[8]; struct prop *prop = chr->prop; chrGetBbox(prop, &radius, &ymax, &ymin); @@ -5132,7 +5132,7 @@ bool func0f03645c(struct chrdata *chr, struct coord *arg1, s16 *arg2, struct coo return result; } -bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, struct coord *vector, f32 arg6, u32 types) +bool func0f03654c(struct chrdata *chr, struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, struct coord *vector, f32 arg6, u32 types) { struct coord tmp; f32 a; @@ -5144,7 +5144,7 @@ bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coo f32 radius; struct coord sp5c; struct coord sp50; - s16 sp40[8]; + RoomNum sp40[8]; f32 mult; prop = chr->prop; @@ -5302,15 +5302,15 @@ bool chrCanJumpInDirection(struct chrdata *chr, bool side, f32 distance) return propchrHasClearLineToPos(prop, &dstpos, &vector); } -bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, s16 *wayrooms) +bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, RoomNum *wayrooms) { struct prop *prop = chr->prop; - s16 sp7c[20]; + RoomNum sp7c[20]; u32 stack; s32 i; - s16 sp64[8]; + RoomNum sp64[8]; bool offscreen = true; - s16 sp50[8]; + RoomNum sp50[8]; if ((chr->hidden & CHRHFLAG_CLOAKED) == 0 || USINGDEVICE(DEVICE_IRSCANNER)) { func0f065dfc(&prop->pos, prop->rooms, waypos, sp64, sp7c, 20); @@ -5364,7 +5364,7 @@ void chrGoPosInitMagic(struct chrdata *chr, struct waydata *waydata, struct coor chrSetLookAngle(chr, angle); } -void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags) +void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, RoomNum *rooms, u32 *flags) { struct waypoint *waypoint = chr->act_gopos.waypoints[chr->act_gopos.curindex]; struct pad pad; @@ -5396,7 +5396,7 @@ void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, } } -void chrGoPosGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, s16 *rooms) +void chrGoPosGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, RoomNum *rooms) { chrGoPosGetCurWaypointInfoWithFlags(chr, pos, rooms, NULL); } @@ -5421,7 +5421,7 @@ s32 chrGoPosCalculateBaseTtl(struct chrdata *chr) f32 zdiff; u32 stack; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; f32 speed; chrGoPosGetCurWaypointInfo(chr, &pos, rooms); @@ -5487,7 +5487,7 @@ void chrGoPosConsiderRestart(struct chrdata *chr) void chrGoPosInitExpensive(struct chrdata *chr) { struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; chrGoPosGetCurWaypointInfo(chr, &pos, rooms); @@ -5600,7 +5600,7 @@ s16 chrPatrolCalculatePadNum(struct chrdata *chr, s32 numsteps) return *padnumptr; } -void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags) +void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, RoomNum *rooms, u32 *flags) { s32 padnum = chrPatrolCalculatePadNum(chr, 0); struct pad pad; @@ -5619,14 +5619,14 @@ void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos } } -void chrPatrolGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, s16 *rooms) +void chrPatrolGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, RoomNum *rooms) { chrPatrolGetCurWaypointInfoWithFlags(chr, pos, rooms, NULL); } void func0f037580(struct chrdata *chr) { - s16 rooms[8]; + RoomNum rooms[8]; chr->act_patrol.waydata.mode = WAYMODE_INIT; chr->act_patrol.waydata.iter = 0; @@ -5645,26 +5645,26 @@ void func0f0375b0(struct chrdata *chr) func0f037580(chr); } -void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, struct coord *arg3, s16 *rooms) +void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, struct coord *arg3, RoomNum *rooms) { - s16 sp118[8]; + RoomNum sp118[8]; f32 ymax; f32 ymin; f32 radius; f32 ground; u16 floorcol; u8 floortype; - s16 floorroom; + RoomNum floorroom; struct coord spf4; struct prop *prop = chr->prop; union modelrwdata *rwdata; struct waypoint *waypoint; struct coord spdc; - s16 spcc[8]; + RoomNum spcc[8]; u32 stack[4]; struct pad pad; struct coord sp5c; - s16 sp4c[8]; + RoomNum sp4c[8]; chr->invalidmove = 0; chr->lastmoveok60 = g_Vars.lvframe60; @@ -5773,7 +5773,7 @@ void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, st */ void chrCalculatePosition(struct chrdata *chr, struct coord *pos) { - s16 rooms[8]; + RoomNum rooms[8]; f32 frac; if (chr->actiontype == ACT_PATROL && chr->act_patrol.waydata.mode == WAYMODE_MAGIC) { @@ -6075,7 +6075,7 @@ void chrGoPosChooseAnimation(struct chrdata *chr) } } -bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, s16 *room, u32 goposflags) +bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, RoomNum *room, u32 goposflags) { struct prop *prop = chr->prop; struct waypoint *nextwaypoint; @@ -6083,7 +6083,7 @@ bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, s16 *room, u32 gopos struct waypoint *waypoints[MAX_CHRWAYPOINTS]; s32 i; struct coord curwppos; - s16 curwprooms[8]; + RoomNum curwprooms[8]; s32 isgopos = chr->actiontype == ACT_GOPOS && (chr->act_gopos.flags & GOPOSMASK_SPEED) == (goposflags & 0xff & GOPOSMASK_SPEED) && !chrGoPosIsWaiting(chr); @@ -6249,15 +6249,15 @@ void chrStartPatrol(struct chrdata *chr, struct path *path) s32 *padnumptr; struct pad pad; struct coord nextpos; - s16 nextrooms[8]; - s16 rooms[8]; + RoomNum nextrooms[8]; + RoomNum rooms[8]; f32 ymax; f32 ymin; f32 radius; f32 bestdistance = 0; s32 nextstep = -1; struct prop *prop = chr->prop; - s16 sp60[2]; + RoomNum sp60[2]; if (CHRRACE(chr) != RACE_EYESPY) { // Do some kind of collision test with the pad to resume from... @@ -6361,11 +6361,11 @@ void chrRecordLastVisibleTargetTime(struct chrdata *chr) chr->lastvisibletarget60 = g_Vars.lvframe60; } -bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, bool allowextraheight, u32 attackflags, u32 entityid) +bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, RoomNum *chrrooms, bool allowextraheight, u32 attackflags, u32 entityid) { bool result = false; struct coord targetpos; - s16 targetrooms[8]; + RoomNum targetrooms[8]; struct prop *targetprop; struct chrdata *targetchr; u32 types; @@ -6404,7 +6404,7 @@ bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, if (allowextraheight && (chr->chrflags & CHRCFLAG_LOSEXTRAHEIGHT)) { struct coord frompos; - s16 fromrooms[8]; + RoomNum fromrooms[8]; frompos.x = chrpos->x; frompos.y = chrpos->y + 70; @@ -6451,7 +6451,7 @@ bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, return result; } -bool chrHasLosToAttackTarget(struct chrdata *chr, struct coord *pos, s16 *rooms, bool allowextraheight) +bool chrHasLosToAttackTarget(struct chrdata *chr, struct coord *pos, RoomNum *rooms, bool allowextraheight) { u32 attackflags = ATTACKFLAG_AIMATTARGET; u32 entityid = 0; @@ -6464,16 +6464,16 @@ bool chrHasLosToAttackTarget(struct chrdata *chr, struct coord *pos, s16 *rooms, return chrHasLosToEntity(chr, pos, rooms, allowextraheight, attackflags, entityid); } -bool chrHasLosToChr(struct chrdata *chr, struct chrdata *target, s16 *room) +bool chrHasLosToChr(struct chrdata *chr, struct chrdata *target, RoomNum *room) { bool cansee = false; u32 stack; - s16 sp88[] = {-1, 0, 0, 0, 0, 0, 0, 0}; + RoomNum sp88[] = {-1, 0, 0, 0, 0, 0, 0, 0}; if (!botIsTargetInvisible(chr, target)) { struct prop *prop = chr->prop; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; pos.x = prop->pos.x; pos.y = chr->ground + chr->height - 20; @@ -6529,12 +6529,12 @@ bool chrHasLosToTarget(struct chrdata *chr) return cansee; } -bool chrHasLosToPos(struct chrdata *chr, struct coord *pos, s16 *rooms) +bool chrHasLosToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms) { struct prop *prop = chr->prop; bool result = false; struct coord eyepos; - s16 chrrooms[8]; + RoomNum chrrooms[8]; eyepos.x = prop->pos.x; eyepos.y = chr->ground + chr->height - 20; @@ -6558,7 +6558,7 @@ bool chrHasLosToPos(struct chrdata *chr, struct coord *pos, s16 *rooms) * Wasteful because this function calculates angles then does nothing with them. * chrHasLosToPos is called with the same arguments regardless. */ -bool chrHasLosToPosWasteful(struct chrdata *chr, struct coord *pos, s16 *rooms) +bool chrHasLosToPosWasteful(struct chrdata *chr, struct coord *pos, RoomNum *rooms) { f32 facingangle = chrGetInverseTheta(chr); f32 posangle = atan2f(pos->x - chr->prop->pos.x, pos->z - chr->prop->pos.z); @@ -7122,7 +7122,7 @@ bool chrGoToPad(struct chrdata *chr, s32 padnum, u32 goposflags) if (padnum >= 0) #endif { - s16 rooms[2]; + RoomNum rooms[2]; struct pad pad; padUnpack(padnum, PADFIELD_ROOM | PADFIELD_POS, &pad); @@ -7234,8 +7234,8 @@ bool chrGoToProp(struct chrdata *chr, struct prop *prop, u32 goposflags) bool chrGoToPos(struct chrdata *chr, struct coord *pos, u32 goposflags) { - s16 inrooms[21]; - s16 aboverooms[21]; + RoomNum inrooms[21]; + RoomNum aboverooms[21]; if (chrIsReadyForOrders(chr)) { #if VERSION >= VERSION_NTSC_1_0 @@ -7246,7 +7246,7 @@ bool chrGoToPos(struct chrdata *chr, struct coord *pos, u32 goposflags) if (g_NumChrsSeenPlayerRecently2 < 10) #endif { - s16 *rooms = NULL; + RoomNum *rooms = NULL; bgFindRoomsByPos(pos, inrooms, aboverooms, 20, NULL); @@ -7372,7 +7372,7 @@ bool chrTryRunFromTarget(struct chrdata *chr) f32 ymin; f32 radius; struct coord dst; - s16 rooms[8]; + RoomNum rooms[8]; struct coord diff; f32 distance; @@ -7492,7 +7492,7 @@ bool chrGoToCoverProp(struct chrdata *chr) f32 propheight; f32 chrheight; struct coord dstpos; - s16 dstrooms[8]; + RoomNum dstrooms[8]; propGetBbox(prop, &propradius, &propymax, &propymin); propGetBbox(chrprop, &chrradius, &chrymax, &chrymin); @@ -9032,7 +9032,7 @@ bool func0f03e9f4(struct chrdata *chr, struct attackanimconfig *animcfg, bool fi f32 sqdist; bool holdturn; struct coord targetpos; - s16 targetrooms[8]; + RoomNum targetrooms[8]; sp178 = targetprop->pos.x - chrprop->pos.x; sp174 = targetprop->pos.y - chrprop->pos.y; @@ -9867,10 +9867,10 @@ void chrTickShoot(struct chrdata *chr, s32 handnum) bool shotdue; bool makebeam; struct coord gunpos; - s16 gunrooms[8]; + RoomNum gunrooms[8]; struct coord hitpos; bool hitsomething; - s16 hitrooms[8]; + RoomNum hitrooms[8]; bool queriedhitrooms; s32 tickspershot; @@ -11771,7 +11771,7 @@ void func0f044b68(struct coord *arg0, struct coord *arg1, struct coord *arg2) * This is similar to chrNavCheckForObstacle. The difference between the two are * not yet understood. */ -bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, s32 arg9) +bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, RoomNum *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, s32 arg9) { struct coord spd4; f32 spd0; @@ -11791,8 +11791,8 @@ bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrroom f32 radius2; struct coord sp6c; struct coord sp60; - s16 sp50[8]; - s16 sp40[8]; + RoomNum sp50[8]; + RoomNum sp40[8]; struct prop *prop = chr->prop; chrGetBbox(prop, &radius2, &ymax, &ymin); @@ -11928,7 +11928,7 @@ bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *chrpos, s16 *chrroom * This is similar to chrNavCanSeeNextPos. The only difference is this one uses * the value1 and value2 variables. */ -bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, bool hasobstacle) +bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, RoomNum *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, bool hasobstacle) { struct coord spd4; f32 spd0; @@ -11950,8 +11950,8 @@ bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrr f32 radius2; struct coord sp6c; struct coord sp60; - s16 sp50[8]; - s16 sp40[8]; + RoomNum sp50[8]; + RoomNum sp40[8]; struct prop *prop = chr->prop; chrGetBbox(prop, &radius2, &ymax, &ymin); @@ -12656,7 +12656,7 @@ bool chrGoPosUpdateLiftAction(struct chrdata *chr, u32 curpadflags, bool arg2, b // Waiting for door to close or lift to arrive at destination if (arg2 || chr->liftaction == LIFTACTION_WAITINGONLIFT) { // Continue waiting - s16 rooms[] = {0, -1}; + RoomNum rooms[] = {0, -1}; u32 stack2; rooms[0] = nextpad.room; @@ -12727,13 +12727,13 @@ void chrTickGoPos(struct chrdata *chr) { struct waypoint *waypoint; struct coord nextpos; - s16 nextrooms[8]; + RoomNum nextrooms[8]; struct prop *prop = chr->prop; bool enteringmagic = false; struct pad pad; bool sp240 = true; struct coord curwppos; - s16 curwprooms[8]; + RoomNum curwprooms[8]; u32 curwpflags; chr->act_gopos.flags &= ~(GOPOSFLAG_CROUCH | GOPOSFLAG_DUCK); @@ -13025,7 +13025,7 @@ void chrTickPatrol(struct chrdata *chr) bool enteringmagic; u32 flags = 0; struct coord sp58; - s16 sp48[8]; + RoomNum sp48[8]; s32 arrivinglaterally; s32 arriving; bool advance; @@ -13742,7 +13742,7 @@ f32 chrGetAngleToTarget(struct chrdata *chr) return chrGetAngleToPos(chr, &prop->pos); } -void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, struct coord *pos, s16 *rooms) +void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, struct coord *pos, RoomNum *rooms) { struct prop *targetprop; struct chrdata *targetchr; @@ -14585,7 +14585,7 @@ bool waypointIsWithin90DegreesOfPosAngle(struct waypoint *waypoint, struct coord * those are in the quadrant then no further checks are made and the function * returns -1. */ -s32 chrFindWaypointWithinPosQuadrant(struct coord *pos, s16 *rooms, f32 angle, u8 quadrant) +s32 chrFindWaypointWithinPosQuadrant(struct coord *pos, RoomNum *rooms, f32 angle, u8 quadrant) { struct waypoint *waypoint = waypointFindClosestToPos(pos, rooms); s32 neighbournum; @@ -14716,7 +14716,7 @@ bool chrSetChrPresetToChrNearSelf(u8 checktype, struct chrdata *chr, f32 distanc bool chrSetChrPresetToChrNearPad(u32 checktype, struct chrdata *chr, f32 distance, s32 padnum) { struct pad pad; - s16 rooms[2]; + RoomNum rooms[2]; padnum = chrResolvePadId(chr, padnum); padUnpack(padnum, PADFIELD_POS | PADFIELD_ROOM, &pad); @@ -14727,19 +14727,19 @@ bool chrSetChrPresetToChrNearPad(u32 checktype, struct chrdata *chr, f32 distanc return chrSetChrPresetToChrNearPos(checktype, chr, distance, &pad.pos, rooms); } -bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, s16 *rooms) +bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, RoomNum *rooms) { s32 i; s16 *propnumptr; s16 propnums[256]; - s16 allrooms[21]; + RoomNum allrooms[21]; f32 xmin = pos->x - distance; f32 xmax = pos->x + distance; f32 ymin = pos->y - distance; f32 ymax = pos->y + distance; f32 zmin = pos->z - distance; f32 zmax = pos->z + distance; - s16 neighbours[11]; + RoomNum neighbours[11]; roomsCopy(rooms, allrooms); @@ -14912,7 +14912,7 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) return false; } -bool chrIsPosOffScreen(struct coord *pos, s16 *rooms) +bool chrIsPosOffScreen(struct coord *pos, RoomNum *rooms) { bool offscreen = true; s32 i; @@ -14943,12 +14943,12 @@ bool chrIsPosOffScreen(struct coord *pos, s16 *rooms) * If the spawn cannot happen, the function return false. */ #if VERSION >= VERSION_NTSC_1_0 -bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool force, bool onlysurrounding) +bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, RoomNum *rooms, f32 angle, bool allowonscreen, bool force, bool onlysurrounding) { struct coord testpos; s32 i; u32 types; - s16 testrooms[8]; + RoomNum testrooms[8]; f32 ymin; f32 ymax = 200; f32 curangle = angle; @@ -15030,12 +15030,12 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl * ntsc-beta's version of this function doesn't have the onlysurrounding argument * nor out of bounds checking, and lacks the reduction for the volume test. */ -bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool force) +bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, RoomNum *rooms, f32 angle, bool allowonscreen, bool force) { struct coord testpos; s32 i; u32 types; - s16 testrooms[8]; + RoomNum testrooms[8]; f32 curangle = angle; if (force) { @@ -15084,11 +15084,11 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angl * triggered, but the function will not attempt to spawn the chr until the next * time it's called. */ -struct prop *chrSpawnAtCoord(s32 bodynum, s32 headnum, struct coord *pos, s16 *rooms, f32 angle, u8 *ailist, u32 spawnflags) +struct prop *chrSpawnAtCoord(s32 bodynum, s32 headnum, struct coord *pos, RoomNum *rooms, f32 angle, u8 *ailist, u32 spawnflags) { struct prop *prop; struct coord pos2; - s16 rooms2[8]; + RoomNum rooms2[8]; s32 stack; if (chrsGetNumFree() > 1) { @@ -15199,7 +15199,7 @@ struct prop *chrSpawnAtPad(struct chrdata *basechr, s32 body, s32 head, s32 pad_ { s32 resolved_pad_id = chrResolvePadId(basechr, pad_id); struct pad pad; - s16 room[2]; + RoomNum room[2]; f32 fvalue; padUnpack(resolved_pad_id, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_ROOM, &pad); fvalue = atan2f(pad.look.x, pad.look.z); @@ -15253,10 +15253,10 @@ void func0f04b740(void) // empty } -bool chrMoveToPos(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 angle, bool force) +bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 angle, bool force) { struct coord pos2; - s16 rooms2[8]; + RoomNum rooms2[8]; bool result = false; u32 nodetype; union modelrwdata *rwdata; @@ -15356,7 +15356,7 @@ bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft) s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 criteria, s32 refdist) { - s16 rooms[8]; + RoomNum rooms[8]; struct cover cover; struct covercandidate tmp; s32 oldcover; @@ -15619,7 +15619,7 @@ bool chrRunFromPos(struct chrdata *chr, u32 goposflags, f32 rundist, struct coor { f32 curdistfrompos; struct coord delta; - s16 rooms[8]; + RoomNum rooms[8]; if (chrIsReadyForOrders(chr)) { delta.x = chr->prop->pos.x - frompos->x; @@ -16010,12 +16010,12 @@ bool audioWasNotPlayedRecently(s16 audioid) } #if VERSION >= VERSION_NTSC_1_0 -Gfx *chrsRenderChrStats(Gfx *gdl, s16 *rooms) +Gfx *chrsRenderChrStats(Gfx *gdl, RoomNum *rooms) { return gdl; } #else -Gfx *chrsRenderChrStats(Gfx *gdl, s16 *rooms) +Gfx *chrsRenderChrStats(Gfx *gdl, RoomNum *rooms) { s32 x; s32 y; @@ -16127,7 +16127,7 @@ void chrAvoid(struct chrdata *chr) f32 zdiff; f32 halfchrradius; f32 chrangle = modelGetChrRotY(chr->model); - s16 dstrooms[8]; + RoomNum dstrooms[8]; struct coord dstpos; // @bug: This shouldn't be here, and the perim is not enabled again diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index f7aba6865..49e55c0e6 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -2361,7 +2361,7 @@ bool aiObjectMoveToPad(void) u16 padnum = cmd[4] | (cmd[3] << 8); Mtxf matrix; struct pad pad; - s16 rooms[2]; + RoomNum rooms[2]; if (obj && obj->prop) { padUnpack(padnum, PADFIELD_POS | PADFIELD_LOOK | PADFIELD_UP | PADFIELD_ROOM, &pad); @@ -5184,7 +5184,7 @@ bool aiChrMoveToPad(void) bool pass = false; f32 theta; struct pad pad; - s16 rooms[2]; + RoomNum rooms[2]; struct chrdata *chr2; if (chr && chr->prop) { @@ -9611,7 +9611,7 @@ bool aiSetDrCarollImages(void) bool aiSetRoomFlag(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - s16 roomnum = cmd[3] | cmd[2] << 8; + RoomNum roomnum = cmd[3] | cmd[2] << 8; s16 flag = cmd[5] | cmd[4] << 8; g_Rooms[roomnum].flags |= flag; @@ -9658,7 +9658,7 @@ bool aiShowCutsceneChrs(void) bool aiConfigureEnvironment(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - s16 room_id = (cmd[3] | (cmd[2] << 8)); + RoomNum room_id = (cmd[3] | (cmd[2] << 8)); s32 value = cmd[5]; s32 i; diff --git a/src/game/chrmgr.c b/src/game/chrmgr.c index 494191dcd..08dec6d76 100644 --- a/src/game/chrmgr.c +++ b/src/game/chrmgr.c @@ -33,8 +33,8 @@ void chrmgrReset(void) g_ChrIndexes = NULL; var80062960 = mempAlloc(ALIGN16(15 * sizeof(struct var80062960)), MEMPOOL_STAGE); - for (i = 0; i < 20; i++) { - var8009ccc0[i] = (void *)ALIGN64(mempAlloc(0x240, MEMPOOL_STAGE)); + for (i = 0; i < ARRAYCOUNT(var8009ccc0); i++) { + var8009ccc0[i] = (void *)ALIGN64(mempAlloc(16 * 16 * sizeof(u16) + 0x40, MEMPOOL_STAGE)); } resetSomeStageThings(); @@ -54,8 +54,8 @@ void chrmgrConfigure(s32 numchrs) } g_NumChrs = 0; - g_Chrnums = mempAlloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE); - g_ChrIndexes = mempAlloc(ALIGN16(g_NumChrSlots * 2), MEMPOOL_STAGE); + g_Chrnums = mempAlloc(ALIGN16(g_NumChrSlots * sizeof(g_Chrnums[0])), MEMPOOL_STAGE); + g_ChrIndexes = mempAlloc(ALIGN16(g_NumChrSlots * sizeof(g_ChrIndexes[0])), MEMPOOL_STAGE); for (i = 0; i < g_NumChrSlots; i++) { g_Chrnums[i] = -1; diff --git a/src/game/dlights.c b/src/game/dlights.c index 3def7eaf0..c00836a0a 100644 --- a/src/game/dlights.c +++ b/src/game/dlights.c @@ -311,7 +311,7 @@ void roomSetDefaults(struct room *room) room->lightop_duration240 = 0; } -Gfx *lightsSetForRoom(Gfx *gdl, s16 roomnum) +Gfx *lightsSetForRoom(Gfx *gdl, RoomNum roomnum) { Lights1 *lights = gfxAllocate(sizeof(Lights1)); @@ -989,7 +989,7 @@ bool lightTickBroken(s32 roomnum, s32 lightnum) f32 rand1 = 2.0f * RANDOMFRAC() - 1.0f; // range -1 to 1 f32 rand2 = 2.0f * RANDOMFRAC() - 1.0f; // range -1 to 1 s32 sparktype = -1; - s16 smokerooms[2]; + RoomNum smokerooms[2]; struct bgroom *room; spc8.x = light->bbox[1].x - light->bbox[0].x; diff --git a/src/game/dyntex.c b/src/game/dyntex.c index 33600ae35..97ebf827c 100644 --- a/src/game/dyntex.c +++ b/src/game/dyntex.c @@ -354,7 +354,7 @@ void dyntexSetCurrentType(s16 type) g_DyntexCurType = type; } -void dyntexSetCurrentRoom(s16 roomnum) +void dyntexSetCurrentRoom(RoomNum roomnum) { s32 i; diff --git a/src/game/explosions.c b/src/game/explosions.c index 1472cda56..329ea74c0 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -81,18 +81,18 @@ struct explosiontype g_ExplosionTypes[] = { /*25*/ { 640, 480, 32, 11.2, 1600, 1000, 1000, 180, 2, 5, SMOKETYPE_NONE, 0x80a4, 4 }, }; -bool explosionCreateSimple(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum) +bool explosionCreateSimple(struct prop *prop, struct coord *pos, RoomNum *rooms, s16 type, s32 playernum) { return explosionCreate(prop, pos, rooms, type, playernum, false, NULL, 0, NULL); } -bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum) +bool explosionCreateComplex(struct prop *prop, struct coord *pos, RoomNum *rooms, s16 type, s32 playernum) { struct coord sp100; struct coord sp88; struct explosiontype *etype; bool makescorch = true; - s16 room; + RoomNum room; f32 y; struct prop *collisionprop; @@ -232,8 +232,8 @@ void explosionAlertChrs(f32 *radius, struct coord *noisepos) #endif } -bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exprooms, - s16 type, s32 playernum, bool makescorch, struct coord *arg6, s16 room, struct coord *arg8) +bool explosionCreate(struct prop *sourceprop, struct coord *exppos, RoomNum *exprooms, + s16 type, s32 playernum, bool makescorch, struct coord *arg6, RoomNum room, struct coord *arg8) { u32 stack; struct explosion *exp = NULL; @@ -314,8 +314,8 @@ bool explosionCreate(struct prop *sourceprop, struct coord *exppos, s16 *exproom struct coord portal2bbmax; struct coord spd4; struct coord spc8; - s16 otherroom; - s16 otherroom2; + RoomNum otherroom; + RoomNum otherroom2; f32 mult = 1; s32 stack4; s32 portalnum2; @@ -626,7 +626,7 @@ bool explosionOverlapsProp(struct explosion *exp, struct prop *prop, struct coor { bool result = false; s32 i; - s16 rooms[8]; + RoomNum rooms[8]; if (exp->type == EXPLOSIONTYPE_HUGE25) { result = true; diff --git a/src/game/filelist.c b/src/game/filelist.c index bdeebcc0a..1cfe79936 100644 --- a/src/game/filelist.c +++ b/src/game/filelist.c @@ -22,7 +22,7 @@ #include "data.h" #include "types.h" -s32 var800a2330[5]; +s32 g_FilelistKnownPlugCounts[5]; struct filelist *g_FileLists[MAX_PLAYERS] = { NULL }; bool var80075bd0[] = { true, true, true, true }; @@ -60,7 +60,7 @@ void filelistCreate(s32 listnum, u8 filetype) g_FileLists[listnum]->filetype = filetype; if (var80062944 == 0) { - joy0001398c(3); + joySetPfsPollInterval(3); } var80062944 = 1; @@ -92,9 +92,9 @@ s32 filelistFindOrCreate(u8 filetype) } #if VERSION >= VERSION_NTSC_1_0 -void func0f110d90(s32 device) +void filelistInvalidatePak(s32 device) { - var800a2330[device] = -1; + g_FilelistKnownPlugCounts[device] = -1; } #endif @@ -103,36 +103,36 @@ void filelistsTick(void) u32 updateall; u32 update; s32 i; - static bool var80075bf4 = false; + static bool doneinit = false; - if (!var80075bf4) { - for (i = 0; i < ARRAYCOUNT(var800a2330); i++) { - var800a2330[i] = -1; + if (!doneinit) { + for (i = 0; i < ARRAYCOUNT(g_FilelistKnownPlugCounts); i++) { + g_FilelistKnownPlugCounts[i] = -1; } - var80075bf4 = true; + doneinit = true; } #if VERSION >= VERSION_NTSC_1_0 - for (i = 0, updateall = false; i < ARRAYCOUNT(var800a2330); i++) { - if (pak0f1167d8(i) && var800a2330[i] != pakGetUnk264(i)) { + for (i = 0, updateall = false; i < ARRAYCOUNT(g_FilelistKnownPlugCounts); i++) { + if (pak0f1167d8(i) && pakGetPlugCount(i) != g_FilelistKnownPlugCounts[i]) { updateall = true; - var800a2330[i] = pakGetUnk264(i); + g_FilelistKnownPlugCounts[i] = pakGetPlugCount(i); } } #else - for (i = 0, updateall = false; i < ARRAYCOUNT(var800a2330); i++) { - s32 tmp = pakGetUnk264(i); + for (i = 0, updateall = false; i < ARRAYCOUNT(g_FilelistKnownPlugCounts); i++) { + s32 plugcount = pakGetPlugCount(i); pak0f11698c(i); if (pak0f1167d8(i)) { - tmp = 0; + plugcount = 0; } - if (var800a2330[i] != tmp) { + if (g_FilelistKnownPlugCounts[i] != plugcount) { updateall = true; - var800a2330[i] = tmp; + g_FilelistKnownPlugCounts[i] = plugcount; } } #endif diff --git a/src/game/filemgr.c b/src/game/filemgr.c index ef3cf8d67..6d7184cf1 100644 --- a/src/game/filemgr.c +++ b/src/game/filemgr.c @@ -2187,7 +2187,7 @@ MenuItemHandlerResult pakDeleteGameNoteMenuHandler(s32 operation, struct menuite g_Menus[g_MpPlayerNum].fm.device1 = g_Menus[g_MpPlayerNum].fm.device; - if (result) { + if (result != PAK_ERR1_OK) { filemgrPushErrorDialog(FILEERROR_DELETENOTEFAILED); } } @@ -2314,14 +2314,14 @@ MenuDialogHandlerResult pakGameNotesMenuDialog(s32 operation, struct menudialogd if (operation == MENUOP_TICK) { if (g_Menus[g_MpPlayerNum].curdialog && g_Menus[g_MpPlayerNum].curdialog->definition == dialogdef) { - s32 value = pak0f1168c4(g_Menus[g_MpPlayerNum].fm.device, &g_EditingPak); + PakErr1 ret = pak0f1168c4(g_Menus[g_MpPlayerNum].fm.device, &g_EditingPak); - if (value) { + if (ret != PAK_ERR1_OK) { menuCloseDialog(); g_EditingPak = NULL; g_Menus[g_MpPlayerNum].fm.device1 = g_Menus[g_MpPlayerNum].fm.device; - if (value == 1) { + if (ret == PAK_ERR1_NOPAK) { filemgrPushErrorDialog(FILEERROR_PAKREMOVED); } @@ -2403,7 +2403,7 @@ char *pakMenuTextEditingPakName(struct menuitem *item) MenuItemHandlerResult pakSelectionMenuHandler(s32 operation, struct menuitem *item, union handlerdata *data) { if (operation == MENUOP_CHECKDISABLED) { - if (!pakIsMemoryPak((s8)item->param)) { + if (!mempakIsOkay((s8)item->param)) { return true; } } @@ -2426,7 +2426,7 @@ MenuDialogHandlerResult pakChoosePakMenuDialog(s32 operation, struct menudialogd #if VERSION >= VERSION_NTSC_1_0 switch (operation) { case MENUOP_OPEN: - joy0001398c(3); + joySetPfsPollInterval(3); g_Menus[g_MpPlayerNum].fm.unke24 = 0; break; case MENUOP_TICK: @@ -2438,20 +2438,20 @@ MenuDialogHandlerResult pakChoosePakMenuDialog(s32 operation, struct menudialogd for (i = 0; i < MAX_PLAYERS; i++) { if (g_Menus[g_MpPlayerNum].fm.unke24 & (1 << i)) { - g_Vars.unk0004e4 &= 0xfff0; - g_Vars.unk0004e4 |= 0x0008; - g_Vars.unk0004e4 |= 1 << (i + 8); + g_Vars.pakstocheck &= 0xfff0; + g_Vars.pakstocheck |= 0x0008; + g_Vars.pakstocheck |= 1 << (i + 8); } } } - joy000139c8(); + joySetDefaultPfsPollInterval(); break; } #else switch (operation) { case MENUOP_OPEN: - joy0001398c(3); - joy0001398c(-1); + joySetPfsPollInterval(3); + joySetPfsPollInterval(-1); g_Menus[g_MpPlayerNum].fm.unke24 = 0; break; case MENUOP_TICK: @@ -2467,7 +2467,7 @@ MenuDialogHandlerResult pakChoosePakMenuDialog(s32 operation, struct menudialogd } } } - joy000139c8(); + joySetDefaultPfsPollInterval(); pak0f1189d0(); break; } diff --git a/src/game/gamefile.c b/src/game/gamefile.c index 70b6a61a1..378a1f33d 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -170,7 +170,7 @@ void gamefileLoadDefaults(struct gamefile *file) pakSetBitflag(GAMEFILEFLAG_P1_FORWARDPITCH, file->flags, false); pakSetBitflag(GAMEFILEFLAG_P1_AUTOAIM, file->flags, true); - pakSetBitflag(GAMEFILEFLAG_P1_AIMCONTROL, file->flags, AIMCONTROL_HOLD); + pakSetBitflag(GAMEFILEFLAG_P1_AIMCONTROL, file->flags, false); pakSetBitflag(GAMEFILEFLAG_P1_SIGHTONSCREEN, file->flags, true); #ifdef PLATFORM_N64 pakSetBitflag(GAMEFILEFLAG_P1_LOOKAHEAD, file->flags, true); @@ -188,7 +188,7 @@ void gamefileLoadDefaults(struct gamefile *file) pakSetBitflag(GAMEFILEFLAG_P2_FORWARDPITCH, file->flags, false); pakSetBitflag(GAMEFILEFLAG_P2_AUTOAIM, file->flags, true); - pakSetBitflag(GAMEFILEFLAG_P2_AIMCONTROL, file->flags, AIMCONTROL_HOLD); + pakSetBitflag(GAMEFILEFLAG_P2_AIMCONTROL, file->flags, false); pakSetBitflag(GAMEFILEFLAG_P2_SIGHTONSCREEN, file->flags, true); pakSetBitflag(GAMEFILEFLAG_P2_LOOKAHEAD, file->flags, true); pakSetBitflag(GAMEFILEFLAG_P2_AMMOONSCREEN, file->flags, true); @@ -206,8 +206,8 @@ void gamefileLoadDefaults(struct gamefile *file) pakSetBitflag(GAMEFILEFLAG_P2_SHOWMISSIONTIME, file->flags, false); pakSetBitflag(GAMEFILEFLAG_P2_PAINTBALL, file->flags, false); - pakSetBitflag(GAMEFILEFLAG_SCREENSPLIT, file->flags, SCREENSPLIT_HORIZONTAL); - pakSetBitflag(GAMEFILEFLAG_SCREENRATIO, file->flags, SCREENRATIO_NORMAL); + pakSetBitflag(GAMEFILEFLAG_SCREENSPLIT, file->flags, false); + pakSetBitflag(GAMEFILEFLAG_SCREENRATIO, file->flags, false); pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_CINEMA, file->flags, false); pakSetBitflag(GAMEFILEFLAG_SCREENSIZE_WIDE, file->flags, false); @@ -223,7 +223,7 @@ void gamefileLoadDefaults(struct gamefile *file) pakSetBitflag(GAMEFILEFLAG_COOPRADARON, file->flags, true); pakSetBitflag(GAMEFILEFLAG_COOPFRIENDLYFIRE, file->flags, true); pakSetBitflag(GAMEFILEFLAG_ANTIRADARON, file->flags, true); - pakSetBitflag(GAMEFILEFLAG_ANTIPLAYERNUM, file->flags, 1); + pakSetBitflag(GAMEFILEFLAG_ANTIPLAYERNUM, file->flags, true); #if VERSION >= VERSION_PAL_BETA pakSetBitflag(GAMEFILEFLAG_LANGBIT1, g_GameFile.flags, ((g_Vars.language & 0x01) == 0x01)); diff --git a/src/game/lv.c b/src/game/lv.c index 0aed98d9d..6d5516152 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -241,7 +241,7 @@ void lvReset(s32 stagenum) var80084010 = 0; #if VERSION >= VERSION_NTSC_1_0 - joy00013900(); + joyLockCyclicPolling(); g_Vars.joydisableframestogo = 10; #else @@ -252,8 +252,8 @@ void lvReset(s32 stagenum) } #endif - g_Vars.paksconnected2 = 0; - g_Vars.paksconnected = 0; + g_Vars.paksneededforgame = 0; + g_Vars.paksneededformenu = 0; g_Vars.stagenum = stagenum; cheatsReset(); @@ -1607,9 +1607,9 @@ Gfx *lvRender(Gfx *gdl) || debugIsChrStatsEnabled() || debug0f11ee40()) { #if VERSION < VERSION_NTSC_1_0 - s16 spc8[21]; - s16 spb0[11]; - s16 sp9c[10]; + RoomNum spc8[21]; + RoomNum spb0[11]; + RoomNum sp9c[10]; s32 j; sp9c[0] = g_Vars.currentplayer->memcamroom; @@ -1997,7 +1997,7 @@ void lvTick(void) lvCheckPauseStateChanged(); #if VERSION >= VERSION_NTSC_1_0 - if (g_Vars.unk0004e4) { + if (g_Vars.pakstocheck) { paksTick(); } #endif @@ -2006,7 +2006,7 @@ void lvTick(void) g_Vars.joydisableframestogo--; } else if (g_Vars.joydisableframestogo == 0) { #if VERSION >= VERSION_NTSC_1_0 - joy00013938(); + joyUnlockCyclicPolling(); #else if (!joyIsCyclicPollingEnabled()) { joyEnableCyclicPolling(3278, "lv.c"); @@ -2017,9 +2017,9 @@ void lvTick(void) || g_Vars.stagenum == STAGE_BOOTPAKMENU || g_Vars.stagenum == STAGE_CREDITS || g_Vars.stagenum == STAGE_4MBMENU) { - g_Vars.paksconnected2 = 0; + g_Vars.paksneededforgame = 0; } else { - g_Vars.paksconnected2 = 31; + g_Vars.paksneededforgame = 0x1f; pakEnableRumbleForAllPlayers(); } @@ -2063,7 +2063,7 @@ void lvTick(void) // Check if another player is in a nearby room for (playernum = 0; playernum < PLAYERCOUNT() && !foundnearbychr; playernum++) { if (g_Vars.players[playernum]->isdead == false) { - s16 *rooms = g_Vars.players[playernum]->prop->rooms; + RoomNum *rooms = g_Vars.players[playernum]->prop->rooms; s32 r; for (r = 0; rooms[r] != -1 && !foundnearbychr; r++) { diff --git a/src/game/menu.c b/src/game/menu.c index b94555c3a..22d9af973 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -5625,7 +5625,7 @@ MenuDialogHandlerResult menudialog000fcd48(s32 operation, struct menudialogdef * if (operation == MENUOP_TICK) { if (g_Menus[g_MpPlayerNum].curdialog && g_Menus[g_MpPlayerNum].curdialog->definition == dialogdef - && joy000155b4(g_Menus[g_MpPlayerNum].fm.device3) == 0) { + && joyGetPakState(g_Menus[g_MpPlayerNum].fm.device3) == PAKSTATE_NOPAK) { func0f0f3704(&g_PakRemovedMenuDialog); } } @@ -5657,12 +5657,12 @@ MenuItemHandlerResult menuhandlerRepairPak(s32 operation, struct menuitem *item, return 0; } -void func0f0fce8c(struct menudialogdef *dialogdef, s32 playernum, s32 arg2) +void menuPushPakDialogForPlayer(struct menudialogdef *dialogdef, s32 playernum, s32 paknum) { s32 prevplayernum = g_MpPlayerNum; g_MpPlayerNum = playernum; - g_Menus[g_MpPlayerNum].fm.device3 = arg2; + g_Menus[g_MpPlayerNum].fm.device3 = paknum; if (g_Menus[g_MpPlayerNum].curdialog == NULL) { if (PLAYERCOUNT() == 1) { @@ -5882,11 +5882,11 @@ MenuItemHandlerResult menuhandlerRetrySavePak(s32 operation, struct menuitem *it menuPopDialog(); #if VERSION >= VERSION_NTSC_1_0 - g_Vars.unk0004e4 &= 0xfff0; - g_Vars.unk0004e4 |= 8; - g_Vars.unk0004e4 |= 1 << ((u8)g_Menus[g_MpPlayerNum].fm.device3 + 8); + g_Vars.pakstocheck &= 0xfff0; + g_Vars.pakstocheck |= 0x0008; + g_Vars.pakstocheck |= 1 << ((u8)g_Menus[g_MpPlayerNum].fm.device3 + 8); #else - pak0f1169c8(g_Menus[g_MpPlayerNum].fm.device3, 0); + pak0f1169c8(g_Menus[g_MpPlayerNum].fm.device3, false); #endif } @@ -5906,18 +5906,18 @@ MenuItemHandlerResult menuhandlerWarnRepairPak(s32 operation, struct menuitem *i return 0; } -u32 func0f0fd118(u32 playernum) +s32 menuPakNumToPlayerNum(s32 paknum) { u32 result = 0; if (g_Vars.normmplayerisrunning) { - if (g_MpSetup.chrslots & (1 << playernum)) { - result = playernum; + if (g_MpSetup.chrslots & (1 << paknum)) { + result = paknum; } } else { if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) && PLAYERCOUNT() >= 2 - && playernum == 1) { + && paknum == 1) { result = 1; } } @@ -5925,9 +5925,9 @@ u32 func0f0fd118(u32 playernum) return result; } -bool func0f0fd1f4(s32 arg0, s32 arg1) +bool menuIsReadyForPakError(s32 paknum, s32 pakerrordialog) { - s32 playernum = func0f0fd118(arg0); + s32 playernum = menuPakNumToPlayerNum(paknum); bool result = true; if (g_Vars.lvframenum < 20) { @@ -5952,8 +5952,7 @@ bool func0f0fd1f4(s32 arg0, s32 arg1) || g_Menus[playernum].curdialog->definition == &g_PakAttemptRepairMenuDialog || g_Menus[playernum].curdialog->definition == &g_PakRemovedMenuDialog || g_Menus[playernum].curdialog->definition == &g_PakRepairSuccessMenuDialog - || g_Menus[playernum].curdialog->definition == &g_PakRepairFailedMenuDialog - ) { + || g_Menus[playernum].curdialog->definition == &g_PakRepairFailedMenuDialog) { result = false; } } else if (g_MenuData.nextbg != 255 || g_MenuData.bg || g_MenuData.unk5d4) { @@ -5963,21 +5962,21 @@ bool func0f0fd1f4(s32 arg0, s32 arg1) return result; } -void func0f0fd320(s32 arg0, s32 arg1) +void menuPushPakErrorDialog(s32 paknum, s32 pakerrordialog) { s32 prevplayernum = g_MpPlayerNum; - s32 playernum = func0f0fd118(arg0); + s32 playernum = menuPakNumToPlayerNum(paknum); bool found; s32 i; g_MpPlayerNum = playernum; - switch (arg1) { - case 1: - case 2: - func0f0fce8c(&g_PakDamagedMenuDialog, playernum, arg0); + switch (pakerrordialog) { + case PAKERRORDIALOG_CORRUPT: + case PAKERRORDIALOG_DEVICEERROR: + menuPushPakDialogForPlayer(&g_PakDamagedMenuDialog, playernum, paknum); break; - case 0: + case PAKERRORDIALOG_FULL: found = false; for (i = 0; i < g_Menus[g_MpPlayerNum].depth; i++) { @@ -5988,15 +5987,15 @@ void func0f0fd320(s32 arg0, s32 arg1) } if (!found) { - func0f0fce8c(&g_PakFullMenuDialog, playernum, arg0); + menuPushPakDialogForPlayer(&g_PakFullMenuDialog, playernum, paknum); } break; #if VERSION >= VERSION_NTSC_1_0 - case 3: - func0f0fce8c(&g_PakCannotReadGameBoyMenuDialog, playernum, arg0); + case PAKERRORDIALOG_GB_UNREADABLE: + menuPushPakDialogForPlayer(&g_PakCannotReadGameBoyMenuDialog, playernum, paknum); break; - case 4: - func0f0fce8c(&g_PakDataLostMenuDialog, playernum, arg0); + case PAKERRORDIALOG_DATALOST: + menuPushPakDialogForPlayer(&g_PakDataLostMenuDialog, playernum, paknum); break; #endif } diff --git a/src/game/menustop.c b/src/game/menustop.c index d0100308b..a58773847 100644 --- a/src/game/menustop.c +++ b/src/game/menustop.c @@ -32,7 +32,7 @@ void menuStop(void) if (var80062944) { var80062944 = 0; var80062948 = 0; - joy000139c8(); + joySetDefaultPfsPollInterval(); func0f110bf8(); } } diff --git a/src/game/menutick.c b/src/game/menutick.c index 758bb5879..f1e713d35 100644 --- a/src/game/menutick.c +++ b/src/game/menutick.c @@ -697,7 +697,7 @@ void menuTick(void) } } - g_Vars.paksconnected = 0; + g_Vars.paksneededformenu = 0; for (i = 0; i < PLAYERCOUNT(); i++) { s32 mpindex = -1; @@ -731,7 +731,7 @@ void menuTick(void) case MENUROOT_4MBMAINMENU: case MENUROOT_TRAINING: if (g_Menus[mpindex].curdialog) { - g_Vars.paksconnected = 0x1f; + g_Vars.paksneededformenu = 0x1f; } break; } diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index 4ee3e806c..e2c144d21 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -64,10 +64,10 @@ struct mpscenario { Gfx *(*radarextrafunc)(Gfx *gdl); bool (*radarchrfunc)(Gfx **gdl, struct prop *prop); bool (*highlightpropfunc)(struct prop *prop, s32 *colour); - bool (*spawnfunc)(f32 arg0, struct coord *pos, s16 *rooms, struct prop *prop, f32 *arg4); + bool (*spawnfunc)(f32 arg0, struct coord *pos, RoomNum *rooms, struct prop *prop, f32 *arg4); s32 (*maxteamsfunc)(void); - bool (*isroomhighlightedfunc)(s16 room); - void (*highlightroomfunc)(s16 room, s32 *arg1, s32 *arg2, s32 *arg3); + bool (*isroomhighlightedfunc)(RoomNum room); + void (*highlightroomfunc)(RoomNum room, s32 *arg1, s32 *arg2, s32 *arg3); void *unk3c; // never hooked into nor fired void (*readsavefunc)(struct savebuffer *buffer); void (*writesavefunc)(struct savebuffer *buffer); @@ -791,7 +791,7 @@ bool scenarioHighlightProp(struct prop *prop, s32 *colour) * * CTC uses this to ensure the chrs spawn near their base. */ -f32 scenarioChooseSpawnLocation(f32 chrradius, struct coord *pos, s16 *rooms, struct prop *prop) +f32 scenarioChooseSpawnLocation(f32 chrradius, struct coord *pos, RoomNum *rooms, struct prop *prop) { f32 result; @@ -917,7 +917,7 @@ s32 scenarioGetMaxTeams(void) /** * This callback is unused. */ -bool scenarioIsRoomHighlighted(s16 room) +bool scenarioIsRoomHighlighted(RoomNum room) { if (g_MpScenarios[g_MpSetup.scenario].isroomhighlightedfunc) { return g_MpScenarios[g_MpSetup.scenario].isroomhighlightedfunc(room); @@ -931,7 +931,7 @@ bool scenarioIsRoomHighlighted(s16 room) * * Used in CTC for the team bases and in KOH for the hill. */ -void scenarioHighlightRoom(s16 room, s32 *arg1, s32 *arg2, s32 *arg3) +void scenarioHighlightRoom(RoomNum room, s32 *arg1, s32 *arg2, s32 *arg3) { if (g_MpScenarios[g_MpSetup.scenario].highlightroomfunc) { g_MpScenarios[g_MpSetup.scenario].highlightroomfunc(room, arg1, arg2, arg3); @@ -1351,7 +1351,7 @@ void scenarioHandleDroppedToken(struct chrdata *chr, struct prop *prop) struct defaultobj *obj; struct pad pad; Mtxf mtx; - s16 rooms[2]; + RoomNum rooms[2]; if (g_MpSetup.scenario == MPSCENARIO_CAPTURETHECASE) { for (i = 0; i < ARRAYCOUNT(g_ScenarioData.ctc.tokens); i++) { diff --git a/src/game/mplayer/scenarios/capturethecase.inc b/src/game/mplayer/scenarios/capturethecase.inc index 652561aca..b701a69c2 100644 --- a/src/game/mplayer/scenarios/capturethecase.inc +++ b/src/game/mplayer/scenarios/capturethecase.inc @@ -457,7 +457,7 @@ void ctcAddPad(s32 *cmd) } } -bool ctcChooseSpawnLocation(f32 arg0, struct coord *pos, s16 *rooms, struct prop *prop, f32 *arg4) +bool ctcChooseSpawnLocation(f32 arg0, struct coord *pos, RoomNum *rooms, struct prop *prop, f32 *arg4) { struct chrdata *chr = prop->chr; s32 index = radarGetTeamIndex(chr->team); @@ -477,7 +477,7 @@ s32 ctcGetMaxTeams(void) return 4; } -bool ctcIsRoomHighlighted(s16 room) +bool ctcIsRoomHighlighted(RoomNum room) { s32 i; @@ -490,7 +490,7 @@ bool ctcIsRoomHighlighted(s16 room) return false; } -void ctcHighlightRoom(s16 roomnum, s32 *arg1, s32 *arg2, s32 *arg3) +void ctcHighlightRoom(RoomNum roomnum, s32 *arg1, s32 *arg2, s32 *arg3) { s32 i; diff --git a/src/game/mplayer/scenarios/kingofthehill.inc b/src/game/mplayer/scenarios/kingofthehill.inc index ae926e975..2a837ff23 100644 --- a/src/game/mplayer/scenarios/kingofthehill.inc +++ b/src/game/mplayer/scenarios/kingofthehill.inc @@ -658,12 +658,12 @@ void kohAddHill(s32 *cmd) } } -bool kohIsRoomHighlighted(s16 room) +bool kohIsRoomHighlighted(RoomNum room) { return room == g_ScenarioData.koh.hillrooms[0]; } -void kohHighlightRoom(s16 roomnum, s32 *arg1, s32 *arg2, s32 *arg3) +void kohHighlightRoom(RoomNum roomnum, s32 *arg1, s32 *arg2, s32 *arg3) { if (roomnum == g_ScenarioData.koh.hillrooms[0]) { f32 a = *arg1; diff --git a/src/game/nbomb.c b/src/game/nbomb.c index 4815c3e8d..28bbb643a 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -431,7 +431,7 @@ void nbombInflictDamage(struct nbomb *nbomb) s16 propnums[256]; struct coord bbmin; struct coord bbmax; - s16 roomnums[54]; + RoomNum roomnums[54]; s16 *propnumptr; s32 i; struct gset gset; diff --git a/src/game/objectives.c b/src/game/objectives.c index 4a7b76d71..01f38e962 100644 --- a/src/game/objectives.c +++ b/src/game/objectives.c @@ -456,7 +456,7 @@ void objectiveCheckRoomEntered(s32 currentroom) } } -void objectiveCheckThrowInRoom(s32 arg0, s16 *inrooms) +void objectiveCheckThrowInRoom(s32 arg0, RoomNum *inrooms) { struct criteria_throwinroom *criteria = g_ThrowInRoomCriterias; @@ -465,7 +465,7 @@ void objectiveCheckThrowInRoom(s32 arg0, s16 *inrooms) s32 room = chrGetPadRoom(NULL, criteria->pad); if (room >= 0) { - s16 requirerooms[2]; + RoomNum requirerooms[2]; requirerooms[0] = room; requirerooms[1] = -1; diff --git a/src/game/padhalllv.c b/src/game/padhalllv.c index 20f1f24b8..7d55e2be9 100644 --- a/src/game/padhalllv.c +++ b/src/game/padhalllv.c @@ -73,12 +73,12 @@ void navSetSeed(u32 upper, u32 lower) * The function will return NULL if there are no waypoints at all within the * position's room or its neighbours. */ -struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) +struct waypoint *waypointFindClosestToPos(struct coord *pos, RoomNum *rooms) { struct waypoint *closest = NULL; - s16 allrooms[30]; + RoomNum allrooms[30]; s32 candlen = 0; - s16 neighbours[10]; + RoomNum neighbours[10]; s32 i; s32 j; struct waypoint *candwaypoints[10]; @@ -152,7 +152,7 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) // Check which candidates have line of sight for (i = 0; i < candlen; i++) { struct pad pad; - s16 padrooms[8]; + RoomNum padrooms[8]; padUnpack(candwaypoints[i]->padnum, PADFIELD_POS | PADFIELD_ROOM, &pad); @@ -185,10 +185,10 @@ struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms) for (i = 0; i < candlen; i++) { if (checkmore[i] && (sp250[i].x != sp1d8[i].x || sp250[i].z != sp1d8[i].z)) { struct pad pad; - s16 padrooms[8]; + RoomNum padrooms[8]; struct coord sp98; struct coord tmppos; - s16 tmprooms[8]; + RoomNum tmprooms[8]; f32 mult; padUnpack(candwaypoints[i]->padnum, PADFIELD_POS | PADFIELD_ROOM, &pad); diff --git a/src/game/pak.c b/src/game/pak.c index a274012f5..c58b59de3 100644 --- a/src/game/pak.c +++ b/src/game/pak.c @@ -214,6 +214,16 @@ #define JOYARGS(line) line, "pak.c" #endif +#if VERSION >= VERSION_NTSC_1_0 +#define SETBANNER(banner) if (var80075d14) { menuSetBanner(banner, true); } +#else +#define SETBANNER(banner) menuSetBanner(banner, true) +#endif + +#define PAKFEATURE_MEMORY 0x01 +#define PAKFEATURE_RUMBLE 0x02 +#define PAKFEATURE_GAMEBOY 0x04 + const char g_N64FontCodeMap[] = "\0************** 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#'*+,-./:=?@"; const char var7f1b3ad4[] = "Pak %d -> Pak_UpdateAndGetPakNoteInfo - ERROR - ekPakErrorPakFatal\n"; const char var7f1b3b18[] = "Pak %d -> Pak_UpdateAndGetPakNoteInfo - ERROR - ekPakErrorNoPakPresent\n"; @@ -313,7 +323,7 @@ char g_PakNoteGameName[] = { char g_PakNoteExtName[] = {0, 0, 0, 0}; u32 var80075d0c = 0x00000000; -u8 var80075d10 = 0; +u8 g_PaksPlugged = 0; #if VERSION >= VERSION_NTSC_1_0 bool var80075d14 = true; @@ -363,15 +373,15 @@ u32 pakGenerateSerial(s8 device) } #endif -bool pakIsMemoryPak(s8 device) +bool mempakIsOkay(s8 device) { if (g_Paks[device].type == PAKTYPE_MEMORY) { - switch (g_Paks[device].unk010) { - case PAK010_14: - case PAK010_15: - case PAK010_19: - case PAK010_20: - case PAK010_22: + switch (g_Paks[device].state) { + case PAKSTATE_MEM_ENTER_DEVICEERROR: + case PAKSTATE_MEM_ENTER_CORRUPT: + case PAKSTATE_MEM_DEVICEERROR: + case PAKSTATE_MEM_CORRUPT: + case PAKSTATE_22: return false; } @@ -406,12 +416,12 @@ bool pakDeleteFile(s8 device, s32 fileid) return _pakDeleteFile(device, fileid); } -s32 pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name) +PakErr1 pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name) { return _pakDeleteGameNote(device, company_code, game_code, game_name, ext_name); } -s32 pak0f1168c4(s8 device, struct pakdata **arg1) +PakErr1 pak0f1168c4(s8 device, struct pakdata **arg1) { return pak0f116df0(device, arg1); } @@ -445,7 +455,7 @@ void pak0f11698c(s8 device) void pak0f116994(void) { if (g_Vars.stagenum == STAGE_BOOTPAKMENU) { - g_Vars.unk0004e4 = 0xf8; + g_Vars.pakstocheck = 0xf8; } } #endif @@ -457,68 +467,68 @@ void pak0f1169bc(u32 arg0, u32 arg1) } #endif -void pak0f1169c8(s8 device, s32 arg1) +void pak0f1169c8(s8 device, bool tick) { #if VERSION >= VERSION_NTSC_1_0 - u8 prevvalue = g_Vars.paksconnected; + u8 prevvalue = g_Vars.paksneededformenu; - g_Vars.paksconnected = 0x1f; + g_Vars.paksneededformenu = 0x1f; - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & (1 << device)) { - var80075d10 &= ~(1 << device); + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & (1 << device)) { + g_PaksPlugged &= ~(1 << device); - pak0f11ca30(); - pak0f11ca30(); + pakCheckPlugged(); + pakCheckPlugged(); - if (arg1) { - var8005eedc = false; + if (tick) { + g_JoyPfsPollMasterEnabled = false; - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); - var8005eedc = true; + g_JoyPfsPollMasterEnabled = true; } } - g_Vars.paksconnected = prevvalue; + g_Vars.paksneededformenu = prevvalue; #else - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & (1 << device)) { - var80075d10 &= ~(1 << device); + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & (1 << device)) { + g_PaksPlugged &= ~(1 << device); - pak0f11ca30(); + pakCheckPlugged(); - if (arg1) { - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); - pak0f11df94(device); + if (tick) { + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); + pakTickState(device); } } #endif } -bool pak0f116aec(s8 device) +bool mempakIsReady(s8 device) { - if (g_Paks[device].unk010 == PAK010_11 && g_Paks[device].type == PAKTYPE_MEMORY) { + if (g_Paks[device].state == PAKSTATE_READY && g_Paks[device].type == PAKTYPE_MEMORY) { return true; } return false; } -bool pak0f116b5c(s8 device) +bool mempakIsReadyOrFull(s8 device) { - if ((g_Paks[device].unk010 == PAK010_11 - || g_Paks[device].unk010 == PAK010_16 - || g_Paks[device].unk010 == PAK010_21) + if ((g_Paks[device].state == PAKSTATE_READY + || g_Paks[device].state == PAKSTATE_MEM_ENTER_FULL + || g_Paks[device].state == PAKSTATE_MEM_FULL) && g_Paks[device].type == PAKTYPE_MEMORY) { return true; } @@ -532,7 +542,7 @@ void pak0f116bdc(s8 device, u8 *arg1, u8 *arg2) *arg2 = g_Paks[device].unk2bb; } -void pak0f116c2c(s8 index) +void pakSetTemporarilyPlugged(s8 index) { joySetPfsTemporarilyPlugged(index); } @@ -559,45 +569,45 @@ ubool pak0f116d4c(s8 device) return g_Paks[device].unk2b8_05 && !g_Paks[device].isgbcamera; } -void pakSetUnk010(s8 device, s32 value) +void pakSetState(s8 device, s32 state) { - g_Paks[device].unk010 = value; + g_Paks[device].state = state; } -s32 pak0f116df0(s8 device, struct pakdata **pakdata) +PakErr1 pak0f116df0(s8 device, struct pakdata **pakdata) { *pakdata = NULL; - if (pak0f116b5c(device)) { + if (mempakIsReadyOrFull(device)) { if (pakQueryTotalUsage(device)) { *pakdata = &g_Paks[device].pakdata; - return 0; + return PAK_ERR1_OK; } - return 2; + return PAK_ERR1_NEWPAK; } - return 1; + return PAK_ERR1_NOPAK; } -s32 _pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name) +PakErr1 _pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name) { s32 result; - if (pak0f116b5c(device)) { + if (mempakIsReadyOrFull(device)) { joyDisableCyclicPolling(JOYARGS(738)); result = pakDeleteGameNote3(PFS(device), company_code, game_code, game_name, ext_name); joyEnableCyclicPolling(JOYARGS(740)); if (pakHandleResult(result, device, true, LINE_825)) { g_Paks[device].unk2b8_02 = 1; - return 0; + return PAK_ERR1_OK; } - return 2; + return PAK_ERR1_NEWPAK; } - return 1; + return PAK_ERR1_NOPAK; } #if VERSION >= VERSION_NTSC_1_0 @@ -657,9 +667,9 @@ s32 _pakDeleteFile(s8 device, s32 fileid) } #endif -s32 pakGetUnk264(s8 device) +s32 pakGetPlugCount(s8 device) { - return g_Paks[device].unk264; + return g_Paks[device].plugcount; } u32 pakGetMaxFileSize(s8 device) @@ -1078,7 +1088,7 @@ PakErr1 _pakReadWriteBlock(OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 le u32 newaddress; #if VERSION >= VERSION_NTSC_1_0 - joyCheckPfs(2); + joyPollPfs(2); #endif if (pfs) { @@ -1441,7 +1451,7 @@ bool pakResizeNote(s8 device, s32 numpages) void pak0f1184d8(s8 device, u32 *arg1, bool *arg2) { if (device != SAVEDEVICE_GAMEPAK) { - if (g_Paks[device].type != PAKTYPE_MEMORY || g_Paks[device].unk010 != PAK010_11) { + if (!(g_Paks[device].type == PAKTYPE_MEMORY && g_Paks[device].state == PAKSTATE_READY)) { pak0f1185e0(device, g_Paks[SAVEDEVICE_GAMEPAK].unk2bd & 0x0f, 1); device = SAVEDEVICE_GAMEPAK; } @@ -1574,7 +1584,7 @@ u32 pak0f118674(s8 device, u32 filetype, s32 *outfileid) return 4; } - g_Paks[device].unk010 = PAK010_16; + g_Paks[device].state = PAKSTATE_MEM_ENTER_FULL; g_Paks[device].type = PAKTYPE_MEMORY; return 4; @@ -1588,53 +1598,53 @@ void pak0f1189d0(void) void paksInit(void) { #if VERSION >= VERSION_NTSC_1_0 - u8 prevvalue = g_Vars.paksconnected; + u8 prevvalue = g_Vars.paksneededformenu; s8 i; - g_Vars.unk0004e4 = 0; + g_Vars.pakstocheck = 0; for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - pakInit(i); + pakSetDefaults(i); } for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { #if VERSION >= VERSION_JPN_FINAL - pak0f11a32c(i, 7, 2054, "pak/pak.c"); + pakSetFeatures(i, PAKFEATURE_MEMORY | PAKFEATURE_RUMBLE | PAKFEATURE_GAMEBOY, 2054, "pak/pak.c"); #elif VERSION >= VERSION_PAL_BETA - pak0f11a32c(i, 7, 2049, "pak.c"); + pakSetFeatures(i, PAKFEATURE_MEMORY | PAKFEATURE_RUMBLE | PAKFEATURE_GAMEBOY, 2049, "pak.c"); #elif VERSION >= VERSION_NTSC_FINAL - pak0f11a32c(i, 7, 2049, "pak/pak.c"); + pakSetFeatures(i, PAKFEATURE_MEMORY | PAKFEATURE_RUMBLE | PAKFEATURE_GAMEBOY, 2049, "pak/pak.c"); #else - pak0f11a32c(i, 7, 2016, "pak.c"); + pakSetFeatures(i, PAKFEATURE_MEMORY | PAKFEATURE_RUMBLE | PAKFEATURE_GAMEBOY, 2016, "pak.c"); #endif } pakProbeEeprom(); joyRecordPfsState(0x10); - g_Vars.paksconnected = 0x10; + g_Vars.paksneededformenu = 0x10; - pak0f1169c8(SAVEDEVICE_GAMEPAK, 1); + pak0f1169c8(SAVEDEVICE_GAMEPAK, true); bossfileLoadFull(); gamefileLoadDefaults(&g_GameFile); gamefileApplyOptions(&g_GameFile); g_GameFileGuid.deviceserial = 0; - g_Vars.unk0004e4 = 0xf5; - g_Vars.paksconnected = prevvalue; + g_Vars.pakstocheck = 0xf5; + g_Vars.paksneededformenu = prevvalue; #else s8 i; s32 j; for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - pakInit(i); + pakSetDefaults(i); } - g_Vars.paksconnected2 = 0x1f; + g_Vars.paksneededforgame = 0x1f; for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - pak0f11a32c(i, 7, 1929, "pak.c"); + pakSetFeatures(i, PAKFEATURE_MEMORY | PAKFEATURE_RUMBLE | PAKFEATURE_GAMEBOY, 1929, "pak.c"); } pakProbeEeprom(); @@ -1665,7 +1675,7 @@ void paksInit(void) gamefileApplyOptions(&g_GameFile); g_GameFileGuid.deviceserial = 0; - g_Vars.paksconnected2 = 0; + g_Vars.paksneededforgame = 0; #endif } @@ -1923,18 +1933,18 @@ u32 pak0f119298(s8 device) return 1; } - switch (g_Paks[device].unk010) { - case PAK010_11: + switch (g_Paks[device].state) { + case PAKSTATE_READY: return 0; - case PAK010_17: + case PAKSTATE_17: return 14; - case PAK010_18: + case PAKSTATE_18: return 4; - case PAK010_03: - case PAK010_04: - case PAK010_05: - case PAK010_06: - case PAK010_07: + case PAKSTATE_MEM_DISPATCH: + case PAKSTATE_MEM_PRE_PREPARE: + case PAKSTATE_MEM_PREPARE: + case PAKSTATE_MEM_POST_PREPARE: + case PAKSTATE_07: return 13; } @@ -2750,17 +2760,17 @@ void paksReset(void) // empty } -s32 pakGetUnk014(s8 device) +s32 pakGetFeatures(s8 device) { - return g_Paks[device].unk014; + return g_Paks[device].features; } -void pak0f11a32c(s8 device, u8 arg1, u32 line, char *file) +void pakSetFeatures(s8 device, u8 features, u32 line, char *file) { - if (g_Paks[device].unk014 == 0) { - g_Paks[device].unk014 = arg1; + if (g_Paks[device].features == 0) { + g_Paks[device].features = features; - if ((g_Paks[device].unk014 & 1) && g_Paks[device].headercache == NULL) { + if ((g_Paks[device].features & PAKFEATURE_MEMORY) && g_Paks[device].headercache == NULL) { g_Paks[device].headercachecount = 0; g_Paks[device].headercache = mempAlloc(align32(sizeof(struct pakheadercache) * MAX_HEADERCACHE_ENTRIES), MEMPOOL_PERMANENT); @@ -2771,15 +2781,13 @@ void pak0f11a32c(s8 device, u8 arg1, u32 line, char *file) } } -void pak0f11a3dc(s8 device, u32 arg1, u32 arg2) +void pakRemoveAllFeatures(s8 device, u32 arg1, u32 arg2) { - if (g_Paks[device].unk014) { - g_Paks[device].unk014 = 0; + if (g_Paks[device].features) { + g_Paks[device].features = 0; } - if (g_Paks[device].unk014) { - // empty - } + if (g_Paks[device].features); } const char var7f1b4294[] = "Pak %d - Pak_StartOne called from line %d in %s -> Flags = %0x\n"; @@ -2814,25 +2822,25 @@ const char var7f1b43f8[] = "Pak -> Pak_MakeOne - Id=%d is finished\n"; const char var7f1b43f8[] = "Pak -> Pak_MakeOne - Id=%d is finished"; #endif -void pakInit(s8 device) +void pakSetDefaults(s8 device) { g_Paks[device].unk274 = 3; - g_Paks[device].unk014 = 0; + g_Paks[device].features = 0; g_Paks[device].type = PAKTYPE_NONE; - g_Paks[device].unk008 = 1; + g_Paks[device].unk008 = PAK008_01; g_Paks[device].rumblestate = RUMBLESTATE_1; - g_Paks[device].unk00c = 3; - g_Paks[device].unk010 = PAK010_00; + g_Paks[device].unk00c = PAK00C_03; + g_Paks[device].state = PAKSTATE_NOPAK; g_Paks[device].pdnoteindex = -1; g_Paks[device].unk2b8_01 = 0; g_Paks[device].unk2b8_05 = 0; g_Paks[device].isgbcamera = 0; g_Paks[device].unk2b8_02 = 0; g_Paks[device].unk2bd = 128; - g_Paks[device].unk264 = 0; + g_Paks[device].plugcount = 0; g_Paks[device].unk2b8_06 = 0; #if VERSION >= VERSION_NTSC_1_0 - g_Paks[device].unk2b8_07 = 0; + g_Paks[device].showdatalost = false; #endif g_Paks[device].headercache = NULL; g_Paks[device].unk2c4 = NULL; @@ -2889,7 +2897,7 @@ bool pakQueryTotalUsage(s8 device) return false; } - for (i = 0; i < 16; i++) { + for (i = 0; i < ARRAYCOUNT(noteerrors); i++) { noteerrors[i] = pakQueryNoteState(PFS(device), i, &pak->pakdata.notes[i]); if (noteerrors[i] != PAK_ERR1_OK) { @@ -2899,7 +2907,7 @@ bool pakQueryTotalUsage(s8 device) } } - for (i = 0, pak->pakdata.pagesused = 0; i < 16; i++) { + for (i = 0, pak->pakdata.pagesused = 0; i < ARRAYCOUNT(noteerrors); i++) { if (noteerrors[i] == PAK_ERR1_OK) { pak->pakdata.pagesused += (pak->pakdata.notes[i].file_size + 255) >> 8; } @@ -2954,7 +2962,7 @@ bool pak0f1147b8nb(s8 device) return false; } - g_Paks[device].unk010 = 3; + g_Paks[device].state = PAKSTATE_MEM_DISPATCH; if (device == SAVEDEVICE_GAMEPAK) { pakExecuteDebugOperations(); @@ -3008,7 +3016,7 @@ bool mempakPrepare(s8 device) pakQueryTotalUsage(device); #if VERSION >= VERSION_NTSC_1_0 - if (g_Paks[device].unk010 == PAK010_01) { + if (g_Paks[device].state == PAKSTATE_UNPLUGGING) { return false; } #endif @@ -3045,11 +3053,11 @@ bool mempakPrepare(s8 device) pakQueryPdSize(device); #if VERSION >= VERSION_NTSC_1_0 - g_Paks[device].unk2b8_07 = false; + g_Paks[device].showdatalost = false; #endif g_Paks[device].headercachecount = 0; - g_Paks[device].unk010 = PAK010_11; + g_Paks[device].state = PAKSTATE_READY; if (device && device && device); @@ -3077,7 +3085,7 @@ bool mempakPrepare(s8 device) } if (device != SAVEDEVICE_GAMEPAK) { - g_Paks[device].unk2b8_07 = true; + g_Paks[device].showdatalost = true; } } } @@ -3089,18 +3097,18 @@ bool mempakPrepare(s8 device) g_Paks[device].maxfileid = maxfileid; if (pakGetFileIdsByType(device, PAKFILETYPE_TERMINATOR, fileids) == 0 && pakCreateInitialFiles(device)) { - g_Paks[device].unk010 = (device == SAVEDEVICE_GAMEPAK) ? PAK010_11 : PAK010_06; + g_Paks[device].state = (device == SAVEDEVICE_GAMEPAK) ? PAKSTATE_READY : PAKSTATE_MEM_POST_PREPARE; - func0f110d90(device); + filelistInvalidatePak(device); return true; } } } - g_Paks[device].unk010 = PAK010_22; + g_Paks[device].state = PAKSTATE_22; - func0f110d90(device); + filelistInvalidatePak(device); return false; #else @@ -3121,7 +3129,7 @@ bool mempakPrepare(s8 device) pakGetFileIdsByType(device, PAKFILETYPE_TERMINATOR, fileids); pakCreateInitialFiles(device); - g_Paks[device].unk010 = (device == SAVEDEVICE_GAMEPAK) ? PAK010_11 : PAK010_06; + g_Paks[device].state = (device == SAVEDEVICE_GAMEPAK) ? PAKSTATE_READY : PAKSTATE_MEM_POST_PREPARE; return true; #endif @@ -3145,7 +3153,7 @@ bool pakProbe(s8 device) ret = pakInitPak(&g_PiMesgQueue, PFS(device), device, NULL); if (pakHandleResult(ret, device, true, LINE_3829)) { - g_Paks[device].unk010 = PAK010_03; + g_Paks[device].state = PAKSTATE_MEM_DISPATCH; if (device == SAVEDEVICE_GAMEPAK) { pakExecuteDebugOperations(); @@ -3171,9 +3179,9 @@ bool pakProbe(s8 device) if (pakHandleResult(ret, device, false, LINE_3865)) { g_Paks[device].type = PAKTYPE_RUMBLE; - g_Paks[device].unk010 = PAK010_11; + g_Paks[device].state = PAKSTATE_READY; g_Paks[device].rumblestate = RUMBLESTATE_1; - g_Paks[device].unk264++; + g_Paks[device].plugcount++; plugged = true; done = true; @@ -3189,12 +3197,12 @@ bool pakProbe(s8 device) if (pakHandleResult(ret, device, false, LINE_3889)) { if (IS4MB()) { g_Paks[device].type = PAKTYPE_NONE; - g_Paks[device].unk010 = PAK010_22; + g_Paks[device].state = PAKSTATE_22; } else { g_Paks[device].type = PAKTYPE_GAMEBOY; - g_Paks[device].unk010 = PAK010_08; + g_Paks[device].state = PAKSTATE_GB_PRE_PREPARE; g_Paks[device].unk2b8_01 = false; - g_Paks[device].unk264++; + g_Paks[device].plugcount++; } plugged = true; @@ -3254,21 +3262,21 @@ void pak0f114dd4nb(s8 device) pak->pdnoteindex = -1; pak->unk2b8_01 = false; pak->type = PAKTYPE_NONE; - pak->unk008 = 1; + pak->unk008 = PAK008_01; pak->rumblestate = RUMBLESTATE_1; - pak->unk00c = 3; + pak->unk00c = PAK00C_03; if (pakProbe(device)) { - if (pak->unk014 & 1) { + if (pak->features & PAKFEATURE_MEMORY) { if (pak0f1147b8nb(device)) { - pak->unk264++; + pak->plugcount++; return; } if (1); } - if (pak->unk014 & 2) { + if (pak->features & PAKFEATURE_RUMBLE) { if (device != SAVEDEVICE_GAMEPAK) { joyDisableCyclicPolling(3514, "pak.c"); ret = osMotorProbe(&g_PiMesgQueue, PFS(device), device); @@ -3276,8 +3284,8 @@ void pak0f114dd4nb(s8 device) if (pakHandleResult(ret, device, 1, 3518)) { pak->type = PAKTYPE_RUMBLE; - pak->unk010 = PAK010_11; - pak->unk264++; + pak->state = PAKSTATE_READY; + pak->plugcount++; return; } } else { @@ -3285,10 +3293,10 @@ void pak0f114dd4nb(s8 device) } } - if (pak->unk014 & 4) { - pak->unk010 = PAK010_08; + if (pak->features & PAKFEATURE_GAMEBOY) { + pak->state = PAKSTATE_GB_PRE_PREPARE; pak->unk2b8_01 = false; - pak->unk264++; + pak->plugcount++; } } } @@ -3445,7 +3453,7 @@ s32 pakCreateFilesystem(s8 device) s32 pak0f11b6ec(s8 device) { - if (g_Paks[device].unk010 == PAK010_11 && g_Paks[device].type == PAKTYPE_MEMORY) { + if (g_Paks[device].state == PAKSTATE_READY && g_Paks[device].type == PAKTYPE_MEMORY) { return 3; } @@ -4265,9 +4273,9 @@ bool pakRepair(s8 device) { s32 result; - switch (g_Paks[device].unk010) { - case PAK010_14: - case PAK010_19: + switch (g_Paks[device].state) { + case PAKSTATE_MEM_ENTER_DEVICEERROR: + case PAKSTATE_MEM_DEVICEERROR: break; default: joyDisableCyclicPolling(JOYARGS(4425)); @@ -4275,20 +4283,20 @@ bool pakRepair(s8 device) joyEnableCyclicPolling(JOYARGS(4427)); if (result == PAK_ERR1_OK) { - g_Paks[device].unk010 = PAK010_02; + g_Paks[device].state = PAKSTATE_PROBE; return true; } pakHandleResult(result, device, false, LINE_4801); #if VERSION >= VERSION_NTSC_1_0 - g_Paks[device].unk010 = PAK010_22; + g_Paks[device].state = PAKSTATE_22; #endif break; } #if VERSION < VERSION_NTSC_1_0 - g_Paks[device].unk010 = PAK010_22; + g_Paks[device].state = PAKSTATE_22; #endif return false; @@ -4314,22 +4322,22 @@ bool pakHandleResult(s32 err1, s8 device, bool arg2, u32 line) #if VERSION >= VERSION_NTSC_1_0 case PAK_ERR1_NOPAK: g_Paks[device].type = PAKTYPE_MEMORY; - g_Paks[device].unk010 = PAK010_01; + g_Paks[device].state = PAKSTATE_UNPLUGGING; break; #endif case PAK_ERR1_DEVICE: g_Paks[device].type = PAKTYPE_MEMORY; - g_Paks[device].unk010 = PAK010_14; + g_Paks[device].state = PAKSTATE_MEM_ENTER_DEVICEERROR; break; case PAK_ERR1_INCONSISTENT: case PAK_ERR1_IDFATAL: g_Paks[device].type = PAKTYPE_MEMORY; - g_Paks[device].unk010 = PAK010_15; + g_Paks[device].state = PAKSTATE_MEM_ENTER_CORRUPT; break; case PAK_ERR1_DATAFULL: case PAK_ERR1_DIRFULL: g_Paks[device].type = PAKTYPE_MEMORY; - g_Paks[device].unk010 = PAK010_16; + g_Paks[device].state = PAKSTATE_MEM_ENTER_FULL; break; } } @@ -4364,40 +4372,40 @@ void paksTick(void) { s32 i; - if (g_Vars.unk0004e4) { + if (g_Vars.pakstocheck) { g_MpPlayerNum = 0; menuSetBanner(MENUBANNER_CHECKINGPAK, true); var80075d14 = false; - if (g_Vars.unk0004e4 & 0x0f) { - joy00013974(0); + if (g_Vars.pakstocheck & 0x0f) { + joySetPfsPollEnabled(0); // Waiting for some timer - if ((g_Vars.unk0004e4 & 0x0f) > 9) { + if ((g_Vars.pakstocheck & 0x0f) >= 10) { if ((g_Vars.lvframenum % 7) == 0) { - g_Vars.unk0004e4--; + g_Vars.pakstocheck--; } } else { - g_Vars.unk0004e4--; + g_Vars.pakstocheck--; } } else { - joyCheckPfs(2); + joyPollPfs(2); for (i = 0; i < 4; i++) { - if (g_Vars.unk0004e4 & (1 << (i + 4))) { + if (g_Vars.pakstocheck & (1 << (i + 4))) { pak0f1169c8(i, true); - g_Vars.unk0004e4 &= ~(1 << (i + 4)); - } else if (g_Vars.unk0004e4 & (1 << (i + 8))) { + g_Vars.pakstocheck &= ~(1 << (i + 4)); + } else if (g_Vars.pakstocheck & (1 << (i + 8))) { pak0f1169c8(i, false); - g_Vars.unk0004e4 &= ~(1 << (i + 8)); + g_Vars.pakstocheck &= ~(1 << (i + 8)); } } - if (!joy00013980()) { - joy00013974(1); - joy000139c8(); + if (!joyIsPfsPollEnabled()) { + joySetPfsPollEnabled(true); + joySetDefaultPfsPollInterval(); } menuSetBanner(-1, true); @@ -4414,21 +4422,21 @@ void pak0f11c6d0(void) s32 i; for (i = 0; i < MAX_PLAYERS; i++) { - switch (g_Paks[i].unk010) { - case PAK010_02: - case PAK010_03: - case PAK010_04: - case PAK010_05: - case PAK010_06: - g_Paks[i].unk010 = PAK010_01; - var80075d10 &= ~(1 << i); + switch (g_Paks[i].state) { + case PAKSTATE_PROBE: + case PAKSTATE_MEM_DISPATCH: + case PAKSTATE_MEM_PRE_PREPARE: + case PAKSTATE_MEM_PREPARE: + case PAKSTATE_MEM_POST_PREPARE: + g_Paks[i].state = PAKSTATE_UNPLUGGING; + g_PaksPlugged &= ~(1 << i); g_MpPlayerNum = i; menuSetBanner(-1, true); break; } } - var8005eedc = true; + g_JoyPfsPollMasterEnabled = true; } #endif @@ -4436,7 +4444,7 @@ void pakExecuteDebugOperations(void) { #if VERSION >= VERSION_NTSC_1_0 static u32 g_PakDebugDumpEeprom = 0; - s32 pass = false; + bool disablepolling = false; s8 i; mainOverrideVariable("forcescrub", &g_PakDebugForceScrub); @@ -4482,30 +4490,30 @@ void pakExecuteDebugOperations(void) g_PakDebugForceScrub = false; } - pak0f11ca30(); + pakCheckPlugged(); for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - if (g_Paks[i].unk014) { - pak0f11df94(i); + if (g_Paks[i].features) { + pakTickState(i); } } for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - switch (g_Paks[i].unk010) { - case PAK010_02: - case PAK010_03: - case PAK010_04: - case PAK010_05: - case PAK010_06: - pass = true; + switch (g_Paks[i].state) { + case PAKSTATE_PROBE: + case PAKSTATE_MEM_DISPATCH: + case PAKSTATE_MEM_PRE_PREPARE: + case PAKSTATE_MEM_PREPARE: + case PAKSTATE_MEM_POST_PREPARE: + disablepolling = true; break; } } - if (pass) { - var8005eedc = false; + if (disablepolling) { + g_JoyPfsPollMasterEnabled = false; } else { - var8005eedc = true; + g_JoyPfsPollMasterEnabled = true; } #else static u32 g_PakDebugDumpEeprom = 0; @@ -4547,12 +4555,12 @@ void pakExecuteDebugOperations(void) g_PakDebugForceScrub = false; } - pak0f11ca30(); + pakCheckPlugged(); pakDumpPak(); for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - if (g_Paks[i].unk014) { - pak0f11df94(i); + if (g_Paks[i].features) { + pakTickState(i); } } #endif @@ -4602,62 +4610,66 @@ const char var7f1ae9acnb[] = "Pak -> Connector Check Failed"; const char var7f1ae9ccnb[] = "Pak -> osGbpakReadId - Failed"; #endif -void pak0f11ca30(void) +void pakCheckPlugged(void) { #if VERSION >= VERSION_NTSC_1_0 if (g_Vars.tickmode != TICKMODE_CUTSCENE || g_MenuData.count > 0) { - u8 oldvalue = var80075d10; - u8 newvalue = var80075d10; - u8 thing = 0xff; + u8 oldplugged = g_PaksPlugged; + u8 newplugged = g_PaksPlugged; + u8 paksconnected = 0xff; s32 i; - if ((g_Vars.unk0004e4 & 0xf) == 0) { + if ((g_Vars.pakstocheck & 0xf) == 0) { for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & (1 << i)) { - if (thing == 0xff) { - thing = joyShiftPfsStates(); + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & (1 << i)) { + if (paksconnected == 0xff) { + paksconnected = joyShiftPfsStates(); } - if (((thing & (1 << i)) != (oldvalue & (1 << i)))) { - if ((thing & (1 << i))) { - g_Paks[i].unk010 = PAK010_02; - newvalue |= (1 << i); + if (((paksconnected & (1 << i)) != (oldplugged & (1 << i)))) { + if ((paksconnected & (1 << i))) { + // pak connected + g_Paks[i].state = PAKSTATE_PROBE; + newplugged |= (1 << i); } else { - g_Paks[i].unk010 = PAK010_01; - newvalue &= ~(1 << i); - func0f110d90(i); + // pak unplugged + g_Paks[i].state = PAKSTATE_UNPLUGGING; + newplugged &= ~(1 << i); + filelistInvalidatePak(i); } } } } - var80075d10 = newvalue; + g_PaksPlugged = newplugged; } } #else if (g_Vars.tickmode != TICKMODE_CUTSCENE) { - u32 thing = joy00013980(); - u8 oldvalue = var80075d10; - u8 newvalue = var80075d10; + u32 paksconnected = joyShiftPfsStates(); + u8 oldplugged = g_PaksPlugged; + u8 newplugged = g_PaksPlugged; s32 i; for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { u32 thisbit = 1 << i; - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & thisbit) { - if ((thing & thisbit) != (oldvalue & thisbit)) { - if (thing & thisbit) { - g_Paks[i].unk010 = PAK010_02; - newvalue |= thisbit; + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & thisbit) { + if ((paksconnected & thisbit) != (oldplugged & thisbit)) { + if (paksconnected & thisbit) { + // pak connected + g_Paks[i].state = PAKSTATE_PROBE; + newplugged |= thisbit; } else { - g_Paks[i].unk010 = PAK010_01; - newvalue &= ~thisbit; + // pak unplugged + g_Paks[i].state = PAKSTATE_UNPLUGGING; + newplugged &= ~thisbit; } } } } - var80075d10 = newvalue; + g_PaksPlugged = newplugged; } #endif } @@ -4913,7 +4925,7 @@ bool gbpak0f11cef8(s8 device) } } - pak->unk008 = 1; + pak->unk008 = PAK008_01; return true; } @@ -5054,7 +5066,7 @@ u32 var80075d5c = 0x00000000; s32 pak0f11d3f8(s8 device) { if (g_Paks[device].type == PAKTYPE_GAMEBOY - && (g_Paks[device].unk010 == PAK010_11 || g_Paks[device].unk010 == PAK010_12 || g_Paks[device].unk010 == PAK010_13)) { + && (g_Paks[device].state == PAKSTATE_READY || g_Paks[device].state == PAKSTATE_12 || g_Paks[device].state == PAKSTATE_13)) { return true; } @@ -5063,8 +5075,8 @@ s32 pak0f11d3f8(s8 device) bool pak0f11d478(s8 device) { - if (g_Paks[device].unk008 == 11) { - g_Paks[device].unk008 = 1; + if (g_Paks[device].unk008 == PAK008_11) { + g_Paks[device].unk008 = PAK008_01; return true; } @@ -5073,8 +5085,8 @@ bool pak0f11d478(s8 device) bool pak0f11d4dc(s8 device) { - if (g_Paks[device].unk008 == 1 || g_Paks[device].unk008 == 0) { - g_Paks[device].unk008 = 2; + if (g_Paks[device].unk008 == PAK008_01 || g_Paks[device].unk008 == PAK008_00) { + g_Paks[device].unk008 = PAK008_02; g_Paks[device].unk270 = 0; } @@ -5083,8 +5095,8 @@ bool pak0f11d4dc(s8 device) s32 pak0f11d540(s8 device, s32 arg1) { - if (g_Paks[device].unk008 == 1 || g_Paks[device].unk008 == 0) { - g_Paks[device].unk008 = 4; + if (g_Paks[device].unk008 == PAK008_01 || g_Paks[device].unk008 == PAK008_00) { + g_Paks[device].unk008 = PAK008_04; g_Paks[device].unk270 = arg1; return true; } @@ -5094,8 +5106,8 @@ s32 pak0f11d540(s8 device, s32 arg1) s32 pak0f11d5b0(s8 device) { - if (g_Paks[device].unk008 == 1 || g_Paks[device].unk008 == 0) { - g_Paks[device].unk008 = 4; + if (g_Paks[device].unk008 == PAK008_01 || g_Paks[device].unk008 == PAK008_00) { + g_Paks[device].unk008 = PAK008_04; g_Paks[device].unk270 = 1; return true; } @@ -5105,8 +5117,8 @@ s32 pak0f11d5b0(s8 device) void pak0f11d620(s8 device) { - if (g_Paks[device].unk010 == PAK010_11) { - g_Paks[device].unk010 = PAK010_12; + if (g_Paks[device].state == PAKSTATE_READY) { + g_Paks[device].state = PAKSTATE_12; } } @@ -5140,20 +5152,20 @@ bool gbpak0f11d680(s8 device, bool arg1) u16 size; switch (g_Paks[device].unk00c) { - case 0: + case PAK00C_00: offset = 0x1a0; size = 0x40; arg1 = true; break; - case 1: + case PAK00C_01: offset = g_Paks[device].unk278 * 0x100 + 0x660; size = 0x40; break; - case 2: + case PAK00C_02: offset = g_Paks[device].unk278 * 0x100 + 0x440; size = 0x80; break; - case 3: + case PAK00C_03: offset = g_Paks[device].unk278 * var80075ccc; size = var80075ccc; break; @@ -5172,22 +5184,22 @@ bool gbpak0f11d680(s8 device, bool arg1) bool pak0f11d7c4(s8 device) { switch (g_Paks[device].unk00c) { - case 0: + case PAK00C_00: if (g_Paks[device].unk278 == 1) { return true; } break; - case 1: + case PAK00C_01: if (g_Paks[device].unk278 == 4) { return true; } break; - case 2: + case PAK00C_02: if (g_Paks[device].unk278 == 8) { return true; } break; - case 3: + case PAK00C_03: if (g_Paks[device].unk278 == 0x1000 / var80075ccc) { return true; } @@ -5255,7 +5267,7 @@ void pak0f11d9c4(s8 device, u8 *arg1, u8 *arg2, u32 arg3) u32 j; switch (g_Paks[device].unk00c) { - case 0: + case PAK00C_00: if (arg2 != NULL) { u8 *src = &g_Paks[device].unk2c4[0x1b2]; s32 i; @@ -5265,7 +5277,7 @@ void pak0f11d9c4(s8 device, u8 *arg1, u8 *arg2, u32 arg3) } } break; - case 1: + case PAK00C_01: if (arg1 != NULL) { pakConvertFromGbcImage(g_Paks[device].unk2c4, sp60); @@ -5276,7 +5288,7 @@ void pak0f11d9c4(s8 device, u8 *arg1, u8 *arg2, u32 arg3) } } break; - case 2: + case PAK00C_02: if (arg1 != NULL) { pakConvertFromGbcImage(g_Paks[device].unk2c4, sp60); @@ -5287,7 +5299,7 @@ void pak0f11d9c4(s8 device, u8 *arg1, u8 *arg2, u32 arg3) } } break; - case 3: + case PAK00C_03: if (arg1 != NULL) { pakConvertFromGbcImage(g_Paks[device].unk2c4, arg1); } @@ -5327,7 +5339,7 @@ void pak0f11d9c4(s8 device, u8 *arg1, u8 *arg2, u32 arg3) #if VERSION >= VERSION_NTSC_1_0 void pakRumble(s32 device, f32 numsecs, s32 onduration, s32 offduration) { - if (g_Paks[device].unk010 == PAK010_11 + if (g_Paks[device].state == PAKSTATE_READY && g_Paks[device].type == PAKTYPE_RUMBLE && g_Paks[device].rumblestate != RUMBLESTATE_DISABLED_STOPPING && g_Paks[device].rumblestate != RUMBLESTATE_DISABLED_STOPPED @@ -5344,7 +5356,7 @@ void pakRumble(s8 device, f32 numsecs, s32 onduration, s32 offduration) { u8 index = g_Vars.playertojoymap[device]; - if (g_Paks[index].unk010 == PAK010_11 + if (g_Paks[index].state == PAKSTATE_READY && g_Paks[index].type == PAKTYPE_RUMBLE && g_Paks[index].rumblestate != RUMBLESTATE_DISABLED_STOPPING && g_Paks[index].rumblestate != RUMBLESTATE_DISABLED_STOPPED @@ -5469,96 +5481,78 @@ void pakDumpPak(void) void pak0f117f94nb(s8 device); -void pak0f11df94(s8 device) +void pakTickState(s8 device) { #if VERSION == VERSION_NTSC_1_0 - if (g_Paks[device].unk2b8_07) { - if (var80075d14) { - menuSetBanner(-1, true); - } + if (g_Paks[device].showdatalost) { + SETBANNER(-1); - if (func0f0fd1f4(device, 4)) { - func0f0fd320(device, 4); - g_Paks[device].unk2b8_07 = false; + if (menuIsReadyForPakError(device, PAKERRORDIALOG_DATALOST)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_DATALOST); + g_Paks[device].showdatalost = false; } } #endif - switch (g_Paks[device].unk010) { - case PAK010_00: + switch (g_Paks[device].state) { + case PAKSTATE_NOPAK: break; - case PAK010_01: - g_Paks[device].unk010 = PAK010_00; - g_Paks[device].unk264++; + case PAKSTATE_UNPLUGGING: + g_Paks[device].state = PAKSTATE_NOPAK; + g_Paks[device].plugcount++; #if VERSION >= VERSION_NTSC_FINAL - g_Paks[device].unk2b8_07 = false; + g_Paks[device].showdatalost = false; #endif g_Paks[device].type = PAKTYPE_NONE; -#if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } -#else - menuSetBanner(-1, true); -#endif - + SETBANNER(-1); func0f14aed0(device); break; - case PAK010_02: + case PAKSTATE_PROBE: #if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } - + SETBANNER(-1); pakProbe(device); #else pak0f114dd4nb(device); #endif func0f14aed0(device); break; - case PAK010_03: + case PAKSTATE_MEM_DISPATCH: #if VERSION >= VERSION_NTSC_1_0 - if (g_Vars.paksconnected & (1 << device)) + if (g_Vars.paksneededformenu & (1 << device)) #else - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & (1 << device)) + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & (1 << device)) #endif { if (device == SAVEDEVICE_GAMEPAK) { - g_Paks[device].unk010 = PAK010_05; + g_Paks[device].state = PAKSTATE_MEM_PREPARE; } else { - g_Paks[device].unk010 = PAK010_04; + g_Paks[device].state = PAKSTATE_MEM_PRE_PREPARE; } } else { - g_Paks[device].unk010 = PAK010_07; + g_Paks[device].state = PAKSTATE_07; } break; - case PAK010_07: + case PAKSTATE_07: #if VERSION >= VERSION_NTSC_1_0 - if (g_Vars.paksconnected & (1 << device)) + if (g_Vars.paksneededformenu & (1 << device)) #else - if ((g_Vars.paksconnected2 | g_Vars.paksconnected) & (1 << device)) + if ((g_Vars.paksneededforgame | g_Vars.paksneededformenu) & (1 << device)) #endif { - g_Paks[device].unk010 = PAK010_02; + g_Paks[device].state = PAKSTATE_PROBE; } break; default: break; - case PAK010_04: + case PAKSTATE_MEM_PRE_PREPARE: g_MpPlayerNum = device; -#if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(MENUBANNER_CHECKINGPAK, true); - } -#else - menuSetBanner(MENUBANNER_CHECKINGPAK, true); -#endif + SETBANNER(MENUBANNER_CHECKINGPAK); - g_Paks[device].unk010 = PAK010_05; + g_Paks[device].state = PAKSTATE_MEM_PREPARE; break; - case PAK010_05: + case PAKSTATE_MEM_PREPARE: #if VERSION >= VERSION_NTSC_1_0 joyDisableCyclicPolling(); mempakPrepare(device); @@ -5567,26 +5561,19 @@ void pak0f11df94(s8 device) mempakPrepare(device); #endif break; - case PAK010_06: -#if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } -#else - menuSetBanner(-1, true); -#endif - - g_Paks[device].unk010 = PAK010_11; + case PAKSTATE_MEM_POST_PREPARE: + SETBANNER(-1); + g_Paks[device].state = PAKSTATE_READY; break; - case PAK010_08: + case PAKSTATE_GB_PRE_PREPARE: if (func0f14aea0(device)) { - g_Paks[device].unk010 = PAK010_09; + g_Paks[device].state = PAKSTATE_GB_PREPARE; } break; - case PAK010_09: + case PAKSTATE_GB_PREPARE: #if VERSION >= VERSION_NTSC_1_0 - g_Paks[device].unk008 = 0; - g_Paks[device].unk010 = PAK010_10; + g_Paks[device].unk008 = PAK008_00; + g_Paks[device].state = PAKSTATE_GB_POST_PREPARE1; #else { s32 ret; @@ -5597,151 +5584,113 @@ void pak0f11df94(s8 device) if (ret == 0) { g_Paks[device].type = PAKTYPE_GAMEBOY; - g_Paks[device].unk008 = 0; - g_Paks[device].unk010 = PAK010_10; + g_Paks[device].unk008 = PAK008_00; + g_Paks[device].state = PAKSTATE_GB_POST_PREPARE1; } else { gbpakHandleError(ret); g_Paks[device].type = PAKTYPE_GAMEBOY_ERROR; - g_Paks[device].unk010 = PAK010_00; + g_Paks[device].state = PAKSTATE_NOPAK; } } #endif break; - case PAK010_10: - g_Paks[device].unk010 = PAK010_24; + case PAKSTATE_GB_POST_PREPARE1: + g_Paks[device].state = PAKSTATE_GB_POST_PREPARE2; break; - case PAK010_24: - g_Paks[device].unk010 = PAK010_25; + case PAKSTATE_GB_POST_PREPARE2: + g_Paks[device].state = PAKSTATE_GB_POST_PREPARE3; break; - case PAK010_25: - g_Paks[device].unk010 = PAK010_11; + case PAKSTATE_GB_POST_PREPARE3: + g_Paks[device].state = PAKSTATE_READY; break; - case PAK010_12: + case PAKSTATE_12: #if VERSION >= VERSION_NTSC_1_0 - g_Paks[device].unk010 = PAK010_11; + g_Paks[device].state = PAKSTATE_READY; #else if (g_Paks[device].type == PAKTYPE_GAMEBOY) { joyDisableCyclicPolling(5960, "pak.c"); pak0f117f94nb(device); joyEnableCyclicPolling(5962, "pak.c"); - g_Paks[device].unk010 = PAK010_13; + g_Paks[device].state = PAKSTATE_13; } else { - g_Paks[device].unk010 = PAK010_11; + g_Paks[device].state = PAKSTATE_READY; } #endif break; - case PAK010_13: + case PAKSTATE_13: break; - case PAK010_15: + case PAKSTATE_MEM_ENTER_CORRUPT: + SETBANNER(-1); + #if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } - - if ((g_Vars.paksconnected & (1 << device)) && func0f0fd1f4(device, 1)) { - func0f0fd320(device, 1); - g_Paks[device].unk010 = PAK010_20; - } else { - // empty - } -#else - menuSetBanner(-1, true); - - if (func0f0fd1f4(device, 1)) { - func0f0fd320(device, 1); - g_Paks[device].unk010 = PAK010_20; - } else { - // empty - } + if ((g_Vars.paksneededformenu & (1 << device))) #endif + { + if (menuIsReadyForPakError(device, PAKERRORDIALOG_CORRUPT)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_CORRUPT); + g_Paks[device].state = PAKSTATE_MEM_CORRUPT; + } else { + // empty + } + } break; #if VERSION >= VERSION_NTSC_1_0 - case PAK010_26: - if (func0f0fd1f4(device, 3)) { - func0f0fd320(device, 3); - g_Paks[device].unk010 = PAK010_27; + case PAKSTATE_GB_OPEN_UNREADABLE: + if (menuIsReadyForPakError(device, PAKERRORDIALOG_GB_UNREADABLE)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_GB_UNREADABLE); + g_Paks[device].state = PAKSTATE_GB_IDLE_UNREADABLE; } break; - case PAK010_27: - g_Paks[device].unk010 = PAK010_11; + case PAKSTATE_GB_IDLE_UNREADABLE: + g_Paks[device].state = PAKSTATE_READY; break; #endif - case PAK010_14: -#if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } + case PAKSTATE_MEM_ENTER_DEVICEERROR: + SETBANNER(-1); - if (((g_Vars.paksconnected & (1 << device))) && func0f0fd1f4(device, 2)) { - func0f0fd320(device, 2); - g_Paks[device].unk010 = PAK010_19; - } else { - // empty - } -#else - menuSetBanner(-1, true); - - if (func0f0fd1f4(device, 2)) { - func0f0fd320(device, 2); - g_Paks[device].unk010 = PAK010_19; - } else { - // empty - } -#endif - break; - case PAK010_16: #if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } - - if ((g_Vars.paksconnected & (1 << device)) && func0f0fd1f4(device, 0)) { - func0f0fd320(device, 0); - g_Paks[device].unk010 = PAK010_21; - } else { - // empty - } -#else - menuSetBanner(-1, true); - - if (func0f0fd1f4(device, 0)) { - func0f0fd320(device, 0); - g_Paks[device].unk010 = PAK010_21; - } else { - // empty - } + if (g_Vars.paksneededformenu & (1 << device)) #endif + { + if (menuIsReadyForPakError(device, PAKERRORDIALOG_DEVICEERROR)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_DEVICEERROR); + g_Paks[device].state = PAKSTATE_MEM_DEVICEERROR; + } else { + // empty + } + } break; - case PAK010_21: + case PAKSTATE_MEM_ENTER_FULL: + SETBANNER(-1); + #if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } -#else - menuSetBanner(-1, true); + if (g_Vars.paksneededformenu & (1 << device)) #endif + { + if (menuIsReadyForPakError(device, PAKERRORDIALOG_FULL)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_FULL); + g_Paks[device].state = PAKSTATE_MEM_FULL; + } else { + // empty + } + } break; - case PAK010_22: -#if VERSION >= VERSION_NTSC_1_0 - if (var80075d14) { - menuSetBanner(-1, true); - } -#else - menuSetBanner(-1, true); -#endif + case PAKSTATE_MEM_FULL: + SETBANNER(-1); + break; + case PAKSTATE_22: + SETBANNER(-1); break; } #if VERSION >= VERSION_NTSC_FINAL - if (g_Paks[device].unk2b8_07) { - if (var80075d14) { - menuSetBanner(-1, true); - } + if (g_Paks[device].showdatalost) { + SETBANNER(-1); - if (func0f0fd1f4(device, 4)) { - func0f0fd320(device, 4); - g_Paks[device].unk2b8_07 = false; + if (menuIsReadyForPakError(device, PAKERRORDIALOG_DATALOST)) { + menuPushPakErrorDialog(device, PAKERRORDIALOG_DATALOST); + g_Paks[device].showdatalost = false; } } #endif @@ -5786,57 +5735,57 @@ void pak0f117f94nb(s8 device) if (pak); if (pak); - if (pak->unk008 == 12) { + if (pak->unk008 == PAK008_12) { pak->unk2b8_05 = gbpakIdentifyGame(device); if (pak->unk2b8_05 && pak->isgbcamera) { - pak->unk008 = 0; + pak->unk008 = PAK008_00; } } if (!pak->unk2b8_05) { func0f14cf6c(); - pak->unk008 = 12; + pak->unk008 = PAK008_12; return; } - if (pak->unk008 != 1) { - if (pak->unk008 == 0) { + if (pak->unk008 != PAK008_01) { + if (pak->unk008 == PAK008_00) { gbpak0f11cef8(device); return; } - if (pak->unk008 == 2) { + if (pak->unk008 == PAK008_02) { gbpak0f11cef8(device); - pak->unk008 = 3; + pak->unk008 = PAK008_03; } - if (pak->unk008 == 3) { + if (pak->unk008 == PAK008_03) { if (pak0f116d1cnb(device) == 0) { - pak->unk008 = 4; + pak->unk008 = PAK008_04; } } - if (pak->unk008 == 4) { - pak->unk008 = pak->unk2b8_06 ? 5 : 8; + if (pak->unk008 == PAK008_04) { + pak->unk008 = pak->unk2b8_06 ? PAK008_05 : PAK008_08; } - if (pak->unk008 == 5) { + if (pak->unk008 == PAK008_05) { gbpak0f11cef8(device); - pak->unk008 = 6; + pak->unk008 = PAK008_06; } - if (pak->unk008 == 6) { + if (pak->unk008 == PAK008_06) { if (pak0f116d1cnb(device) == 0) { - pak->unk008 = 7; + pak->unk008 = PAK008_07; } } - if (pak->unk008 == 7) { - pak->unk008 = 8; + if (pak->unk008 == PAK008_07) { + pak->unk008 = PAK008_08; } - if (pak->unk008 == 8) { + if (pak->unk008 == PAK008_08) { s32 i; for (i = 0; i < 0x1000; i++) { @@ -5844,12 +5793,12 @@ void pak0f117f94nb(s8 device) } gbpak0f1172c8nb(device, pak->unk270); - pak->unk008 = 9; + pak->unk008 = PAK008_09; } - if (pak->unk008 == 9) { + if (pak->unk008 == PAK008_09) { if (gbpak0f11d680(device, pakGetUnk270(device)) && pak0f11d7c4(device)) { - pakSetUnk008(device, 11); + pakSetUnk008(device, PAK008_11); } } } @@ -5858,7 +5807,7 @@ void pak0f117f94nb(s8 device) void pak0f11e3bc(s8 device) { - g_Paks[device].unk008 = 0; + g_Paks[device].unk008 = PAK008_00; } void pakProbeEeprom(void) @@ -6005,7 +5954,7 @@ s8 pakFindBySerial(s32 findserial) s32 i; for (i = 0; i < ARRAYCOUNT(g_Paks); i++) { - if (pak0f116aec(i)) { + if (mempakIsReady(i)) { s32 serial = pakGetSerial(i); if (findserial == serial) { @@ -6135,7 +6084,7 @@ s32 gbpakIdentifyGame(s8 device) return game; } - g_Paks[device].unk010 = PAK010_26; + g_Paks[device].state = PAKSTATE_GB_OPEN_UNREADABLE; return GBGAME_OTHER; #else OSGbpakId id; diff --git a/src/game/player.c b/src/game/player.c index b3de7af4e..76eb9b6bf 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -211,7 +211,7 @@ s32 g_NumDeathAnimations = 0; * @dangerous: If there are too many pads (24+) in the setup then array * overflows may occur. */ -f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms, struct prop *prop, s16 *pads, s32 numpads) +f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstrooms, struct prop *prop, s16 *pads, s32 numpads) { u8 verybadpads[24]; u8 badpads[24]; @@ -226,7 +226,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms // "sl" prefixes are for shortlist s16 slpadindexes[8]; struct coord slpositions[4]; - s16 slrooms[4][8]; + RoomNum slrooms[4][8]; f32 slangles[4]; s32 sllen = 0; @@ -237,9 +237,9 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms u8 stack2[0x10]; struct pad pad; s32 stack3[2]; - s16 tmppadrooms[2]; + RoomNum tmppadrooms[2]; f32 bestsqdist; - s16 neighbours[20]; + RoomNum neighbours[20]; // Iterate all spawn pads and populate the category arrays for (p = 0; p < numpads; p++) { @@ -472,7 +472,7 @@ f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms return dstangle; } -f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, s16 *rooms, struct prop *prop) +f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, RoomNum *rooms, struct prop *prop) { return playerChooseSpawnLocation(chrradius, pos, rooms, prop, g_SpawnPoints, g_NumSpawnPoints); } @@ -480,7 +480,7 @@ f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, s16 *room void playerStartNewLife(void) { struct coord pos = {0, 0, 0}; - s16 rooms[8]; + RoomNum rooms[8]; f32 angle; s32 *cmd = g_StageSetup.intro; f32 groundy; @@ -3366,9 +3366,9 @@ void playerTick(bool arg0) rocket->base.realrot[0][0] * rocket->base.realrot[0][0] + rocket->base.realrot[1][0] * rocket->base.realrot[1][0] + rocket->base.realrot[2][0] * rocket->base.realrot[2][0]); - s16 inrooms[21]; - s16 aboverooms[21]; - s16 bestroom; + RoomNum inrooms[21]; + RoomNum aboverooms[21]; + RoomNum bestroom; s16 outofbounds = false; sp2b8[0][0] = rocket->base.realrot[0][0] / sp2a8; @@ -4921,14 +4921,14 @@ void playerSetCameraMode(s32 mode) g_Vars.currentplayer->cameramode = mode; } -void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, struct coord *pos2, s16 *rooms2) +void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, struct coord *pos2, RoomNum *rooms2) { bool done = false; - s16 inrooms[21]; - s16 aboverooms[21]; - s16 sp54[8]; - s16 bestroom; - s16 tmp; + RoomNum inrooms[21]; + RoomNum aboverooms[21]; + RoomNum sp54[8]; + RoomNum bestroom; + RoomNum tmp; s32 i; s32 room; @@ -5022,7 +5022,7 @@ void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, str void player0f0c1ba4(struct coord *pos, struct coord *up, struct coord *look, struct coord *memcampos, s32 memcamroom) { - s16 rooms[2]; + RoomNum rooms[2]; rooms[0] = memcamroom; rooms[1] = -1; @@ -5589,7 +5589,7 @@ void playerChooseThirdPersonAnimation(struct chrdata *chr, s32 crouchpos, f32 sp } } else if (turnspeed < 0.4f || (chr->prop->type == PROPTYPE_PLAYER - && g_Vars.players[playermgrGetPlayerNumByProp(chr->prop)]->headanim == 0)) { + && g_Vars.players[playermgrGetPlayerNumByProp(chr->prop)]->headanim == HEADANIM_RESTING)) { turnmode = TURNMODE_STAND_SOFTTURN; speed = 2.0f * turnspeed; diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 869d01dcb..01d47c65e 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -327,7 +327,7 @@ void playermgrAllocatePlayer(s32 index) g_Vars.players[index]->resetheadrot = true; g_Vars.players[index]->resetheadtick = true; - g_Vars.players[index]->headanim = 0; + g_Vars.players[index]->headanim = HEADANIM_RESTING; g_Vars.players[index]->headdamp = (PAL ? 0.9166f : 0.93f); g_Vars.players[index]->headwalkingtime60 = 0; g_Vars.players[index]->headamplitude = 1; diff --git a/src/game/playerreset.c b/src/game/playerreset.c index 0e786b62c..aed9245f3 100644 --- a/src/game/playerreset.c +++ b/src/game/playerreset.c @@ -110,7 +110,7 @@ struct cmd32 { void playerReset(void) { struct coord pos = {0, 0, 0}; - s16 rooms[8]; + RoomNum rooms[8]; f32 turnanglerad = 0; f32 groundy; bool hasdefaultweapon = false; diff --git a/src/game/prop.c b/src/game/prop.c index 12360bc08..2a0c496f3 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -391,11 +391,11 @@ Gfx *propRender(Gfx *gdl, struct prop *prop, bool xlupass) * terminal in the pre-bg pass and the screen in the post-bg pass, likely to * avoid Z-fighting issues. */ -Gfx *propsRender(Gfx *gdl, s16 renderroomnum, s32 renderpass, s16 *roomnumsbyprop) +Gfx *propsRender(Gfx *gdl, RoomNum renderroomnum, s32 renderpass, RoomNum *roomnumsbyprop) { struct prop **ptr; struct prop *prop; - s16 *proprooms; + RoomNum *proprooms; if (renderpass == RENDERPASS_OPA_PREBG || renderpass == RENDERPASS_OPA_POSTBG) { // Iterate onscreen props near to far @@ -592,22 +592,22 @@ struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2, struc s32 sparktype; #ifdef AVOID_UB - s16 rooms[131]; + RoomNum rooms[131]; #else - s16 rooms[124]; + RoomNum rooms[124]; #endif - s16 spc8[8]; - s16 spb8[8]; + RoomNum spc8[8]; + RoomNum spb8[8]; s32 uVar6; - s16 *roomsptr; + RoomNum *roomsptr; struct prop *prop; struct coord spa0; struct defaultobj *obj; bool doexplosiveshells; struct coord sp8c; - s16 sp7c[8]; - s16 sp6c[8]; + RoomNum sp7c[8]; + RoomNum sp6c[8]; struct prop *hitprop; bgun0f0a9494(arg6); @@ -1688,7 +1688,7 @@ void propsTickPlayer(bool islastplayer) s32 savedslotupdate240_60; f32 savedslotupdate240f; struct g_vars *vars = &g_Vars; - s16 *rooms; + RoomNum *rooms; u8 mostindex; u8 leastindex; u8 runstateindex; @@ -2215,8 +2215,8 @@ void propsTickPadEffects(void) struct pad pad; u32 stack; struct coord up; - s16 rooms[2]; - s16 rooms2[2]; + RoomNum rooms[2]; + RoomNum rooms2[2]; s32 type; if (g_LastPadEffectIndex >= 0) { @@ -2306,8 +2306,8 @@ void propsTestForPickup(void) s16 *propnumptr; s32 i; s16 propnums[256]; - s16 allrooms[21]; - s16 tmp[11]; + RoomNum allrooms[21]; + RoomNum tmp[11]; if (g_Vars.currentplayer->bondmovemode != MOVEMODE_CUTSCENE && !g_PlayerInvincible @@ -2853,10 +2853,10 @@ bool propIsOfCdType(struct prop *prop, u32 types) return result; } -void roomsCopy(s16 *src, s16 *dst) +void roomsCopy(RoomNum *src, RoomNum *dst) { - s16 *srcptr = src; - s16 *dstptr = dst; + RoomNum *srcptr = src; + RoomNum *dstptr = dst; s32 val; while ((val = *srcptr) != -1) { @@ -2871,7 +2871,7 @@ void roomsCopy(s16 *src, s16 *dst) /** * Append newrooms to dstrooms without duplicates. */ -void roomsAppend(s16 *newrooms, s16 *dstrooms, s32 maxlen) +void roomsAppend(RoomNum *newrooms, RoomNum *dstrooms, s32 maxlen) { s32 i; @@ -2887,12 +2887,12 @@ void roomsAppend(s16 *newrooms, s16 *dstrooms, s32 maxlen) } } -bool arrayIntersects(s16 *a, s16 *b) +bool arrayIntersects(RoomNum *a, RoomNum *b) { - s16 *aptr = a; - s16 aval = *aptr; - s16 *bptr; - s16 bval; + RoomNum *aptr = a; + RoomNum aval = *aptr; + RoomNum *bptr; + RoomNum bval; while (aval != -1) { bptr = b; bval = *bptr; @@ -2951,7 +2951,7 @@ s32 roomAllocatePropListChunk(s32 room, s32 prevchunkindex) return -1; } -void propRegisterRoom(struct prop *prop, s16 room) +void propRegisterRoom(struct prop *prop, RoomNum room) { s32 prev = -1; s32 i; @@ -2979,7 +2979,7 @@ void propRegisterRoom(struct prop *prop, s16 room) } } -void propDeregisterRoom(struct prop *prop, s16 room) +void propDeregisterRoom(struct prop *prop, RoomNum room) { bool removed = false; s32 prev = -1; @@ -3033,8 +3033,8 @@ void propDeregisterRoom(struct prop *prop, s16 room) */ void propDeregisterRooms(struct prop *prop) { - s16 *rooms = prop->rooms; - s16 room = *rooms; + RoomNum *rooms = prop->rooms; + RoomNum room = *rooms; while (room != -1) { propDeregisterRoom(prop, room); @@ -3050,8 +3050,8 @@ void propDeregisterRooms(struct prop *prop) */ void propRegisterRooms(struct prop *prop) { - s16 *rooms = prop->rooms; - s16 room = *rooms; + RoomNum *rooms = prop->rooms; + RoomNum room = *rooms; while (room != -1) { propRegisterRoom(prop, room); @@ -3060,9 +3060,9 @@ void propRegisterRooms(struct prop *prop) } } -void func0f065d1c(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms, s16 *morerooms, u32 arg5) +void func0f065d1c(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms, RoomNum *morerooms, u32 arg5) { - s16 stackrooms[8]; + RoomNum stackrooms[8]; s32 index; s32 i; @@ -3080,12 +3080,12 @@ void func0f065d1c(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newr newrooms[index] = -1; } -void func0f065dd8(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms) +void func0f065dd8(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms) { func0f065d1c(pos, rooms, newpos, newrooms, NULL, 0); } -void func0f065dfc(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms, s16 *morerooms, u32 arg5) +void func0f065dfc(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms, RoomNum *morerooms, u32 arg5) { func0f065d1c(pos, rooms, newpos, newrooms, morerooms, arg5); @@ -3098,16 +3098,16 @@ void func0f065dfc(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newr } } -void func0f065e74(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms) +void func0f065e74(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms) { func0f065dfc(pos, rooms, newpos, newrooms, NULL, 0); } -void func0f065e98(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *dstrooms) +void func0f065e98(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *dstrooms) { - s16 inrooms[21]; - s16 aboverooms[21]; - s16 *ptr = NULL; + RoomNum inrooms[21]; + RoomNum aboverooms[21]; + RoomNum *ptr = NULL; s32 i; bgFindRoomsByPos(pos2, inrooms, aboverooms, 20, NULL); @@ -3148,10 +3148,10 @@ void func0f065e98(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *dstroo * to get 256 props in a small space without exhausing the memory of the * console, you could potentially achieve arbitrary code execution. */ -void roomGetProps(s16 *rooms, s16 *propnums, s32 len) +void roomGetProps(RoomNum *rooms, s16 *propnums, s32 len) { s16 *writeptr = propnums; - s32 room; + RoomNum room; s32 i; s32 j; diff --git a/src/game/propobj.c b/src/game/propobj.c index 884b7b640..5152d380f 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -989,7 +989,7 @@ struct defaultobj *objFindByPadNum(s32 padnum) return NULL; } -struct defaultobj *objFindByPos(struct coord *pos, s16 *rooms) +struct defaultobj *objFindByPos(struct coord *pos, RoomNum *rooms) { struct prop *prop = g_Vars.activeprops; u8 *sp38; @@ -1353,7 +1353,7 @@ struct modelrodata_bbox *objFindBboxRodata(struct defaultobj *obj) return modelFindBboxRodata(obj->model); } -s32 objGetAverageBrightnessInRooms(s16 *rooms, s32 brightnesstype) +s32 objGetAverageBrightnessInRooms(RoomNum *rooms, s32 brightnesstype) { s32 brightness = 0; s32 i; @@ -1773,11 +1773,11 @@ void func0f069850(struct defaultobj *obj, struct coord *pos, f32 rot[3][3], stru if (obj->type == OBJTYPE_HOVERBIKE) { hoverbike = (struct hoverbikeobj *)obj; - cyl->ymax = hoverbike->hov.ground + g_HovTypes[hoverbike->hov.type].unk00 + objGetLocalYMax(bbox) * obj->model->scale; + cyl->ymax = hoverbike->hov.ground + g_HovTypes[hoverbike->hov.type].bobymid + objGetLocalYMax(bbox) * obj->model->scale; cyl->ymin = hoverbike->hov.ground + 20.0f; } else if (obj->type == OBJTYPE_HOVERPROP) { hoverprop = (struct hoverpropobj *)obj; - cyl->ymax = hoverprop->hov.ground + g_HovTypes[hoverprop->hov.type].unk00 + objGetLocalYMax(bbox) * obj->model->scale; + cyl->ymax = hoverprop->hov.ground + g_HovTypes[hoverprop->hov.type].bobymid + objGetLocalYMax(bbox) * obj->model->scale; cyl->ymin = hoverprop->hov.ground + 20.0f; } else { cyl->ymin = mtx.m[3][1] + objGetRotatedLocalYMinByMtx4(bbox, &mtx); @@ -1796,11 +1796,11 @@ void func0f069850(struct defaultobj *obj, struct coord *pos, f32 rot[3][3], stru if (obj->type == OBJTYPE_HOVERBIKE) { hoverbike = (struct hoverbikeobj *)obj; - cyl->ymax = hoverbike->hov.ground + g_HovTypes[hoverbike->hov.type].unk00 + objGetLocalYMax(bbox) * obj->model->scale; + cyl->ymax = hoverbike->hov.ground + g_HovTypes[hoverbike->hov.type].bobymid + objGetLocalYMax(bbox) * obj->model->scale; cyl->ymin = hoverbike->hov.ground + 20.0f; } else if (obj->type == OBJTYPE_HOVERPROP) { hoverprop = (struct hoverpropobj *)obj; - cyl->ymax = hoverprop->hov.ground + g_HovTypes[hoverprop->hov.type].unk00 + objGetLocalYMax(bbox) * obj->model->scale; + cyl->ymax = hoverprop->hov.ground + g_HovTypes[hoverprop->hov.type].bobymid + objGetLocalYMax(bbox) * obj->model->scale; cyl->ymin = hoverprop->hov.ground + 20.0f; } } @@ -2142,7 +2142,7 @@ struct prop *objInitWithAutoModel(struct defaultobj *obj) return objInitWithModelDef(obj, g_ModelStates[obj->modelnum].modeldef); } -void func0f06a580(struct defaultobj *obj, struct coord *pos, Mtxf *matrix, s16 *rooms) +void func0f06a580(struct defaultobj *obj, struct coord *pos, Mtxf *matrix, RoomNum *rooms) { struct prop *prop = obj->prop; @@ -2171,13 +2171,13 @@ f32 func0f06a620(struct defaultobj *obj) return 4; } -void func0f06a650(struct defaultobj *obj, struct coord *pos, Mtxf *arg2, s16 *rooms) +void func0f06a650(struct defaultobj *obj, struct coord *pos, Mtxf *arg2, RoomNum *rooms) { struct modelrodata_bbox *bbox; - s16 room; + RoomNum room; f32 sp3c; struct coord newpos; - s16 newrooms[2]; + RoomNum newrooms[2]; bbox = modelFindBboxRodata(obj->model); @@ -2201,14 +2201,14 @@ void func0f06a650(struct defaultobj *obj, struct coord *pos, Mtxf *arg2, s16 *ro } } -void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *mtx, s16 *rooms, struct coord *centre) +void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *mtx, RoomNum *rooms, struct coord *centre) { struct modelrodata_bbox *bbox = modelFindBboxRodata(obj->model); f32 min = objGetLocalYMin(bbox); f32 max = objGetLocalYMax(bbox); struct coord pos2; Mtxf sp70; - s16 rooms2[8]; + RoomNum rooms2[8]; f32 curval; f32 y; f32 maxval; @@ -2327,12 +2327,12 @@ void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *mtx, s16 *ro func0f06a580(obj, &pos2, &sp70, rooms2); } -void func0f06ab60(struct defaultobj *obj, struct coord *arg1, Mtxf *arg2, s16 *rooms, struct coord *arg4) +void func0f06ab60(struct defaultobj *obj, struct coord *arg1, Mtxf *arg2, RoomNum *rooms, struct coord *arg4) { struct modelrodata_bbox *bbox; f32 mult; struct coord newpos; - s16 newrooms[8]; + RoomNum newrooms[8]; Mtxf sp5c; Mtxf sp1c; @@ -3108,7 +3108,7 @@ bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord *arg2, s return result; } -bool projectileFindCollidingProp(struct prop *prop, struct coord *pos1, struct coord *pos2, u32 cdtypes, struct coord *arg4, struct coord *arg5, s16 *rooms) +bool projectileFindCollidingProp(struct prop *prop, struct coord *pos1, struct coord *pos2, u32 cdtypes, struct coord *arg4, struct coord *arg5, RoomNum *rooms) { bool result = false; f32 dist; @@ -3232,9 +3232,9 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, struct coord sp1c4; u32 stack; bool s0; - s16 spcc[120]; - s16 *ptr; - s16 spb8[8]; + RoomNum spcc[120]; + RoomNum *ptr; + RoomNum spb8[8]; s32 i; f32 scale = 1.0f; @@ -3287,7 +3287,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, } } } else { - s16 spa0[2]; + RoomNum spa0[2]; spa0[0] = spcc[i]; spa0[1] = -1; @@ -3377,7 +3377,7 @@ bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 bool sp98 = false; struct coord sp8c; struct coord sp80; - s16 rooms[8]; + RoomNum rooms[8]; struct coord sp64; struct coord sp58; struct coord sp4c; @@ -3966,7 +3966,7 @@ void objLand2(struct defaultobj *obj, struct coord *arg1, struct coord *arg2) struct modelrodata_bbox *bbox = modelFindBboxRodata(obj->model); f32 ymin = objGetLocalYMin(bbox); struct prop *prop = obj->prop; - s16 newrooms[8]; + RoomNum newrooms[8]; func0f06e9cc(arg2, &sp40); mtx00015f04(obj->model->scale, &sp40); @@ -3987,7 +3987,7 @@ void boltLand(struct weaponobj *weapon, struct coord *arg1) s32 beamnum; f32 zmax; struct prop *prop; - s16 newrooms[8]; + RoomNum newrooms[8]; bbox = modelFindBboxRodata(weapon->base.model); prop = weapon->base.prop; @@ -4023,7 +4023,7 @@ void knifeLand(struct defaultobj *obj, struct coord *arg1, struct coord *arg2) struct modelrodata_bbox *bbox = modelFindBboxRodata(obj->model); f32 zero = 0.0f; struct prop *prop = obj->prop; - s16 newrooms[8]; + RoomNum newrooms[8]; struct coord sp1c; // @bug? Should these be assigned to zero? @@ -4175,7 +4175,7 @@ bool propExplode(struct prop *prop, s32 exptype) if (prop->parent) { struct prop *parent = prop->parent; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; while (parent->parent) { parent = parent->parent; @@ -4821,20 +4821,15 @@ s32 glassCalculateOpacity(struct coord *pos, f32 xludist, f32 opadist, f32 arg3) struct prop *g_Lifts[10] = {NULL}; +#define BOB(minamount, randamount, accel, maxspeed) \ + minamount, randamount, PALUPF(accel), PALUPF(maxspeed) + struct hovtype g_HovTypes[] = { -#if PAL - /* HOVTYPE_BED */ { 90, 1, 2, 0.0012, 1.200000000, 0.0062821852043271, 0.0062821852043271, 0.000012564370990731, 0.00037693112972192, 0.0062821852043271, 0.0062821852043271, 0.000012564370990731, 0.00037693112972192 }, - /* HOVTYPE_BIKE */ { 80, 1, 3, 0.0030, 0.120000004, 0.0125643704086540, 0.0188465546816590, 0.000025128741981462, 0.00075386225944385, 0.0125643704086540, 0.0188465546816590, 0.000025128741981462, 0.00075386225944385 }, - /* HOVTYPE_CRATE */ { 70, 2, 4, 0.0012, 1.200000000, 0.0062821852043271, 0.0125643704086540, 0.000012564370990731, 0.00037693112972192, 0.0062821852043271, 0.0125643704086540, 0.000012564370990731, 0.00037693112972192 }, - /* HOVTYPE_3 */ { 170, 2, 2, 0.0012, 1.200000000, 0.0031410926021636, 0.0031410926021636, 0.000006282185495365, 0.00022615866328124, 0.0031410926021636, 0.0031410926021636, 0.000006282185495365, 0.00022615866328124 }, - /* HOVTYPE_4 */ { 170, 2, 2, 0.0012, 1.200000000, 0.0031410926021636, 0.0031410926021636, 0.000006282185495365, 0.00022615866328124, 0.0031410926021636, 0.0031410926021636, 0.000006282185495365, 0.00022615866328124 }, -#else - /* HOVTYPE_BED */ { 90, 1, 2, 0.0010, 1.000000000, 0.0062821852043271, 0.0062821852043271, 0.000010470308552613, 0.00031410926021636, 0.0062821852043271, 0.0062821852043271, 0.000010470308552613, 0.00031410926021636 }, - /* HOVTYPE_BIKE */ { 80, 1, 3, 0.0025, 0.100000000, 0.0125643704086540, 0.0188465546816590, 0.000020940617105225, 0.00062821852043271, 0.0125643704086540, 0.0188465546816590, 0.000020940617105225, 0.00062821852043271 }, - /* HOVTYPE_CRATE */ { 70, 2, 4, 0.0010, 1.000000000, 0.0062821852043271, 0.0125643704086540, 0.000010470308552613, 0.00031410926021636, 0.0062821852043271, 0.0125643704086540, 0.000010470308552613, 0.00031410926021636 }, - /* HOVTYPE_3 */ { 170, 2, 2, 0.0010, 1.000000000, 0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905, 0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905 }, - /* HOVTYPE_4 */ { 170, 2, 2, 0.0010, 1.000000000, 0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905, 0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905 }, -#endif + /* HOVTYPE_BED */ { 90, BOB(1, 2, 0.0010, 1.0), BOB(0.0062821852043271, 0.0062821852043271, 0.000010470308552613, 0.00031410926021636), BOB(0.0062821852043271, 0.0062821852043271, 0.000010470308552613, 0.00031410926021636) }, + /* HOVTYPE_BIKE */ { 80, BOB(1, 3, 0.0025, 0.1), BOB(0.0125643704086540, 0.0188465546816590, 0.000020940617105225, 0.00062821852043271), BOB(0.0125643704086540, 0.0188465546816590, 0.000020940617105225, 0.00062821852043271) }, + /* HOVTYPE_CRATE */ { 70, BOB(2, 4, 0.0010, 1.0), BOB(0.0062821852043271, 0.0125643704086540, 0.000010470308552613, 0.00031410926021636), BOB(0.0062821852043271, 0.0125643704086540, 0.000010470308552613, 0.00031410926021636) }, + /* HOVTYPE_3 */ { 170, BOB(2, 2, 0.0010, 1.0), BOB(0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905), BOB(0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905) }, + /* HOVTYPE_4 */ { 170, BOB(2, 2, 0.0010, 1.0), BOB(0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905), BOB(0.0031410926021636, 0.0031410926021636, 0.000005235154276306, 0.00018846555030905) }, }; void func0f070a1c(struct modelrodata_bbox *bbox, f32 rot[3][3], struct coord *pos, struct coord *vertices) @@ -5139,7 +5134,13 @@ void liftGoToStop(struct liftobj *lift, s32 stopnum) } } -f32 objGetHov04(struct defaultobj *obj) +/** + * For hover crates, hover bikes and hover beds. + * + * The value returned is the distance between the object's ground (when not falling) + * and its Y value. For crates, the value returned is typically between 65 and 75 (cm). + */ +f32 objGetHovBobOffsetY(struct defaultobj *obj) { struct hov *hov = NULL; f32 result; @@ -5153,7 +5154,7 @@ f32 objGetHov04(struct defaultobj *obj) } if (hov) { - result = hov->unk04; + result = hov->bobycur; } else { struct modelrodata_bbox *bbox = objFindBboxRodata(obj); f32 value = objGetRotatedLocalYMinByMtx3(bbox, obj->realrot); @@ -5163,13 +5164,13 @@ f32 objGetHov04(struct defaultobj *obj) return result; } -void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 matrix[3][3]) +void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, RoomNum *rooms, f32 matrix[3][3]) { f32 ground; - s16 testrooms[8]; + RoomNum testrooms[8]; struct coord testpos; - if (g_Vars.lvframe60 > hov->nexttick60) { + if (g_Vars.lvframe60 > hov->prevframe60) { testpos.x = pos->x; testpos.y = pos->y - 50; testpos.z = pos->z; @@ -5184,7 +5185,7 @@ void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, } hov->ground = ground; - hov->prevtick60 = g_Vars.lvframe60; + hov->prevgroundframe60 = g_Vars.lvframe60; } } @@ -5198,8 +5199,8 @@ void hovTick(struct defaultobj *obj, struct hov *hov) struct modelrodata_bbox *bbox; struct coord sp1b4; struct coord sp1a8; - s16 sp198[8]; - s16 sp188[8]; + RoomNum sp198[8]; + RoomNum sp188[8]; Mtxf sp148; Mtxf sp108; Mtxf spc8; @@ -5207,30 +5208,31 @@ void hovTick(struct defaultobj *obj, struct hov *hov) struct hovtype *type; f32 spbc; f32 spb8; - f32 spb4; + f32 groundangle; f32 xrot; - f32 spac; - s16 sp9c[8]; + f32 ground; + RoomNum sp9c[8]; struct coord sp90; - bool sp8c; + bool moved; f32 radius; f32 ymax; f32 ymin; - if (g_Vars.lvframe60 > hov->nexttick60) { + if (g_Vars.lvframe60 > hov->prevframe60) { prop = obj->prop; bbox = objFindBboxRodata(obj); type = &g_HovTypes[hov->type]; - sp8c = false; + moved = false; - if (hov->prevtick60 < g_Vars.lvframe60) { + if (g_Vars.lvframe60 > hov->prevgroundframe60) { hovUpdateGround(obj, hov, &prop->pos, prop->rooms, obj->realrot); } - hov->nexttick60 = g_Vars.lvframe60; + hov->prevframe60 = g_Vars.lvframe60; + // Calculate ground angle if (obj->flags & OBJFLAG_DEACTIVATED) { - spb4 = 0.0f; + groundangle = 0.0f; } else { if (obj->flags3 & OBJFLAG3_GEOCYL) { objGetBbox(prop, &radius, &ymax, &ymin); @@ -5241,8 +5243,8 @@ void hovTick(struct defaultobj *obj, struct hov *hov) sp1cc = bbox->zmax * 0.9f * obj->model->scale; } - spbc = cosf(hov->unk10); - spb8 = sinf(hov->unk10); + spbc = cosf(hov->yrot); + spb8 = sinf(hov->yrot); sp1b4.x = prop->pos.x + sp1d0 * spb8; sp1b4.y = prop->pos.y; @@ -5269,81 +5271,84 @@ void hovTick(struct defaultobj *obj, struct hov *hov) ground2 = cdFindGroundAtCyl(&sp1a8, 5, sp188, NULL, NULL); if (ground1 >= -30000.0f && ground2 >= -30000.0f) { - spb4 = atan2f(ground1 - ground2, sp1cc - sp1d0); + groundangle = atan2f(ground1 - ground2, sp1cc - sp1d0); - if (spb4 >= M_PI) { - spb4 -= M_BADTAU; + if (groundangle >= M_PI) { + groundangle -= M_BADTAU; } } else if (ground1 >= -30000.0f) { - spb4 = atan2f(ground1 - hov->ground, -sp1d0); + groundangle = atan2f(ground1 - hov->ground, -sp1d0); - if (spb4 >= M_PI) { - spb4 -= M_BADTAU; + if (groundangle >= M_PI) { + groundangle -= M_BADTAU; } } else if (ground2 >= -30000.0f) { - spb4 = atan2f(hov->ground - ground2, sp1cc); + groundangle = atan2f(hov->ground - ground2, sp1cc); - if (spb4 >= M_PI) { - spb4 -= M_BADTAU; + if (groundangle >= M_PI) { + groundangle -= M_BADTAU; } } else { - spb4 = 0.0f; + groundangle = 0.0f; } } - spac = hov->ground; + ground = hov->ground; if (obj->hidden & OBJHFLAG_GRABBED) { - if (spac < g_Vars.currentplayer->vv_ground - 70.0f) { - spac = g_Vars.currentplayer->vv_ground; + if (g_Vars.currentplayer->vv_ground - 70.0f > ground) { + ground = g_Vars.currentplayer->vv_ground; } } - if (hov->flags & 1) { - sp8c = true; - hov->unk04 = hov->unk08 = type->unk00; - hov->unk30 = spac; - hov->flags &= ~1; + if (hov->flags & HOVFLAG_FIRSTTICK) { + moved = true; + hov->bobycur = hov->bobytarget = type->bobymid; + hov->y = ground; + hov->flags &= ~HOVFLAG_FIRSTTICK; if (obj->type == OBJTYPE_HOVERBIKE) { psCreate(NULL, obj->prop, SFX_BIKE_PULSE, -1, -1, 0, 0, PSTYPE_NONE, 0, -1.0f, 0, -1, -1.0f, -1.0f, -1.0f); } } - applySpeed(&hov->unk04, hov->unk08, &hov->unk0c, type->unk0c, type->unk0c, type->unk10); + // Update Y bob + applySpeed(&hov->bobycur, hov->bobytarget, &hov->bobyspeed, type->bobyaccel, type->bobyaccel, type->bobymaxspeed); - if (hov->unk08 >= type->unk00 && hov->unk08 <= hov->unk04) { - hov->unk0c = 0.0f; - hov->unk08 = type->unk00 - type->unk04 - RANDOMFRAC() * type->unk08; - } else if (hov->unk08 < type->unk00 && hov->unk08 >= hov->unk04) { - hov->unk0c = 0.0f; - hov->unk08 = type->unk00 + type->unk04 + RANDOMFRAC() * type->unk08; + if (hov->bobytarget >= type->bobymid && hov->bobycur >= hov->bobytarget) { + hov->bobyspeed = 0.0f; + hov->bobytarget = type->bobymid - type->bobyminradius - RANDOMFRAC() * type->bobyrandradius; + } else if (hov->bobytarget < type->bobymid && hov->bobycur <= hov->bobytarget) { + hov->bobyspeed = 0.0f; + hov->bobytarget = type->bobymid + type->bobyminradius + RANDOMFRAC() * type->bobyrandradius; } - applyRotation(&hov->unk14, hov->unk18, &hov->unk1c, type->unk1c, type->unk1c, type->unk20); + // Update pitch bob + applyRotation(&hov->bobpitchcur, hov->bobpitchtarget, &hov->bobpitchspeed, type->bobpitchaccel, type->bobpitchaccel, type->bobpitchmaxspeed); - if (hov->unk14 == hov->unk18) { - if (hov->unk1c <= 2.0f * type->unk1c && hov->unk1c >= 2.0f * -type->unk1c) { - hov->unk1c = 0.0f; + if (hov->bobpitchcur == hov->bobpitchtarget) { + if (hov->bobpitchspeed <= 2.0f * type->bobpitchaccel && hov->bobpitchspeed >= 2.0f * -type->bobpitchaccel) { + hov->bobpitchspeed = 0.0f; - if (hov->unk18 < M_PI) { - hov->unk18 = M_BADTAU - type->unk14 - RANDOMFRAC() * type->unk18; + if (hov->bobpitchtarget < M_PI) { + hov->bobpitchtarget = M_BADTAU - type->bobpitchminangle - RANDOMFRAC() * type->bobpitchrandangle; } else { - hov->unk18 = type->unk14 + RANDOMFRAC() * type->unk18; + hov->bobpitchtarget = type->bobpitchminangle + RANDOMFRAC() * type->bobpitchrandangle; } } } - applyRotation(&hov->unk20, hov->unk24, &hov->unk28, type->unk2c, type->unk2c, type->unk30); + // Update roll bob + applyRotation(&hov->bobrollcur, hov->bobrolltarget, &hov->bobrollspeed, type->bobrollaccel, type->bobrollaccel, type->bobrollmaxspeed); - if (hov->unk20 == hov->unk24) { - if (hov->unk28 <= 2.0f * type->unk2c && hov->unk28 >= 2.0f * -type->unk2c) { - hov->unk28 = 0.0f; + if (hov->bobrollcur == hov->bobrolltarget) { + if (hov->bobrollspeed <= 2.0f * type->bobrollaccel && hov->bobrollspeed >= 2.0f * -type->bobrollaccel) { + hov->bobrollspeed = 0.0f; - if (hov->unk24 < M_PI) { - hov->unk24 = M_BADTAU - type->unk24 - RANDOMFRAC() * type->unk28; + if (hov->bobrolltarget < M_PI) { + hov->bobrolltarget = M_BADTAU - type->bobrollminangle - RANDOMFRAC() * type->bobrollrandangle; } else { - hov->unk24 = type->unk24 + RANDOMFRAC() * type->unk28; + hov->bobrolltarget = type->bobrollminangle + RANDOMFRAC() * type->bobrollrandangle; } } } @@ -5353,12 +5358,12 @@ void hovTick(struct defaultobj *obj, struct hov *hov) f32 f12; f32 f2; - hov->unk2c += (spb4 - hov->unk2c) * (PAL ? 0.0893f : 0.075f); + hov->groundpitch += (groundangle - hov->groundpitch) * (PAL ? 0.0893f : 0.075f); - f0 = spac - hov->unk30; + f0 = ground - hov->y; f12 = (PAL ? 0.102000005f : 0.085f); - if (hov->unk30 < hov->ground) { + if (hov->y < hov->ground) { if (f0 >= 0.0f) { f2 = f0; } else { @@ -5392,28 +5397,28 @@ void hovTick(struct defaultobj *obj, struct hov *hov) } } - hov->unk30 += f0; + hov->y += f0; if (f0 > 1.0f || f0 < -1.0f) { - sp8c = true; + moved = true; } } - if (sp8c) { + if (moved) { func0f069c70(obj, true, true); } - if (hov->unk30 < hov->ground - 5.0f || hov->unk30 > hov->ground + 5.0f) { + if (hov->y < hov->ground - 5.0f || hov->y > hov->ground + 5.0f) { obj->flags |= OBJFLAG_HOVERCAR_ISHOVERBOT; } else { obj->flags &= ~OBJFLAG_HOVERCAR_ISHOVERBOT; } - prop->pos.y = objGetHov04(obj) + hov->unk30; + prop->pos.y = objGetHovBobOffsetY(obj) + hov->y; - mtx4LoadZRotation(hov->unk20, &sp148); + mtx4LoadZRotation(hov->bobrollcur, &sp148); - xrot = hov->unk2c + hov->unk14; + xrot = hov->groundpitch + hov->bobpitchcur; if (xrot >= M_BADTAU) { xrot -= M_BADTAU; @@ -5423,7 +5428,7 @@ void hovTick(struct defaultobj *obj, struct hov *hov) mtx4LoadXRotation(xrot, &sp108); mtx00015be0(&sp108, &sp148); - mtx4LoadYRotation(hov->unk10, &sp108); + mtx4LoadYRotation(hov->yrot, &sp108); mtx00015be0(&sp108, &sp148); mtx00015f04(obj->model->scale, &sp148); @@ -5459,10 +5464,10 @@ f32 hoverpropGetTurnAngle(struct defaultobj *obj) if (obj->type == OBJTYPE_HOVERPROP) { struct hoverpropobj *hoverprop = (struct hoverpropobj *)obj; - angle = hoverprop->hov.unk10; + angle = hoverprop->hov.yrot; } else if (obj->type == OBJTYPE_HOVERBIKE) { struct hoverbikeobj *hoverbike = (struct hoverbikeobj *)obj; - angle = hoverbike->hov.unk10; + angle = hoverbike->hov.yrot; } return angle; @@ -5472,10 +5477,10 @@ void hoverpropSetTurnAngle(struct defaultobj *obj, f32 angle) { if (obj->type == OBJTYPE_HOVERPROP) { struct hoverpropobj *hoverprop = (struct hoverpropobj *)obj; - hoverprop->hov.unk10 = angle; + hoverprop->hov.yrot = angle; } else if (obj->type == OBJTYPE_HOVERBIKE) { struct hoverbikeobj *hoverbike = (struct hoverbikeobj *)obj; - hoverbike->hov.unk10 = angle; + hoverbike->hov.yrot = angle; } } @@ -5485,7 +5490,7 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 f32 sp460[3][3]; f32 yrot; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; struct hov prevhov; struct hov *hov = NULL; union geounion geounion; @@ -5636,7 +5641,7 @@ void hovercarStartNextPath(struct hovercarobj *hovercar) s32 *pads; struct pad pad; Mtxf matrix; - s16 rooms[2]; + RoomNum rooms[2]; hovercarFindNextPath(hovercar); @@ -6012,7 +6017,7 @@ bool rocketTickFbw(struct weaponobj *rocket) struct coord newpos; struct coord dir; u32 stack[2]; - s16 newrooms[8]; + RoomNum newrooms[8]; if (projectile->ownerprop && projectile->ownerprop->type == PROPTYPE_CHR) { ownerchr = projectile->ownerprop->chr; @@ -6189,7 +6194,7 @@ s32 projectileLaunch(struct defaultobj *obj, struct projectile *projectile, stru } if (cdresult == CDRESULT_NOCOLLISION) { - s16 rooms[8]; + RoomNum rooms[8]; func0f065e74(&prop->pos, prop->rooms, &projectile->nextsteppos, rooms); @@ -6201,7 +6206,7 @@ s32 projectileLaunch(struct defaultobj *obj, struct projectile *projectile, stru roomsCopy(rooms, prop->rooms); } else if (cdresult != CDRESULT_NOCOLLISION && obj->type == OBJTYPE_WEAPON) { struct weaponobj *weapon = (struct weaponobj *)obj; - s16 rooms[8]; + RoomNum rooms[8]; if (weapon->weaponnum == WEAPON_ROCKET || weapon->weaponnum == WEAPON_HOMINGROCKET) { weapon->timer240 = 0; @@ -6232,7 +6237,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) bool result = false; struct prop *prop = obj->prop; struct coord sp5c8; - s16 sp5b8[8]; + RoomNum sp5b8[8]; struct coord sp5ac; f32 sp5a8; struct coord sp59c; @@ -6653,7 +6658,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) ground = cdFindGroundAtCyl(&prop->pos, 2, prop->rooms, &obj->floorcol, NULL); if (ground > -30000.0f) { - prop->pos.y = ground + objGetHov04(obj); + prop->pos.y = ground + objGetHovBobOffsetY(obj); } } @@ -6666,7 +6671,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) result = true; } else if (projectile->flags & PROJECTILEFLAG_AIRBORNE) { f32 sp390; - s16 roomnum; + RoomNum roomnum; struct coord sp380; f32 sp37c; f32 realrot[3][3]; @@ -7151,7 +7156,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) if (!handled) { if (cdresult != CDRESULT_COLLISION) { - s16 rooms[8]; + RoomNum rooms[8]; func0f065e74(&prop->pos, prop->rooms, &sp5dc, rooms); @@ -7162,7 +7167,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) propDeregisterRooms(prop); roomsCopy(rooms, prop->rooms); } else { - s16 rooms[8]; + RoomNum rooms[8]; if (g_EmbedProp && (g_EmbedProp->type == PROPTYPE_CHR || g_EmbedProp->type == PROPTYPE_PLAYER)) { sp5dc.x = prop->pos.x; @@ -7448,7 +7453,7 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) if (projectile->speed.f[0] != 0.0f || projectile->speed.f[2] != 0.0f || projectile->unk060 < 1.0f) { f32 f12; f32 spa4; - s16 roomnum; + RoomNum roomnum; s32 i; f32 sp98 = objGetRotatedLocalYMinByMtx3(objFindBboxRodata(obj), obj->realrot); #if VERSION >= VERSION_NTSC_1_0 @@ -7818,7 +7823,7 @@ void platformDisplaceProps(struct prop *platform, s16 *propnums, struct coord *p } if (hov) { - hov->unk30 += newpos->y - prevpos->y; + hov->y += newpos->y - prevpos->y; hov->ground += newpos->y - prevpos->y; } @@ -7886,7 +7891,7 @@ void platformDisplaceProps(struct prop *platform, s16 *propnums, struct coord *p if (g_Vars.players[playernum]->inlift && !g_Vars.players[playernum]->onladder && !g_Vars.players[playernum]->isfalling) { struct coord sp78; - s16 sp68[8]; + RoomNum sp68[8]; f32 ydist = newpos->y - prevpos->y; if (ydist != 0.0f) { @@ -7979,7 +7984,7 @@ void liftTick(struct prop *prop) f32 frac; s32 move; struct coord newpos; - s16 newrooms[8]; + RoomNum newrooms[8]; struct coord prevpos; #if VERSION >= VERSION_NTSC_1_0 f32 prevdist; @@ -9013,11 +9018,11 @@ void autogunTickShoot(struct prop *autogunprop) if (fireleft || fireright) { struct coord gunpos; - s16 gunrooms[8]; + RoomNum gunrooms[8]; struct coord dir; bool missed = false; struct coord hitpos; - s16 hitrooms[8]; + RoomNum hitrooms[8]; bool makebeam = (autogun->firecount % 4) == 0; struct prop *targetprop = autogun->target; struct modelnode *flashnode; @@ -9777,7 +9782,7 @@ void chopperIncrementMovement(struct prop *prop, f32 goalroty, f32 goalrotx, str { struct defaultobj *obj = prop->obj; struct chopperobj *chopper = (struct chopperobj *)obj; - s16 newrooms[8]; + RoomNum newrooms[8]; struct coord newpos; f32 curroty; f32 currotx; @@ -10070,10 +10075,10 @@ void chopperTickFall(struct prop *chopperprop) if (cdExamLos09(&chopperprop->pos, chopperprop->rooms, &newpos, CDTYPE_BG) == CDRESULT_COLLISION) { struct coord sp74; - s16 room; + RoomNum room; struct coord sp64; f32 ground; - s16 newrooms[8]; + RoomNum newrooms[8]; chopperprop->pos.y += 100; ground = cdFindGroundAtCyl(&chopperprop->pos, 5, chopperprop->rooms, NULL, NULL); @@ -10373,7 +10378,7 @@ void hovercarTick(struct prop *prop) bool stopping; struct pad pad; struct coord sp214; - s16 sp210[2]; + RoomNum sp210[2]; struct hovercarobj *hovercar = (struct hovercarobj *) prop->obj; struct defaultobj *obj = &hovercar->base; u32 stack; @@ -10384,11 +10389,11 @@ void hovercarTick(struct prop *prop) struct prop *doorprop; struct coord sp1e4; struct coord sp1d8; - s16 sp1d6; + RoomNum sp1d6; f32 x; f32 z; struct coord sp1c0; - s16 sp1b0[8]; + RoomNum sp1b0[8]; struct modelrodata_bbox *bbox; f32 ymin; s32 *padnum; @@ -10401,7 +10406,7 @@ void hovercarTick(struct prop *prop) f32 sp180; f32 sp15c[3][3]; struct coord sp150; - s16 sp140[8]; + RoomNum sp140[8]; f32 tmp2; f32 sp138; struct coord sp12c; @@ -10550,7 +10555,7 @@ void hovercarTick(struct prop *prop) // during acceleration can cause the hovercar to exceed its max speed. if (hovercar->speedtime60 >= 0) { if (1); - if (hovercar->speedtime60 <= g_Vars.lvupdate60freal) { + if (g_Vars.lvupdate60freal >= hovercar->speedtime60) { hovercar->speed = hovercar->speedaim; } else { hovercar->speed += (hovercar->speedaim - hovercar->speed) * g_Vars.lvupdate60freal / hovercar->speedtime60; @@ -11030,7 +11035,7 @@ s32 objTickPlayer(struct prop *prop) struct modelrenderdata sp476 = {0, 1, 3}; Mtxf sp412; struct coord sp400; - s16 sp384[8]; + RoomNum sp384[8]; struct hov *hov = NULL; if (fulltick) { @@ -11089,13 +11094,13 @@ s32 objTickPlayer(struct prop *prop) hovUpdateGround(obj, hov, &prop->pos, prop->rooms, obj->realrot); hoverpropSetTurnAngle(obj, atan2f(sp412.m[2][0], sp412.m[2][2])); - hov->unk14 = 0; - hov->unk1c = 0; - hov->unk20 = 0; - hov->unk28 = 0; - hov->unk30 = hov->ground; - hov->unk04 = prop->pos.y - hov->ground; - hov->unk0c = 0; + hov->bobpitchcur = 0; + hov->bobpitchspeed = 0; + hov->bobrollcur = 0; + hov->bobrollspeed = 0; + hov->y = hov->ground; + hov->bobycur = prop->pos.y - hov->ground; + hov->bobyspeed = 0; } if ((obj->flags & OBJFLAG_IGNOREFLOORCOLOUR) == 0) { @@ -11116,7 +11121,7 @@ s32 objTickPlayer(struct prop *prop) struct modelrenderdata sp312 = {0, 1, 3}; Mtxf sp248; struct coord sp236; - s16 sp220[8]; + RoomNum sp220[8]; s32 numchrs; Mtxf sp152; s32 sp148; @@ -14391,7 +14396,7 @@ bool objDrop(struct prop *prop, bool lazy) struct model *model; Mtxf spf0; struct coord spe4; - s16 rooms[8]; + RoomNum rooms[8]; if ((obj->hidden & OBJHFLAG_EMBEDDED) && obj->embedment->projectile) { struct projectile *projectile2 = obj->embedment->projectile; @@ -14708,7 +14713,7 @@ void objCheckDestroyed(struct defaultobj *obj, struct coord *pos, s32 playernum) struct prop *prop = obj->prop; struct prop *rootprop = prop; s16 exptype = g_PropExplosionTypes[8 + obj->modelnum]; - s16 rooms[8]; + RoomNum rooms[8]; // If in Deep Sea outro if (g_Vars.tickmode == TICKMODE_CUTSCENE && g_CutsceneAnimNum == ANIM_CUT_PAM_OUTRO_CAM) { @@ -18765,7 +18770,7 @@ s32 weaponTestForPickup(struct prop *prop) return objTestForPickup(prop); } -void weaponSetGunfireVisible(struct prop *prop, bool visible, s16 room) +void weaponSetGunfireVisible(struct prop *prop, bool visible, RoomNum room) { u32 stack[4]; bool flash = false; @@ -19301,12 +19306,12 @@ void doorDeactivatePortal(struct doorobj *door) } } -struct prop *doorInit(struct doorobj *door, struct coord *pos, Mtxf *mtx, s16 *rooms, struct coord *coord, struct coord *centre) +struct prop *doorInit(struct doorobj *door, struct coord *pos, Mtxf *mtx, RoomNum *rooms, struct coord *coord, struct coord *centre) { struct prop *prop; union modelrodata *rodata; Mtxf sp38; - s16 sp28[8]; + RoomNum sp28[8]; door->base.flags |= OBJFLAG_00000100; prop = objInitWithAutoModel(&door->base); @@ -19809,10 +19814,10 @@ s32 doorIsOpen(struct doorobj *door) return (door->mode == DOORMODE_IDLE || door->mode == DOORMODE_WAITING) && door->frac >= door->maxfrac; } -s32 func0f08e5a8(s16 *rooms2, struct screenbox *box) +s32 func0f08e5a8(RoomNum *rooms2, struct screenbox *box) { bool result = false; - s16 *rooms = rooms2; + RoomNum *rooms = rooms2; s32 roomnum = *rooms; while (roomnum != -1) { @@ -19917,8 +19922,8 @@ bool posIsInObjFadeDistance(struct coord *pos, f32 modelscale) bool func0f08e8ac(struct prop *prop, struct coord *pos, f32 arg2, bool arg3) { - s16 *rooms; - s32 roomnum; + RoomNum *rooms; + RoomNum roomnum; bool result = false; u32 stack; @@ -21127,7 +21132,7 @@ void projectileCreate(struct prop *fromprop, struct fireslotthing *arg1, struct f32 z; f32 sqdist; struct prop *obstacle = NULL; - s16 sp1c8[8]; + RoomNum sp1c8[8]; u8 forcebeam = false; struct beam beam; struct coord frompos; diff --git a/src/game/propsnd.c b/src/game/propsnd.c index 9e4b07fde..6cd41bd3c 100644 --- a/src/game/propsnd.c +++ b/src/game/propsnd.c @@ -232,7 +232,7 @@ void psTickChannel(s32 channelnum) #endif { struct coord *pos = NULL; - s16 *rooms = NULL; + RoomNum *rooms = NULL; s32 newvol; s32 newpan; s32 newfx; @@ -261,7 +261,7 @@ void psTickChannel(s32 channelnum) } } else { if (pos && rooms) { - s16 *tmprooms; + RoomNum *tmprooms; if (channel->flags & PSFLAG_IGNOREROOMS) { tmprooms = NULL; @@ -645,7 +645,7 @@ void psStopOneShootChannel(struct prop *prop) s16 psCreate(struct pschannel *channel, struct prop *prop, s16 soundnum, s16 padnum, s32 vol, u16 flags, u16 flags2, s32 type, - struct coord *pos, f32 pitch, s16 *rooms, s32 room, + struct coord *pos, f32 pitch, RoomNum *rooms, s32 room, f32 dist1, f32 dist2, f32 dist3) { union soundnumhack spac; @@ -1123,12 +1123,12 @@ void psModify(s32 channelnum, s32 volume, s16 padnum, struct prop *prop, s32 vol } } -s32 psCalculateVol(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, s16 *rooms, s16 soundnum, s32 arg6, f32 *playerdistptr) +s32 psCalculateVol(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, RoomNum *rooms, s16 soundnum, s32 arg6, f32 *playerdistptr) { union soundnumhack sp6c; union soundnumhack sp68; f32 playerdist; - s16 roomnum; + RoomNum roomnum; s32 s0; s32 i; @@ -1382,7 +1382,7 @@ s32 psCalculatePan(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, f32 playe * If the given soundnum were to play at the given world position, calculate the * final volume and pan and write them to the vol and pan pointers. */ -void psGetTheoreticalVolPan(struct coord *pos, s16 *rooms, s16 soundnum, s32 *vol, s32 *pan) +void psGetTheoreticalVolPan(struct coord *pos, RoomNum *rooms, s16 soundnum, s32 *vol, s32 *pan) { f32 dist1; f32 dist2; @@ -1434,7 +1434,7 @@ void psGetTheoreticalVolPan(struct coord *pos, s16 *rooms, s16 soundnum, s32 *vo } #endif -void psApplyVolPan(struct sndstate *handle, struct coord *pos, f32 dist1, f32 dist2, f32 dist3, s16 *rooms, s16 soundnum, s32 arg7, f32 *distanceptr) +void psApplyVolPan(struct sndstate *handle, struct coord *pos, f32 dist1, f32 dist2, f32 dist3, RoomNum *rooms, s16 soundnum, s32 arg7, f32 *distanceptr) { union soundnumhack sp5c; union soundnumhack sp58; diff --git a/src/game/room.c b/src/game/room.c index 51e889ac8..8ee216e86 100644 --- a/src/game/room.c +++ b/src/game/room.c @@ -47,8 +47,8 @@ */ u8 *g_RoomMtxAges; -s16 *g_RoomMtxLinkedRooms; -s16 *g_RoomMtxBaseRooms; +RoomNum *g_RoomMtxLinkedRooms; +RoomNum *g_RoomMtxBaseRooms; f32 *g_RoomMtxScales; Mtxf *g_RoomMtxMatrices; diff --git a/src/game/roomreset.c b/src/game/roomreset.c index dd5ab8c01..d02e12820 100644 --- a/src/game/roomreset.c +++ b/src/game/roomreset.c @@ -15,10 +15,10 @@ void roomsReset(void) g_RoomMtxNumSlots = PLAYERCOUNT() >= 2 ? 200 : 120; g_RoomMtxAges = mempAlloc(ALIGN16(g_RoomMtxNumSlots), MEMPOOL_STAGE); - g_RoomMtxLinkedRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(s16)), MEMPOOL_STAGE); - g_RoomMtxBaseRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(s16)), MEMPOOL_STAGE); - g_RoomMtxScales = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(f32)), MEMPOOL_STAGE); - g_RoomMtxMatrices = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(Mtxf)), MEMPOOL_STAGE); + g_RoomMtxLinkedRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxLinkedRooms)), MEMPOOL_STAGE); + g_RoomMtxBaseRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxBaseRooms)), MEMPOOL_STAGE); + g_RoomMtxScales = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxScales)), MEMPOOL_STAGE); + g_RoomMtxMatrices = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxMatrices)), MEMPOOL_STAGE); for (i = 0; i < PLAYERCOUNT(); i++) { g_Vars.players[i]->lastroomforoffset = -1; diff --git a/src/game/setup.c b/src/game/setup.c index fc8381b30..912284624 100644 --- a/src/game/setup.c +++ b/src/game/setup.c @@ -389,7 +389,7 @@ void setupCreateObject(struct defaultobj *obj, s32 cmdindex) struct coord centre; f32 scale; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; struct prop *prop2; u32 flag40; u32 stack; @@ -1084,7 +1084,7 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex) struct prop *prop; s32 siblingcmdindex; struct coord pos; - s16 rooms[8]; + RoomNum rooms[8]; Mtxf finalmtx; struct coord centre; Mtxf zrotmtx; @@ -1184,21 +1184,21 @@ void setupCreateDoor(struct doorobj *door, s32 cmdindex) void setupCreateHov(struct defaultobj *obj, struct hov *hov) { - hov->unk04 = 0; - hov->unk08 = 0; - hov->unk0c = 0; - hov->unk10 = atan2f(obj->realrot[2][0], obj->realrot[2][2]); - hov->unk14 = 0; - hov->unk18 = 0; - hov->unk1c = 0; - hov->unk20 = 0; - hov->unk24 = 0; - hov->unk28 = 0; - hov->unk2c = 0; - hov->unk30 = 0; + hov->bobycur = 0; + hov->bobytarget = 0; + hov->bobyspeed = 0; + hov->yrot = atan2f(obj->realrot[2][0], obj->realrot[2][2]); + hov->bobpitchcur = 0; + hov->bobpitchtarget = 0; + hov->bobpitchspeed = 0; + hov->bobrollcur = 0; + hov->bobrolltarget = 0; + hov->bobrollspeed = 0; + hov->groundpitch = 0; + hov->y = 0; hov->ground = 0; - hov->nexttick60 = -1; - hov->prevtick60 = -1; + hov->prevframe60 = -1; + hov->prevgroundframe60 = -1; } void setupLoadBriefing(s32 stagenum, u8 *buffer, s32 bufferlen, struct briefing *briefing) diff --git a/src/game/setupcover.c b/src/game/setupcover.c index d03a0cb44..5b446c12a 100644 --- a/src/game/setupcover.c +++ b/src/game/setupcover.c @@ -13,7 +13,7 @@ void coverAllocateSpecial(u16 *specialcovernums) { s32 i; - g_SpecialCoverNums = mempAlloc(ALIGN16(g_NumSpecialCovers * sizeof(u16)), MEMPOOL_STAGE); + g_SpecialCoverNums = mempAlloc(ALIGN16(g_NumSpecialCovers * sizeof(g_SpecialCoverNums[0])), MEMPOOL_STAGE); if (g_SpecialCoverNums != NULL) { for (i = 0; i < g_NumSpecialCovers; i++) { @@ -26,17 +26,17 @@ void setupPrepareCover(void) { s32 i; s32 numcovers = g_PadsFile->numcovers; - s16 *roomsptr; + RoomNum *roomsptr; f32 scale = 1; struct coord aimpos; struct cover cover; u16 specialcovernums[1024]; - s16 inrooms[21]; - s16 aboverooms[21]; + RoomNum inrooms[21]; + RoomNum aboverooms[21]; - g_CoverFlags = mempAlloc(ALIGN16(numcovers * sizeof(u16)), MEMPOOL_STAGE); - g_CoverRooms = mempAlloc(ALIGN16(numcovers * sizeof(s32)), MEMPOOL_STAGE); - g_CoverCandidates = mempAlloc(ALIGN16(numcovers * 0x10), MEMPOOL_STAGE); + g_CoverFlags = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverFlags[0])), MEMPOOL_STAGE); + g_CoverRooms = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverRooms[0])), MEMPOOL_STAGE); + g_CoverCandidates = mempAlloc(ALIGN16(numcovers * sizeof(g_CoverCandidates[0])), MEMPOOL_STAGE); g_NumSpecialCovers = 0; g_SpecialCoverNums = NULL; @@ -80,7 +80,7 @@ void setupPrepareCover(void) s32 room = cdFindFloorRoomAtPos(cover.pos, roomsptr); if (room > 0) { - g_CoverRooms[i] = (s16)room; + g_CoverRooms[i] = (RoomNum)room; } else { g_CoverRooms[i] = roomsptr[0]; } @@ -106,7 +106,7 @@ void setupPrepareCover(void) s32 aimroom = cdFindFloorRoomAtPos(&aimpos, roomsptr); if (aimroom > 0) { - g_CoverFlags[i] |= (g_CoverRooms[i] == (s16)aimroom) ? COVERFLAG_AIMSAMEROOM : COVERFLAG_AIMDIFFROOM; + g_CoverFlags[i] |= (g_CoverRooms[i] == (RoomNum)aimroom) ? COVERFLAG_AIMSAMEROOM : COVERFLAG_AIMDIFFROOM; } else { g_CoverFlags[i] |= (g_CoverRooms[i] == roomsptr[0]) ? COVERFLAG_AIMSAMEROOM : COVERFLAG_AIMDIFFROOM; } diff --git a/src/game/setuppads.c b/src/game/setuppads.c index d4f4a9a8f..9e629fdad 100644 --- a/src/game/setuppads.c +++ b/src/game/setuppads.c @@ -28,15 +28,15 @@ void setupPreparePads(void) { struct packedpad *packedpad; - s16 *roomsptr; + RoomNum *roomsptr; s32 padnum; s32 numpads; s32 roomnum; struct pad pad; struct waypoint *waypoint; struct waygroup *waygroup; - s16 inrooms[24]; - s16 aboverooms[22]; + RoomNum inrooms[24]; + RoomNum aboverooms[22]; s32 offset; g_PadsFile = (struct padsfileheader *)g_StageSetup.padfiledata; diff --git a/src/game/setuputils.c b/src/game/setuputils.c index f1b210d53..93b38933a 100644 --- a/src/game/setuputils.c +++ b/src/game/setuputils.c @@ -187,7 +187,7 @@ bool setup0f092304(struct defaultobj *obj, struct coord *arg1, struct coord *arg return setupGetObjBbox(obj, &obj->prop->pos, obj->realrot, arg1, arg2); } -void setup0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], s16 *rooms) +void setup0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], RoomNum *rooms) { struct coord a; struct coord b; diff --git a/src/game/shards.c b/src/game/shards.c index 48a070d97..729579654 100644 --- a/src/game/shards.c +++ b/src/game/shards.c @@ -19,7 +19,7 @@ struct shard *g_Shards; s32 g_NextShardNum = 0; bool g_ShardsActive = false; -void shardCreate(s16 room, struct coord *pos, f32 rotx, f32 size, s32 type); +void shardCreate(RoomNum room, struct coord *pos, f32 rotx, f32 size, s32 type); void shardsCreate(struct coord *pos, f32 *rotx, f32 *roty, f32 *rotz, f32 relxmin, f32 relxmax, f32 relymin, f32 relymax, s32 type, struct prop *prop) { @@ -111,7 +111,7 @@ void shardsCreate(struct coord *pos, f32 *rotx, f32 *roty, f32 *rotz, f32 relxmi } } -void shardCreate(s16 room, struct coord *pos, f32 rotx, f32 size, s32 type) +void shardCreate(RoomNum room, struct coord *pos, f32 rotx, f32 size, s32 type) { f32 velx = RANDOMFRAC() * 2.0f - 1.0f; f32 vely = RANDOMFRAC() * 1.12f - 0.12f; @@ -211,7 +211,7 @@ void shardCreate(s16 room, struct coord *pos, f32 rotx, f32 size, s32 type) Gfx *shardsRenderWood(Gfx *gdl) { if (g_ShardsActive) { - s16 prevroom = 0; + RoomNum prevroom = 0; s32 i; Mtxf shardmtx; s32 j; @@ -325,7 +325,7 @@ Gfx *shardsRenderWood(Gfx *gdl) Gfx *shardsRenderGlass(Gfx *gdl) { if (g_ShardsActive) { - s16 prevroom = 0; + RoomNum prevroom = 0; s32 i; Mtxf shardmtx; s32 j; diff --git a/src/game/smoke.c b/src/game/smoke.c index af2439db1..edc7d5e37 100644 --- a/src/game/smoke.c +++ b/src/game/smoke.c @@ -261,7 +261,7 @@ Gfx *smokeRenderPart(struct smoke *smoke, struct smokepart *part, Gfx *gdl, stru return gdl; } -struct smoke *smokeCreate(struct coord *pos, s16 *rooms, s16 type) +struct smoke *smokeCreate(struct coord *pos, RoomNum *rooms, s16 type) { struct smoke *smoke = NULL; s32 playercount = PLAYERCOUNT(); @@ -326,7 +326,7 @@ struct smoke *smokeCreate(struct coord *pos, s16 *rooms, s16 type) return smoke; } -bool smokeCreateForHand(struct coord *pos, s16 *rooms, s16 type, s32 handnum) +bool smokeCreateForHand(struct coord *pos, RoomNum *rooms, s16 type, s32 handnum) { struct smoke *smoke; s32 i; @@ -368,7 +368,7 @@ bool smokeCreateForHand(struct coord *pos, s16 *rooms, s16 type, s32 handnum) * smoke parts have a size of zero. Perhaps the caller is supposed to check if * this function returns false and reuse the zero-sized smoke parts if so? */ -bool smokeCreateWithSource(void *source, struct coord *pos, s16 *rooms, s16 type, bool srcispadeffect) +bool smokeCreateWithSource(void *source, struct coord *pos, RoomNum *rooms, s16 type, bool srcispadeffect) { struct smoke *smoke; s32 i; @@ -415,7 +415,7 @@ void smokeCreateAtProp(struct prop *prop, s16 type) smokeCreateWithSource(prop, &prop->pos, prop->rooms, type, false); } -void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, s16 *rooms, s16 type) +void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, RoomNum *rooms, s16 type) { smokeCreateWithSource(effect, pos, rooms, type, true); } @@ -432,7 +432,7 @@ void smokeClearForProp(struct prop *prop) } } -struct smoke *smokeCreateSimple(struct coord *pos, s16 *rooms, s16 type) +struct smoke *smokeCreateSimple(struct coord *pos, RoomNum *rooms, s16 type) { return smokeCreate(pos, rooms, type); } diff --git a/src/game/splat.c b/src/game/splat.c index 41e41146e..15079869a 100644 --- a/src/game/splat.c +++ b/src/game/splat.c @@ -245,9 +245,9 @@ bool splat0f149274(f32 arg0, struct prop *chrprop, struct shotdata *shotdata, f3 struct prop *objprop; struct hitthing hitthing; struct hitthing besthitthing; - s16 rooms[32]; - s16 gunrooms[8]; - s16 endrooms[8]; + RoomNum rooms[32]; + RoomNum gunrooms[8]; + RoomNum endrooms[8]; struct coord endpos; s32 i; struct coord *sp50c; @@ -422,7 +422,7 @@ void splat0f14986c(struct splatdata *splat) bool sp84 = splat->isskedar & 1; bool translucent = splat->translucent; f32 distance; - s16 smokerooms[2]; + RoomNum smokerooms[2]; texnum = WALLHITTEX_BLOOD1 + (random() % 3); diff --git a/src/game/title.c b/src/game/title.c index 606277e91..21a601153 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -532,10 +532,10 @@ void titleInitPdLogo(void) { struct coord coord = {0, 0, 0}; - g_ModelStates[MODEL_NLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NLOGO].fileid, nextaddr, 0x47800, 0); + g_ModelStates[MODEL_NLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NLOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0); size = ALIGN64(fileGetLoadedSize(g_ModelStates[MODEL_NLOGO].fileid)); nextaddr += size; - remaining = 0x47800 - size; + remaining = TITLE_ALLOCSIZE - size; modelAllocateRwData(g_ModelStates[MODEL_NLOGO].modeldef); g_TitleModel = modelmgrInstantiateModelWithAnim(g_ModelStates[MODEL_NLOGO].modeldef); @@ -1782,7 +1782,7 @@ void titleInitNintendoLogo(void) { struct coord coord = {0, 0, 0}; - g_ModelStates[MODEL_NINTENDOLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NINTENDOLOGO].fileid, nextaddr, 0x47800, 0); + g_ModelStates[MODEL_NINTENDOLOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_NINTENDOLOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0); modelAllocateRwData(g_ModelStates[MODEL_NINTENDOLOGO].modeldef); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_NINTENDOLOGO].modeldef); @@ -1941,7 +1941,7 @@ void titleInitRareLogo(void) { struct coord coord = {0, 0, 0}; - g_ModelStates[MODEL_RARELOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_RARELOGO].fileid, nextaddr, 0x47800, 0); + g_ModelStates[MODEL_RARELOGO].modeldef = modeldefLoad(g_ModelStates[MODEL_RARELOGO].fileid, nextaddr, TITLE_ALLOCSIZE, 0); modelAllocateRwData(g_ModelStates[MODEL_RARELOGO].modeldef); g_TitleModel = modelmgrInstantiateModelWithoutAnim(g_ModelStates[MODEL_RARELOGO].modeldef); diff --git a/src/game/titlereset.c b/src/game/titlereset.c index 77e57ee9c..1144943ec 100644 --- a/src/game/titlereset.c +++ b/src/game/titlereset.c @@ -21,7 +21,7 @@ void titleReset(void) g_TitleNextMode = TITLEMODE_SKIP; } - var8009cca0 = mempAlloc(0x47800, MEMPOOL_STAGE); + var8009cca0 = mempAlloc(TITLE_ALLOCSIZE, MEMPOOL_STAGE); getitleReset(); } diff --git a/src/game/training.c b/src/game/training.c index edfc1feed..157ff84fb 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -1248,9 +1248,9 @@ void frEndSession(bool hidetargets) s32 j; s16 propnums[256]; s16 *propnumptr; - s16 rooms[20]; + RoomNum rooms[20]; u32 stack1; - s16 rooms2[10]; + RoomNum rooms2[10]; u32 stack2; if (g_FrDataLoaded) { @@ -1507,8 +1507,8 @@ bool frIsAmmoWasted(void) s32 ammototal[2]; s16 *propnumptr; s16 propnums[258]; - s16 rooms20[22]; - s16 rooms10[12]; + RoomNum rooms20[22]; + RoomNum rooms10[12]; u32 stack[4]; s32 ammotype; struct hand *hand; @@ -3144,7 +3144,7 @@ void htEnd(void) struct prop *prop; s16 *propnum; s16 propnums[256]; - s16 rooms[5] = { 0x0016, 0x0017, 0x0018, 0x0019, -1 }; + RoomNum rooms[5] = { 0x0016, 0x0017, 0x0018, 0x0019, -1 }; struct waypoint *waypoints = g_StageSetup.waypoints; g_HtData.intraining = false; diff --git a/src/game/wallhit.c b/src/game/wallhit.c index c5e244369..393dbb1b1 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -633,7 +633,7 @@ const char var7f1b5c44[] = ""; const char var7f1b5c48[] = ""; void wallhitCreate(struct coord *relpos, struct coord *arg1, struct coord *arg2, s16 arg3[3], - s16 arg4[3], s16 texnum, s16 room, struct prop *objprop, + s16 arg4[3], s16 texnum, RoomNum room, struct prop *objprop, s8 mtxindex, s8 arg9, struct chrdata *chr, bool xlu) { f32 scale = RANDOMFRAC() * 0.1f + 0.6f; @@ -648,7 +648,7 @@ void wallhitCreate(struct coord *relpos, struct coord *arg1, struct coord *arg2, } void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct coord *arg2, s16 arg3[3], - s16 arg4[3], s16 texnum, s16 room, struct prop *objprop, + s16 arg4[3], s16 texnum, RoomNum room, struct prop *objprop, struct prop *chrprop, s8 mtxindex, s8 arg10, struct chrdata *chr, f32 width, f32 height, u8 minalpha, u8 maxalpha, s32 rotdeg, u32 timermax, u32 timerspeed, bool xlu) diff --git a/src/game/weather.c b/src/game/weather.c index 0ddb66a1d..cc2458d89 100644 --- a/src/game/weather.c +++ b/src/game/weather.c @@ -856,7 +856,7 @@ Gfx *weatherRenderRain(Gfx *gdl, struct weatherdata *weather, s32 arg2) u32 stack2; struct coord distcamtobbmax; struct coord distcamtobbmin; - s16 neighbours[20]; + RoomNum neighbours[20]; particledata = weather->particledata[arg2]; numtris = 0; @@ -2872,7 +2872,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) s32 i; // 184 struct coord sp178; struct coord sp16c; - s16 sp144[20]; + RoomNum sp144[20]; struct coord sp124; struct coord sp118; f32 f26; diff --git a/src/include/bss.h b/src/include/bss.h index 1791c1c93..67eb234e9 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -232,8 +232,8 @@ extern bool g_FogEnabled; extern bool g_EnvHasTransparency; extern struct distfadesettings *g_EnvDistFadeSettingsPtr; extern u8 *g_RoomMtxAges; -extern s16 *g_RoomMtxLinkedRooms; -extern s16 *g_RoomMtxBaseRooms; +extern RoomNum *g_RoomMtxLinkedRooms; +extern RoomNum *g_RoomMtxBaseRooms; extern f32 *g_RoomMtxScales; extern Mtxf *g_RoomMtxMatrices; extern struct fileinfo g_FileInfo[NUM_FILES]; diff --git a/src/include/commands.h b/src/include/commands.h index a7c6eab38..17682d823 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -4334,11 +4334,11 @@ * Gets the distance from chr to pad, but only if they are on the same floor * (ie. Y difference is less than 150). */ -#define if_chr_same_floor_distance_to_pad_lt(chr, pad, distance, label) \ +#define if_chr_same_floor_distance_to_pad_lt(chr, distance, pad, label) \ mkshort(0x01df), \ chr, \ - mkshort(pad), \ mkshort(distance / 10), \ + mkshort(pad), \ label, /** diff --git a/src/include/constants.h b/src/include/constants.h index ef0efb033..3a8e7ea97 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1347,6 +1347,9 @@ #define HATTYPE_METAL 3 #define HATTYPE_CLOTH 5 +#define HEADANIM_RESTING 0 +#define HEADANIM_MOVING 1 + #define HEADBODYTYPE_DEFAULT 0 #define HEADBODYTYPE_FEMALE 1 #define HEADBODYTYPE_FEMALEGUARD 2 @@ -1382,6 +1385,8 @@ #define HITPART_GENERAL 200 #define HITPART_GENERALHALF 201 +#define HOVFLAG_FIRSTTICK 1 + #define HOVTYPE_BED 0 #define HOVTYPE_BIKE 1 #define HOVTYPE_CRATE 2 @@ -3264,33 +3269,57 @@ #define PADFLAG_AIDUCK 0x10000 #define PADFLAG_AIBOTINUSE 0x20000 -#define PAK010_00 0 -#define PAK010_01 1 -#define PAK010_02 2 -#define PAK010_03 3 -#define PAK010_04 4 -#define PAK010_05 5 -#define PAK010_06 6 -#define PAK010_07 7 -#define PAK010_08 8 -#define PAK010_09 9 -#define PAK010_10 10 -#define PAK010_11 11 -#define PAK010_12 12 -#define PAK010_13 13 -#define PAK010_14 14 -#define PAK010_15 15 -#define PAK010_16 16 -#define PAK010_17 17 -#define PAK010_18 18 -#define PAK010_19 19 -#define PAK010_20 20 -#define PAK010_21 21 -#define PAK010_22 22 -#define PAK010_24 24 -#define PAK010_25 25 -#define PAK010_26 26 -#define PAK010_27 27 +#define PAK008_00 0 +#define PAK008_01 1 +#define PAK008_02 2 +#define PAK008_03 3 +#define PAK008_04 4 +#define PAK008_05 5 +#define PAK008_06 6 +#define PAK008_07 7 +#define PAK008_08 8 +#define PAK008_09 9 +#define PAK008_11 11 +#define PAK008_12 12 + +#define PAK00C_00 0 +#define PAK00C_01 1 +#define PAK00C_02 2 +#define PAK00C_03 3 + +#define PAKERRORDIALOG_FULL 0 +#define PAKERRORDIALOG_CORRUPT 1 +#define PAKERRORDIALOG_DEVICEERROR 2 +#define PAKERRORDIALOG_GB_UNREADABLE 3 +#define PAKERRORDIALOG_DATALOST 4 + +#define PAKSTATE_NOPAK 0 +#define PAKSTATE_UNPLUGGING 1 +#define PAKSTATE_PROBE 2 +#define PAKSTATE_MEM_DISPATCH 3 +#define PAKSTATE_MEM_PRE_PREPARE 4 +#define PAKSTATE_MEM_PREPARE 5 +#define PAKSTATE_MEM_POST_PREPARE 6 +#define PAKSTATE_07 7 +#define PAKSTATE_GB_PRE_PREPARE 8 +#define PAKSTATE_GB_PREPARE 9 +#define PAKSTATE_GB_POST_PREPARE1 10 +#define PAKSTATE_READY 11 +#define PAKSTATE_12 12 +#define PAKSTATE_13 13 +#define PAKSTATE_MEM_ENTER_DEVICEERROR 14 +#define PAKSTATE_MEM_ENTER_CORRUPT 15 +#define PAKSTATE_MEM_ENTER_FULL 16 +#define PAKSTATE_17 17 +#define PAKSTATE_18 18 +#define PAKSTATE_MEM_DEVICEERROR 19 +#define PAKSTATE_MEM_CORRUPT 20 +#define PAKSTATE_MEM_FULL 21 +#define PAKSTATE_22 22 +#define PAKSTATE_GB_POST_PREPARE2 24 +#define PAKSTATE_GB_POST_PREPARE3 25 +#define PAKSTATE_GB_OPEN_UNREADABLE 26 +#define PAKSTATE_GB_IDLE_UNREADABLE 27 #define PAK_ERR1_OK 0 #define PAK_ERR1_NOPAK PFS_ERR_NOPACK /* no memory card is plugged */ diff --git a/src/include/data.h b/src/include/data.h index 9c9e9126a..6c6637b4b 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -46,7 +46,7 @@ extern s32 g_SoundMode; extern s32 g_SndNumPlaying; extern struct audiorussmapping g_AudioRussMappings[]; extern struct audioconfig g_AudioConfigs[]; -extern bool var8005eedc; +extern bool g_JoyPfsPollMasterEnabled; extern f32 var8005ef10[2]; extern s32 g_NumGlobalAilists; extern s32 g_NumLvAilists; @@ -310,7 +310,7 @@ extern struct menudialogdef g_MpEditSimulant4MbMenuDialog; extern struct menudialogdef g_AdvancedSetup4MbMenuDialog; extern struct filelist *g_FileLists[MAX_PLAYERS]; extern bool var80075bd0[]; -extern struct var80075c00 var80075c00[]; +extern struct headanim g_HeadAnims[2]; extern s32 var80075d60; extern s32 var80075d64; extern s32 var80075d68; diff --git a/src/include/game/bg.h b/src/include/game/bg.h index cb3cd068d..0ac8645ca 100644 --- a/src/include/game/bg.h +++ b/src/include/game/bg.h @@ -72,25 +72,25 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a s32 bg0f1612e4(struct coord *bbmin, struct coord *bbmax, struct coord *frompos, struct coord *dist, struct coord *arg4, struct coord *arg5); bool bgTestHitInRoom(struct coord *frompos, struct coord *topos, s32 roomnum, struct hitthing *hitthing); bool bgRoomIsLoaded(s32 room); -bool bgRoomContainsCoord(struct coord *pos, s16 roomnum); -bool bgTestPosInRoomCheap(struct coord *pos, s16 roomnum); -bool bgTestPosInRoomExpensive(struct coord *pos, s16 roomnum); -bool bgTestPosInRoom(struct coord *pos, s16 roomnum); -void bgFindRoomsByPos(struct coord *pos, s16 *inrooms, s16 *aboverooms, s32 max, s16 *bestroom); +bool bgRoomContainsCoord(struct coord *pos, RoomNum roomnum); +bool bgTestPosInRoomCheap(struct coord *pos, RoomNum roomnum); +bool bgTestPosInRoomExpensive(struct coord *pos, RoomNum roomnum); +bool bgTestPosInRoom(struct coord *pos, RoomNum roomnum); +void bgFindRoomsByPos(struct coord *pos, RoomNum *inrooms, RoomNum *aboverooms, s32 max, RoomNum *bestroom); bool bgCmdPushValue(bool value); bool bgCmdPopValue(void); bool bgCmdGetNthValueFromEnd(s32 offset); struct bgcmd *bgCmdExecuteBranch(struct bgcmd *cmd, bool s2); struct bgcmd *bgCmdExecute(struct bgcmd *cmd); void bgTickPortalsXray(void); -void bgAddToSnake(s16 fromroomnum, s16 roomnum, s16 draworder, struct screenbox *box); +void bgAddToSnake(RoomNum fromroomnum, RoomNum roomnum, s16 draworder, struct screenbox *box); void bgConsumeSnakeItem(struct bgsnakeitem *arg0); bool bgTryConsumeSnake(void); void bgChooseRoomsToLoad(void); void bgTickPortals(void); Gfx *bgRenderSceneAndLoadCandidate(Gfx *gdl); -s32 bgGetForceOnscreenRooms(s16 *rooms, s32 len); -s32 bgRoomGetNeighbours(s32 room, s16 *rooms, s32 len); +s32 bgGetForceOnscreenRooms(RoomNum *rooms, s32 len); +s32 bgRoomGetNeighbours(s32 room, RoomNum *rooms, s32 len); bool bgRoomsAreNeighbours(s32 roomnum1, s32 roomnum2); void bgCalculateScreenProperties(void); void bgExpandRoomToPortals(s32 roomnum); @@ -101,6 +101,6 @@ void bgSetPortalOpenState(s32 portal, bool open); s32 bgFindPortalBetweenPositions(struct coord *pos1, struct coord *pos2); bool bgIsBboxOverlapping(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct coord *arg3); void bgCalculatePortalBbox(s32 portalnum, struct coord *bbmin, struct coord *bbmax); -void bgFindEnteredRooms(struct coord *bbmin, struct coord *upper, s16 *rooms, s32 maxlen, bool arg4); +void bgFindEnteredRooms(struct coord *bbmin, struct coord *upper, RoomNum *rooms, s32 maxlen, bool arg4); #endif diff --git a/src/include/game/body.h b/src/include/game/body.h index e913574ef..4cc36931c 100644 --- a/src/include/game/body.h +++ b/src/include/game/body.h @@ -16,7 +16,7 @@ struct model *bodyAllocateModel(s32 bodynum, s32 headnum, u32 spawnflags); s32 body0f02d3f8(void); s32 bodyChooseHead(s32 bodynum); void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex); -struct prop *bodyAllocateEyespy(struct pad *pad, s16 room); +struct prop *bodyAllocateEyespy(struct pad *pad, RoomNum room); void bodyCalculateHeadOffset(struct modeldef *headmodeldef, s32 headnum, s32 bodynum); #endif diff --git a/src/include/game/bondeyespy.h b/src/include/game/bondeyespy.h index f3af79691..033893c17 100644 --- a/src/include/game/bondeyespy.h +++ b/src/include/game/bondeyespy.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -f32 eyespyFindGround(s16 *floorroom); +f32 eyespyFindGround(RoomNum *floorroom); s32 eyespyTryMoveUpwards(f32 yvel); s32 eyespyCalculateNewPosition(struct coord *vel); bool eyespyCalculateNewPositionWithPush(struct coord *vel); diff --git a/src/include/game/bondgun.h b/src/include/game/bondgun.h index 1e753a449..e704cdcad 100644 --- a/src/include/game/bondgun.h +++ b/src/include/game/bondgun.h @@ -73,9 +73,9 @@ void bgunTickMasterLoad(void); void bgunTickLoad(void); bool bgunLoadAll(void); struct modeldef *bgunGetCartModeldef(void); -void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos); +void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, RoomNum *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos); void bgun0f09ed2c(struct defaultobj *obj, struct coord *coord, Mtxf *arg2, struct coord *velocity, Mtxf *arg4); -struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *velocity); +struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, RoomNum *rooms, Mtxf *arg4, struct coord *velocity); void bgunCreateThrownProjectile(s32 handnum, struct gset *gset); void bgunUpdateHeldRocket(s32 handnum); void bgunCreateHeldRocket(s32 handnum, struct weaponfunc_shootprojectile *func); @@ -142,8 +142,8 @@ s32 bgunAllocateFireslot(void); void bgunRender(Gfx **gdl); struct sndstate **bgunAllocateAudioHandle(void); void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum); -void bgunPlayGlassHitSound(struct coord *pos, s16 *rooms, s32 texturenum); -void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, s16 *rooms); +void bgunPlayGlassHitSound(struct coord *pos, RoomNum *rooms, s32 texturenum); +void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum, RoomNum *rooms); void bgunSetTriggerOn(s32 handnum, bool on); s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu); void bgun0f0a8c50(void); diff --git a/src/include/game/bondhead.h b/src/include/game/bondhead.h index 270cb2dce..a1adcbc62 100644 --- a/src/include/game/bondhead.h +++ b/src/include/game/bondhead.h @@ -10,7 +10,7 @@ void bheadFlipAnimation(void); void bheadUpdateIdleRoll(void); void bheadUpdatePos(struct coord *vel); void bheadUpdateRot(struct coord *lookvel, struct coord *upvel); -void bheadSetdamp(f32 headdamp); +void bheadSetDamp(f32 headdamp); void bheadUpdate(f32 arg0, f32 arg1); void bheadAdjustAnimation(f32 speed); void bheadStartDeathAnimation(s16 animnum, u32 flip, f32 fstarttime, f32 speed); diff --git a/src/include/game/bondmove.h b/src/include/game/bondmove.h index 378ab167c..7733b613f 100644 --- a/src/include/game/bondmove.h +++ b/src/include/game/bondmove.h @@ -30,8 +30,8 @@ void bmoveUpdateSpeedThetaControl(f32 value); f32 bmoveCalculateLookahead(void); void bmoveResetMoveData(struct movedata *data); void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool ignorec2); -void bmoveFindEnteredRoomsByPos(struct player *player, struct coord *arg1, s16 *rooms); -void bmoveFindEnteredRooms(struct player *player, s16 *rooms); +void bmoveFindEnteredRoomsByPos(struct player *player, struct coord *arg1, RoomNum *rooms); +void bmoveFindEnteredRooms(struct player *player, RoomNum *rooms); void bmoveUpdateRooms(struct player *player); void bmove0f0cb904(struct coord *coord); void bmove0f0cba88(f32 *a, f32 *b, struct coord *c, f32 mult1, f32 mult2); diff --git a/src/include/game/bot.h b/src/include/game/bot.h index 4e188c48e..729822a04 100644 --- a/src/include/game/bot.h +++ b/src/include/game/bot.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -bool botroomFindPos(s16 room, struct coord *pos, f32 *angleptr, s32 *padnumptr, s32 *covernumptr); +bool botroomFindPos(RoomNum room, struct coord *pos, f32 *angleptr, s32 *padnumptr, s32 *covernumptr); bool botIsDizzy(struct chrdata *chr); void botReset(struct chrdata *chr, u8 respawning); @@ -45,8 +45,8 @@ char *botGetCommandName(s32 command); void botApplyAttack(struct chrdata *chr, struct prop *prop); void botApplyFollow(struct chrdata *chr, struct prop *prop); void botApplyProtect(struct chrdata *chr, struct prop *prop); -void botApplyDefend(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle); -void botApplyHold(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle); +void botApplyDefend(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle); +void botApplyHold(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle); void botApplyScenarioCommand(struct chrdata *chr, u32 arg1); bool botCanFollow(struct chrdata *leader, struct chrdata *follower); s32 botFindTeammateToFollow(struct chrdata *chr, f32 range); diff --git a/src/include/game/botact.h b/src/include/game/botact.h index 801b20c6d..4b91ac0d4 100644 --- a/src/include/game/botact.h +++ b/src/include/game/botact.h @@ -18,7 +18,7 @@ u32 botactGetProjectileThrowInterval(u32 weapon); s32 botactGetWeaponByAmmoType(s32 ammotype); void botactThrow(struct chrdata *chr); s32 botactGetShootInterval60(s32 weaponnum, s32 funcnum); -bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct coord *topos, s16 *fromrooms, s16 *torooms, struct projectile *projectile); +bool botactFindRocketRoute(struct chrdata *chr, struct coord *frompos, struct coord *topos, RoomNum *fromrooms, RoomNum *torooms, struct projectile *projectile); void botactGetRocketNextStepPos(u16 padnum, struct coord *pos); void botactCreateSlayerRocket(struct chrdata *chr); diff --git a/src/include/game/camera.h b/src/include/game/camera.h index 725ea06c8..f8dd37acf 100644 --- a/src/include/game/camera.h +++ b/src/include/game/camera.h @@ -43,6 +43,6 @@ f32 camGetPerspAspect(void); void cam0f0b5838(void); bool cam0f0b5b9c(struct coord *arg0, f32 arg1); bool camIsPosInScreenBox(struct coord *pos, f32 arg1, struct drawslot *drawslot); -bool camIsPosInFovAndVisibleRoom(s16 *rooms, struct coord *pos, f32 arg2); +bool camIsPosInFovAndVisibleRoom(RoomNum *rooms, struct coord *pos, f32 arg2); #endif diff --git a/src/include/game/chr.h b/src/include/game/chr.h index 41b7654cd..151da2705 100644 --- a/src/include/game/chr.h +++ b/src/include/game/chr.h @@ -6,24 +6,24 @@ void chrSetChrnum(struct chrdata *chr, s16 chrnum); void chrDeregister(s32 chrnum); -void chrCalculatePushPos(struct chrdata *chr, struct coord *pos, s16 *rooms, bool arg3); +void chrCalculatePushPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, bool arg3); #if VERSION >= VERSION_NTSC_1_0 -bool chr0f01f264(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 arg3, bool arg4); +bool chr0f01f264(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 arg3, bool arg4); #else -bool chr0f01f264(struct chrdata *chr, struct coord *pos, s16 *rooms, f32 arg3); +bool chr0f01f264(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 arg3); #endif bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f32 *mangroundptr); s32 chrsGetNumFree(void); s16 chrsGetNextUnusedChrnum(void); -struct prop *chr0f020b14(struct prop *prop, struct model *model, struct coord *pos, s16 *rooms, f32 arg3, u8 *ailist); +struct prop *chr0f020b14(struct prop *prop, struct model *model, struct coord *pos, RoomNum *rooms, f32 arg3, u8 *ailist); void chrRemove(struct prop *prop, bool free); void chrUpdateAimProperties(struct chrdata *chr); void chrFlinchBody(struct chrdata *chr); void chrFlinchHead(struct chrdata *chr, f32 arg1); f32 chrGetFlinchAmount(struct chrdata *chr); -void chr0f021fa8(struct chrdata *chr, struct coord *pos, s16 *rooms); +void chr0f021fa8(struct chrdata *chr, struct coord *pos, RoomNum *rooms); void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2); void chr0f022214(struct chrdata *chr, struct prop *child, bool fulltick); void chrUpdateCloak(struct chrdata *chr); @@ -80,9 +80,9 @@ f32 chrGetMaxDamage(struct chrdata *chr); void chrAddHealth(struct chrdata *chr, f32 health); f32 chrGetArmor(struct chrdata *chr); void chrInit(struct prop *prop, u8 *ailist); -struct prop *chrAllocate(struct model *model, struct coord *pos, s16 *rooms, f32 faceangle, u8 *ailist); +struct prop *chrAllocate(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist); void chrClearReferences(s32 propnum); -void chr0f022084(struct chrdata *chr, s16 *room); +void chr0f022084(struct chrdata *chr, RoomNum *room); void chr0f0220ac(struct chrdata *chr); void chrCloak(struct chrdata *chr, bool arg1); void chrUncloak(struct chrdata *chr, bool value); diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index 982103e05..e981d0369 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -66,8 +66,8 @@ void chrDamageByImpact(struct chrdata *chr, f32 damage, struct coord *vector, st void chrDamageByExplosion(struct chrdata *chr, f32 damage, struct coord *vector, struct prop *prop, struct coord *explosionpos); void playerUpdateDamageStats(struct prop *attacker, struct prop *victim, f32 damage); void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *aprop, s32 hitpart, bool damageshield, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg11, bool explosion, struct coord *explosionpos); -bool func0f03645c(struct chrdata *chr, struct coord *arg1, s16 *arg2, struct coord *arg3, struct coord *arg4, s32 cdtypes); -bool func0f03654c(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, struct coord *vector, f32 arg6, u32 types); +bool func0f03645c(struct chrdata *chr, struct coord *arg1, RoomNum *arg2, struct coord *arg3, struct coord *arg4, s32 cdtypes); +bool func0f03654c(struct chrdata *chr, struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, struct coord *vector, f32 arg6, u32 types); bool propchrHasClearLineToPos(struct prop *prop, struct coord *dstpos, struct coord *vector); bool propchrHasClearLineInVector(struct prop *prop, struct coord *coord, f32 arg2); bool func0f036974(struct prop *prop, struct coord *coord); @@ -75,9 +75,9 @@ void chrGetSideVectorToTarget(struct chrdata *chr, bool side, struct coord *vect bool chrCanRollInDirection(struct chrdata *chr, bool toleft, f32 distance); void chrGetSideVector(struct chrdata *chr, bool side, struct coord *vector); bool chrCanJumpInDirection(struct chrdata *chr, bool side, f32 distance); -bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, s16 *wayrooms); +bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, RoomNum *wayrooms); void chrGoPosInitMagic(struct chrdata *chr, struct waydata *waydata, struct coord *arg2, struct coord *prevpos); -void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags); +void chrGoPosGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, RoomNum *rooms, u32 *flags); f32 func0f0370a8(struct chrdata *chr); s32 chrGoPosCalculateBaseTtl(struct chrdata *chr); void chrGoPosConsiderRestart(struct chrdata *chr); @@ -85,20 +85,20 @@ void chrGoPosInitExpensive(struct chrdata *chr); void chrGoPosAdvanceWaypoint(struct chrdata *chr); s32 chrPatrolCalculateStep(struct chrdata *chr, bool *forward, s32 numsteps); s16 chrPatrolCalculatePadNum(struct chrdata *chr, s32 numsteps); -void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 *flags); +void chrPatrolGetCurWaypointInfoWithFlags(struct chrdata *chr, struct coord *pos, RoomNum *rooms, u32 *flags); void func0f037580(struct chrdata *chr); void func0f0375b0(struct chrdata *chr); -void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, struct coord *arg3, s16 *rooms); +void chrNavTickMagic(struct chrdata *chr, struct waydata *waydata, f32 speed, struct coord *arg3, RoomNum *rooms); void chrCalculatePosition(struct chrdata *chr, struct coord *pos); void chrGoPosChooseAnimation(struct chrdata *chr); -bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, s16 *rooms, u32 goposflags); +bool chrGoToRoomPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, u32 goposflags); void chrPatrolChooseAnimation(struct chrdata *chr); void chrStartPatrol(struct chrdata *chr, struct path *path); -bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, bool allowextraheight, u32 attackflags, u32 entityid); -bool chrHasLosToAttackTarget(struct chrdata *chr, struct coord *pos, s16 *rooms, bool allowextraheight); -bool chrHasLosToChr(struct chrdata *chr, struct chrdata *target, s16 *room); -bool chrHasLosToPos(struct chrdata *viewerchr, struct coord *pos, s16 *rooms); -bool chrHasLosToPosWasteful(struct chrdata *chr, struct coord *pos, s16 *room); +bool chrHasLosToEntity(struct chrdata *chr, struct coord *chrpos, RoomNum *chrrooms, bool allowextraheight, u32 attackflags, u32 entityid); +bool chrHasLosToAttackTarget(struct chrdata *chr, struct coord *pos, RoomNum *rooms, bool allowextraheight); +bool chrHasLosToChr(struct chrdata *chr, struct chrdata *target, RoomNum *room); +bool chrHasLosToPos(struct chrdata *viewerchr, struct coord *pos, RoomNum *rooms); +bool chrHasLosToPosWasteful(struct chrdata *chr, struct coord *pos, RoomNum *room); bool chrHasLosToProp(struct chrdata *chr, struct prop *prop); bool chrIsStopped(struct chrdata *chr); bool chrCheckCanSeeTarget(struct chrdata *chr); @@ -166,8 +166,8 @@ bool posIsArrivingLaterallyAtPos(struct coord *prevpos, struct coord *curpos, st bool posIsArrivingAtPos(struct coord *prevpos, struct coord *curpos, struct coord *targetpos, f32 range); void chrTickRunPos(struct chrdata *chr); void func0f044b68(struct coord *arg0, struct coord *arg1, struct coord *arg2); -bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *pos, s16 *rooms, struct coord *aimpos, struct coord *arg4, struct coord *arg5, f32 negchrradius, f32 chrradius, s32 cdtypes, s32 arg9); -bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, s16 *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, bool hasobstacle); +bool chrNavCanSeeNextPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, struct coord *aimpos, struct coord *arg4, struct coord *arg5, f32 negchrradius, f32 chrradius, s32 cdtypes, s32 arg9); +bool chrNavCheckForObstacle(struct chrdata *chr, struct coord *chrpos, RoomNum *chrrooms, struct coord *aimpos, struct coord *leftpos, struct coord *rightpos, f32 negchrradius, f32 chrradius, s32 cdtypes, bool hasobstacle); bool chrNavTryObstacle(struct chrdata *chr, struct coord *arg1, bool arg2, struct coord *arg3, f32 radius, bool arg5, struct coord *nextpos, struct waydata *waydata, f32 arg8, s32 cdtypes, s32 arg10); struct prop *chrOpenDoor(struct chrdata *chr, struct coord *rangepos); void chrNavTickMain(struct chrdata *chr, struct coord *pos, struct waydata *waydata, bool arg3); @@ -181,7 +181,7 @@ void chraTick(struct chrdata *chr); void cutsceneStart(u32 ailistid); void chraTickBg(void); f32 chrGetAngleToPos(struct chrdata *chr, struct coord *pos); -void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, struct coord *pos, s16 *rooms); +void chrGetAttackEntityPos(struct chrdata *chr, u32 attackflags, s32 entityid, struct coord *pos, RoomNum *rooms); f32 chrGetAngleFromTargetsFov(struct chrdata *chr); f32 chrGetVerticalAngleToTarget(struct chrdata *chr); bool chrIsInTargetsFovX(struct chrdata *chr, u8 fov360); @@ -197,23 +197,23 @@ bool chrIsTargetAimingAtMe(struct chrdata *chr); bool chrSawInjury(struct chrdata *chr, u8 arg1); bool chrSawDeath(struct chrdata *chr, u8 arg1); bool waypointIsWithin90DegreesOfPosAngle(struct waypoint *waypoint, struct coord *pos, f32 angle); -s32 chrFindWaypointWithinPosQuadrant(struct coord *pos, s16 *rooms, f32 angle, u8 quadrant); +s32 chrFindWaypointWithinPosQuadrant(struct coord *pos, RoomNum *rooms, f32 angle, u8 quadrant); bool func0f04a4ec(struct chrdata *chr, u8 quadrant); bool chrSetPadPresetToWaypointWithinTargetQuadrant(struct chrdata *chr, u8 arg1); bool chrSetChrPresetToChrNearPad(u32 checktype, struct chrdata *chr, f32 distance, s32 padnum); -bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, s16 *room); +bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, RoomNum *room); bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr); -bool chrIsPosOffScreen(struct coord *pos, s16 *rooms); +bool chrIsPosOffScreen(struct coord *pos, RoomNum *rooms); #if VERSION >= VERSION_NTSC_1_0 -bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool force, bool onlysurrounding); +bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, RoomNum *rooms, f32 angle, bool allowonscreen, bool force, bool onlysurrounding); #else -bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool force); +bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, RoomNum *rooms, f32 angle, bool allowonscreen, bool force); #endif -struct prop *chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, s16 *room, f32 angle, u8 *ailist, u32 spawnflags); +struct prop *chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, RoomNum *room, f32 angle, u8 *ailist, u32 spawnflags); bool chrIsPropPresetBlockingSightToTarget(struct chrdata *chr); -bool chrMoveToPos(struct chrdata *chr, struct coord *pos, s16 *room, f32 angle, bool ignorebg); +bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle, bool ignorebg); bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft); s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 arg1, s32 arg2); s32 chrAssignCoverAwayFromDanger(struct chrdata *chr, s32 mindist, s32 maxdist); @@ -238,9 +238,9 @@ void chrRunToPos(struct chrdata *chr, struct coord *pos); void chrBeginDead(struct chrdata *chr); f32 chrGetShield(struct chrdata *chr); void chrDie(struct chrdata *chr, s32 aplayernum); -void chrGoPosGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, s16 *rooms); +void chrGoPosGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, RoomNum *rooms); void chrGoPosClearRestartTtl(struct chrdata *chr); -void chrPatrolGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, s16 *rooms); +void chrPatrolGetCurWaypointInfo(struct chrdata *chr, struct coord *pos, RoomNum *rooms); struct path *pathFindById(u32 path_id); void chrRecordLastVisibleTargetTime(struct chrdata *chr); bool chrHasLosToTarget(struct chrdata *chr); @@ -340,7 +340,7 @@ s16 *teamGetChrIds(s32 team_id); s16 *squadronGetChrIds(s32 squadron_id); void audioMarkAsRecentlyPlayed(s16 audioid); bool audioWasNotPlayedRecently(s16 audioid); -Gfx *chrsRenderChrStats(Gfx *gdl, s16 *rooms); +Gfx *chrsRenderChrStats(Gfx *gdl, RoomNum *rooms); void chrToggleModelPart(struct chrdata *chr, s32 partnum); bool chrIsAvoiding(struct chrdata *chr); void chrDrCarollEmitSparks(struct chrdata *chr); diff --git a/src/include/game/dlights.h b/src/include/game/dlights.h index 6829cad1b..a52b251ce 100644 --- a/src/include/game/dlights.h +++ b/src/include/game/dlights.h @@ -19,7 +19,7 @@ bool lightIsVulnerable(s32 roomnum, s32 lightnum); bool lightIsOn(s32 roomnum, s32 lightnum); void roomSetFlashBrightness(s32 roomnum, s32 value); void roomSetDefaults(struct room *room); -Gfx *lightsSetForRoom(Gfx *gdl, s16 roomnum); +Gfx *lightsSetForRoom(Gfx *gdl, RoomNum roomnum); Gfx *lightsSetDefault(Gfx *gdl); void roomInitLights(s32 roomnum); bool lightsHandleHit(struct coord *gunpos, struct coord *hitpos, s32 roomnum); diff --git a/src/include/game/dyntex.h b/src/include/game/dyntex.h index 150bb2226..f6c2cd952 100644 --- a/src/include/game/dyntex.h +++ b/src/include/game/dyntex.h @@ -7,7 +7,7 @@ void dyntexTickRoom(s32 roomnum, Vtx *vertices); void dyntexAddVertex(Vtx *vertex); void dyntexSetCurrentType(s16 type); -void dyntexSetCurrentRoom(s16 roomnum); +void dyntexSetCurrentRoom(RoomNum roomnum); void dyntexReset(void); bool dyntexHasRoom(void); diff --git a/src/include/game/explosions.h b/src/include/game/explosions.h index 84ae5cc8b..f6d15e212 100644 --- a/src/include/game/explosions.h +++ b/src/include/game/explosions.h @@ -8,13 +8,13 @@ void explosionsReset(void); void explosionsStop(void); -bool explosionCreateSimple(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum); -bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum); +bool explosionCreateSimple(struct prop *prop, struct coord *pos, RoomNum *rooms, s16 type, s32 playernum); +bool explosionCreateComplex(struct prop *prop, struct coord *pos, RoomNum *rooms, s16 type, s32 playernum); f32 explosionGetHorizontalRangeAtFrame(struct explosion *exp, s32 frame); f32 explosionGetVerticalRangeAtFrame(struct explosion *exp, s32 frame); void explosionGetBboxAtFrame(struct coord *lower, struct coord *upper, s32 frame, struct prop *prop); void explosionAlertChrs(f32 *radius, struct coord *noisepos); -bool explosionCreate(struct prop *prop, struct coord *pos, s16 *rooms, s16 type, s32 playernum, bool makescorch, struct coord *arg6, s16 room, struct coord *arg8); +bool explosionCreate(struct prop *prop, struct coord *pos, RoomNum *rooms, s16 type, s32 playernum, bool makescorch, struct coord *arg6, RoomNum room, struct coord *arg8); void explosionsUpdateShake(struct coord *arg0, struct coord *arg1, struct coord *arg2); bool explosionOverlapsProp(struct explosion *exp, struct prop *prop, struct coord *pos1, struct coord *pos2); void explosionInflictDamage(struct prop *prop); diff --git a/src/include/game/filelist.h b/src/include/game/filelist.h index 54760dc09..b22811613 100644 --- a/src/include/game/filelist.h +++ b/src/include/game/filelist.h @@ -8,7 +8,7 @@ void func0f110bf0(void); void func0f110bf8(void); void filelistCreate(s32 listnum, u8 filetype); s32 filelistFindOrCreate(u8 filetype); -void func0f110d90(s32 device); +void filelistInvalidatePak(s32 device); void filelistsTick(void); void filelistUpdate(struct filelist *list); diff --git a/src/include/game/menu.h b/src/include/game/menu.h index 5f8b6f90e..b4af1b93b 100644 --- a/src/include/game/menu.h +++ b/src/include/game/menu.h @@ -97,11 +97,11 @@ Gfx *menuRenderBackgroundLayer2(Gfx *gdl, u8 bg, f32 frac); Gfx *menuRender(Gfx *gdl); u32 menuChooseMusic(void); u32 menuGetRoot(void); -void func0f0fce8c(struct menudialogdef *dialogdef, s32 playernum, s32 arg2); +void menuPushPakDialogForPlayer(struct menudialogdef *dialogdef, s32 playernum, s32 arg2); char *menuTextSaveDeviceName(struct menuitem *item); -u32 func0f0fd118(u32 arg0); -bool func0f0fd1f4(s32 device, s32 arg1); -void func0f0fd320(s32 arg0, s32 arg1); +s32 menuPakNumToPlayerNum(s32 paknum); +bool menuIsReadyForPakError(s32 device, s32 arg1); +void menuPushPakErrorDialog(s32 arg0, s32 arg1); void func0f0fd494(struct coord *pos); void func0f0fd548(s32 arg0); struct menudialog *menuIsDialogOpen(struct menudialogdef *dialogdef); diff --git a/src/include/game/mplayer/scenarios.h b/src/include/game/mplayer/scenarios.h index d47594e0f..a04f0d021 100644 --- a/src/include/game/mplayer/scenarios.h +++ b/src/include/game/mplayer/scenarios.h @@ -26,8 +26,8 @@ void scenarioTick(void); void scenarioTickChr(struct chrdata *chr); Gfx *scenarioRadarExtra(Gfx *gdl); bool scenarioRadarChr(Gfx **gdl, struct prop *prop); -f32 scenarioChooseSpawnLocation(f32 chrradius, struct coord *pos, s16 *rooms, struct prop *prop); +f32 scenarioChooseSpawnLocation(f32 chrradius, struct coord *pos, RoomNum *rooms, struct prop *prop); s32 scenarioGetMaxTeams(void); -void scenarioHighlightRoom(s16 room, s32 *arg1, s32 *arg2, s32 *arg3); +void scenarioHighlightRoom(RoomNum room, s32 *arg1, s32 *arg2, s32 *arg3); #endif diff --git a/src/include/game/mplayer/setup.h b/src/include/game/mplayer/setup.h index b8c21972a..00d42360b 100644 --- a/src/include/game/mplayer/setup.h +++ b/src/include/game/mplayer/setup.h @@ -81,11 +81,11 @@ Gfx *htbRenderHud(Gfx *gdl); void ctcInitProps(void); bool ctcHighlightProp(struct prop *prop, s32 *colour); void ctcAddPad(s32 *cmd); -void ctcHighlightRoom(s16 roomnum, s32 *arg1, s32 *arg2, s32 *arg3); +void ctcHighlightRoom(RoomNum roomnum, s32 *arg1, s32 *arg2, s32 *arg3); void kohTick(void); Gfx *kohRenderHud(Gfx *gdl); void kohAddHill(s32 *cmd); -void kohHighlightRoom(s16 roomnum, s32 *arg1, s32 *arg2, s32 *arg3); +void kohHighlightRoom(RoomNum roomnum, s32 *arg1, s32 *arg2, s32 *arg3); void htmAddPad(s16 padnum); void htmReset(void); void htbCreateUplink(void); diff --git a/src/include/game/objectives.h b/src/include/game/objectives.h index 438eb1782..fa13c3834 100644 --- a/src/include/game/objectives.h +++ b/src/include/game/objectives.h @@ -27,7 +27,7 @@ void objectivesDisableChecking(void); void objectivesShowHudmsg(char *buffer, s32 hudmsgtype); void objectivesCheckAll(void); void objectiveCheckRoomEntered(s32 currentroom); -void objectiveCheckThrowInRoom(s32 arg0, s16 *requiredrooms); +void objectiveCheckThrowInRoom(s32 arg0, RoomNum *requiredrooms); void objectiveCheckHolograph(f32 sqdist); struct prop *chopperGetTargetProp(struct chopperobj *heli); struct defaultobj *objFindByTagId(s32 tag_id); diff --git a/src/include/game/padhalllv.h b/src/include/game/padhalllv.h index 924da841d..9d4306c29 100644 --- a/src/include/game/padhalllv.h +++ b/src/include/game/padhalllv.h @@ -5,7 +5,7 @@ #include "types.h" void navSetSeed(u32 upper, u32 lower); -struct waypoint *waypointFindClosestToPos(struct coord *pos, s16 *rooms); +struct waypoint *waypointFindClosestToPos(struct coord *pos, RoomNum *rooms); struct waygroup *waygroupChooseNeighbour(s32 *groupnums, s32 step, u32 ignoremask); void waygroupSetStepIfUndiscovered(s32 *groupnums, s32 step, u32 ignoremask); bool waygroupDiscoverOneStep(struct waygroup *group, s32 step, u32 ignoremask); diff --git a/src/include/game/pak.h b/src/include/game/pak.h index af25246f0..327fcfd1a 100644 --- a/src/include/game/pak.h +++ b/src/include/game/pak.h @@ -9,29 +9,29 @@ u32 pakAlign(s8 device, u32 size); s32 pakGetAlignedFileLenByBodyLen(s8 device, u32 bodylen); u32 pakGetBodyLenByFileLen(u32 filelen); u32 pakGenerateSerial(s8 device); -bool pakIsMemoryPak(s8 device); +bool mempakIsOkay(s8 device); s32 pakGetFileIdsByType(s8 device, u32 filetype, u32 *fileids); s32 pak0f1167d8(s8 device); s32 pakReadBodyAtGuid(s8 device, s32 fileid, u8 *body, s32 arg3); s32 pakSaveAtGuid(s8 device, s32 fileid, s32 filetype, u8 *body, s32 *outfileid, u8 *olddata); bool pakDeleteFile(s8 device, s32 fileid); -s32 pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name); -s32 pak0f1168c4(s8 device, struct pakdata **arg1); +PakErr1 pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name); +PakErr1 pak0f1168c4(s8 device, struct pakdata **arg1); s32 pakGetType(s8 device); s32 pakGetSerial(s8 device); void pak0f11698c(s8 device); void pak0f116994(void); -void pak0f1169c8(s8 device, s32 arg1); -bool pak0f116aec(s8 device); -bool pak0f116b5c(s8 device); +void pak0f1169c8(s8 device, bool tick); +bool mempakIsReady(s8 device); +bool mempakIsReadyOrFull(s8 device); void pak0f116bdc(s8 device, u8 *arg1, u8 *arg2); u16 _pakGetSerial(s8 device); u32 _pakGetType(s8 device); -void pakSetUnk010(s8 device, s32 value); +void pakSetState(s8 device, s32 value); s32 pak0f116df0(s8 device, struct pakdata **arg1); s32 _pakDeleteGameNote(s8 device, u16 company_code, u32 game_code, char *game_name, char *ext_name); s32 _pakDeleteFile(s8 device, s32 fileid); -s32 pakGetUnk264(s8 device); +s32 pakGetPlugCount(s8 device); u32 pakGetMaxFileSize(s8 device); s32 pakGetBodyLenByType(s8 device, u32 filetype); void pak0f117150(s8 device, u8 *ptr); @@ -91,8 +91,8 @@ void pakCreateInitialFiles(s8 device); s32 pakFindMaxFileId(s8 device); void pakMergeBlanks(s8 device); void paksReset(void); -void pak0f11a32c(s8 device, u8 arg1, u32 line, char *file); -void pakInit(s8 arg0); +void pakSetFeatures(s8 device, u8 features, u32 line, char *file); +void pakSetDefaults(s8 arg0); PakErr1 pakReadWriteBlock(s8 device, OSPfs *pfs, s32 file_no, u8 flag, u32 address, u32 len, u8 *buffer); bool pakQueryTotalUsage(s8 device); void pakQueryPdSize(s8 device); @@ -111,7 +111,7 @@ bool pakHandleResult(s32 err1, s8 device, bool arg2, u32 line); void paksTick(void); void pak0f11c6d0(void); void pakExecuteDebugOperations(void); -void pak0f11ca30(void); +void pakCheckPlugged(void); void gbpakHandleError(u32 arg0); bool gbpakRead(s8 device, u16 address, u8 *buffer, u16 size); bool gbpakWrite(s8 device, u16 address, u8 *buffer, u16 size); @@ -140,7 +140,7 @@ void pakEnableRumbleForPlayer(s8 playernum); void pakDisableRumbleForAllPlayers(void); void pakEnableRumbleForAllPlayers(void); void pakDumpPak(void); -void pak0f11df94(s8 device); +void pakTickState(s8 device); void pak0f11e3bc(s8 device); void pakProbeEeprom(void); PakErr1 pakReadEeprom(u8 address, u8 *buffer, u32 len); diff --git a/src/include/game/player.h b/src/include/game/player.h index b012a1654..81840b813 100644 --- a/src/include/game/player.h +++ b/src/include/game/player.h @@ -4,8 +4,8 @@ #include "data.h" #include "types.h" -f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, s16 *dstrooms, struct prop *prop, s16 *spawnpads, s32 numspawnpads); -f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, s16 *rooms, struct prop *prop); +f32 playerChooseSpawnLocation(f32 chrradius, struct coord *dstpos, RoomNum *dstrooms, struct prop *prop, s16 *spawnpads, s32 numspawnpads); +f32 playerChooseGeneralSpawnLocation(f32 chrradius, struct coord *pos, RoomNum *rooms, struct prop *prop); void playerStartNewLife(void); void playerLoadDefaults(void); bool playerSpawnAnti(struct chrdata *chr, s32 param_2); @@ -63,7 +63,7 @@ void playerDie(bool force); void playerDieByShooter(u32 shooter, bool force); void playerCheckIfShotInBack(s32 attackerplayernum, f32 x, f32 z); f32 playerGetHealthBarHeightFrac(void); -void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, struct coord *pos2, s16 *rooms); +void player0f0c1840(struct coord *pos, struct coord *up, struct coord *look, struct coord *pos2, RoomNum *rooms); void player0f0c1ba4(struct coord *pos, struct coord *up, struct coord *look, struct coord *memcampos, s32 memcamroom); void player0f0c1bd8(struct coord *pos, struct coord *up, struct coord *look); void playersClearMemCamRoom(void); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index 5076414a6..b26589518 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -21,7 +21,7 @@ void propDelist(struct prop *prop); void propReparent(struct prop *mover, struct prop *adopter); void propDetach(struct prop *prop); Gfx *propRender(Gfx *gdl, struct prop *prop, bool xlupass); -Gfx *propsRender(Gfx *gdl, s16 renderroomnum, s32 renderpass, s16 *roomnumsbyprop); +Gfx *propsRender(Gfx *gdl, RoomNum renderroomnum, s32 renderpass, RoomNum *roomnumsbyprop); void weaponPlayWhooshSound(s32 weaponnum, struct prop *prop); void func0f060bac(s32 weaponnum, struct prop *prop); struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2, struct coord *arg3, struct coord *gunpos, struct coord *dir, u32 arg6, f32 arg7, bool arg8); @@ -46,21 +46,21 @@ void farsightChooseTarget(void); void autoaimTick(void); u32 propDoorGetCdTypes(struct prop *prop); bool propIsOfCdType(struct prop *prop, u32 types); -void roomsCopy(s16 *srcrooms, s16 *dstrooms); -void roomsAppend(s16 *newrooms, s16 *dstrooms, s32 maxlen); -bool arrayIntersects(s16 *a, s16 *b); +void roomsCopy(RoomNum *srcrooms, RoomNum *dstrooms); +void roomsAppend(RoomNum *newrooms, RoomNum *dstrooms, s32 maxlen); +bool arrayIntersects(RoomNum *a, RoomNum *b); bool propTryAddToChunk(s16 propnum, s32 chunkindex); s32 roomAllocatePropListChunk(s32 room, s32 arg1); -void propRegisterRoom(struct prop *prop, s16 room); -void propDeregisterRoom(struct prop *prop, s16 room); +void propRegisterRoom(struct prop *prop, RoomNum room); +void propDeregisterRoom(struct prop *prop, RoomNum room); void propDeregisterRooms(struct prop *prop); void propRegisterRooms(struct prop *prop); -void func0f065d1c(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms, s16 *morerooms, u32 arg5); -void func0f065dd8(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms); -void func0f065dfc(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms, s16 *morerooms, u32 arg5); -void func0f065e74(struct coord *pos, s16 *rooms, struct coord *newpos, s16 *newrooms); -void func0f065e98(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2); -void roomGetProps(s16 *room, s16 *propnums, s32 len); +void func0f065d1c(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms, RoomNum *morerooms, u32 arg5); +void func0f065dd8(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms); +void func0f065dfc(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms, RoomNum *morerooms, u32 arg5); +void func0f065e74(struct coord *pos, RoomNum *rooms, struct coord *newpos, RoomNum *newrooms); +void func0f065e98(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2); +void roomGetProps(RoomNum *room, s16 *propnums, s32 len); void propsDefragRoomProps(void); void propGetBbox(struct prop *prop, f32 *radius, f32 *ymax, f32 *ymin); bool propUpdateGeometry(struct prop *prop, u8 **start, u8 **end); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index ba17e8f0f..98752dd7a 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -63,7 +63,7 @@ bool modelGetScreenCoords2(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 * bool modelGetScreenCoords(struct model *model, f32 *x2, f32 *x1, f32 *y2, f32 *y1); void func0f06803c(struct coord *arg0, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4); struct defaultobj *objFindByPadNum(s32 padnum); -struct defaultobj *objFindByPos(struct coord *pos, s16 *rooms); +struct defaultobj *objFindByPos(struct coord *pos, RoomNum *rooms); void projectileFree(struct projectile *projectile); void projectilesUnrefOwner(struct prop *owner); void projectileReset(struct projectile *projectile); @@ -81,7 +81,7 @@ struct modelnode *modelFindBboxNode(struct model *model); struct modelrodata_bbox *modelFindBboxRodata(struct model *model); struct modelnode *objFindBboxNode(struct defaultobj *obj); struct modelrodata_bbox *objFindBboxRodata(struct defaultobj *obj); -s32 objGetAverageBrightnessInRooms(s16 *rooms, s32 arg1); +s32 objGetAverageBrightnessInRooms(RoomNum *rooms, s32 arg1); s32 door0f068c04(struct prop *prop, s32 *arg1, s32 *arg2); s32 func0f068fc8(struct prop *prop, bool arg1); void propCalculateShadeColour(struct prop *prop, u8 *nextcol, u16 floorcol); @@ -98,10 +98,10 @@ void objCreateDebris(struct defaultobj *obj, struct prop *prop); struct prop *objInit(struct defaultobj *obj, struct modeldef *modeldef, struct prop *prop, struct model *model); struct prop *objInitWithModelDef(struct defaultobj *obj, struct modeldef *modeldef); struct prop *objInitWithAutoModel(struct defaultobj *obj); -void func0f06a580(struct defaultobj *obj, struct coord *pos, Mtxf *matrix, s16 *rooms); +void func0f06a580(struct defaultobj *obj, struct coord *pos, Mtxf *matrix, RoomNum *rooms); f32 func0f06a620(struct defaultobj *obj); -void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *matrix, s16 *rooms, struct coord *arg4); -void func0f06ab60(struct defaultobj *obj, struct coord *arg1, Mtxf *matrix, s16 *rooms, struct coord *arg4); +void func0f06a730(struct defaultobj *obj, struct coord *arg1, Mtxf *matrix, RoomNum *rooms, struct coord *arg4); +void func0f06ab60(struct defaultobj *obj, struct coord *arg1, Mtxf *matrix, RoomNum *rooms, struct coord *arg4); void objFreeProjectile(struct defaultobj *obj); void objFreeEmbedmentOrProjectile(struct prop *prop); void objFree(struct defaultobj *obj, bool freeprop, bool canregen); @@ -112,7 +112,7 @@ bool func0f06b488(struct prop *prop, struct coord *arg1, struct coord *arg2, str bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2, struct coord *arg3, f32 arg4, struct coord *arg5, struct coord *arg6, struct coord *arg7, struct coord *arg8, f32 *arg9); bool func0f06bea0(struct model *model, struct modelnode *arg1, struct modelnode *arg2, struct coord *arg3, struct coord *arg4, void *arg5, f32 *arg6, struct modelnode **arg7, s32 *hitpart, s32 *arg9, struct modelnode **arg10); bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord *arg2, struct coord *arg3, f32 arg4, struct coord *arg5, struct coord *arg6, struct coord *arg7, struct coord *arg8, f32 *arg9); -bool projectileFindCollidingProp(struct prop *prop, struct coord *pos, struct coord *arg2, u32 cdtypes, struct coord *arg4, struct coord *arg5, s16 *arg6); +bool projectileFindCollidingProp(struct prop *prop, struct coord *pos, struct coord *arg2, u32 cdtypes, struct coord *arg4, struct coord *arg5, RoomNum *rooms); s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, struct coord *arg3); bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2, struct coord *arg3); void applySpeed(f32 *distdone, f32 maxdist, f32 *speed, f32 accel, f32 decel, f32 maxspeed); @@ -141,8 +141,8 @@ struct prop *liftFindByPad(s16 padnum); f32 liftGetY(struct liftobj *lift); void liftUpdateTiles(struct liftobj *lift, bool stationary); void liftGoToStop(struct liftobj *lift, s32 stopnum); -f32 objGetHov04(struct defaultobj *obj); -void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, s16 *rooms, f32 matrix[3][3]); +f32 objGetHovBobOffsetY(struct defaultobj *obj); +void hovUpdateGround(struct defaultobj *obj, struct hov *hov, struct coord *pos, RoomNum *rooms, f32 matrix[3][3]); void hovTick(struct defaultobj *obj, struct hov *hov); s32 objIsHoverpropOrBike(struct defaultobj *obj); f32 hoverpropGetTurnAngle(struct defaultobj *obj); @@ -289,7 +289,7 @@ void weaponDeleteFromChr(struct chrdata *chr, s32 hand); struct prop *weaponCreateForChr(struct chrdata *chr, s32 modelnum, s32 weaponnum, u32 flags, struct weaponobj *obj, struct modeldef *modeldef); struct prop *chrGiveWeapon(struct chrdata *chr, s32 model, s32 weaponnum, u32 flags); s32 weaponTestForPickup(struct prop *prop); -void weaponSetGunfireVisible(struct prop *prop, bool visible, s16 room); +void weaponSetGunfireVisible(struct prop *prop, bool visible, RoomNum room); bool weaponIsGunfireVisible(struct prop *prop); s32 hatGetType(struct prop *prop); bool doorIsUnlocked(struct prop *playerprop, struct prop *doorprop); @@ -306,7 +306,7 @@ void func0f08d3dc(struct doorobj *door); void func0f08d460(struct doorobj *door); void doorActivatePortal(struct doorobj *door); void doorDeactivatePortal(struct doorobj *door); -struct prop *doorInit(struct doorobj *door, struct coord *pos, Mtxf *mtx, s16 *rooms, struct coord *coord, struct coord *centre); +struct prop *doorInit(struct doorobj *door, struct coord *pos, Mtxf *mtx, RoomNum *rooms, struct coord *coord, struct coord *centre); void doorPlayOpeningSound(s32 soundtype, struct prop *prop); void doorPlayClosingSound(s32 soundtype, struct prop *prop); void doorPlayOpenedSound(s32 soundtype, struct prop *prop); @@ -320,7 +320,7 @@ void doorSetMode(struct doorobj *door, s32 newmode); void doorsRequestMode(struct doorobj *door, s32 newmode); s32 doorIsClosed(struct doorobj *door); s32 doorIsOpen(struct doorobj *door); -s32 func0f08e5a8(s16 *rooms, struct screenbox *box); +s32 func0f08e5a8(RoomNum *rooms, struct screenbox *box); f32 objCalculateFadeDistOpacityFrac(struct prop *prop, f32 modelscale); bool posIsInObjFadeDistance(struct coord *coord, f32 modelscale); bool func0f08e8ac(struct prop *prop, struct coord *pos, f32 arg2, bool arg3); diff --git a/src/include/game/propsnd.h b/src/include/game/propsnd.h index f08196bf5..d1b236033 100644 --- a/src/include/game/propsnd.h +++ b/src/include/game/propsnd.h @@ -21,17 +21,17 @@ void psTick(void); void psSetPitch(struct prop *prop, f32 targetpitch, s32 changespeed); void psSetVolume(struct prop *prop, s32 vol); void psStopOneShootChannel(struct prop *prop); -s16 psCreate(struct pschannel *channel, struct prop *prop, s16 soundnum, s16 padnum, s32 vol, u16 flags, u16 flags2, s32 type, struct coord *pos, f32 pitch, s16 *rooms, s32 room, f32 dist1, f32 dist2, f32 dist3); +s16 psCreate(struct pschannel *channel, struct prop *prop, s16 soundnum, s16 padnum, s32 vol, u16 flags, u16 flags2, s32 type, struct coord *pos, f32 pitch, RoomNum *rooms, s32 room, f32 dist1, f32 dist2, f32 dist3); s32 psPlayFromProp(s32 channelnum, s16 soundnum, s32 vol, struct prop *prop, s16 type, u16 flags); void psMuteChannel(s32 channelnum); bool psIsChannelFree(s32 channelnum); void psModify(s32 channelnum, s32 arg1, s16 padnum, struct prop *prop, s32 volchangetimer60, s32 dist2, s32 dist3, u16 flags); -s32 psCalculateVol(struct coord *pos, f32 arg1, f32 arg2, f32 arg3, s16 *rooms, s16 soundnum, s32 arg6, f32 *arg7); +s32 psCalculateVol(struct coord *pos, f32 arg1, f32 arg2, f32 arg3, RoomNum *rooms, s16 soundnum, s32 arg6, f32 *arg7); s32 psCalculatePan3(s32 degrees, f32 arg1, struct pschannel *channel); s32 psCalculatePan2(struct coord *pos, s32 arg1, f32 arg2, struct pschannel *channel); s32 psCalculatePan(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, f32 playerdist, bool arg5, struct pschannel *channel); -void psGetTheoreticalVolPan(struct coord *pos, s16 *rooms, s16 soundnum, s32 *vol, s32 *pan); -void psApplyVolPan(struct sndstate *handle, struct coord *pos, f32 dist1, f32 dist2, f32 dist3, s16 *rooms, s16 soundnum, s32 arg7, f32 *distanceptr); +void psGetTheoreticalVolPan(struct coord *pos, RoomNum *rooms, s16 soundnum, s32 *vol, s32 *pan); +void psApplyVolPan(struct sndstate *handle, struct coord *pos, f32 dist1, f32 dist2, f32 dist3, RoomNum *rooms, s16 soundnum, s32 arg7, f32 *distanceptr); s32 psGetRandomSparkSound(void); s32 psGetDuration60(s32 channelnum); diff --git a/src/include/game/setuputils.h b/src/include/game/setuputils.h index 4d4fcb77a..86cad9dea 100644 --- a/src/include/game/setuputils.h +++ b/src/include/game/setuputils.h @@ -11,7 +11,7 @@ u32 setupGetCmdIndexByProp(struct prop *prop); bool setupLoadModeldef(s32 modelnum); bool setupGetObjBbox(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], struct coord *arg3, struct coord *arg4); bool setup0f092304(struct defaultobj *obj, struct coord *arg1, struct coord *arg2); -void setup0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], s16 *rooms); +void setup0f09233c(struct defaultobj *obj, struct coord *pos, f32 realrot[3][3], RoomNum *rooms); void setup0f0923d4(struct defaultobj *obj); struct defaultobj *setupGetObjByCmdIndex(u32 cmdindex); struct defaultobj *setupFindObjForReuse(s32 type, struct defaultobj **arg1, struct defaultobj **arg2, bool musthaveprop, bool musthavemodel, struct modeldef *modeldef); diff --git a/src/include/game/smoke.h b/src/include/game/smoke.h index 790c272cf..221ecda59 100644 --- a/src/include/game/smoke.h +++ b/src/include/game/smoke.h @@ -11,13 +11,13 @@ void smokeReset(void); void smokeStop(void); Gfx *smokeRenderPart(struct smoke *smoke, struct smokepart *part, Gfx *gdl, struct coord *coord, f32 size); -struct smoke *smokeCreate(struct coord *pos, s16 *rooms, s16 type); -bool smokeCreateForHand(struct coord *pos, s16 *rooms, s16 type, s32 handnum); -bool smokeCreateWithSource(void *source, struct coord *pos, s16 *rooms, s16 type, bool srcispadeffect); +struct smoke *smokeCreate(struct coord *pos, RoomNum *rooms, s16 type); +bool smokeCreateForHand(struct coord *pos, RoomNum *rooms, s16 type, s32 handnum); +bool smokeCreateWithSource(void *source, struct coord *pos, RoomNum *rooms, s16 type, bool srcispadeffect); void smokeCreateAtProp(struct prop *prop, s16 type); -void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, s16 *rooms, s16 type); +void smokeCreateAtPadEffect(struct padeffectobj *effect, struct coord *pos, RoomNum *rooms, s16 type); void smokeClearForProp(struct prop *prop); -struct smoke *smokeCreateSimple(struct coord *pos, s16 *rooms, s16 type); +struct smoke *smokeCreateSimple(struct coord *pos, RoomNum *rooms, s16 type); u32 smokeTick(struct prop *prop); u32 smokeTickPlayer(struct prop *prop); Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass); diff --git a/src/include/game/title.h b/src/include/game/title.h index b65659136..6dc4ed517 100644 --- a/src/include/game/title.h +++ b/src/include/game/title.h @@ -4,6 +4,8 @@ #include "data.h" #include "types.h" +#define TITLE_ALLOCSIZE 1024 * 286 + extern u32 var800624d4; extern u32 var800624d8; extern u32 var800624dc; diff --git a/src/include/game/wallhit.h b/src/include/game/wallhit.h index 36fe0e25b..9866462ee 100644 --- a/src/include/game/wallhit.h +++ b/src/include/game/wallhit.h @@ -17,11 +17,11 @@ void wallhitRemoveOne(void); void wallhitsTick(void); void wallhitCreate(struct coord *relpos, struct coord *arg1, struct coord *arg2, s16 arg3[3], - s16 arg4[3], s16 texnum, s16 room, struct prop *objprop, + s16 arg4[3], s16 texnum, RoomNum room, struct prop *objprop, s8 mtxindex, s8 arg9, struct chrdata *chr, bool xlu); void wallhitCreateWith20Args(struct coord *relpos, struct coord *arg1, struct coord *arg2, s16 arg3[3], - s16 arg4[3], s16 texnum, s16 room, struct prop *objprop, + s16 arg4[3], s16 texnum, RoomNum room, struct prop *objprop, struct prop *chrprop, s8 mtxindex, s8 arg10, struct chrdata *chr, f32 width, f32 height, u8 minalpha, u8 maxalpha, s32 rotdeg, u32 timermax, u32 timerspeed, bool xlu); diff --git a/src/include/lib/collision.h b/src/include/lib/collision.h index 657659d4a..a227b2331 100644 --- a/src/include/lib/collision.h +++ b/src/include/lib/collision.h @@ -25,47 +25,47 @@ bool cd000266a4(f32 x, f32 z, struct geo *tile); void cdGetPropsOnPlatform(struct prop *platform, s16 *propnums, s32 len); s32 cd000274e0Block(struct geoblock *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collision *collision); bool cd000276c8Cyl(struct geocyl *tile, f32 x, f32 z, f32 width, struct prop *prop, struct collision *collision); -bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags, struct coord *laddernormal); -bool cd0002a13c(struct coord *pos, f32 radius, f32 arg2, f32 arg3, s16 *rooms, u16 geoflags); -f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype, u16 *floorflags, s16 *floorroom, s32 *inlift, struct prop **lift); +bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, RoomNum *rooms, u16 geoflags, struct coord *laddernormal); +bool cd0002a13c(struct coord *pos, f32 radius, f32 arg2, f32 arg3, RoomNum *rooms, u16 geoflags); +f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, RoomNum *rooms, u16 *floorcol, u8 *floortype, u16 *floorflags, RoomNum *floorroom, s32 *inlift, struct prop **lift); f32 cdReturnZero(void); -f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype); -f32 cdFindFloorYColourTypeAtPos(struct coord *pos, s16 *rooms, u16 *floorcol, u8 *floortype); -s32 cdFindFloorRoomAtPos(struct coord *pos, s16 *nearrooms); +f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, RoomNum *rooms, u16 *floorcol, u8 *floortype); +f32 cdFindFloorYColourTypeAtPos(struct coord *pos, RoomNum *rooms, u16 *floorcol, u8 *floortype); +s32 cdFindFloorRoomAtPos(struct coord *pos, RoomNum *nearrooms); #if VERSION >= VERSION_NTSC_1_0 -s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); -s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); +RoomNum cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); +RoomNum cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr); #else -s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); -s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr); +RoomNum cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr); +RoomNum cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr); #endif -s16 cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr); -s16 cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *geoflags, struct coord *normal); -s32 cdTestVolume(struct coord *pos, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); -s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); -s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); -bool cdTestCylMove01(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin); -s32 cdTestCylMove02(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, bool arg5, f32 ymax, f32 ymin); -s32 cdExamCylMove03(struct coord *pos, s16 *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin); -s32 cdTestCylMove04(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); -s32 cdExamCylMove05(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin); -s32 cdExamCylMove06(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 arg4, s32 types, s32 arg6, f32 ymax, f32 ymin); -s32 cdExamCylMove07(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); -s32 cdExamCylMove08(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin); -bool cdTestLos03(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 geoflags); -bool cdTestLos04(struct coord *coord, s16 *rooms, struct coord *coord2, s32 arg3); -bool cdTestLos05(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 cdtypes, u16 geoflags); -bool cdTestLos06(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 types); -bool cdTestLos07(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 geoflags); -s32 cdExamLos08(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 geoflags); -s32 cdExamLos09(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types); -s32 cdTestLos10(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 geoflags); -s32 cdTestLos11(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types); +RoomNum cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr); +RoomNum cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcol, u16 *geoflags, struct coord *normal); +s32 cdTestVolume(struct coord *pos, f32 radius, RoomNum *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, RoomNum *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, RoomNum *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin); +bool cdTestCylMove01(struct coord *pos, RoomNum *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin); +s32 cdTestCylMove02(struct coord *pos, RoomNum *rooms, struct coord *coord2, RoomNum *rooms2, u32 types, bool arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove03(struct coord *pos, RoomNum *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin); +s32 cdTestCylMove04(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove05(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove06(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, f32 arg4, s32 types, s32 arg6, f32 ymax, f32 ymin); +s32 cdExamCylMove07(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin); +s32 cdExamCylMove08(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin); +bool cdTestLos03(struct coord *viewpos, RoomNum *rooms, struct coord *targetpos, u32 types, u16 geoflags); +bool cdTestLos04(struct coord *coord, RoomNum *rooms, struct coord *coord2, s32 arg3); +bool cdTestLos05(struct coord *coord, RoomNum *rooms, struct coord *coord2, RoomNum *rooms2, s32 cdtypes, u16 geoflags); +bool cdTestLos06(struct coord *arg0, RoomNum *rooms1, struct coord *arg2, RoomNum *rooms2, u32 types); +bool cdTestLos07(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, RoomNum *rooms3, u32 types, u16 geoflags); +s32 cdExamLos08(struct coord *pos, RoomNum *rooms, struct coord *pos2, u32 types, u16 geoflags); +s32 cdExamLos09(struct coord *pos, RoomNum *rooms, struct coord *pos2, u32 types); +s32 cdTestLos10(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, u16 geoflags); +s32 cdTestLos11(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types); bool cd0002ded8(struct coord *arg0, struct coord *arg1, struct prop *prop); -s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, s16 *rooms, u32 types); -s32 cd0002f02c(struct geoblock *block, s16 *rooms, s32 types); -bool cdIsNearlyInSight(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 arg4); +s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, RoomNum *rooms, u32 types); +s32 cd0002f02c(struct geoblock *block, RoomNum *rooms, s32 types); +bool cdIsNearlyInSight(struct coord *viewpos, RoomNum *rooms, struct coord *targetpos, f32 distance, s32 arg4); #endif diff --git a/src/include/lib/joy.h b/src/include/lib/joy.h index c50727b22..adff70a59 100644 --- a/src/include/lib/joy.h +++ b/src/include/lib/joy.h @@ -4,15 +4,15 @@ #include "data.h" #include "types.h" -void joy00013900(void); -void joy00013938(void); -void joy00013974(u32 value); -u32 joy00013980(void); -void joy0001398c(s32 value); -void joy000139c8(void); +void joyLockCyclicPolling(void); +void joyUnlockCyclicPolling(void); +void joySetPfsPollEnabled(bool enabled); +bool joyIsPfsPollEnabled(void); +void joySetPfsPollInterval(s32 value); +void joySetDefaultPfsPollInterval(void); s32 joyShiftPfsStates(void); void joyRecordPfsState(u8 pfsstate); -void joyCheckPfs(s32 arg0); +void joyPollPfs(s32 force); void joySetPfsTemporarilyPlugged(s8 index); void joyInit(void); void joyDisableTemporarily(void); @@ -49,8 +49,8 @@ void joyEnableCyclicPolling(s32 line, char *file); void joyDestroy(void); void joyGetContpadNumsForPlayer(s8 playernum, s32 *pad1, s32 *pad2); void joyStopRumble(s8 device, bool disablepolling); -s32 joy000155b4(s8 device); -s32 joy000155f4(s8 device); +s32 joyGetPakState(s8 device); +s32 joyGetPakState2(s8 device); void joysTickRumble(void); #endif diff --git a/src/include/lib/lib_17ce0.h b/src/include/lib/lib_17ce0.h index 5fa8ddb14..a6d970059 100644 --- a/src/include/lib/lib_17ce0.h +++ b/src/include/lib/lib_17ce0.h @@ -9,8 +9,8 @@ #define PORTALINTERSECTION_FRONTTOBEHIND 2 void portalGetAvgVertexPos(s32 portalnum, struct coord *avg); -void portal00017dc4(s16 *rooms, s16 roomnum); +void portal00017dc4(RoomNum *rooms, RoomNum roomnum); s32 portalCalculateIntersection(s32 portalnum, struct coord *pos1, struct coord *pos2); -void portal00018148(struct coord *pos, struct coord *pos2, s16 *rooms, s16 *arg3, s16 *arg4, s32 arg5); +void portal00018148(struct coord *pos, struct coord *pos2, RoomNum *rooms, RoomNum *arg3, RoomNum *arg4, s32 arg5); #endif diff --git a/src/include/props.h b/src/include/props.h index b9069f884..ddb46622a 100644 --- a/src/include/props.h +++ b/src/include/props.h @@ -186,14 +186,14 @@ #define hoverbike(scale, model, pad, flags, flags2, flags3, maxdamage) \ _generic_object(0x33, scale, model, pad, flags, flags2, flags3, maxdamage), \ - _mkword(_mkshort(HOVTYPE_BIKE, TRUE), 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + _mkword(_mkshort(HOVTYPE_BIKE, HOVFLAG_FIRSTTICK), 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #define endprops \ 0x34, #define hover_prop(scale, model, pad, flags, flags2, flags3, maxdamage, hovtype) \ _generic_object(0x35, scale, model, pad, flags, flags2, flags3, maxdamage), \ - _mkword(_mkshort(hovtype, TRUE), 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + _mkword(_mkshort(hovtype, HOVFLAG_FIRSTTICK), 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #define fan(scale, model, pad, flags, flags2, flags3, maxdamage, maxspeed, accel, on) \ _generic_object(0x36, scale, model, pad, flags, flags2, flags3, maxdamage), \ diff --git a/src/include/types.h b/src/include/types.h index 9d4c6a9ea..112e6d17b 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -28,6 +28,7 @@ typedef s32 PakErr1; typedef s32 PakErr2; typedef s32 MenuDialogHandlerResult; typedef intptr_t MenuItemHandlerResult; +typedef s16 RoomNum; // Float version of a graphics matrix, which has higher precision than an Mtx. // Matrices are stored as Mtxfs then converted to an Mtx when passed to the GPU. @@ -231,8 +232,8 @@ struct g_vars { /*0x4b8*/ struct prop *aibuddies[4]; /*0x4c8*/ u32 dontplaynrg; // allow X music to be played (NRG = energy track) /*0x4cc*/ s32 in_cutscene; - /*0x4d0*/ u8 paksconnected; - /*0x4d1*/ u8 paksconnected2; + /*0x4d0*/ u8 paksneededformenu; + /*0x4d1*/ u8 paksneededforgame; /*0x4d2*/ s8 autocutnum; // cutscene scene number (0, 1 or 2), set to -1 while loading cutscene /*0x4d3*/ s8 autocutplaying; // true if playing a cutscene via the menu, false when a button is pressed /*0x4d4*/ s8 autocutgroupcur; // index into g_Cutscenes @@ -247,9 +248,9 @@ struct g_vars { /*0x4e3*/ u8 langfilteron; // 000f = Counter: if 10-15 then ticks down 1 per 7 frames, if under 10 then 1 per frame. - // 00f0 = One bit per pak. Does something with the pak if counter expired. - // 0f00 = One bit per pak. Does something with the pak if counter expired (likely opposite of the above). - /*0x4e4*/ u16 unk0004e4; + // 00f0 = One bit per pak. These paks are checked and ticked. + // 0f00 = One bit per pak. These paks are checked but not ticked. + /*0x4e4*/ u16 pakstocheck; /*0x4e8*/ u32 unk0004e8; /*0x4ec*/ u32 unk0004ec; @@ -301,7 +302,7 @@ struct prop { /*0x1c*/ struct prop *child; /*0x20*/ struct prop *next; /*0x24*/ struct prop *prev; - /*0x28*/ s16 rooms[8]; + /*0x28*/ RoomNum rooms[8]; /*0x38*/ u16 lastupdateframe; /*0x3a*/ u16 propupdate240; /*0x3c*/ u8 propupdate60err; @@ -753,7 +754,7 @@ struct aibot { /*0x076*/ s16 lastkilledbyplayernum; /*0x078*/ u8 forceslowupdates; /*0x079*/ u8 command; - /*0x07a*/ s16 defendholdrooms[1]; + /*0x07a*/ RoomNum defendholdrooms[1]; /*0x07c*/ u32 unk07c; // unused /*0x080*/ u32 unk080; // unused /*0x084*/ u32 unk084; // unused @@ -785,7 +786,7 @@ struct aibot { /*0x0e0*/ s16 reaperspeed[2]; /*0x0e4*/ f32 maulercharge[2]; /*0x0ec*/ struct coord gotopos; - /*0x0f8*/ s16 gotorooms[8]; + /*0x0f8*/ RoomNum gotorooms[8]; /*0x108*/ struct coord shotspeed; // "boost" when aibot is shot /*0x114*/ s32 feudplayernum; /*0x118*/ s32 commandtimer60; @@ -798,7 +799,7 @@ struct aibot { /*0x13c*/ f32 chrdistances[MAX_MPCHRS]; /*0x16c*/ u8 chrsinsight[MAX_MPCHRS]; /*0x178*/ s32 chrslastseen60[MAX_MPCHRS]; - /*0x1a8*/ s16 chrrooms[MAX_MPCHRS]; + /*0x1a8*/ RoomNum chrrooms[MAX_MPCHRS]; /*0x1c0*/ f32 extraangle; /*0x1c4*/ f32 extraanglerate; /*0x1c8*/ f32 extraanglebase; @@ -1055,7 +1056,7 @@ struct act_patrol { struct act_gopos { /*0x02c*/ struct coord endpos; - /*0x038*/ s16 endrooms[8]; + /*0x038*/ RoomNum endrooms[8]; /*0x048*/ struct waypoint *target; // Target/final waypoint // Array of pointers to the next couple of waypoints. Recalculated each time @@ -1258,9 +1259,9 @@ struct chrdata { /*0x2ae*/ u16 unk2ae; /*0x2b0*/ u8 tude; /*0x2b1*/ u8 voicebox; - /*0x2b2*/ s16 floorroom; + /*0x2b2*/ RoomNum floorroom; /*0x2b4*/ u32 unk2b4; - /*0x2b8*/ s16 oldrooms[8]; + /*0x2b8*/ RoomNum oldrooms[8]; /*0x2c8*/ struct coord runfrompos; /*0x2d4*/ struct aibot *aibot; /*0x2d8*/ s16 blurdrugamount; @@ -1433,21 +1434,21 @@ struct tvscreen { struct hov { /*0x00*/ u8 type; /*0x01*/ u8 flags; - /*0x04*/ f32 unk04; - /*0x08*/ f32 unk08; - /*0x0c*/ f32 unk0c; - /*0x10*/ f32 unk10; - /*0x14*/ f32 unk14; - /*0x18*/ f32 unk18; - /*0x1c*/ f32 unk1c; - /*0x20*/ f32 unk20; - /*0x24*/ f32 unk24; - /*0x28*/ f32 unk28; - /*0x2c*/ f32 unk2c; - /*0x30*/ f32 unk30; + /*0x04*/ f32 bobycur; + /*0x08*/ f32 bobytarget; + /*0x0c*/ f32 bobyspeed; + /*0x10*/ f32 yrot; + /*0x14*/ f32 bobpitchcur; + /*0x18*/ f32 bobpitchtarget; + /*0x1c*/ f32 bobpitchspeed; + /*0x20*/ f32 bobrollcur; + /*0x24*/ f32 bobrolltarget; + /*0x28*/ f32 bobrollspeed; + /*0x2c*/ f32 groundpitch; + /*0x30*/ f32 y; /*0x34*/ f32 ground; - /*0x38*/ s32 nexttick60; // framenum of when next tick should occur - /*0x3c*/ s32 prevtick60; // framenum of when hov was last ticked + /*0x38*/ s32 prevframe60; + /*0x3c*/ s32 prevgroundframe60; }; struct defaultobj { @@ -2478,7 +2479,7 @@ struct player { /*0x0278*/ f32 shieldshowrot; /*0x027c*/ u32 shieldshowrnd; /*0x0280*/ f32 shieldshowtime; - /*0x0284*/ s16 bondprevrooms[8]; + /*0x0284*/ RoomNum bondprevrooms[8]; /*0x0294*/ f32 liftground; /*0x0298*/ struct prop *lift; /*0x029c*/ f32 ladderupdown; @@ -2674,7 +2675,7 @@ struct player { /*0x19a4*/ f32 speedgo; /*0x19a8*/ s32 sighttimer240; /*0x19ac*/ s32 crouchoffsetreal; - /*0x19b0*/ s16 floorroom; + /*0x19b0*/ RoomNum floorroom; /*0x19b2*/ u8 unk19b2; /*0x19b3*/ u8 dostartnewlife; /*0x19b4*/ f32 crouchoffsetsmall; @@ -2820,7 +2821,7 @@ struct coverdefinition { struct cover { /*0x00*/ struct coord *pos; /*0x04*/ struct coord *look; - /*0x08*/ s16 rooms[2]; + /*0x08*/ RoomNum rooms[2]; /*0x0c*/ u16 flags; }; @@ -4450,7 +4451,7 @@ struct scenariodata_koh { /*0x800ac118*/ s16 movehill; /*0x800ac11a*/ s16 hillindex; /*0x800ac11c*/ s16 hillcount; - /*0x800ac11e*/ s16 hillrooms[2]; + /*0x800ac11e*/ RoomNum hillrooms[2]; /*0x800ac122*/ s16 hillpads[9]; /*0x800ac134*/ struct coord hillpos; /*0x800ac140*/ f32 colourfracr; @@ -4467,7 +4468,7 @@ struct ctcspawnpadsperteam { struct scenariodata_ctc { /*0x00*/ s16 playercountsperteam[4]; /*0x08*/ s16 teamindexes[4]; - /*0x10*/ s16 baserooms[4]; + /*0x10*/ RoomNum baserooms[4]; /*0x18*/ struct ctcspawnpadsperteam spawnpadsperteam[4]; /*0x58*/ struct prop *tokens[4]; }; @@ -4616,8 +4617,8 @@ struct explosionpart { struct explosionbb { struct coord bbmin; struct coord bbmax; - s16 room; - s16 room2; + RoomNum room; + RoomNum room2; }; struct explosion { @@ -4625,7 +4626,7 @@ struct explosion { struct prop *source; // Prop of the thing that created the explosion struct explosionpart parts[40]; /*0x3c8*/ s16 age; - /*0x3ca*/ s16 room; + /*0x3ca*/ RoomNum room; /*0x3cc*/ s8 type; /*0x3cd*/ s8 makescorch; /*0x3ce*/ s8 owner; @@ -4714,12 +4715,12 @@ struct pak { /*0x004*/ u32 rumblestate; /*0x008*/ u32 unk008; /*0x00c*/ u32 unk00c; - /*0x010*/ s32 unk010; - /*0x014*/ u8 unk014; + /*0x010*/ s32 state; + /*0x014*/ u8 features; /*0x018*/ struct pakdata pakdata; /*0x25c*/ u32 maxfileid; /*0x260*/ u32 serial; - /*0x264*/ u32 unk264; + /*0x264*/ u32 plugcount; /*0x268*/ u32 unk268; /*0x26c*/ u32 unk26c; /*0x270*/ u32 unk270; @@ -4746,7 +4747,7 @@ struct pak { /*0x2b8*/ u8 isgbpd : 1; /*0x2b8*/ u8 unk2b8_05 : 1; /*0x2b8*/ u8 unk2b8_06 : 1; - /*0x2b8*/ u8 unk2b8_07 : 1; + /*0x2b8*/ u8 showdatalost : 1; /*0x2b9*/ u8 unk2b9; /*0x2ba*/ u8 unk2ba; /*0x2bb*/ u8 unk2bb; @@ -4836,13 +4837,13 @@ struct animtable { s32 injuryanimcount; }; -struct var80075c00 { +struct headanim { s16 animnum; f32 loopframe; f32 endframe; - f32 unk0c; - f32 unk10; - f32 unk14; + f32 translateperframe; + f32 minspeed; + f32 maxspeed; }; struct vimode { @@ -5161,7 +5162,7 @@ struct bgcmd { }; struct drawslot { - s16 roomnum; + RoomNum roomnum; u8 unk02; u8 draworder; struct screenbox box; @@ -5178,8 +5179,8 @@ struct zrange { }; struct bgsnakeitem { - /*0x00*/ s16 roomnum; - /*0x02*/ s16 fromroomnums[5]; + /*0x00*/ RoomNum roomnum; + /*0x02*/ RoomNum fromroomnums[5]; /*0x0c*/ u8 depth; /*0x0d*/ u8 numportals; /*0x0e*/ s16 roomportallistoffset; @@ -5625,7 +5626,7 @@ struct var80067e6c { }; struct shard { - /*0x00*/ s16 room; + /*0x00*/ RoomNum room; /*0x04*/ s32 age60; /*0x08*/ struct coord pos; /*0x14*/ struct coord rot; @@ -5670,7 +5671,7 @@ struct pschannel { /*0x50*/ struct prop *prop; /*0x54*/ struct coord *posptr; /*0x58*/ struct coord pos; - /*0x64*/ s16 rooms[8]; + /*0x64*/ RoomNum rooms[8]; #if VERSION >= VERSION_NTSC_1_0 /*0x74*/ u32 uuid; #endif @@ -5708,7 +5709,7 @@ struct wallhit { /*0x5c*/ struct prop *chrprop; /*0x60*/ struct prop *objprop; /*0x64*/ Vtx *vertices2; // overridden vertices for when blood is expanding - /*0x68*/ s16 roomnum; + /*0x68*/ RoomNum roomnum; /*0x6a*/ u8 texturenum; /*0x6b*/ u8 unk6b; /*0x6c*/ u8 mtxindex; @@ -5818,7 +5819,6 @@ typedef struct AudioInfo_s { short *data; /* Output data pointer */ short frameSamples; /* # of samples synthesized in this frame */ OSScTask task; /* scheduler structure */ - AudioMsg msg; /* completion message */ } AudioInfo; typedef struct { @@ -5926,12 +5926,7 @@ struct mp3vars { /*0x38*/ struct mp3thing *var8009c3c8; /*0x3c*/ s32 var8009c3cc; /*0x40*/ s32 var8009c3d0; - - union { - /*0x44*/ u32 *var8009c3d4; - /*0x44*/ u32 *var8009c3d4_arr[1]; - }; - + /*0x44*/ u32 *var8009c3d4[1]; /*0x48*/ u32 var8009c3d8; /*0x4c*/ void *var8009c3dc; /*0x50*/ u32 var8009c3e0; @@ -5943,18 +5938,6 @@ struct mp3vars { /*0x61*/ u8 var8009c3f1; }; -struct sndcache { - /*0x0000*/ u16 *indexes; // indexed by sfxnum, value is cache index (0-44) or 0xffff - /*0x0004*/ u8 refcounts[45]; - /*0x0032*/ u16 ages[45]; - /*0x008c*/ ALEnvelope envelopes[45]; - /*0x035c*/ ALKeyMap keymaps[45]; - /*0x046c*/ ALWaveTable wavetables[45]; - /*0x07f0*/ ALADPCMBook books[45]; - /*0x3658*/ ALADPCMloop loops[45]; - /*0x3e14*/ ALSound sounds[45]; -}; - struct rdptask { OSScTask sctask; u16 *framebuffer; @@ -6313,19 +6296,19 @@ struct skyvtx2d { }; struct hovtype { - /*0x00*/ f32 unk00; - /*0x04*/ f32 unk04; - /*0x08*/ f32 unk08; - /*0x0c*/ f32 unk0c; - /*0x10*/ f32 unk10; - /*0x14*/ f32 unk14; - /*0x18*/ f32 unk18; - /*0x1c*/ f32 unk1c; - /*0x20*/ f32 unk20; - /*0x24*/ f32 unk24; - /*0x28*/ f32 unk28; - /*0x2c*/ f32 unk2c; - /*0x30*/ f32 unk30; + /*0x00*/ f32 bobymid; + /*0x04*/ f32 bobyminradius; + /*0x08*/ f32 bobyrandradius; + /*0x0c*/ f32 bobyaccel; + /*0x10*/ f32 bobymaxspeed; + /*0x14*/ f32 bobpitchminangle; + /*0x18*/ f32 bobpitchrandangle; + /*0x1c*/ f32 bobpitchaccel; + /*0x20*/ f32 bobpitchmaxspeed; + /*0x24*/ f32 bobrollminangle; + /*0x28*/ f32 bobrollrandangle; + /*0x2c*/ f32 bobrollaccel; + /*0x30*/ f32 bobrollmaxspeed; }; struct modelrwdatabinding { diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 80f3d099e..31e1f2aaa 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -1,6 +1,7 @@ #include #include "lib/boot.h" #include "lib/sched.h" +#include "naudio/n_synthInternals.h" #include "constants.h" #include "bss.h" #include "lib/audiodma.h" @@ -85,8 +86,8 @@ void amgrCreate(ALSynConfig *config) g_AmgrFreqPerTick++; } - g_AmgrFreqPerTick = g_AmgrFreqPerTick / 184 * 184 + 184; - var800918dc = g_AmgrFreqPerTick - 184; + g_AmgrFreqPerTick = g_AmgrFreqPerTick / SAMPLES * SAMPLES + SAMPLES; + var800918dc = g_AmgrFreqPerTick - SAMPLES; var800918e4 = g_AmgrFreqPerTick + 80; var8005cf94 = 0; @@ -108,8 +109,7 @@ void amgrCreate(ALSynConfig *config) } for (i = 0; i < ARRAYCOUNT(g_AudioManager.audioInfo); i++) { - // @todo: Find out why AudioInfo is only 0x60 - g_AudioManager.audioInfo[i] = alHeapAlloc(&g_SndHeap, 1, 0x60); + g_AudioManager.audioInfo[i] = alHeapAlloc(&g_SndHeap, 1, sizeof(AudioInfo)); g_AudioManager.audioInfo[i]->frameSamples = 0; g_AudioManager.audioInfo[i]->data = alHeapAlloc(&g_SndHeap, 1, PAL ? 3688 : 1024 * 3); } diff --git a/src/lib/collision.c b/src/lib/collision.c index eb75cb0e0..f9eab66e8 100644 --- a/src/lib/collision.c +++ b/src/lib/collision.c @@ -962,9 +962,9 @@ bool cd00026a04(struct coord *pos, u8 *start, u8 *end, u16 geoflags, s32 room, s return result; } -void cdFindClosestVertical(struct coord *pos, s16 *rooms, u16 geoflags, struct geo **geoptr, s16 *roomptr, f32 *groundptr, struct prop **propptr, bool ceiling) +void cdFindClosestVertical(struct coord *pos, RoomNum *rooms, u16 geoflags, struct geo **geoptr, RoomNum *roomptr, f32 *groundptr, struct prop **propptr, bool ceiling) { - s16 *roomptr2; + RoomNum *roomptr2; s32 roomnum; u8 *start; u8 *end; @@ -1262,9 +1262,9 @@ void cdCollectGeoForCylFromList(struct coord *pos, f32 radius, u8 *start, u8 *en } } -void cdCollectGeoForCyl(struct coord *pos, f32 radius, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) +void cdCollectGeoForCyl(struct coord *pos, f32 radius, RoomNum *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) { - s16 *roomptr; + RoomNum *roomptr; s32 roomnum; u8 *start; u8 *end; @@ -1590,9 +1590,9 @@ void cdCollectGeoForCylMoveFromList(u8 *start, u8 *end, struct coord *pos, f32 r } } -void cdCollectGeoForCylMove(struct coord *pos, f32 width, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) +void cdCollectGeoForCylMove(struct coord *pos, f32 width, RoomNum *rooms, u32 types, u16 geoflags, bool checkvertical, f32 ymax, f32 ymin, struct collision *collisions, s32 maxcollisions) { - s16 *roomptr; + RoomNum *roomptr; s32 roomnum; u8 *start; u8 *end; @@ -2139,7 +2139,7 @@ f32 cdFindGroundFromList(struct collision *collisions, struct coord *pos, struct * There is nothing specific to ladders in this function, but it's only used * for finding ladders. */ -bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags, struct coord *laddernormal) +bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, RoomNum *rooms, u16 geoflags, struct coord *laddernormal) { struct collision collisions[2]; @@ -2167,7 +2167,7 @@ bool cdFindLadder(struct coord *pos, f32 width, f32 ymax, f32 ymin, s16 *rooms, return false; } -bool cd0002a13c(struct coord *pos, f32 radius, f32 ymax, f32 ymin, s16 *rooms, u16 geoflags) +bool cd0002a13c(struct coord *pos, f32 radius, f32 ymax, f32 ymin, RoomNum *rooms, u16 geoflags) { struct collision collisions[2]; @@ -2180,8 +2180,8 @@ bool cd0002a13c(struct coord *pos, f32 radius, f32 ymax, f32 ymin, s16 *rooms, u return false; } -f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, - u8 *floortype, u16 *floorflags, s16 *floorroom, s32 *inlift, struct prop **lift) +f32 cdFindGroundInfoAtCyl(struct coord *pos, f32 radius, RoomNum *rooms, u16 *floorcol, + u8 *floortype, u16 *floorflags, RoomNum *floorroom, s32 *inlift, struct prop **lift) { struct collision collisions[21]; struct collision *sp72 = NULL; @@ -2244,15 +2244,15 @@ f32 cdReturnZero(void) return 0; } -f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, s16 *rooms, u16 *floorcol, u8 *floortype) +f32 cdFindGroundAtCyl(struct coord *pos, f32 radius, RoomNum *rooms, u16 *floorcol, u8 *floortype) { return cdFindGroundInfoAtCyl(pos, radius, rooms, floorcol, floortype, NULL, NULL, NULL, NULL); } -f32 cdFindFloorYColourTypeAtPos(struct coord *pos, s16 *rooms, u16 *floorcol, u8 *floortype) +f32 cdFindFloorYColourTypeAtPos(struct coord *pos, RoomNum *rooms, u16 *floorcol, u8 *floortype) { struct geo *geo; - s16 sp30[2]; + RoomNum sp30[2]; f32 sp2c; f32 result = -4294967296; @@ -2273,10 +2273,10 @@ f32 cdFindFloorYColourTypeAtPos(struct coord *pos, s16 *rooms, u16 *floorcol, u8 return result; } -s32 cdFindFloorRoomAtPos(struct coord *pos, s16 *nearrooms) +s32 cdFindFloorRoomAtPos(struct coord *pos, RoomNum *nearrooms) { struct geo *geo; - s16 room; + RoomNum room; f32 sp2c; cdFindClosestVertical(pos, nearrooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, 0, SURFACE_FLOOR); @@ -2285,13 +2285,13 @@ s32 cdFindFloorRoomAtPos(struct coord *pos, s16 *nearrooms) } #if VERSION >= VERSION_NTSC_1_0 -s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) +RoomNum cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) #else -s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) +RoomNum cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr) #endif { struct geo *geo; - s16 room; + RoomNum room; f32 sp2c; cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, NULL, SURFACE_FLOOR); @@ -2314,13 +2314,13 @@ s16 cdFindFloorRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u } #if VERSION >= VERSION_NTSC_1_0 -s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) +RoomNum cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr, u16 *flagsptr) #else -s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcolptr) +RoomNum cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcolptr) #endif { struct geo *geo; - s16 sp32; + RoomNum sp32; f32 sp2c; cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &sp32, &sp2c, NULL, SURFACE_CEILING); @@ -2342,10 +2342,10 @@ s16 cdFindCeilingRoomYColourFlagsAtPos(struct coord *pos, s16 *rooms, f32 *arg2, return sp32; } -s16 cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr) +RoomNum cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcol, struct coord *normal, struct prop **propptr) { struct geo *geo; - s16 room; + RoomNum room; f32 sp2c; cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &room, &sp2c, propptr, SURFACE_FLOOR); @@ -2362,10 +2362,10 @@ s16 cdFindFloorRoomYColourNormalPropAtPos(struct coord *pos, s16 *rooms, f32 *ar return room; } -s16 cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, s16 *rooms, f32 *arg2, u16 *floorcol, u16 *flagsptr, struct coord *normal) +RoomNum cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, RoomNum *rooms, f32 *arg2, u16 *floorcol, u16 *flagsptr, struct coord *normal) { struct geo *geo; - s16 sp32; + RoomNum sp32; f32 sp2c; cdFindClosestVertical(pos, rooms, GEOFLAG_FLOOR1 | GEOFLAG_FLOOR2, &geo, &sp32, &sp2c, NULL, SURFACE_CEILING); @@ -2389,7 +2389,7 @@ s16 cdFindCeilingRoomYColourFlagsNormalAtPos(struct coord *pos, s16 *rooms, f32 /** * Tests if a cylinder volume fits in the given position. */ -s32 cdTestVolume(struct coord *pos, f32 width, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) +s32 cdTestVolume(struct coord *pos, f32 width, RoomNum *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { struct collision collisions[2]; bool result = true; @@ -2404,7 +2404,7 @@ s32 cdTestVolume(struct coord *pos, f32 width, s16 *rooms, s32 types, bool check return result; } -s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, s16 *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) +s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, RoomNum *rooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { struct collision collisions[2]; s32 cdresult; @@ -2469,7 +2469,7 @@ s32 cdExamCylMove01(struct coord *pos, struct coord *pos2, f32 radius, s16 *room return cdresult; } -s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, s16 *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) +s32 cdExamCylMove02(struct coord *origpos, struct coord *dstpos, f32 width, RoomNum *dstrooms, s32 types, bool checkvertical, f32 ymax, f32 ymin) { struct collision collisions[21]; struct coord dist; @@ -3337,10 +3337,10 @@ bool cdExamAToBGeolist(u8 *start, u8 *end, struct coord *arg2, struct coord *arg return !result; } -bool cdTestAToB(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) +bool cdTestAToB(struct coord *pos, struct coord *coord2, RoomNum *rooms, u32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) { s32 roomnum; - s16 *roomptr; + RoomNum *roomptr; u8 *start; u8 *end; struct coord sp27c; @@ -3391,10 +3391,10 @@ bool cdTestAToB(struct coord *pos, struct coord *coord2, s16 *rooms, u32 types, return true; } -s32 cdExamAToB(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamAToB(struct coord *arg0, struct coord *arg1, RoomNum *rooms, s32 types, u16 geoflags, bool checkvertical, s32 arg6, f32 ymax, f32 ymin) { s32 roomnum; - s16 *roomptr; + RoomNum *roomptr; u8 *start; u8 *end; struct coord sp2c4; @@ -3451,21 +3451,21 @@ s32 cdExamAToB(struct coord *arg0, struct coord *arg1, s16 *rooms, s32 types, u1 return !sp2c0; } -bool cdTestCylMove01(struct coord *pos, s16 *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin) +bool cdTestCylMove01(struct coord *pos, RoomNum *rooms, struct coord *targetpos, u32 types, u32 arg4, f32 ymax, f32 ymin) { - s16 sp44[21]; - s16 sp34[8]; + RoomNum sp44[21]; + RoomNum sp34[8]; portal00018148(pos, targetpos, rooms, sp34, sp44, 20); return cdTestAToB(pos, targetpos, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg4, ymax, ymin); } -s32 cdTestCylMove02(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *rooms2, u32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdTestCylMove02(struct coord *pos, RoomNum *rooms, struct coord *coord2, RoomNum *rooms2, u32 types, s32 arg5, f32 ymax, f32 ymin) { s32 result; - s16 sp44[20]; - s16 sp34[8]; + RoomNum sp44[20]; + RoomNum sp34[8]; func0f065d1c(pos, rooms, coord2, sp34, sp44, 20); @@ -3478,29 +3478,29 @@ s32 cdTestCylMove02(struct coord *pos, s16 *rooms, struct coord *coord2, s16 *ro return result; } -s32 cdExamCylMove03(struct coord *pos, s16 *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin) +s32 cdExamCylMove03(struct coord *pos, RoomNum *rooms, struct coord *arg2, u32 types, u32 arg4, f32 ymax, f32 ymin) { - s16 sp44[21]; - s16 sp34[8]; + RoomNum sp44[21]; + RoomNum sp34[8]; portal00018148(pos, arg2, rooms, sp34, sp44, 20); return cdExamAToB(pos, arg2, sp44, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg4, ymax, ymin); } -s32 cdTestCylMove04(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdTestCylMove04(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) { - s16 rooms[21]; + RoomNum rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cdTestAToB(arg0, arg2, rooms, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); } -s32 cdExamCylMove05(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin) +s32 cdExamCylMove05(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, s32 types, bool arg5, f32 ymax, f32 ymin) { - s16 sp44[21]; - s16 sp34[8]; + RoomNum sp44[21]; + RoomNum sp34[8]; s32 result; func0f065d1c(pos, rooms, pos2, sp34, sp44, 20); @@ -3515,10 +3515,10 @@ s32 cdExamCylMove05(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *room return result; } -s32 cdExamCylMove06(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, s32 types, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamCylMove06(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, f32 width, s32 types, s32 arg6, f32 ymax, f32 ymin) { - s16 sp5c[21]; - s16 sp4c[8]; + RoomNum sp5c[21]; + RoomNum sp4c[8]; struct coord sp40; s32 result; @@ -3540,18 +3540,18 @@ s32 cdExamCylMove06(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3 return result; } -s32 cdExamCylMove07(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) +s32 cdExamCylMove07(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, s32 arg5, f32 ymax, f32 ymin) { - s16 rooms[21]; + RoomNum rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cdExamAToB(arg0, arg2, rooms, types, GEOFLAG_WALL, CHECKVERTICAL_NO, arg5, ymax, ymin); } -s32 cdExamCylMove08(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin) +s32 cdExamCylMove08(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, f32 width, u32 types, s32 arg6, f32 ymax, f32 ymin) { - s16 rooms[21]; + RoomNum rooms[21]; struct coord sp40; s32 result; @@ -3570,26 +3570,26 @@ s32 cdExamCylMove08(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3 return result; } -bool cdTestLos03(struct coord *viewpos, s16 *rooms, struct coord *targetpos, u32 types, u16 geoflags) +bool cdTestLos03(struct coord *viewpos, RoomNum *rooms, struct coord *targetpos, u32 types, u16 geoflags) { - s16 sp44[21]; - s16 sp34[8]; + RoomNum sp44[21]; + RoomNum sp34[8]; portal00018148(viewpos, targetpos, rooms, sp34, sp44, 20); return cdTestAToB(viewpos, targetpos, sp44, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -bool cdTestLos04(struct coord *frompos, s16 *fromrooms, struct coord *topos, s32 types) +bool cdTestLos04(struct coord *frompos, RoomNum *fromrooms, struct coord *topos, s32 types) { return cdTestLos03(frompos, fromrooms, topos, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -bool cdTestLos05(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *rooms2, s32 types, u16 geoflags) +bool cdTestLos05(struct coord *coord, RoomNum *rooms, struct coord *coord2, RoomNum *rooms2, s32 types, u16 geoflags) { bool result; - s16 sp44[20]; - s16 sp34[8]; + RoomNum sp44[20]; + RoomNum sp34[8]; func0f065d1c(coord, rooms, coord2, sp34, sp44, 20); @@ -3602,15 +3602,15 @@ bool cdTestLos05(struct coord *coord, s16 *rooms, struct coord *coord2, s16 *roo return result; } -bool cdTestLos06(struct coord *arg0, s16 *rooms1, struct coord *arg2, s16 *rooms2, u32 types) +bool cdTestLos06(struct coord *arg0, RoomNum *rooms1, struct coord *arg2, RoomNum *rooms2, u32 types) { return cdTestLos05(arg0, rooms1, arg2, rooms2, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -bool cdTestLos07(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, s16 *rooms3, u32 types, u16 geoflags) +bool cdTestLos07(struct coord *pos, RoomNum *rooms, struct coord *pos2, RoomNum *rooms2, RoomNum *rooms3, u32 types, u16 geoflags) { bool result; - s16 sp34[20]; + RoomNum sp34[20]; func0f065d1c(pos, rooms, pos2, rooms3, sp34, 20); @@ -3623,31 +3623,31 @@ bool cdTestLos07(struct coord *pos, s16 *rooms, struct coord *pos2, s16 *rooms2, return result; } -s32 cdExamLos08(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types, u16 geoflags) +s32 cdExamLos08(struct coord *pos, RoomNum *rooms, struct coord *pos2, u32 types, u16 geoflags) { - s16 sp44[21]; - s16 sp34[8]; + RoomNum sp44[21]; + RoomNum sp34[8]; portal00018148(pos, pos2, rooms, sp34, sp44, 20); return cdExamAToB(pos, pos2, sp44, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -s32 cdExamLos09(struct coord *pos, s16 *rooms, struct coord *pos2, u32 types) +s32 cdExamLos09(struct coord *pos, RoomNum *rooms, struct coord *pos2, u32 types) { return cdExamLos08(pos, rooms, pos2, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } -s32 cdTestLos10(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types, u16 geoflags) +s32 cdTestLos10(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types, u16 geoflags) { - s16 rooms[21]; + RoomNum rooms[21]; portal00018148(arg0, arg2, arg1, arg3, rooms, 20); return cdTestAToB(arg0, arg2, rooms, types, geoflags, CHECKVERTICAL_YES, 1, 0, 0); } -s32 cdTestLos11(struct coord *arg0, s16 *arg1, struct coord *arg2, s16 *arg3, u32 types) +s32 cdTestLos11(struct coord *arg0, RoomNum *arg1, struct coord *arg2, RoomNum *arg3, u32 types) { return cdTestLos10(arg0, arg1, arg2, arg3, types, GEOFLAG_WALL | GEOFLAG_BLOCK_SIGHT | GEOFLAG_BLOCK_SHOOT); } @@ -3811,13 +3811,13 @@ s32 cdTestBlockOverlapsGeolist(u8 *start, u8 *end, struct geoblock *block, u16 g * and is also used in a sanity check to make sure a moved object hasn't moved * into the player's position. */ -s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, s16 *rooms, u32 types) +s32 cdTestBlockOverlapsAnyProp(struct geoblock *geo, RoomNum *rooms, u32 types) { s32 result = CDRESULT_NOCOLLISION; s32 roomnum; u8 *start; u8 *end; - s16 *roomptr; + RoomNum *roomptr; s16 propnums[256]; s16 *propnumptr; @@ -4065,7 +4065,7 @@ bool cd0002ed30(u8 *start, u8 *end, struct geoblock *block, s32 numvertices, str return true; } -bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) +bool cd0002f02c(struct geoblock *block, RoomNum *rooms, s32 types) { s32 numvertices = block->header.numvertices; s32 i; @@ -4093,7 +4093,7 @@ bool cd0002f02c(struct geoblock *block, s16 *rooms, s32 types) } if (types & CDTYPE_BG) { - s16 *roomsptr = rooms; + RoomNum *roomsptr = rooms; s32 roomnum = *roomsptr; while (roomnum != -1) { @@ -4232,7 +4232,7 @@ void cd0002f2fc(u32 arg0, u32 arg1) // empty } -bool cdIsNearlyInSightWithFlags(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 types, u16 geoflags) +bool cdIsNearlyInSightWithFlags(struct coord *viewpos, RoomNum *rooms, struct coord *targetpos, f32 distance, s32 types, u16 geoflags) { struct coord diff; f32 x; @@ -4271,7 +4271,7 @@ bool cdIsNearlyInSightWithFlags(struct coord *viewpos, s16 *rooms, struct coord return false; } -bool cdIsNearlyInSight(struct coord *viewpos, s16 *rooms, struct coord *targetpos, f32 distance, s32 types) +bool cdIsNearlyInSight(struct coord *viewpos, RoomNum *rooms, struct coord *targetpos, f32 distance, s32 types) { return cdIsNearlyInSightWithFlags(viewpos, rooms, targetpos, distance, types, GEOFLAG_BLOCK_SIGHT); } diff --git a/src/lib/joy.c b/src/lib/joy.c index 64e7b969f..d371d8f05 100644 --- a/src/lib/joy.c +++ b/src/lib/joy.c @@ -101,84 +101,66 @@ u32 var8005eed4 = 0; u8 var8005eed8 = 0; #if VERSION >= VERSION_NTSC_1_0 -bool var8005eedc = true; -s32 var8005eee0 = 0; -s32 var8005eee4 = -1; -u32 var8005eee8 = 0; -u32 var8005eeec = 0; -u32 var8005eef0 = 1; +bool g_JoyPfsPollMasterEnabled = true; +s32 g_JoyPfsPollInterval = 0; +s32 g_JoyPfsPollTimeRemaining = -1; +u32 g_JoyPfsPollCount = 0; +bool g_JoyPfsPollEnabled = false; +bool g_JoyCyclicPollingLocked = true; #else u32 var800612c8nb = 3; u8 var800612ccnb = 0; #endif #if VERSION >= VERSION_NTSC_1_0 -void joy00013900(void) +void joyLockCyclicPolling(void) { - if (var8005eef0) { + if (g_JoyCyclicPollingLocked) { joyDisableCyclicPolling(); - var8005eef0 = false; + g_JoyCyclicPollingLocked = false; } } -void joy00013938(void) +void joyUnlockCyclicPolling(void) { - if (!var8005eef0) { + if (!g_JoyCyclicPollingLocked) { joyEnableCyclicPolling(); - var8005eef0 = true; + g_JoyCyclicPollingLocked = true; } } -void joy00013974(u32 value) +void joySetPfsPollEnabled(bool enabled) { - var8005eeec = value; + g_JoyPfsPollEnabled = enabled; +} + +bool joyIsPfsPollEnabled(void) +{ + return g_JoyPfsPollEnabled; } #endif -#if VERSION >= VERSION_NTSC_1_0 -u32 joy00013980(void) -{ - return var8005eeec; -} -#endif - -/** - * Note: Some of the variables in this file are misnamed in NTSC beta. - * @TODO: Untangle these. - */ -void joy0001398c(s32 value) +void joySetPfsPollInterval(s32 value) { #if VERSION >= VERSION_NTSC_1_0 - var8005eee4 = var8005eee0 = value * 11000; + g_JoyPfsPollTimeRemaining = g_JoyPfsPollInterval = value * 11000; #else g_JoyNextPfsStateIndex = value; #endif } -void joy000139c8(void) +void joySetDefaultPfsPollInterval(void) { - joy0001398c(VERSION >= VERSION_NTSC_1_0 ? 10 : 30); + joySetPfsPollInterval(VERSION >= VERSION_NTSC_1_0 ? 10 : 30); } -#if VERSION < VERSION_NTSC_1_0 -// Same function as the one a couple above, just relocated -u32 joy00013980(void) -{ -#if VERSION >= VERSION_NTSC_1_0 - return var8005eeec; -#else - return var8005eed8; -#endif -} -#endif - -#if VERSION >= VERSION_NTSC_1_0 /** * Remove an item from the beginning of the g_JoyPfsStates array, * shift the rest of the array back and return the removed item. */ s32 joyShiftPfsStates(void) { +#if VERSION >= VERSION_NTSC_1_0 s32 pfsstate = 0; s32 i; @@ -195,8 +177,10 @@ s32 joyShiftPfsStates(void) } return pfsstate; -} +#else + return var8005eed8; #endif +} #if VERSION >= VERSION_NTSC_1_0 void joyRecordPfsState(u8 pfsstate) @@ -215,68 +199,69 @@ void joyRecordPfsState(u8 pfsstate) #if VERSION >= VERSION_NTSC_1_0 /** * Scan controllers for controller paks, but only under certain conditions. - * Seems to be timer based, or can be forced by passing 2 as arg0. + * + * force 0 = poll based on the configured poll frequency and if not disabled + * force 1 = poll based on the configured poll frequency even if disabled + * force 2 = poll now */ -void joyCheckPfs(s32 arg0) +void joyPollPfs(s32 force) { - static u32 thiscount = 0; // 8005eef4 - static u32 prevcount = 0; // 8005eef8 - static u32 doingit = false; // 8005eefc + static u32 thiscount = 0; + static u32 prevcount = 0; + static u32 doingit = false; u32 diffcount; u32 value; - if (var8005eedc - && (arg0 == 2 || (var8005eee0 && (arg0 || ((g_JoyCyclicPollDisableCount == 0 || var8005eef0 == 0) && var8005eeec)))) + if (g_JoyPfsPollMasterEnabled + && (force == 2 || (g_JoyPfsPollInterval && (force || ((g_JoyCyclicPollDisableCount == 0 || !g_JoyCyclicPollingLocked) && g_JoyPfsPollEnabled)))) && !doingit) { doingit = true; prevcount = thiscount; thiscount = osGetCount(); diffcount = (thiscount - prevcount) / 256; - value = var8005eee0 * 2; + value = g_JoyPfsPollInterval * 2; if (diffcount > value) { diffcount = value; } - var8005eee4 -= diffcount; + g_JoyPfsPollTimeRemaining -= diffcount; - if (var8005eee4 < 0 - || arg0 == 2 - || (arg0 == 1 && var8005eee4 < 0 && var8005eee0 < -var8005eee4)) { + if (g_JoyPfsPollTimeRemaining < 0 + || force == 2 + || (force == 1 && g_JoyPfsPollTimeRemaining < 0 && -g_JoyPfsPollTimeRemaining > g_JoyPfsPollInterval)) { u8 bitpattern = 0; - var8005eee8++; + g_JoyPfsPollCount++; - if (arg0) { + if (force) { joyDisableCyclicPolling(); } osPfsIsPlug(&g_PiMesgQueue, &bitpattern); - if (arg0) { + if (force) { joyEnableCyclicPolling(); } - bitpattern |= 0x10; + bitpattern |= 0x10; // eeprom joyRecordPfsState(bitpattern); - var8005eee4 = var8005eee0; + g_JoyPfsPollTimeRemaining = g_JoyPfsPollInterval; } doingit = false; } #if VERSION < VERSION_PAL_BETA - if (arg0) { - // empty - } + if (force); #endif } #endif /** - * "Temporarily" because the next time joyCheckPfs runs, the true state will be + * "Temporarily" because the next time joyPollPfs runs, the true state will be * recorded. * * Note that var8005eed8 is always zero, so this record will suggest that this @@ -527,8 +512,8 @@ void joy00014238(void) doingit = true; for (i = 0; i < NUM_PADS; i++) { - if (joy000155f4(i) == PAK010_13) { - pakSetUnk010(i, PAK010_11); + if (joyGetPakState2(i) == PAKSTATE_13) { + pakSetState(i, PAKSTATE_READY); } } @@ -551,8 +536,8 @@ void joyDebugJoy(void) #endif #if VERSION >= VERSION_NTSC_1_0 - if (g_Vars.paksconnected) { - joyCheckPfs(1); + if (g_Vars.paksneededformenu) { + joyPollPfs(1); } #endif @@ -652,7 +637,7 @@ void joysHandleRetrace(void) var8005ee68++; #if VERSION >= VERSION_NTSC_1_0 - joyCheckPfs(0); + joyPollPfs(0); #endif return; } @@ -678,7 +663,7 @@ void joysHandleRetrace(void) if (g_JoyInitDone) { #if VERSION >= VERSION_NTSC_1_0 if (var8005ee68) { - joyCheckPfs(0); + joyPollPfs(0); return; } #endif @@ -701,7 +686,7 @@ void joysHandleRetrace(void) joy00014238(); #if VERSION >= VERSION_NTSC_1_0 - joyCheckPfs(0); + joyPollPfs(0); #else joy0001509cnb(); #endif @@ -1078,14 +1063,14 @@ void joyStopRumble(s8 arg0, bool disablepolling) } } -s32 joy000155b4(s8 device) +s32 joyGetPakState(s8 device) { - return g_Paks[device].unk010; + return g_Paks[device].state; } -s32 joy000155f4(s8 device) +s32 joyGetPakState2(s8 device) { - return joy000155b4(device); + return joyGetPakState(device); } void joysTickRumble(void) @@ -1093,7 +1078,7 @@ void joysTickRumble(void) s32 i; for (i = 0; i < NUM_PADS; i++) { - if (g_Paks[i].unk010 == PAK010_11 && g_Paks[i].type == PAKTYPE_RUMBLE) { + if (g_Paks[i].state == PAKSTATE_READY && g_Paks[i].type == PAKTYPE_RUMBLE) { switch (g_Paks[i].rumblestate) { case RUMBLESTATE_ENABLED_STARTING: g_Paks[i].rumblestate = RUMBLESTATE_ENABLED_RUMBLING; diff --git a/src/lib/lib_17ce0.c b/src/lib/lib_17ce0.c index 071dd02d9..e319ec44f 100644 --- a/src/lib/lib_17ce0.c +++ b/src/lib/lib_17ce0.c @@ -59,7 +59,7 @@ void portal00018e74nb(s32 portalnum) * The list is assumed to have 16 slots, with the last being reserved for the * -1 terminator. */ -void portal00017dc4(s16 *rooms, s16 roomnum) +void portal00017dc4(RoomNum *rooms, RoomNum roomnum) { s32 i; @@ -169,16 +169,16 @@ s32 portalCalculateIntersection(s32 portalnum, struct coord *pos1, struct coord : PORTALINTERSECTION_FRONTTOBEHIND; } -void portal00018148(struct coord *pos1, struct coord *pos2, s16 *rooms1, s16 *rooms2, s16 *rooms3, s32 arg5) +void portal00018148(struct coord *pos1, struct coord *pos2, RoomNum *rooms1, RoomNum *rooms2, RoomNum *rooms3, s32 arg5) { s32 i; s32 j; s32 roomnum; s32 numportals; s16 *portalnums; - s16 rooms9c[16]; - s16 rooms7c[16]; - s16 rooms5c[16]; + RoomNum rooms9c[16]; + RoomNum rooms7c[16]; + RoomNum rooms5c[16]; for (i = 0; i < 8; i++) { rooms9c[i] = rooms1[i]; diff --git a/src/lib/main.c b/src/lib/main.c index 2d776e661..5fe7b38fc 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -768,7 +768,7 @@ void mainLoop(void) if (g_DoBootPakMenu) { #if VERSION >= VERSION_NTSC_1_0 - g_Vars.unk0004e4 = 0xfd; + g_Vars.pakstocheck = 0xfd; #endif g_StageNum = STAGE_BOOTPAKMENU; } diff --git a/src/lib/mp3.c b/src/lib/mp3.c index b0784b8fd..925213098 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -1,6 +1,8 @@ #include #include #include "naudio/n_abi.h" +#include "ultra/audio/synthInternals.h" +#include "naudio/n_synthInternals.h" #include "lib/mp3.h" #include "mp3/mp3.h" #include "types.h" @@ -53,19 +55,18 @@ void mp3Init(ALHeap *heap) #endif g_AsiStream = alHeapAlloc(heap, sizeof(struct asistream), 1); - var8005f6f8 = alHeapAlloc(heap, 1, 0x2200); - var8005f6fc = alHeapAlloc(heap, 1, 0x2200); + var8005f6f8 = alHeapAlloc(heap, 1, 34 * 256 * sizeof(var8005f6f8[0])); + var8005f6fc = alHeapAlloc(heap, 1, 34 * 256 * sizeof(var8005f6fc[0])); - var8009c6d8 = alHeapAlloc(heap, 256 * sizeof(f32), 1); - var8009c6dc = alHeapAlloc(heap, 256 * sizeof(f32), 1); + var8009c6d8 = alHeapAlloc(heap, 256 * sizeof(var8009c6d8[0]), 1); + var8009c6dc = alHeapAlloc(heap, 256 * sizeof(var8009c6dc[0]), 1); var8009c640 = alHeapAlloc(heap, 10500 * sizeof(struct mp3decfourbytes), 1); - var8009c644 = alHeapAlloc(heap, 8192 * sizeof(f32), 1); + var8009c644 = alHeapAlloc(heap, 8192 * sizeof(var8009c644[0]), 1); mp3mainInit(); - g_Mp3Vars.var8009c398 = alHeapAlloc(heap, 1, 0x50); - *(u8 **)((uintptr_t)&g_Mp3Vars+0x44) = alHeapAlloc(heap, 1, 0x440); - + g_Mp3Vars.var8009c398 = alHeapAlloc(heap, 1, ALIGN16(sizeof(ALEnvMixer))); + g_Mp3Vars.var8009c3d4[0] = alHeapAlloc(heap, 1, 0x440); g_Mp3Vars.var8009c3e0 = 0; g_Mp3Vars.var8009c3e4 = 0x7fff; g_Mp3Vars.var8009c3ec = g_Mp3Vars.var8009c3ee = 0x40; @@ -180,8 +181,8 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) struct mp3thing *sp58; struct mp3thing *sp54 = NULL; s32 sp50; - s32 sp4c = 0x4e0; - s32 sp48 = 0x650; + s32 sp4c = N_AL_MAIN_L_OUT; + s32 sp48 = N_AL_MAIN_R_OUT; if (g_Mp3Vars.var8009c3ec != g_Mp3Vars.var8009c3ee) { sp60 = g_Mp3Vars.var8009c3ee - g_Mp3Vars.var8009c3ec; @@ -212,7 +213,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) g_Mp3Vars.var8009c3d0 = 0; g_Mp3Vars.var8009c3d8 = 0; - bzero(*(u32 **)&g_Mp3Vars.var8009c3d4, 0x440); + bzero(g_Mp3Vars.var8009c3d4[0], 0x440); } } else { g_Mp3Vars.var8009c3f0--; @@ -245,7 +246,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) g_Mp3Vars.var8009c3c8 = sp58; for (i = 0; i < sp5c; i++) { - acmd08((*cmd)++, osVirtualToPhysical(g_Mp3Vars.var8009c3d4_arr[i])); + acmd08((*cmd)++, osVirtualToPhysical(g_Mp3Vars.var8009c3d4[i])); acmd07((*cmd)++, g_Mp3Vars.var8009c3d8, osVirtualToPhysical(sp58)); sp58++; @@ -294,7 +295,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) func00038924(&g_Mp3Vars); if (!g_Mp3Vars.var8009c3f1) { - aClearBuffer((*cmd)++, 0x4e0, 0x2e0); + aClearBuffer((*cmd)++, N_AL_MAIN_L_OUT, N_AL_TEMP_2); if (g_Mp3Vars.var8009c3b4) { g_Mp3Vars.var8009c3b4 = 0; @@ -313,7 +314,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) n_aEnvMixer((*cmd)++, 0, 0, osVirtualToPhysical(g_Mp3Vars.var8009c398)); } - g_Mp3Vars.samples += 184; + g_Mp3Vars.samples += SAMPLES; if (g_Mp3Vars.samples > g_Mp3Vars.var8009c3bc) { g_Mp3Vars.samples = g_Mp3Vars.var8009c3bc; @@ -367,7 +368,7 @@ void func00038924(struct mp3vars *vars) } vars->samples = 0; - vars->var8009c3bc = (vars->var8009c3e8 + 183) / 184 * 184; + vars->var8009c3bc = SAMPLE184(vars->var8009c3e8); vars->var8009c3b4 = 1; } } diff --git a/src/lib/naudio/n_csplayer.c b/src/lib/naudio/n_csplayer.c index cc534816d..f8e849c86 100644 --- a/src/lib/naudio/n_csplayer.c +++ b/src/lib/naudio/n_csplayer.c @@ -281,7 +281,7 @@ ALMicroTime __n_CSPVoiceHandler(void *node) ALFxRef fx = func0003e5b8(seqp->nextEvent.msg.evt19.unk00); if (fx) { - func0003e674((struct fx *) fx, seqp->nextEvent.msg.evt19.unk01, &seqp->nextEvent.msg.evt19.param); + func0003e674(fx, seqp->nextEvent.msg.evt19.unk01, &seqp->nextEvent.msg.evt19.param); } } break; diff --git a/src/lib/naudio/n_drvrNew.c b/src/lib/naudio/n_drvrNew.c index 89b497d59..47383a3dd 100644 --- a/src/lib/naudio/n_drvrNew.c +++ b/src/lib/naudio/n_drvrNew.c @@ -175,11 +175,11 @@ void n_alFxNew(ALFx **fx_ar, ALSynConfig *c, s16 bus, ALHeap *hp) r->base[1] = alHeapAlloc(hp, r->length, sizeof(s16)); r->input[1] = r->base[1]; - for (k=0; k < r->length; k++) { + for (k = 0; k < r->length; k++) { r->base[0][k] = r->base[1][k] = 0; } - for ( i=0; isection_count; i++ ){ + for (i = 0; i < r->section_count; i++) { d = &r->delay[i]; d->input = param[j++]; d->output = param[j++]; diff --git a/src/lib/naudio/n_mainbus.c b/src/lib/naudio/n_mainbus.c index bba347bbe..102c86f7f 100644 --- a/src/lib/naudio/n_mainbus.c +++ b/src/lib/naudio/n_mainbus.c @@ -32,15 +32,14 @@ Acmd *n_alMainBusPull(s32 sampleOffset, Acmd *p) aMix(ptr++, 0, 0x7fff, N_AL_AUX_L_OUT, N_AL_MAIN_L_OUT); } - if (n_syn->auxBus[i].unk44->unk02 > 0) { + if (n_syn->auxBus[i].unk44->fx.unk02 > 0) { struct auxbus44 *bus44 = n_syn->auxBus[i].unk44; if (bus44->unk28) { - // @todo: Remove cast - func0003ba64((struct fx *)bus44, n_syn->outputRate); + func0003ba64(&bus44->fx, n_syn->outputRate); } - n_aLoadADPCM(ptr++, 32, osVirtualToPhysical(&bus44->unk08)); + n_aLoadADPCM(ptr++, 32, osVirtualToPhysical(&bus44->fx.unk08)); n_aPoleFilter(ptr++, 0, N_AL_MAIN_L_OUT, 0, osVirtualToPhysical(bus44->unk2c) & 0xffffff); n_aPoleFilter(ptr++, 0, N_AL_MAIN_R_OUT, 0, osVirtualToPhysical(bus44->unk30) & 0xffffff); diff --git a/src/lib/naudio/n_sndplayer.c b/src/lib/naudio/n_sndplayer.c index 82f4fdbac..9c3e4e8ae 100644 --- a/src/lib/naudio/n_sndplayer.c +++ b/src/lib/naudio/n_sndplayer.c @@ -41,7 +41,7 @@ void n_alSndpNew(ALSndpConfig *config) g_SndPlayer->sndState = ptr; // Init the event queue - ptr = alHeapAlloc(config->heap, 1, config->maxEvents * 0x1c); + ptr = alHeapAlloc(config->heap, 1, config->maxEvents * sizeof(N_ALEventListItem)); n_alEvtqNew(&g_SndPlayer->evtq, ptr, config->maxEvents); g_SndpFreeStatesHead = g_SndPlayer->sndState; diff --git a/src/lib/naudio/n_synthInternals.h b/src/lib/naudio/n_synthInternals.h index a5f91400b..faf6334ae 100644 --- a/src/lib/naudio/n_synthInternals.h +++ b/src/lib/naudio/n_synthInternals.h @@ -99,10 +99,6 @@ typedef struct N_PVoice_s { u8 unk8c; u16 unk8e; struct fx fx; - s32 unka8; - s32 unkac; - s32 unkb0; - s32 unkb4; s32 unkb8; void *unkbc; // size 8 } N_PVoice; @@ -123,25 +119,14 @@ typedef struct N_ALMainBus_s { N_ALFilter filter; } N_ALMainBus; -// Suspected to be the same as struct fx, but auxbus44 is too big to fit inside N_PVoice. -// Maybe auxbus44 contains struct fx at unk00, then adds unk30 and unk34? struct auxbus44 { - u16 unk00; - s16 unk02; - u32 unk04; - u32 unk08; - u32 unk0c; - u32 unk10; - u32 unk14; - u32 unk18; - u32 unk1c; - u32 unk20; - u32 unk24; + struct fx fx; u32 unk28; - void *unk2c; // size 8 - void *unk30; // size 8 + POLEF_STATE *unk2c; + POLEF_STATE *unk30; u32 unk34; }; + typedef struct N_ALAuxBus_s { ALFilter filter; s32 sourceCount; diff --git a/src/lib/naudio/n_synthesizer.c b/src/lib/naudio/n_synthesizer.c index 418b9bb97..546a1a2f5 100644 --- a/src/lib/naudio/n_synthesizer.c +++ b/src/lib/naudio/n_synthesizer.c @@ -36,18 +36,18 @@ void n_alSynNew(ALSynConfig *c) for (i = 0; i < n_syn->maxAuxBusses; i++) { n_syn->auxBus[i].sourceCount = 0; n_syn->auxBus[i].maxSources = c->maxPVoices; - n_syn->auxBus[i].sources = alHeapAlloc(hp, c->maxPVoices, 4); + n_syn->auxBus[i].sources = alHeapAlloc(hp, c->maxPVoices, sizeof(void *)); if (c->fxTypes[i]) { n_syn->auxBus[i].fx = n_alSynAllocFX(i, c, hp); } else { - n_syn->auxBus[i].fx = 0; + n_syn->auxBus[i].fx = NULL; } n_syn->auxBus[i].unk44 = alHeapAlloc(hp, 1, sizeof(struct auxbus44)); - n_syn->auxBus[i].unk44->unk02 = 0; - n_syn->auxBus[i].unk44->unk2c = alHeapAlloc(hp, 1, 8); - n_syn->auxBus[i].unk44->unk30 = alHeapAlloc(hp, 1, 8); + n_syn->auxBus[i].unk44->fx.unk02 = 0; + n_syn->auxBus[i].unk44->unk2c = alHeapAlloc(hp, 1, sizeof(POLEF_STATE)); + n_syn->auxBus[i].unk44->unk30 = alHeapAlloc(hp, 1, sizeof(POLEF_STATE)); } /******* main new *******************************/ diff --git a/src/lib/sched.c b/src/lib/sched.c index 9d0311593..266e4cb68 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -352,7 +352,7 @@ void __scHandleRetrace(OSSched *sc) schedRenderCrashPeriodically(sc->frameCount); } -extern struct sndcache g_SndCache; +extern u8 g_SndCache; /** * __scHandleTasks is called both on retrace and when the RDP completes a task. @@ -411,7 +411,7 @@ void __scHandleTasks(OSSched *sc) } if (checksum != CHECKSUM_PLACEHOLDER) { - u8 *addr = (u8 *) &g_SndCache; + u8 *addr = &g_SndCache; for (i = 0; i < 40; i++) { addr[4 + i] = 0xff; diff --git a/src/lib/snd.c b/src/lib/snd.c index 28f46444d..6eb771a9d 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -26,6 +26,24 @@ #include "preprocess.h" #endif +#define MAX_SEQ_SIZE_4MB 1024 * 14 +#define MAX_SEQ_SIZE_8MB 1024 * 18 + +#define NUM_CACHE_SLOTS 45 +#define NUM_KEYTHINGS 9 + +struct sndcache { + /*0x0000*/ u16 *indexes; // indexed by sfxnum, value is cache index (0-44) or 0xffff + /*0x0004*/ u8 refcounts[NUM_CACHE_SLOTS]; + /*0x0032*/ u16 ages[NUM_CACHE_SLOTS]; + /*0x008c*/ ALEnvelope envelopes[NUM_CACHE_SLOTS]; + /*0x035c*/ ALKeyMap keymaps[NUM_CACHE_SLOTS]; + /*0x046c*/ ALWaveTable wavetables[NUM_CACHE_SLOTS]; + /*0x07f0*/ ALADPCMBook books[NUM_CACHE_SLOTS]; + /*0x3658*/ ALADPCMloop loops[NUM_CACHE_SLOTS]; + /*0x3e14*/ ALSound sounds[NUM_CACHE_SLOTS]; +}; + struct curmp3 { union soundnumhack sfxref; u32 playing; @@ -885,7 +903,7 @@ void sndSetSfxVolume(u16 volume) } #endif - for (i = 0; i < 9; i++) { + for (i = 0; i < NUM_KEYTHINGS; i++) { func00033f44(i, volume); } @@ -902,7 +920,7 @@ void snd0000ea80(u16 volume) } #endif - for (i = 0; i < 9; i++) { + for (i = 0; i < NUM_KEYTHINGS; i++) { func00033f44(i, volume); } } @@ -979,7 +997,7 @@ void sndLoadSfxCtl(void) g_SndCache.indexes[i] = -1; } - for (i = 0; i < 45; i++) { + for (i = 0; i < NUM_CACHE_SLOTS; i++) { #if VERSION >= VERSION_NTSC_1_0 g_SndCache.ages[i] = 1; #else @@ -995,7 +1013,7 @@ void sndIncrementAges(void) { s32 i; - for (i = 0; i < 45; i++) { + for (i = 0; i < NUM_CACHE_SLOTS; i++) { if (g_SndCache.refcounts[i] == 0 && g_SndCache.ages[i] < 32000) { g_SndCache.ages[i]++; } @@ -1317,7 +1335,7 @@ ALSound *sndLoadSound(s16 soundnum) oldestindex = -1; oldestage = 0; - for (i = 0; i < 45; i++) { + for (i = 0; i < NUM_CACHE_SLOTS; i++) { if (g_SndCache.refcounts[i] == 0) { #if VERSION >= VERSION_NTSC_1_0 if (g_SndCache.ages[i] > oldestage) { @@ -1386,9 +1404,9 @@ void seqInit(struct seqinstance *seq) func00030c98(&config); if (IS4MB()) { - g_SeqBufferSize = 0x3800; + g_SeqBufferSize = MAX_SEQ_SIZE_4MB; } else { - g_SeqBufferSize = 0x4800; + g_SeqBufferSize = MAX_SEQ_SIZE_8MB; } seq->data = alHeapAlloc(&g_SndHeap, 1, g_SeqBufferSize); @@ -1401,7 +1419,7 @@ void seqInit(struct seqinstance *seq) void sndAddRef(ALSound *sound) { - if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[44]) { + if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[NUM_CACHE_SLOTS - 1]) { s32 cacheindex = sound - g_SndCache.sounds; g_SndCache.refcounts[cacheindex]++; } @@ -1409,7 +1427,7 @@ void sndAddRef(ALSound *sound) void sndRemoveRef(ALSound *sound) { - if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[44]) { + if (sound >= &g_SndCache.sounds[0] && sound <= &g_SndCache.sounds[NUM_CACHE_SLOTS - 1]) { s32 cacheindex = sound - g_SndCache.sounds; g_SndCache.refcounts[cacheindex]--; } @@ -1420,7 +1438,7 @@ void sndInit(void) ALSndpConfig sndpconfig; ALSynConfig synconfig; #if VERSION >= VERSION_PAL_BETA - u32 settings[3]; + u32 settings[3]; #endif #if VERSION >= VERSION_JPN_FINAL @@ -1476,7 +1494,7 @@ void sndInit(void) // Allocate some space at the start of the heap for a string identifier. // This might be used to determine if the heap has overflowed. - g_SndGuardStringPtr = alHeapAlloc(&g_SndHeap, 1, 32); + g_SndGuardStringPtr = alHeapAlloc(&g_SndHeap, 1, ALIGN16(sizeof(g_SndGuardString))); strcpy(g_SndGuardStringPtr, g_SndGuardString); // Load sfx.ctl @@ -1499,7 +1517,7 @@ void sndInit(void) len = g_SeqTable->count * sizeof(struct seqtableentry) + 4; g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len); - dmaExec(g_SeqTable, (romptr_t) REF_SEG _sequencesSegmentRomStart, (len + 0xf) & 0xfffffff0); + dmaExec(g_SeqTable, (romptr_t) REF_SEG _sequencesSegmentRomStart, (len + 0xf) & ~0xf); // Promote segment-relative offsets to ROM addresses for (i = 0; i < g_SeqTable->count; i++) { @@ -1521,7 +1539,7 @@ void sndInit(void) sndpconfig.maxEvents = 64; sndpconfig.maxStates = 64; sndpconfig.maxSounds = 20; - sndpconfig.unk10 = 9; + sndpconfig.unk10 = NUM_KEYTHINGS; sndpconfig.heap = &g_SndHeap; #if VERSION >= VERSION_PAL_BETA @@ -1544,7 +1562,7 @@ void sndInit(void) osSyncPrintf("RWI : MP3 player Initialising Done\n"); } - for (i = 0; i < 3; i++) { + for (i = 0; i < ARRAYCOUNT(g_SeqInstances); i++) { seqInit(&g_SeqInstances[i]); } diff --git a/src/setups/setupame.c b/src/setups/setupame.c index 887aa5aed..0e952d4c4 100644 --- a/src/setups/setupame.c +++ b/src/setups/setupame.c @@ -1600,14 +1600,14 @@ u8 func0414_programmer[] = { beginloop(0x91) #if VERSION >= VERSION_NTSC_1_0 set_target_chr(CHR_BOND) - if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 80, 1240, /*goto*/ 0x06) + if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 800, PAD_AME_007C, /*goto*/ 0x06) set_target_chr(CHR_COOP) - if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 80, 1240, /*goto*/ 0x06) + if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 800, PAD_AME_007C, /*goto*/ 0x06) #else set_target_chr(CHR_BOND) - if_chr_distance_to_pad_lt(CHR_TARGET, 800, 124, /*goto*/ 0x06) + if_chr_distance_to_pad_lt(CHR_TARGET, 800, PAD_AME_007C, /*goto*/ 0x06) set_target_chr(CHR_COOP) - if_chr_distance_to_pad_lt(CHR_TARGET, 800, 124, /*goto*/ 0x06) + if_chr_distance_to_pad_lt(CHR_TARGET, 800, PAD_AME_007C, /*goto*/ 0x06) #endif endloop(0x91) @@ -1623,14 +1623,14 @@ u8 func0414_programmer[] = { beginloop(0x92) #if VERSION >= VERSION_NTSC_1_0 set_target_chr(CHR_BOND) - if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, PAD_AME_0014, 1240, /*goto*/ 0x06) + if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 200, PAD_AME_007C, /*goto*/ 0x06) set_target_chr(CHR_COOP) - if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, PAD_AME_0014, 1240, /*goto*/ 0x06) + if_chr_same_floor_distance_to_pad_lt(CHR_TARGET, 200, PAD_AME_007C, /*goto*/ 0x06) #else set_target_chr(CHR_BOND) - if_chr_distance_to_pad_lt(CHR_TARGET, 200, 124, /*goto*/ 0x06) + if_chr_distance_to_pad_lt(CHR_TARGET, 200, PAD_AME_007C, /*goto*/ 0x06) set_target_chr(CHR_COOP) - if_chr_distance_to_pad_lt(CHR_TARGET, 200, 124, /*goto*/ 0x06) + if_chr_distance_to_pad_lt(CHR_TARGET, 200, PAD_AME_007C, /*goto*/ 0x06) #endif endloop(0x92)