diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-05-01 10:09:49 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2024-05-01 10:09:49 -0600 |
| commit | a2c3feb67a2f8afb1cebd0e77e4a3e23db2c28c4 (patch) | |
| tree | 4250a53478f87b8b07e16481a634ef16550ddb43 /src | |
| parent | d5264825f0a7ab67f53fca8857cbd24dd86ee86d (diff) | |
WIP Compilation
Diffstat (limited to 'src')
171 files changed, 4575 insertions, 1336 deletions
diff --git a/src/actors/banana/render.inc.c b/src/actors/banana/render.inc.c index e148cb767..ee7220421 100644 --- a/src/actors/banana/render.inc.c +++ b/src/actors/banana/render.inc.c @@ -1,13 +1,13 @@ #include <actors.h> #include <code_800029B0.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> /** * @brief Render the banana actor - * - * @param camera - * @param arg1 - * @param banana + * + * @param camera + * @param arg1 + * @param banana */ void render_actor_banana(Camera *camera, UNUSED Mat4 arg1, struct BananaActor *banana) { UNUSED s32 pad[2]; diff --git a/src/actors/blue_and_red_shells/render.inc.c b/src/actors/blue_and_red_shells/render.inc.c index 42bf7ca82..c0dc24c8f 100644 --- a/src/actors/blue_and_red_shells/render.inc.c +++ b/src/actors/blue_and_red_shells/render.inc.c @@ -1,12 +1,12 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> /** * @brief Render the red shell actor - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_red_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, &gTLUTRedShell); // set texture @@ -15,10 +15,10 @@ void render_actor_red_shell(Camera *camera, Mat4 matrix, struct ShellActor *shel /** * @brief Render the blue shell actor - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_blue_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_blue_shell); // set texture diff --git a/src/actors/box_truck/render.inc.c b/src/actors/box_truck/render.inc.c index 794dd305e..f429144c1 100644 --- a/src/actors/box_truck/render.inc.c +++ b/src/actors/box_truck/render.inc.c @@ -1,5 +1,5 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include <defines.h> #include "courses/toads_turnpike/course_data.h" @@ -8,9 +8,9 @@ * @brief Renders the box truck actor. * Actor used in Toad's Turnpike. * His update are made in vehicle. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_box_truck(Camera *arg0, struct Actor *arg1) { UNUSED s32 pad[6]; diff --git a/src/actors/cow/render.inc.c b/src/actors/cow/render.inc.c index 3800fbbbc..58042e389 100644 --- a/src/actors/cow/render.inc.c +++ b/src/actors/cow/render.inc.c @@ -1,16 +1,16 @@ #include <camera.h> #include <actors.h> #include <main.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include "courses/moo_moo_farm/course_data.h" /** * @brief Renders the cow actor. * Actor used in Moo Moo Farm. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_cow(Camera *camera, Mat4 arg1, struct Actor *arg2) { if (is_within_render_distance(camera->pos, arg2->pos, camera->rot[1], 0, gCameraZoom[camera - camera1], 4000000.0f) < 0) { return; } diff --git a/src/actors/fake_item_box/render.inc.c b/src/actors/fake_item_box/render.inc.c index 30ef468d4..e01de10a8 100644 --- a/src/actors/fake_item_box/render.inc.c +++ b/src/actors/fake_item_box/render.inc.c @@ -1,13 +1,13 @@ #include <actors.h> #include <code_800029B0.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> /** * @brief Renders the fake item box actor. - * - * @param camera - * @param fakeItemBox + * + * @param camera + * @param fakeItemBox */ void render_actor_fake_item_box(Camera *camera, struct FakeItemBox *fakeItemBox) { Vec3s someRot; diff --git a/src/actors/falling_rock/update.inc.c b/src/actors/falling_rock/update.inc.c index b10a9b26f..15f9e589d 100644 --- a/src/actors/falling_rock/update.inc.c +++ b/src/actors/falling_rock/update.inc.c @@ -4,9 +4,7 @@ #include "courses/choco_mountain/course_data.h" void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) spawnData; Vec3s sp24 = {60, 120, 180}; temp_v0 += rock->unk_06; rock->respawnTimer = sp24[rock->unk_06]; // * 2 @@ -20,14 +18,12 @@ void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { /** * @brief Spawns falling rocks. * Used in Choco Mountain. - * - * @param spawnData + * + * @param spawnData */ void spawn_falling_rocks(struct ActorSpawnData *spawnData) { - s32 addr = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); // Casting this to prevent warning does not work. - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct FallingRock *temp_v1; Vec3f startingPos; Vec3f startingVelocity; @@ -52,8 +48,8 @@ void spawn_falling_rocks(struct ActorSpawnData *spawnData) { /** * @brief Updates the falling rock actor. * Actor used in Choco Mountain. - * - * @param rock + * + * @param rock */ void update_actor_falling_rocks(struct FallingRock *rock) { Vec3f unkVec; diff --git a/src/actors/green_shell/render.inc.c b/src/actors/green_shell/render.inc.c index 627e62886..e5432f9bc 100644 --- a/src/actors/green_shell/render.inc.c +++ b/src/actors/green_shell/render.inc.c @@ -1,14 +1,14 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include <assets/common_data.h> /** * @brief Renders the green shell actor. - * - * @param camera - * @param matrix - * @param shell + * + * @param camera + * @param matrix + * @param shell */ void render_actor_green_shell(Camera *camera, Mat4 matrix, struct ShellActor *shell) { gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_green_shell); // set texture diff --git a/src/actors/kiwano_fruit/render.inc.c b/src/actors/kiwano_fruit/render.inc.c index b6d4c16bd..eef9bd5c9 100644 --- a/src/actors/kiwano_fruit/render.inc.c +++ b/src/actors/kiwano_fruit/render.inc.c @@ -1,15 +1,15 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include "courses/dks_jungle_parkway/course_data.h" /** * @brief Renders the kiwano fruit actor. * Actor used in DK's Jungle Parkway. - * - * @param camera - * @param arg1 - * @param actor + * + * @param camera + * @param arg1 + * @param actor */ void render_actor_kiwano_fruit(UNUSED Camera *camera, Mat4 arg1, struct Actor *actor) { uintptr_t addr; diff --git a/src/actors/paddle_boat/render.inc.c b/src/actors/paddle_boat/render.inc.c index 379b7455d..bf2c4006d 100644 --- a/src/actors/paddle_boat/render.inc.c +++ b/src/actors/paddle_boat/render.inc.c @@ -1,20 +1,20 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <actor_types.h> #include "camera.h" #include "main.h" #include "actors.h" #include "courses/all_course_data.h" -#include <PR/gbi.h> +#include <libultra/gbi.h> /** * @brief Renders the paddle boat actor. * Actor used in DK's Jungle Parkway. - * - * @param arg0 - * @param boat - * @param arg2 - * @param pathCounter + * + * @param arg0 + * @param boat + * @param arg2 + * @param pathCounter */ void render_actor_paddle_boat(Camera *arg0, struct PaddleWheelBoat *boat, UNUSED Mat4 arg2, u16 pathCounter) { UNUSED s32 pad[3]; @@ -25,7 +25,7 @@ void render_actor_paddle_boat(Camera *arg0, struct PaddleWheelBoat *boat, UNUSED f32 temp; if ((pathCounter > 20) && (pathCounter < 25)) { return; } - + temp = is_within_render_distance(arg0->pos, boat->pos, arg0->rot[1], 90000.0f, gCameraZoom[arg0 - camera1], 9000000.0f); if (temp < 0.0f) { return; } diff --git a/src/actors/paddle_boat/update.inc.c b/src/actors/paddle_boat/update.inc.c index 386e634d0..fdb596388 100644 --- a/src/actors/paddle_boat/update.inc.c +++ b/src/actors/paddle_boat/update.inc.c @@ -1,12 +1,12 @@ -#include <ultra64.h> +#include <libultraship.h> #include <actor_types.h> /** * @brief Updates the paddle boat actor. * Actor used in DK's Jungle Parkway. * Rotate only the paddle wheel, for position and rotation of the boat it's in vehicle. - * - * @param boat + * + * @param boat */ void update_actor_paddle_boat(struct PaddleWheelBoat *boat) { boat->wheelRot += 0x38E; diff --git a/src/actors/piranha_plant/render.inc.c b/src/actors/piranha_plant/render.inc.c index 525c73b01..8be53d488 100644 --- a/src/actors/piranha_plant/render.inc.c +++ b/src/actors/piranha_plant/render.inc.c @@ -1,16 +1,16 @@ #include <actors.h> #include <main.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include "courses/mario_raceway/course_data.h" #include "courses/royal_raceway/course_data.h" /** * @brief Renders the piranha plant actor. * Actor used in Mario Raceway and Royal Raceway. - * - * @param arg0 - * @param arg1 - * @param arg2 + * + * @param arg0 + * @param arg1 + * @param arg2 */ void render_actor_piranha_plant(Camera *arg0, Mat4 arg1, struct PiranhaPlant *arg2) { UNUSED s32 pad; diff --git a/src/actors/railroad_crossing/render.inc.c b/src/actors/railroad_crossing/render.inc.c index b87d6a695..e21894b0f 100644 --- a/src/actors/railroad_crossing/render.inc.c +++ b/src/actors/railroad_crossing/render.inc.c @@ -1,14 +1,14 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include "courses/kalimari_desert/course_data.h" /** * @brief Renders the railroad crossing actor. * Actor used in Kalimari Desert. - * - * @param arg0 - * @param rr_crossing + * + * @param arg0 + * @param rr_crossing */ void render_actor_railroad_crossing(Camera *arg0, struct RailroadCrossing *rr_crossing) { UNUSED Vec3s sp80 = {0, 0, 0}; diff --git a/src/actors/school_bus/render.inc.c b/src/actors/school_bus/render.inc.c index 163e258ee..82de0926f 100644 --- a/src/actors/school_bus/render.inc.c +++ b/src/actors/school_bus/render.inc.c @@ -1,5 +1,5 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include <defines.h> @@ -7,9 +7,9 @@ * @brief Renders the school bus actor. * Actor used in Toad's Turnpike. * His update are made in vehicle. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_school_bus(Camera *arg0, struct Actor *arg1) { UNUSED s32 pad[6]; diff --git a/src/actors/train/render.inc.c b/src/actors/train/render.inc.c index d4fab764a..ff6596c6b 100644 --- a/src/actors/train/render.inc.c +++ b/src/actors/train/render.inc.c @@ -1,5 +1,5 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include "courses/kalimari_desert/course_data.h" @@ -7,9 +7,9 @@ * @brief Renders the train engine actor. * Actor used in Kalimari Desert. * His update position are made in vehicle. - * - * @param camera - * @param actor + * + * @param camera + * @param actor */ void render_actor_train_engine(Camera *camera, struct TrainCar *actor) { UNUSED s32 pad[2]; diff --git a/src/actors/trees/render.inc.c b/src/actors/trees/render.inc.c index 9fe162160..5521e787e 100644 --- a/src/actors/trees/render.inc.c +++ b/src/actors/trees/render.inc.c @@ -1,15 +1,15 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include <assets/common_data.h> #include "courses/all_course_data.h" /** * @brief Renders the tree actor in Mario rawceay. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_mario_raceway(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -36,10 +36,10 @@ void render_actor_tree_mario_raceway(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Yoshi Valley. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_yoshi_valley(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -66,10 +66,10 @@ void render_actor_tree_yoshi_valley(Camera *camera, Mat4 arg1, struct Actor *arg /** * @brief Renders the tree actor in Royal Raceway. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_royal_raceway(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -96,10 +96,10 @@ void render_actor_tree_royal_raceway(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Moo Moo Farm. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_moo_moo_farm(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -154,10 +154,10 @@ void func_80299864(Camera *camera, Mat4 arg1, struct Actor *arg2) { /** * @brief Renders the tree actor in Bowser's Castle. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -184,10 +184,10 @@ void render_actor_tree_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the bush actor in Bowser's Castle. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_bush_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -214,10 +214,10 @@ void render_actor_bush_bowser_castle(Camera *camera, Mat4 arg1, struct Actor *ar /** * @brief Renders the tree actor in Frappe Snowland. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_frappe_snowland(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -243,10 +243,10 @@ void render_actor_tree_frappe_snowland(Camera *camera, Mat4 arg1, struct Actor * /** * @brief Renders the a first variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus1_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -272,10 +272,10 @@ void render_actor_tree_cactus1_kalimari_desert(Camera *camera, Mat4 arg1, struct /** * @brief Renders the a second variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus2_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; @@ -301,10 +301,10 @@ void render_actor_tree_cactus2_kalimari_desert(Camera *camera, Mat4 arg1, struct /** * @brief Renders the a third variant of cactus in Kalimari Desert. - * - * @param camera - * @param arg1 - * @param arg2 + * + * @param camera + * @param arg1 + * @param arg2 */ void render_actor_tree_cactus3_kalimari_desert(Camera *camera, Mat4 arg1, struct Actor *arg2) { f32 temp_f0; diff --git a/src/actors/wario_sign/render.inc.c b/src/actors/wario_sign/render.inc.c index 84216470f..1572d940b 100644 --- a/src/actors/wario_sign/render.inc.c +++ b/src/actors/wario_sign/render.inc.c @@ -1,14 +1,14 @@ #include <actors.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <main.h> #include "courses/wario_stadium/course_data.h" /** * @brief Renders the Wario sign actor. * Used in Wario Stadium. - * - * @param arg0 - * @param arg1 + * + * @param arg0 + * @param arg1 */ void render_actor_wario_sign(Camera *arg0, struct Actor *arg1) { Mat4 sp38; diff --git a/src/audio/data.c b/src/audio/data.c index f1cb322ad..f6bbc8373 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -1,4 +1,4 @@ -#include <PR/ultratypes.h> +#include <libultra/types.h> #include <macros.h> #include "data.h" diff --git a/src/audio/effects.c b/src/audio/effects.c index d8003ef1a..2ebd60da3 100644 --- a/src/audio/effects.c +++ b/src/audio/effects.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/seqplayer.h" @@ -30,7 +30,7 @@ void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 reca layer->noteFreqScale = layer->freqScale * seqChannel->freqScale; layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume; layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7; - layer->notePropertiesNeedInit = FALSE; + layer->notePropertiesNeedInit = false; } else { if (seqChannel->changes.as_bitfields.freqScale) { layer->noteFreqScale = layer->freqScale * seqChannel->freqScale; @@ -52,7 +52,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) { if (seqPlayer->fadeRemainingFrames != 0) { seqPlayer->fadeVolume += seqPlayer->fadeVelocity; - seqPlayer->recalculateVolume = TRUE; + seqPlayer->recalculateVolume = true; if (seqPlayer->fadeVolume > US_FLOAT2(1)) { seqPlayer->fadeVolume = US_FLOAT2(1); @@ -75,13 +75,13 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) { // Process channels for (i = 0; i < CHANNELS_MAX; i++) { - if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE - && seqPlayer->channels[i]->enabled == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == true + && seqPlayer->channels[i]->enabled == true) { sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->recalculateVolume); } } - seqPlayer->recalculateVolume = FALSE; + seqPlayer->recalculateVolume = false; } f32 get_portamento_freq_scale(struct Portamento *p) { @@ -176,7 +176,7 @@ void note_vibrato_init(struct Note *note) { vib = ¬e->vibratoState; - vib->active = TRUE; + vib->active = true; vib->time = 0; vib->curve = gWaveSamples[2]; diff --git a/src/audio/external.c b/src/audio/external.c index a46e63712..ead0d88eb 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <defines.h> @@ -12,6 +12,7 @@ #include "code_800029B0.h" #include "code_80005FD0.h" #include "code_80091750.h" +#include <stdbool.h> s8 D_8018EF10; UnkStruct8018EF18 D_8018EF18[16]; @@ -31,7 +32,7 @@ u8 sSoundBankFreeListFront[SOUND_BANK_COUNT]; u8 sNumSoundsInBank[SOUND_BANK_COUNT]; u8 D_80192AB8[SOUND_BANK_COUNT][8][8]; u8 D_80192C38; -ubool8 sSoundBankDisabled[SOUND_BANK_COUNT]; +bool sSoundBankDisabled[SOUND_BANK_COUNT]; struct ChannelVolumeScaleFade D_80192C48[SOUND_BANK_COUNT]; struct_D_80192CA8_entry D_80192CA8[3][5]; u8 D_80192CC6[3]; @@ -244,7 +245,7 @@ void audio_reset_session_eu(OSMesg presetId) { osRecvMesg(D_800EA3B4, &mesg, 0); osSendMesg(D_800EA3B0, presetId, 0); osRecvMesg(D_800EA3B4, &mesg, 1); - if (mesg != presetId) { + if (mesg.data32 != presetId.data32) { osRecvMesg(D_800EA3B4, &mesg, 1); } } @@ -931,7 +932,8 @@ void func_800C2A2C(u32 arg0) { break; case 15: D_800EA1C0 = (arg0 & 0xFF00) >> 8; - audio_reset_session_eu((void *) test); + // UTODO: Stubbed + // audio_reset_session_eu((void *) test); D_800EA1F4[0] = test; func_800CBBE8(0x46020000U, why); func_800C5C40(); @@ -963,14 +965,14 @@ u16 func_800C3508(u8 player) { } u8 func_800C357C(s32 arg0) { - u8 var_v1; + bool var_v1; u8 i; i = D_800EA1E8; - var_v1 = TRUE; + var_v1 = true; for(i = D_800EA1E8; i < (s32) D_800EA1E4; i++) { if ((u32) arg0 == D_80192CD0[i]) { - var_v1 = FALSE; + var_v1 = false; i = D_800EA1E4; } } @@ -1237,9 +1239,9 @@ void func_800C4084(u16 bankMask) { for (bank = 0; bank < SOUND_BANK_COUNT; bank++) { if (bankMask & 1) { - sSoundBankDisabled[bank] = TRUE; + sSoundBankDisabled[bank] = true; } else { - sSoundBankDisabled[bank] = FALSE; + sSoundBankDisabled[bank] = false; } bankMask = bankMask >> 1; } @@ -1258,7 +1260,7 @@ void play_sound(u32 soundBits, Vec3f *position, u8 cameraId, f32 *arg3, f32 *arg struct Sound *temp_v0; bank = soundBits >> 0x1C; - if (sSoundBankDisabled[bank] == FALSE) { + if (sSoundBankDisabled[bank] == false) { temp_v0 = &sSoundRequests[sSoundRequestCount]; temp_v0->soundBits = soundBits; temp_v0->position = position; @@ -1276,37 +1278,37 @@ void func_800C41CC(u8 arg0, struct SoundCharacteristics *arg1) { struct Sound *sound; for (soundId = sNumProcessedSoundRequests; soundId != sSoundRequestCount; soundId++) { - found = FALSE; + found = false; sound = &sSoundRequests[soundId]; switch (arg0) { case 0: if ((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) { - found = TRUE; + found = true; } break; case 1: if (((sound->soundBits & 0xF0000000) == (arg1->soundBits & 0xF0000000)) && (sound->position == arg1->unk00)) { - found = TRUE; + found = true; } break; case 2: if (sound->position == arg1->unk00) { - found = TRUE; + found = true; } break; case 3: if ((sound->position == arg1->unk00) && (sound->soundBits == arg1->soundBits)) { - found = TRUE; + found = true; } break; case 4: if ((sound->cameraId == arg1->cameraId) && (sound->soundBits == arg1->soundBits)) { - found = TRUE; + found = true; } break; case 5: if (sound->soundBits == arg1->soundBits) { - found = TRUE; + found = true; } break; } @@ -1806,7 +1808,7 @@ void sound_init(void) { sSoundBankUsedListBack[var_v0] = 0; sSoundBankFreeListFront[var_v0] = 1; sNumSoundsInBank[var_v0] = 0; - sSoundBankDisabled[var_v0] = FALSE; + sSoundBankDisabled[var_v0] = false; D_80192C48[var_v0].current = 1.0f; D_80192C48[var_v0].remainingFrames = 0; } diff --git a/src/audio/external.h b/src/audio/external.h index 6425b936a..42c8ab4c5 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -345,7 +345,7 @@ extern u8 sSoundBankFreeListFront[SOUND_BANK_COUNT]; extern u8 sNumSoundsInBank[SOUND_BANK_COUNT]; extern u8 D_80192AB8[SOUND_BANK_COUNT][8][8]; extern u8 D_80192C38; -extern u8 sSoundBankDisabled[SOUND_BANK_COUNT]; +extern bool sSoundBankDisabled[SOUND_BANK_COUNT]; extern struct ChannelVolumeScaleFade D_80192C48[SOUND_BANK_COUNT]; extern struct_D_80192CA8_entry D_80192CA8[3][5]; extern u8 D_80192CC6[3]; diff --git a/src/audio/heap.c b/src/audio/heap.c index 59eadb63b..53a104e06 100644 --- a/src/audio/heap.c +++ b/src/audio/heap.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/data.h" @@ -126,8 +126,8 @@ void discard_bank(s32 bankId) { if (note->priority >= NOTE_PRIORITY_MIN) { // eu_stubbed_printf_3("Kill Voice %d (ID %d) %d\n", note->waveId, bankId, note->priority); // eu_stubbed_printf_0("Warning: Running Sequence's data disappear!\n"); - note->parentLayer->enabled = FALSE; // is 0x48, should be 0x44 - note->parentLayer->finished = TRUE; + note->parentLayer->enabled = false; // is 0x48, should be 0x44 + note->parentLayer->finished = true; } note_disable(note); audio_list_remove(¬e->listItem); @@ -380,7 +380,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg pool = &arg0->temporary.pool; if (tp->entries[tp->nextSide].id != (s8)-1) { table[tp->entries[tp->nextSide].id] = SOUND_LOAD_STATUS_NOT_LOADED; - if (isSound == TRUE) { + if (isSound == true) { discard_bank(tp->entries[tp->nextSide].id); } } diff --git a/src/audio/heap.h b/src/audio/heap.h index 6a8999396..533d598d1 100644 --- a/src/audio/heap.h +++ b/src/audio/heap.h @@ -1,7 +1,7 @@ #ifndef AUDIO_HEAP_H #define AUDIO_HEAP_H -#include <PR/ultratypes.h> +#include <libultra/types.h> #include "internal.h" diff --git a/src/audio/internal.h b/src/audio/internal.h index 85ea368c9..ea67502fd 100644 --- a/src/audio/internal.h +++ b/src/audio/internal.h @@ -1,8 +1,8 @@ #ifndef AUDIO_INTERNAL_H #define AUDIO_INTERNAL_H -#include <ultra64.h> - +#include <libultraship.h> +#include "common_structs.h" #define SEQUENCE_PLAYERS 4 #define SEQUENCE_CHANNELS 48 @@ -226,7 +226,7 @@ struct SequencePlayer { /*0x11C, 0x124*/ OSIoMesg bankDmaIoMesg; /*0x130, 0x13C*/ u8 *bankDmaCurrMemAddr; /*0x138, 0x140*/ uintptr_t bankDmaCurrDevAddr; - /*0x13C, 0x144*/ ssize_t bankDmaRemaining; + /*0x13C, 0x144*/ size_t bankDmaRemaining; }; // size = 0x140, 0x148 on EU, 0x14C on SH struct AdsrSettings { diff --git a/src/audio/load.c b/src/audio/load.c index f6c60d17a..2c9e6fdfe 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/load.h" @@ -126,8 +126,8 @@ void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQ * Performs a partial asynchronous (normal priority) DMA copy. This is limited * to 0x1000 bytes transfer at once. */ -void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) { - ssize_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining); +void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, size_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) { + size_t transfer = (*remaining >= 0x1000 ? 0x1000 : *remaining); *remaining -= transfer; osInvalDCache(*vAddr, transfer); osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue); @@ -164,13 +164,13 @@ void decrease_sample_dma_ttls() { } void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { - s32 hasDma = FALSE; + s32 hasDma = false; struct SharedDma *dma; uintptr_t dmaDevAddr; u32 transfer; u32 i; u32 dmaIndex; - ssize_t bufferPos; + size_t bufferPos; UNUSED u32 pad; if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) { @@ -199,7 +199,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { // TTL 60 is pretty large. dmaIndex = sSampleDmaReuseQueue2[sSampleDmaReuseQueueTail2++]; dma = &sSampleDmas[dmaIndex]; - hasDma = TRUE; + hasDma = true; } } else { dma = &sSampleDmas[*dmaIndexRef]; @@ -231,7 +231,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) { // be empty, since TTL 2 is so small. dmaIndex = sSampleDmaReuseQueue1[sSampleDmaReuseQueueTail1++]; dma = &sSampleDmas[dmaIndex]; - hasDma = TRUE; + hasDma = true; } transfer = dma->bufSize; @@ -539,7 +539,7 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s seqPlayer->bankDmaRemaining = alloc; if (1) { } osCreateMesgQueue(&seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaMesg, 1); - seqPlayer->bankDmaInProgress = TRUE; + seqPlayer->bankDmaInProgress = true; audio_dma_partial_copy_async(&seqPlayer->bankDmaCurrDevAddr, &seqPlayer->bankDmaCurrMemAddr, &seqPlayer->bankDmaRemaining, &seqPlayer->bankDmaMesgQueue, &seqPlayer->bankDmaIoMesg); if (gBankLoadStatus[bankId] != 5) { gBankLoadStatus[bankId] = 1; @@ -590,7 +590,7 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer) audio_dma_copy_immediate(seqData, ptr, 0x00000040U); mesgQueue = &seqPlayer->seqDmaMesgQueue; osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1); - seqPlayer->seqDmaInProgress = TRUE; + seqPlayer->seqDmaInProgress = true; audio_dma_copy_async((uintptr_t) (seqData + 0x40), (u8*) ptr + 0x40, seqLength - 0x40, mesgQueue, &seqPlayer->seqDmaIoMesg); if (gSeqLoadStatus[seqId] != 5) { gSeqLoadStatus[seqId] = 1; @@ -612,7 +612,7 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) { for (i = gAlBankSets[offset++], ret = 0; i != 0; i--) { bankId = gAlBankSets[offset++]; - if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == true) { temp = get_bank_or_seq(1, 2, bankId); } else { temp = NULL; @@ -639,7 +639,7 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank) { for (i = gAlBankSets[offset++]; i != 0; i--) { bankId = gAlBankSets[offset++]; - if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == true) { ret = get_bank_or_seq(1, 2, bankId); } else { ret = NULL; @@ -672,7 +672,7 @@ void preload_sequence(u32 seqId, u8 preloadMask) { if (preloadMask & PRELOAD_SEQUENCE) { //! @bug should be IS_SEQ_LOAD_COMPLETE - if (IS_BANK_LOAD_COMPLETE(seqId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(seqId) == true) { sequenceData = get_bank_or_seq(0, 2, seqId); } else { sequenceData = NULL; @@ -753,7 +753,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) { init_sequence_player(player); seqPlayer->scriptState.depth = 0; seqPlayer->delay = 0; - seqPlayer->enabled = TRUE; + seqPlayer->enabled = true; seqPlayer->seqData = sequenceData; seqPlayer->scriptState.pc = sequenceData; } @@ -796,7 +796,8 @@ void audio_init(void) { } #endif - switch (osTvType) { /* irregular */ + // UTODO: Which is the correct one? + switch (0) { /* irregular */ case 0: D_803B7178 = 20.03042f; gRefreshRate = 0x00000032; diff --git a/src/audio/load.h b/src/audio/load.h index 4feedf970..24523bd1b 100644 --- a/src/audio/load.h +++ b/src/audio/load.h @@ -1,8 +1,9 @@ #ifndef AUDIO_LOAD_H #define AUDIO_LOAD_H -#include <PR/ultratypes.h> +#include <libultra/types.h> #include "audio/internal.h" +#include "PR/libaudio.h" #define AUDIO_FRAME_DMA_QUEUE_SIZE 0x40 @@ -23,7 +24,7 @@ struct SharedDma { void audio_dma_copy_immediate(u8* devAddr, void *vAddr, size_t nbytes); void audio_dma_copy_async(uintptr_t, void*, size_t, OSMesgQueue*, OSIoMesg*); -void audio_dma_partial_copy_async(uintptr_t*, u8**, ssize_t*, OSMesgQueue*, OSIoMesg*); +void audio_dma_partial_copy_async(uintptr_t*, u8**, size_t*, OSMesgQueue*, OSIoMesg*); void decrease_sample_dma_ttls(void); void *dma_sample_data(uintptr_t, u32, s32, u8*); void func_800BB030(s32); diff --git a/src/audio/playback.c b/src/audio/playback.c index 750f40873..6162c1f70 100644 --- a/src/audio/playback.c +++ b/src/audio/playback.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/internal.h" @@ -28,26 +28,26 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbV sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex]; sub->headsetPanRight = gHeadsetPanQuantization[ARRAY_COUNT(gHeadsetPanQuantization) - 1 - smallPanIndex]; - sub->stereoStrongRight = FALSE; - sub->stereoStrongLeft = FALSE; - sub->usesHeadsetPanEffects = TRUE; + sub->stereoStrongRight = false; + sub->stereoStrongLeft = false; + sub->usesHeadsetPanEffects = true; volLeft = gHeadsetPanVolume[pan]; volRight = gHeadsetPanVolume[127 - pan]; } else if (sub->stereoHeadsetEffects && gAudioLibSoundMode == SOUND_MODE_STEREO) { - strongRight = FALSE; - strongLeft = FALSE; + strongRight = false; + strongLeft = false; sub->headsetPanRight = 0; sub->headsetPanLeft = 0; - sub->usesHeadsetPanEffects = FALSE; + sub->usesHeadsetPanEffects = false; volLeft = gStereoPanVolume[pan]; volRight = gStereoPanVolume[127 - pan]; if (pan < 0x20) { - strongLeft = TRUE; + strongLeft = true; } else if (pan > 0x60) { - strongRight = TRUE; + strongRight = true; } sub->stereoStrongRight = strongRight; @@ -76,14 +76,14 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbV //! @bug for the change to UQ0.7, the if statement should also have been changed accordingly if (sub->reverbVol != reverbVol) { sub->reverbVol = reverbVol; - sub->envMixerNeedsInit = TRUE; + sub->envMixerNeedsInit = true; return; } if (sub->needsInit) { - sub->envMixerNeedsInit = TRUE; + sub->envMixerNeedsInit = true; } else { - sub->envMixerNeedsInit = FALSE; + sub->envMixerNeedsInit = false; } } @@ -130,7 +130,7 @@ struct AudioBankSound *instrument_get_audio_bank_sound(struct Instrument *instru struct Instrument *get_instrument_inner(s32 bankId, s32 instId) { struct Instrument *inst; - if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == false) { stubbed_printf("Audio: voiceman: No bank error %d\n", bankId); gAudioErrorFlags = bankId + 0x10000000; return NULL; @@ -155,7 +155,7 @@ struct Instrument *get_instrument_inner(s32 bankId, s32 instId) { struct Drum *get_drum(s32 bankId, s32 drumId) { struct Drum *drum; - if (IS_BANK_LOAD_COMPLETE(bankId) == FALSE) { + if (IS_BANK_LOAD_COMPLETE(bankId) == false) { stubbed_printf("Audio: voiceman: No bank error %d\n", bankId); gAudioErrorFlags = bankId + 0x10000000; return NULL; @@ -196,16 +196,16 @@ void note_init(struct Note *note) { } void note_disable(struct Note *note) { - if (note->noteSubEu.needsInit == TRUE) { - note->noteSubEu.needsInit = FALSE; + if (note->noteSubEu.needsInit == true) { + note->noteSubEu.needsInit = false; } else { note_set_vel_pan_reverb(note, 0, 0x40, 0); } note->priority = NOTE_PRIORITY_DISABLED; note->parentLayer = NO_LAYER; note->prevParentLayer = NO_LAYER; - note->noteSubEu.enabled = FALSE; - note->noteSubEu.finished = FALSE; + note->noteSubEu.enabled = false; + note->noteSubEu.finished = false; } void process_notes(void) { @@ -625,7 +625,7 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye note->prevParentLayer = NO_LAYER; note->parentLayer = seqLayer; note->priority = seqLayer->seqChannel->notePriority; - seqLayer->notePropertiesNeedInit = TRUE; + seqLayer->notePropertiesNeedInit = true; seqLayer->status = SOUND_LOAD_STATUS_DISCARDABLE; // "loaded" seqLayer->note = note; seqLayer->seqChannel->noteUnused = note; @@ -639,9 +639,9 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye sub->sound.audioBankSound = seqLayer->sound; if (instId >= 0x80) { - sub->isSyntheticWave = TRUE; + sub->isSyntheticWave = true; } else { - sub->isSyntheticWave = FALSE; + sub->isSyntheticWave = false; } if (sub->isSyntheticWave) { @@ -693,7 +693,7 @@ struct Note *alloc_note_from_active(struct NotePool *pool, struct SequenceChanne func_800BD8F4(aNote, seqLayer); audio_list_push_back(&pool->releasing, &aNote->listItem); } - + return aNote; } @@ -781,7 +781,7 @@ void note_init_all(void) { note->adsrVolScale = 0; note->adsr.state = ADSR_STATE_DISABLED; note->adsr.action = 0; - note->vibratoState.active = FALSE; + note->vibratoState.active = false; note->portamento.cur = 0.0f; note->portamento.speed = 0.0f; // This only works if NoteSynthesisBuffers are size 0xA0. See internal.h diff --git a/src/audio/playback.h b/src/audio/playback.h index e33422fe6..2c25be714 100644 --- a/src/audio/playback.h +++ b/src/audio/playback.h @@ -1,7 +1,7 @@ #ifndef AUDIO_PLAYBACK_H #define AUDIO_PLAYBACK_H -#include <PR/ultratypes.h> +#include <libultra/types.h> #include "internal.h" diff --git a/src/audio/port_eu.c b/src/audio/port_eu.c index e5b3c7e01..eeb8e983c 100644 --- a/src/audio/port_eu.c +++ b/src/audio/port_eu.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <PR/ucode.h> @@ -168,7 +168,7 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { break; case 0x83: - if (gSequencePlayers[cmd->u.s.bankId].enabled != FALSE) { + if (gSequencePlayers[cmd->u.s.bankId].enabled != false) { if (cmd->u2.as_s32 == 0) { sequence_player_disable(&gSequencePlayers[cmd->u.s.bankId]); } @@ -184,15 +184,15 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) { case 0xf1: for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = TRUE; - gSequencePlayers[i].recalculateVolume = TRUE; + gSequencePlayers[i].muted = true; + gSequencePlayers[i].recalculateVolume = true; } break; case 0xf2: for (i = 0; i < 4; i++) { - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].recalculateVolume = TRUE; + gSequencePlayers[i].muted = false; + gSequencePlayers[i].recalculateVolume = true; } break; case 0xF3: @@ -297,7 +297,7 @@ void func_800CBCB0(u32 arg0) { switch (cmd->u.s.op) { case 0x41: seqPlayer->fadeVolumeScale = cmd->u2.as_f32; - seqPlayer->recalculateVolume = TRUE; + seqPlayer->recalculateVolume = true; break; case 0x47: @@ -313,25 +313,25 @@ void func_800CBCB0(u32 arg0) { break; } } - else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) { + else if (seqPlayer->enabled != false && cmd->u.s.arg2 < 0x10) { chan = seqPlayer->channels[cmd->u.s.arg2]; if (IS_SEQUENCE_CHANNEL_VALID(chan)) { switch (cmd->u.s.op) { case 1: chan->volumeScale = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; + chan->changes.as_bitfields.volume = true; break; case 2: chan->volume = cmd->u2.as_f32; - chan->changes.as_bitfields.volume = TRUE; + chan->changes.as_bitfields.volume = true; break; case 3: chan->newPan = cmd->u2.as_s8; - chan->changes.as_bitfields.pan = TRUE; + chan->changes.as_bitfields.pan = true; break; case 4: chan->freqScale = cmd->u2.as_f32; - chan->changes.as_bitfields.freqScale = TRUE; + chan->changes.as_bitfields.freqScale = true; break; case 5: chan->reverbVol = cmd->u2.as_s8; diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 131c32984..6aca09dcf 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/data.h" @@ -52,14 +52,14 @@ char seqplayer_unused_string25[] = "Group:Undefined Command\n"; void sequence_channel_init(struct SequenceChannel *seqChannel) { s32 i; - seqChannel->enabled = FALSE; - seqChannel->finished = FALSE; - seqChannel->stopScript = FALSE; - seqChannel->stopSomething2 = FALSE; - seqChannel->hasInstrument = FALSE; - seqChannel->stereoHeadsetEffects = FALSE; + seqChannel->enabled = false; + seqChannel->finished = false; + seqChannel->stopScript = false; + seqChannel->stopSomething2 = false; + seqChannel->hasInstrument = false; + seqChannel->stereoHeadsetEffects = false; seqChannel->transposition = 0; - seqChannel->largeNotes = FALSE; + seqChannel->largeNotes = false; seqChannel->bookOffset = 0; seqChannel->changes.as_u8 = 0xff; seqChannel->scriptState.depth = 0; @@ -86,7 +86,7 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) { for (i = 0; i < 8; i++) { seqChannel->soundScriptIO[i] = -1; } - seqChannel->unused = FALSE; + seqChannel->unused = false; init_note_lists(&seqChannel->notePool); } @@ -109,11 +109,11 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) { layer->seqChannel = seqChannel; layer->adsr = seqChannel->adsr; layer->adsr.releaseRate = 0; - layer->enabled = TRUE; - layer->stopSomething = FALSE; - layer->continuousNotes = FALSE; - layer->finished = FALSE; - layer->ignoreDrumPan = FALSE; + layer->enabled = true; + layer->stopSomething = false; + layer->continuousNotes = false; + layer->finished = false; + layer->ignoreDrumPan = false; layer->portamento.mode = 0; layer->scriptState.depth = 0; layer->status = SOUND_LOAD_STATUS_NOT_LOADED; @@ -134,8 +134,8 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) { void seq_channel_layer_disable(struct SequenceChannelLayer *layer) { if (layer != NULL) { seq_channel_layer_note_decay(layer); - layer->enabled = FALSE; - layer->finished = TRUE; + layer->enabled = false; + layer->finished = true; } } @@ -156,8 +156,8 @@ void sequence_channel_disable(struct SequenceChannel *seqChannel) { } note_pool_clear(&seqChannel->notePool); - seqChannel->enabled = FALSE; - seqChannel->finished = TRUE; + seqChannel->enabled = false; + seqChannel->finished = true; } struct SequenceChannel *allocate_sequence_channel(void) { @@ -177,12 +177,12 @@ void sequence_player_init_channels(struct SequencePlayer *seqPlayer, u16 channel for (i = 0; i < CHANNELS_MAX; i++) { if (channelBits & 1) { seqChannel = seqPlayer->channels[i]; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE && seqChannel->seqPlayer == seqPlayer) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == true && seqChannel->seqPlayer == seqPlayer) { sequence_channel_disable(seqChannel); seqChannel->seqPlayer = NULL; } seqChannel = allocate_sequence_channel(); - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == false) { //eu_stubbed_printf_0("Audio:Track:Warning: No Free Notetrack\n"); gAudioErrorFlags = i + 0x10000; seqPlayer->channels[i] = seqChannel; @@ -207,7 +207,7 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan for (i = 0; i < CHANNELS_MAX; i++) { if (channelBits & 1) { seqChannel = seqPlayer->channels[i]; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == true) { if (seqChannel->seqPlayer == seqPlayer) { sequence_channel_disable(seqChannel); seqChannel->seqPlayer = NULL; @@ -225,12 +225,12 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *script) { struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex]; s32 i; - if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == false) { //stubbed_printf("SEQID %d,BANKID %d\n", seqPlayer->seqId, seqPlayer->defaultBank[0]); //stubbed_printf("ERR:SUBTRACK %d NOT ALLOCATED\n", channelIndex); } else { - seqChannel->enabled = TRUE; - seqChannel->finished = FALSE; + seqChannel->enabled = true; + seqChannel->finished = false; seqChannel->scriptState.depth = 0; seqChannel->scriptState.pc = script; seqChannel->delay = 0; @@ -245,8 +245,8 @@ void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void sequence_player_disable(struct SequencePlayer *seqPlayer) { sequence_player_disable_channels(seqPlayer, 0xffff); note_pool_clear(&seqPlayer->notePool); - seqPlayer->finished = TRUE; - seqPlayer->enabled = FALSE; + seqPlayer->finished = true; + seqPlayer->enabled = false; if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) && gSeqLoadStatus[seqPlayer->seqId] != 5) { gSeqLoadStatus[seqPlayer->seqId] = SOUND_LOAD_STATUS_DISCARDABLE; @@ -347,8 +347,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { f32 temp_f12; f32 temp_f2; - sameSound = TRUE; - if (layer->enabled == FALSE) { + sameSound = true; + if (layer->enabled == false) { return; } @@ -356,7 +356,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { layer->delay--; if (!layer->stopSomething && layer->delay <= layer->duration) { seq_channel_layer_note_decay(layer); - layer->stopSomething = TRUE; + layer->stopSomething = true; } return; } @@ -379,7 +379,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { seqChannel = layer->seqChannel; seqPlayer = seqChannel->seqPlayer; - layer->notePropertiesNeedInit = TRUE; + layer->notePropertiesNeedInit = true; for (;;) { state = &layer->scriptState; @@ -455,9 +455,9 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { case 0xc4: // layer_somethingon case 0xc5: // layer_somethingoff if (cmd == 0xc4) { - layer->continuousNotes = TRUE; + layer->continuousNotes = true; } else { - layer->continuousNotes = FALSE; + layer->continuousNotes = false; } seq_channel_layer_note_decay(layer); break; @@ -525,7 +525,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { break; case 0xcc: - layer->ignoreDrumPan = TRUE; + layer->ignoreDrumPan = true; break; default: @@ -545,11 +545,11 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { if (cmd == 0xc0) { // layer_delay layer->delay = m64_read_compressed_u16(state); - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { - layer->stopSomething = FALSE; + layer->stopSomething = false; - if (seqChannel->largeNotes == TRUE) { + if (seqChannel->largeNotes == true) { switch (cmd & 0xc0) { case 0x00: // layer_note0 (play percentage, velocity, duration) sp3A = m64_read_compressed_u16(state); @@ -602,7 +602,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { if ((seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_NOTES) != 0) || seqChannel->stopSomething2 ) { - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { s32 temp = layer->instOrWave; @@ -617,7 +617,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { drum = get_drum(seqChannel->bankId, cmd); if (drum == NULL) { - layer->stopSomething = TRUE; + layer->stopSomething = true; layer->delayUnused = layer->delay; return; } else { @@ -634,7 +634,7 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { cmd += seqPlayer->transposition + seqChannel->transposition + layer->transposition; if (cmd >= 0x80) { - layer->stopSomething = TRUE; + layer->stopSomething = true; } else { if (layer->instOrWave == 0xffu) { instrument = seqChannel->instrument; @@ -706,30 +706,30 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) { } } - if (layer->stopSomething == TRUE) { + if (layer->stopSomething == true) { if (layer->note != NULL || layer->continuousNotes) { seq_channel_layer_note_decay(layer); } return; } - cmd = FALSE; + cmd = false; if (!layer->continuousNotes) { - cmd = TRUE; + cmd = true; } else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) { - cmd = TRUE; - } else if (sameSound == FALSE) { + cmd = true; + } else if (sameSound == false) { seq_channel_layer_note_decay(layer); - cmd = TRUE; + cmd = true; } else if (layer != layer->note->parentLayer) { - cmd = TRUE; + cmd = true; } else if (layer->sound == NULL) { init_synthetic_wave(layer->note, layer); } - if (cmd != FALSE) { + if (cmd != false) { layer->note = alloc_note(layer); } @@ -764,11 +764,11 @@ void set_instrument(struct SequenceChannel *seqChannel, u8 instId) { } else { if ((seqChannel->instOrWave = get_instrument(seqChannel, instId, &seqChannel->instrument, &seqChannel->adsr)) == 0) { - seqChannel->hasInstrument = FALSE; + seqChannel->hasInstrument = false; return; } } - seqChannel->hasInstrument = TRUE; + seqChannel->hasInstrument = true; } void sequence_channel_set_volume(struct SequenceChannel *seqChannel, u8 volume) { @@ -1215,16 +1215,16 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { struct M64ScriptState *state; s32 temp32; - if (seqPlayer->enabled == FALSE) { + if (seqPlayer->enabled == false) { return; } - if (seqPlayer->bankDmaInProgress == TRUE) { + if (seqPlayer->bankDmaInProgress == true) { if (osRecvMesg(&seqPlayer->bankDmaMesgQueue, NULL, 0) == -1) { return; } if (seqPlayer->bankDmaRemaining == 0) { - seqPlayer->bankDmaInProgress = FALSE; + seqPlayer->bankDmaInProgress = false; func_800BB584(seqPlayer->loadingBankId); if (gBankLoadStatus[seqPlayer->loadingBankId] != 5) { gBankLoadStatus[seqPlayer->loadingBankId] = 2; @@ -1237,11 +1237,11 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { return; } - if (seqPlayer->seqDmaInProgress == TRUE) { + if (seqPlayer->seqDmaInProgress == true) { if (osRecvMesg(&seqPlayer->seqDmaMesgQueue, NULL, 0) == -1) { return; } - seqPlayer->seqDmaInProgress = FALSE; + seqPlayer->seqDmaInProgress = false; if (gSeqLoadStatus[seqPlayer->seqId] != 5) { gSeqLoadStatus[seqPlayer->seqId] = 2; } @@ -1249,9 +1249,9 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { // If discarded, bail out. temp32 = 2; // I beg your pardon? - if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) == FALSE + if (IS_SEQ_LOAD_COMPLETE(seqPlayer->seqId) == false || ( - IS_BANK_LOAD_COMPLETE(seqPlayer->defaultBank[0]) == FALSE)) { + IS_BANK_LOAD_COMPLETE(seqPlayer->defaultBank[0]) == false)) { sequence_player_disable(seqPlayer); return; } @@ -1457,7 +1457,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { break; case 0xd4: // seq_mute - seqPlayer->muted = TRUE; + seqPlayer->muted = true; break; case 0xd3: // seq_setmutebhv @@ -1534,7 +1534,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { } for (i = 0; i < CHANNELS_MAX; i++) { - if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE) { + if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == true) { sequence_channel_process_script(seqPlayer->channels[i]); } } @@ -1543,7 +1543,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer) { void process_sequences(UNUSED s32 iterationsRemaining) { s32 i; for (i = 0; i < SEQUENCE_PLAYERS; i++) { - if (gSequencePlayers[i].enabled == TRUE) { + if (gSequencePlayers[i].enabled == true) { sequence_player_process_sequence(&gSequencePlayers[i]); sequence_player_process_sound(&gSequencePlayers[i]); } @@ -1577,7 +1577,7 @@ void init_sequence_players(void) { for (i = 0; i < ARRAY_COUNT(gSequenceChannels); i++) { gSequenceChannels[i].seqPlayer = NULL; - gSequenceChannels[i].enabled = FALSE; + gSequenceChannels[i].enabled = false; /** * @bug Size of wrong array. Zeroes out second half of gSequenceChannels[0], * all of gSequenceChannels[1..31], and part of gSequenceLayers[0]. @@ -1597,7 +1597,7 @@ void init_sequence_players(void) { for (i = 0; i < ARRAY_COUNT(gSequenceLayers); i++) { gSequenceLayers[i].seqChannel = NULL; - gSequenceLayers[i].enabled = FALSE; + gSequenceLayers[i].enabled = false; } for (i = 0; i < SEQUENCE_PLAYERS; i++) { @@ -1607,10 +1607,10 @@ void init_sequence_players(void) { gSequencePlayers[i].seqVariationEu[0] = -1; gSequencePlayers[i].muteBehavior = MUTE_BEHAVIOR_STOP_SCRIPT | MUTE_BEHAVIOR_STOP_NOTES | MUTE_BEHAVIOR_SOFTEN; - gSequencePlayers[i].enabled = FALSE; - gSequencePlayers[i].muted = FALSE; - gSequencePlayers[i].bankDmaInProgress = FALSE; - gSequencePlayers[i].seqDmaInProgress = FALSE; + gSequencePlayers[i].enabled = false; + gSequencePlayers[i].muted = false; + gSequencePlayers[i].bankDmaInProgress = false; + gSequencePlayers[i].seqDmaInProgress = false; init_note_lists(&gSequencePlayers[i].notePool); init_sequence_player(i); } diff --git a/src/audio/seqplayer.h b/src/audio/seqplayer.h index dc8cbe995..8c95a60d5 100644 --- a/src/audio/seqplayer.h +++ b/src/audio/seqplayer.h @@ -1,7 +1,7 @@ #ifndef AUDIO_SEQPLAYER_H #define AUDIO_SEQPLAYER_H -#include <PR/ultratypes.h> +#include <libultra/types.h> #include "audio/internal.h" diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c index 56f3e2a6d..b5b6adb6c 100644 --- a/src/audio/synthesis.c +++ b/src/audio/synthesis.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "audio/synthesis.h" #include "audio/heap.h" @@ -7,7 +7,7 @@ #include "audio/seqplayer.h" #include "audio/internal.h" //#include "audio/external.h" -#include "PR/abi.h" +#include <libultra/abi.h> #define aSetLoadBufferPair(pkt, c, off) \ aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \ @@ -127,7 +127,7 @@ void func_800B6FB4(s32 updateIndexStart, s32 noteIndex) { for (i = updateIndexStart + 1; i < gAudioBufferParameters.updatesPerFrame; i++) { if (!gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].needsInit) { - gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = FALSE; + gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = false; } else { break; } @@ -144,9 +144,9 @@ void synthesis_load_note_subs_eu(s32 updateIndex) { dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i]; if (src->enabled) { *dest = *src; - src->needsInit = FALSE; + src->needsInit = false; } else { - dest->enabled = FALSE; + dest->enabled = false; } } } @@ -161,7 +161,8 @@ Acmd *synthesis_execute(Acmd *acmd, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) { process_sequences(i - 1); synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i); } - aSegment(cmd++, 0, 0); + // UTODO: Stubbed + // aSegment(cmd++, 0, 0); aiBufPtr = (u32 *) aiBuf; for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) { if (i == 1) { @@ -307,7 +308,7 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda } for (; i < notePos; i++) { temp = updateIndex * gMaxSimultaneousNotes; - if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId) == TRUE) { + if (IS_BANK_LOAD_COMPLETE(gNoteSubsEu[temp + noteIndices[i]].bankId)) { acmd = synthesis_process_note(noteIndices[i], &gNoteSubsEu[temp + noteIndices[i]], &gNotes[noteIndices[i]].synthesisState, @@ -319,7 +320,8 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda temp = bufLen * 2; aSetBuffer(acmd++, 0, 0, DMEM_ADDR_TEMP, temp); - aInterleave(acmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH); + // UTODO: Stubbed + // aInterleave(acmd++, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH); aSaveBuffer(acmd++, DMEM_ADDR_TEMP, VIRTUAL_TO_PHYSICAL2(aiBuf), temp * 2); return acmd; } @@ -672,14 +674,16 @@ GLOBAL_ASM("asm/non_matchings/audio/synthesis/synthesis_process_note.s") Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) { s32 a3; s32 repeats; - aLoadBuffer(acmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples), 0x1A0, 128); + // UTODO: Stubbed + // aLoadBuffer(acmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples), 0x1A0, 128); synthesisState->samplePosInt &= 0x3f; a3 = 64 - synthesisState->samplePosInt; if (a3 < nSamplesToLoad) { repeats = (nSamplesToLoad - a3 + 63) / 64; if (repeats != 0) { - aDMEMMove2(acmd++, repeats, 0x1A0, 0x1A0 + 128, 128); + // UTODO: Stubbed + // aDMEMMove2(acmd++, repeats, 0x1A0, 0x1A0 + 128, 128); } } return acmd; diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h index 974fc9c32..a0397706f 100644 --- a/src/audio/synthesis.h +++ b/src/audio/synthesis.h @@ -2,7 +2,7 @@ #define AUDIO_SYNTHESIS_H #include "audio/internal.h" -#include "PR/abi.h" +#include <libultra/gbi.h> #define DEFAULT_LEN_1CH 0x180 #define DEFAULT_LEN_2CH 0x300 diff --git a/src/buffers.h b/src/buffers.h index 13584036d..66f58ad1a 100644 --- a/src/buffers.h +++ b/src/buffers.h @@ -1,7 +1,7 @@ #ifndef BUFFERS_H #define BUFFERS_H -#include <PR/ultratypes.h> +#include <libultra/types.h> #include <mk64.h> #include "common_structs.h" @@ -52,7 +52,7 @@ typedef struct { * Appears to be a combination of 2 different palettes: * kart_palette contains the palette for all non-wheel elements of the kart (including the driver). * wheel_palette contains the palette for the wheels. - * + * * kart palette sets a defined palette based on the character while * wheels palette sets a dynamic palette as you drive around with the kart. * @@ -74,7 +74,7 @@ extern struct_D_802DFB80 D_802DFB80[][2][8]; /** * It would be nice to define D_802F1F80 as "struct_D_802F1F80 D_802F1F80[2][4][8]". - * But due to register allocation issues in load_kart_palette / func_80026B4C + * But due to register allocation issues in load_kart_palette / func_80026B4C * we have to define it in a different manner to match those functions. * If AVOID_UB is defined, the struct is properly defined with their correct pointers. **/ diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index cc08aa60a..1218438a9 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include "buffers.h" diff --git a/src/buffers/gfx_output_buffer.c b/src/buffers/gfx_output_buffer.c index 0a699180c..355ffdd55 100644 --- a/src/buffers/gfx_output_buffer.c +++ b/src/buffers/gfx_output_buffer.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "gfx_output_buffer.h" diff --git a/src/buffers/gfx_output_buffer.h b/src/buffers/gfx_output_buffer.h index 5336b65ad..f3637b7df 100644 --- a/src/buffers/gfx_output_buffer.h +++ b/src/buffers/gfx_output_buffer.h @@ -1,7 +1,7 @@ #ifndef GFX_OUTPUT_BUFFER_H #define GFX_OUTPUT_BUFFER_H -#include <PR/ultratypes.h> +#include <libultra/types.h> // 0x1f000 bytes, aligned to a 0x1000-byte boundary through sm64.ld. (This results // in a bunch of unused space: ~0x100 in JP, ~0x300 in US.) diff --git a/src/buffers/memory_pool.c b/src/buffers/memory_pool.c index d7dee6cc9..5b401d83f 100644 --- a/src/buffers/memory_pool.c +++ b/src/buffers/memory_pool.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <segments.h> diff --git a/src/buffers/random.h b/src/buffers/random.h index bb7aefa8b..d0443e200 100644 --- a/src/buffers/random.h +++ b/src/buffers/random.h @@ -1,7 +1,7 @@ #ifndef RANDOM_H #define RANDOM_H -#include <ultra64.h> +#include <libultraship.h> extern u16 gRandomSeed16; extern u8 randomSeedPadding[]; diff --git a/src/buffers/trig_tables.c b/src/buffers/trig_tables.c index 22c61be30..d95b50189 100644 --- a/src/buffers/trig_tables.c +++ b/src/buffers/trig_tables.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> f32 gSineTable[] = { diff --git a/src/buffers/trig_tables_bss.c b/src/buffers/trig_tables_bss.c index aa2bc38d1..6caec65c2 100644 --- a/src/buffers/trig_tables_bss.c +++ b/src/buffers/trig_tables_bss.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> /** diff --git a/src/camera.c b/src/camera.c index 0ff40d9be..e82303eb1 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <common_structs.h> #include <defines.h> diff --git a/src/code_800029B0.c b/src/code_800029B0.c index c55bcc712..d4c3c8747 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> diff --git a/src/code_800029B0.h b/src/code_800029B0.h index 40376ff2e..ccf20c8e5 100644 --- a/src/code_800029B0.h +++ b/src/code_800029B0.h @@ -2,7 +2,7 @@ #define CODE_800029B0_H #include <macros.h> -#include <ultra64.h> +#include <libultraship.h> #include <actor_types.h> #include "camera.h" diff --git a/src/code_80004740.c b/src/code_80004740.c index a863eac74..094305e83 100644 --- a/src/code_80004740.c +++ b/src/code_80004740.c @@ -1,11 +1,11 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include "math_util.h" #include "code_80004740.h" #include "memory.h" #include <main.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include "code_80057C60.h" Vec3s D_80162D70; @@ -91,7 +91,7 @@ void func_80004A1C(animation_type_1 *arg0, s16 *arg1, animation_type_3_triplet a } sp8C[someIndex] = arg1[arg2[someIndex].some_offset + some_offset]; } - + mtxf_translate_rotate2(sp4C, sp94, sp8C); func_80004740(&gGfxPool->mtxHud[gMatrixHudCount], sp4C); D_80162D7A += 1; @@ -172,6 +172,6 @@ s16 func_80004DFC(animation_type_1 *arg0, animation_type_2 **arg1, s16 arg2, s16 s16 func_80004EAC(void *addr, s16 offset) { uintptr_t *item = segmented_to_virtual(addr); struct stru_80004EAC *temp = (struct stru_80004EAC *) segmented_to_virtual((void *) item[offset]); - + return temp->unk8 - 1; } diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 3084c84e3..f3d2e7646 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> @@ -1204,19 +1204,19 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { D_80163128[playerId] = -1; D_80163150[playerId] = -1; if (gModeSelection == 1) { - return TRUE; + return true; } if (arg1 < 0) { - return TRUE; + return true; } else if (arg1 >= 4) { arg1 = 3; } if (D_80163330[playerId] == 1) { - return TRUE; + return true; } player = &gPlayers[playerId]; if (player->type & 0x4000) { - return TRUE; + return true; } arg1_times_8 = arg1 * 8; temp_a3 = &D_800DCBB4[gCurrentCourseId][arg1_times_8]; @@ -1233,9 +1233,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { D_80163150[playerId] = temp_a3[0]; } if (D_80163150[playerId] < temp_a2 && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return FALSE; + return false; } - return TRUE; + return true; } progress = D_80164450[playerId] - D_80164450[D_80163478]; rank = gGPCurrentRaceRankByPlayerId[2 + (D_80163478 * 4)]; @@ -1253,9 +1253,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80163150[playerId] = (gCCSelection + 1) * var_a0_2; if (D_80163150[playerId] < progress && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return FALSE; + return false; } - return TRUE; + return true; } else { var_a1_4 = D_80164450[(s16) *D_80163344] - D_80164450[playerId]; if (var_a1_4 < 0) { @@ -1279,7 +1279,7 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80164538[playerId] = var_t1; if (var_t1 < 0 || var_t1 >= 8) { - return FALSE; + return false; } if (arg1_times_8 < 24) { temp_a3 = &temp_a3[var_t1]; @@ -1290,9 +1290,9 @@ s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { } D_80163128[playerId] = var_a1_4; if (D_80163150[playerId] < var_a1_4) { - return TRUE; + return true; } - return FALSE; + return false; } } #else @@ -2217,22 +2217,22 @@ void func_8000BBD8(u16 waypointIndex, f32 arg1, s16 pathIndex) { path1 = &D_80164560[pathIndex][waypointIndex]; path2 = &D_80164570[pathIndex][waypointIndex]; - + x1 = (f32) path1->posX; z1 = (f32) path1->posZ; - + x2 = (f32) path2->posX; z2 = (f32) path2->posZ; - + waypointIndex += 1; waypointIndex = waypointIndex % gWaypointCountByPathIndex[pathIndex]; - + path1 = &D_80164560[pathIndex][waypointIndex]; path2 = &D_80164570[pathIndex][waypointIndex]; - + x3 = (f32) path1->posX; z3 = (f32) path1->posZ; - + x4 = (f32) path2->posX; z4 = (f32) path2->posZ; @@ -3015,13 +3015,13 @@ void func_8000DF8C(s32 bombKartId) { Player *var_v0; bombKart = &gBombKarts[bombKartId]; - + sp7E = bombKart->state; if (sp7E == 0) { return; } - + if (((bombKart->unk_4A != 1) || (gCurrentCourseId == COURSE_AWARD_CEREMONY))) { var_f22 = bombKart->bombPos[0]; var_f20 = bombKart->bombPos[1]; @@ -3357,10 +3357,10 @@ void func_8000F124(void) { for (j = 0; j < 2; j++) { D_80163348[j] = 0; } - + if (gDemoMode == 1) { return; } if (gModeSelection != GRAND_PRIX) { return; } - + for (i = 0; i < 2; i++) { while(1) { @@ -3370,7 +3370,7 @@ void func_8000F124(void) { if (gPlayerCount < 1) { break; } var_a1 = 0; - + for (j = 0; j < gPlayerCount; j++) { if (gCharacterSelections[j] == D_80163348[i]) { var_a1 = 1; @@ -3405,7 +3405,7 @@ void func_8000F2DC(void) { D_80163368[1] = (s32) ptr->unk2; D_80163368[2] = (s32) ptr->unk4; D_80163368[3] = (s32) ptr->unk6; - + temp = ptr->unk8; D_80163598 = get_next_available_memory_addr(temp * 4); @@ -3480,7 +3480,7 @@ void func_8000F628(void) { for (i = 0; i < NUM_PLAYERS; i++) { Player *player = &gPlayerOne[i]; - + D_80163050[i] = 0; D_80162FF8[i] = 0; D_80163010[i] = 0; @@ -3534,7 +3534,7 @@ void func_8000F628(void) { D_80163380[i] = 6; if (gPlayers[i].type & PLAYER_HUMAN) { D_80163330[i] = 3; - + } else { D_80163330[i] = 0; } @@ -3558,7 +3558,7 @@ void func_8000F628(void) { D_80163344[i] = D_80164478[D_80163348[i]]; D_80163330[ D_80163344[i] ] = 1; D_8016334C[ D_80163344[i] ] = i; - } + } } } if ((D_8018EE08 == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { @@ -3570,12 +3570,12 @@ void func_8000F628(void) { D_80163344[0] = cameras->playerId; D_80163330[D_80163344[0]] = 1; D_8016334C[D_80163344[0]] = 0; - + for (i = 1; i < 2; i++) { D_80163344[i] = cameras[i].playerId; D_80163330[D_80163344[i]] = 1; D_8016334C[D_80163344[i]] = i; - + } } } @@ -3951,21 +3951,21 @@ s32 func_80011014(TrackWaypoint *pathDest, TrackWaypoint *path, s32 numPathPoint z3 = (f32) point3->posZ; temp = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + (sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2))))); - + for (j = 0.0f; j <= 1.0 ; j += temp) { temp_f2_3 = (f32) ((1.0 - j) * 0.5 * (1.0 - j)); z1_3 = (f32) (((1.0 - j) * j) + 0.5); temp_f16 = (f32) (j * 0.5 * j); - + temp_f24_2 = (temp_f2_3 * x1) + (z1_3 * x2) + (temp_f16 * x3); x1_2 = (temp_f2_3 * z1) + (z1_3 * z2) + (temp_f16 * z3); - + var_f30 += sqrtf(((temp_f24_2 - temp_f20) * (temp_f24_2 - temp_f20)) + ((x1_2 - temp_f22) * (x1_2 - temp_f22))); - + temp_f20 = temp_f24_2; temp_f22 = x1_2; - + if ((var_f30 > 20.0f) || ((i == 0) && (j == 0.0))) { if (gIsMirrorMode) { //temp_f12 = -temp_f24_2; @@ -3983,7 +3983,7 @@ s32 func_80011014(TrackWaypoint *pathDest, TrackWaypoint *path, s32 numPathPoint if (var_f20_2 < -500.0) { var_f20_2 = var_f28; } else { - + switch (gCurrentCourseId) { case 13: if (var_f20_2 < (var_f28 - 15.0)) { @@ -4072,11 +4072,11 @@ s32 func_8001168C(PathNoY *pathDest, TrackWaypoint *pathSrc, s32 numWaypoints) { UNUSED s32 pad2; f32 temp_f24; - + f32 spA8; f32 temp_f26; f32 spA0; - + f32 temp_f2_3; TrackWaypoint *point1; @@ -4304,9 +4304,7 @@ void func_80011EC0(s32 arg0, Player *player, s32 arg2, UNUSED u16 arg3) { void func_800120C8(void) { s32 i; PathNoY *temp; - TrackWaypoint *waypoint = (TrackWaypoint *) VIRTUAL_TO_PHYSICAL2( - gSegmentTable[SEGMENT_NUMBER2(d_course_kalimari_desert_track_unknown_waypoints)] - + SEGMENT_OFFSET(d_course_kalimari_desert_track_unknown_waypoints)); + TrackWaypoint *waypoint = (TrackWaypoint *) d_course_kalimari_desert_track_unknown_waypoints; for (i = 0; ; i++) { if ((u16)waypoint[i].posX == 0x8000) { @@ -4320,11 +4318,9 @@ void func_800120C8(void) { } void func_80012190(void) { - TrackWaypoint *tree; + TrackWaypoint *tree = d_frappe_snowland_tree; s32 i; - tree = (TrackWaypoint *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_frappe_snowland_tree)] + (SEGMENT_OFFSET(d_frappe_snowland_tree))); - for (i = 0; ; i++) { if ((u16)tree[i].posX == 0x8000) { break; @@ -4491,29 +4487,29 @@ void func_800127E0(void) { ptr1 = &gTrainList[i].tender; ptr2 = &D_80163598[waypointOffset]; func_80012780(ptr1, ptr2, waypointOffset); - + waypointOffset += 4; ptr1 = &gTrainList[i].locomotive; ptr2 = &D_80163598[waypointOffset]; func_80012780(ptr1, ptr2, waypointOffset); - + // Only use locomotive unless overwritten below. gTrainList[i].numCars = LOCOMOTIVE_ONLY; } - + // Spawn all rolling stock in single player mode. switch (gScreenModeSelection) { case SCREEN_MODE_1P: // single player for (i = 0; i < NUM_TRAINS; i++) { gTrainList[i].tender.isActive = 1; - + // Same line required for matching... for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { gTrainList[i].passengerCars[j].isActive = 1; } - + gTrainList[i].numCars = NUM_TENDERS + NUM_PASSENGER_CAR_ENTRIES; } break; - + // Spawn locomotive, tender, and one passenger car in versus 2/3 player mode. case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: // multiplayer fall-through case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: @@ -4525,9 +4521,9 @@ void func_800127E0(void) { } } break; - + } - + D_80162FCC = 0; } @@ -4683,12 +4679,12 @@ void func_80013054(void) { temp_f18 = 0.72017354f; temp_f12 = 0.42299348f; - if (((temp_f12 - 0.1) < temp_f16) + if (((temp_f12 - 0.1) < temp_f16) && (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f12 + 0.01)))) { isCrossingTriggeredByIndex[0] = 1; } - if (((temp_f18 - 0.1) < temp_f16) + if (((temp_f18 - 0.1) < temp_f16) && (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f18 + 0.01)))) { isCrossingTriggeredByIndex[1] = 1; @@ -4710,9 +4706,9 @@ void func_800131DC(s32 playerId) { if ((!(D_801631E0[playerId] != 0)) || (func_800061DC(gPlayers[playerId].pos, 1000.0f, 0))) { - if ((isCrossingTriggeredByIndex[1] == 1) + if ((isCrossingTriggeredByIndex[1] == 1) && ((D_801637BC[1]) > 240)) { - + if ((D_80162FCE > 176) && (D_80162FCE < 182)) { D_801634D8[playerId] = 1; } @@ -4740,7 +4736,7 @@ void func_800132F4(void) { var_a1->position[2] = temp_a2->z; var_a1->waypointIndex = i * 0xB4; var_a1->actorIndex = -1; - + if (gPlayerCount >= 3) { var_a1->isActive = 0; } else { @@ -5031,7 +5027,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 f32 temp_f12; f32 temp_f14; f32 temp_f22; - + s32 i; f32 spC4; @@ -5040,7 +5036,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((D_801631E0[playerId] != 1) || (( ((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_KART_AI))) && !(player->effects & 0x01000000)) { - + spC4 = player->pos[0]; spC0 = player->pos[1]; spBC = player->pos[2]; @@ -5052,7 +5048,7 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((temp_f12) > -100.0) && ((temp_f12) < 100.0)) { if ((temp_f22 > -20.0) && (temp_f22 < 20.0)) { - + if (((temp_f14) > -100.0) && ((temp_f14) < 100.0)) { if (func_80006018(vehicle->position[0], vehicle->position[2], vehicle->velocity[0], vehicle->velocity[2], arg3, arg4, spC4, spBC) == (s32) 1) { player->soundEffects |= REVERSE_SOUND_EFFECT; @@ -5081,12 +5077,12 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 if (((temp_f12) > -200.0) && ((temp_f12) < 200.0) && ((temp_f22 > -20.0)) && (temp_f22 < 20.0) && ( ((temp_f14) > -200.0)) && ((temp_f14) < 200.0)) { if (!(vehicle->someFlagsTheSequel & ((1 << playerId)))) { - + s32 var_s1 = 0; - u16 path = gWaypointCountByPathIndex[0]; + u16 path = gWaypointCountByPathIndex[0]; s32 t1; s32 t2; - + switch (D_8016347A) { case 0: t1 = func_80007BF8(vehicle->waypointIndex, gNearestWaypointByPlayerId[playerId], 10, 0, path); @@ -5115,9 +5111,9 @@ void func_80013F7C(s32 playerId, Player *player, VehicleStuff *vehicle, f32 arg3 break; } if (var_s1 == 1) { - + u32 soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); - + switch (soundBits) { case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05): soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); @@ -6500,7 +6496,7 @@ void func_80019890(s32 playerId, s32 cameraId) { Camera *camera = camera1; camera += cameraId; camera->playerId = playerId; - + D_801646C0[cameraId] = 0; pathIndex = gPathIndexByPlayerId[playerId]; @@ -6863,7 +6859,7 @@ void func_8001A588(UNUSED u16 *localD_80152300, Camera *camera, Player *player, func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 0); } if ((gModeSelection != TIME_TRIALS) && (cameraIndex == 1) && (((D_801646C8 == 260)) || (D_801646C8 == 261))) { - + var_v1 = 0; if (gPlayerCount == 2) { func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 1); @@ -6986,7 +6982,7 @@ void kart_ai_decisions_branch_item(UNUSED s32 arg0, s16 *arg1, s32 arg2) { case ITEM_MUSHROOM: value = 0x1D; break; - case ITEM_DOUBLE_MUSHROOM: + case ITEM_DOUBLE_MUSHROOM: break; case ITEM_TRIPLE_MUSHROOM: break; diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index 3de5b0add..9853b8d7e 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include "math_util.h" diff --git a/src/code_80057C60.c b/src/code_80057C60.c index ce3586ea3..c17d3ffc3 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -3,9 +3,9 @@ * @warning there are too many variables here */ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <mk64.h> #include "camera.h" @@ -113,7 +113,7 @@ s32 D_80165754; ThwompSpawn *gThowmpSpawnList; Vec4s D_80165760; -UNUSED s16 D_80165768; +UNUSED s16 D_80165768; s8 D_8016576A; Vec4s D_80165770; UNUSED s32 D_80165778; @@ -151,21 +151,21 @@ s8 D_801657E2; s8 D_801657E3; s8 D_801657E4; s8 D_801657E5; -bool8 D_801657E6; +bool D_801657E6; u8 D_801657E7; -bool8 D_801657E8; +bool D_801657E8; UNUSED s32 D_801657EC; -bool8 D_801657F0; +bool D_801657F0; UNUSED s32 D_801657F4; -bool8 D_801657F8; +bool D_801657F8; s32 D_801657FC; s8 D_80165800[2]; s32 D_80165804; s8 D_80165808; s32 D_8016580C; -bool8 D_80165810; +bool D_80165810; s32 D_80165814; -bool8 D_80165818; +bool D_80165818; s32 D_8016581C; s8 D_80165820; UNUSED s32 D_80165824; @@ -971,7 +971,7 @@ void func_80058F78(void) { render_hud_timer(PLAYER_ONE); draw_simplified_lap_count(PLAYER_ONE); func_8004EB38(0); - if (D_801657E6 != FALSE) { + if (D_801657E6 != false) { func_8004ED40(0); } } @@ -1044,10 +1044,10 @@ void func_800591B4(void) { if (gIsHUDVisible != 0) { if (D_801657D8 == 0) { - if (D_801657F0 != FALSE) { + if (D_801657F0 != false) { func_800514BC(); } - if ((!gDemoMode) && (D_801657E8 != FALSE)) { + if ((!gDemoMode) && (D_801657E8 != false)) { if (D_80165800[0] != 0) { func_8004EE54(0); if (gModeSelection != BATTLE) { @@ -1224,7 +1224,7 @@ void randomize_seed_from_controller(s32 arg0) { } void func_8005994C(void) { - D_8018D214 = TRUE; + D_8018D214 = true; } void func_8005995C(void) { @@ -1233,7 +1233,7 @@ void func_8005995C(void) { for (i = 0; i < 4; i++) { if ((D_80165890 != 0) && (player->type & PLAYER_INVISIBLE_OR_BOMB)) { player->currentItemCopy = ITEM_MUSHROOM; - + playerHUD[i].unk_75 = 2; } if ((player->type & PLAYER_INVISIBLE_OR_BOMB) && (player->currentItemCopy == ITEM_NONE)) { @@ -1258,7 +1258,7 @@ void func_80059A88(s32 playerId) { void func_80059AC8(void) { s32 i; - if (gIsGamePaused == FALSE) { + if (gIsGamePaused == false) { func_8008C1D8(&D_80165678); gRaceFrameCounter++; for (i = 0; i < NUM_PLAYERS; i++) { @@ -1311,16 +1311,16 @@ void func_80059C50(void) { } void func_80059D00(void) { - + func_8005A99C(); func_8005A3C0(); func_8005A380(); if (D_801657AE == 0) { - switch (gScreenModeSelection) { + switch (gScreenModeSelection) { case SCREEN_MODE_1P: randomize_seed_from_controller(PLAYER_ONE); - if (D_8018D214 == FALSE) { + if (D_8018D214 == false) { func_80059820(PLAYER_ONE); func_8005B914(); if (!gDemoMode) { @@ -1420,7 +1420,7 @@ void func_8005A070(void) { gMatrixHudCount = 0; D_801655C0 = 0; func_80041D34(); - if (gIsGamePaused == FALSE) { + if (gIsGamePaused == false) { func_8005C728(); if (gGamestate == ENDING) { func_80086604(); @@ -1497,7 +1497,7 @@ void func_8005A380(void) { } void func_8005A3C0(void) { - bool b = FALSE; + bool b = false; if ((gGamestate != ENDING) && (gGamestate != CREDITS_SEQUENCE) && !D_8018D204) { switch (gPlayerCountSelection1) { case 1: @@ -1506,38 +1506,38 @@ void func_8005A3C0(void) { D_801657E4 = 0; } if (D_801657E4 == 2) { - D_801657E8 = FALSE; - D_801657E6 = FALSE; - D_801657F0 = TRUE; + D_801657E8 = false; + D_801657E6 = false; + D_801657F0 = true; } else if (D_801657E4 == 1) { - D_801657E8 = FALSE; - D_801657E6 = TRUE; - D_801657F0 = FALSE; + D_801657E8 = false; + D_801657E6 = true; + D_801657F0 = false; } else { - D_801657E8 = TRUE; - D_801657E6 = FALSE; - D_801657F0 = FALSE; + D_801657E8 = true; + D_801657E6 = false; + D_801657F0 = false; } - b = TRUE; + b = true; } break; case 2: if (gModeSelection != BATTLE) { if (gControllerOne->buttonPressed & R_CBUTTONS) { D_80165800[0] = (D_80165800[0] + 1) & 1; - b = TRUE; + b = true; } if (gControllerTwo->buttonPressed & R_CBUTTONS) { D_80165800[1] = (D_80165800[1] + 1) & 1; - b = TRUE; + b = true; } if (D_80165800[0] && D_80165800[1]) { - D_801657F0 = FALSE; + D_801657F0 = false; } else { - D_801657F0 = TRUE; + D_801657F0 = true; } if (gDemoMode) { - D_801657F0 = FALSE; + D_801657F0 = false; } } break; @@ -1549,7 +1549,7 @@ void func_8005A3C0(void) { D_801657F0 = (D_801657F0 + 1) & 1; } D_801657E4 = (D_801657E4 + 1) & 1; - b = TRUE; + b = true; } break; case 4: @@ -1563,7 +1563,7 @@ void func_8005A3C0(void) { if (gModeSelection != BATTLE) { D_801657F0 = (D_801657F0 + 1) & 1; } - b = TRUE; + b = true; } break; } @@ -1664,7 +1664,7 @@ void func_8005A99C(void) { func_8005AA34(); } if (gPlayerCountSelection1 == 3) { - D_801657E8 = TRUE; + D_801657E8 = true; } gIsHUDVisible = (s32) 1; D_8018D170 = (s32) 1; @@ -2862,7 +2862,7 @@ void func_8005D898(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s8 arg3, UN if (player->unk_22A == 1) { func_8005D800(&player->unk_258[10 + arg1], 0xFFFF00, 0x70); - + } if (player->unk_22A >= 2) { @@ -4197,7 +4197,7 @@ void func_80062C74(Player *player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3) { void func_80062F98(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) { f32 temp_f0; - + temp_f0 = player->unk_258[10 + arg1].unk_018 / 10.0f; ++player->unk_258[10 + arg1].unk_01E; player->unk_258[10 + arg1].unk_000[1] += temp_f0; @@ -4443,7 +4443,7 @@ void func_80063D58(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { } else { player->unk_258[10 + arg1].unk_000[1] += 0.4; } - + if (player->unk_258[10 + arg1].unk_03E <= 0) { player->unk_258[10 + arg1].unk_03E = 0; } @@ -4513,7 +4513,7 @@ void func_800643A8(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[10 + arg1].unk_01E = 0; player->unk_258[10 + arg1].unk_012 = 0; } - + player->unk_258[10 + arg1].unk_00C += 0.2; player->unk_258[10 + arg1].unk_03E -= 8; if (player->unk_258[10 + arg1].unk_03E <= 0) { @@ -4598,11 +4598,11 @@ void func_800648E4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_00C -= 0.06; player->unk_258[30 + arg1].unk_000[1] += 0.1; player->unk_258[30 + arg1].unk_03E -= 12; - + if (player->unk_258[30 + arg1].unk_03E <= 0) { player->unk_258[30 + arg1].unk_03E = 0; } - + if (player->unk_258[30 + arg1].unk_01E == 10) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_01E = 0; @@ -4624,7 +4624,7 @@ void func_80064988(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_800649F4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { f32 temp; temp = player->unk_258[30 + arg1].unk_018; - + player->unk_258[30 + arg1].unk_000[2] = player->unk_21C + (((-temp) * player->unk_258[30 + arg1].unk_01E) * coss(player->unk_258[30 + arg1].unk_020)); player->unk_258[30 + arg1].unk_000[0] = player->unk_218 + (((-temp) * player->unk_258[30 + arg1].unk_01E) * sins(player->unk_258[30 + arg1].unk_020)); player->unk_258[30 + arg1].unk_000[1] = player->pos[1] + player->unk_258[30 + arg1].unk_014; @@ -4636,7 +4636,7 @@ void func_800649F4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_012 = 0; } - + if (player->unk_258[30 + arg1].unk_01E >= 9) { player->unk_258[30 + arg1].unk_03E -= 0x10; if (player->unk_258[30 + arg1].unk_03E <= 0) { @@ -4659,7 +4659,7 @@ void func_80064B30(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { player->unk_258[30 + arg1].unk_01C = 0; player->unk_258[30 + arg1].unk_012 = 0; } - + player->unk_258[30 + arg1].unk_038 += 1820; if (player->unk_258[30 + arg1].unk_01E >= 6) { player->unk_258[30 + arg1].unk_03E -= 16; @@ -4676,7 +4676,7 @@ void func_80064C74(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { } else { player->unk_258[30 + arg1].unk_020 -= 2184; } - + player->unk_258[30 + arg1].unk_000[2] = player->pos[2] + (coss(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f); player->unk_258[30 + arg1].unk_000[0] = player->pos[0] + (sins(player->unk_258[30 + arg1].unk_020 - player->rotation[1] - player->unk_0C0) * 5.0f); player->unk_258[30 + arg1].unk_000[1] = player->pos[1] - 1.0f; @@ -4700,14 +4700,14 @@ void func_80064DEC(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { player->unk_258[20 + arg3].unk_000[1] = player->pos[1]; ++player->unk_258[20 + arg3].unk_01E; - + if (player->unk_258[20 + arg3].unk_01E == 9) { player->unk_0B6 &= ~0x0040; player->unk_258[20 + arg3].unk_01C = 0; player->unk_258[20 + arg3].unk_01E = 0; player->unk_258[20 + arg3].unk_012 = 0; } - + player->unk_258[20 + arg3].unk_00C += 0.8; if (player->unk_258[20 + arg3].unk_00C >= (f64) 2.5) { player->unk_258[20 + arg3].unk_00C = 2.5f; @@ -4735,7 +4735,7 @@ void func_80064EA4(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { void func_80064F88(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { ++player->unk_258[20 + arg3].unk_01E; player->unk_258[20 + arg3].unk_00C += 0.15; - + if (1.2 <= player->unk_258[20 + arg3].unk_00C) { player->unk_258[20 + arg3].unk_00C = 1.2f; } @@ -4755,7 +4755,7 @@ void func_80065030(Player* player, UNUSED s8 arg1, UNUSED s8 arg2, s8 arg3) { if (player->unk_258[20 + arg3].unk_00C >= (f64) 1.5) { player->unk_258[20 + arg3].unk_00C = 1.5f; } - + if (player->unk_258[20 + arg3].unk_01E >= 12) { player->unk_0B6 &= ~0x0100; player->unk_258[20 + arg3].unk_01C = 0; @@ -5789,7 +5789,7 @@ void render_battle_balloon(Player *player, s8 arg1, s16 arg2, s8 arg3) { gDPSetTextureLUT(gDisplayListHead++, G_TT_RGBA16); func_8004B614(primRed, primGreen, primBlue, envRed, envGreen, envBlue, 0x000000D8); - + gDPSetRenderMode(gDisplayListHead++, AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | ZMODE_XLU | CVG_X_ALPHA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); gDPLoadTextureBlock(gDisplayListHead++, D_8018D4BC, G_IM_FMT_CI, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPVertex(gDisplayListHead++, gBalloonVertexPlane1, 4, 0); @@ -6055,39 +6055,39 @@ void func_8006C9B8(Player *player, s16 arg1, s8 arg2, s8 arg3) { case 1: func_800644E8(player, arg1, arg2, arg3); break; - + case 2: func_800649F4(player, arg1, arg2, arg3); break; - + case 3: func_80064C74(player, arg1, arg2, arg3); break; - + case 4: func_800647C8(player, arg1, arg2, arg3); break; - + case 5: func_80064B30(player, arg1, arg2, arg3); break; - + case 6: func_800648E4(player, arg1, arg2, arg3); break; - + case 7: func_80064988(player, arg1, arg2, arg3); break; - + case 8: func_80064C74(player, arg1, arg2, arg3); break; - + case 9: func_80064664(player, arg1, arg2, arg3); break; - + default: break; } @@ -6174,7 +6174,7 @@ void func_8006CEC0(Player *arg0, s16 arg1, s8 arg2, s8 arg3) { } else if (((arg0->effects & 0x40000000) == 0x40000000) && (arg0->unk_0B0 < 0x32)) { func_80061094(arg0, arg1, sp20, arg2, arg3); return; - } else if ((arg0->type & 0x4000) == 0x4000) { + } else if ((arg0->type & 0x4000) == 0x4000) { if ((arg0->unk_0DE & 8) == 8) { func_80060F50(arg0, arg1, sp20, arg2, arg3); return; @@ -6449,7 +6449,7 @@ void func_8006DD3C(Player* arg0, s8 arg1, s8 arg2) { } void func_8006E058(void) { - switch (gActiveScreenMode) { + switch (gActiveScreenMode) { case SCREEN_MODE_1P: switch (gModeSelection) { case GRAND_PRIX: @@ -6469,7 +6469,7 @@ void func_8006E058(void) { if ((gPlayerTwo->type & 0x100) == 0x100) { func_8006E420(gPlayerTwo, 1, 0); } - + if ((gPlayerThree->type & 0x100) == 0x100) { func_8006E420(gPlayerThree, 2, 0); break; @@ -6480,7 +6480,7 @@ void func_8006E058(void) { case BATTLE: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); - + if (gPlayerCountSelection1 >= 3) { func_8006E420(gPlayerThree, 2, 0); } @@ -6496,7 +6496,7 @@ void func_8006E058(void) { break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - switch (gModeSelection) { + switch (gModeSelection) { case GRAND_PRIX: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); @@ -6508,7 +6508,7 @@ void func_8006E058(void) { func_8006E420(gPlayerEight, 7, 0); break; - case VERSUS: + case VERSUS: case BATTLE: func_8006E420(gPlayerOne, 0, 0); func_8006E420(gPlayerTwo, 1, 0); @@ -6516,7 +6516,7 @@ void func_8006E058(void) { break; case TIME_TRIALS: func_8006E420(gPlayerOne, 0, 0); - + if ((gPlayerTwo->type & 0x8000) == 0x8000) { func_8006E420(gPlayerTwo, 1, 0); break; @@ -6548,7 +6548,7 @@ void func_8006E420(Player* player, s8 arg1, s8 arg2) { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { func_8006D194(player, arg1, arg2); } - + for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) { func_8006CEC0(player, temp_s0, arg1, arg2); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) || (gGamestate == ENDING)) { diff --git a/src/code_80057C60.h b/src/code_80057C60.h index f8f5eeeeb..c9150e67a 100644 --- a/src/code_80057C60.h +++ b/src/code_80057C60.h @@ -333,20 +333,20 @@ extern s8 D_801657E2; extern s8 D_801657E3; extern s8 D_801657E4; extern s8 D_801657E5; -extern bool8 D_801657E6; +extern bool D_801657E6; extern u8 D_801657E7; -extern bool8 D_801657E8; -extern bool8 D_801657F0; -extern bool8 D_801657F8; +extern bool D_801657E8; +extern bool D_801657F0; +extern bool D_801657F8; extern s32 D_801657FC; extern s8 D_80165800[2]; extern s32 D_80165804; extern s8 D_80165808; extern s32 D_8016580C; -extern bool8 D_80165810; +extern bool D_80165810; extern s32 D_80165814; -extern bool8 D_80165818; +extern bool D_80165818; extern s32 D_8016581C; extern s8 D_80165820; extern s8 D_80165828; diff --git a/src/code_80057C60_var.c b/src/code_80057C60_var.c index 04393db96..0ed5c549c 100644 --- a/src/code_80057C60_var.c +++ b/src/code_80057C60_var.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "code_80057C60.h" @@ -152,13 +152,13 @@ s32 D_8018D3D4; s32 D_8018D3D8; s32 D_8018D3DC; //! some alpha -s32 D_8018D3E0; +s32 D_8018D3E0; //! some red -s32 D_8018D3E4; +s32 D_8018D3E4; //! some green -s32 D_8018D3E8; +s32 D_8018D3E8; //! some blue -s32 D_8018D3EC; +s32 D_8018D3EC; s32 D_8018D3F0; s32 D_8018D3F4; s32 D_8018D3F8; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 3eb226d95..5a2263a00 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <memory.h> #include <defines.h> @@ -67,7 +67,7 @@ void reset_object_variable(void) { void func_8006EB10(void) { s32 i; - + for (i = 0; i < gObjectParticle1_SIZE; i++) { gObjectParticle1[i] = NULL_OBJECT_ID; } @@ -638,10 +638,10 @@ void init_clouds(CloudData *cloudList) { /** * This function is part of the spawning for the "stars" in some stages - * + * * arg2 is a pointer to some type of spawn data for the stars, although it not super clear * what types each element is. It seems like its a bunch of u16's, so maybe a Vec4su? - * + * * The stars in Wario's Stadium, Toad's Turnpike, and Rainbow Road are not part of the skybox. * They are instead objects that seemingly hover in the air around the player * They have no true x/y/z position, instead they seem to be kept in a position relative to the @@ -694,7 +694,7 @@ void func_8007055C(void) { if (gPlayerCount == 1) { var_s4 = 0x32; } else { - var_s4 = 0x19; + var_s4 = 0x19; } for (var_s0 = 0; var_s0 < var_s4; var_s0++) { find_unused_obj_index(&D_8018CC80[D_8018D1F8 + var_s0]); @@ -1278,7 +1278,7 @@ void init_hud_three_four_player(void) { playerHUD[PLAYER_TWO].lapY = 0x60; playerHUD[PLAYER_TWO].unk_6C = 0xC8; playerHUD[PLAYER_TWO].unk_6E = 0xC8; - + playerHUD[PLAYER_THREE].itemBoxX = -0x36; playerHUD[PLAYER_THREE].itemBoxY = 0x2D; playerHUD[PLAYER_THREE].slideItemBoxX = 0; @@ -1293,7 +1293,7 @@ void init_hud_three_four_player(void) { playerHUD[PLAYER_THREE].lapY = 0xD4; playerHUD[PLAYER_THREE].unk_6C = 0xDE; playerHUD[PLAYER_THREE].unk_6E = 0xC0; - + playerHUD[PLAYER_FOUR].itemBoxX = 0x175; playerHUD[PLAYER_FOUR].itemBoxY = 0x2D; playerHUD[PLAYER_FOUR].slideItemBoxX = 0; diff --git a/src/code_80086E70.c b/src/code_80086E70.c index 0489faa0a..c0cd42e9d 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <common_structs.h> #include <mk64.h> @@ -45,9 +45,9 @@ void func_80086F60(s32 objectIndex) { } bool func_80086FA4(s32 objectIndex) { - bool ret = FALSE; + bool ret = false; if (gObjectList[objectIndex].unk_0AE == 0) { - ret = TRUE; + ret = true; } return ret; } @@ -66,7 +66,7 @@ s32 func_80087060(s32 objectIndex, s32 arg1) { s32 sp1C; sp1C = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = arg1; } @@ -82,7 +82,7 @@ s32 func_80087104(s32 objectIndex, u16 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = random_int(arg1); } @@ -98,7 +98,7 @@ s32 func_800871AC(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].unk_0B0 = (s16) arg1; } @@ -218,7 +218,7 @@ s32 func_8008789C(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); func_8008751C(objectIndex); gObjectList[objectIndex].unk_0B0 = arg1; @@ -237,7 +237,7 @@ s32 func_80087954(s32 objectIndex, s32 arg1) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); func_80087620(objectIndex); gObjectList[objectIndex].unk_0B0 = arg1; @@ -258,8 +258,8 @@ bool func_80087A0C(s32 objectIndex, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { s16 temp_v0; bool sp2C; - sp2C = FALSE; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + sp2C = false; + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); temp_v0 = arg2 - arg1; temp_a0 = arg4 - arg3; @@ -272,7 +272,7 @@ bool func_80087A0C(s32 objectIndex, s16 arg1, s16 arg2, s16 arg3, s16 arg4) { gObjectList[objectIndex].unk_0B0--; if (gObjectList[objectIndex].unk_0B0 < 0) { set_object_flag_status_false(objectIndex, 8); - sp2C = TRUE; + sp2C = true; } else { object_add_velocity_offset_xz(objectIndex); } @@ -283,7 +283,7 @@ s32 func_80087B84(s32 objectIndex, f32 arg1, f32 arg2) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].velocity[1] = -arg1; } @@ -300,7 +300,7 @@ s32 func_80087C48(s32 objectIndex, f32 arg1, f32 arg2, s32 arg3) { s32 sp24; sp24 = 0; - if (is_obj_index_flag_status_inactive(objectIndex, 8) != FALSE) { + if (is_obj_index_flag_status_inactive(objectIndex, 8) != false) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].velocity[1] = arg1; gObjectList[objectIndex].unk_0B0 = (s16) arg3; @@ -340,7 +340,7 @@ bool func_80087E08(s32 objectIndex, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s32 bool sp2C; UNUSED s32 pad; - sp2C = FALSE; + sp2C = false; if (is_obj_index_flag_status_inactive(objectIndex, 8) != 0) { set_object_flag_status_true(objectIndex, 8); gObjectList[objectIndex].offset[2] = 0.0f; @@ -356,7 +356,7 @@ bool func_80087E08(s32 objectIndex, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s32 if (gObjectList[objectIndex].unk_0B0 < 0) { set_object_flag_status_false(objectIndex, 8); func_80086FD4(objectIndex); - sp2C = TRUE; + sp2C = true; } else { gObjectList[objectIndex].velocity[1] -= arg2; object_add_velocity_offset_xyz(objectIndex); @@ -585,10 +585,10 @@ void func_800887C0(s32 objectIndex) { /** * @brief Returns the distance between the object and the player. - * - * @param objectIndex - * @param player - * @return UNUSED + * + * @param objectIndex + * @param player + * @return UNUSED */ UNUSED s32 get_horizontal_distance_to_player(s32 objectIndex, Player *player) { s32 x; @@ -601,10 +601,10 @@ UNUSED s32 get_horizontal_distance_to_player(s32 objectIndex, Player *player) { /** * @brief Returns the distance between the object and the player. - * - * @param objectIndex - * @param player - * @return UNUSED + * + * @param objectIndex + * @param player + * @return UNUSED */ UNUSED s32 get_distance_to_player(s32 objectIndex, Player *player) { s32 x; @@ -619,10 +619,10 @@ UNUSED s32 get_distance_to_player(s32 objectIndex, Player *player) { /** * @brief Returns the distance between the object and the camera. - * - * @param objectIndex - * @param camera - * @return UNUSED + * + * @param objectIndex + * @param camera + * @return UNUSED */ u32 get_horizontal_distance_to_camera(s32 objectIndex, Camera *camera) { s32 x; @@ -635,10 +635,10 @@ u32 get_horizontal_distance_to_camera(s32 objectIndex, Camera *camera) { /** * @brief Returns the distance between the object and the camera. - * - * @param objectIndex - * @param camera - * @return UNUSED + * + * @param objectIndex + * @param camera + * @return UNUSED */ UNUSED s32 get_distance_to_camera(s32 objectIndex, Camera *camera) { s32 x; @@ -653,36 +653,36 @@ UNUSED s32 get_distance_to_camera(s32 objectIndex, Camera *camera) { /** * @brief Returns if the object is closer than the distance to the player. - * - * @param objectIndex - * @param player + * + * @param objectIndex + * @param player * @param distance - * @return true - * @return false + * @return true + * @return false */ bool is_within_horizontal_distance_of_player(s32 objectIndex, Player *player, f32 distance) { f32 x; f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[2] - player->pos[2]; if (((x * x) + (y * y)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the player. - * - * @param objectIndex - * @param player - * @param distance_min - * @param distance_max - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance_min + * @param distance_max + * @return true + * @return false */ bool is_in_bounds_to_player(s32 objectIndex, Player *player, f32 distance_min, f32 distance_max) { f32 x; @@ -690,24 +690,24 @@ bool is_in_bounds_to_player(s32 objectIndex, Player *player, f32 distance_min, f f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = (x * x) + (z * z); if (((distance_min * distance_min) <= distance) && (distance <= (distance_max * distance_max))) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is closer than the distance to the player. - * - * @param objectIndex - * @param player - * @param distance - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance + * @return true + * @return false */ bool is_within_distance_to_player(s32 objectIndex, Player *player, f32 distance) { f32 x; @@ -715,47 +715,47 @@ bool is_within_distance_to_player(s32 objectIndex, Player *player, f32 distance) f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the camera. - * - * @param objectIndex - * @param camera - * @param distance - * @return true - * @return false + * + * @param objectIndex + * @param camera + * @param distance + * @return true + * @return false */ bool is_within_horizontal_distance_to_camera(s32 objectIndex, Camera *camera, f32 distance) { f32 x; f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; y = gObjectList[objectIndex].pos[2] - camera->pos[2]; if (((x * x) + (y * y)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is between the distance_min and distance_max to the camera. - * - * @param objectIndex - * @param camera - * @param distance_min - * @param distance_max - * @return UNUSED + * + * @param objectIndex + * @param camera + * @param distance_min + * @param distance_max + * @return UNUSED */ UNUSED bool is_within_bounds_to_camera(s32 objectIndex, Camera *camera, f32 distance_min, f32 distance_max) { f32 x; @@ -763,23 +763,23 @@ UNUSED bool is_within_bounds_to_camera(s32 objectIndex, Camera *camera, f32 dist f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; z = gObjectList[objectIndex].pos[2] - camera->pos[2]; distance = (x * x) + (z * z); if (((distance_min * distance_min) <= distance) && (distance <= (distance_max * distance_max))) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object is closer than the distance to the camera. - * - * @param objectIndex - * @param camera - * @param distance - * @return UNUSED + * + * @param objectIndex + * @param camera + * @param distance + * @return UNUSED */ UNUSED bool is_within_distance_to_camera(s32 objectIndex, Camera *camera, f32 distance) { f32 x; @@ -787,23 +787,23 @@ UNUSED bool is_within_distance_to_camera(s32 objectIndex, Camera *camera, f32 di f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - camera->pos[0]; y = gObjectList[objectIndex].pos[1] - camera->pos[1]; z = gObjectList[objectIndex].pos[2] - camera->pos[2]; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @return true - * @return false + * + * @param objectIndex + * @param player + * @return true + * @return false */ bool has_collided_horizontally_with_player(s32 objectIndex, Player *player) { f32 x; @@ -811,23 +811,23 @@ bool has_collided_horizontally_with_player(s32 objectIndex, Player *player) { f32 z; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = gObjectList[objectIndex].boundingBoxSize + player->boundingBoxSize; if (((x * x) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @return true - * @return false + * + * @param objectIndex + * @param player + * @return true + * @return false */ bool has_collided_with_player(s32 objectIndex, Player *player) { f32 x; @@ -836,45 +836,45 @@ bool has_collided_with_player(s32 objectIndex, Player *player) { f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; distance = gObjectList[objectIndex].boundingBoxSize + player->boundingBoxSize; if (((x * x) + (y * y) + (z * z)) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player. - * - * @param objectIndex - * @param player - * @param distance - * @return UNUSED + * + * @param objectIndex + * @param player + * @param distance + * @return UNUSED */ UNUSED bool has_collided_with_player_1d(s32 objectIndex, Player *player, f32 distance) { f32 x; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[1] - player->pos[1]; if ((x * x) <= (distance * distance)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } /** * @brief Returns if the object collided with the player and is closer than the distance in the y axis. - * - * @param objectIndex - * @param player - * @param distance_y - * @return true - * @return false + * + * @param objectIndex + * @param player + * @param distance_y + * @return true + * @return false */ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, f32 distance_y) { f32 x; @@ -883,7 +883,7 @@ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, f32 y; bool var_v1; - var_v1 = FALSE; + var_v1 = false; x = gObjectList[objectIndex].pos[0] - player->pos[0]; y = gObjectList[objectIndex].pos[1] - player->pos[1]; z = gObjectList[objectIndex].pos[2] - player->pos[2]; @@ -893,7 +893,7 @@ bool has_collided_with_player_and_within_height(s32 objectIndex, Player *player, y = -y; } if ((((x * x) + (z * z)) <= (distance * distance)) && (y <= distance_y)) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } @@ -914,13 +914,13 @@ UNUSED bool func_80088F94(s32 objectIndex, Player *player, f32 arg2) { bool var_v1; distance = gObjectList[objectIndex].pos[1] - player->unk_074; - var_v1 = FALSE; + var_v1 = false; // abs(distance) if (distance < 0.0f) { distance = -distance; } if (distance <= arg2) { - var_v1 = TRUE; + var_v1 = true; } return var_v1; } @@ -1238,7 +1238,7 @@ s32 func_8008A060(s32 objectIndex, Camera *camera, u16 arg2) { var_v1 = 0; temp_t3 = (((u16)camera->rot[1] - gObjectList[objectIndex].direction_angle[1]) + (arg2 >> 1)); - + //! @warning Always true if ((temp_t3 >= 0) && (arg2 >= temp_t3)) { var_v1 = 1; @@ -1266,10 +1266,10 @@ bool is_object_visible_on_camera(s32 objectIndex, Camera *camera, u16 angle) { u16 temp_t2; s32 var_t0; - var_t0 = FALSE; + var_t0 = false; temp_t2 = (get_angle_between_xy(camera->pos[0], gObjectList[objectIndex].pos[0], camera->pos[2], gObjectList[objectIndex].pos[2]) + ((s32) angle / 2)) - camera->rot[1]; if ((temp_t2 >= 0) && (angle >= temp_t2)) { - var_t0 = TRUE; + var_t0 = true; } return var_t0; } diff --git a/src/code_80091440.c b/src/code_80091440.c index 45201bedf..b6c02d8d3 100644 --- a/src/code_80091440.c +++ b/src/code_80091440.c @@ -16,10 +16,8 @@ void func_800914A0(void) { UNUSED void func_800914E0(void) { UNUSED Vec3f sp64 = {0.0f, -20.0f, 150.0f}; UNUSED Vec3f sp58 = {0.0f, -6.0f, 4.0f}; - uintptr_t segment = SEGMENT_NUMBER2(D_8015F718[0]); - uintptr_t offset = SEGMENT_OFFSET(D_8015F718[0]); Camera *camera = &cameras[0]; - struct ActorSpawnData *sp48 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *sp48 = D_8015F718[0]; struct ActorSpawnData *tempData; s16 temp3 = (s16) D_80152308; @@ -31,7 +29,7 @@ UNUSED void func_800914E0(void) { camera->up[0] = 0; camera->up[1] = 1; camera->up[2] = 0; - + if(1) {} // waa? temp = temp2 - temp3; diff --git a/src/code_80091440.h b/src/code_80091440.h index 18aa89297..a8956a0ac 100644 --- a/src/code_80091440.h +++ b/src/code_80091440.h @@ -1,7 +1,7 @@ #ifndef CODE_80091440_H #define CODE_80091440_H -#include "ultra64.h" +#include <libultraship.h> void func_80091440(s8); void func_800914A0(void); diff --git a/src/code_80091750.c b/src/code_80091750.c index 165948d97..6c398e758 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -1,9 +1,9 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <defines.h> #include <segments.h> -#include <PR/ultratypes.h> +#include <libultra/types.h> #include <sounds.h> #include "code_800029B0.h" #include "code_80091750.h" @@ -1498,7 +1498,7 @@ void func_80091EE4(void) { if ((D_8018EDFB != 0) && (tmp == 0)) { temp_s2 = (gCupSelection * 4) + gCupCourseSelection; func_800B6708(); - + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { if ((D_8018EE10[temp_s0].ghostDataSaved != 0) && (temp_s2 == D_8018EE10[temp_s0].courseIndex)) { func_800B64EC(temp_s0); @@ -1612,7 +1612,7 @@ void func_80092290(s32 arg0, s32 *arg1, s32 *arg2) { if ((arg0 < 4) || (arg0 >= 6)) { return; } idx = (((arg0 * 4) + ((gGlobalTimer % 2) * 2)) - 6); - + *arg2 += 16; if (*arg2 >= 256) { *arg2 = 0; @@ -2739,7 +2739,7 @@ Gfx *draw_flash_select_case(UNUSED Gfx *displayListHead, s32 ulx, s32 uly, s32 l if (greyscale > 0xFF) { // set max greyscale to 0xFF greyscale = 0xFF; } - + #if AVOID_UB return gDisplayListHead = draw_box_fill(gDisplayListHead, ulx, uly, lrx, lry, greyscale, greyscale, greyscale, 0xFF); #else @@ -2832,7 +2832,7 @@ void func_80095AE0(Mtx2 *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { arg0->u.i[1][1] = sp10.s[0]; arg0->u.i[2][2] = 1; arg0->u.i[3][0] = spC.s[0]; - arg0->u.i[3][1] = sp8.s[0]; + arg0->u.i[3][1] = sp8.s[0]; arg0->u.i[3][3] = 1; arg0->u.f[0][0] = sp14.s[1]; arg0->u.f[1][1] = sp10.s[1]; @@ -2964,7 +2964,7 @@ Gfx *func_80095E10(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, arg8 += var_t0; } - + arg8 = sp7C; arg9 += temp_lo; } @@ -3062,7 +3062,7 @@ Gfx *func_800963F0(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, f32 arg4, argA += var_t0 * arg4; } - + argA = sp7C; argB += temp_lo * arg5; } @@ -3162,7 +3162,7 @@ Gfx *func_80096CD8(Gfx *displayListHead, s32 arg1, s32 arg2, u32 width, u32 arg4 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(displayListHead++, var_s1_3 * 4, var_fp * 4, (var_s1_3 + var_a1) * 4, (var_fp + var_v0) * 4, 0, (var_s1_3 * 32) & 0xFFFF, (var_fp * 32) & 0xFFFF, 1024, 1024); - + } } @@ -3256,14 +3256,14 @@ Gfx *func_80097274(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, } else { var_s2 = var_t0; } - - gDPLoadMultiTile(displayListHead++, arg1, 0, G_TX_RENDERTILE, arg2, G_IM_SIZ_16b, - argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, + + gDPLoadMultiTile(displayListHead++, arg1, 0, G_TX_RENDERTILE, arg2, G_IM_SIZ_16b, + argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, G_TX_WRAP, G_TX_WRAP, sp68, sp64, G_TX_NOLOD, G_TX_NOLOD); - gDPLoadMultiTile(displayListHead++, D_0B002A00 + random_int(128) * 2, 256, G_TX_RENDERTILE+1, arg2, G_IM_SIZ_16b, - argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, + gDPLoadMultiTile(displayListHead++, D_0B002A00 + random_int(128) * 2, 256, G_TX_RENDERTILE+1, arg2, G_IM_SIZ_16b, + argB, argC, var_a1_2, var_s3, var_a1_2 + var_s2, var_s3 + var_s4, 0, G_TX_WRAP, G_TX_WRAP, sp68, sp64, G_TX_NOLOD, G_TX_NOLOD); gSPTextureRectangle(displayListHead++, arg8 * 4, arg9 * 4, (arg8 + var_s2) * 4, (arg9 + var_s4) * 4, 0, @@ -3271,7 +3271,7 @@ Gfx *func_80097274(Gfx *displayListHead, s8 arg1, s32 arg2, s32 arg3, s32 arg4, arg8 += var_t0; } - + arg8 = sp7C; arg9 += temp_lo; } @@ -3522,9 +3522,9 @@ void func_80099110(void) { /** * Differs from memory.c with `+ 0x8` instead of `| 0x8` - * - * @param addr - * @return void* + * + * @param addr + * @return void* */ void *segmented_to_virtual_dupe(const void *addr) { size_t segment = (uintptr_t) addr >> 24; @@ -3816,9 +3816,9 @@ void func_80099AEC(void) { var_s4 = 0; var_s1 = D_8018E060; temp_s2 = var_s1->texture; - + if (temp_s2 == NULL) return; - + huh = temp_s2->size; if (huh != 0) { var_s0 = huh; @@ -3915,9 +3915,9 @@ void func_80099EC4(void) { var_s4 = 0; var_s1 = D_8018E0E8; temp_s2 = var_s1->mk64Texture; - + if (temp_s2 == NULL) return; - + huh = temp_s2->size; if (huh != 0) { var_s0 = huh; @@ -4401,11 +4401,11 @@ Gfx *func_8009B9D0(Gfx *displayListHead, MkTexture *textures) { bool found; s32 index; - found = FALSE; + found = false; for (index = 0; index < D_8018E768_SIZE; index++) { if (D_8018E768[index].textures == segmented_to_virtual_dupe(textures)) { displayList = D_8018E768[index].displayList; - found = TRUE; + found = true; break; } } @@ -6443,7 +6443,7 @@ void func_800A08D8(u8 arg0, s32 column, s32 row) { s32 func_800A095C(char *someString, s32 len, s32 column, s32 row) { s32 tempColumn; s32 nonTerminatorCount; - + nonTerminatorCount = 0; tempColumn = column; for (; len != 0; len--, tempColumn += 8) { @@ -8003,7 +8003,7 @@ void func_800A5738(struct_8018D9E0_entry *arg0) { void func_800A6034(struct_8018D9E0_entry *arg0) { char *text; - if (D_801657E8 != TRUE) { + if (D_801657E8 != true) { gDPSetPrimColor(gDisplayListHead++, 0, 0, 0x00, 0x00, 0x00, arg0->unk1C); text = gCupNames[D_800DC540]; set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2); @@ -10014,7 +10014,7 @@ struct_8018D9E0_entry *func_800AAE68(void) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } @@ -10034,7 +10034,7 @@ struct_8018D9E0_entry *func_800AAEB4(s32 arg0) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } @@ -10044,7 +10044,7 @@ escape: * search for. If no entry with that "type" is found, this * function will enter a `while(1)` loop, hard-locking the * game. - * + * * In practice this never appears to happen, but that is * probably as much a matter of luck as it is good * reasoning on the original author(s) part. @@ -10058,7 +10058,7 @@ struct_8018D9E0_entry *find_8018D9E0_entry_dupe(s32 arg0) { } // Something VERY wrong has occurred - while(TRUE); + while(true); escape: return entry; } diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index 9f76a1ae2..27f4fb4c9 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> @@ -91,7 +91,7 @@ void func_800AFC54(Vtx *arg0, s32 arg1, s32 arg2, s32 arg3, s16 arg4[3]) { a1 = &arg0[arg1]; a2 = &arg0[arg2]; - a3 = &arg0[arg3]; + a3 = &arg0[arg3]; saved1 = a2->v.ob[0]; saved2 = a2->v.ob[1]; @@ -185,7 +185,7 @@ void func_800AFF58(Vtx *arg0) { UNUSED u32 pad88[26]; s32 i, j; s16 sp40[12][3]; - + for (i = 0, j = 0; i < ARRAY_COUNT(sp40); i++, j += 4) { func_800AFC54(&arg0[j], 1, 2, 0, sp40[i]); } diff --git a/src/crash_screen.c b/src/crash_screen.c index 0208862be..1afe58019 100644 --- a/src/crash_screen.c +++ b/src/crash_screen.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <stdarg.h> @@ -99,11 +99,11 @@ GLOBAL_ASM("asm/non_matchings/crash_screen/crash_screen_draw_square.s") * Line 1: threadId - address of faulted instruction - error code * Line 2: Address in the return address register * Line 3: Machine code of faulted instruction - * + * * The R4300i manual discusses exceptions in more depth. - * - * @param framebuffer - * @param faulted thread + * + * @param framebuffer + * @param faulted thread **/ // 0xRGBA @@ -203,16 +203,16 @@ void thread9_crash_screen(UNUSED void *arg0) osSetEventMesg(10, &D_80162D40, (OSMesg) 16); sButtonSequenceIndex = 0; - while (TRUE) { + while (true) { osRecvMesg(&D_80162D40, &mesg, 1); thread = get_faulted_thread(); - + if (thread) { // Run only on the first iteration. if (sCounter == 0) { crash_screen_draw_square(pFramebuffer); #ifndef DEBUG - while(TRUE) + while(true) { read_controllers(); @@ -235,9 +235,9 @@ void thread9_crash_screen(UNUSED void *arg0) #else crash_screen_draw_info(pFramebuffer, thread); #endif - + } - if (sCounter < 5) { + if (sCounter < 5) { sCounter++; } } diff --git a/src/crash_screen.h b/src/crash_screen.h index 44ea6619d..bdcab16ea 100644 --- a/src/crash_screen.h +++ b/src/crash_screen.h @@ -1,7 +1,7 @@ #ifndef CRASH_SCREEN_H #define CRASH_SCREEN_H -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> extern u16 *pFramebuffer; diff --git a/src/data/data_segment2.c b/src/data/data_segment2.c index 2d72f4398..54e98c666 100644 --- a/src/data/data_segment2.c +++ b/src/data/data_segment2.c @@ -1,6 +1,6 @@ #include <macros.h> -#include <PR/ultratypes.h> -#include <PR/gbi.h> +#include <libultra/types.h> +#include <libultra/gbi.h> #include "data_segment2.h" #include <assets/startup_logo.h> diff --git a/src/data/some_data.h b/src/data/some_data.h index 3d70b3158..96ab00f5e 100644 --- a/src/data/some_data.h +++ b/src/data/some_data.h @@ -1,7 +1,7 @@ #ifndef SOME_DATA_H #define SOME_DATA_H -#include "PR/gbi.h" +#include <libultra/gbi.h> #include "spline.h" #include "data/other_textures.h" #include "objects.h" diff --git a/src/data/trig_tables_bss.c b/src/data/trig_tables_bss.c index aa2bc38d1..6caec65c2 100644 --- a/src/data/trig_tables_bss.c +++ b/src/data/trig_tables_bss.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> /** diff --git a/src/data_segment2.h b/src/data_segment2.h index f69f6a4d0..4dd9913e1 100644 --- a/src/data_segment2.h +++ b/src/data_segment2.h @@ -1,7 +1,7 @@ #ifndef DATA_SEGMENT2_H #define DATA_SEGMENT2_H -#include <PR/gbi.h> +#include <libultra/gbi.h> extern Vtx D_02007B38[]; diff --git a/src/debug/all_variables.h b/src/debug/all_variables.h index 561a23ea6..73b15e69d 100644 --- a/src/debug/all_variables.h +++ b/src/debug/all_variables.h @@ -63,7 +63,7 @@ #include <segments.h> #include <sounds.h> #include "buffers/trig_tables.h" -#include <ultra64.h> +#include <libultraship.h> #include <vehicles.h> #include <waypoints.h> diff --git a/src/debug/crash_screen_enhancement.c b/src/debug/crash_screen_enhancement.c index 574b3f531..4c05f28ae 100644 --- a/src/debug/crash_screen_enhancement.c +++ b/src/debug/crash_screen_enhancement.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <stdarg.h> @@ -126,9 +126,9 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) { void crash_screen_sleep(s32 ms) { u64 cycles = ms * 1000LL * osClockRate / 1000000ULL; - osSetTime(0); - while (osGetTime() < cycles) { - } + // osSetTime(0); + // while (osGetTime() < cycles) { + // } } void crash_screen_print_float_reg(s32 x, s32 y, s32 regNum, void *addr) { @@ -215,6 +215,6 @@ void crash_screen_draw(OSThread* thread) { crash_screen_print_float_reg(120, 210, 26, &tc->fp26.f.f_even); crash_screen_print_float_reg(210, 210, 28, &tc->fp28.f.f_even); crash_screen_print_float_reg(30, 220, 30, &tc->fp30.f.f_even); - osViBlack(FALSE); + osViBlack(false); osViSwapBuffer(pFramebuffer); } diff --git a/src/debug/crash_screen_enhancement.h b/src/debug/crash_screen_enhancement.h index 9f9a321ca..5860f9226 100644 --- a/src/debug/crash_screen_enhancement.h +++ b/src/debug/crash_screen_enhancement.h @@ -1,7 +1,7 @@ #ifndef CRASH_SCREEN_ENHANCEMENT_H #define CRASH_SCREEN_ENHANCEMENT_H -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> void crash_screen_draw(OSThread* thread); diff --git a/src/debug/debug.c b/src/debug/debug.c index cdc333dc5..f5daa4397 100644 --- a/src/debug/debug.c +++ b/src/debug/debug.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <debug.h> #include "debug.inc.c" #include <libc/stdio.h> @@ -82,14 +82,14 @@ static u32 variable_to_u64(variableWatchAttributes *attribute) { u32 variable; switch (attribute->variableSize) { - case sizeof(u8): + case sizeof(u8): variable = *((u8*) attribute->variablePointer); break; - case sizeof(u16): + case sizeof(u16): variable = *((u16*) attribute->variablePointer); break; case sizeof(u32): - case sizeof(u64): + case sizeof(u64): variable = *((u32*) attribute->variablePointer); // no floating point rounding break; default: @@ -103,7 +103,7 @@ static void round_up_float(u32 *variable, u8 variableSize) { switch (variableSize) { case sizeof(u64): case sizeof(u32): - *variable = (u32) (*(f32*) &*variable); + *variable = (u32) (*(f32*) &*variable); break; default: sDisplayListState = BAD; @@ -131,7 +131,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b switch (variableSize) { case sizeof(u8): signedVariable = (s8) variable; - if (signedVariable < 0) { + if (signedVariable < 0) { signedVariable = -signedVariable; variable = (u8) signedVariable; *bufferedString = '-'; @@ -150,7 +150,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b case sizeof(u32): case sizeof(u64): signedVariable = (s32) variable; - if (signedVariable < 0) { + if (signedVariable < 0) { signedVariable = -signedVariable; variable = (u32) signedVariable; *bufferedString = '-'; @@ -164,11 +164,11 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b // convert u64 into a string but it gets put in reverse if (base != HEXIDECIMAL) { - do { + do { stringLength++; *bufferedString = variable % base + '0'; bufferedString++; - variable /= base; + variable /= base; } while (variable != 0); } else { do { @@ -186,8 +186,8 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b } while (variable != 0); } - bufferedString -= stringLength; - upperIndex = stringLength - 1; + bufferedString -= stringLength; + upperIndex = stringLength - 1; // flip string 4321 --> 1234 for (lowerIndex = 0; lowerIndex < stringLength >> 1; lowerIndex++) { @@ -228,7 +228,7 @@ static void u64_to_string(variableWatchAttributes *attribute, u32 variable, u8 b static u32 _strlen(const char *str) { u32 len; - + len = 0; for (; *str != '\0'; str++) { len++; @@ -245,7 +245,7 @@ static void _memcpy(char *destStr, const char *copyStr, u32 copySize) { *destStr = *copyStr; destStr++; copyStr++; - } + } } #endif diff --git a/src/debug/debug.inc.c b/src/debug/debug.inc.c index 758bf3600..82f26be03 100644 --- a/src/debug/debug.inc.c +++ b/src/debug/debug.inc.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <debug.h> #include "all_variables.h" @@ -6,7 +6,7 @@ extern s32 gGlobalTimer; -/** +/** * Edit this to edit what displays on the screen while the DVDL is active. * The Size of the structure array is calculated at compile time. */ @@ -14,42 +14,42 @@ variableWatchAttributes gMainVariableWatchList[] = { { "Global Timer: ", &gGlobalTimer, - sizeof(gGlobalTimer), + sizeof(gGlobalTimer), DISPLAY_DECIMAL_NUMBER | DISPLAY_SIGNED_NUMBER, 0, 0 }, { "Actors: ", &gNumActors, - sizeof(gNumActors), + sizeof(gNumActors), DISPLAY_DECIMAL_NUMBER, 0, 0 }, { "Player Type: ", &gPlayers[0].type, - sizeof(gPlayerOne->type), + sizeof(gPlayerOne->type), DISPLAY_HEXIDECIMAL_NUMBER, 0, 0 }, { "X ", &gPlayers[0].pos[0], - sizeof(gPlayerOne->pos[0]), + sizeof(gPlayerOne->pos[0]), DISPLAY_FLOAT_NUMBER, 0, 0 }, { "Y ", &gPlayers[0].pos[1], - sizeof(gPlayerOne->pos[1]), + sizeof(gPlayerOne->pos[1]), DISPLAY_FLOAT_NUMBER, 0, 0 }, { "Z ", &gPlayers[0].pos[2], - sizeof(gPlayerOne->pos[2]), + sizeof(gPlayerOne->pos[2]), DISPLAY_FLOAT_NUMBER, 0, 0 }, diff --git a/src/effects.c b/src/effects.c index 52c5127e2..d8614722d 100644 --- a/src/effects.c +++ b/src/effects.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <decode.h> #include <mk64.h> @@ -186,14 +186,14 @@ void clean_effect(Player *player, s8 arg1) { if ((player->effects & 0x400) == 0x400) { func_8008C6D0(player, arg1); } - + if (((player->effects & 0x80) == 0x80) || (player->effects & 0x40) == 0x40) { func_8008C8C4(player, arg1); } if ((player->effects & 0x800) == 0x800) { func_8008D0E4(player, arg1); } - if ((player->unk_044 & 0x4000) != 0) { + if ((player->unk_044 & 0x4000) != 0) { func_8008D3B0(player, arg1); } if ((player->effects & BOOST_EFFECT) == BOOST_EFFECT) { @@ -311,7 +311,7 @@ void func_8008C73C(Player *player, s8 arg1) { D_80165190[3][arg1] = 1; D_80165280[arg1] = player->currentSpeed; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; D_8018D920[arg1] = 0; @@ -340,7 +340,7 @@ void func_8008C8C4(Player* player, s8 playerId) { player->unk_046 &= 0xFFBF; - if ((gIsPlayerTripleAButtonCombo[playerId] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[playerId] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed = (f32) (player->currentSpeed + 100.0f); } if ((gModeSelection == VERSUS) && ((player->type & PLAYER_KART_AI) == PLAYER_KART_AI) && (!gDemoMode) && ((player->unk_0CA & 2) == 0) && (gGPCurrentRaceRankByPlayerId[playerId] != 0)) { @@ -394,7 +394,7 @@ void func_8008C9EC(Player *player, s8 arg1) { } } } - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { gTimerBoostTripleACombo[arg1] = 0x00000078; if (player->currentSpeed <= 90.0f) { player->currentSpeed = 90.0f; @@ -410,7 +410,7 @@ void func_8008CDC0(Player* player, s8 arg1) { player->unk_0B8 = 3.0f; player->unk_0AC = 1; player->effects &= ~0x10; - + if (((player->unk_07C >> 0x10) >= 0x14) || ((player->unk_07C >> 0x10) < -0x13) || (((player->unk_094 / 18.0f) * 216.0f) <= 30.0f) || ((player->effects & 8) != 0) || (((player->type & PLAYER_HUMAN) == 0) && ((player->effects & 0x1000) == 0))) { func_8008C73C(player, arg1); } @@ -548,7 +548,7 @@ void apply_boost_sound_effect(Player* player, s8 arg1) { player->soundEffects &= ~BOOST_SOUND_EFFECT; player->unk_DB4.unk0 = 0; player->unk_DB4.unk8 = 8.0f; - + if (D_8015F890 != 1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C9250(arg1); @@ -575,7 +575,7 @@ void apply_boost_effect(Player* player) { } else { move_f32_towards(&player->boostPower, 0.0f, 0.1f); } - + if (player->boostPower <= 1.0f) { player->effects &= ~BOOST_EFFECT; } @@ -613,7 +613,7 @@ void func_8008D570(Player *player, s8 arg1) { void func_8008D698(Player* player, s8 arg1) { s16 temp; - + if (player->unk_0B2 == 0) { player->rotation[1] = player->unk_0AE; temp = 0; @@ -758,7 +758,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->currentSpeed = 0.0f; if ((player->unk_110.unk3C[2] >= 600.0f) || ((player->effects & 0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match - switch (D_8018D990[arg1]) { + switch (D_8018D990[arg1]) { case 0: player->unk_DB4.unk10 = 4.5f; if (player->unk_238 < 0x3D) { @@ -792,7 +792,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_DB4.unk10 = 4.5f; player->pos[1] += 0.13; ++player->unk_238; - + if ((player->unk_046 & 0x80) != 0) { if (player->unk_238 >= 0x32) { D_8018D990[arg1] = 2; @@ -868,9 +868,9 @@ void apply_hit_rotating_sound_effect(Player* player, s8 arg1) { player->unk_0AE = player->rotation[1]; player->unk_0B2 = 2; player->unk_0C0 = 0; - player->unk_07C = 0; + player->unk_07C = 0; player->unk_078 = 0; - + D_80165190[0][arg1] = 1; D_80165190[1][arg1] = 1; D_80165190[2][arg1] = 1; @@ -942,18 +942,18 @@ void apply_lightning_effect(Player *player, s8 arg1) { void remove_lightning_effect(Player* player, UNUSED s8 arg1) { move_f32_towards(&player->size, 1.0f, 0.1f); move_f32_towards(&player->boundingBoxSize, gKartBoundingBoxSizeTable[player->characterId], 0.1f); - + player->effects &= ~LIGHTNING_EFFECT; player->size = 1.0f; player->boundingBoxSize = gKartBoundingBoxSizeTable[player->characterId]; player->unk_DB4.unk10 = 3.0f; player->unk_DB4.unk2 = 0; player->effects |= 0x08000000; - + if ((player->effects & 0x20000) == 0x20000) { player->rotation[1] = player->unk_0AE; } - + player->effects &= ~0x20000; } @@ -985,7 +985,7 @@ void func_8008E4A4(Player* player, s8 arg1) { player->unk_042 = 0; player->type &= ~0x80; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } if (gModeSelection == BATTLE) { @@ -1008,7 +1008,7 @@ void func_8008E4A4(Player* player, s8 arg1) { if (gModeSelection == BATTLE) { func_8006B8B4(player, arg1); } - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1055,7 +1055,7 @@ void apply_reverse_sound_effect(Player *player, s8 arg1) player->soundEffects &= ~(REVERSE_SOUND_EFFECT | 0x80000); player->unk_0B6 |= 0x40; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; } @@ -1096,7 +1096,7 @@ void apply_hit_by_item_effect(Player *player, s8 arg1) { D_80165190[2][arg1] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1116,7 +1116,7 @@ void apply_hit_by_item_effect(Player *player, s8 arg1) { D_80165190[2][arg1] = 1; D_80165190[3][arg1] = 1; player->unk_042 = 0; - if ((gIsPlayerTripleAButtonCombo[arg1] == TRUE) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if ((gIsPlayerTripleAButtonCombo[arg1] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed += 100.0f; } @@ -1142,20 +1142,20 @@ void apply_hit_by_item_sound_effect(Player* player, s8 arg1) { player->unk_236 = 4; player->unk_042 = 0; player->unk_0E0 = 0; - + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); func_800C9060(arg1, SOUND_ACTION_EXPLOSION); } else { func_800098FC(arg1, player); } - + player->effects |= HIT_BY_ITEM_EFFECT; player->unk_0B6 |= 0x40; player->soundEffects &= ~0x01000002; gTimerBoostTripleACombo[arg1] = 0; - gIsPlayerTripleAButtonCombo[arg1] = FALSE; + gIsPlayerTripleAButtonCombo[arg1] = false; gCountASwitch[arg1] = 0; gFrameSinceLastACombo[arg1] = 0; } @@ -1247,7 +1247,7 @@ void apply_boost_ramp_wood_effect(Player* player) { } else { move_f32_towards(&player->boostPower, 300.0f, 0.1f); } - + if (player->boostPower <= 1.0f) { player->effects &= ~BOOST_RAMP_WOOD_EFFECT; player->boostPower = 0.0f; @@ -1268,10 +1268,10 @@ void func_8008F104(Player* player, s8 arg1) { player->unk_0B2 = 2; player->unk_0C0 = 0; player->unk_07C = 0; - player->effects |= 0x4000; + player->effects |= 0x4000; player->unk_078 = 0; D_8018D920[arg1] = -0x8000; - + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); } @@ -1358,13 +1358,13 @@ void func_8008F494(Player* player, s8 arg1) { clean_effect(player, arg1); func_8008F86C(player, arg1); - + player->unk_0A8 = 0; player->effects |= 0x10000; player->effects &= ~0x10; player->unk_236 = 0x1E; player->unk_042 = 0; - + if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) == 0) && ((player->unk_0CA & 2) == 0) && @@ -1380,7 +1380,7 @@ void func_8008F5A4(Player* player, s8 arg1) { func_8006B8B4(player, arg1); player->unk_044 &= ~0x8000; } - + player->unk_206 = 0; player->slopeAccel = 0; player->effects &= ~0x10000; @@ -1453,7 +1453,7 @@ void apply_boo_effect(Player* arg0, s8 arg1) { tmp = ((s32) gCourseTimer) - D_8018D950[arg1]; if (tmp < 7) { arg0->unk_0C6 -= 2; - + if (arg0->unk_0C6 < 0x61) { arg0->unk_0C6 = 0x60; } @@ -1489,7 +1489,7 @@ void apply_boo_sound_effect(Player* player, s8 arg1) { if ((player->type & PLAYER_HUMAN) != 0) { player->unk_044 |= 0x200; - + for (temp_v1 = 0; temp_v1 < 10; ++temp_v1) { player->unk_258[temp_v1].unk_01C = 0; player->unk_258[temp_v1].unk_01E = 0; @@ -1549,7 +1549,7 @@ void func_8008FC64(Player* player, s8 arg1) { player->soundEffects &= 0xFBFFFFFF; player->soundEffects |= 0x08000000; player->type |= PLAYER_UNKNOWN_0x40; - + func_8008FDA8(player, arg1); func_800569F4(arg1); } @@ -1567,7 +1567,7 @@ void func_8008FCDC(Player* player, s8 arg1) { void func_8008FD4C(Player* player, UNUSED s8 arg1) { s16 temp_v0; - + player->soundEffects |= 0x04000000; player->unk_044 |= 0x200; @@ -1590,7 +1590,7 @@ void func_8008FDA8(Player* player, UNUSED s8 arg1) { void func_8008FDF4(Player* player, UNUSED s8 arg1) { clean_effect(player, arg1); - + player->effects &= ~0x10; player->kartHopJerk = D_800E37F0[player->characterId]; player->kartHopAcceleration = 0.0f; @@ -1649,9 +1649,9 @@ void func_8008FF08(Player *player, s8 playerId) { case COURSE_FRAPPE_SNOWLAND: waypoint = gNearestWaypointByPlayerId[playerId]; #ifdef VERSION_EU - if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || + if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || ((gCopyNearestWaypointByPlayerId[playerId] >= 0xF0) && (gCopyNearestWaypointByPlayerId[playerId] < 0x11E))) -#else +#else if ((waypoint >= 0xF0) && (waypoint < 0x105)) #endif { @@ -1791,7 +1791,7 @@ void func_80090778(Player* player) { clean_effect(player, playerIndex); func_8008F86C(player, playerIndex); - + player->unk_DB4.unk0 = 0; player->unk_0C2 = 0; player->unk_DB4.unk8 = 0.0f; @@ -2009,7 +2009,7 @@ void func_80090970(Player *player, s8 playerId, s8 arg2) { bool prevent_item_use(Player *player) { s32 phi_v0 = 0; if ((((((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) || ((player->type & PLAYER_UNKNOWN_0x40) != 0)) || ((player->type & PLAYER_CINEMATIC_MODE) != 0)) || ((player->type & PLAYER_EXISTS) == 0)) { - return TRUE; + return true; } switch (player->currentItemCopy) { @@ -2018,7 +2018,7 @@ bool prevent_item_use(Player *player) { case ITEM_TRIPLE_MUSHROOM: case ITEM_SUPER_MUSHROOM: if ((player->effects & 8) != 0) { - return TRUE; + return true; } phi_v0 = EFFECT_BLACKLIST_USE_ITEM; goto prevent_item_use_label; @@ -2029,9 +2029,9 @@ bool prevent_item_use(Player *player) { prevent_item_use_label: default: if ((player->effects & phi_v0) != 0) { - return TRUE; + return true; } - return FALSE; + return false; } } diff --git a/src/ending/camera_junk.c b/src/ending/camera_junk.c index ec709d0ff..808fd9bb0 100644 --- a/src/ending/camera_junk.c +++ b/src/ending/camera_junk.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <common_structs.h> @@ -16,7 +16,7 @@ void setup_camera_podium_ceremony(void) { camera = &cameras[0]; func_80283648(camera); - + x_dist = camera->lookAt[0] - camera->pos[0]; y_dist = camera->lookAt[1] - camera->pos[1]; z_dist = camera->lookAt[2] - camera->pos[2]; diff --git a/src/ending/ceremony_and_credits.c b/src/ending/ceremony_and_credits.c index d12c5d276..a4ae32ee7 100644 --- a/src/ending/ceremony_and_credits.c +++ b/src/ending/ceremony_and_credits.c @@ -4,7 +4,7 @@ * Camera moves via splines. */ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <segments.h> #include <common_structs.h> @@ -113,9 +113,9 @@ s32 f32_lerp(f32 *dest, f32 src, f32 lerp) { if (lerp > 1.0f) { lerp = 1.0f; } - + *dest = *dest + ((src - *dest) * lerp); - + if (src == *dest) { return 0; } @@ -133,7 +133,7 @@ UNUSED s32 func_80282200(Vec3s arg0, s16 arg1, s16 arg2) { temp_v0 += arg1; arg0[0] = temp_v0; } - + if (arg1 == arg0[0]) { return 0; } @@ -143,7 +143,7 @@ UNUSED s32 func_80282200(Vec3s arg0, s16 arg1, s16 arg2) { // Calculates fade in/out s32 set_transition_colour_fade_alpha_ending(f32 *arg0, f32 arg1, f32 arg2) { f32 temp_f0 = arg1 - *arg0; - + if (arg2 < 0.0f) { arg2 = -1.0f * arg2; } @@ -309,7 +309,7 @@ s32 move_point_along_spline(Vec3f p, f32 *arg1, struct struct_80283430 spline[], } func_80282700(u, p, arg1, controlPoints[0], controlPoints[1], controlPoints[2], controlPoints[3]); - + if (spline[*splineSegment + 1].unk2 != 0) { firstSpeed = 1.0f / spline[*splineSegment + 1].unk2; } @@ -356,10 +356,10 @@ void func_80282C40(struct struct_80283430 *arg0, struct struct_80282C40 *arg1, s s32 i = 0; s32 j = 0; func_80282BE4(&arg0[j], arg1[j].unk0, arg1[j].unk3, arg1[j].unk4, arg1[j].unk6, arg2); - + j++; goto dummy_label_888430; - while(TRUE) { + while(true) { do { dummy_label_888430: ; @@ -372,7 +372,7 @@ dummy_label_888430: ; func_80282BE4(&arg0[j], arg1->unk0, arg1[i].unk3, arg1[i].unk4, arg1[i].unk6, arg2); func_80282BE4(&arg0[j + 1], arg1->unk0, 0, arg1[i].unk4, arg1[i].unk6, arg2); func_80282BE4(&arg0[j + 2], arg1->unk0, 0, arg1[i].unk4, arg1[i].unk6, arg2); - func_80282BE4(&arg0[j + 3], -1, 0, arg1[i].unk4, arg1[i].unk6, arg2); + func_80282BE4(&arg0[j + 3], -1, 0, arg1[i].unk4, arg1[i].unk6, arg2); break; } } @@ -727,7 +727,7 @@ void func_80283BF0(UNUSED struct CinematicCamera *camera) { func_800C8EF8(0x1A); } -// +// void func_80283C14(UNUSED struct CinematicCamera *camera) { func_800C8EF8(0x1B); } @@ -1584,7 +1584,7 @@ void func_802847CC(struct CinematicCamera *camera) { } #endif - if (gCutsceneShotTimer == sp2C) { + if (gCutsceneShotTimer == sp2C) { if (D_80286A04[D_800DC5E4].unk0 != 2) { func_80280268(D_80286A04[D_800DC5E4 + 1].unk1); } @@ -1631,7 +1631,7 @@ void play_cutscene(struct CinematicCamera *camera) { #undef CUTSCENE if ((cutsceneDuration != 0) && ((gCutsceneShotTimer & 0xC000) == 0)) { - + if (gCutsceneShotTimer < 16383) { gCutsceneShotTimer++; } @@ -1651,12 +1651,12 @@ void play_cutscene(struct CinematicCamera *camera) { reset_spline(); } } - + } /** * Scene transition - * + * * Sliding black borders that open horizontally to display scene. * Used at the beginning of award ceremony and throughout credits. */ @@ -1681,4 +1681,3 @@ void transition_sliding_borders(void) { gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); set_transition_colour_fade_alpha_ending(&D_802856C0, D_802856B8, D_802856BC / D_802856B4); } - diff --git a/src/ending/code_80280000.c b/src/ending/code_80280000.c index f9f1fe824..c7351a09b 100644 --- a/src/ending/code_80280000.c +++ b/src/ending/code_80280000.c @@ -1,8 +1,7 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <debug.h> -#include <PR/gu.h> #include <mk64.h> #include <main.h> @@ -50,7 +49,7 @@ void func_80280038(void) { func_802A53A4(); init_rdp(); func_80057FC4(0); - + gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, D_80150150, D_8015014C, 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); @@ -83,7 +82,7 @@ void func_80280268(s32 arg0) { void credits_loop(void) { Camera *camera = &cameras[0]; - + f32 temp_f12; f32 temp; f32 temp_f14; @@ -140,7 +139,7 @@ void load_credits(void) { load_course(gCurrentCourseId); D_8015F730 = gNextFreeMemoryAddress; set_segment_base_addr(0xB, (void *) decompress_segments((u8 *) CEREMONY_DATA_ROM_START, (u8 *) CEREMONY_DATA_ROM_END)); - + gCourseMinX = -0x15A1; gCourseMinY = -0x15A1; gCourseMinZ = -0x15A1; diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 4b33160a1..367241e39 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <segments.h> @@ -21,6 +21,8 @@ #include "menus.h" #include "render_courses.h" +#define bcopy memcpy + u8 defaultCharacterIds[] = { 1, 2, 3, 4, 5, 6, 7, 0 }; diff --git a/src/ending/code_80281C40.c b/src/ending/code_80281C40.c index afc01f1de..7c6ff8f7a 100644 --- a/src/ending/code_80281C40.c +++ b/src/ending/code_80281C40.c @@ -1,5 +1,4 @@ -#include <ultra64.h> -#include <PR/gu.h> +#include <libultraship.h> #include <macros.h> #include "code_80281C40.h" diff --git a/src/ending/code_80281C40.h b/src/ending/code_80281C40.h index 50ccc4f4e..23f356284 100644 --- a/src/ending/code_80281C40.h +++ b/src/ending/code_80281C40.h @@ -1,5 +1,5 @@ #ifndef CODE_80281C40_H -#define CODE_80281C40_h +#define CODE_80281C40_H /* Function Prototypes */ diff --git a/src/ending/credits.h b/src/ending/credits.h index 277cf0196..505bb6262 100644 --- a/src/ending/credits.h +++ b/src/ending/credits.h @@ -1,7 +1,7 @@ #ifndef CREDITS_H #define CREDITS_H -#include "PR/ultratypes.h" +#include <libultra/types.h> #define SLIDE_RIGHT 0 #define SLIDE_LEFT 1 diff --git a/src/ending/dl_unk_80284EE0.c b/src/ending/dl_unk_80284EE0.c index 64282cb08..ada5ac8b0 100644 --- a/src/ending/dl_unk_80284EE0.c +++ b/src/ending/dl_unk_80284EE0.c @@ -1,5 +1,5 @@ -#include <ultra64.h> -#include <PR/gbi.h> +#include <libultraship.h> +#include <libultra/gbi.h> #include "courses/royal_raceway/course_displaylists.inc.h" // Init RDP - RSP (Ceremony) diff --git a/src/ending/podium_ceremony_actors.c b/src/ending/podium_ceremony_actors.c index dc6a224d6..f6d5231c0 100644 --- a/src/ending/podium_ceremony_actors.c +++ b/src/ending/podium_ceremony_actors.c @@ -1,6 +1,5 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> -#include <PR/gu.h> #include <mk64.h> #include <debug.h> #include <common_structs.h> @@ -90,7 +89,7 @@ void set_initial_position(CeremonyActor *actor) { actor->pos[0] = params->unk2[0]; actor->pos[1] = params->unk2[1]; actor->pos[2] = params->unk2[2]; - + // Place value in the high bits of s16. // Example: 85, 0b01010101 -> 0b0101010100000000 actor->unkA = params->unk8 << 8; @@ -149,7 +148,7 @@ u16 random_u16_credits(void) { temp1 = ((temp1 & 0x00FF) << 1) ^ sRandomSeed16; temp2 = (temp1 >> 1) ^ 0xFF80; - + if ((temp1 & 1) == 0) { if (temp2 == 43605) { sRandomSeed16 = 0; @@ -356,7 +355,7 @@ void spawn_firework_cone(s32 arg0, s32 arg1, s32 arg2) { cone->pos[0] = random_who_knows(0.0f) + arg0; cone->pos[1] = random_who_knows((f32) (D_802874B0[11] + 100)) + (f32) arg1; cone->pos[2] = random_who_knows((f32) (D_802874B0[12] + 700)) + (f32) arg2; - + num = 1.1f; // Wrap the counter from zero to three @@ -393,7 +392,7 @@ void spawn_timer(void) { } else if (D_802874D8.actorTimer == 2) { spawn_balloons(-0xC6C, (s32) ((f32) D_802874B0[10] + 210.0f), -0x1EF); } - + D_802874D8.actorTimer += 1; } @@ -475,7 +474,7 @@ void podium_ceremony_loop(void) { func_80281D00(); func_80281540(); #if DVDL - display_dvdl(); + display_dvdl(); #endif gDPFullSync(gDisplayListHead++); gSPEndDisplayList(gDisplayListHead++); diff --git a/src/gbiMacro.c b/src/gbiMacro.c index 18f131dce..d1f2fefe4 100644 --- a/src/gbiMacro.c +++ b/src/gbiMacro.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "PR/gu.h" #include "main.h" diff --git a/src/kart_dma.c b/src/kart_dma.c index faba825d3..97825a528 100644 --- a/src/kart_dma.c +++ b/src/kart_dma.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "main.h" #include "buffers.h" diff --git a/src/main.c b/src/main.c index 19eb4f4c5..74146d418 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ #ifndef GCC #define D_800DC510_AS_U16 #endif -#include <ultra64.h> +#include <libultraship.h> #include <PR/os.h> #include <PR/ucode.h> #include <macros.h> @@ -230,7 +230,7 @@ void thread1_idle(void *arg) { osViSetMode(&osViModeTable[OS_VI_MPAL_LAN1]); } #endif - osViBlack(TRUE); + osViBlack(true); osViSetSpecialFeatures(OS_VI_GAMMA_OFF); osCreatePiManager(OS_PRIORITY_PIMGR, &gPIMesgQueue, gPIMesgBuf, ARRAY_COUNT(gPIMesgBuf)); wasSoftReset = (s16) osResetType; @@ -241,7 +241,7 @@ void thread1_idle(void *arg) { osSetThreadPri(NULL, 0); // Halt - while (TRUE); + while (true); } void setup_mesg_queues(void) { @@ -306,9 +306,9 @@ void init_controllers(void) { osSetEventMesg(OS_EVENT_SI, &gSIEventMesgQueue, (OSMesg) 0x33333333); osContInit(&gSIEventMesgQueue, &gControllerBits, gControllerStatuses); if ((gControllerBits & 1) == 0) { - sIsController1Unplugged = TRUE; + sIsController1Unplugged = true; } else { - sIsController1Unplugged = FALSE; + sIsController1Unplugged = false; } } @@ -517,7 +517,7 @@ void setup_game_memory(void) { init_segment_racing(); gHeapEndPtr = SEG_RACING; set_segment_base_addr(0, (void *) SEG_START); - + // Memory pool size of 0xAB630 initialize_memory_pool(MEMORY_POOL_START, MEMORY_POOL_END); @@ -529,7 +529,7 @@ void setup_game_memory(void) { osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK); set_segment_base_addr(2, (void *) load_data(SEG_DATA_START, SEG_DATA_END)); - + commonCourseDataSize = COMMON_TEXTURES_SIZE; commonCourseDataSize = ALIGN16(commonCourseDataSize); @@ -613,14 +613,14 @@ void race_logic_loop(void) { D_8015F788 = 0; render_player_one_1p_screen(); if (!gEnableDebugMode) { - D_800DC514 = FALSE; + D_800DC514 = false; } else { if (D_800DC514) { if ((gControllerOne->buttonPressed & R_TRIG) && (gControllerOne->button & A_BUTTON) && (gControllerOne->button & B_BUTTON)) { - D_800DC514 = FALSE; + D_800DC514 = false; } rotY = camera1->rot[1]; @@ -641,7 +641,7 @@ void race_logic_loop(void) { if ((gControllerOne->buttonPressed & L_TRIG) && (gControllerOne->button & A_BUTTON) && (gControllerOne->button & B_BUTTON)) { - D_800DC514 = TRUE; + D_800DC514 = true; } } } @@ -872,7 +872,7 @@ void game_state_handler(void) { (gControllerOne->button & Z_TRIG) && (gControllerOne->button & A_BUTTON)) { gGamestateNext = CREDITS_SEQUENCE; - } else if ((gControllerOne->button & L_TRIG) && + } else if ((gControllerOne->button & L_TRIG) && (gControllerOne->button & R_TRIG) && (gControllerOne->button & Z_TRIG) && (gControllerOne->button & B_BUTTON)) { @@ -1080,7 +1080,7 @@ void thread3_video(UNUSED void *arg0) { create_thread(&gGameLoopThread, 5, &thread5_game_loop, 0, gGameLoopThreadStack + ARRAY_COUNT(gGameLoopThreadStack), 10); osStartThread(&gGameLoopThread); - while (TRUE) { + while (true) { osRecvMesg(&gIntrMesgQueue, &msg, OS_MESG_BLOCK); switch ((u32) msg) { case MESG_VI_VBLANK: @@ -1147,7 +1147,7 @@ void update_gamestate(void) { gCurrentlyLoadedCourseId = COURSE_NULL; break; case RACING: - /** + /** * @bug Reloading this segment makes random_u16() deterministic for player spawn order. * In laymens terms, random_u16() outputs the same value every time. */ @@ -1189,7 +1189,7 @@ void thread5_game_loop(UNUSED void *arg) { read_controllers(); func_800C5CB8(); - while(TRUE) { + while(true) { func_800CB2C4(); // Update the gamestate if it has changed (racing, menus, credits, etc.). @@ -1215,7 +1215,7 @@ void thread4_audio(UNUSED void *arg) { osCreateMesgQueue(&sSoundMesgQueue, sSoundMesgBuf, ARRAY_COUNT(sSoundMesgBuf)); set_vblank_handler(1, &sSoundVblankHandler, &sSoundMesgQueue, (OSMesg) 512); - while (TRUE) { + while (true) { OSMesg msg; struct SPTask *spTask; diff --git a/src/main.h b/src/main.h index b1e37ea95..f760b9e44 100644 --- a/src/main.h +++ b/src/main.h @@ -1,6 +1,8 @@ #ifndef MAIN_H #define MAIN_H +#include "mk64.h" +#include "common_structs.h" // Message IDs #define MESG_SP_COMPLETE 100 diff --git a/src/math_util_2.c b/src/math_util_2.c index 2afe7f201..d5571ee4b 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <common_structs.h> #include "math_util_2.h" @@ -30,9 +30,9 @@ UNUSED void operator_xor(s32 *arg0, s32 arg1) { UNUSED bool func_80040E84(s32 *arg0, s32 arg1) { bool phi_v1; - phi_v1 = FALSE; + phi_v1 = false; if ((*arg0 & arg1) != 0) { - phi_v1 = TRUE; + phi_v1 = true; } return phi_v1; } @@ -455,10 +455,10 @@ bool is_particle_on_screen(Vec3f arg0, Camera *arg1, u16 arg2) { u16 temp_t9; s32 ret; - ret = FALSE; + ret = false; temp_t9 = (get_angle_between_xy(arg1->pos[0], arg0[0], arg1->pos[2], arg0[2]) + (arg2 / 2)) - arg1->rot[1]; if ((temp_t9 >= 0) && (arg2 >= temp_t9)) { - ret = TRUE; + ret = true; } return ret; } @@ -502,7 +502,7 @@ void mtfx_translation_x_y(Mat4 arg0, s32 x, s32 y) { * 1 0 0 x * 0 1 0 y * 0 0 1 0 - * 0 0 0 1 + * 0 0 0 1 */ } @@ -944,10 +944,10 @@ void vec3f_rotate_x_y(Vec3f dest, Vec3f pos, Vec3s rot) { /** * @brief set the matrix to a transformation matrix - * + * * @param translate or position - * @param orientation - * @param scale + * @param orientation + * @param scale */ void rsp_set_matrix_transformation(Vec3f translate, Vec3su orientation, f32 scale) { Mat4 matrix; diff --git a/src/menus.c b/src/menus.c index f5d371820..6236aa6f4 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <common_structs.h> @@ -30,7 +30,7 @@ f32 D_8018EDD8; f32 D_8018EDDC; s32 D_8018EDE0; s8 gCharacterGridSelections[4]; // map from player id to current grid position -bool8 D_8018EDE8[4]; // map player id to isCharSelected on CSS +bool D_8018EDE8[4]; // map player id to isCharSelected on CSS s8 D_8018EDEC; s8 gMainMenuSelectionDepth; s8 D_8018EDEE; // grid screen state? @@ -240,7 +240,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { case 0x17: case 0x18: { - sp2C = FALSE; + sp2C = false; if ((btnAndStick & D_JPAD) && (D_8018EDEC < 0x18)) { D_8018EDEC += 1; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -248,7 +248,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { sp38->unk24 += 4.0; } sp38->unk8 = 1; - sp2C = TRUE; + sp2C = true; } if ((btnAndStick & U_JPAD) && (D_8018EDEC >= 0x16)) { D_8018EDEC -= 1; @@ -256,7 +256,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) { if (sp38->unk24 < 4.2) { sp38->unk24 += 4.0; } - sp2C = TRUE; + sp2C = true; sp38->unk8 = -1; } if (sp2C && gSoundMode != sp38->cursor) { @@ -1008,7 +1008,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { u16 i; s32 sp28; - sp28 = TRUE; + sp28 = true; btnAndStick = controller->buttonPressed | controller->stickPressed; if (func_800B4520() == 0) { @@ -1018,7 +1018,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { switch (gDebugMenuSelection) { case DEBUG_MENU_DISABLED: { - sp28 = FALSE; + sp28 = false; if ((gMenuDelayTimer >= 0x2E) && (btnAndStick & (A_BUTTON | START_BUTTON))) { func_8009E1C0(); func_800CA330(0x19); @@ -1035,7 +1035,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) { if (gEnableDebugMode) { gEnableDebugMode = DEBUG_MODE; } else { - gEnableDebugMode = TRUE; + gEnableDebugMode = true; } } if (btnAndStick & D_JPAD) { @@ -1398,15 +1398,15 @@ void main_menu_act(struct Controller *controller, u16 arg1) { } // L800B3068 if (btnAndStick & D_JPAD) { - sp24 = FALSE; + sp24 = false; if (func_800B555C()) { if (sp28 < D_800F2B60[gPlayerCount + 4][D_800E86AC[gPlayerCount - 1] + 1]) { - sp24 = TRUE; + sp24 = true; } } else { // L800B30D4 if (sp28 < D_800F2B60[gPlayerCount][D_800E86AC[gPlayerCount - 1] + 1]) { - sp24 = TRUE; + sp24 = true; } } // L800B3110 @@ -1500,10 +1500,10 @@ bool is_character_spot_free(s32 gridId) { s32 i; for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { if (gridId == gCharacterGridSelections[i]) { - return FALSE; + return false; } } - return TRUE; + return true; } #ifdef NON_MATCHING @@ -1533,7 +1533,7 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { // L800B3630 if (btnAndStick & B_BUTTON) { if (D_8018EDE8[arg1]) { - D_8018EDE8[arg1] = FALSE; + D_8018EDE8[arg1] = false; play_sound2(SOUND_MENU_GO_BACK); } else { func_8009E208(); @@ -1542,17 +1542,17 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { } // L800B3684 if ((btnAndStick & A_BUTTON) && !D_8018EDE8[arg1]) { - D_8018EDE8[arg1] = TRUE; + D_8018EDE8[arg1] = true; func_800C90F4( arg1, (((uintptr_t)D_800F2BAC[gCharacterGridSelections[arg1] - 1]) << 4) + 0x2900800EU ); } // L800B36F4 - selected = FALSE; + selected = false; for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) { if (gCharacterGridSelections[i] && D_8018EDE8[i]) { - selected = TRUE; + selected = true; break; } } @@ -1658,7 +1658,7 @@ void player_select_menu_act(struct Controller *controller, u16 arg1) { // L800B3AA4 if (btnAndStick & B_BUTTON) { D_8018EDEE = 1; - D_8018EDE8[arg1] = FALSE; + D_8018EDE8[arg1] = false; play_sound2(SOUND_MENU_GO_BACK); } else if (btnAndStick & A_BUTTON) { func_8009E1C0(); @@ -1906,7 +1906,7 @@ void func_800B3F74(s32 menuSelection) { } else { gCharacterGridSelections[i] = 0; } - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; gCharacterSelections[i] = i; } play_sound2(SOUND_MENU_SELECT_PLAYER); @@ -1917,7 +1917,7 @@ void func_800B3F74(s32 menuSelection) { gGamestateNext = 0; func_800C8EAC(2); for (i = 0; i < ARRAY_COUNT(D_8018EDE8); i++) { - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; } } break; @@ -1927,9 +1927,9 @@ void func_800B3F74(s32 menuSelection) { D_8018EDEE = 3; for (i = 0; i < ARRAY_COUNT(D_8018EDE8); i++) { if (gPlayerCount > i) { - D_8018EDE8[i] = TRUE; + D_8018EDE8[i] = true; } else { - D_8018EDE8[i] = FALSE; + D_8018EDE8[i] = false; } } break; @@ -1990,9 +1990,9 @@ void func_800B44BC(void) { bool func_800B4520(void) { if ((D_8018E7B0 == 2) || (D_8018E7B0 == 3) || (D_8018E7B0 == 4) || (D_8018E7B0 == 7)) { - return TRUE; + return true; } - return FALSE; + return false; } UNUSED void func_800B4560(s32 arg0, s32 arg1) { diff --git a/src/menus.h b/src/menus.h index 487697564..7d5101d03 100644 --- a/src/menus.h +++ b/src/menus.h @@ -1,7 +1,6 @@ #ifndef MENUS_H #define MENUS_H -#include "PR/os.h" #include "common_structs.h" #include <defines.h> diff --git a/src/os/_Printf.c b/src/os/_Printf.c index 0442e5fcc..cd57ceb60 100644 --- a/src/os/_Printf.c +++ b/src/os/_Printf.c @@ -47,7 +47,7 @@ s32 _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char u8 sp4c[0x20]; // probably a buffer? s32 sp48, sp44, sp40, sp3c, sp38, sp34, sp30, sp2c, sp28, sp24; sp78.size = 0; - while (TRUE) { + while (true) { fmt_ptr = (u8 *) fmt; #ifdef VERSION_SH // new version: don't point fmt_ptr beyond NUL character diff --git a/src/os/__osDevMgrMain.c b/src/os/__osDevMgrMain.c index 62f2c6ffd..10e074d29 100644 --- a/src/os/__osDevMgrMain.c +++ b/src/os/__osDevMgrMain.c @@ -22,7 +22,7 @@ void __osDevMgrMain(void *args) { mb = NULL; ret = 0; sp34 = (OSMgrArgs *) args; - while (TRUE) { + while (true) { osRecvMesg(sp34->cmdQueue, (OSMesg) &mb, OS_MESG_BLOCK); if (mb->piHandle != NULL && mb->piHandle->type == 2 && (mb->piHandle->transferInfo.cmdType == 0 @@ -41,7 +41,7 @@ void __osDevMgrMain(void *args) { osRecvMesg(sp34->accessQueue, &dummy, OS_MESG_BLOCK); __osResetGlobalIntMask(0x00100401); // remove magic constant! __osEPiRawWriteIo(mb->piHandle, 0x05000510, (sp24->bmCtlShadow | 0x80000000)); - while (TRUE) { + while (true) { osRecvMesg(sp34->eventQueue, &em, OS_MESG_BLOCK); sp30 = osSendMesg(mb->hdr.retQueue, mb, OS_MESG_NOBLOCK); if (sp2c != 1 || mb->piHandle->transferInfo.errStatus != 0) { diff --git a/src/os/__osLeoInterrupt.c b/src/os/__osLeoInterrupt.c index e77c5af6d..99b4e532a 100644 --- a/src/os/__osLeoInterrupt.c +++ b/src/os/__osLeoInterrupt.c @@ -1,4 +1,4 @@ -#include "ultra64.h" +#include <libultraship.h> #include "osint.h" #include "piint.h" #include "libultra_internal.h" diff --git a/src/os/contpfs.c b/src/os/contpfs.c index 1ff0fc7f9..b6d191e2b 100644 --- a/src/os/contpfs.c +++ b/src/os/contpfs.c @@ -57,7 +57,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) pfs->activebank = j; ERRCK(__osPfsSelectBank(pfs)) //! @todo fix magic number - ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&temp)); + ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&temp)); temp[0] = j | 0x80; for (i = 1; i < ARRLEN(temp); i++) { @@ -65,7 +65,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) temp[i] = ~temp[i]; } - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, (u8*)temp, FALSE)); //oddr 0, don't force + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, 0, (u8*)temp, false)); //oddr 0, don't force ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)&comp)); for (i = 0; i < ARRLEN(temp); i++) @@ -82,7 +82,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) ERRCK(__osContRamRead(pfs->queue, pfs->channel, 0, (u8*)temp)); if (temp[0] != 128) //! @todo remove magic constant - break; + break; } j++; } @@ -102,7 +102,7 @@ s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid) index[3] = 6; for (i = 0; i < ARRLEN(index); i++) { - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, TRUE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[i], (u8*)newid, true)); } ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); for (i = 0; i < ARRLEN(temp); i++) @@ -142,7 +142,7 @@ s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp) { if (j != i) { - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, TRUE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, index[j], (u8*)temp, true)); } } return 0; @@ -176,7 +176,7 @@ s32 __osGetId(OSPfs *pfs) } } //! @todo remove magic constant - if ((id->deviceid & 1) == 0) + if ((id->deviceid & 1) == 0) { ERRCK(__osRepairPackId(pfs, id, &newid)); id = &newid; @@ -190,7 +190,7 @@ s32 __osGetId(OSPfs *pfs) pfs->version = id->version; pfs->banks = id->banks; //! @todo loads of magic constants.. - pfs->inode_start_page = pfs->banks * 2 + 3; + pfs->inode_start_page = pfs->banks * 2 + 3; pfs->dir_size = 16; pfs->inode_table = 8; pfs->minode_table = pfs->banks * PFS_ONE_PAGE + 8; @@ -247,11 +247,11 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < 8; j++) { //! @todo don't like this =/ //maybe &inode->inode_table[j*PFS_ONE_PAGE].ipage or something - addr = ((u8 *)inode->inode_page + j * 32); + addr = ((u8 *)inode->inode_page + j * 32); if (flag == PFS_WRITE) { - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr, FALSE); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * 8 + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * 8 + j, addr, false); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * 8 + j, addr, false); } else { @@ -275,7 +275,7 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < PFS_ONE_PAGE; j++) { addr = ((u8 *)inode->inode_page + j * 32); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->inode_table + bank * PFS_ONE_PAGE + j, addr, false); } } else @@ -283,7 +283,7 @@ s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank) for (j = 0; j < PFS_ONE_PAGE; j++) { addr = ((u8 *)inode->inode_page + j * 32); - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->minode_table + bank * PFS_ONE_PAGE + j, addr, false); } } } @@ -300,6 +300,6 @@ s32 __osPfsSelectBank(OSPfs *pfs) { temp[i] = pfs->activebank; } - ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, (u8*)temp, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, 1024, (u8*)temp, false); return ret; } diff --git a/src/os/controller.h b/src/os/controller.h index 541fafdc6..92af3d4bd 100644 --- a/src/os/controller.h +++ b/src/os/controller.h @@ -1,7 +1,7 @@ #ifndef _CONTROLLER_H #define _CONTROLLER_H #include "PR/os_internal.h" -#include "PR/os.h" +#include <libultraship.h> #include "PR/rcp.h" //should go somewhere else but diff --git a/src/os/guLookAtRef.c b/src/os/guLookAtRef.c index 4e65a49a3..1b5174760 100644 --- a/src/os/guLookAtRef.c +++ b/src/os/guLookAtRef.c @@ -19,7 +19,7 @@ **************************************************************************/ /* Minor modifications */ -#include <ultra64.h> +#include <libultraship.h> #define FTOFRAC8(x) ((int) MIN(((x) * (128.0)), 127.0) & 0xff) void guLookAtReflectF(float mf[4][4], LookAt *l, float xEye, float yEye, float zEye, float xAt, diff --git a/src/os/guMtxCatF.c b/src/os/guMtxCatF.c index 94e0d10f3..96c01c2b6 100755 --- a/src/os/guMtxCatF.c +++ b/src/os/guMtxCatF.c @@ -30,7 +30,7 @@ * */ -#include <PR/gu.h> +#include <libultraship.h> void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4]) { @@ -60,4 +60,3 @@ void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1]; *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2]; } - diff --git a/src/os/guMtxCatL.c b/src/os/guMtxCatL.c index 82fd4c597..f7b22d482 100755 --- a/src/os/guMtxCatL.c +++ b/src/os/guMtxCatL.c @@ -30,8 +30,7 @@ * */ -#include "libultra_internal.h" -#include <PR/gu.h> +#include <libultraship.h> void guMtxXFMF(Mtx *, float, float, float, float *, float *, float *); void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4]); diff --git a/src/os/libaudio_internal.h b/src/os/libaudio_internal.h index ea63322c1..74868ac4e 100644 --- a/src/os/libaudio_internal.h +++ b/src/os/libaudio_internal.h @@ -1,6 +1,6 @@ #ifndef _LIBAUDIO_INTERNAL_H_ #define _LIBAUDIO_INTERNAL_H_ -#include <ultra64.h> +#include <libultraship.h> #define AL_BANK_VERSION 0x4231 /* 'B1' */ typedef u8 ALPan; diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h index 5a6027f75..dafdbd8a9 100644 --- a/src/os/libultra_internal.h +++ b/src/os/libultra_internal.h @@ -1,6 +1,6 @@ #ifndef _LIBULTRA_INTERNAL_H_ #define _LIBULTRA_INTERNAL_H_ -#include <ultra64.h> +#include <libultraship.h> #include <PR/os_thread.h> #include "macros.h" diff --git a/src/os/osCartRomInit.c b/src/os/osCartRomInit.c index b1b6599c7..389e69ea0 100644 --- a/src/os/osCartRomInit.c +++ b/src/os/osCartRomInit.c @@ -5,7 +5,7 @@ #include "PR/R4300.h" #include "PR/rcp.h" #include "PR/os_pi.h" -#include "PR/os.h" +#include <libultraship.h> OSPiHandle CartRomHandle; diff --git a/src/os/osCreatePiManager.c b/src/os/osCreatePiManager.c index 68c491eb6..c65201934 100644 --- a/src/os/osCreatePiManager.c +++ b/src/os/osCreatePiManager.c @@ -3,7 +3,7 @@ #define OS_PI_MGR_MESG_BUFF_SIZE 1 //! @todo In libreultra this is in an include -#ifdef VERSION_SH +#ifdef VERSION_SH extern OSPiHandle *CartRomHandle; extern OSPiHandle *LeoDiskHandle; #endif @@ -39,7 +39,7 @@ void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgC osSetThreadPri(NULL, pri); } int_disabled = __osDisableInt(); - __osPiDevMgr.initialized = TRUE; + __osPiDevMgr.initialized = true; __osPiDevMgr.mgrThread = &piMgrThread; __osPiDevMgr.cmdQueue = cmdQ; __osPiDevMgr.eventQueue = &__osPiMesgQueue; diff --git a/src/os/osCreateViManager.c b/src/os/osCreateViManager.c index a90b3eab5..950f43d81 100644 --- a/src/os/osCreateViManager.c +++ b/src/os/osCreateViManager.c @@ -41,7 +41,7 @@ void osCreateViManager(OSPri pri) { osSetThreadPri(NULL, pri); } int_disabled = __osDisableInt(); - viMgrMainArgs.initialized = TRUE; + viMgrMainArgs.initialized = true; viMgrMainArgs.mgrThread = &viMgrThread; viMgrMainArgs.cmdQueue = &__osViMesgQueue; viMgrMainArgs.eventQueue = &__osViMesgQueue; @@ -67,7 +67,7 @@ void viMgrMain(void *vargs) { u32 sp28; // always 0 u32 sp24; // time related mesg = NULL; - sp28 = FALSE; + sp28 = false; context = __osViGetCurrentContext(); if ((retrace = context->retraceCount) == 0) { @@ -76,7 +76,7 @@ void viMgrMain(void *vargs) { args = (OSMgrArgs *) vargs; - while (TRUE) { + while (true) { osRecvMesg(args->eventQueue, &mesg, OS_MESG_BLOCK); switch (*(u16 *) mesg) { case 13: diff --git a/src/os/osInitialize.c b/src/os/osInitialize.c index 921c969ae..292cbbc1c 100644 --- a/src/os/osInitialize.c +++ b/src/os/osInitialize.c @@ -33,7 +33,7 @@ void osInitialize(void) { UNUSED u32 eu_sp34; UNUSED u32 eu_sp30; UNUSED u32 sp2c; - D_80194040 = TRUE; + D_80194040 = true; __osSetSR(__osGetSR() | 0x20000000); __osSetFpcCsr(0x01000800); while (__osSiRawReadIo(PIF_ADDR_START, &sp34)) { diff --git a/src/os/osPfsAllocateFile.c b/src/os/osPfsAllocateFile.c index 655c57cd0..b2614955e 100644 --- a/src/os/osPfsAllocateFile.c +++ b/src/os/osPfsAllocateFile.c @@ -29,7 +29,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name return PFS_ERR_INVALID; file_size_in_pages = (file_size_in_bytes + 255) / (BLOCKSIZE * PFS_ONE_PAGE); - if ((pfs->status & PFS_INITIALIZED) == FALSE) + if ((pfs->status & PFS_INITIALIZED) == false) return PFS_ERR_INVALID; PFS_CHECK_ID; @@ -99,7 +99,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name dir.game_name[j] = *game_name++; for (j = 0; j < ARRLEN(dir.ext_name); j++) dir.ext_name[j] = *ext_name++; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, *file_no + pfs->dir_table, (u8*)&dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, *file_no + pfs->dir_table, (u8*)&dir, false)); return ret; } return PFS_ERR_INVALID; @@ -171,7 +171,7 @@ static s32 __osClearPage(OSPfs *pfs, int page_no, u8 *data, u8 bank) ERRCK(__osPfsSelectBank(pfs)); for (i = 0; i < PFS_ONE_PAGE; i++) { - ret = __osContRamWrite(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, page_no * PFS_ONE_PAGE + i, data, false); if (ret != 0) break; } diff --git a/src/os/osPfsChecker.c b/src/os/osPfsChecker.c index 18457216e..78bd44bb9 100644 --- a/src/os/osPfsChecker.c +++ b/src/os/osPfsChecker.c @@ -59,7 +59,7 @@ s32 osPfsChecker(OSPfs *pfs) tmp_dir.status = DIR_STATUS_EMPTY; tmp_dir.data_sum = 0; SET_ACTIVEBANK_TO_ZERO; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, false)); fixed++; } else @@ -73,7 +73,7 @@ s32 osPfsChecker(OSPfs *pfs) tmp_dir.data_sum = 0; SET_ACTIVEBANK_TO_ZERO; - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&tmp_dir, false)); fixed++; } } diff --git a/src/os/osPfsDeleteFile.c b/src/os/osPfsDeleteFile.c index 7ea124f8b..c7ec885b4 100644 --- a/src/os/osPfsDeleteFile.c +++ b/src/os/osPfsDeleteFile.c @@ -32,7 +32,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, { ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank)); //! @todo magic constant - ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); + ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, 1)); ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank)); if (last_page.ipage == 1) break; @@ -56,7 +56,7 @@ s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, dir.ext_name[k] = 0; } dir.status = DIR_STATUS_EMPTY; - ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, false); return ret; } @@ -86,7 +86,7 @@ s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u16 *sum, u return PFS_ERR_INCONSISTENT; *last_page = next_page; //! @todo magic number - if (flag == 1) + if (flag == 1) inode->inode_page[start_page].ipage = 3; ERRCK(__osBlockSum(pfs, start_page, sum, bank)); diff --git a/src/os/osPfsIsPlug.c b/src/os/osPfsIsPlug.c index 11580732b..4df1bf328 100644 --- a/src/os/osPfsIsPlug.c +++ b/src/os/osPfsIsPlug.c @@ -17,7 +17,7 @@ s32 osPfsIsPlug(OSMesgQueue *queue, u8 *pattern) { bits = 0; crc_error_cnt = 3; __osSiGetAccess(); - while (TRUE) { + while (true) { __osPfsRequestData(CONT_CMD_REQUEST_STATUS); ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam); osRecvMesg(queue, &dummy, OS_MESG_BLOCK); diff --git a/src/os/osPfsNumFiles.c b/src/os/osPfsNumFiles.c index 09d0eba6f..1bcebaca2 100755 --- a/src/os/osPfsNumFiles.c +++ b/src/os/osPfsNumFiles.c @@ -1,5 +1,5 @@ #include "libultra_internal.h" -#include "PR/os.h" +#include <libultraship.h> #include "controller.h" s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) diff --git a/src/os/osPfsReadWriteFile.c b/src/os/osPfsReadWriteFile.c index b972147a2..a910a681d 100644 --- a/src/os/osPfsReadWriteFile.c +++ b/src/os/osPfsReadWriteFile.c @@ -82,7 +82,7 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in if (flag == OS_READ) ret = __osContRamRead(pfs->queue, pfs->channel, blockno, buffer); else - ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, FALSE); + ret = __osContRamWrite(pfs->queue, pfs->channel, blockno, buffer, false); if (ret != 0) return ret; buffer += BLOCKSIZE; @@ -94,7 +94,7 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in dir.status |= DIR_STATUS_OCCUPIED; pfs->activebank = 0; ERRCK(__osPfsSelectBank(pfs)); - ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, FALSE)); + ERRCK(__osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + file_no, (u8*)&dir, false)); } return 0; diff --git a/src/os/osPfsSearchFile.c b/src/os/osPfsSearchFile.c index efd994698..b78171294 100755 --- a/src/os/osPfsSearchFile.c +++ b/src/os/osPfsSearchFile.c @@ -15,14 +15,14 @@ s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir)); if ((dir.company_code == company_code) && dir.game_code == game_code) { - fail = FALSE; + fail = false; if (game_name != NULL) { for (i = 0; i < ARRLEN(dir.game_name); i++) { if (dir.game_name[i] != game_name[i]) { - fail = TRUE; + fail = true; break; } } @@ -34,7 +34,7 @@ s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 { if (dir.ext_name[i] != ext_name[i]) { - fail = TRUE; + fail = true; break; } } diff --git a/src/os/osTimer.c b/src/os/osTimer.c index b14139a94..21d6ee19a 100644 --- a/src/os/osTimer.c +++ b/src/os/osTimer.c @@ -26,7 +26,7 @@ void __osTimerInterrupt(void) { if (__osTimerList->next == __osTimerList) { return; } - while (TRUE) { + while (true) { sp24 = __osTimerList->next; if (sp24 == __osTimerList) { __osSetCompare(0); diff --git a/src/os/piint.h b/src/os/piint.h index 39278eed9..8b2a479a2 100644 --- a/src/os/piint.h +++ b/src/os/piint.h @@ -3,7 +3,7 @@ #include "PR/os_internal.h" #include "PR/rcp.h" #include "PR/os_pi.h" -#include "PR/os.h" +#include <libultraship.h> //https://github.com/LuigiBlood/64dd/wiki/Memory-Map @@ -84,11 +84,11 @@ #define LEO_BM_CTL_SECTOR_SHIFT 16 //! @todo name -#define LEO_CMD_TYPE_0 0 +#define LEO_CMD_TYPE_0 0 //! @todo name -#define LEO_CMD_TYPE_1 1 +#define LEO_CMD_TYPE_1 1 //! @todo name -#define LEO_CMD_TYPE_2 2 +#define LEO_CMD_TYPE_2 2 #define LEO_ERROR_GOOD 0 #define LEO_ERROR_3 3 diff --git a/src/player_controller.c b/src/player_controller.c index 08b852f68..5b8c9332f 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <mk64.h> @@ -620,7 +620,7 @@ void func_80027EDC(Player *player, s8 playerId) { void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { u16 sp1E; - + if (!(player->type & PLAYER_START_SEQUENCE)) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: @@ -633,32 +633,32 @@ void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); break; case SCREEN_MODE_3P_4P_SPLITSCREEN: - sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + if (sp1E == 1) break; + sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); + if (sp1E == 1) break; + sp1E = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); if (sp1E == 1) break; - sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); - if (sp1E == 1) break; - sp1E = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); - if (sp1E == 1) break; sp1E = check_player_camera_collision(player, camera4, (f32) D_8016557C, 0.0f); - break; + break; } - if ((sp1E == 1) || - ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || - (gModeSelection == BATTLE) || - ((player->unk_0CA & 2) != 0) || - (player->unk_0CA & 8) || + if ((sp1E == 1) || + ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || + (gModeSelection == BATTLE) || + ((player->unk_0CA & 2) != 0) || + (player->unk_0CA & 8) || //! @todo make a proper match ((*(D_801633F8 + (arg2))) == ((s16) 1U))) { player->effects &= ~0x1000; - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x01000000) == 0x01000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x01000000) == 0x01000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || (player->unk_044 & 0x800)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -680,18 +680,18 @@ void func_80028864(Player *player, Camera *camera, s8 arg2, s8 arg3) { } } -void func_80028C44(Player *player, Camera *camera, s8 arg2, s8 arg3) { +void func_80028C44(Player *player, Camera *camera, s8 arg2, s8 arg3) { if ((player->type & PLAYER_START_SEQUENCE) == 0) { player->effects &= ~0x1000; - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -709,16 +709,16 @@ void func_80028D3C(Player *player, Camera *camera, s8 arg2, s8 arg3) { || (player->unk_0CA & 8) != 0 || (player->effects & 0x4F010CC0) != 0) { player->effects &= ~0x1000; - - if (((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x4000) == 0x4000) || - ((player->effects & 0x80000) == 0x80000) || - ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || - ((player->effects & 0x20000) == 0x20000) || + + if (((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40) || + ((player->effects & 0x400) == 0x400) || + ((player->effects & 0x4000) == 0x4000) || + ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || + ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, arg3, arg2); } else { @@ -737,9 +737,9 @@ void func_80028E70(Player *player, Camera *camera, s8 arg2, s8 arg3) { func_80038C6C(player, camera, arg3, arg2); } else { player->effects &= ~8; - } + } break; - default: + default: func_80027DA8(player, arg2); switch (gModeSelection) { case TIME_TRIALS: @@ -752,7 +752,7 @@ void func_80028E70(Player *player, Camera *camera, s8 arg2, s8 arg3) { default: func_80028864(player, camera, arg2, arg3); break; - } + } break; } } @@ -915,7 +915,7 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->unk_044 & 0x800)) { player->unk_050[arg2] = 0; } - if (((player->effects & 8) == 8) + if (((player->effects & 8) == 8) && ((player->unk_0CA & 2) == 2)) { player->unk_050[arg2] = 0; } @@ -951,7 +951,7 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->effects & 0x800000) || (player->effects & 0x20000) || (player->unk_044 & 0x800)) { - + if ((player->animFrameSelector[arg2]) >= 0x14) { player->animFrameSelector[arg2] = 0; } @@ -971,10 +971,10 @@ void func_8002934C(Player *player, Camera *camera, s8 arg2, s8 playerId) { || (player->effects & 0x10000) || (player->effects & 0x80) || (player->effects & 0x40)) { - + player->unk_002 |= 1 << (arg2 * 4); D_80165190[arg2][playerId] = 1; - + if ((player->effects & 0x80) || (player->effects & 0x40)) { if ((player->animFrameSelector[arg2] == D_801650D0[arg2][playerId]) && (player->animGroupSelector[arg2] == D_80165110[arg2][playerId])) { @@ -1016,7 +1016,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { else { var_f12 = 18.0f * (gCharacterSize[player->characterId] / 2); } - + calculate_orientation_matrix(sp5C, 0.0f, 1.0f, 0.0f, (player->rotation[1] + player->unk_0C0)); sp8C[0] = var_f12 - 3.6; sp8C[1] = -player->boundingBoxSize; @@ -1029,7 +1029,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[0].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[0].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[0], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = (-var_f12) + 3.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = var_f12 - 2.0f; @@ -1041,7 +1041,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[1].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[1].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[1], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = var_f12 - 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; @@ -1053,7 +1053,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[2].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[2].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[2], sp80[0], sp80[1], sp80[2]); - + sp8C[0] = (-var_f12) + 2.6; sp8C[1] = -player->boundingBoxSize; sp8C[2] = (-var_f12) + 4.0f; @@ -1065,7 +1065,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) { player->boundingBoxCorners[3].cornerPos[1] = player->pos[1] + sp8C[1]; player->boundingBoxCorners[3].cornerPos[2] = player->pos[2] + sp8C[2]; process_collision(player, &player->boundingBoxCorners[3], sp80[0], sp80[1], sp80[2]); - + if (!(player->effects & 8)) { a = (player->boundingBoxCorners[2].cornerGroundY + player->boundingBoxCorners[0].cornerGroundY) / 2; move_f32_towards(&player->unk_230, a, 0.5f); @@ -1712,59 +1712,59 @@ void func_8002BB9C(Player *player, f32 *arg1, f32 *arg2, UNUSED s8 arg3, UNUSED s16 t0; UNUSED s32 pad; s16 sp30[10] = {0x0000, 0x00b6, 0x016c, 0x0222, 0x02d8, 0x038e, 0x0444, 0x04fa, 0x05b0, 0x0666}; - + if (((u16) player->unk_256) <= 0) { - return; + return; } if (((u16) player->unk_256) > 2) { return; } - + if (!(player->unk_046 & 0x20)) { - return; + return; } - + calculate_orientation_matrix(sp64, 0, 1, 0, (s16) 0); - + sp58[0] = *arg1; sp58[1] = 0; sp58[2] = *arg2; - + mtxf_translate_vec3f_mat3(sp58, sp64); - + sp4C[0] = player->copy_rotation_x; sp4C[1] = 0; sp4C[2] = player->copy_rotation_z; - + mtxf_translate_vec3f_mat3(sp4C, sp64); var_v0 = -(s16)get_angle_between_two_vectors(sp58, sp4C); t0 = player->rotation[1]; var_v0 = 0x10000 + (t0 - var_v0); var_v0 /= 182; - + if (var_v0 < 0x97 && (var_v0 > -0x97)) { return; } - + var_v0 = (player->unk_07C >> 0x10) / 6; - + if (var_v0 < 0) { var_v0 *= -1; } - + if (var_v0 >= 8) { var_v0 = 8; } - + if ((player->unk_07C >> 0x10) < 0) { player->rotation[1] -= sp30[var_v0]; } else { player->rotation[1] += sp30[var_v0]; } } - + void func_8002BD58(Player *player) { s32 sp2C[7] = { 0x002f0000, 0x00300000, 0x00310000, 0x00320000, 0x00320000, 0x00320000, 0x00320000 }; s32 spC[8] = { 0x00280000, 0x002c0000, 0x00300000, 0x00320000, 0x00320000, 0x00320000, 0x00320000, 0x00320000 }; @@ -1794,16 +1794,16 @@ void func_8002BD58(Player *player) { } } -void func_8002BF4C(Player *player, s8 arg1) { +void func_8002BF4C(Player *player, s8 arg1) { UNUSED s32 pad[3]; UNUSED s32 uselessAssignment; s32 i; s32 var_a2; Player *playerBorrow; Player *players = gPlayerOne; - + var_a2 = 0; - + if (((player->unk_094 / 18.0f) * 216.0f) < 50.0f) { player->unk_0E2 = 0; player->effects &= 0xFFDFFFFF; @@ -1817,9 +1817,9 @@ void func_8002BF4C(Player *player, s8 arg1) { } else { for (i = 0; i < NUM_PLAYERS; i++) { playerBorrow = &players[i]; - if (((player != playerBorrow) && - ((playerBorrow->type & 0x100) == 0) && - (playerBorrow->type & 0x8000)) && + if (((player != playerBorrow) && + ((playerBorrow->type & 0x100) == 0) && + (playerBorrow->type & 0x8000)) && ((var_a2 = func_8001FD78(player, playerBorrow->pos[0], playerBorrow->pos[1], playerBorrow->pos[2]), var_a2 == 1))) { player->unk_0E2 += 1; if (player->unk_0E2 >= 0x3D) { @@ -1836,7 +1836,7 @@ void func_8002BF4C(Player *player, s8 arg1) { break; } } - + if (var_a2 == 0) { player->unk_0E2 = 0; } @@ -1970,7 +1970,7 @@ void func_8002C4F8(Player *player, s8 arg1) { func_8002C17C(player, arg1); } -void func_8002C7E4(Player *player, s8 arg1, s8 arg2) { +void func_8002C7E4(Player *player, s8 arg1, s8 arg2) { if ((player->unk_046 & 1) != 1) { if ((player->effects & 0x8000) == 0x8000) { if ((player->effects & BOOST_EFFECT) != BOOST_EFFECT) { @@ -2017,15 +2017,15 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { f32 zdist; temp_f0 = player->pos[1] - player->unk_074; - if (((((player->effects & 0x10000) != 0x10000) && - ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) || - ((((temp_f0 >= 20.0f) || - (temp_f0 < (-1.0f))) && - ((player->effects & 0x10000) == 0)) && - (player->effects & 8)) || - ((player->unk_110.unk34 == 0) && - ((player->effects & 0x10000) == 0))) && - (((player->unk_0CA & 2) == 0) || + if (((((player->effects & 0x10000) != 0x10000) && + ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) || + ((((temp_f0 >= 20.0f) || + (temp_f0 < (-1.0f))) && + ((player->effects & 0x10000) == 0)) && + (player->effects & 8)) || + ((player->unk_110.unk34 == 0) && + ((player->effects & 0x10000) == 0))) && + (((player->unk_0CA & 2) == 0) || (!(player->unk_0CA & 8)))) { func_8008F494(player, playerId); } @@ -2051,17 +2051,17 @@ void func_8002C954(Player *player, s8 playerId, Vec3f arg2) { var_f14 = D_80165070[playerId][1] - arg2[1]; ydist = var_f14; // okay zdist = D_80165070[playerId][2] - arg2[2]; - var_f14 = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist)) / 3; + var_f14 = sqrtf((xdist * xdist) + (ydist * ydist) + (zdist * zdist)) / 3; if (var_f14 >= 1.0) { var_f14 = 1.0f; } - if ((var_f14 <= 0.6) && - (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && + if ((var_f14 <= 0.6) && + (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && (!(player->type & PLAYER_INVISIBLE_OR_BOMB))) { func_800CAEC4(playerId, 0.6F); } else if (!(player->type & PLAYER_INVISIBLE_OR_BOMB)) { - if ((var_f14 <= 0.6) && - (((player->unk_094 / 18.0f) * 216.0f) < 40.0f) && + if ((var_f14 <= 0.6) && + (((player->unk_094 / 18.0f) * 216.0f) < 40.0f) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { func_800CAEC4(playerId, 0.3F); } else { @@ -2166,7 +2166,7 @@ void func_8002D028(Player *player, s8 arg1) { thing0 = 8; - + if (temp > ((s16) (thing0 * 182))) { temp = (thing0 * 182); } @@ -2324,7 +2324,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) posX = player->pos[0]; posY = player->pos[1]; posZ = player->pos[2]; - + player->copy_rotation_x = player->pos[0]; player->copy_rotation_z = player->pos[2]; player->copy_rotation_y = player->pos[1]; @@ -2362,10 +2362,10 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) player->unk_DB4.unkC = 3.0f; player->unk_DB4.unk18 = 0; player->unk_0B6 |= 0x100; - if ((((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) - && ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) - && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) - + if ((((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) + && ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) + && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) + func_800C9060(playerId, 0x1900A60AU); else if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { @@ -2379,7 +2379,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) if (((player->unk_0C2 < 0x23) && (player->unk_0C2 >= 0x1C)) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { player->unk_DB4.unkC = 2.8f; player->unk_DB4.unk18 = 0; - if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800CADD0((u8) playerId, ((f32) player->unk_0C2) / 35.0f); } @@ -2449,7 +2449,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) player->unk_22C = player->unk_094; player->unk_094 = sqrtf(temp2); - if ((player->unk_08C <= 0.0f) + if ((player->unk_08C <= 0.0f) && (player->unk_094 <= 0.08) && (D_8018CE10[playerId].unk_04[0] == 0.0f) && (D_8018CE10[playerId].unk_04[2] == 0.0f)) { @@ -2583,7 +2583,7 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) } else { sp54[0] += ((((f64) (spEC[0] + sp80 + spD4[0]) - (sp54[0] * (0.2 * (f64) player->kartFriction))) / 6000) * 0.08); sp54[2] += ((((f64) (spEC[2] + sp78 + spD4[2]) - (sp54[2] * (0.2 * (f64) player->kartFriction))) / 6000) * 0.08); - + } sp54[1] += ((( ((spEC[1] + sp7C) + spD4[1])) - (sp54[1] * (0.12 * player->kartFriction))) / 6000) / player->unk_DAC; @@ -2595,11 +2595,11 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) posX = player->pos[0]; posY = player->pos[1]; posZ = player->pos[2]; - + player->copy_rotation_x = player->pos[0]; player->copy_rotation_y = player->pos[1]; player->copy_rotation_z = player->pos[2]; - + spD0 = posX + player->velocity[0] + D_8018CE10[playerId].unk_04[0]; spCC = posY + player->velocity[1]; spC8 = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2]; @@ -2917,7 +2917,7 @@ void func_8002F730(Player *player, UNUSED Camera *camera, UNUSED s8 arg2, s8 arg player->velocity[0] = sp68[0]; player->velocity[1] = sp68[1]; player->velocity[2] = sp68[2]; - + D_80165070[arg3][0] = sp68[0]; D_80165070[arg3][1] = sp68[1]; D_80165070[arg3][2] = sp68[2]; @@ -2987,7 +2987,7 @@ void func_8002FE84(Player *player, f32 arg1) { player->unk_098 = ((player->currentSpeed * player->currentSpeed) / 25.0f) * 1.1; return; } - + // Huh? if (((player->effects & 0xFFFFFFFF) & 8) == 8) { player->unk_098 = ((player->currentSpeed * player->currentSpeed) / 25.0f) * 1.1; @@ -3039,14 +3039,14 @@ f32 func_80030150(Player *player, s8 arg1) { } else { var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[3].surfaceType]; } - - if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[2].surfaceType < 0xF) var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[2].surfaceType]; - - if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[1].surfaceType < 0xF) var_f0 += D_800E2EB0[player->characterId][player->boundingBoxCorners[1].surfaceType]; - - if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) + + if ((s32) player->boundingBoxCorners[0].surfaceType < 0xF) var_f0 += D_800E2E90[player->characterId][player->boundingBoxCorners[0].surfaceType]; } if (((player->effects & 8) != 8) && ((player->unk_0CA & 2) != 2)) { @@ -3229,15 +3229,15 @@ void detect_triple_a_combo_a_released(Player *player) { if (player == gPlayerEight) { playerIndex = 7; } - if (gIsPlayerTripleAButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsThrottleActive[playerIndex] == TRUE) { + if (gIsPlayerTripleAButtonCombo[playerIndex] == false) { + if (gPlayerIsThrottleActive[playerIndex] == true) { if ((gFrameSinceLastACombo[playerIndex] < 2) || (gFrameSinceLastACombo[playerIndex] >= 9)) { gCountASwitch[playerIndex] = 0; } gFrameSinceLastACombo[playerIndex] = 0; D_80165400[playerIndex] = 0; } - gPlayerIsThrottleActive[playerIndex] = FALSE; + gPlayerIsThrottleActive[playerIndex] = false; gFrameSinceLastACombo[playerIndex]++; if (gFrameSinceLastACombo[playerIndex] >= 9) { gFrameSinceLastACombo[playerIndex] = 9; @@ -3249,7 +3249,7 @@ void detect_triple_a_combo_a_released(Player *player) { D_80165400[playerIndex] = 1; } if (gCountASwitch[playerIndex] == 5) { - gIsPlayerTripleAButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleAButtonCombo[playerIndex] = true; gTimerBoostTripleACombo[playerIndex] = 120; gCountASwitch[playerIndex] = 0; gFrameSinceLastACombo[playerIndex] = 0; @@ -3257,7 +3257,7 @@ void detect_triple_a_combo_a_released(Player *player) { } else { gTimerBoostTripleACombo[playerIndex]--; if (gTimerBoostTripleACombo[playerIndex] <= 0) { - gIsPlayerTripleAButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleAButtonCombo[playerIndex] = false; } } } @@ -3289,15 +3289,15 @@ void detect_triple_a_combo_a_pressed(Player *player) { if (player == gPlayerEight) { playerIndex = 7; } - if (gIsPlayerTripleAButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsThrottleActive[playerIndex] == FALSE) { + if (gIsPlayerTripleAButtonCombo[playerIndex] == false) { + if (gPlayerIsThrottleActive[playerIndex] == false) { if ((gFrameSinceLastACombo[playerIndex] < 2) || (gFrameSinceLastACombo[playerIndex] >= 9)) { gCountASwitch[playerIndex] = 0; } gFrameSinceLastACombo[playerIndex] = 0; D_80165400[playerIndex] = 0; } - gPlayerIsThrottleActive[playerIndex] = TRUE; + gPlayerIsThrottleActive[playerIndex] = true; gFrameSinceLastACombo[playerIndex]++; if (gFrameSinceLastACombo[playerIndex] >= 9) { gFrameSinceLastACombo[playerIndex] = 9; @@ -3309,7 +3309,7 @@ void detect_triple_a_combo_a_pressed(Player *player) { D_80165400[playerIndex] = 1; } if (gCountASwitch[playerIndex] == 5) { - gIsPlayerTripleAButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleAButtonCombo[playerIndex] = true; gTimerBoostTripleACombo[playerIndex] = 120; gCountASwitch[playerIndex] = 0; gFrameSinceLastACombo[playerIndex] = 0; @@ -3317,7 +3317,7 @@ void detect_triple_a_combo_a_pressed(Player *player) { } else { gTimerBoostTripleACombo[playerIndex]--; if (gTimerBoostTripleACombo[playerIndex] <= 0) { - gIsPlayerTripleAButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleAButtonCombo[playerIndex] = false; } } } @@ -3326,7 +3326,7 @@ void player_speed(Player *player) { s32 player_index; player_index = get_player_index_for_player(player); - if (gIsPlayerTripleAButtonCombo[player_index] == FALSE) { + if (gIsPlayerTripleAButtonCombo[player_index] == false) { if ((0.0 <= player->currentSpeed) && (player->currentSpeed < (player->topSpeed * 0.1))) { player->currentSpeed += gKartAccelerationTables[player->characterId][0] + (0.05 * (player->slopeAccel / 182)); } @@ -3457,15 +3457,15 @@ void detect_triple_b_combo_b_released(Player *player) { playerIndex = 7; } - if (gIsPlayerTripleBButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsBrakeActive[playerIndex] == TRUE) { + if (gIsPlayerTripleBButtonCombo[playerIndex] == false) { + if (gPlayerIsBrakeActive[playerIndex] == true) { if ((gFrameSinceLastBCombo[playerIndex] < 2) || (gFrameSinceLastBCombo[playerIndex] >= 9)) { gCountBChangement[playerIndex] = 0; } gFrameSinceLastBCombo[playerIndex] = 0; D_801654C0[playerIndex] = 0; } - gPlayerIsBrakeActive[playerIndex] = FALSE; + gPlayerIsBrakeActive[playerIndex] = false; gFrameSinceLastBCombo[playerIndex]++; if (gFrameSinceLastBCombo[playerIndex] >= 9) { gFrameSinceLastBCombo[playerIndex] = 9; @@ -3477,7 +3477,7 @@ void detect_triple_b_combo_b_released(Player *player) { D_801654C0[playerIndex] = 1; } if (gCountBChangement[playerIndex] == 5) { - gIsPlayerTripleBButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleBButtonCombo[playerIndex] = true; gTimerBoostTripleBCombo[playerIndex] = 120; gCountBChangement[playerIndex] = 0; gFrameSinceLastBCombo[playerIndex] = 0; @@ -3485,7 +3485,7 @@ void detect_triple_b_combo_b_released(Player *player) { } else { gTimerBoostTripleBCombo[playerIndex]--; if (gTimerBoostTripleBCombo[playerIndex] <= 0) { - gIsPlayerTripleBButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleBButtonCombo[playerIndex] = false; } } } @@ -3518,15 +3518,15 @@ void detect_triple_b_combo_b_pressed(Player *player) { playerIndex = 7; } - if (gIsPlayerTripleBButtonCombo[playerIndex] == FALSE) { - if (gPlayerIsBrakeActive[playerIndex] == FALSE) { + if (gIsPlayerTripleBButtonCombo[playerIndex] == false) { + if (gPlayerIsBrakeActive[playerIndex] == false) { if ((gFrameSinceLastBCombo[playerIndex] < 2) || (gFrameSinceLastBCombo[playerIndex] >= 9)) { gCountBChangement[playerIndex] = 0; } gFrameSinceLastBCombo[playerIndex] = 0; D_801654C0[playerIndex] = 0; } - gPlayerIsBrakeActive[playerIndex] = TRUE; + gPlayerIsBrakeActive[playerIndex] = true; gFrameSinceLastBCombo[playerIndex]++; if (gFrameSinceLastBCombo[playerIndex] >= 9) { gFrameSinceLastBCombo[playerIndex] = 9; @@ -3538,7 +3538,7 @@ void detect_triple_b_combo_b_pressed(Player *player) { D_801654C0[playerIndex] = 1; } if (gCountBChangement[playerIndex] == 5) { - gIsPlayerTripleBButtonCombo[playerIndex] = TRUE; + gIsPlayerTripleBButtonCombo[playerIndex] = true; gTimerBoostTripleBCombo[playerIndex] = 120; gCountBChangement[playerIndex] = 0; gFrameSinceLastBCombo[playerIndex] = 0; @@ -3546,7 +3546,7 @@ void detect_triple_b_combo_b_pressed(Player *player) { } else { gTimerBoostTripleBCombo[playerIndex]--; if (gTimerBoostTripleBCombo[playerIndex] <= 0) { - gIsPlayerTripleBButtonCombo[playerIndex] = FALSE; + gIsPlayerTripleBButtonCombo[playerIndex] = false; } } } @@ -3602,7 +3602,7 @@ void func_800323E4(Player *player) { player->unk_20C = 2.0f; } } - if (gIsPlayerTripleBButtonCombo[var_v1] == TRUE) { + if (gIsPlayerTripleBButtonCombo[var_v1] == true) { if (player->unk_20C >= 2.0f) { func_80031F48(player, (1.0f - var_f2) * 5.0f); } else { @@ -3807,9 +3807,9 @@ void func_80033850(Player *arg0, f32 arg1) { void func_80033884(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { s32 temp_v1; - if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { + if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { temp_v1 = player->unk_200; - player->unk_200 -= 0x800; + player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { player->unk_200 = temp_v1; } @@ -3827,7 +3827,7 @@ void func_80033884(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 UNUSED void func_80033940(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { u32 temp_v1; - + temp_v1 = player->unk_200; player->unk_200 -= 0x800; if (!(player->unk_200 < 0xF0000000)) { @@ -3846,7 +3846,7 @@ UNUSED void func_80033940(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg void func_800339C4(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { s32 temp_v0; - + temp_v0 = player->unk_200; player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { @@ -3855,18 +3855,18 @@ void func_800339C4(Player *player, s32 *arg1, s32 arg2, s32 arg3, f32 arg4) { if (arg3 >= (s32)player->unk_200) { player->unk_200 = arg3; } - + *arg1 = (arg2 < *arg1) ? *arg1 - player->unk_200 : *arg1 + player->unk_200; - + func_80033850(player, arg4); } void func_80033A40(Player *player, s32 *arg1, s32 *arg2, s32 arg3, s32 arg4, s32 arg5, f32 arg6) { s32 temp_v1; - if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { + if ((*arg1 >= arg4) || (-arg4 >= *arg1)) { temp_v1 = player->unk_200; - player->unk_200 -= 0x800; + player->unk_200 -= 0x800; if (player->unk_200 >= 0xF0000000) { player->unk_200 = temp_v1; } @@ -4631,17 +4631,17 @@ void func_80037BB4(Player *player, Vec3f arg1) { } void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { - if (((player->effects & 0x80) != 0x80) && - ((player->effects & 0x40) != 0x40) && - ((player->effects & 0x400) != 0x400) && - ((player->effects & 0x4000) != 0x4000) && - ((player->effects & 0x01000000) != 0x01000000) && - ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && ((player->effects & 0x10000) != 0x10000) && + if (((player->effects & 0x80) != 0x80) && + ((player->effects & 0x40) != 0x40) && + ((player->effects & 0x400) != 0x400) && + ((player->effects & 0x4000) != 0x4000) && + ((player->effects & 0x01000000) != 0x01000000) && + ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && ((player->effects & 0x10000) != 0x10000) && ((player->effects & 0x20000) != 0x20000)) { - if (((player->effects & HIT_EFFECT) != HIT_EFFECT) && - ((player->effects & 8) != 8) && - ((player->effects & 2) != 2) && - ((player->effects & 0x10) != 0x10) && + if (((player->effects & HIT_EFFECT) != HIT_EFFECT) && + ((player->effects & 8) != 8) && + ((player->effects & 2) != 2) && + ((player->effects & 0x10) != 0x10) && (controller->buttonPressed & R_TRIG)) { kart_hop(player); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { @@ -4665,8 +4665,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } } } - if (((player->effects & 0x20) == 0x20) && - (((controller->button & B_BUTTON) == 0) || + if (((player->effects & 0x20) == 0x20) && + (((controller->button & B_BUTTON) == 0) || (!(controller->button & A_BUTTON)))) { player->effects &= ~0x20; } @@ -4695,8 +4695,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } } if ((!(player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && (!(player->effects & 4))) { - if (((func_800388B0(controller) < (-0x31)) && - (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f)) && + if (((func_800388B0(controller) < (-0x31)) && + (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f)) && (controller->button & B_BUTTON)) { player->currentSpeed = 140.0f; player->unk_044 |= 1; @@ -4718,9 +4718,9 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { func_80031F48(player, 5.0f); } } - if (((((player->effects & 0x80) == 0x80) || - ((player->effects & 0x40) == 0x40)) || - ((player->effects & 0x01000000) == 0x01000000)) || + if (((((player->effects & 0x80) == 0x80) || + ((player->effects & 0x40) == 0x40)) || + ((player->effects & 0x01000000) == 0x01000000)) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT)) { if (controller->button & A_BUTTON) { detect_triple_a_combo_a_pressed(player); @@ -4734,8 +4734,8 @@ void func_80037CFC(Player *player, struct Controller *controller, s8 arg2) { } void func_800381AC(Player *player, struct Controller *controller, s8 arg2) { - if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && - ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && + if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && + ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { if ((player->type & PLAYER_START_SEQUENCE) != PLAYER_START_SEQUENCE) { if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) { @@ -4802,7 +4802,7 @@ void func_800382DC(void) { } return; } - + break; } break; @@ -4964,7 +4964,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) Vec3f sp88; Vec3f sp7C; UNUSED s32 pad[10]; - + player->unk_084 = -10.0f; player->unk_088 = 28.0f; player->topSpeed = 250.0f; @@ -4985,12 +4985,12 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) spA4 += sp108[0]; sp9C += sp108[2]; sp114[2] = player->unk_08C; - mtxf_translate_vec3f_mat3(sp114, player->orientationMatrix); - + mtxf_translate_vec3f_mat3(sp114, player->orientationMatrix); + sp88[0] = player->velocity[0]; sp88[1] = player->velocity[1]; sp88[2] = player->velocity[2]; - + sp88[0] += ((((((sp114[0] + spA4) + spF0[0])) - (sp88[0] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); sp88[2] += ((((((sp114[2] + sp9C) + spF0[2])) - (sp88[2] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); sp88[1] += ((((((sp114[1] + spA0) + spF0[1])) - (sp88[1] * (0.12 * (player->kartFriction)))) / 6000.0) / 1); @@ -5068,7 +5068,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId) D_80165070[playerId][0] = sp88[0]; D_80165070[playerId][1] = sp88[1]; D_80165070[playerId][2] = sp88[2]; - + if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { if (gKartTopSpeedTable[player->characterId] < player->unk_094) { divOptimize = gKartTopSpeedTable[player->characterId] / player->unk_094; diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp new file mode 100644 index 000000000..f3466be60 --- /dev/null +++ b/src/port/Engine.cpp @@ -0,0 +1,194 @@ +#include "Engine.h" +#include "ui/ImguiUI.h" +#include "ZAPDUtils/Utils/StringHelper.h" +#include "libultraship/src/Context.h" +#include "resource/type/ResourceType.h" +#include "resource/importers/GenericArrayFactory.h" +#include "resource/importers/Vec3fFactory.h" +#include "resource/importers/Vec3sFactory.h" + +#include <Fast3D/gfx_pc.h> +#include <Fast3D/gfx_rendering_api.h> +#include <SDL2/SDL.h> + +#include <utility> + +extern "C" { +float gInterpolationStep = 0.0f; +#include <macros.h> +} + +GameEngine* GameEngine::Instance; + +GameEngine::GameEngine() { + std::vector<std::string> OTRFiles; + if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("sp.otr"); std::filesystem::exists(cube_path)) { + OTRFiles.push_back(cube_path); + } + if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("sm64.otr"); std::filesystem::exists(sm64_otr_path)) { + OTRFiles.push_back(sm64_otr_path); + } + if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { + if (std::filesystem::is_directory(patches_path)) { + for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) { + if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { + OTRFiles.push_back(p.path().generic_string()); + } + } + } + } + + this->context = LUS::Context::CreateInstance("Spaghettify", "skart64", "spaghettify.cfg.json", OTRFiles, {}, 3); + + auto loader = context->GetResourceManager()->GetResourceLoader(); + loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3fV0>(), RESOURCE_FORMAT_BINARY, "Vec3f", static_cast<uint32_t>(SF64::ResourceType::Vec3f), 0); + loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryVec3sV0>(), RESOURCE_FORMAT_BINARY, "Vec3s", static_cast<uint32_t>(SF64::ResourceType::Vec3s), 0); + loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinaryGenericArrayV0>(), RESOURCE_FORMAT_BINARY, "GenericArray", static_cast<uint32_t>(SF64::ResourceType::GenericArray), 0); +} + +void GameEngine::Create(){ + const auto instance = Instance = new GameEngine(); + GameUI::SetupGuiElements(); +#if defined(__SWITCH__) || defined(__WIIU__) + CVarRegisterInteger("gControlNav", 1); // always enable controller nav on switch/wii u +#endif +} + +void GameEngine::Destroy(){ + +} + +bool ShouldClearTextureCacheAtEndOfFrame = false; + +void GameEngine::StartFrame() const{ + using LUS::KbScancode; + const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); + this->context->GetWindow()->SetLastScancode(-1); + + switch (dwScancode) { + case KbScancode::LUS_KB_TAB: { + // Toggle HD Assets + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + ShouldClearTextureCacheAtEndOfFrame = true; + break; + } + default: break; + } + this->context->GetWindow()->StartFrame(); +} + +void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const { + this->context->GetWindow()->MainLoop(run_one_game_iter); +} + +void GameEngine::RunCommands(Gfx* Commands) { + gfx_run(Commands, {}); + gfx_end_frame(); + + if (ShouldClearTextureCacheAtEndOfFrame) { + gfx_texture_cache_clear(); + ShouldClearTextureCacheAtEndOfFrame = false; + } +} + +void GameEngine::ProcessGfxCommands(Gfx* commands) { + RunCommands(commands); + Instance->context->GetWindow()->SetTargetFps(30); + Instance->context->GetWindow()->SetMaximumFrameLatency(1); +} + +extern "C" uint32_t GameEngine_GetSampleRate() { + auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer(); + if (player == nullptr) { + return 0; + } + + if (!player->IsInitialized()) { + return 0; + } + + return player->GetSampleRate(); +} + +extern "C" uint32_t GameEngine_GetSamplesPerFrame(){ + return SAMPLES_PER_FRAME; +} + +// End + +extern "C" float GameEngine_GetAspectRatio() { + return gfx_current_dimensions.aspect_ratio; +} + +extern "C" uint32_t GameEngine_GetGameVersion() { + return 0x00000001; +} + +static const char* sOtrSignature = "__OTR__"; + +extern "C" uint8_t GameEngine_OTRSigCheck(const char* data) { + if(data == nullptr) { + return 0; + } + return strncmp(data, sOtrSignature, strlen(sOtrSignature)) == 0; +} + +// struct TimedEntry { +// uint64_t duration; +// TimerAction action; +// int32_t* address; +// int32_t value; +// bool active; +// }; + +// std::vector<TimedEntry> gTimerTasks; + + +// uint64_t Timer_GetCurrentMillis() { +// return SDL_GetTicks(); +// } + +// extern "C" s32 Timer_CreateTask(u64 time, TimerAction action, s32* address, s32 value) { +// const auto millis = Timer_GetCurrentMillis(); +// TimedEntry entry = { +// .duration = millis + CYCLES_TO_MSEC_PC(time), +// .action = action, +// .address = address, +// .value = value, +// .active = true, +// }; + +// gTimerTasks.push_back(entry); + +// return gTimerTasks.size() - 1; +// } + +extern "C" void Timer_Increment(int32_t* address, int32_t value) { + *address += value; +} + +extern "C" void Timer_SetValue(int32_t* address, int32_t value) { + *address = value; +} + +// void Timer_CompleteTask(TimedEntry& task) { +// if (task.action != nullptr) { +// task.action(task.address, task.value); +// } +// task.active = false; +// } + +// extern "C" void Timer_Update() { + +// if(gTimerTasks.empty()) { +// return; +// } + +// const auto millis = Timer_GetCurrentMillis(); + +// for (auto& task : gTimerTasks) { +// if (task.active && millis >= task.duration) { +// Timer_CompleteTask(task); +// } +// } +// } diff --git a/src/port/Engine.h b/src/port/Engine.h new file mode 100644 index 000000000..79c29533a --- /dev/null +++ b/src/port/Engine.h @@ -0,0 +1,35 @@ +#pragma once + +#define LOAD_ASSET(path) (path == NULL ? NULL : (GameEngine_OTRSigCheck((const char*) path) ? ResourceGetDataByName((const char*) path) : path)) +#define LOAD_ASSET_RAW(path) ResourceGetDataByName((const char*) path) + +#ifdef __cplusplus +#include <vector> +#include <Fast3D/gfx_pc.h> +#include "libultraship/src/Context.h" + +#define SAMPLES_HIGH 544 +#define SAMPLES_LOW 528 +#define AUDIO_FRAMES_PER_UPDATE 2 +#define NUM_AUDIO_CHANNELS 2 +#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2) + +class GameEngine { + public: + static GameEngine* Instance; + + std::shared_ptr<LUS::Context> context; + + GameEngine(); + static void Create(); + void StartFrame() const; + static void RunCommands(Gfx* Commands); + void ProcessFrame(void (*run_one_game_iter)()) const; + static void Destroy(); + static void ProcessGfxCommands(Gfx* commands); +}; +#else +void GameEngine_ProcessGfxCommands(Gfx* commands); +float GameEngine_GetAspectRatio(); +uint8_t GameEngine_OTRSigCheck(char* imgData); +#endif
\ No newline at end of file diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp new file mode 100644 index 000000000..37b86004a --- /dev/null +++ b/src/port/GBIMiddleware.cpp @@ -0,0 +1,54 @@ +#include <libultraship.h> + +#include "Engine.h" +#include "DisplayList.h" +#include "Array.h" + +extern "C" int GameEngine_OTRSigCheck(const char* data); + +extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { + char* imgData = (char*)dl; + + if (GameEngine_OTRSigCheck(imgData) == 1) { + auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + auto res = std::static_pointer_cast<LUS::DisplayList>(resource); + dl = &res->Instructions[0]; + dl->words.trace.file = imgData; + dl->words.trace.idx = 0; + dl->words.trace.valid = true; + } + + __gSPDisplayList(pkt, dl); +} + +extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) { + + if (GameEngine_OTRSigCheck((char*)v) == 1) { + v = (uintptr_t) ResourceGetDataByName((char *) v); + } + + __gSPVertex(pkt, v, n, v0); +} + +extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { + auto data = reinterpret_cast<char*>(texAddr); + + if (texAddr != 0 && GameEngine_OTRSigCheck(data)) { + const auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(data); + const auto type = static_cast<LUS::ResourceType>(res->GetInitData()->Type); + + switch(type) { + case LUS::ResourceType::DisplayList: + texAddr = reinterpret_cast<uintptr_t>(&std::static_pointer_cast<LUS::DisplayList>(res)->Instructions[0]); + break; + case LUS::ResourceType::Array: + texAddr = reinterpret_cast<uintptr_t>(std::static_pointer_cast<LUS::Array>(res)->Vertices.data()); + break; + default: + texAddr = reinterpret_cast<uintptr_t>(res->GetRawPointer()); + break; + } + } + + __gSPInvalidateTexCache(pkt, texAddr); +} diff --git a/src/port/Game.cpp b/src/port/Game.cpp new file mode 100644 index 000000000..9dbb0eb54 --- /dev/null +++ b/src/port/Game.cpp @@ -0,0 +1,42 @@ +#include <libultraship.h> + +#include <Fast3D/gfx_pc.h> +#include "Engine.h" + +extern "C" { + +} + +extern "C" +void Graphics_PushFrame(Gfx* data) { + GameEngine::ProcessGfxCommands(data); +} + +extern "C" void Timer_Update(); + +void push_frame() { + // GameEngine::StartAudioFrame(); + GameEngine::Instance->StartFrame(); + // Graphics_ThreadUpdate();w + // Timer_Update(); + // thread5_iteration(); + // GameEngine::EndAudioFrame(); +} + +#ifdef _WIN32 +int SDL_main(int argc, char **argv) { +#else +#if defined(__cplusplus) && defined(PLATFORM_IOS) +extern "C" +#endif +int main(int argc, char *argv[]) { +#endif + GameEngine::Create(); + // Main_SetVIMode(); + // Lib_FillScreen(1); + // Main_Initialize(); + // Main_ThreadEntry(NULL); + GameEngine::Instance->ProcessFrame(push_frame); + GameEngine::Instance->Destroy(); + return 0; +}
\ No newline at end of file diff --git a/src/port/Variables.cpp b/src/port/Variables.cpp new file mode 100644 index 000000000..f7ccf0eb6 --- /dev/null +++ b/src/port/Variables.cpp @@ -0,0 +1,6 @@ +#include <libultraship.h> +#include <Fast3D/gfx_pc.h> + +extern "C" { + +}
\ No newline at end of file diff --git a/src/port/resource/importers/GenericArrayFactory.cpp b/src/port/resource/importers/GenericArrayFactory.cpp new file mode 100644 index 000000000..64608f442 --- /dev/null +++ b/src/port/resource/importers/GenericArrayFactory.cpp @@ -0,0 +1,104 @@ +#include "GenericArrayFactory.h" +#include "../type/GenericArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr<LUS::IResource> ResourceFactoryBinaryGenericArrayV0::ReadResource(std::shared_ptr<LUS::File> file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto arr = std::make_shared<GenericArray>(file->InitData); + auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); + + auto type = reader->ReadUInt32(); + + SPDLOG_INFO("GenericArray Type Num: {}", type); + + auto count = reader->ReadUInt32(); + + SPDLOG_INFO("GenericArray Count: {}", count); + + for (uint32_t i = 0; i < count; i++) { + switch (static_cast<ArrayType>(type)) { + case ArrayType::u8: { + auto x = reader->ReadUByte(); + arr->mData.push_back(x); + break; + } + case ArrayType::s8: { + auto x = reader->ReadInt8(); + arr->mData.push_back(x); + break; + } + case ArrayType::u16: { + auto x = reader->ReadUInt16(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 2, std::back_inserter(arr->mData)); + break; + } + case ArrayType::s16: { + auto x = reader->ReadInt16(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 2, std::back_inserter(arr->mData)); + break; + } + case ArrayType::u32: { + auto x = reader->ReadUInt32(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::s32: { + auto x = reader->ReadInt32(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::u64: { + auto x = reader->ReadUInt64(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 8, std::back_inserter(arr->mData)); + break; + } + case ArrayType::f32: { + auto x = reader->ReadFloat(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 4, std::back_inserter(arr->mData)); + break; + } + case ArrayType::f64: { + auto x = reader->ReadDouble(); + std::copy_n(reinterpret_cast<uint8_t*>(&x), 8, std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec2f: { + Vec2f vec(reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec2f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3f: { + Vec3f vec(reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec3f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3s: { + Vec3s vec(reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec3s), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec3i: { + Vec3i vec(reader->ReadInt32(), reader->ReadInt32(), reader->ReadInt32()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec3i), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec4f: { + Vec4f vec(reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat(), reader->ReadFloat()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec4f), std::back_inserter(arr->mData)); + break; + } + case ArrayType::Vec4s: { + Vec4s vec(reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16(), reader->ReadInt16()); + std::copy_n(reinterpret_cast<uint8_t*>(&vec), sizeof(Vec4s), std::back_inserter(arr->mData)); + break; + } + } + } + + return arr; +} +} // namespace LUS diff --git a/src/port/resource/importers/GenericArrayFactory.h b/src/port/resource/importers/GenericArrayFactory.h new file mode 100644 index 000000000..ce0d2262a --- /dev/null +++ b/src/port/resource/importers/GenericArrayFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryGenericArrayV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/importers/ResourceUtil.h b/src/port/resource/importers/ResourceUtil.h new file mode 100644 index 000000000..4872ad649 --- /dev/null +++ b/src/port/resource/importers/ResourceUtil.h @@ -0,0 +1,15 @@ +#pragma once + +#include "resourcebridge.h" +#include "Context.h" + +namespace SF64 { +template <typename T> T LoadChild(uint64_t crc) { + auto path = ResourceGetNameByCrc(crc); + if (path == nullptr) { + return nullptr; + } + auto asset = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path); + return asset ? static_cast<T>(asset->GetRawPointer()) : nullptr; +} +}
\ No newline at end of file diff --git a/src/port/resource/importers/Vec3fFactory.cpp b/src/port/resource/importers/Vec3fFactory.cpp new file mode 100644 index 000000000..e93b4f3d5 --- /dev/null +++ b/src/port/resource/importers/Vec3fFactory.cpp @@ -0,0 +1,27 @@ +#include "Vec3fFactory.h" +#include "../type/Vec3fArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<LUS::File> file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto vec = std::make_shared<Vec3fArray>(file->InitData); + auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); + + auto vecCount = reader->ReadUInt32(); + + SPDLOG_INFO("Vec3f Count: {}", vecCount); + + for (uint32_t i = 0; i < vecCount; i++) { + auto x = reader->ReadFloat(); + auto y = reader->ReadFloat(); + auto z = reader->ReadFloat(); + vec->mData.emplace_back(x, y, z); + } + + return vec; +} +} // namespace LUS diff --git a/src/port/resource/importers/Vec3fFactory.h b/src/port/resource/importers/Vec3fFactory.h new file mode 100644 index 000000000..ee7ac7e0c --- /dev/null +++ b/src/port/resource/importers/Vec3fFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryVec3fV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/importers/Vec3sFactory.cpp b/src/port/resource/importers/Vec3sFactory.cpp new file mode 100644 index 000000000..549a1d20f --- /dev/null +++ b/src/port/resource/importers/Vec3sFactory.cpp @@ -0,0 +1,27 @@ +#include "Vec3sFactory.h" +#include "../type/Vec3sArray.h" +#include "spdlog/spdlog.h" + +namespace SF64 { +std::shared_ptr<LUS::IResource> ResourceFactoryBinaryVec3sV0::ReadResource(std::shared_ptr<LUS::File> file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto vec = std::make_shared<Vec3sArray>(file->InitData); + auto reader = std::get<std::shared_ptr<LUS::BinaryReader>>(file->Reader); + + auto vecCount = reader->ReadUInt32(); + + SPDLOG_INFO("Vec3s Count: {}", vecCount); + + for (uint32_t i = 0; i < vecCount; i++) { + auto x = reader->ReadInt16(); + auto y = reader->ReadInt16(); + auto z = reader->ReadInt16(); + vec->mData.emplace_back(x, y, z); + } + + return vec; +} +} // namespace LUS diff --git a/src/port/resource/importers/Vec3sFactory.h b/src/port/resource/importers/Vec3sFactory.h new file mode 100644 index 000000000..eddcc1dc7 --- /dev/null +++ b/src/port/resource/importers/Vec3sFactory.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Resource.h" +#include "ResourceFactoryBinary.h" + +namespace SF64 { +class ResourceFactoryBinaryVec3sV0 : public LUS::ResourceFactoryBinary { + public: + std::shared_ptr<LUS::IResource> ReadResource(std::shared_ptr<LUS::File> file) override; +}; +}; // namespace LUS diff --git a/src/port/resource/type/Animation.cpp b/src/port/resource/type/Animation.cpp new file mode 100644 index 000000000..7cb2c9002 --- /dev/null +++ b/src/port/resource/type/Animation.cpp @@ -0,0 +1,11 @@ +#include "Animation.h" + +namespace SF64 { +AnimationData* Animation::GetPointer() { + return &mData; +} + +size_t Animation::GetPointerSize() { + return sizeof(mData); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Animation.h b/src/port/resource/type/Animation.h new file mode 100644 index 000000000..868aa5d2c --- /dev/null +++ b/src/port/resource/type/Animation.h @@ -0,0 +1,38 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { +struct JointKey { + /* 0x0 */ uint16_t xLen; + /* 0x2 */ uint16_t x; + /* 0x4 */ uint16_t yLen; + /* 0x6 */ uint16_t y; + /* 0x8 */ uint16_t zLen; + /* 0xA */ uint16_t z; +}; // size = 0xC + +struct AnimationData { + /* 0x00 */ int16_t frameCount; + /* 0x02 */ int16_t limbCount; + /* 0x04 */ uint16_t* frameData; + /* 0x08 */ JointKey* jointKey; +}; // size = 0xC + +class Animation : public LUS::Resource<AnimationData> { + public: + using Resource::Resource; + + Animation() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + AnimationData* GetPointer(); + size_t GetPointerSize(); + + AnimationData mData; + + std::vector<uint16_t> frameData; + std::vector<JointKey> jointKey; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/ColPoly.cpp b/src/port/resource/type/ColPoly.cpp new file mode 100644 index 000000000..3823181b9 --- /dev/null +++ b/src/port/resource/type/ColPoly.cpp @@ -0,0 +1,11 @@ +#include "ColPoly.h" + +namespace SF64 { +ColPolyData* ColPoly::GetPointer() { + return mColPolys.data(); +} + +size_t ColPoly::GetPointerSize() { + return sizeof(mColPolys); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/ColPoly.h b/src/port/resource/type/ColPoly.h new file mode 100644 index 000000000..49c6c5ba6 --- /dev/null +++ b/src/port/resource/type/ColPoly.h @@ -0,0 +1,33 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { + +struct Vec3s { + int16_t x, y, z; +}; + +struct ColPolyData { + /* 0x00 */ Vec3s tri; + /* 0x06 */ int16_t unk_06; + /* 0x08 */ Vec3s norm; + /* 0x0E */ int16_t unk_0E; + /* 0x10 */ int32_t dist; + ColPolyData(Vec3s tri, int16_t unk_06, Vec3s norm, int16_t unk_0E, int32_t dist) : tri(std::move(tri)), unk_06(unk_06), norm(std::move(norm)), unk_0E(unk_0E), dist(dist) {} +}; // size = 0x14 + +class ColPoly : public LUS::Resource<ColPolyData> { + public: + using Resource::Resource; + + ColPoly() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + ColPolyData* GetPointer(); + size_t GetPointerSize(); + + std::vector<ColPolyData> mColPolys; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/EnvSettings.cpp b/src/port/resource/type/EnvSettings.cpp new file mode 100644 index 000000000..54dde2734 --- /dev/null +++ b/src/port/resource/type/EnvSettings.cpp @@ -0,0 +1,11 @@ +#include "EnvSettings.h" + +namespace SF64 { +EnvSettingsData* EnvSettings::GetPointer() { + return &mSettings; +} + +size_t EnvSettings::GetPointerSize() { + return sizeof(EnvSettingsData); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/EnvSettings.h b/src/port/resource/type/EnvSettings.h new file mode 100644 index 000000000..eba0e47ef --- /dev/null +++ b/src/port/resource/type/EnvSettings.h @@ -0,0 +1,40 @@ +#pragma once + +#include "Limb.h" + +#include <cstdint> +#include <Resource.h> + +namespace SF64 { + +struct EnvSettingsData { + /* 0x00 */ int32_t type; + /* 0x04 */ int32_t unk_04; + /* 0x08 */ uint16_t bgColor; + /* 0x0A */ uint16_t seqId; + /* 0x0C */ int32_t fogR; + /* 0x10 */ int32_t fogG; + /* 0x14 */ int32_t fogB; + /* 0x18 */ int32_t fogN; + /* 0x1C */ int32_t fogF; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ int32_t lightR; + /* 0x30 */ int32_t lightG; + /* 0x34 */ int32_t lightB; + /* 0x38 */ int32_t ambR; + /* 0x3C */ int32_t ambG; + /* 0x40 */ int32_t ambB; +}; + +class EnvSettings : public LUS::Resource<EnvSettingsData> { + public: + using Resource::Resource; + + EnvSettings() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + EnvSettingsData* GetPointer(); + size_t GetPointerSize(); + + EnvSettingsData mSettings{}; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/GenericArray.cpp b/src/port/resource/type/GenericArray.cpp new file mode 100644 index 000000000..74332a7e4 --- /dev/null +++ b/src/port/resource/type/GenericArray.cpp @@ -0,0 +1,11 @@ +#include "GenericArray.h" + +namespace SF64 { +uint8_t* GenericArray::GetPointer() { + return mData.data(); +} + +size_t GenericArray::GetPointerSize() { + return mData.size(); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/GenericArray.h b/src/port/resource/type/GenericArray.h new file mode 100644 index 000000000..576c60150 --- /dev/null +++ b/src/port/resource/type/GenericArray.h @@ -0,0 +1,55 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { + +struct Vec2f { + float x, y; + Vec2f(float x, float y) : x(x), y(y) {} +}; + +struct Vec3f { + float x, y, z; + Vec3f(float x, float y, float z) : x(x), y(y), z(z) {} +}; + +struct Vec3s { + int16_t x, y, z; + Vec3s(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} +}; + +struct Vec3i { + int32_t x, y, z; + Vec3i(int32_t x, int32_t y, int32_t z) : x(x), y(y), z(z) {} +}; + +struct Vec4f { + float x, y, z, w; + Vec4f(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} +}; + +struct Vec4s { + int16_t x, y, z, w; + Vec4s(int16_t x, int16_t y, int16_t z, int16_t w) : x(x), y(y), z(z), w(w) {} +}; + +enum class ArrayType { + u8, s8, u16, s16, u32, s32, u64, f32, f64, Vec2f, Vec3f, Vec3s, Vec3i, Vec4f, Vec4s, +}; + +class GenericArray : public LUS::Resource<uint8_t> { + public: + using Resource::Resource; + + GenericArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + uint8_t* GetPointer(); + size_t GetPointerSize(); + + std::vector<uint8_t> mData; + size_t mSize; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Hitbox.cpp b/src/port/resource/type/Hitbox.cpp new file mode 100644 index 000000000..44a31ba30 --- /dev/null +++ b/src/port/resource/type/Hitbox.cpp @@ -0,0 +1,11 @@ +#include "Hitbox.h" + +namespace SF64 { +float* Hitbox::GetPointer() { + return mHitbox.data(); +} + +size_t Hitbox::GetPointerSize() { + return sizeof(float) * mHitbox.size(); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Hitbox.h b/src/port/resource/type/Hitbox.h new file mode 100644 index 000000000..832eedf15 --- /dev/null +++ b/src/port/resource/type/Hitbox.h @@ -0,0 +1,16 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> + +namespace SF64 { +class Hitbox : public LUS::Resource<float> { + public: + using Resource::Resource; + + float* GetPointer() override; + size_t GetPointerSize() override; + + std::vector<float> mHitbox; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Limb.cpp b/src/port/resource/type/Limb.cpp new file mode 100644 index 000000000..a2030c32f --- /dev/null +++ b/src/port/resource/type/Limb.cpp @@ -0,0 +1,11 @@ +#include "Limb.h" + +namespace SF64 { +LimbData* Limb::GetPointer() { + return &mData; +} + +size_t Limb::GetPointerSize() { + return sizeof(mData); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Limb.h b/src/port/resource/type/Limb.h new file mode 100644 index 000000000..eb12e2e32 --- /dev/null +++ b/src/port/resource/type/Limb.h @@ -0,0 +1,37 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> + +namespace SF64 { + +struct Vec3f { + float x, y, z; +}; + +struct Vec3s { + int16_t x, y, z; +}; + +struct Gfx; + +struct LimbData { + /* 0x000 */ Gfx* dList; + /* 0x004 */ Vec3f trans; + /* 0x010 */ Vec3s rot; + /* 0x018 */ LimbData* sibling; + /* 0x01C */ LimbData* child; +}; // size = 0x20 + +class Limb : public LUS::Resource<LimbData> { + public: + using Resource::Resource; + + Limb() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + LimbData* GetPointer(); + size_t GetPointerSize(); + + LimbData mData{}; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Message.cpp b/src/port/resource/type/Message.cpp new file mode 100644 index 000000000..a0708f608 --- /dev/null +++ b/src/port/resource/type/Message.cpp @@ -0,0 +1,19 @@ +#include "Message.h" + +namespace SF64 { +void* Message::GetPointer() { + return mMessage.data(); +} + +size_t Message::GetPointerSize() { + return mMessage.size() * sizeof(uint16_t); +} + +MsgLookup* MessageLookup::GetPointer() { + return mLookupTable.data(); +} + +size_t MessageLookup::GetPointerSize() { + return mLookupTable.size() * sizeof(MsgLookup); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Message.h b/src/port/resource/type/Message.h new file mode 100644 index 000000000..ac0748627 --- /dev/null +++ b/src/port/resource/type/Message.h @@ -0,0 +1,32 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { +typedef struct { + s32 msgId; + u16* msgPtr; +} MsgLookup; + +class Message : public LUS::Resource<void> { + public: + using Resource::Resource; + + void* GetPointer() override; + size_t GetPointerSize() override; + + std::vector<uint16_t> mMessage; +}; + +class MessageLookup : public LUS::Resource<MsgLookup> { + public: + using Resource::Resource; + + MsgLookup* GetPointer() override; + size_t GetPointerSize() override; + + std::vector<MsgLookup> mLookupTable; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/ObjectInit.cpp b/src/port/resource/type/ObjectInit.cpp new file mode 100644 index 000000000..3fe6e95b7 --- /dev/null +++ b/src/port/resource/type/ObjectInit.cpp @@ -0,0 +1,11 @@ +#include "ObjectInit.h" + +namespace SF64 { +ObjectInitData* ObjectInit::GetPointer() { + return mObjects.data(); +} + +size_t ObjectInit::GetPointerSize() { + return sizeof(ObjectInitData) * mObjects.size(); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/ObjectInit.h b/src/port/resource/type/ObjectInit.h new file mode 100644 index 000000000..56f755665 --- /dev/null +++ b/src/port/resource/type/ObjectInit.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Limb.h" + +#include <cstdint> +#include <Resource.h> + +namespace SF64 { + +struct ObjectInitData { + /* 0x00 */ float zPos1; + /* 0x04 */ int16_t zPos2; + /* 0x06 */ int16_t xPos; + /* 0x08 */ int16_t yPos; + /* 0x0A */ Vec3s rot; + /* 0x10 */ int16_t id; +}; // size = 0x14 + +class ObjectInit : public LUS::Resource<ObjectInitData> { + public: + using Resource::Resource; + + ObjectInit() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + ObjectInitData* GetPointer(); + size_t GetPointerSize(); + + std::vector<ObjectInitData> mObjects; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/ResourceType.h b/src/port/resource/type/ResourceType.h new file mode 100644 index 000000000..c143457d2 --- /dev/null +++ b/src/port/resource/type/ResourceType.h @@ -0,0 +1,21 @@ +#pragma once + +namespace SF64 { +enum class ResourceType { + // SF64 + AnimData = 0x414E494D, // ANIM + ColPoly = 0x43504C59, // CPLY + EnvSettings = 0x454E5653, // ENVS + Limb = 0x4C494D42, // LIMB + Message = 0x4D534720, // MSG + MessageTable = 0x4D534754, // MSGT + Skeleton = 0x534B454C, // SKEL + Script = 0x53435250, // SCRP + ScriptCmd = 0x53434D44, // SCMD + Hitbox = 0x48544258, // HTBX + ObjectInit = 0x4F42494E, // OBIN + Vec3f = 0x56433346, // VC3F + Vec3s = 0x56433353, // VC3S + GenericArray = 0x47415252, // GARR +}; +} // namespace SOH diff --git a/src/port/resource/type/Script.cpp b/src/port/resource/type/Script.cpp new file mode 100644 index 000000000..71ddc7680 --- /dev/null +++ b/src/port/resource/type/Script.cpp @@ -0,0 +1,19 @@ +#include "Script.h" + +namespace SF64 { +uint16_t** Script::GetPointer() { + return mScripts.data(); +} + +size_t Script::GetPointerSize() { + return sizeof(uint16_t*) * mScripts.size(); +} + +uint16_t* ScriptCMDs::GetPointer() { + return mCommands.data(); +} + +size_t ScriptCMDs::GetPointerSize() { + return sizeof(uint16_t) * mCommands.size(); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Script.h b/src/port/resource/type/Script.h new file mode 100644 index 000000000..55d0b348d --- /dev/null +++ b/src/port/resource/type/Script.h @@ -0,0 +1,26 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> + +namespace SF64 { +class Script : public LUS::Resource<uint16_t*> { + public: + using Resource::Resource; + + uint16_t** GetPointer() override; + size_t GetPointerSize() override; + + std::vector<uint16_t*> mScripts; +}; + +class ScriptCMDs : public LUS::Resource<uint16_t> { + public: + using Resource::Resource; + + uint16_t* GetPointer() override; + size_t GetPointerSize() override; + + std::vector<uint16_t> mCommands; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Skeleton.cpp b/src/port/resource/type/Skeleton.cpp new file mode 100644 index 000000000..49e9a59ad --- /dev/null +++ b/src/port/resource/type/Skeleton.cpp @@ -0,0 +1,11 @@ +#include "Skeleton.h" + +namespace SF64 { +LimbData** Skeleton::GetPointer() { + return mLimbs.data(); +} + +size_t Skeleton::GetPointerSize() { + return mLimbs.size() * sizeof(LimbData*); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Skeleton.h b/src/port/resource/type/Skeleton.h new file mode 100644 index 000000000..3332abf77 --- /dev/null +++ b/src/port/resource/type/Skeleton.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Limb.h" + +#include <Resource.h> + +namespace SF64 { +class Skeleton : public LUS::Resource<LimbData*> { + public: + using Resource::Resource; + + Skeleton() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + LimbData** GetPointer(); + size_t GetPointerSize(); + + std::vector<LimbData*> mLimbs; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Vec3fArray.cpp b/src/port/resource/type/Vec3fArray.cpp new file mode 100644 index 000000000..27ccd1d9e --- /dev/null +++ b/src/port/resource/type/Vec3fArray.cpp @@ -0,0 +1,11 @@ +#include "Vec3fArray.h" + +namespace SF64 { +Vec3fData* Vec3fArray::GetPointer() { + return mData.data(); +} + +size_t Vec3fArray::GetPointerSize() { + return sizeof(mData); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Vec3fArray.h b/src/port/resource/type/Vec3fArray.h new file mode 100644 index 000000000..9a6cb0bdf --- /dev/null +++ b/src/port/resource/type/Vec3fArray.h @@ -0,0 +1,25 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { + +struct Vec3fData { + float x, y, z; + Vec3fData(float x, float y, float z) : x(x), y(y), z(z) {} +}; + +class Vec3fArray : public LUS::Resource<Vec3fData> { + public: + using Resource::Resource; + + Vec3fArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + Vec3fData* GetPointer(); + size_t GetPointerSize(); + + std::vector<Vec3fData> mData; +}; +}
\ No newline at end of file diff --git a/src/port/resource/type/Vec3sArray.cpp b/src/port/resource/type/Vec3sArray.cpp new file mode 100644 index 000000000..e6c4fa2d7 --- /dev/null +++ b/src/port/resource/type/Vec3sArray.cpp @@ -0,0 +1,11 @@ +#include "Vec3sArray.h" + +namespace SF64 { +Vec3sData* Vec3sArray::GetPointer() { + return mData.data(); +} + +size_t Vec3sArray::GetPointerSize() { + return sizeof(mData); +} +}
\ No newline at end of file diff --git a/src/port/resource/type/Vec3sArray.h b/src/port/resource/type/Vec3sArray.h new file mode 100644 index 000000000..5e8f466b9 --- /dev/null +++ b/src/port/resource/type/Vec3sArray.h @@ -0,0 +1,25 @@ +#pragma once + +#include <cstdint> +#include <Resource.h> +#include <libultraship/libultra/types.h> + +namespace SF64 { + +struct Vec3sData { + int16_t x, y, z; + Vec3sData(int16_t x, int16_t y, int16_t z) : x(x), y(y), z(z) {} +}; + +class Vec3sArray : public LUS::Resource<Vec3sData> { + public: + using Resource::Resource; + + Vec3sArray() : Resource(std::shared_ptr<LUS::ResourceInitData>()) {} + + Vec3sData* GetPointer(); + size_t GetPointerSize(); + + std::vector<Vec3sData> mData; +}; +}
\ No newline at end of file diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp new file mode 100644 index 000000000..83e91ed6b --- /dev/null +++ b/src/port/ui/ImguiUI.cpp @@ -0,0 +1,510 @@ +#include "ImguiUI.h" +#include "UIWidgets.h" +#include "ResolutionEditor.h" + +#include <spdlog/spdlog.h> +#include <ImGui/imgui.h> +#define IMGUI_DEFINE_MATH_OPERATORS +#include "libultraship/src/Context.h" + +#include <ImGui/imgui_internal.h> +#include <libultraship/libultraship.h> +#include <Fast3D/gfx_pc.h> +#include "port/Engine.h" + +extern "C" { + +} + +namespace GameUI { +std::shared_ptr<GameMenuBar> mGameMenuBar; +std::shared_ptr<LUS::GuiWindow> mConsoleWindow; +std::shared_ptr<LUS::GuiWindow> mStatsWindow; +std::shared_ptr<LUS::GuiWindow> mInputEditorWindow; +std::shared_ptr<LUS::GuiWindow> mGfxDebuggerWindow; +std::shared_ptr<AdvancedResolutionSettings::AdvancedResolutionSettingsWindow> mAdvancedResolutionSettingsWindow; + +void SetupGuiElements() { + auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + + auto& style = ImGui::GetStyle(); + style.FramePadding = ImVec2(4.0f, 6.0f); + style.ItemSpacing = ImVec2(8.0f, 6.0f); + style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray; + + mGameMenuBar = std::make_shared<GameMenuBar>("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + gui->SetMenuBar(mGameMenuBar); + mStatsWindow = gui->GetGuiWindow("Stats"); + if (mStatsWindow == nullptr) { + SPDLOG_ERROR("Could not find stats window"); + } + + mConsoleWindow = gui->GetGuiWindow("Console"); + if (mConsoleWindow == nullptr) { + SPDLOG_ERROR("Could not find console window"); + } + + mInputEditorWindow = gui->GetGuiWindow("Input Editor"); + if (mInputEditorWindow == nullptr) { + SPDLOG_ERROR("Could not find input editor window"); + return; + } + + mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); + if (mGfxDebuggerWindow == nullptr) { + SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); + } + + mAdvancedResolutionSettingsWindow = std::make_shared<AdvancedResolutionSettings::AdvancedResolutionSettingsWindow>("gAdvancedResolutionEditorEnabled", "Advanced Resolution Settings"); + gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); +} + +void Destroy() { + mAdvancedResolutionSettingsWindow = nullptr; + mConsoleWindow = nullptr; + mStatsWindow = nullptr; + mInputEditorWindow = nullptr; +} + +std::string GetWindowButtonText(const char* text, bool menuOpen) { + char buttonText[100] = ""; + if (menuOpen) { + strcat(buttonText, ICON_FA_CHEVRON_RIGHT " "); + } + strcat(buttonText, text); + if (!menuOpen) { strcat(buttonText, " "); } + return buttonText; +} +} + +static const char* filters[3] = { +#ifdef __WIIU__ + "", +#else + "Three-Point", +#endif + "Linear", "None" +}; + +void DrawSettingsMenu(){ + if(UIWidgets::BeginMenu("Settings")){ + // if (UIWidgets::BeginMenu("Audio")) { + // UIWidgets::CVarSliderFloat("Master Volume", "gGameMasterVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // }); + // if (UIWidgets::CVarSliderFloat("Main Music Volume", "gMainMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Environment Volume", "gEnvironmentVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); + // } + // + // static std::unordered_map<LUS::AudioBackend, const char*> audioBackendNames = { + // { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, + // { LUS::AudioBackend::PULSE, "PulseAudio" }, + // { LUS::AudioBackend::SDL, "SDL" }, + // }; + // + // ImGui::Text("Audio API (Needs reload)"); + // auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); + // + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + // } + // if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { + // for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { + // auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; + // if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { + // LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); + // } + // } + // ImGui::EndCombo(); + // } + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::ReEnableComponent(""); + // } + // + // ImGui::EndMenu(); + // } + + UIWidgets::Spacer(0); + + if (UIWidgets::BeginMenu("Controller")) { + UIWidgets::WindowButton("Controller Mapping", "gInputEditorWindow", GameUI::mInputEditorWindow); + + UIWidgets::Spacer(0); + +#ifndef __SWITCH__ + UIWidgets::CVarCheckbox("Menubar Controller Navigation", "gControlNav", { + .tooltip = "Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar" + }); +#endif + UIWidgets::CVarCheckbox("Show Inputs", "gInputEnabled", { + .tooltip = "Shows currently pressed inputs on the bottom right of the screen" + }); + if (CVarGetInteger("gInputEnabled", 0)) { + UIWidgets::CVarSliderFloat("Input Scale", "gInputScale", 1.0f, 3.0f, 1.0f, { + .tooltip = "Sets the on screen size of the displayed inputs from the Show Inputs setting", + .format = "%.1fx", + }); + } + + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } + + ImGui::SetCursorPosY(0.0f); + if (UIWidgets::BeginMenu("Graphics")) { + UIWidgets::WindowButton("Resolution Editor", "gAdvancedResolutionEditorEnabled", GameUI::mAdvancedResolutionSettingsWindow); + + UIWidgets::Spacer(0); + + // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste? + // LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + // UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); +#ifndef __WIIU__ + if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, { + .tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel" + })) { + LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + } +#endif + + { // FPS Slider + const int minFps = 30; + static int maxFps; + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + maxFps = 360; + } else { + maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + } + int currentFps = 0; + #ifdef __WIIU__ + UIWidgets::Spacer(0); + // only support divisors of 60 on the Wii U + if (currentFps > 60) { + currentFps = 60; + } else { + currentFps = 60 / (60 / currentFps); + } + + int fpsSlider = 1; + if (currentFps == 30) { + ImGui::Text("FPS: Original (30)"); + } else { + ImGui::Text("FPS: %d", currentFps); + if (currentFps == 30) { + fpsSlider = 2; + } else { // currentFps == 60 + fpsSlider = 3; + } + } + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (ImGui::Button(" - ##WiiUFPS")) { + fpsSlider--; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + UIWidgets::Spacer(0); + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - 60.0f), 260.0f)); + ImGui::SliderInt("##WiiUFPSSlider", &fpsSlider, 1, 3, "", ImGuiSliderFlags_AlwaysClamp); + ImGui::PopItemWidth(); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(" + ##WiiUFPS")) { + fpsSlider++; + } + + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::ReEnableComponent(""); + } + if (fpsSlider > 3) { + fpsSlider = 3; + } else if (fpsSlider < 1) { + fpsSlider = 1; + } + + if (fpsSlider == 1) { + currentFps = 20; + } else if (fpsSlider == 2) { + currentFps = 30; + } else if (fpsSlider == 3) { + currentFps = 60; + } + CVarSetInteger("gInterpolationFPS", currentFps); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + #else + bool matchingRefreshRate = + CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; + UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { + .disabled = matchingRefreshRate + }); + #endif + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc.\n\n" + "A higher target FPS than your monitor's refresh rate will waste resources, and might give a worse result." + ); + } else { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc." + ); + } + } // END FPS Slider + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Spacer(0); + if (ImGui::Button("Match Refresh Rate")) { + int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + if (hz >= 30 && hz <= 360) { + CVarSetInteger("gInterpolationFPS", hz); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } else { + UIWidgets::PaddedEnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate", true, false); + } + + UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", + "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); + UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + + static std::unordered_map<LUS::WindowBackend, const char*> windowBackendNames = { + { LUS::WindowBackend::DX11, "DirectX" }, + { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, + { LUS::WindowBackend::SDL_METAL, "Metal" }, + { LUS::WindowBackend::GX2, "GX2"} + }; + + ImGui::Text("Renderer API (Needs reload)"); + LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); + LUS::WindowBackend configWindowBackend; + int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast<int>(LUS::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast<LUS::WindowBackend>(configWindowBackendId); + } else { + configWindowBackend = runningWindowBackend; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { + for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { + auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; + if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { + LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast<int>(backend)); + LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + windowBackendNames[backend]); + LUS::Context::GetInstance()->GetConfig()->Save(); + } + } + ImGui::EndCombo(); + } + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::ReEnableComponent(""); + } + + if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { + UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); + } + + // If more filters are added to LUS, make sure to add them to the filters list here + ImGui::Text("Texture Filter (Needs reload)"); + + UIWidgets::EnhancementCombobox("gTextureFilter", filters, 0); + + UIWidgets::Spacer(0); + + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + + ImGui::EndMenu(); + } +} + +void DrawMenuBarIcon() { + static bool gameIconLoaded = false; + if (!gameIconLoaded) { + // LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); + gameIconLoaded = false; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { +#ifdef __SWITCH__ + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.0f; +#elif defined(__WIIU__) + ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2); + float posScale = 2.0f; +#else + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.5f; +#endif + ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); + ImGui::SameLine(); + ImGui::SetCursorPos(ImVec2(25, 0) * posScale); + } +} + +void DrawGameMenu() { + if (UIWidgets::BeginMenu("Lylat64")) { + if (UIWidgets::MenuItem("Reset", +#ifdef __APPLE__ + "Command-R" +#else + "Ctrl+R" +#endif + )) { + // gNextGameState = GSTATE_BOOT; + } +#if !defined(__SWITCH__) && !defined(__WIIU__) + + if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) { + LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); + } + + if (UIWidgets::MenuItem("Quit")) { + LUS::Context::GetInstance()->GetWindow()->Close(); + } +#endif + ImGui::EndMenu(); + } +} + +void DrawEnhancementsMenu() { + if (UIWidgets::BeginMenu("Enhancements")) { + + if (UIWidgets::BeginMenu("Gameplay")) { + UIWidgets::CVarCheckbox("No Level of Detail (LOD)", "gDisableLOD", { + .tooltip = "Disable Level of Detail (LOD) to avoid models using lower poly versions at a distance" + }); + UIWidgets::CVarCheckbox("Select any star from menu", "gSelectAllStars", { + .tooltip = "Let's you select any star from the menu regardless of the courses completion status." + }); + UIWidgets::CVarCheckbox("Collecting Stars Will Not Exit Level", "gStarNoExit", { + .tooltip = "Stars act like the 100 coin star and will not take you out of the level" + }); + UIWidgets::CVarCheckbox("Avoid playing peach cutscene", "gDisablePeachCutscene", { + .tooltip = "Avoid playing the peach cutscene when starting a new game" + }); + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } +} + +void DrawCheatsMenu() { + if (UIWidgets::BeginMenu("Cheats")) { + UIWidgets::CVarCheckbox("Infinite Health", "gInfiniteHealth"); + UIWidgets::CVarCheckbox("Infinite Lives", "gInfiniteLives"); + + ImGui::EndMenu(); + } +} + +const char* debugInfoPages[6] = { + "Object", + "Check Surface", + "Map", + "Stage", + "Effect", + "Enemy", +}; + +void DrawDebugMenu() { + if (UIWidgets::BeginMenu("Developer")) { + UIWidgets::WindowButton("Gfx Debugger", "gGfxDebuggerEnabled", GameUI::mGfxDebuggerWindow, { + .tooltip = "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" + }); + + UIWidgets::CVarCheckbox("Debug mode", "gEnableDebugMode", { + .tooltip = "TBD" + }); + + UIWidgets::CVarCheckbox("Level Selector", "gLevelSelector", { + .tooltip = "Allows you to select any level from the main menu" + }); + + UIWidgets::CVarCheckbox("SFX Jukebox", "gSfxJukebox", { + .tooltip = "Allows you to play sound effects from the game" + }); + + UIWidgets::Spacer(0); + + UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, { + .tooltip = "Shows the stats window, with your FPS and frametimes, and the OS you're playing on" + }); + UIWidgets::WindowButton("Console", "gConsoleEnabled", GameUI::mConsoleWindow, { + .tooltip = "Enables the console window, allowing you to input commands, type help for some examples" + }); + + ImGui::EndMenu(); + } +} + +void GameMenuBar::DrawElement() { + if(ImGui::BeginMenuBar()){ + DrawMenuBarIcon(); + + DrawGameMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawSettingsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawEnhancementsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawCheatsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawDebugMenu(); + + ImGui::EndMenuBar(); + } +}
\ No newline at end of file diff --git a/src/port/ui/ImguiUI.h b/src/port/ui/ImguiUI.h new file mode 100644 index 000000000..2d233f4c5 --- /dev/null +++ b/src/port/ui/ImguiUI.h @@ -0,0 +1,16 @@ +#pragma once +#include <libultraship/libultraship.h> + +namespace GameUI { + void SetupGuiElements(); + void Destroy(); +} + +class GameMenuBar : public LUS::GuiMenuBar { + public: + using LUS::GuiMenuBar::GuiMenuBar; + protected: + void DrawElement() override; + void InitElement() override {}; + void UpdateElement() override {}; +};
\ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp new file mode 100644 index 000000000..01995a3c9 --- /dev/null +++ b/src/port/ui/ResolutionEditor.cpp @@ -0,0 +1,422 @@ +#include "ResolutionEditor.h" +#include "UIWidgets.h" +#include "libultraship/src/Context.h" + +#include <ImGui/imgui.h> +#include <libultraship/libultraship.h> +#include <graphic/Fast3D/gfx_pc.h> + +/* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled") + + The following CVars are used in Libultraship and can be edited here: + - Enabled - Turns Advanced Resolution Mode on. + - AspectRatioX, AspectRatioY - Aspect ratio controls. To toggle off, set either to zero. + - VerticalPixelCount, VerticalResolutionToggle - Resolution controls. + - PixelPerfectMode, IntegerScale.Factor - Pixel Perfect Mode a.k.a. integer scaling controls. + (Waiting on a second PR merge on LUS for this to fully function.): + - IntegerScale.FitAutomatically - Automatic resizing for Pixel Perfect Mode. + - IntegerScale.NeverExceedBounds - Prevents manual resizing from exceeding screen bounds. + + The following CVars are also implemented in LUS for niche use cases: + - IgnoreAspectCorrection - Stretch framebuffer to fill screen. + This is something of a power-user setting for niche setups that most people won't need or care about, + but may be useful if playing the Switch/Wii U ports on a 4:3 television. + - IntegerScale.ExceedBoundsBy - Offset the max screen bounds, usually by +1. + This isn't that useful at the moment. +*/ + +namespace AdvancedResolutionSettings { + enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount }; + + const char* aspectRatioPresetLabels[] = { + "Off", "Custom", "Original (4:3)", "Widescreen (16:9)", "Nintendo 3DS (5:3)", "16:10 (8:5)", "Ultrawide (21:9)" + }; + const float aspectRatioPresetsX[] = { 0.0f, 12.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; + const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; + const int default_aspectRatio = 1; // Default combo list option + + const char* pixelCountPresetLabels[] = { "Custom", "Native N64 (240p)", "2x (480p)", "3x (720p)", "4x (960p)", + "5x (1200p)", "6x (1440p)", "Full HD (1080p)", "4K (2160p)" }; + const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 }; + const int default_pixelCount = 0; // Default combo list option + + const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution() + const uint32_t maxVerticalPixelCount = 4320; + + const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. + + const float enhancementSpacerHeight = 19.0f; +// This will need to be determined more intelligently when Hi-DPI UI support is added. + + void AdvancedResolutionSettingsWindow::InitElement() { + } + + void AdvancedResolutionSettingsWindow::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(497, 532), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Advanced Resolution Settings", &mIsVisible)) { + // Initialise update flags. + bool update[sizeof(setting)]; + for (unsigned short i = 0; i < sizeof(setting); i++) + update[i] = false; + static short updateCountdown = 0; + short countdownStartingValue = CVarGetInteger("gInterpolationFPS", 20) / 2; // half of a second, in frames. + + // Initialise integer scale bounds. + short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + // overridden depending on viewport res + + short integerScale_maximumBounds = 1; // can change when window is resized + // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > + ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + // Scale to window height + integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + } else { + // Scale to window width + integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + } + // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. + // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. + if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { + max_integerScaleFactor = + integerScale_maximumBounds + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + } + + // Stored Values for non-UIWidgets elements + static float aspectRatioX = CVarGetFloat("gAdvancedResolution.AspectRatioX", 16.0f); + static float aspectRatioY = CVarGetFloat("gAdvancedResolution.AspectRatioY", 9.0f); + static int verticalPixelCount = CVarGetInteger("gAdvancedResolution.VerticalPixelCount", 480); + // Combo List defaults + static int item_aspectRatio = default_aspectRatio; + static int item_pixelCount = default_pixelCount; + // Additional settings + static bool showHorizontalResField = false; + static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + +#ifdef __APPLE__ + ImGui::Text("Note: these settings may behave incorrectly on Apple Retina Displays."); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); +#endif + + // The original resolution slider (for convenience) + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, + "", 1.0f, true, true, + (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && + CVarGetInteger("gAdvancedResolution.Enabled", 0)) || + CVarGetInteger("gLowResMode", 0))) { + LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + } + UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective " + "form of anti-aliasing"); // Description pulled from SohMenuBar.cpp + + // N64 Mode toggle (again for convenience) + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", "gLowResMode", false, false, false, + // "", UIWidgets::CheckboxGraphics::Cross, false); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Activator + UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, + false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display + if (!CVarGetInteger("gLowResMode", 0)) { + if (IsDroppingFrames()) { // Significant frame drop warning + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, + ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); + UIWidgets::Spacer(2); + } else { // No warnings + UIWidgets::Spacer(enhancementSpacerHeight); + } + } else { // N64 Mode warning + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); + ImGui::SameLine(); + if (ImGui::Button("Click to disable")) { + CVarSetInteger("gLowResMode", (int)false); + CVarSave(); + } + } + // Resolution visualiser + ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, + gfx_current_game_window_viewport.height); + ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Aspect Ratio + ImGui::Text("Force aspect ratio:"); + ImGui::SameLine(); + ImGui::TextColored({ 0.75f, 0.75f, 0.75f, 1.0f }, "(Select \"Off\" to disable.)"); + if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, + IM_ARRAYSIZE(aspectRatioPresetLabels)) && + item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. + aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; + aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { + // Declaring the Y input interaction in particular as a variable beforehand + // will prevent a bug where the Y field would disappear when modifying X. + bool inputX = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); + bool inputY = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); + if (inputX || inputY) { + item_aspectRatio = default_aspectRatio; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } else if (showHorizontalResField) { // Show calculated aspect ratio + if (item_aspectRatio) { + UIWidgets::Spacer(2); + float resolvedAspectRatio = (float)gfx_current_dimensions.height / gfx_current_dimensions.width; + ImGui::Text("Aspect ratio: %.4f", resolvedAspectRatio); + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + } + + UIWidgets::Spacer(0); + // Vertical Resolution + UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", + "gAdvancedResolution.VerticalResolutionToggle", true, false, false, "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip( + "Override the resolution scale slider and use the settings below, irrespective of window size."); + if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, + IM_ARRAYSIZE(pixelCountPresetLabels)) && + item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. + verticalPixelCount = pixelCountPresets[item_pixelCount]; + update[UPDATE_verticalPixelCount] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + // Horizontal Resolution, if visibility is enabled for it. + if (showHorizontalResField) { + // Only show the field if Aspect Ratio is being enforced. + if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { + // So basically we're "faking" this one by setting aspectRatioX instead. + if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { + item_aspectRatio = default_aspectRatio; + if (horizontalPixelCount < (minVerticalPixelCount / 3.0f) * 4.0f) { + horizontalPixelCount = (minVerticalPixelCount / 3.0f) * 4.0f; + } + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } else { // Display a notice instead. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); + // ImGui::Text(" "); + ImGui::SameLine(); + if (ImGui::Button("Click to resolve")) { + item_aspectRatio = default_aspectRatio; // Set it to Custom + aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults + aspectRatioY = aspectRatioPresetsY[2]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + } + // Vertical Resolution part 2 + if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { + item_pixelCount = default_pixelCount; + update[UPDATE_verticalPixelCount] = true; + + // Account for the natural instinct to enter horizontal first. + // Ignore vertical resolutions that are below the lower clamp constant. + if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } + + UIWidgets::Spacer(0); + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Integer scaling settings group + if (ImGui::CollapsingHeader("Integer Scaling Settings")) { + // Pixel-perfect Mode + UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", "gAdvancedResolution.PixelPerfectMode", true, + true, + !CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Don't scale image to fill window."); + if (!CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0)) { + CVarSetInteger("gAdvancedResolution.PixelPerfectMode", (int)false); + CVarSave(); + } + + // Integer Scaling + UIWidgets::EnhancementSliderInt("Integer scale factor: %d", "##ARSIntScale", + "gAdvancedResolution.IntegerScale.Factor", 1, max_integerScaleFactor, "%d", + 1, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)); + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); + // Display warning if size is being clamped or if framebuffer is larger than viewport. + if (CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) && + (CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger("gAdvancedResolution.IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + ImGui::SameLine(); + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); + } + + UIWidgets::PaddedEnhancementCheckbox("Automatically scale image to fit viewport", + "gAdvancedResolution.IntegerScale.FitAutomatically", true, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)) { + // This is just here to update the value shown on the slider. + // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. + CVarSetInteger("gAdvancedResolution.IntegerScale.Factor", integerScale_maximumBounds); + // CVarSave(); + } + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Collapsible panel for additional settings + if (ImGui::CollapsingHeader("Additional Settings")) { + UIWidgets::Spacer(0); +#if defined(__SWITCH__) || defined(__WIIU__) + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated CVar is still functional on PC platforms if you want to use it though. + UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + "gAdvancedResolution.IgnoreAspectCorrection", false, true, + CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); +#else + if (CVarGetInteger("gAdvancedResolution.IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger("gAdvancedResolution.IgnoreAspectCorrection", (int)false); + CVarSave(); + } + UIWidgets::Spacer(2); + } +#endif + + if (ImGui::Checkbox("Show a horizontal resolution field.", &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + } + } + update[UPDATE_aspectRatioX] = true; + } + + UIWidgets::PaddedEnhancementCheckbox( + "Don't allow integer scaling to exceed screen bounds.\n" + "(Makes screen bounds take priority over specified factor.)", + "gAdvancedResolution.IntegerScale.NeverExceedBounds", true, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0), + "", UIWidgets::CheckboxGraphics::Cross, true); + + if (!CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + // Another helpful button for an unused CVar. + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + if (ImGui::Button("Click to reset an unused CVar that may be causing this.")) { + CVarSetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + } + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + + // I've ended up dummying this one out because it doesn't function in a satisfactory way. + // Consider this idea on the table, but I don't deem it an important enough feature to push for. + /* + UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go 1x above maximum screen bounds.", + "gAdvancedResolution.IntegerScale.ExceedBoundsBy", false, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + }*/ + + } // end of Additional Settings + + // Clamp and update the CVars that don't use UIWidgets + if (IsBoolArrayTrue(update)) { + if (update[UPDATE_aspectRatioX]) { + if (aspectRatioX < 0.0f) { + aspectRatioX = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioX", aspectRatioX); + } + if (update[UPDATE_aspectRatioY]) { + if (aspectRatioY < 0.0f) { + aspectRatioY = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioY", aspectRatioY); + } + if (update[UPDATE_verticalPixelCount]) { + // There's a upper and lower clamp on the Libultraship side too, + // so clamping it here is purely visual, so the vertical resolution field reflects it. + if (verticalPixelCount < minVerticalPixelCount) { + verticalPixelCount = minVerticalPixelCount; + } + if (verticalPixelCount > maxVerticalPixelCount) { + verticalPixelCount = maxVerticalPixelCount; + } + CVarSetInteger("gAdvancedResolution.VerticalPixelCount", verticalPixelCount); + } + // Delay saving this set of CVars by a predetermined length of time, in frames. + updateCountdown = countdownStartingValue; + } + if (updateCountdown > 0) { + updateCountdown--; + } else { + CVarSave(); + } + } + ImGui::End(); + } + + void AdvancedResolutionSettingsWindow::UpdateElement() { + } + + bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { + // a rather imprecise way of checking for frame drops. + // but it's mostly there to inform the player of large drops. + const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const float threshold = targetFPS / 20.0f + 4.1f; + return ImGui::GetIO().Framerate < targetFPS - threshold; + } + + bool AdvancedResolutionSettingsWindow::IsBoolArrayTrue(bool* foo) { + for (unsigned short i = 0; i < sizeof(&foo); i++) + if (&foo[i]) + return true; + return false; + } +} // namespace AdvancedResolutionSettings
\ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.h b/src/port/ui/ResolutionEditor.h new file mode 100644 index 000000000..38af56073 --- /dev/null +++ b/src/port/ui/ResolutionEditor.h @@ -0,0 +1,19 @@ +#pragma once +#include <libultraship/libultraship.h> + +namespace AdvancedResolutionSettings { + class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { + private: + bool IsDroppingFrames(); + + protected: + bool IsBoolArrayTrue(bool*); + + public: + using LUS::GuiWindow::GuiWindow; + + void InitElement() override; + void DrawElement() override; + void UpdateElement() override; + }; +} // namespace AdvancedResolutionSettings
\ No newline at end of file diff --git a/src/port/ui/UIWidgets.cpp b/src/port/ui/UIWidgets.cpp new file mode 100644 index 000000000..7aec506c6 --- /dev/null +++ b/src/port/ui/UIWidgets.cpp @@ -0,0 +1,1033 @@ +// +// UIWidgets.cpp +// soh +// +// Created by David Chavez on 25.08.22. +// + +#include "UIWidgets.h" + +#include "libultraship/src/Context.h" + +#include <ImGui/imgui.h> +#include <ImGui/imgui_internal.h> +#include <libultraship/libultraship.h> +#include <libultraship/libultra/types.h> + +namespace UIWidgets { + + // MARK: - Layout Helper + + // Automatically adds newlines to break up text longer than a specified number of characters + // Manually included newlines will still be respected and reset the line length + // If line is midword when it hits the limit, text should break at the last encountered space + char* WrappedText(const char* text, unsigned int charactersPerLine) { + std::string newText(text); + const size_t tipLength = newText.length(); + int lastSpace = -1; + int currentLineLength = 0; + for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) { + if (newText[currentCharacter] == '\n') { + currentLineLength = 0; + lastSpace = -1; + continue; + } else if (newText[currentCharacter] == ' ') { + lastSpace = currentCharacter; + } + + if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) { + newText[lastSpace] = '\n'; + currentLineLength = currentCharacter - lastSpace - 1; + lastSpace = -1; + } + currentLineLength++; + } + + return strdup(newText.c_str()); + } + + char* WrappedText(const std::string& text, unsigned int charactersPerLine) { + return WrappedText(text.c_str(), charactersPerLine); + } + + void SetLastItemHoverText(const std::string& text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void SetLastItemHoverText(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + // Adds a "?" next to the previous ImGui item with a custom tooltip + void InsertHelpHoverText(const std::string& text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void InsertHelpHoverText(const char* text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + + // MARK: - UI Elements + + void Tooltip(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("%s", WrappedText(text)); + } + } + + void Spacer(float height) { + ImGui::Dummy(ImVec2(0.0f, height)); + } + + void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) { + if (padTop) { + Spacer(extraVerticalTopPadding); + } + ImGui::Separator(); + if (padBottom) { + Spacer(extraVerticalBottomPadding); + } + } + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) { + float thickness = ImMax(sz / 5.0f, 1.0f); + sz -= thickness * 0.5f; + pos += ImVec2(thickness * 0.25f, thickness * 0.25f); + + draw_list->PathLineTo(ImVec2(pos.x, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + } + + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic) { + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) { + return false; + } + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); + + const float square_sz = ImGui::GetFrameHeight(); + const ImVec2 pos = window->DC.CursorPos; + const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); + ImGui::ItemSize(total_bb, style.FramePadding.y); + if (!ImGui::ItemAdd(total_bb, id)) { + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return false; + } + + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(total_bb, id, &hovered, &held); + if (pressed) { + *v = !(*v); + ImGui::MarkItemEdited(id); + } + + const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); + ImGui::RenderNavHighlight(total_bb, id); + ImGui::RenderFrame(check_bb.Min, check_bb.Max, ImGui::GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); + ImU32 check_col = ImGui::GetColorU32(ImGuiCol_CheckMark); + ImU32 cross_col = ImGui::GetColorU32(ImVec4(0.50f, 0.50f, 0.50f, 1.00f)); + bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0; + if (mixed_value) { + // Undocumented tristate/mixed/indeterminate checkbox (#2644) + // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox) + ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); + window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); + } else if ((!disabled && *v) || (disabled && disabledGraphic == CheckboxGraphics::Checkmark)) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + ImGui::RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f); + } else if (disabled && disabledGraphic == CheckboxGraphics::Cross) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + RenderCross(window->DrawList, check_bb.Min + ImVec2(pad, pad), cross_col, square_sz - pad * 2.0f); + } + + ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y); + if (g.LogEnabled) { + ImGui::LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); + } + if (label_size.x > 0.0f) { + ImGui::RenderText(label_pos, label); + } + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return pressed; + } + + void ReEnableComponent(const char* disabledTooltipText) { + // End of disable region of previous component + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + } + + void DisableComponent(const float alpha) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); + } + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + bool changed = false; + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + bool val = (bool)CVarGetInteger(cvarName, defaultValue); + if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + return changed; + } + + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + bool changed = EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic, defaultValue); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementCombobox(const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + bool changed = false; + if (defaultIndex <= 0) { + defaultIndex = 0; + } + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + uint8_t selected = CVarGetInteger(cvarName, defaultIndex); + std::string comboName = std::string("##") + std::string(cvarName); + if (ImGui::BeginCombo(comboName.c_str(), comboArray[selected])) { + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == selected)) { + CVarSetInteger(cvarName, i); + selected = i; + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } + ImGui::EndCombo(); + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + + if (disabledValue >= 0 && selected != disabledValue) { + CVarSetInteger(cvarName, disabledValue); + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + + return changed; + } + + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + ImGui::Text(label); + s32 currentValue = CVarGetInteger(cvarName, defaultIndex); + +#ifdef __WIIU__ + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 40.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 60.0f); +#else + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 20.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 30.0f); +#endif + + bool changed = EnhancementCombobox(cvarName, comboArray, defaultIndex, disabled, disabledTooltipText, disabledValue); + + ImGui::PopItemWidth(); + return changed; + } + + void PaddedText(const char* text, bool padTop, bool padBottom) { + if (padTop) Spacer(0); + + ImGui::Text("%s", text); + + if (padBottom) Spacer(0); + } + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + int val = CVarGetInteger(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + ImGui::Text(text, val); + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + val--; + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderInt(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) + { + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + val++; + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + float val = CVarGetFloat(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (!isPercentage) { + ImGui::Text(text, val); + } else { + ImGui::Text(text, static_cast<int>(100 * val)); + } + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + if (isPercentage) { + val -= 0.01f; + } else { + val -= 0.1f; + } + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderFloat(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) { + if (isPercentage) { + val = roundf(val * 100) / 100; + } + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + if (isPercentage) { + val += 0.01f; + } else { + val += 0.1f; + } + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetFloat(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderFloat(text, id, cvarName, min, max, format, defaultValue, isPercentage, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id) { + /*Usage : + EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + First arg is the visible name of the Radio button + Second is the cvar name where MyID will be saved. + Note: the CVar name should be the same to each Buddies. + Example : + EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG); + EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER); + EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA); + */ + std::string make_invisible = "##" + std::string(text) + std::string(cvarName); + + bool ret = false; + int val = CVarGetInteger(cvarName, 0); + if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { + CVarSetInteger(cvarName, id); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + ret = true; + } + ImGui::SameLine(); + ImGui::Text("%s", text); + + return ret; + } + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) { + bool changed = false; + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Reset##" + std::string(cvarName) + "Reset"; + if (ImGui::Button(MakeInvisible.c_str())) { + colors->x = defaultcolors.x; + colors->y = defaultcolors.y; + colors->z = defaultcolors.z; + colors->w = has_alpha ? defaultcolors.w : 255.0f; + + Color_RGBA8 colorsRGBA; + colorsRGBA.r = defaultcolors.x; + colorsRGBA.g = defaultcolors.y; + colorsRGBA.b = defaultcolors.z; + colorsRGBA.a = has_alpha ? defaultcolors.w : 255.0f; + + CVarSetColor(cvarName, colorsRGBA); + CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); + return changed; + } + + void DrawLockColorCheckbox(const char* cvarName) { + std::string Cvar_Lock = std::string(cvarName) + "Lock"; + s32 lock = CVarGetInteger(Cvar_Lock.c_str(), 0); + std::string FullName = "Lock##" + Cvar_Lock; + EnhancementCheckbox(FullName.c_str(), Cvar_Lock.c_str()); + Tooltip("Prevents this color from being changed upon selecting \"Randomize all\""); + } + + void RainbowColor(const char* cvarName, ImVec4* colors) { + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Rainbow##" + std::string(cvarName) + "Rainbow"; + + EnhancementCheckbox(MakeInvisible.c_str(), Cvar_RBM.c_str()); + Tooltip("Cycles through colors on a timer\nOverwrites previously chosen color"); + } + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) { + Color_RGBA8 defaultColors; + defaultColors.r = default_colors.x; + defaultColors.g = default_colors.y; + defaultColors.b = default_colors.z; + defaultColors.a = default_colors.w; + + Color_RGBA8 cvarColor = CVarGetColor(cvarname, defaultColors); + + ColorArray.x = cvarColor.r / 255.0; + ColorArray.y = cvarColor.g / 255.0; + ColorArray.z = cvarColor.b / 255.0; + ColorArray.w = cvarColor.a / 255.0; + } + + void DrawFlagArray32(const std::string& name, uint32_t& flags) { + ImGui::PushID(name.c_str()); + for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint32_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray16(const std::string& name, uint16_t& flags) { + ImGui::PushID(name.c_str()); + for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint16_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray8(const std::string& name, uint8_t& flags) { + ImGui::PushID(name.c_str()); + for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint8_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + // V2 + + void PushStyleMenu(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::Colors::DarkGray); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::DarkGray); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); + } + + void PopStyleMenu() { + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(4); + } + + bool BeginMenu(const char* label, const ImVec4& color) { + bool dirty = false; + PushStyleMenu(color); + if (ImGui::BeginMenu(label)) { + dirty = true; + } + PopStyleMenu(); + return dirty; + } + + void PushStyleMenuItem(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0f, 15.0f)); + } + + void PopStyleMenuItem() { + ImGui::PopStyleVar(1); + ImGui::PopStyleColor(1); + } + + bool MenuItem(const char* label, const char* shortcut, const ImVec4& color) { + bool dirty = false; + PushStyleMenuItem(color); + if (ImGui::MenuItem(label, shortcut)) { + dirty = true; + } + PopStyleMenuItem(); + return dirty; + } + + void PushStyleButton(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleButton() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(4); + } + + bool Button(const char* label, const ButtonOptions& options) { + ImGui::BeginDisabled(options.disabled); + PushStyleButton(options.color); + bool dirty = ImGui::Button(label, options.size); + PopStyleButton(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + return dirty; + } + + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options) { + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + std::string buttonText = label; + bool dirty = false; + if (CVarGetInteger(cvarName, 0)) { + buttonText = ICON_FA_WINDOW_CLOSE " " + buttonText; + } else { + buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText; + } + if (Button(buttonText.c_str(), options)) { + windowPtr->ToggleVisibility(); + dirty = true; + } + ImGui::PopStyleVar(); + return dirty; + } + + void PushStyleCheckbox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleCheckbox() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(5); + } + + bool Checkbox(const char* label, bool* value, const CheckboxOptions& options) { + ImGui::PushID(label); + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::BeginDisabled(options.disabled); + PushStyleCheckbox(options.color); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } else if (options.labelPosition == LabelPosition::Above) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + } + } + dirty = ImGui::Checkbox(invisibleLabel, value); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(); + ImGui::SetCursorPosX(startX); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } + PopStyleCheckbox(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options) { + bool dirty = false; + bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); + if (Checkbox(label, &value, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleCombobox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + } + + void PopStyleCombobox() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(9); + } + + bool Combobox(const char* label, uint8_t* value, std::span<const char*, std::dynamic_extent> comboArray, const ComboboxOptions& options) { + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleCombobox(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().ItemSpacing.x * 2); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SetNextItemWidth(ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4 + ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::CalcTextSize(label).x + ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + float width = ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4; + ImGui::SameLine(ImGui::GetContentRegionAvail().x - width); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + } + if (ImGui::BeginCombo(invisibleLabel, comboArray[*value], options.flags)) { + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 10.0f)); + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == *value)) { + *value = i; + dirty = true; + } + } + } + ImGui::PopStyleVar(); + ImGui::EndCombo(); + } + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(startX); + ImGui::Text(label); + } + } + PopStyleCombobox(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, const ComboboxOptions& options) { + bool dirty = false; + uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex); + if (Combobox(label, &value, comboArray, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleSlider(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(1.0, 1.0, 1.0, 0.4f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(1.0, 1.0, 1.0, 0.5f)); + ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); + } + + void PopStyleSlider() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(6); + } + + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, *value); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, *value); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options) { + bool dirty = false; + int32_t value = CVarGetInteger(cvarName, defaultValue); + if (SliderInt(label, &value, min, max, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + float valueToDisplay = options.isPercentage ? *value * 100.0f : *value; + float maxToDisplay = options.isPercentage ? max * 100.0f : max; + float minToDisplay = options.isPercentage ? min * 100.0f : min; + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, valueToDisplay); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, valueToDisplay); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { + *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options) { + bool dirty = false; + float value = CVarGetFloat(cvarName, defaultValue); + if (SliderFloat(label, &value, min, max, options)) { + CVarSetFloat(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } +} diff --git a/src/port/ui/UIWidgets.h b/src/port/ui/UIWidgets.h new file mode 100644 index 000000000..63daa568f --- /dev/null +++ b/src/port/ui/UIWidgets.h @@ -0,0 +1,210 @@ +#pragma once + +#include <string> +#include <vector> +#include <span> +#include <stdint.h> +#define IMGUI_DEFINE_MATH_OPERATORS +#include <ImGui/imgui.h> +#include <libultraship/libultraship.h> + +namespace UIWidgets { + + struct TextFilters { + static int FilterNumbers(ImGuiInputTextCallbackData* data) { + if (data->EventChar < 256 && strchr("1234567890", (char)data->EventChar)) { + return 0; + } + return 1; + } + + static int FilterAlphaNum(ImGuiInputTextCallbackData* data) { + const char* alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789"; + if (data->EventChar < 256 && strchr(alphanum, (char)data->EventChar)) { + return 0; + } + return 1; + } + + }; + + // MARK: - Enums + + enum class CheckboxGraphics { + Cross, + Checkmark, + None + }; + constexpr float maxSliderWidth = 260.0f; +#ifdef __SWITCH__ + constexpr float sliderButtonWidth = 42.0f; +#elif defined(__WIIU__) + constexpr float sliderButtonWidth = 60.0f; +#else + constexpr float sliderButtonWidth = 30.0f; +#endif + + char* WrappedText(const char* text, unsigned int charactersPerLine = 60); + char* WrappedText(const std::string& text, unsigned int charactersPerLine); + + void SetLastItemHoverText(const std::string& text); + void SetLastItemHoverText(const char* text); + + void InsertHelpHoverText(const std::string& text); + void InsertHelpHoverText(const char* text); + + void Tooltip(const char* text); + void Spacer(float height); + void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic); + + void ReEnableComponent(const char* disabledTooltipText); + void DisableComponent(const float alpha); + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + + bool EnhancementCombobox(const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + + void PaddedText(const char* text, bool padTop = true, bool padBottom = true); + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id); + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha); + bool DrawRandomizeColorButton(const char* cvarName, ImVec4* colors); + void DrawLockColorCheckbox(const char* cvarName); + void RainbowColor(const char* cvarName, ImVec4* colors); + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha); + bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha = false, bool TitleSameLine = false); + + void DrawFlagArray32(const std::string& name, uint32_t& flags); + void DrawFlagArray16(const std::string& name, uint16_t& flags); + void DrawFlagArray8(const std::string& name, uint8_t& flags); + + // V2 + namespace Colors { + const ImVec4 White = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + const ImVec4 Gray = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); + const ImVec4 DarkGray = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); + const ImVec4 Indigo = ImVec4(0.24f, 0.31f, 0.71f, 1.0f); + const ImVec4 Red = ImVec4(0.5f, 0.0f, 0.0f, 1.0f); + const ImVec4 DarkRed = ImVec4(0.3f, 0.0f, 0.0f, 1.0f); + const ImVec4 LightGreen = ImVec4(0.0f, 0.7f, 0.0f, 1.0f); + const ImVec4 Green = ImVec4(0.0f, 0.5f, 0.0f, 1.0f); + const ImVec4 DarkGreen = ImVec4(0.0f, 0.3f, 0.0f, 1.0f); + const ImVec4 Yellow = ImVec4(1.0f, 0.627f, 0.0f, 1.0f); + }; + + namespace Sizes { + const ImVec2 Inline = ImVec2(0.0f, 0.0f); + const ImVec2 Fill = ImVec2(-1.0f, 0.0f); + } + + enum LabelPosition { + Near, + Far, + Above, + None, + Within, + }; + + enum ComponentAlignment { + Left, + Right, + }; + + void PushStyleMenu(const ImVec4& color = Colors::Indigo); + void PopStyleMenu(); + bool BeginMenu(const char* label, const ImVec4& color = Colors::Indigo); + + void PushStyleMenuItem(const ImVec4& color = Colors::Indigo); + void PopStyleMenuItem(); + bool MenuItem(const char* label, const char* shortcut = NULL, const ImVec4& color = Colors::Indigo); + + struct ButtonOptions { + const ImVec4 color = Colors::Gray; + const ImVec2 size = Sizes::Fill; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + }; + + void PushStyleButton(const ImVec4& color = Colors::Gray); + void PopStyleButton(); + bool Button(const char* label, const ButtonOptions& options = {}); + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<LUS::GuiWindow> windowPtr, const ButtonOptions& options = {}); + + struct CheckboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool defaultValue = false; // Only applicable to CVarCheckbox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Near; + }; + + void PushStyleCheckbox(const ImVec4& color = Colors::Indigo); + void PopStyleCheckbox(); + bool Checkbox(const char* label, bool* v, const CheckboxOptions& options = {}); + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options = {}); + + struct ComboboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + uint32_t defaultIndex = 0; // Only applicable to CVarCombobox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + ImGuiComboFlags flags = 0; + }; + + void PushStyleCombobox(const ImVec4& color = Colors::Indigo); + void PopStyleCombobox(); + bool Combobox(const char* label, uint8_t* value, std::span<const char*, std::dynamic_extent> comboArray, const ComboboxOptions& options = {}); + bool CVarCombobox(const char* label, const char* cvarName, std::span<const char*, std::dynamic_extent> comboArray, const ComboboxOptions& options = {}); + + struct IntSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%d"; + const uint32_t step = 1; + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + struct FloatSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%f"; + const float step = 0.01f; + bool isPercentage = false; // Multiplies visual value by 100 + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + void PushStyleSlider(const ImVec4& color = Colors::Indigo); + void PopStyleSlider(); + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options = {}); + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options = {}); + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options = {}); + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options = {}); +}
\ No newline at end of file diff --git a/src/profiler.c b/src/profiler.c index 2bb9f5b97..1066c3964 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include "profiler.h" #include <mk64.h> diff --git a/src/racing/actors.c b/src/racing/actors.c index 4f919a22e..5013b0878 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -1,12 +1,11 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> -#include <PR/os.h> #include <mk64.h> #include <sounds.h> #include <common_structs.h> #include <actor_types.h> #include <defines.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include "code_800029B0.h" #include "main.h" @@ -396,7 +395,7 @@ void func_802977E4(Player *arg0) { // Invert green and red on green shell texture void init_red_shell_texture(void) { s16 *red_shell_texture = (s16 *) &gTLUTRedShell[0]; - s16 *green_shell_texture = (s16 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(common_tlut_green_shell)] + SEGMENT_OFFSET(common_tlut_green_shell)); + s16 *green_shell_texture = (s16 *) common_tlut_green_shell; s16 color_pixel, red_color, green_color, blue_color, alpha_color; s32 i; for (i = 0; i < 256; i++) { @@ -469,10 +468,8 @@ void render_cows(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { struct ActorSpawnData *var_s5; Vec3f sp88; u32 soundThing = SOUND_ARG_LOAD(0x19, 0x01, 0x90, 0x4D); - s32 segment = SEGMENT_NUMBER2(d_course_moo_moo_farm_cow_spawn); - s32 offset = SEGMENT_OFFSET(d_course_moo_moo_farm_cow_spawn); - var_t1 = (struct ActorSpawnData*)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_t1 = d_course_moo_moo_farm_cow_spawn; D_8015F704 = 6.4e7f; gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); @@ -537,9 +534,7 @@ void render_cows(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { void evaluate_collision_player_palm_trees(Player *player) { Vec3f pos; - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *data = (struct UnkActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *data = d_course_dks_jungle_parkway_tree_spawn; while (data->pos[0] != END_OF_SPAWN_DATA) { pos[0] = data->pos[0] * gCourseDirection; @@ -572,9 +567,7 @@ void evaluate_collision_players_palm_trees(void) { } void func_80298D10(void) { - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *temp_v1 = (struct UnkActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *temp_v1 = d_course_dks_jungle_parkway_tree_spawn; while (temp_v1->pos[0] != END_OF_SPAWN_DATA) { temp_v1->pos[1] = temp_v1->unk8; @@ -584,9 +577,7 @@ void func_80298D10(void) { } void render_palm_trees(Camera *camera, Mat4 arg1, UNUSED struct Actor *actor) { - s32 segment = SEGMENT_NUMBER2(d_course_dks_jungle_parkway_tree_spawn); - s32 offset = SEGMENT_OFFSET(d_course_dks_jungle_parkway_tree_spawn); - struct UnkActorSpawnData *var_s1 = (struct UnkActorSpawnData *)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct UnkActorSpawnData *var_s1 = d_course_dks_jungle_parkway_tree_spawn; UNUSED s32 pad; Vec3f spD4; f32 var_f22; @@ -803,9 +794,7 @@ UNUSED void func_8029AE14() { #include "actors/falling_rock/render.inc.c" void spawn_piranha_plants(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct PiranhaPlant *temp_v1; UNUSED s32 pad; Vec3f startingPos; @@ -835,9 +824,7 @@ void spawn_piranha_plants(struct ActorSpawnData *spawnData) { } void spawn_palm_trees(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; struct PalmTree *temp_v1; Vec3f startingPos; Vec3f startingVelocity; @@ -873,10 +860,8 @@ void spawn_foliage(struct ActorSpawnData *arg0) { s16 actorType; struct Actor *temp_s0; struct ActorSpawnData *var_s3; - s32 segment = SEGMENT_NUMBER2(arg0); - s32 offset = SEGMENT_OFFSET(arg0); - var_s3 = (struct ActorSpawnData *)VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s3 = arg0; vec3f_set(velocity, 0.0f, 0.0f, 0.0f); rotation[0] = 0x4000; rotation[1] = 0; @@ -946,14 +931,12 @@ void spawn_foliage(struct ActorSpawnData *arg0) { } void spawn_all_item_boxes(struct ActorSpawnData *spawnData) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); s16 temp_s1; f32 temp_f0; Vec3f startingPos; Vec3f startingVelocity; Vec3s startingRot; - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + struct ActorSpawnData *temp_s0 = spawnData; //struct ItemBox *itemBox; if ((gModeSelection == TIME_TRIALS) || (gPlaceItemBoxes == 0)) { return; } @@ -1157,7 +1140,7 @@ void spawn_course_actors(void) { /** * @brief Loads actor textures, course specific actor textures. * Calls to init_course_vehicles and place_course_actors - * + * */ void init_actors_and_load_textures(void) { set_segment_base_addr(3, (void *) gNextFreeMemoryAddress); @@ -1448,10 +1431,8 @@ struct test { UNUSED void prototype_actor_spawn_data(Player *player, uintptr_t arg1) { Vec3f sp64; struct test *var_s0; - s32 segment = SEGMENT_NUMBER2(arg1); - s32 offset = SEGMENT_OFFSET(arg1); - var_s0 = (struct test *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (struct test *) arg1; while (var_s0->thing[0] != END_OF_SPAWN_DATA) { sp64[0] = var_s0->thing[0] * gCourseDirection; sp64[1] = var_s0->thing[1]; @@ -1555,9 +1536,9 @@ bool collision_mario_sign(Player *player, struct Actor *marioRacewaySign) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x1A)); } } - return TRUE; + return true; } - return FALSE; + return false; } bool collision_piranha_plant(Player *player, struct PiranhaPlant *plant) { @@ -1571,9 +1552,9 @@ bool collision_piranha_plant(Player *player, struct PiranhaPlant *plant) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0xA0, 0x52)); } } - return TRUE; + return true; } - return FALSE; + return false; } bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { @@ -1588,34 +1569,34 @@ bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { x_dist = egg->pos[0] - player->pos[0]; if ((x_dist < minDist) && (x_dist < -maxDist)) { - return FALSE; + return false; } if (x_dist > maxDist) { - return FALSE; + return false; } z_dist = egg->pos[2] - player->pos[2]; if ((z_dist < minDist) && (z_dist < -maxDist)) { - return FALSE; + return false; } if (z_dist > maxDist) { - return FALSE; + return false; } xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); if (xz_dist > maxDist) { - return FALSE; + return false; } func_802977B0(player); y_dist = player->pos[1] - egg->pos[1]; if (y_dist < minDist) { - return FALSE; + return false; } totalBox = player->boundingBoxSize + egg->boundingBoxSize; if (totalBox < xz_dist) { - return FALSE; + return false; } if ((player->type & PLAYER_HUMAN) != 0) { @@ -1634,7 +1615,7 @@ bool collision_yoshi_egg(Player *player, struct YoshiValleyEgg *egg) { apply_hit_sound_effect(player, player - gPlayerOne); } - return TRUE; + return true; } bool collision_tree(Player *player, struct Actor *actor) { @@ -1654,33 +1635,33 @@ bool collision_tree(Player *player, struct Actor *actor) { var_f16 = actor->unk_08; x_dist = actor->pos[0] - player->pos[0]; if ((x_dist < 0.0f) && (x_dist < -var_f16)) { - return FALSE; + return false; } if (var_f16 < x_dist) { - return FALSE; + return false; } z_dist = actor->pos[2] - player->pos[2]; if ((z_dist < 0.0f) && (z_dist < -var_f16)) { - return FALSE; + return false; } if (var_f16 < z_dist) { - return FALSE; + return false; } y_dist = player->pos[1] - actor->pos[1]; if (y_dist < 0.0f) { - return FALSE; + return false; } if ((f32) actor->state < y_dist) { - return FALSE; + return false; } xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); if (var_f16 < xz_dist) { - return FALSE; + return false; } func_802977B0(player); var_f16 = player->boundingBoxSize + actor->boundingBoxSize; if (var_f16 < xz_dist) { - return FALSE; + return false; } sp48 = player->velocity[0]; sp44 = player->velocity[2]; @@ -1689,7 +1670,7 @@ bool collision_tree(Player *player, struct Actor *actor) { actor->flags |= 0x400; func_800C98B8(player->pos, player->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x10)); func_800C90F4(player - gPlayerOne, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D)); - return TRUE; + return true; } if (!(player->type & PLAYER_INVISIBLE_OR_BOMB)) { func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x70, 0x18)); @@ -1720,7 +1701,7 @@ bool collision_tree(Player *player, struct Actor *actor) { player->pos[2] = actorPos[2] - (z_dist * var_f16 * 1.2f); player->velocity[0] = 0; player->velocity[2] = 0; - return TRUE; + return true; } temp_f12 = ((x_dist * sp48) + (z_dist * sp44)) / temp_f0_4; temp_f12 = temp_f0_4 * temp_f12 * 1.5f; @@ -1730,7 +1711,7 @@ bool collision_tree(Player *player, struct Actor *actor) { player->pos[0] += x_dist * temp_f2 * 0.5f; player->pos[2] += z_dist * temp_f2 * 0.5f; } - return TRUE; + return true; } bool query_collision_player_vs_actor_item(Player *arg0, struct Actor *arg1) { diff --git a/src/racing/actors.h b/src/racing/actors.h index 8c0b2e2b2..a9cb13830 100644 --- a/src/racing/actors.h +++ b/src/racing/actors.h @@ -83,13 +83,13 @@ void destroy_actor(struct Actor*); s16 try_remove_destructable_item(Vec3f, Vec3s, Vec3f, s16); s16 add_actor_to_empty_slot(Vec3f, Vec3s, Vec3f, s16); s16 spawn_actor_at_pos(Vec3f, s16); -s32 query_and_resolve_collision_player_actor(Player*, Vec3f, f32, f32, f32); -s32 collision_mario_sign(Player*, struct Actor*); -s32 collision_piranha_plant(Player*, struct PiranhaPlant*); -s32 collision_yoshi_egg(Player*, struct YoshiValleyEgg*); -s32 collision_tree(Player*, struct Actor*); -s32 query_collision_player_vs_actor_item(Player*, struct Actor*); -s32 query_collision_actor_vs_actor(struct Actor*, struct Actor*); +bool query_and_resolve_collision_player_actor(Player*, Vec3f, f32, f32, f32); +bool collision_mario_sign(Player*, struct Actor*); +bool collision_piranha_plant(Player*, struct PiranhaPlant*); +bool collision_yoshi_egg(Player*, struct YoshiValleyEgg*); +bool collision_tree(Player*, struct Actor*); +bool query_collision_player_vs_actor_item(Player*, struct Actor*); +bool query_collision_actor_vs_actor(struct Actor*, struct Actor*); void destroy_destructable_actor(struct Actor*); void play_sound_on_destructible_actor_collision(struct Actor*, struct Actor*); void evaluate_actor_collision_between_two_destructible_actors(struct Actor*, struct Actor*); diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index a28d64215..0b3df79de 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <actor_types.h> @@ -315,19 +315,19 @@ void update_actor_banana_bunch(struct BananaBunchParent *banana_bunch) { bool is_shell_exist(s16 arg0) { struct ShellActor *actor; if (arg0 < 0) { - return FALSE; + return false; } actor = (struct ShellActor*) &gActorList[arg0]; if (actor->type == ACTOR_GREEN_SHELL) { if (actor->state == TRIPLE_GREEN_SHELL) { - return TRUE; + return true; } - return FALSE; + return false; } if (actor->state == TRIPLE_RED_SHELL) { - return TRUE; + return true; } - return FALSE; + return false; } void update_actor_triple_shell(TripleShellParent *parent, s16 shellType) { @@ -606,12 +606,12 @@ s32 use_green_shell_item(Player *player) { // rotate to match player orientation mtxf_translate_vec3f_mat3(startingPos, player->orientationMatrix); - + // move to player position startingPos[0] += player->pos[0]; startingPos[1] += player->pos[1]; startingPos[2] += player->pos[2]; - + // spawn the shell actorIndex = add_actor_to_empty_slot(startingPos, startingRot, startingVelocity, ACTOR_GREEN_SHELL); if (actorIndex < 0) { @@ -848,8 +848,8 @@ s32 use_banana_item(Player *player) { /** * Strikes players with thunder - * - * @param Activating player (not to be struck) + * + * @param Activating player (not to be struck) */ void use_thunder_item(Player *player) { s32 index; @@ -932,7 +932,7 @@ void check_player_use_item(void) { for (player = &gPlayers[0], loopController = &gControllers[0], target = &gControllers[4]; loopController != target; player++, loopController++) { controller = loopController; - if (prevent_item_use(player) == FALSE) { + if (prevent_item_use(player) == false) { if((player->type & PLAYER_INVISIBLE_OR_BOMB) != 0){ if ((player - gPlayerTwo) == 0) { controller = gControllerSix; diff --git a/src/racing/collision.c b/src/racing/collision.c index f42acaf5a..1f3b94a7a 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -1,6 +1,6 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <mk64.h> #include <common_structs.h> #include <actor_types.h> @@ -10,16 +10,11 @@ #include "math_util.h" #include "code_800029B0.h" -#pragma intrinsic (sqrtf) - // Used to delete the choco mountain guard rail void nullify_displaylist(uintptr_t addr) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - Gfx *macro; - macro = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + macro = (Gfx *) addr; macro->words.w0 = (G_ENDDL << 24); macro->words.w1 = 0; } @@ -127,7 +122,7 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f10; f32 temp_f0_3; f32 temp_f2_2; - s32 bool = 1; + s32 flag = 1; if (surfaceMap->gravity < -0.9f) return 0; @@ -160,7 +155,7 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -170,22 +165,22 @@ s32 func_802AAE4C(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f10 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f10 * temp_f0_3) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_2 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if (temp_f2_2 != 0) { if ((temp_f0_3 * temp_f2_2) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } temp_f0_5 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) @@ -222,7 +217,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 x3; f32 y3; UNUSED f32 pad2[1]; - + UNUSED f32 pad3[5]; f32 x2; f32 y2; @@ -232,7 +227,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 temp_f2_2; f32 temp_f0_2; f32 temp_f2_3; - s32 bool = 1; + s32 flag = 1; if (surfaceMap->vtx31 > posX) { return 0; @@ -272,29 +267,29 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { temp_f0_2 = (y2 - posY) * (x3 - posX) - (x2 - posX) * (y3 - posY); if (!temp_f0_2) { temp_f2_3 = (y3 - posY) * (x1 - posX) - (x3 - posX) * (y1 - posY); if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((y3 - posY) * (x1 - posX)) - ((x3 - posX) * (y1 - posY)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } temp_f0_4 = ((surfaceMap->height * posX) + (surfaceMap->gravity * posY) + (surfaceMap->rotation * posZ) + surfaceMap->height2) - boundingBoxSize; @@ -325,7 +320,7 @@ s32 func_802AB288(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ, u16 index) { mk64_surface_map_ram *surfaceMap = &gSurfaceMap[index]; - s32 bool = 1; + bool flag = 1; UNUSED f32 pad[7]; f32 sp20; f32 temp_f8; @@ -375,7 +370,7 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -385,23 +380,23 @@ s32 func_802AB6C4(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if ((temp_f2_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((sp20 - posY) * (sp24 - posZ)) - ((temp_f8 - posZ) * (temp_f4 - posY)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (!bool) { + if (!flag) { return 0; } @@ -447,7 +442,7 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { f32 temp_f2_2; f32 temp_f2_3; f32 temp_f0_2; - s32 bool = 1; + s32 flag = 1; x1 = surfaceMap->vtxPoly1->v.ob[0]; z1 = surfaceMap->vtxPoly1->v.ob[2]; @@ -467,29 +462,29 @@ s32 func_802ABB04(f32 posX, f32 posZ, u16 index) { temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } else { temp_f0_2 = (z2 - posZ) * (x3 - posX) - (x2 - posX) * (z3 - posZ); if (!temp_f0_2) { temp_f2_3 = (z3 - posZ) * (x1 - posX) - (x3 - posX) * (z1 - posZ); if (temp_f2_2 * temp_f2_3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((temp_f2_2 * temp_f0_2) < 0.0f) { - bool = 0; + flag = 0; } else { temp_f2_3 = ((z3 - posZ) * (x1 - posX)) - ((x3 - posX) * (z1 - posZ)); if (temp_f2_3 != 0) { if ((temp_f0_2 * temp_f2_3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - return bool; + return flag; } s8 get_surface_type(u16 index) { @@ -777,7 +772,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize f32 area; f32 area2; f32 area3; - s32 bool = 1; + s32 flag = 1; if (tile->vtx31 > x1) { return 0; @@ -810,7 +805,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize area2 = (z3 - z1) * (x4 - x1) - (x3 - x1) * (z4 - z1); area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -822,22 +817,22 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (z4- z1) * (x2 - x1) - (x4 - x1) * (z2 - z1); if (area3 != 0) { if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -884,11 +879,11 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, UNUSED s32 pad2[3]; f32 temp_f0_4; f32 temp_f4_2; - UNUSED s32 pad3[2]; + UNUSED s32 pad3[2]; f32 area; f32 area2; f32 area3; - s32 bool = 1; + s32 flag = 1; if (tile->vtx31 > x1) { return 0; } @@ -925,7 +920,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -936,23 +931,23 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if ((area * area3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (y4 - y1) * (x2 - x1) - (x4 - x1) * (y2 - y1); if (area3 != 0) { if ((area2 * area3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -1054,7 +1049,7 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, */ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) { mk64_surface_map_ram *tile = &gSurfaceMap[arg5]; - s32 bool = 1; + s32 flag = 1; UNUSED s32 pad[7]; f32 y4; f32 z4; @@ -1065,7 +1060,7 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, UNUSED s32 pad3[2]; f32 temp_f0_4; f32 temp_f4_2; - UNUSED s32 pad4[2]; + UNUSED s32 pad4[2]; f32 area; f32 area2; f32 area3; @@ -1106,7 +1101,7 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if (area2 * area3 < 0.0f) { - bool = 0; + flag = 0; } } else { @@ -1117,23 +1112,23 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, if ((area * area3) < 0.0f) { - bool = 0; + flag = 0; } } else { if ((area * area2) < 0.0f) { - bool = 0; + flag = 0; } else { area3 = (y4 - y1) * (z2 - z1) - (z4 - z1) * (y2 - y1); if (area3 != 0) { if ((area2 * area3) < 0.0f) { - bool = 0; + flag = 0; } } } } } - if (bool == 0) { + if (flag == 0) { return 0; } @@ -1246,7 +1241,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 u16 flags = 0; s32 temp1; s32 temp2; - + u16 i; collision->unk30 = 0; @@ -1341,7 +1336,7 @@ u16 func_802AD950(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 } } phi_s2++; - + } return flags; } @@ -1386,7 +1381,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, if (var_s4 == (0x4000 | 0x2000 | 0x8000)) { return var_s4; } - + temp_f4 = (s32) gCourseMaxX - gCourseMinX; temp_f6 = (s32) gCourseMaxZ - gCourseMinZ; @@ -1396,7 +1391,7 @@ u16 func_802ADDC8(Collision* collision, f32 boundingBoxSize, f32 posX, f32 posY, temp_f10 = (posX - gCourseMinX) / temp1; temp_f16 = (posZ - gCourseMinZ) / temp2; - + if (temp_f10 < 0) { return 0; } @@ -1577,10 +1572,10 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI tile->vtxPoly1 = vtx1; tile->vtxPoly2 = vtx2; tile->vtxPoly3 = vtx3; - if ((tile->vtxPoly1->v.flag == 4) && - (tile->vtxPoly2->v.flag == 4) && + if ((tile->vtxPoly1->v.flag == 4) && + (tile->vtxPoly2->v.flag == 4) && (tile->vtxPoly3->v.flag == 4)) { - + return; } @@ -1680,7 +1675,7 @@ void func_802AE434(Vtx *vtx1, Vtx *vtx2, Vtx *vtx3, s8 surfaceType, u16 sectionI if (maxZ > gCourseMaxZ) { gCourseMaxZ = maxZ; } - + tile->height = normalX; tile->gravity = normalY; tile->rotation = normalZ; @@ -1782,7 +1777,7 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { vtx2 = vtxBuffer[vert2]; vtx3 = vtxBuffer[vert3]; vtx4 = vtxBuffer[vert4]; - + // Triangle 1 func_802AE434(vtx1, vtx2, vtx3, surfaceType, sectionId); // Triangle 2 @@ -1794,9 +1789,7 @@ void set_vtx_from_quadrangle(u32 line, s8 surfaceType, u16 sectionId) { */ void set_vtx_buffer(uintptr_t addr, u32 numVertices, u32 bufferIndex) { u32 i; - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); - Vtx *vtx = (Vtx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Vtx *vtx = (Vtx *) addr; for (i = 0; i < numVertices; i++) { vtxBuffer[bufferIndex] = vtx; vtx++; @@ -1986,7 +1979,7 @@ void set_vertex_data_with_default_section_id(Gfx *gfx, s8 surfaceType) { extern u32 D_8015F58C; /** - * Recursive search and set for vertex data + * Recursive search and set for vertex data */ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { s32 opcode; @@ -1994,9 +1987,7 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { uintptr_t hi; s32 i; - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) addr; D_8015F6FA = 0; D_8015F6FC = 0; @@ -2036,15 +2027,13 @@ void find_and_set_vertex_data(Gfx *addr, s8 surfaceType, u16 sectionId) { * Search for G_SETTILESIZE and set its args. */ void find_and_set_tile_size(uintptr_t addr, s32 uls, s32 ult) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) addr; u32 opcode; uls = (uls << 12) & 0xFFF000; ult &= 0xFFF; - while(TRUE) { + while(true) { opcode = GFX_GET_OPCODE(gfx->words.w0); @@ -2060,10 +2049,8 @@ void find_and_set_tile_size(uintptr_t addr, s32 uls, s32 ult) { } void set_vertex_colours(uintptr_t addr, u32 vertexCount, UNUSED s32 vert3, s8 alpha, u8 red, u8 green, u8 blue) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); s32 i; - Vtx *vtx = (Vtx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Vtx *vtx = (Vtx *) addr; for (i = 0; (u32)i < vertexCount; i++) { if (red) { @@ -2080,14 +2067,12 @@ void set_vertex_colours(uintptr_t addr, u32 vertexCount, UNUSED s32 vert3, s8 al * Recursive search for vertices and set their colour values. */ void find_vtx_and_set_colours(uintptr_t displayList, s8 alpha, u8 red, u8 green, u8 blue) { - s32 segment = SEGMENT_NUMBER2(displayList); - s32 offset = SEGMENT_OFFSET(displayList); - Gfx *gfx = (Gfx *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx *gfx = (Gfx *) displayList; uintptr_t lo; uintptr_t hi; s32 opcode; - while(TRUE) { + while(true) { lo = gfx->words.w0; hi = gfx->words.w1; opcode = GFX_GET_OPCODE(lo); @@ -2122,7 +2107,7 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP f32 cornerPos3; f32 boundingBoxSize; f32 temp_f0; - + s32 temp_v0_2; s32 temp_v1; @@ -2183,7 +2168,7 @@ u16 process_collision(Player *player, KartBoundingBoxCorner *corner, f32 cornerP } // If the surface flags are not set then try setting them. - + temp_v0_2 = (s32) gCourseMaxX - gCourseMinX; temp_v1 = (s32) gCourseMaxZ - gCourseMinZ; diff --git a/src/racing/math_util.c b/src/racing/math_util.c index 3305cb931..2590f0408 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <mk64.h> #include <macros.h> #include <math_util.h> @@ -127,7 +127,7 @@ void *vec3f_copy_return(Vec3f dest, Vec3f src) { dest[1] = src[1]; dest[2] = src[2]; //! @warning function returns address of local variable - return &dest; + return &dest; } void vec3s_copy(Vec3s dest, Vec3s src) { @@ -422,8 +422,6 @@ void func_802B5D30(s16 arg0, s16 arg1, s32 arg2) { } void func_802B5D64(uintptr_t addr, s16 arg1, s16 arg2, s32 arg3) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); UNUSED s32 pad; f32 sp48; f32 sp44; @@ -434,7 +432,7 @@ void func_802B5D64(uintptr_t addr, s16 arg1, s16 arg2, s32 arg3) { s8 sp2C[3]; Lights1 *var_s0; - var_s0 = (Lights1 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (Lights1 *) addr; sp48 = sins(arg2); sp44 = coss(arg2); sp40 = sins(arg1); @@ -1154,8 +1152,6 @@ f32 is_within_render_distance(Vec3f cameraPos, Vec3f objectPos, u16 orientationY // No idea if arg1 is actually a Mat4 or not, but since this function is unused // its impossible to know with certainty either way, very close of func_802B5D64 UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg4) { - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); UNUSED s32 pad; Vec3f sp40; s8 sp3C[3]; @@ -1163,7 +1159,7 @@ UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg UNUSED s32 pad2[3]; Lights1 *var_s0; - var_s0 = (Lights1 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + var_s0 = (Lights1 *) addr; sins(arg3); coss(arg3); sins(arg2); diff --git a/src/racing/math_util.h b/src/racing/math_util.h index f3ec26b3f..6b7159556 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -1,7 +1,7 @@ #ifndef MATH_UTIL_H #define MATH_UTIL_H -#include <PR/ultratypes.h> +#include <libultra/types.h> //#define sins(x) gSineTable[(u16) (x) >> 4] diff --git a/src/racing/memory.c b/src/racing/memory.c index d2d352d62..f453c3262 100644 --- a/src/racing/memory.c +++ b/src/racing/memory.c @@ -1,5 +1,5 @@ -#include <ultra64.h> -#include <PR/ultratypes.h> +#include <libultraship.h> +#include <libultra/types.h> #include <macros.h> #include <common_structs.h> #include <segments.h> @@ -31,7 +31,7 @@ s32 memoryPadding[2]; * @brief Returns the address of the next available memory location and updates the memory pointer * to reference the next location of available memory based provided size to allocate. * @param size of memory to allocate. - * @return Address of free memory + * @return Address of free memory */ void *get_next_available_memory_addr(u32 size) { u32 *freeSpace = (u32 *)gNextFreeMemoryAddress; @@ -84,7 +84,7 @@ void move_segment_table_to_dmem(void) { /** * @brief Sets the starting location for allocating memory and calculates pool size. - * + * * Default memory size, 701.984 Kilobytes. */ void initialize_memory_pool(uintptr_t poolStart, uintptr_t poolEnd) { @@ -245,7 +245,7 @@ UNUSED void *func_802A80B0(u8 *dest, u8 *srcStart, u8 *srcEnd) { void *addr; u32 size = srcStart - dest; addr = main_pool_alloc(size, (u32) srcEnd); - + if (addr != 0) { osInvalDCache(addr, size); @@ -349,7 +349,7 @@ UNUSED s32 func_802A8348(s32 arg0, s32 arg1, s32 arg2) { UNUSED void *pad; uintptr_t oldAddr; void *newAddr; - + offset = ALIGN16(arg1 * arg2); oldAddr = gNextFreeMemoryAddress; newAddr = (void *) (oldAddr + offset); @@ -357,7 +357,7 @@ UNUSED s32 func_802A8348(s32 arg0, s32 arg1, s32 arg2) { osInvalDCache(newAddr, offset); osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_other_texturesSegmentRomStart[SEGMENT_OFFSET(arg0)], newAddr, offset, &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1); - + func_80040030((u8 *) newAddr, (u8 *) oldAddr); gNextFreeMemoryAddress += offset; return oldAddr; @@ -370,7 +370,7 @@ UNUSED u8 *func_802A841C(u8* arg0, s32 arg1, s32 arg2) { temp_a0 = temp_v0 + arg2; arg1 = ALIGN16(arg1); arg2 = ALIGN16(arg2); - + osInvalDCache(temp_a0, arg1); osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_other_texturesSegmentRomStart[SEGMENT_OFFSET(arg0)],temp_a0, arg1, &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, 1); @@ -458,10 +458,8 @@ void func_802A86A8(CourseVtx *data, u32 arg1) { void decompress_vtx(CourseVtx *arg0, u32 vertexCount) { s32 size = ALIGN16(vertexCount * 0x18); - u32 segment = SEGMENT_NUMBER2(arg0); - u32 offset = SEGMENT_OFFSET(arg0); void *freeSpace; - u8 *vtxCompressed = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + u8 *vtxCompressed = arg0; UNUSED s32 pad; freeSpace = (void *) gNextFreeMemoryAddress; @@ -684,7 +682,7 @@ void unpack_tile_sync(Gfx *gfx, u8 *args, s8 opcode) { lo = (G_SETTILE << 24) | (fmt << 21) | (siz << 19) | (line << 9) | tmem; hi = ((cmt) << 18) | ((maskt) << 14) | ((cms) << 8) | ((masks) << 4); - + gfx[sGfxSeekPosition].words.w0 = lo; gfx[sGfxSeekPosition].words.w1 = hi; sGfxSeekPosition++; @@ -954,16 +952,14 @@ UNUSED void func_802A9AEC(void) { * The opcodes range from 0 to 87 which are used to run the relevant unpack function. * The file pointer increments when arguments are used. This way, * displaylist_unpack will always read an opcode and not an argument by accident. - * + * * @warning opcodes that do not contain a definition in the switch are ignored. If an undefined opcode * contained arguments the unpacker might try to unpack those arguments. * This issue is prevented so long as the packed file adheres to correct opcodes and unpack code * increments the file pointer the correct number of times. */ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 arg2) { - uintptr_t segment = SEGMENT_NUMBER2(data); - uintptr_t offset = SEGMENT_OFFSET(data); - u8 *packed_dl = VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + u8 *packed_dl = data; Gfx *gfx; u32 addr; @@ -977,14 +973,14 @@ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 a sGfxSeekPosition = 0; sPackedSeekPosition = 0; - while(TRUE) { + while(true) { // Seek to the next byte opcode = packed_dl[sPackedSeekPosition++]; // Break when the eof has been reached denoted by opcode 0xFF if (opcode == 0xFF) break; - + switch (opcode) { case 0x0: unpack_lights(gfx, packed_dl, opcode); @@ -1036,7 +1032,7 @@ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 a break; case 0x10: unpack_lights(gfx, packed_dl, opcode); - break; + break; case 0x11: unpack_lights(gfx, packed_dl, opcode); break; @@ -1263,10 +1259,8 @@ struct UnkStr_802AA7C8 { }; void decompress_textures(u32 *arg0) { - u32 segment = SEGMENT_NUMBER2(arg0); - u32 offset = SEGMENT_OFFSET(arg0); struct UnkStr_802AA7C8 *phi_s0 = - (struct UnkStr_802AA7C8 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + (struct UnkStr_802AA7C8 *) arg0; struct UnkStr_802AA7C8 *temp_s0; u32 temp_t2; u8 *temp_a0; @@ -1275,7 +1269,7 @@ void decompress_textures(u32 *arg0) { phi_v0 = 0; temp_s0 = phi_s0; - while (TRUE) { + while (true) { temp_a0 = phi_s0->unk0; if ((temp_a0) == 0) { break; @@ -1287,7 +1281,7 @@ void decompress_textures(u32 *arg0) { gHeapEndPtr -= phi_v0; sp20 = gHeapEndPtr; - while (TRUE) { + while (true) { temp_a0 = phi_s0->unk0; if ((temp_a0) == 0) { break; diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 1c690e512..9b3babac4 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <common_structs.h> @@ -836,7 +836,7 @@ void func_8028F970(void) { return; } } - + if (gEnableDebugMode) { if (gModeSelection == BATTLE) { // do stuff? @@ -1108,7 +1108,7 @@ void func_802903B0(void) { void func_802903D8(Player *playerOne, Player *playerTwo) { f32 sp70 = (playerOne->boundingBoxSize + playerTwo->boundingBoxSize) - 5.0f; f32 temp_f0; - f32 sp74; + f32 sp74; Vec3f sp60; Vec3f sp54; f32 temp_f0_2; diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index 8bb715a79..0aef69c6b 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <common_structs.h> @@ -44,9 +44,7 @@ s32 func_80290C20(Camera *camera) { } void parse_course_displaylists(uintptr_t addr) { - s32 segment = SEGMENT_NUMBER2(addr); - s32 offset = SEGMENT_OFFSET(addr); - TrackSections *section = (TrackSections *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + TrackSections *section = (TrackSections *) addr; while(section->addr != 0) { if (section->flags & 0x8000) { @@ -74,10 +72,8 @@ extern u32 isFlycam; void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { Player *player = arg1->player; Camera *camera = arg1->camera; - u32 segment = SEGMENT_NUMBER2(addr); - u32 offset = SEGMENT_OFFSET(addr); //! @todo Should be Gfx* - s32 *gfx = (s32 *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Gfx* gfx = (Gfx*) addr; s16 var_a3; s16 temp_v1; s16 sp1E; @@ -125,12 +121,12 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = temp_v0_3; } } else if (camera->unk_54.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = sp1E; } } else { @@ -163,7 +159,7 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = arg1->pathCounter; } else if (player->unk_110.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else { + } else { temp_v1 = temp_v0_3; } break; @@ -173,14 +169,14 @@ void load_surface_map(uintptr_t addr, struct UnkStruct_800DC5EC *arg1) { temp_v1 = func_802ABD40(camera->unk_54.unk3A); if (camera->unk_54.unk3C[2] > 30.0f) { temp_v1 = arg1->pathCounter; - } else if (temp_v1 == 255) { + } else if (temp_v1 == 255) { temp_v1 = arg1->pathCounter; } } arg1->pathCounter = temp_v1; temp_v1 = ((temp_v1 - 1) * 4) + var_a3; - + gSPDisplayList(gDisplayListHead++, gfx[temp_v1]); } @@ -866,7 +862,7 @@ void render_luigi_raceway(struct UnkStruct_800DC5EC *arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); load_surface_map((uintptr_t) luigi_raceway_dls, arg0); - + gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_luigi_raceway_packed_dl_E0 @@ -940,48 +936,48 @@ void render_moo_moo_farm(struct UnkStruct_800DC5EC *arg0) { if ((temp_s0 < 14) && (temp_s0 > 10)) { if ((temp_s1 == 2) || (temp_s1 == 3) || (temp_s1 == 1)) - // + // gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } else if (temp_s0 < 16) { gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); } else if (temp_s0 < 19) { - if (temp_s1 != 2) + if (temp_s1 != 2) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } else if (temp_s0 < 20) { - if (temp_s1 == 0) + if (temp_s1 == 0) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_13FF8); - + } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); if ((temp_s0 >= 16) && (temp_s0 < 24)) { - if ((temp_s1 == 2) || (temp_s1 == 3)) + if ((temp_s1 == 2) || (temp_s1 == 3)) // d_course_moo_moo_farm_packed_dl_5410 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005410)); - + } else if (temp_s0 < 9) { - if (temp_s1 == 2) + if (temp_s1 == 2) // d_course_moo_moo_farm_packed_dl_5410 gSPDisplayList(gDisplayListHead++, ((uintptr_t)0x07005410)); - + } if (temp_s0 < 4) { if (temp_s1 != 0) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } else if (temp_s0 < 8) { if (temp_s1 == 2) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } else if (temp_s0 >= 22) { gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); } else if (temp_s0 >= 18) { if ((temp_s1 == 0) || (temp_s1 == 3)) gSPDisplayList(gDisplayListHead++, d_course_moo_moo_farm_dl_14060); - + } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); @@ -1412,7 +1408,7 @@ void func_80295D88(void) { gCourseMaxX = 0; gCourseMaxY = 0; gCourseMaxZ = 0; - + D_8015F59C = 0; D_8015F5A0 = 0; func_80295D6C(); diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index 0245992b0..e0cd0ac7b 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -1,6 +1,6 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <mk64.h> #include "skybox_and_splitscreen.h" @@ -471,7 +471,7 @@ void func_802A4A0C(Vtx *vtx, struct UnkStruct_800DC5EC *arg1, UNUSED s32 arg2, U vtx[2].v.ob[1] = temp_t5; vtx[4].v.ob[1] = temp_t5; vtx[7].v.ob[1] = temp_t5; - + init_rdp(); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER | G_LIGHTING); diff --git a/src/racing/skybox_and_splitscreen.h b/src/racing/skybox_and_splitscreen.h index 820a593bc..34d7c7456 100644 --- a/src/racing/skybox_and_splitscreen.h +++ b/src/racing/skybox_and_splitscreen.h @@ -1,7 +1,7 @@ #ifndef SKYBOX_AND_SPLITSCREEN_H #define SKYBOX_AND_SPLITSCREEN_H -#include <PR/gbi.h> +#include <libultra/gbi.h> #include "code_800029B0.h" #define G_CLEAR_ALL_MODES 0xFFFFFFFF diff --git a/src/render_objects.c b/src/render_objects.c index 085d6780d..b09a77190 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -3,9 +3,9 @@ * A more suitable name may be print.c **/ -#include <ultra64.h> +#include <libultraship.h> #include <mk64.h> -#include <PR/gbi.h> +#include <libultra/gbi.h> #include <macros.h> #include <defines.h> #include <common_structs.h> @@ -153,7 +153,7 @@ UNUSED void func_8004398C(s32 arg0, s32 arg1, u16 arg2, f32 arg3, Vtx *vtx, s32 gSPVertex(gDisplayListHead++, vtx, 4, 0); gSPDisplayList(gDisplayListHead++, common_rectangle_display); } - + s32 func_80043A54(s32 arg0) { s32 temp_a1; s32 phi_v0; @@ -252,7 +252,7 @@ void func_80044DA0(u8 *image, s32 width, s32 height) { // This macro ought to be equivalent to the block of macros below but it doesn't match // See comment above the `gDPLoadBlock` macro // gDPLoadTextureBlock_4b(gDisplayListHead++, image, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 1, image); gDPSetTile(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 0, G_TX_RENDERTILE, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD); gDPLoadSync(gDisplayListHead++); @@ -268,7 +268,7 @@ void func_80044F34(u8 *image, s32 width, s32 height) { // This macro ought to be equivalent to the block of macros below but it doesn't match // See comment above the `gDPLoadBlock` macro // gDPLoadTextureBlock_4b(gDisplayListHead++, image, G_IM_FMT_I, width, height, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - + gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 1, image); gDPSetTile(gDisplayListHead++, G_IM_FMT_I, G_IM_SIZ_16b, 0, G_TX_RENDERTILE, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOLOD); gDPLoadSync(gDisplayListHead++); @@ -831,7 +831,7 @@ void func_800485C4(Vec3f arg0, Vec3su arg1, f32 arg2, s32 arg3, u8 *tlut, u8 *te set_transparency(arg3); draw_rectangle_texture_overlap(tlut, texture, arg6, arg7, arg8, arg9, argA); - + gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); } @@ -1683,7 +1683,7 @@ void func_8004C6FC(s16 arg0, s16 arg1, u8 *texture, u32 width, u32 arg4) { athing += var_s4 * 0; var_s4 += heigth; } - + gSPDisplayList(gDisplayListHead++, D_0D007EB8); } #else @@ -2074,7 +2074,7 @@ void func_8004DF5C(s32 arg0, s32 arg1, u8 *texture, s32 width, s32 arg4, s32 hei s32 var_s0 = var_s0 = arg1 - (arg4 / 2); u8 *img = texture; s32 i; - + for (i = 0; i < arg4 / height; i++) { rsp_load_texture(img, width, height); func_8004B97C(arg0 - (width / 2), var_s0, width, height, 1); @@ -3270,7 +3270,7 @@ void render_ice_block(s32 arg0) { for (playerId = 0; playerId < gPlayerCountSelection1; playerId++) { objectIndex = gIndexLakituList[playerId]; if (objectIndex) {} - if (func_80072320(objectIndex, 4) != FALSE) { + if (func_80072320(objectIndex, 4) != false) { func_8005285C(playerId); } func_80072320(objectIndex, 0x00000010); @@ -3633,7 +3633,7 @@ void render_object_paddle_boat_smoke_particles(s32 cameraId) { UNUSED s32 pad[2]; Camera *camera; s32 i; - + camera = &camera1[cameraId]; gSPDisplayList(gDisplayListHead++, D_0D007AE0); @@ -4420,18 +4420,18 @@ UNUSED void func_800573BC(void) { } UNUSED void func_800573C4(void) { - + } UNUSED void func_800573CC(void) { - + } UNUSED void func_800573D4(void) { - + } UNUSED void func_800573DC(void) { - + } @@ -4473,7 +4473,7 @@ void debug_print_number(s32 *x, s32 *y, s32 number, u32 numDigits) debug_wrap_text(x, y); n = -number; } - + *D_801657B8 = -1; ptr = D_801657B8; if (n != 0) { @@ -4485,7 +4485,7 @@ void debug_print_number(s32 *x, s32 *y, s32 number, u32 numDigits) } else { *++ptr = 0; } - + do { func_800573E4(*x, *y, *ptr--); debug_wrap_text(x, y); @@ -4502,7 +4502,7 @@ void func_8005762C(s32 *x, s32 *y, s32 pathCount, u32 numDigits) { s8 *ptr; s32 count; s8 remainder; - + debug_wrap_text(x, y); *D_801657B8 = -1; ptr = D_801657B8; @@ -4518,7 +4518,7 @@ void func_8005762C(s32 *x, s32 *y, s32 pathCount, u32 numDigits) { } else { *++ptr = 0; } - + do { func_800573E4(*x, *y, *ptr--); debug_wrap_text(x, y); diff --git a/src/render_player.c b/src/render_player.c index aec58a16c..e4b073343 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <common_structs.h> @@ -106,7 +106,7 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 s16 var_v0; u16 ret; - ret = FALSE; + ret = false; switch (gActiveScreenMode) { /* irregular */ case SCREEN_MODE_1P: var_v0 = 0x293C; @@ -135,7 +135,7 @@ u16 check_player_camera_collision(Player *player, Camera *camera, f32 arg2, f32 sp5C = ((sp44 - player->pos[2]) * (sp58 - player->pos[0])) - ((sp4C - player->pos[2]) * (sp50 - player->pos[0])); if (((sp64 >= 0) && (sp60 >= 0) && (sp5C >= 0)) || (((sp64) <= 0) && (sp60 <= 0) && (sp5C <= 0))) { - ret = TRUE; + ret = true; } return ret; } @@ -152,7 +152,7 @@ u16 func_8001FD78(Player *player, f32 posX, UNUSED f32 arg2, f32 posZ) { f32 thing1; u16 ret; - ret = FALSE; + ret = false; sp58 = (70.0f * coss(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[2]; sp64 = (70.0f * sins(((player->unk_0C0 - player->rotation[1]) - 0x71C))) + player->pos[0]; @@ -165,7 +165,7 @@ u16 func_8001FD78(Player *player, f32 posX, UNUSED f32 arg2, f32 posZ) { thing0 = ((sp54 - posZ) * (sp5c - posX)) - ((sp50 - posZ) * (sp60 - posX)); thing1 = ((sp50 - posZ) * (sp64 - posX)) - ((sp58 - posZ) * (sp5c - posX)); if (((temp_f14 >= 0) && (thing0 >= 0) && (thing1 >= 0)) || ((temp_f14 <= 0) && (thing0 <= 0) && (thing1 <= 0))) { - ret = TRUE; + ret = true; } return ret; } @@ -710,7 +710,7 @@ void mtxf_scale2(Mat4 arg0, f32 scale) { * This function writes a fixed-point value to each Mtx entry. This is not how the Mtx struct works. * The first half of Mtx only holds s16 whole numbers and the second half holds the s16 decimal (fractional) parts. * See convert_to_fixed_point_matrix() for correct calculations. Note that each Mtx entry is the size of s32. - * This means each Mtx entry holds two s16 values. + * This means each Mtx entry holds two s16 values. * The first sixteen entries contain only the integer parts and the second sixteen entries hold only the decimal (fractional) parts. */ UNUSED void failed_fixed_point_matrix_conversion(Mtx *dest, Mat4 src) { @@ -793,9 +793,9 @@ bool adjust_angle(s16 *angle, s16 targetAngle, s16 step) { } } if (targetAngle == *angle) { - return FALSE; + return false; } - return TRUE; + return true; } void move_s32_towards(s32 *startingValue, s32 targetValue, f32 somePercent) { @@ -1063,12 +1063,12 @@ bool is_player_under_light_luigi_raceway(Player *player, s8 arg1) { change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); D_80164B80[arg1] = 0; - return TRUE; + return true; } - return FALSE; + return false; default: - return FALSE; + return false; } } @@ -1214,7 +1214,7 @@ void func_800235AC(Player *player, s8 arg1) { return; } } - if (is_player_under_light_luigi_raceway(player, arg1) != TRUE) { + if (is_player_under_light_luigi_raceway(player, arg1) != true) { if (((player->boundingBoxCorners[3].unk_14 & 1) == 1) || ((player->boundingBoxCorners[3].unk_14 & 2) == 2) || ((player->boundingBoxCorners[0].unk_14 & 3) == 3)) { @@ -1296,7 +1296,7 @@ void render_player_shadow(Player *player, s8 arg1, s8 arg2) { convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)], sp118); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[arg1 + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR @@ -1304,14 +1304,14 @@ void render_player_shadow(Player *player, s8 arg1, s8 arg2) { func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0xFF); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } @@ -1346,9 +1346,9 @@ void render_player_shadow_credits(Player *player, s8 playerId, s8 arg2) { mtxf_translate_rotate(sp118, spCC, spC4); mtxf_scale2(sp118, gCharacterSize[player->characterId] * player->size); convert_to_fixed_point_matrix(&gGfxPool->mtxShadow[playerId + (arg2 * 8)], sp118); - + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxShadow[playerId + (arg2 * 8)]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - + gSPDisplayList(gDisplayListHead++, D_0D008D58); gDPSetTextureLUT(gDisplayListHead++, G_TT_NONE); gDPLoadTextureBlock(gDisplayListHead++, D_8018D474, G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, @@ -1356,14 +1356,14 @@ void render_player_shadow_credits(Player *player, s8 playerId, s8 arg2) { func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E51D0[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gDPLoadTextureBlock(gDisplayListHead++, (D_8018D474 + SOME_TEXTURE_POINTER_MATH), G_IM_FMT_I, G_IM_SIZ_8b, 64, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); func_8004B414(0, 0, 0, 0x000000D0); gDPSetRenderMode(gDisplayListHead++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); gSPVertex(gDisplayListHead++, &D_800E5210[0], 4, 0); - + gSPDisplayList(gDisplayListHead++, common_square_plain_render); gSPTexture(gDisplayListHead++, 1, 1, 0, G_TX_RENDERTILE, G_OFF); } @@ -1705,7 +1705,7 @@ void func_80026A48(Player *player, s8 arg1) { } temp_f0 = ((player->unk_094 * (1.0f + player->unk_104)) / 18.0f) * 216.0f; - if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == TRUE)) { + if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == true)) { player->unk_240 = 0; } else { player->unk_240 += D_800DDE74[(s32)(temp_f0 / 12.0f)]; diff --git a/src/save.c b/src/save.c index 664a0faf8..260b314e0 100644 --- a/src/save.c +++ b/src/save.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> @@ -144,7 +144,7 @@ void load_save_data(void) { for (i = 0; i < 16; i++) { func_800B4A9C(i); } - + validate_save_data(); gSoundMode = gSaveData.main.soundMode; @@ -165,7 +165,7 @@ void func_800B4A9C(s32 course) { .unknownBytes[0] = 1; } sp24 = &gSaveData.allCourseTimeTrialRecords.cupRecords[course / 4].courseRecords[course % 4]; - + func_800B4FB0(course); if(sp24) {} @@ -209,7 +209,7 @@ void validate_save_data(void) { Stuff *backup = &gSaveData.backup; if (main->checksum[1] != (compute_save_data_checksum_1()) || (main->checksum[2] != compute_save_data_checksum_2())) { reset_save_data_grand_prix_points_and_sound_mode(); - + if (validate_save_data_checksum_backup() == 0) { for (cup_index = 0; cup_index < 4; cup_index++) { main->grandPrixPoints[cup_index] = backup->grandPrixPoints[cup_index]; @@ -385,7 +385,7 @@ void func_800B536C(s32 arg0) { if (arg0 >= 0) { points = &gSaveData.main.grandPrixPoints[gCCSelection]; - + tmp = func_800B54EC(gCupSelection, *points); tmp2 = 3 - arg0; if ((arg0 < 3) && (tmp < (3-arg0))) { @@ -411,7 +411,7 @@ void func_800B5404(s32 arg0, s32 arg1) if ((arg0 < 3) && (temp < (temp_a0 = 3 - arg0))) { *points = func_800B5508(temp2, *points, temp_a0); - + write_save_data_grand_prix_points_and_sound_mode(); update_save_data_backup(); } @@ -499,7 +499,7 @@ void func_800B559C(s32 arg0) { * odd. It calculates a checksum for 51 bytes in 17 byte chunks, but that doesn't line * up with anything in the save data cleanly. At that byte count it would get the 48 bytes * for the records plus 3 of the unknown bytes. -* +* * But only unknown bytes 7 and 8 ever get set, so why the extra 3, and why in chunks of 17? **/ s32 func_800B578C(s32 arg0) { @@ -595,7 +595,7 @@ s32 check_for_controller_pak(s32 controller) { } osPfsIsPlug(&gSIEventMesgQueue, &controllerBitpattern); - + if ((controllerBitpattern & (1 << controller)) != 0) { return PAK; } @@ -618,8 +618,8 @@ s32 controller_pak_1_status(void) { gControllerPak1State = BAD; break; } - } - + } + if (!gControllerPak1State) { s32 errorCode; if (check_for_controller_pak(CONTROLLER_1) == NO_PAK) { @@ -639,7 +639,7 @@ s32 controller_pak_1_status(void) { return PFS_PAK_BAD_READ; } } - + gControllerPak1State = OK; if (osPfsFindFile(&gControllerPak1FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak1FileNote) == PFS_NO_ERROR) { return PFS_NO_ERROR; @@ -663,13 +663,13 @@ s32 controller_pak_1_status(void) { } // gives status info about controller pak insterted in controller 2 -s32 controller_pak_2_status(void) { +s32 controller_pak_2_status(void) { s32 stateBorrow = sControllerPak2State; - + if (stateBorrow) { switch (osPfsFindFile(&gControllerPak2FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak2FileNote)) { case PFS_NO_ERROR: - return PFS_NO_ERROR; + return PFS_NO_ERROR; case PFS_ERR_INVALID: return PFS_INVALID_DATA; default: @@ -683,7 +683,7 @@ s32 controller_pak_2_status(void) { if (check_for_controller_pak(CONTROLLER_2) == NO_PAK) { return PFS_NO_PAK_INSERTED; } - + errorCode = osPfsInit(&gSIEventMesgQueue, &gControllerPak2FileHandle, CONTROLLER_2); if (errorCode) { switch (errorCode) { @@ -699,7 +699,7 @@ s32 controller_pak_2_status(void) { } sControllerPak2State = OK; - + switch (osPfsFindFile(&gControllerPak2FileHandle, gCompanyCode, gGameCode, (u8 *) gGameName, (u8 *) gExtCode, &gControllerPak2FileNote)) { case PFS_NO_ERROR: return PFS_NO_ERROR; @@ -765,7 +765,7 @@ u8 func_800B60E8(s32 page) { s32 i; u32 checksum = 0; u8 *addr; - + for (i = 0, addr = (u8*) &((u8*)D_800DC714)[page * 256]; i < 256; i++) { checksum += (*addr++ * (page + 1) + i); } @@ -847,7 +847,7 @@ s32 func_800B63F0(s32 arg0) { func_800051C4(); D_80162DD6 = 1; func_80005AE8(gPlayerThree); - + phi_s3 = 0; if (((gCupSelection * 4) + gCupCourseSelection) != D_8018EE10[arg0].courseIndex) { phi_s3 = 2; @@ -859,14 +859,14 @@ s32 func_800B63F0(s32 arg0) { } else { temp_s0 = 0; phi_s1 = (u8*) &D_8018EE10[arg0]; - + while (temp_s0 < 0x3C) { if (phi_s1[7] != func_800B60E8(temp_s0)) { phi_s3 = 1; break; } - + ++phi_s1; ++temp_s0; } @@ -943,7 +943,7 @@ void func_800B6708(void) { s32 temp_s0; osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, (u8*) &D_8018EE10); - + for (temp_s0 = 0; temp_s0 < 2; ++temp_s0) { if (D_8018EE10[temp_s0].checksum != func_800B6828(temp_s0)) { D_8018EE10[temp_s0].ghostDataSaved = 0; @@ -954,7 +954,7 @@ void func_800B6708(void) { void func_800B6798(void) { s32 temp_s0; u8* tmp; - + tmp = (u8*) D_8018D9C0; osPfsReadWriteFile(&gControllerPak2FileHandle, gControllerPak2FileNote, PFS_READ, 0, 0x100 /* 2*sizeof(struct_8018EE10_entry) ? */, tmp); @@ -999,14 +999,14 @@ s32 func_800B69BC(s32 arg0) { s32 i; struct_8018EE10_entry *plz = &D_8018EE10[arg0]; - plz->ghostDataSaved = FALSE; + plz->ghostDataSaved = false; plz->courseIndex = 0; plz->characterId = 0; for (i = 0; i < sizeof(plz->unk_07); i++) { plz->unk_07[i] = i; } plz->checksum = func_800B6828(arg0); - + return osPfsReadWriteFile(&gControllerPak1FileHandle, gControllerPak1FileNote, PFS_WRITE, (s32) sizeof(struct_8018EE10_entry) * arg0, sizeof(struct_8018EE10_entry), (u8 *)plz); } diff --git a/src/save.h b/src/save.h index 81c93d340..aadba2660 100644 --- a/src/save.h +++ b/src/save.h @@ -1,7 +1,7 @@ #ifndef SAVE_H #define SAVE_H -#include "PR/os.h" +#include <libultraship.h> #include "common_structs.h" /* define symbols */ diff --git a/src/spawn_players.c b/src/spawn_players.c index 427975e50..0206569bf 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -269,11 +269,11 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC gFrameSinceLastACombo[idx] = 0; gCountASwitch[idx] = 0; - gIsPlayerTripleAButtonCombo[idx] = FALSE; + gIsPlayerTripleAButtonCombo[idx] = false; gTimerBoostTripleACombo[idx] = 0; gFrameSinceLastBCombo[idx] = 0; gCountBChangement[idx] = 0; - gIsPlayerTripleBButtonCombo[idx] = FALSE; + gIsPlayerTripleBButtonCombo[idx] = false; gTimerBoostTripleBCombo[playerIndex] = 0; D_8018D900[0] = 0; @@ -456,7 +456,7 @@ void func_80039AE4(void) { void func_80039DA4(void) { s32 i; - + s32 sp2C[] = { 7, 6, 5, 4, 3, 2, 1, 0, diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 97142e717..6b75e232f 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <mk64.h> #include <common_structs.h> @@ -412,8 +412,8 @@ void func_8000599C(void) { u32 temp_t0; u32 temp_a0_2; - if (((D_80162DB8 >= 0x1000) || - ((gPlayerOne->unk_0CA & 2) != 0)) || + if (((D_80162DB8 >= 0x1000) || + ((gPlayerOne->unk_0CA & 2) != 0)) || ((gPlayerOne->unk_0CA & 8) != 0)) { D_80162DF8 = 1; return; @@ -458,7 +458,7 @@ void func_8000599C(void) { temp_t0 += 0x10000; D_80162DBC[D_80162DB8] = temp_t0; - + } } else { D_80162DB8++; D_80162DBC[D_80162DB8] = phi_a3; diff --git a/src/staff_ghosts.h b/src/staff_ghosts.h index 5444caa8b..b02de2412 100644 --- a/src/staff_ghosts.h +++ b/src/staff_ghosts.h @@ -1,7 +1,7 @@ #ifndef STAFF_GHOSTS_H #define STAFF_GHOSTS_H -#include "PR/os.h" +#include <libultraship.h> #include "common_structs.h" void func_80005B18(void); diff --git a/src/textures.h b/src/textures.h index 079c8703e..5a631cf58 100644 --- a/src/textures.h +++ b/src/textures.h @@ -1,7 +1,7 @@ #ifndef TEXTURES_H #define TEXTURES_H -#include "PR/ultratypes.h" +#include <libultra/types.h> /** * @brief struct for a texture use in menu mainly diff --git a/src/update_objects.c b/src/update_objects.c index 09996421b..281b611e7 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -1,4 +1,4 @@ -#include <ultra64.h> +#include <libultraship.h> #include <macros.h> #include <defines.h> #include <decode.h> @@ -37,7 +37,7 @@ #include "memory.h" //! @todo unused? -f32 D_800E43B0[] = { +f32 D_800E43B0[] = { 65536.0, 0.0, 1.0, 0.0, 0.0, 65536.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, @@ -211,9 +211,9 @@ UNUSED void func_80072214(s32 objectIndex, s32 arg1) { } bool is_obj_flag_status_active(s32 objectIndex, s32 arg1) { - s32 phi_v1 = FALSE; + s32 phi_v1 = false; if ((gObjectList[objectIndex].status & arg1) != 0) { - phi_v1 = TRUE; + phi_v1 = true; } return phi_v1; } @@ -239,17 +239,17 @@ UNUSED void func_800722F8(s32 objectIndex, s32 arg1) { } bool func_80072320(s32 objectIndex, s32 arg1) { - s32 b = FALSE; + s32 b = false; if ((gObjectList[objectIndex].unk_058 & arg1) != 0) { - b = TRUE; + b = true; } return b; } bool func_80072354(s32 objectIndex, s32 arg1) { - s32 b = FALSE; + s32 b = false; if ((gObjectList[objectIndex].unk_058 & arg1) == 0) { - b = TRUE; + b = true; } return b; } @@ -363,7 +363,7 @@ s32 func_8007278C(s32 objectIndex, s32 arg1) { func_80072488(objectIndex); phi_v1 = 1; } - + return phi_v1; } @@ -382,7 +382,7 @@ UNUSED s32 func_8007281C(s32 objectIndex, s32 arg1) { func_80072488(objectIndex); phi_a2 = 1; } - + return phi_a2; } @@ -401,7 +401,7 @@ UNUSED s32 func_800728B0(s32 objectIndex, s32 arg1, s32 arg2) { func_80072488(objectIndex); phi_a3 = 1; } - + return phi_a3; } @@ -430,7 +430,7 @@ void set_type_object(s32 objectIndex, s32 arg1) { } void func_800729EC(s32 objectIndex) { - u32 temp_v1 = 1; + u32 temp_v1 = 1; s32 i; start_race(); @@ -547,7 +547,7 @@ void func_80072D3C(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { } else { gObjectList[objectIndex].itemDisplay = arg2; } - + if (gObjectList[objectIndex].unk_0D4 < 0) { gObjectList[objectIndex].unk_0D4 = 1; if (gObjectList[objectIndex].unk_0CC > 0) { @@ -600,7 +600,7 @@ s32 func_80072E54(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 a bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex, 0x2000) != 0) { gObjectList[objectIndex].itemDisplay = arg1; gObjectList[objectIndex].unk_050 = arg4; @@ -621,7 +621,7 @@ bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 set_object_flag_status_false(objectIndex, 0x2000); set_object_unk_0CB(objectIndex, 0); func_80072488(objectIndex); - sp24 = TRUE; + sp24 = true; } else { gObjectList[objectIndex].itemDisplay = arg1; } @@ -634,7 +634,7 @@ bool func_80072F88(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex ,0x2000) != 0) { gObjectList[objectIndex].itemDisplay = arg1; gObjectList[objectIndex].unk_050 = arg4; @@ -665,7 +665,7 @@ bool func_800730BC(s32 objectIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 set_object_flag_status_false(objectIndex, 0x2000); set_object_unk_0CB(objectIndex, 0); func_80072488(objectIndex); - sp24 = TRUE; + sp24 = true; } else { set_object_flag_status_false(objectIndex, 0x4000); set_object_flag_status_true(objectIndex, 0x80); @@ -775,7 +775,7 @@ UNUSED void func_80073570(s32 objectIndex) { D_8018D1EC = 0; } (*test)++; -} +} void func_800735BC(s32 objectIndex, Gfx *arg1, f32 arg2) { gObjectList[objectIndex].status = 0; @@ -814,7 +814,7 @@ void func_80073720(s32 objectIndex) { bool func_8007375C(s32 objectIndex, s32 arg1) { s32 sp24; - sp24 = FALSE; + sp24 = false; if (is_obj_index_flag_status_inactive(objectIndex, 0x00008000) != 0) { gObjectList[objectIndex].unk_04C = arg1; set_object_flag_status_true(objectIndex, 0x00008000); @@ -823,7 +823,7 @@ bool func_8007375C(s32 objectIndex, s32 arg1) { if (gObjectList[objectIndex].unk_04C < 0) { set_object_flag_status_false(objectIndex, 0x00008000); func_80073654(objectIndex); - sp24 = TRUE; + sp24 = true; } return sp24; } @@ -893,7 +893,7 @@ UNUSED void func_800739CC(s32 arg0, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 bool func_80073A10(s32 objectIndex, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { bool phi_t0; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { *arg1 = arg2; gObjectList[objectIndex].unk_0AC = arg5; @@ -913,7 +913,7 @@ bool func_80073A10(s32 objectIndex, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 *arg1 = arg3; func_80073800(objectIndex, 0); func_8007381C(objectIndex); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 = arg2; } @@ -937,7 +937,7 @@ s32 func_80073B34(s32 arg0, s16* arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s bool func_80073B78(s32 arg0, s32 objectIndex, s16* arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7) { s32 phi_t0; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { gObjectList[objectIndex].unk_0AC = arg6; if (arg0 != 0) { @@ -965,7 +965,7 @@ bool func_80073B78(s32 arg0, s32 objectIndex, s16* arg2, s32 arg3, s32 arg4, s32 if (gObjectList[objectIndex].unk_0D0 == 0) { func_80073800(objectIndex, 0); func_8007381C(objectIndex); - phi_t0 = TRUE; + phi_t0 = true; } else { gObjectList[objectIndex].unk_0CF = 1; } @@ -1007,7 +1007,7 @@ bool func_80073E18(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { bool phi_t0; s32 temp_v1; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { func_80073800(objectIndex, 1); gObjectList[objectIndex].unk_048 = arg3; @@ -1017,12 +1017,12 @@ bool func_80073E18(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { if (temp_v1 <= 0) { *arg1 += gObjectList[objectIndex].unk_048; func_80073800(objectIndex, 0); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 += arg2; gObjectList[objectIndex].unk_048 = temp_v1; } - + return phi_t0; } @@ -1030,7 +1030,7 @@ UNUSED bool func_80073ED4(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { bool phi_t0; s32 temp_v1; - phi_t0 = FALSE; + phi_t0 = false; if (gObjectList[objectIndex].unk_0CF == 0) { func_80073800(objectIndex, 1); gObjectList[objectIndex].unk_048 = arg3; @@ -1040,7 +1040,7 @@ UNUSED bool func_80073ED4(s32 objectIndex, u16* arg1, u16 arg2, s32 arg3) { if (temp_v1 <= 0) { *arg1 += gObjectList[objectIndex].unk_048; func_80073800(objectIndex, 0); - phi_t0 = TRUE; + phi_t0 = true; } else { *arg1 -= arg2; gObjectList[objectIndex].unk_048 = temp_v1; @@ -1068,7 +1068,7 @@ UNUSED void func_80074014(void) { bool func_8007401C(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5, s32 arg6) { bool phi_a3; - phi_a3 = FALSE; + phi_a3 = false; if (gObjectList[objectIndex].unk_0CD == 0) { *arg1 = arg2; gObjectList[objectIndex].unk_0AA = arg5; @@ -1087,14 +1087,14 @@ bool func_8007401C(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 *arg1 = arg3; func_80073F90(objectIndex, 0); func_80073FAC(objectIndex); - phi_a3 = TRUE; + phi_a3 = true; } else { *arg1 = arg2; } } } } - + return phi_a3; } @@ -1133,7 +1133,7 @@ s32 func_800741B4(s32 objectIndex, f32* arg1, f32 arg2, f32 arg3, f32 arg4, s32 } } } - + return 0; } @@ -1224,7 +1224,7 @@ void func_800745C8(s32 objectIndex, s32 arg1) { if ((gObjectList[objectIndex].status & 2) != 0) { phi_a1 = 1; } - + gObjectList[objectIndex].activeTexture = (u8 *) (gObjectList[objectIndex].textureWidth * gObjectList[objectIndex].textureHeight * phi_a1) + arg1; func_800744A0(objectIndex); } @@ -1248,7 +1248,7 @@ void func_8007466C(s32 objectIndex, s32 arg1) { void func_80074704(s32 objectIndex, s32 arg1) { s32 phi_a1; - + if ((gObjectList[objectIndex].status & 1) != 0) { gObjectList[objectIndex].activeTLUT = gObjectList[objectIndex].tlutList; gObjectList[objectIndex].status ^= 2; @@ -1581,7 +1581,7 @@ void func_80075714(s32 objectIndex) { case 0: break; } - + object_calculate_new_pos_offset(objectIndex); } @@ -1664,7 +1664,7 @@ s32 func_80075A6C(s32 arg0, Vec3f arg1, f32 arg2) { func_800759EC(objectIndex, arg1, arg2); } } - + return objectIndex; } @@ -3567,7 +3567,7 @@ void func_8007AA44(s32 playerId) { void func_8007ABFC(s32 playerId, bool arg1) { s32 itemWindow; - if (playerHUD[playerId].raceCompleteBool == FALSE) { + if (playerHUD[playerId].raceCompleteBool == false) { itemWindow = gItemWindowObjectByPlayerId[playerId]; if (func_80072354(itemWindow, 4) != 0) { init_object(itemWindow, 0); @@ -3648,11 +3648,11 @@ u8 gen_random_item(s16 rank, s16 isCpu) } u8 gen_random_item_human(UNUSED s16 arg0, s16 rank) { - return gen_random_item(rank, FALSE); + return gen_random_item(rank, false); } u8 kart_ai_gen_random_item(UNUSED s32 arg0, s16 rank) { - return gen_random_item(rank, TRUE); + return gen_random_item(rank, true); } s16 func_8007AFB0(s32 objectIndex, s32 arg1) { @@ -3660,7 +3660,7 @@ s16 func_8007AFB0(s32 objectIndex, s32 arg1) { s16 randomItem; randomItem = gen_random_item_human(gLapCountByPlayerId[arg1], gGPCurrentRaceRankByPlayerId[arg1]); - + if (playerHUD[arg1].itemOverride != 0) { randomItem = (s16) playerHUD[arg1].itemOverride; playerHUD[arg1].itemOverride = 0; @@ -5858,7 +5858,7 @@ void func_80080A4C(s32 objectIndex, s32 cameraPlayerId) { Player *player = &gPlayerOne[cameraPlayerId]; if (gScreenModeSelection != SCREEN_MODE_3P_4P_SPLITSCREEN) { - if ((func_80072320(objectIndex, 0x00000010) != 0) && (is_within_horizontal_distance_of_player(objectIndex, player, 500.0f) != FALSE)) { + if ((func_80072320(objectIndex, 0x00000010) != 0) && (is_within_horizontal_distance_of_player(objectIndex, player, 500.0f) != false)) { func_8001CA10(camera); func_800C98B8(gObjectList[objectIndex].pos, gObjectList[objectIndex].velocity, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x0F)); } @@ -6114,7 +6114,7 @@ void func_8008153C(s32 objectIndex) { } void func_80081790(s32 objectIndex) { - switch (gObjectList[objectIndex].state) { + switch (gObjectList[objectIndex].state) { case 0: break; /* irregular */ case 1: |
