From 58d56fcba848e8545052c1d85ef27d0b02841538 Mon Sep 17 00:00:00 2001 From: coco875 <59367621+coco875@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:54:13 +0200 Subject: [PATCH] Fix linux compilation (#110) * fix wamr windows normally * fix linux issue * load all wasm in mods folder * minor fix --- mods/C/compile.sh | 5 +- mods/C/test.c | 2 +- src/audio/external.c | 1 + src/camera.c | 1 + src/code_800029B0.c | 1 + src/code_80005FD0.c | 82 ++--- src/code_80005FD0.h | 2 +- src/code_8003DC40.c | 1 + src/code_80057C60.c | 4 +- src/code_8006E9C0.c | 349 ++++++++++----------- src/code_80086E70.c | 1 + src/code_80091750.c | 68 +++-- src/effects.c | 169 +++++----- src/ending/code_80281780.c | 1 + src/engine/GameAPI.h | 2 +- src/engine/wasm.cpp | 72 +++-- src/main.c | 5 +- src/menus.c | 15 +- src/networking/start_game.c | 3 +- src/player_controller.c | 5 +- src/port/Game.cpp | 459 ++++++++++++++-------------- src/port/Game.h | 134 ++++++++ src/racing/actors.c | 3 +- src/racing/collision.c | 7 +- src/racing/memory.c | 2 + src/racing/race_logic.c | 20 +- src/racing/render_courses.c | 1 + src/racing/skybox_and_splitscreen.c | 60 ++-- src/render_objects.c | 1 + src/render_player.c | 16 +- src/save.c | 1 + src/spawn_players.c | 17 +- src/staff_ghosts.c | 1 + src/update_objects.c | 69 ++--- yamls/us/data_segment2.yml | 1 + 35 files changed, 901 insertions(+), 680 deletions(-) create mode 100644 src/port/Game.h diff --git a/mods/C/compile.sh b/mods/C/compile.sh index c74c6e55d..b417dc02b 100755 --- a/mods/C/compile.sh +++ b/mods/C/compile.sh @@ -1,3 +1,4 @@ emcc test.c -o testc.wasm -O3 -s LINKABLE=1 -s EXPORT_ALL=1 -s PURE_WASI=1 -rm ../../build/test.wasm -cp testc.wasm ../../build/test.wasm \ No newline at end of file +mkdir -p ../../build/mods/ +rm ../../build/mods/test.wasm +cp testc.wasm ../../build/mods/test.wasm \ No newline at end of file diff --git a/mods/C/test.c b/mods/C/test.c index ef56be181..abc7b9cdf 100644 --- a/mods/C/test.c +++ b/mods/C/test.c @@ -10,7 +10,7 @@ IMPORT_FUNC(void, post_debug_print)(); IMPORT_FUNC(void, debug_print_str2)(int x, int y, char*); int fib(int n) { - call_extern_function("test", "testfunc", 0, NULL); + // call_extern_function("test", "testfunc", 0, NULL); if (n <= 1) { return n; } diff --git a/src/audio/external.c b/src/audio/external.c index a992b3a51..ec4ed3846 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -14,6 +14,7 @@ #include "code_80005FD0.h" #include "code_80091750.h" #include +#include "port/Game.h" s8 D_8018EF10; UnkStruct8018EF18 D_8018EF18[16]; diff --git a/src/camera.c b/src/camera.c index d4ebd36cf..732824944 100644 --- a/src/camera.c +++ b/src/camera.c @@ -20,6 +20,7 @@ #include "freecam.h" #include "engine/GameAPI.h" +#include "port/Game.h" f32 D_800DDB30[] = { 0.4f, 0.6f, 0.275f, 0.3f }; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 4f2b7fe30..aa00b5ca1 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -26,6 +26,7 @@ #include #include #include +#include "port/Game.h" extern s32 D_802BA038; extern s16 D_802BA048; diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index 5a7bb4ff3..8fe8145a4 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -38,6 +38,7 @@ #include #include "engine/Engine.h" +#include "port/Game.h" #include "engine/courses/Course.h" s32 unk_code_80005FD0_pad[24]; @@ -1920,7 +1921,7 @@ void func_80009B60(s32 playerId) { } var_v1 = CourseManager_GetProps()->AISteeringSensitivity; - //var_v1 = gKartAISteeringSensitivity[gCurrentCourseId]; + // var_v1 = gKartAISteeringSensitivity[gCurrentCourseId]; switch (D_801631D8[playerId]) { /* switch 4; irregular */ case 2: /* switch 4 */ @@ -3681,15 +3682,15 @@ void func_800100F0(s32 pathIndex) { if (GetCourse() != GetPodiumCeremony()) { if (GetCourse() == GetTestCourse()) { - var_v0 = process_path_data(pathDest, test_course_path); - gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; + var_v0 = process_path_data(pathDest, test_course_path); + gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; } else { var_v0 = process_path_data(pathDest, LOAD_ASSET(CourseManager_GetProps()->PathTable2[pathIndex])); gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; } } - + else { // Course path included in course_data which has already been loaded into memory. // This is how we get the addr to our path data. @@ -4203,11 +4204,10 @@ void kart_ai_behaviour_start(s32 playerId, Player* player) { s32 behaviourType; UNUSED s32 test; - KartAIBehaviour *beh = (KartAIBehaviour*)LOAD_ASSET(CourseManager_GetProps()->AIBehaviour); - - sCurrentKartAIBehaviour = &((KartAIBehaviour*)LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[gCurrentKartAIBehaviourId[playerId]]; - + KartAIBehaviour* beh = (KartAIBehaviour*) LOAD_ASSET(CourseManager_GetProps()->AIBehaviour); + sCurrentKartAIBehaviour = + &((KartAIBehaviour*) LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[gCurrentKartAIBehaviourId[playerId]]; playerWaypoint = gNearestWaypointByPlayerId[playerId]; @@ -4216,7 +4216,7 @@ void kart_ai_behaviour_start(s32 playerId, Player* player) { behaviourType = sCurrentKartAIBehaviour->type; if ((waypointStart == -1) && (waypointEnd == -1)) { - sCurrentKartAIBehaviour = &((KartAIBehaviour*)LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[0]; + sCurrentKartAIBehaviour = &((KartAIBehaviour*) LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[0]; reset_kart_ai_behaviour_none(playerId); return; } @@ -4271,7 +4271,8 @@ void kart_ai_behaviour_end(s32 playerIndex, Player* player) { u32 waypointEnd; s32 behaviourType; - sCurrentKartAIBehaviour = &((KartAIBehaviour*)LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[gPreviousKartAIBehaviourId[playerIndex]]; + sCurrentKartAIBehaviour = &( + (KartAIBehaviour*) LOAD_ASSET(CourseManager_GetProps()->AIBehaviour))[gPreviousKartAIBehaviourId[playerIndex]]; nearestWaypoint = gNearestWaypointByPlayerId[playerIndex]; behaviourType = sCurrentKartAIBehaviour->type; waypointEnd = sCurrentKartAIBehaviour->waypointEnd; @@ -4453,45 +4454,45 @@ void init_vehicles_trains(size_t i, size_t numCarriages, f32 speed) { gTrainList[i].numCarriages = numCarriages; - //for (i = 0; i < NUM_TRAINS; i++) { - // outputs 160 or 392 depending on the train. - // Wraps the value around to always output a valid waypoint. - waypointOffset = (((i * gVehicle2DWaypointLength) / gNumTrains) + 160) % gVehicle2DWaypointLength; + // for (i = 0; i < NUM_TRAINS; i++) { + // outputs 160 or 392 depending on the train. + // Wraps the value around to always output a valid waypoint. + waypointOffset = (((i * gVehicle2DWaypointLength) / gNumTrains) + 160) % gVehicle2DWaypointLength; - // 120.0f is about the maximum usable value - gTrainList[i].speed = speed; - for (j = 0; j < gTrainList[i].numCarriages; j++) { - waypointOffset += 4; - ptr1 = &gTrainList[i].passengerCars[j]; - pos = &gVehicle2DWaypoint[waypointOffset]; - set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); - } - // Smaller offset for the tender - waypointOffset += 3; - ptr1 = &gTrainList[i].tender; - pos = &gVehicle2DWaypoint[waypointOffset]; - set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); + // 120.0f is about the maximum usable value + gTrainList[i].speed = speed; + for (j = 0; j < gTrainList[i].numCarriages; j++) { waypointOffset += 4; - ptr1 = &gTrainList[i].locomotive; + ptr1 = &gTrainList[i].passengerCars[j]; pos = &gVehicle2DWaypoint[waypointOffset]; set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); + } + // Smaller offset for the tender + waypointOffset += 3; + ptr1 = &gTrainList[i].tender; + pos = &gVehicle2DWaypoint[waypointOffset]; + set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); + waypointOffset += 4; + ptr1 = &gTrainList[i].locomotive; + pos = &gVehicle2DWaypoint[waypointOffset]; + set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); - // Only use locomotive unless overwritten below. - gTrainList[i].numCars = LOCOMOTIVE_ONLY; + // 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; + // for (i = 0; i < NUM_TRAINS; i++) { + gTrainList[i].tender.isActive = 1; - // clang-format off + // clang-format off // Same line required for matching... for (j = 0; j < gTrainList[i].numCarriages; j++) { gTrainList[i].passengerCars[j].isActive = 1; } - // clang-format on + // clang-format on - gTrainList[i].numCars = NUM_TENDERS + gTrainList[i].numCarriages; + gTrainList[i].numCars = NUM_TENDERS + gTrainList[i].numCarriages; //} break; @@ -4499,10 +4500,10 @@ void init_vehicles_trains(size_t i, size_t numCarriages, f32 speed) { case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: // multiplayer fall-through case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: if (gModeSelection != GRAND_PRIX) { - //for (i = 0; i < NUM_TRAINS; i++) { - gTrainList[i].tender.isActive = 1; - gTrainList[i].passengerCars[4].isActive = 1; - gTrainList[i].numCars = NUM_TENDERS + NUM_2P_PASSENGER_CARS; + // for (i = 0; i < NUM_TRAINS; i++) { + gTrainList[i].tender.isActive = 1; + gTrainList[i].passengerCars[4].isActive = 1; + gTrainList[i].numCars = NUM_TENDERS + NUM_2P_PASSENGER_CARS; //} } break; @@ -4641,7 +4642,8 @@ void func_80012DC0(s32 playerId, Player* player) { } } - for (passengerCarIndex = 0; passengerCarIndex < gTrainList[trainIndex].numCarriages; passengerCarIndex++) { + for (passengerCarIndex = 0; passengerCarIndex < gTrainList[trainIndex].numCarriages; + passengerCarIndex++) { trainCar = &gTrainList[trainIndex].passengerCars[passengerCarIndex]; x_dist = playerPosX - trainCar->position[0]; z_dist = playerPosZ - trainCar->position[2]; diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h index e1e60bdfb..338292918 100644 --- a/src/code_80005FD0.h +++ b/src/code_80005FD0.h @@ -152,7 +152,7 @@ void kart_ai_behaviour_end(s32, Player*); void kart_ai_behaviour(s32); void func_80011EC0(s32, Player*, s32, u16); -void generate_train_waypoints(void); +void generate_train_waypoints(const char*); void generate_ferry_waypoints(void); void spawn_vehicle_on_road(VehicleStuff*); void spawn_course_vehicles(void); diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index 231c40e4b..845b2bda3 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -7,6 +7,7 @@ #include "effects.h" #include "code_8003DC40.h" #include "defines.h" +#include "port/Game.h" void func_8003DC40(Player* player) { player->unk_DAC = 1.0f; diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 09e33baf2..a0c676010 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -37,6 +37,7 @@ #include "sounds.h" #include "data/some_data.h" #include +#include "port/Game.h" //! @warning this macro is undef'd at the end of this file #define MAKE_RGB(r, g, b) (((r) << 0x10) | ((g) << 0x08) | (b << 0x00)) @@ -2592,7 +2593,8 @@ void func_8005CB60(s32 playerId, s32 lapCount) { case 1: /* switch 1 */ func_80079084(playerId); func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15)); - if ((GetCourse() == GetLuigiRaceway()) && (D_80165898 == 0) && (gModeSelection != (s32) TIME_TRIALS)) { + if ((GetCourse() == GetLuigiRaceway()) && (D_80165898 == 0) && + (gModeSelection != (s32) TIME_TRIALS)) { D_80165898 = 1; } break; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 9b2e69331..c3b0c2322 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -27,6 +27,7 @@ #include "src/data/some_data.h" #include "effects.h" #include +#include "port/Game.h" void init_hud(void) { @@ -207,136 +208,136 @@ void func_8006F008(void) { // D_80165720 = 5; // D_80165728 = -240; break; - // case COURSE_CHOCO_MOUNTAIN: - // D_8018D2A0 = 0.022f; - // D_8018D2C0[0] = 265; - // D_8018D2E0 = 19; - // D_8018D2E8 = 37; - // break; - // case COURSE_BOWSER_CASTLE: - // D_8018D2C0[0] = 265; - // D_8018D2A0 = 0.0174f; - // D_8018D2E0 = 12; - // D_8018D2E8 = 48; - // break; - // case COURSE_BANSHEE_BOARDWALK: - // D_80165880 = (void*) dma_textures(gTextureGhosts, 0x4CC2, 0xD980); - // D_8018D2A0 = 0.016f; - // D_8018D2C0[0] = 0x0106; - // D_8018D2E0 = 55; - // D_8018D2E8 = 39; - // break; - // case COURSE_YOSHI_VALLEY: - // D_8018D220 = (void*) dma_textures(gTextureExhaust0, 0x479, 0xC00); - // D_8018D2A0 = 0.018f; - // D_8018D2E0 = 61; - // D_8018D2E8 = 38; - // break; - // case COURSE_FRAPPE_SNOWLAND: - // D_8018D2C0[0] = 262; - // D_8018D2A0 = 0.016f; - // D_8018D2E0 = 36; - // D_8018D2E8 = 40; - // D_8018D300 = 72; - // D_8018D308 = 100; - // D_8018D310 = 255; - // break; - // case COURSE_KOOPA_BEACH: - // D_8018D220 = (void*) dma_textures(gTextureExhaust3, 0x3C8U, 0x1000); - // D_8018D2A0 = 0.014f; - // D_8018D2C0[0] = 268; - // D_8018D2E0 = 40; - // D_8018D2E8 = 21; - // break; - // case COURSE_ROYAL_RACEWAY: - // D_8018D220 = (void*) dma_textures(gTextureExhaust4, 0x3F8, 0x1000); - // D_8018D2C0[0] = 262; - // D_8018D2A0 = 0.014f; - // D_8018D2E0 = 37; - // D_8018D2E8 = 50; - // D_80165718 = -64; - // D_80165720 = 5; - // D_80165728 = -330; - // break; - // case COURSE_LUIGI_RACEWAY: - // D_8018D220 = (void*) dma_textures(gTextureExhaust2, 0x4F4U, 0xC00); - // D_8018D2A0 = 0.0155f; - // D_8018D2C0[0] = 271; - // D_8018D2E0 = 45; - // D_8018D2E8 = 60; - // D_80165718 = -140; - // D_80165720 = -44; - // D_80165728 = -215; - // break; - // case COURSE_MOO_MOO_FARM: - // D_8018D220 = (void*) dma_textures(gTextureExhaust0, 0x479, 0xC00); - // D_8018D2A0 = 0.0155f; - // D_8018D2C0[0] = 271; - // D_8018D2E0 = 18; - // D_8018D2E8 = 36; - // break; - // case COURSE_TOADS_TURNPIKE: - // D_8018D2A0 = 0.013f; - // D_8018D2C0[0] = 252; - // D_8018D2E0 = 57; - // D_8018D2E8 = 44; - // break; - // case COURSE_KALAMARI_DESERT: - // D_8018D2C0[0] = 263; - // D_8018D2D8[0] = 165; - // D_8018D220 = (void*) dma_textures(gTextureExhaust5, 0x443, 0x1000); - // D_8018D2A0 = 0.015f; - // D_8018D2E0 = 55; - // D_8018D2E8 = 27; - // break; - // case COURSE_SHERBET_LAND: - // D_8018D220 = (void*) dma_textures(gTextureExhaust1, 0x485, 0xC00); - // D_8018D2A0 = 0.015f; - // D_8018D2C0[0] = 262; - // D_8018D2E0 = 52; - // D_8018D2E8 = 33; - // D_8018D300 = 72; - // D_8018D308 = 100; - // D_8018D310 = 255; - // break; - // case COURSE_RAINBOW_ROAD: - // D_8018D2A0 = 0.0103f; - // D_8018D2C0[0] = 261; - // D_8018D2D8[0] = 166; - // D_8018D2E0 = 39; - // D_8018D2E8 = 55; - // break; - // case COURSE_WARIO_STADIUM: - // D_8018D2A0 = 0.0155f; - // D_8018D2C0[0] = 0x0106; - // D_8018D2E0 = 53; - // D_8018D2E8 = 35; - // break; - // case COURSE_BLOCK_FORT: - // D_8018D2A0 = 0.0335f; - // D_8018D2E0 = 32; - // D_8018D2E8 = 32; - // break; - // case COURSE_SKYSCRAPER: - // D_8018D2A0 = 0.0445f; - // D_8018D2E0 = 32; - // D_8018D2E8 = 32; - // break; - // case COURSE_DOUBLE_DECK: - // D_8018D2A0 = 0.0285f; - // D_8018D2E0 = 32; - // D_8018D2E8 = 32; - // break; - // case COURSE_DK_JUNGLE: - // D_8018D2A0 = 0.0155f; - // D_8018D2C0[0] = 255; - // D_8018D2E0 = 29; - // D_8018D2E8 = 47; - // break; - // case COURSE_BIG_DONUT: - // D_8018D2A0 = 0.0257f; - // D_8018D2E0 = 32; - // D_8018D2E8 = 31; + // case COURSE_CHOCO_MOUNTAIN: + // D_8018D2A0 = 0.022f; + // D_8018D2C0[0] = 265; + // D_8018D2E0 = 19; + // D_8018D2E8 = 37; + // break; + // case COURSE_BOWSER_CASTLE: + // D_8018D2C0[0] = 265; + // D_8018D2A0 = 0.0174f; + // D_8018D2E0 = 12; + // D_8018D2E8 = 48; + // break; + // case COURSE_BANSHEE_BOARDWALK: + // D_80165880 = (void*) dma_textures(gTextureGhosts, 0x4CC2, 0xD980); + // D_8018D2A0 = 0.016f; + // D_8018D2C0[0] = 0x0106; + // D_8018D2E0 = 55; + // D_8018D2E8 = 39; + // break; + // case COURSE_YOSHI_VALLEY: + // D_8018D220 = (void*) dma_textures(gTextureExhaust0, 0x479, 0xC00); + // D_8018D2A0 = 0.018f; + // D_8018D2E0 = 61; + // D_8018D2E8 = 38; + // break; + // case COURSE_FRAPPE_SNOWLAND: + // D_8018D2C0[0] = 262; + // D_8018D2A0 = 0.016f; + // D_8018D2E0 = 36; + // D_8018D2E8 = 40; + // D_8018D300 = 72; + // D_8018D308 = 100; + // D_8018D310 = 255; + // break; + // case COURSE_KOOPA_BEACH: + // D_8018D220 = (void*) dma_textures(gTextureExhaust3, 0x3C8U, 0x1000); + // D_8018D2A0 = 0.014f; + // D_8018D2C0[0] = 268; + // D_8018D2E0 = 40; + // D_8018D2E8 = 21; + // break; + // case COURSE_ROYAL_RACEWAY: + // D_8018D220 = (void*) dma_textures(gTextureExhaust4, 0x3F8, 0x1000); + // D_8018D2C0[0] = 262; + // D_8018D2A0 = 0.014f; + // D_8018D2E0 = 37; + // D_8018D2E8 = 50; + // D_80165718 = -64; + // D_80165720 = 5; + // D_80165728 = -330; + // break; + // case COURSE_LUIGI_RACEWAY: + // D_8018D220 = (void*) dma_textures(gTextureExhaust2, 0x4F4U, 0xC00); + // D_8018D2A0 = 0.0155f; + // D_8018D2C0[0] = 271; + // D_8018D2E0 = 45; + // D_8018D2E8 = 60; + // D_80165718 = -140; + // D_80165720 = -44; + // D_80165728 = -215; + // break; + // case COURSE_MOO_MOO_FARM: + // D_8018D220 = (void*) dma_textures(gTextureExhaust0, 0x479, 0xC00); + // D_8018D2A0 = 0.0155f; + // D_8018D2C0[0] = 271; + // D_8018D2E0 = 18; + // D_8018D2E8 = 36; + // break; + // case COURSE_TOADS_TURNPIKE: + // D_8018D2A0 = 0.013f; + // D_8018D2C0[0] = 252; + // D_8018D2E0 = 57; + // D_8018D2E8 = 44; + // break; + // case COURSE_KALAMARI_DESERT: + // D_8018D2C0[0] = 263; + // D_8018D2D8[0] = 165; + // D_8018D220 = (void*) dma_textures(gTextureExhaust5, 0x443, 0x1000); + // D_8018D2A0 = 0.015f; + // D_8018D2E0 = 55; + // D_8018D2E8 = 27; + // break; + // case COURSE_SHERBET_LAND: + // D_8018D220 = (void*) dma_textures(gTextureExhaust1, 0x485, 0xC00); + // D_8018D2A0 = 0.015f; + // D_8018D2C0[0] = 262; + // D_8018D2E0 = 52; + // D_8018D2E8 = 33; + // D_8018D300 = 72; + // D_8018D308 = 100; + // D_8018D310 = 255; + // break; + // case COURSE_RAINBOW_ROAD: + // D_8018D2A0 = 0.0103f; + // D_8018D2C0[0] = 261; + // D_8018D2D8[0] = 166; + // D_8018D2E0 = 39; + // D_8018D2E8 = 55; + // break; + // case COURSE_WARIO_STADIUM: + // D_8018D2A0 = 0.0155f; + // D_8018D2C0[0] = 0x0106; + // D_8018D2E0 = 53; + // D_8018D2E8 = 35; + // break; + // case COURSE_BLOCK_FORT: + // D_8018D2A0 = 0.0335f; + // D_8018D2E0 = 32; + // D_8018D2E8 = 32; + // break; + // case COURSE_SKYSCRAPER: + // D_8018D2A0 = 0.0445f; + // D_8018D2E0 = 32; + // D_8018D2E8 = 32; + // break; + // case COURSE_DOUBLE_DECK: + // D_8018D2A0 = 0.0285f; + // D_8018D2E0 = 32; + // D_8018D2E8 = 32; + // break; + // case COURSE_DK_JUNGLE: + // D_8018D2A0 = 0.0155f; + // D_8018D2C0[0] = 255; + // D_8018D2E0 = 29; + // D_8018D2E8 = 47; + // break; + // case COURSE_BIG_DONUT: + // D_8018D2A0 = 0.0257f; + // D_8018D2E0 = 32; + // D_8018D2E8 = 31; } if (gIsMirrorMode != 0) { D_8018D2E0 = D_8018D2B0 - D_8018D2E0; @@ -704,50 +705,50 @@ void func_8007055C(void) { switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: // Uses Kalimari Desert's clouds for initialization? - //init_clouds(gKalimariDesertClouds); + // init_clouds(gKalimariDesertClouds); break; - // case COURSE_YOSHI_VALLEY: - // init_clouds(gYoshiValleyMooMooFarmClouds); - // break; - // case COURSE_FRAPPE_SNOWLAND: - // if (gPlayerCount == 1) { - // var_s4 = 0x32; - // } else { - // var_s4 = 0x19; - // } - // for (var_s0 = 0; var_s0 < var_s4; var_s0++) { - // find_unused_obj_index(&D_8018CC80[D_8018D1F8 + var_s0]); - // } - // D_8018D1F8 += var_s0; - // D_8018D1F0 = var_s0; - // break; - // case COURSE_KOOPA_BEACH: - // init_clouds(gKoopaTroopaBeachClouds); - // break; - // case COURSE_ROYAL_RACEWAY: - // init_clouds(gRoyalRacewayClouds); - // break; - // case COURSE_LUIGI_RACEWAY: - // init_clouds(gLuigiRacewayClouds); - // break; - // case COURSE_MOO_MOO_FARM: - // init_clouds(gYoshiValleyMooMooFarmClouds); - // break; - // case COURSE_TOADS_TURNPIKE: - // init_stars(gToadsTurnpikeRainbowRoadStars); - // break; - // case COURSE_KALAMARI_DESERT: - // init_clouds(gKalimariDesertClouds); - // break; - // case COURSE_SHERBET_LAND: - // init_clouds(gSherbetLandClouds); - // break; - // case COURSE_RAINBOW_ROAD: - // init_stars(gToadsTurnpikeRainbowRoadStars); - // break; - // case COURSE_WARIO_STADIUM: - // init_stars(gWarioStadiumStars); - // break; + // case COURSE_YOSHI_VALLEY: + // init_clouds(gYoshiValleyMooMooFarmClouds); + // break; + // case COURSE_FRAPPE_SNOWLAND: + // if (gPlayerCount == 1) { + // var_s4 = 0x32; + // } else { + // var_s4 = 0x19; + // } + // for (var_s0 = 0; var_s0 < var_s4; var_s0++) { + // find_unused_obj_index(&D_8018CC80[D_8018D1F8 + var_s0]); + // } + // D_8018D1F8 += var_s0; + // D_8018D1F0 = var_s0; + // break; + // case COURSE_KOOPA_BEACH: + // init_clouds(gKoopaTroopaBeachClouds); + // break; + // case COURSE_ROYAL_RACEWAY: + // init_clouds(gRoyalRacewayClouds); + // break; + // case COURSE_LUIGI_RACEWAY: + // init_clouds(gLuigiRacewayClouds); + // break; + // case COURSE_MOO_MOO_FARM: + // init_clouds(gYoshiValleyMooMooFarmClouds); + // break; + // case COURSE_TOADS_TURNPIKE: + // init_stars(gToadsTurnpikeRainbowRoadStars); + // break; + // case COURSE_KALAMARI_DESERT: + // init_clouds(gKalimariDesertClouds); + // break; + // case COURSE_SHERBET_LAND: + // init_clouds(gSherbetLandClouds); + // break; + // case COURSE_RAINBOW_ROAD: + // init_stars(gToadsTurnpikeRainbowRoadStars); + // break; + // case COURSE_WARIO_STADIUM: + // init_stars(gWarioStadiumStars); + // break; } func_8008C23C(); } @@ -765,7 +766,7 @@ void func_80070714(void) { D_80165748 = 0xA; } -const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gTextureBat4 }; +// const char* sBoardwalkTexList[] = { gTextureBat1, gTextureBat2, gTextureBat3, gTextureBat4 }; void init_course_object(void) { s32 objectId; diff --git a/src/code_80086E70.c b/src/code_80086E70.c index a7a2180ae..a4eed4f2c 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -15,6 +15,7 @@ #include "main.h" #include "code_80057C60.h" #include "defines.h" +#include "port/Game.h" void func_80086E70(s32 objectIndex) { gObjectList[objectIndex].unk_0AE = 1; // * 0xE0)) = 1; diff --git a/src/code_80091750.c b/src/code_80091750.c index f0ad51099..9522a57bb 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -42,6 +42,7 @@ #include "stdio.h" #include "port/Engine.h" +#include "port/Game.h" #include "engine/Engine.h" #include "engine/courses/Course.h" @@ -3633,7 +3634,8 @@ void load_menu_img2(MkTexture* arg0, s32 arg1) { } if (1) {} // D_8018D9B0[gMenuTextureBufferIndex] = &gTextureBackgroundBlueSky; - // tkmk00decode(D_8018D9B4, texture->textureData, (u8*)&D_8018D9B0[gMenuTextureBufferIndex], var_v0_2); + // tkmk00decode(D_8018D9B4, texture->textureData, (u8*)&D_8018D9B0[gMenuTextureBufferIndex], + // var_v0_2); u8* tex2 = (u8*) LOAD_ASSET(texture->textureData); memcpy(&D_8018D9B0[gMenuTextureBufferIndex], tex2, texture->width * texture->height * 2); break; @@ -5009,12 +5011,12 @@ void func_8009CE64(s32 arg0) { gNextDemoId = 0; } printf("\nSELECTED!!!!!\n"); - //SetCupIndex(gCurrentCourseId); // World->GetCourse - gCupSelection = GetCupIndex(); //gCupSelectionByCourseId[gCurrentCourseId]; + // SetCupIndex(gCurrentCourseId); // World->GetCourse + gCupSelection = GetCupIndex(); // gCupSelectionByCourseId[gCurrentCourseId]; D_800DC540 = (s32) GetCupIndex(); gCourseIndexInCup = GetCupCursorPosition(); - //gCupCourseSelection = (s8) gPerCupIndexByCourseId[gCurrentCourseId]; - //SetCupCursorPosition(); // + // gCupCourseSelection = (s8) gPerCupIndexByCourseId[gCurrentCourseId]; + // SetCupCursorPosition(); // break; case 3: /* switch 3 */ switch (gMenuSelection) { @@ -5075,9 +5077,7 @@ void func_8009CE64(s32 arg0) { } } - if (GetCourse() == GetBlockFort() || - GetCourse() == GetSkyscraper() || - GetCourse() == GetDoubleDeck() || + if (GetCourse() == GetBlockFort() || GetCourse() == GetSkyscraper() || GetCourse() == GetDoubleDeck() || GetCourse() == GetBigDonut()) { gModeSelection = BATTLE; @@ -5625,8 +5625,8 @@ void add_ui_element(s32 type, s32 column, s32 row, s8 priority) { load_menu_img2(D_800E7D4C[has_unlocked_extra_mode()], 0); load_menu_img2(D_02004B74, 0); convert_img_to_greyscale(0, 0x00000019); - adjust_img_colour(0, SCREEN_WIDTH * SCREEN_HEIGHT, D_800E74E8[type - 0x23].red, D_800E74E8[type - 0x23].green, - D_800E74E8[type - 0x23].blue); + adjust_img_colour(0, SCREEN_WIDTH * SCREEN_HEIGHT, D_800E74E8[type - 0x23].red, + D_800E74E8[type - 0x23].green, D_800E74E8[type - 0x23].blue); break; case 0xF: var_ra->unk1C = 0x00000020; @@ -5672,12 +5672,14 @@ void add_ui_element(s32 type, s32 column, s32 row, s8 priority) { case 0x30: case 0x31: case 0x32: - var_ra->D_8018DEE0_index = animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E8320[type - 0x2B])); + var_ra->D_8018DEE0_index = + animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E8320[type - 0x2B])); load_menu_img2(segmented_to_virtual_dupe(D_800E7D54[type - 0x2B]), 0); break; case 0xA0: case 0xA1: - var_ra->D_8018DEE0_index = animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E8320[type - 0xA0])); + var_ra->D_8018DEE0_index = + animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E8320[type - 0xA0])); break; case 0x5D: var_ra->unk1C = 0x00000020; @@ -5698,8 +5700,8 @@ void add_ui_element(s32 type, s32 column, s32 row, s8 priority) { case 0x60: case 0x61: case 0x62: - var_ra->D_8018DEE0_index = - animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E7E34[gCupCourseOrder[0][var_ra->type - 0x5F]])); + var_ra->D_8018DEE0_index = animate_character_select_menu( + segmented_to_virtual_dupe_2(D_800E7E34[gCupCourseOrder[0][var_ra->type - 0x5F]])); break; case 0x5E: var_ra->unk20 = random_int(4U) + 2; @@ -5712,8 +5714,8 @@ void add_ui_element(s32 type, s32 column, s32 row, s8 priority) { case 0x67: var_ra->unk1C = (s32) GetCupIndex(); var_ra->unk20 = func_800B54C0(GetCupIndex(), gCCSelection); - var_ra->D_8018DEE0_index = - animate_character_select_menu(segmented_to_virtual_dupe_2(D_800E7E20[((gCCSelection / 2) * 4) - var_ra->unk20])); + var_ra->D_8018DEE0_index = animate_character_select_menu( + segmented_to_virtual_dupe_2(D_800E7E20[((gCCSelection / 2) * 4) - var_ra->unk20])); var_ra->column = D_800E7268[0].column; var_ra->row = D_800E7268[0].row; break; @@ -6045,8 +6047,8 @@ void func_8009F5E0(struct_8018D9E0_entry* arg0) { case 0x23: /* switch 6 */ case 0x24: /* switch 6 */ case 0x25: /* switch 6 */ - gDisplayListHead = - func_8009BC9C(gDisplayListHead, D_800E7D4C[has_unlocked_extra_mode()], arg0->column, arg0->row, 3, 0); + gDisplayListHead = func_8009BC9C(gDisplayListHead, D_800E7D4C[has_unlocked_extra_mode()], arg0->column, + arg0->row, 3, 0); break; case 0xA: /* switch 6 */ gDisplayListHead = func_8009BA74(gDisplayListHead, D_02004660, arg0->column, arg0->row); @@ -7252,7 +7254,8 @@ void func_800A2EB8(struct_8018D9E0_entry* arg0) { func_800A32B4(0xBE - arg0->column, arg0->row + (0x10 * var_s2) + 0x5A, sp70[var_s2], var_s2); } set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_2); - temp_s0 = (s32) (((f32) (get_string_width(GetCupName()) + 8) * 0.6f) / 2);// gCupNames[GetCupIndex()]) + 8) * 0.6f) / 2); + temp_s0 = (s32) (((f32) (get_string_width(GetCupName()) + 8) * 0.6f) / + 2); // gCupNames[GetCupIndex()]) + 8) * 0.6f) / 2); draw_text((-(s32) (((f32) (get_string_width(D_800E76CC[gCCSelection]) + 8) * 0.6f) / 2) - arg0->column) + 0xF5, arg0->row + 0xE1, gCupNames[D_800DC540], 0, 0.6f, 0.6f); draw_text((temp_s0 - arg0->column) + 0xF5, arg0->row + 0xE1, @@ -7443,8 +7446,7 @@ void func_800A3C84(struct_8018D9E0_entry* arg0) { s32 rowOffset; set_text_color(TEXT_BLUE_GREEN_RED_CYCLE_1); - draw_text(arg0->column + 0x43, arg0->row + 0x19, CourseManager_GetProps()->Name - , 0, 0.6f, 0.6f); + draw_text(arg0->column + 0x43, arg0->row + 0x19, CourseManager_GetProps()->Name, 0, 0.6f, 0.6f); set_text_color(TEXT_YELLOW); draw_text(arg0->column + 0x46, arg0->row + 0x28, D_800E7730, 0, 0.75f, 0.75f); for (recordType = 0, rowOffset = 0; recordType < TIME_TRIAL_3LAP_RECORD_5; recordType += 1, rowOffset += 0xF) { @@ -7984,8 +7986,8 @@ void func_800A5738(struct_8018D9E0_entry* arg0) { gDisplayListHead = draw_box(gDisplayListHead, 0, 0, 0x0000013F, 0x000000EF, 0, 0, 0, var_s1); gDPSetPrimColor(gDisplayListHead++, 0, 0, 0x00, 0x00, 0x00, var_s2); set_text_color(3); - func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[GetCupIndex()][GetCupCursorPosition()]], 0, - 1.0f, 1.0f); + func_80093754(0x000000A0, 0x00000050, gCourseNamesDup[gCupCourseOrder[GetCupIndex()][GetCupCursorPosition()]], + 0, 1.0f, 1.0f); switch (arg0->cursor) { /* switch 1 */ case 1: /* switch 1 */ case 11: /* switch 1 */ @@ -8212,12 +8214,12 @@ void func_800A638C(struct_8018D9E0_entry* arg0) { } } -void func_800A66A8(struct_8018D9E0_entry *arg0, Unk_D_800E70A0 *arg1) { - Mtx *mtx; +void func_800A66A8(struct_8018D9E0_entry* arg0, Unk_D_800E70A0* arg1) { + Mtx* mtx; f32 tmp; static float x2, y2, z2; static float x1, y1, z1; - + mtx = &gGfxPool->mtxEffect[gMatrixEffectCount]; if (arg0->unk24 > 1.5) { arg0->unk24 *= 0.95; @@ -8233,7 +8235,12 @@ void func_800A66A8(struct_8018D9E0_entry *arg0, Unk_D_800E70A0 *arg1) { y2 += y1; z2 += z1; - if(x2); if(y2); if(z2); + if (x2) + ; + if (y2) + ; + if (z2) + ; guScale(mtx, 1.2f, 1.2f, 1.2f); guRotate(mtx + 1, y2, 0.0f, 1.0f, 0.0f); @@ -8244,7 +8251,8 @@ void func_800A66A8(struct_8018D9E0_entry *arg0, Unk_D_800E70A0 *arg1) { guMtxCatL(mtx, mtx + 1, mtx); guTranslate(mtx + 1, arg1->column, arg1->row, 0.0f); guMtxCatL(mtx, mtx + 1, mtx); - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount++]), (G_MTX_NOPUSH | G_MTX_LOAD) | G_MTX_MODELVIEW); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount++]), + (G_MTX_NOPUSH | G_MTX_LOAD) | G_MTX_MODELVIEW); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPNoOp(gDisplayListHead++); @@ -12056,8 +12064,8 @@ void func_800AF004(struct_8018D9E0_entry* arg0) { if (arg0->unk1C >= 0x65) { arg0->unk1C = 0; arg0->cursor = 1; - //gCupSelection %= 4; - //gCCSelection %= 4; + // gCupSelection %= 4; + // gCCSelection %= 4; add_ui_element(0x0000012C, 0, 0, 4); } break; diff --git a/src/effects.c b/src/effects.c index fe0f35bab..76c38e4ba 100644 --- a/src/effects.c +++ b/src/effects.c @@ -17,6 +17,7 @@ #include "audio/external.h" #include "spawn_players.h" #include "code_80091750.h" +#include "port/Game.h" s32 D_8018D900[8]; s16 D_8018D920[8]; @@ -1594,87 +1595,89 @@ void func_8008FF08(Player* player, s8 playerId) { CourseManager_Waypoints(player, playerId); -// switch (gCurrentCourseId) { -// case COURSE_BOWSER_CASTLE: -// waypoint = gNearestWaypointByPlayerId[playerId]; -// if ((waypoint >= 0x235) && (waypoint < 0x247)) { -// player->nearestWaypointId = 0x214; -// } else if ((waypoint >= 0x267) && (waypoint < 0x277)) { -// player->nearestWaypointId = 0x25B; -// } else { -// player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// } -// break; -// case COURSE_BANSHEE_BOARDWALK: -// waypoint = gNearestWaypointByPlayerId[playerId]; -// if ((waypoint >= 0x12C) && (waypoint < 0x13C)) { -// player->nearestWaypointId = 0x12CU; -// } else { -// player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// } -// break; -// case COURSE_YOSHI_VALLEY: -// case COURSE_RAINBOW_ROAD: -// player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; -// break; -// case COURSE_FRAPPE_SNOWLAND: -// waypoint = gNearestWaypointByPlayerId[playerId]; -// #ifdef VERSION_EU -// if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || ((gCopyNearestWaypointByPlayerId[playerId] >= 0xF0) && -// (gCopyNearestWaypointByPlayerId[playerId] < 0x11E))) -// #else -// if ((waypoint >= 0xF0) && (waypoint < 0x105)) -// #endif -// { -// player->nearestWaypointId = 0xF0U; -// } else { -// player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// } -// break; -// case COURSE_ROYAL_RACEWAY: -// waypoint = gNearestWaypointByPlayerId[playerId]; -// if ((waypoint >= 0x258) && (waypoint < 0x2A4)) { -// player->nearestWaypointId = 0x258U; -// } else { -// player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// } -// break; -// case COURSE_DK_JUNGLE: -// waypoint = gNearestWaypointByPlayerId[playerId]; -// if ((waypoint >= 0xB9) && (waypoint < 0x119)) { -// player->nearestWaypointId = 0xB9U; -// } else { -// player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// } -// break; -// case COURSE_BLOCK_FORT: -// case COURSE_SKYSCRAPER: -// case COURSE_DOUBLE_DECK: -// case COURSE_BIG_DONUT: -// player->nearestWaypointId = 0U; -// break; -// default: -// player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; -// if (player->nearestWaypointId < 0) { -// player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; -// } -// break; -// } + // switch (gCurrentCourseId) { + // case COURSE_BOWSER_CASTLE: + // waypoint = gNearestWaypointByPlayerId[playerId]; + // if ((waypoint >= 0x235) && (waypoint < 0x247)) { + // player->nearestWaypointId = 0x214; + // } else if ((waypoint >= 0x267) && (waypoint < 0x277)) { + // player->nearestWaypointId = 0x25B; + // } else { + // player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // } + // break; + // case COURSE_BANSHEE_BOARDWALK: + // waypoint = gNearestWaypointByPlayerId[playerId]; + // if ((waypoint >= 0x12C) && (waypoint < 0x13C)) { + // player->nearestWaypointId = 0x12CU; + // } else { + // player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // } + // break; + // case COURSE_YOSHI_VALLEY: + // case COURSE_RAINBOW_ROAD: + // player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; + // break; + // case COURSE_FRAPPE_SNOWLAND: + // waypoint = gNearestWaypointByPlayerId[playerId]; + // #ifdef VERSION_EU + // if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || ((gCopyNearestWaypointByPlayerId[playerId] >= 0xF0) + // && + // (gCopyNearestWaypointByPlayerId[playerId] < + // 0x11E))) + // #else + // if ((waypoint >= 0xF0) && (waypoint < 0x105)) + // #endif + // { + // player->nearestWaypointId = 0xF0U; + // } else { + // player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // } + // break; + // case COURSE_ROYAL_RACEWAY: + // waypoint = gNearestWaypointByPlayerId[playerId]; + // if ((waypoint >= 0x258) && (waypoint < 0x2A4)) { + // player->nearestWaypointId = 0x258U; + // } else { + // player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // } + // break; + // case COURSE_DK_JUNGLE: + // waypoint = gNearestWaypointByPlayerId[playerId]; + // if ((waypoint >= 0xB9) && (waypoint < 0x119)) { + // player->nearestWaypointId = 0xB9U; + // } else { + // player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // } + // break; + // case COURSE_BLOCK_FORT: + // case COURSE_SKYSCRAPER: + // case COURSE_DOUBLE_DECK: + // case COURSE_BIG_DONUT: + // player->nearestWaypointId = 0U; + // break; + // default: + // player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; + // if (player->nearestWaypointId < 0) { + // player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + // } + // break; + // } } void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { @@ -1704,8 +1707,8 @@ void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { arg2[1] = temp_v1->posY; arg2[2] = temp_v1->posZ; temp_v1 = &D_80164550[gCopyPathIndexByPlayerId[playerId]] - [(player->nearestWaypointId + 5) % - (gWaypointCountByPathIndex[gCopyPathIndexByPlayerId[playerId]] + 1)]; + [(player->nearestWaypointId + 5) % + (gWaypointCountByPathIndex[gCopyPathIndexByPlayerId[playerId]] + 1)]; arg3[0] = temp_v1->posX; arg3[1] = temp_v1->posY; arg3[2] = temp_v1->posZ; diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 2ac70325c..ca20c998c 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -22,6 +22,7 @@ #include "menus.h" #include "render_courses.h" #include +#include "port/Game.h" #define bcopy memcpy diff --git a/src/engine/GameAPI.h b/src/engine/GameAPI.h index 2ac0c7511..6e2e84323 100644 --- a/src/engine/GameAPI.h +++ b/src/engine/GameAPI.h @@ -1,6 +1,6 @@ #ifndef GAME_API_H #define GAME_API_H -uintptr_t* GetCourse(void); +void* GetCourse(void); #endif // GAME_API_H \ No newline at end of file diff --git a/src/engine/wasm.cpp b/src/engine/wasm.cpp index c307b90d7..a0bd31b23 100644 --- a/src/engine/wasm.cpp +++ b/src/engine/wasm.cpp @@ -40,6 +40,19 @@ extern "C" void call_render_hook() { } } +bool CreateDirectoryRecursive(std::string const& dirName, std::error_code& err) { + err.clear(); + if (!std::filesystem::create_directories(dirName, err)) { + if (std::filesystem::exists(dirName)) { + // The folder already exists: + err.clear(); + return true; + } + return false; + } + return true; +} + void load_mod_wasm_file(char* mod_name, char* buffer, size_t size) { char error_buf[128]; wasm_module_t module; @@ -186,28 +199,49 @@ extern "C" void load_wasm() { exit(-1); } uint32_t size; + + std::error_code err; + if (!CreateDirectoryRecursive("mods", err)) { + // Report the error: + std::cout << "CreateDirectoryRecursive FAILED, err: " << err.message() << std::endl; + } + /* read WASM file into a memory buffer */ - buffer = read_wasm_binary_to_buffer("test.wasm", &size); - if (buffer == NULL) { - printf("error read binary\n"); - exit(-1); + for (const auto& entry : std::filesystem::directory_iterator("mods")) { + if (std::filesystem::is_regular_file(entry) && entry.path().extension() == ".wasm") { + std::string path = entry.path().string(); + std::string name = entry.path().stem().string(); + printf("found %s\n", name.c_str()); + buffer = read_wasm_binary_to_buffer((char*) path.c_str(), &size); + if (buffer == NULL) { + printf("error read binary\n"); + } + load_mod_wasm_file((char*) name.c_str(), buffer, size); + mod_call_function_wasm((char*) name.c_str(), "init", 0, NULL); + } } + // buffer = read_wasm_binary_to_buffer("test.wasm", &size); + // if (buffer == NULL) { + // printf("error read binary\n"); + // exit(-1); + // } - load_mod_wasm_file("test", buffer, size); + // load_mod_wasm_file("test", buffer, size); - uint32_t argv[2]; + // uint32_t argv[2]; - /* arguments are always transferred in 32-bit element */ - argv[0] = 8; - printf("run fib function\n"); - /* call the WASM function */ - if (mod_call_function_wasm("test", "fib", 1, argv)) { - /* the return value is stored in argv[0] */ - printf("fib function return: %d\n", argv[0]); - } else { - /* exception is thrown if call fails */ - // wasm_runtime_dump_call_stack(exec_env); - mod_print_exception("test"); - } - mod_call_function_wasm("test", "init", 0, NULL); + // /* arguments are always transferred in 32-bit element */ + // argv[0] = 8; + // printf("run fib function\n"); + // /* call the WASM function */ + // if (mod_call_function_wasm("test", "fib", 1, argv)) { + // /* the return value is stored in argv[0] */ + // printf("fib function return: %d\n", argv[0]); + // } else { + // /* exception is thrown if call fails */ + // // wasm_runtime_dump_call_stack(exec_env); + // mod_print_exception("test"); + // } + // mod_call_function_wasm("test", "init", 0, NULL); + // exit(-1); } \ No newline at end of file diff --git a/src/main.c b/src/main.c index 7f744a006..b527951c0 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,7 @@ #include #include "enhancements/freecam/freecam.h" #include "engine/wasm.h" +#include "port/Game.h" // Declarations (not in this file) void func_80091B78(void); @@ -911,8 +912,8 @@ void race_logic_loop(void) { #if DVDL display_dvdl(); #endif - gDPFullSync(gDisplayListHead++); - gSPEndDisplayList(gDisplayListHead++); + // gDPFullSync(gDisplayListHead++); + // gSPEndDisplayList(gDisplayListHead++); } /** diff --git a/src/menus.c b/src/menus.c index f772f87cc..dd37671af 100644 --- a/src/menus.c +++ b/src/menus.c @@ -19,6 +19,7 @@ #include "save_data.h" #include #include "spawn_players.h" +#include "port/Game.h" /** BSS **/ s32 D_8018EDC0; @@ -1697,11 +1698,11 @@ void course_select_menu_act(struct Controller* arg0, u16 arg1) { switch (D_8018EDEC) { case 1: if ((buttonAndStickPress & R_JPAD) != 0) { - //if (GetCupIndex() < SPECIAL_CUP) { - D_8018EE0A = WorldNextCup(); - //++gCupSelection; - func_800B44AC(); - play_sound2(SOUND_MENU_CURSOR_MOVE); + // if (GetCupIndex() < SPECIAL_CUP) { + D_8018EE0A = WorldNextCup(); + //++gCupSelection; + func_800B44AC(); + play_sound2(SOUND_MENU_CURSOR_MOVE); //} } if (((buttonAndStickPress & L_JPAD) != 0)) { @@ -1953,13 +1954,13 @@ void func_800B3F74(s32 menuSelection) { case 13: { if (gModeSelection == BATTLE) { SetCupIndex(BATTLE_CUP); - //gCupSelection = BATTLE_CUP; + // gCupSelection = BATTLE_CUP; D_800DC540 = 4; D_8018EDEC = 4; } else { if (GetCupIndex() == BATTLE_CUP) { SetCupIndex(MUSHROOM_CUP); - //gCupSelection = MUSHROOM_CUP; + // gCupSelection = MUSHROOM_CUP; } D_8018EDEC = 1; } diff --git a/src/networking/start_game.c b/src/networking/start_game.c index 02c2ec9dc..ac70aa771 100644 --- a/src/networking/start_game.c +++ b/src/networking/start_game.c @@ -7,6 +7,7 @@ #include "menus.h" #include "audio/external.h" #include "code_80091750.h" +#include "port/Game.h" // PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_HUMAN // PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI @@ -54,7 +55,7 @@ void set_course(const char* data) { if (data != NULL) { SetCupIndex(data[0]); gCupSelection = data[0]; - //gCurrentCourseId = gCupCourseOrder[gCupSelection][COURSE_ONE]; + // gCurrentCourseId = gCupCourseOrder[gCupSelection][COURSE_ONE]; //! @todo SetCourse(); } } diff --git a/src/player_controller.c b/src/player_controller.c index cf4683c24..852e8ef5d 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -20,6 +20,7 @@ #include "code_80057C60.h" #include "code_80005FD0.h" #include "sounds.h" +#include "port/Game.h" extern s32 D_8018D168; @@ -245,9 +246,9 @@ void func_80027EDC(Player* player, s8 playerId) { UNUSED s32 pad; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - + CourseManager_WhatDoesThisDo(player, playerId); - + // switch (gCurrentCourseId) { // // case COURSE_MARIO_RACEWAY: // // if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x19B) && diff --git a/src/port/Game.cpp b/src/port/Game.cpp index edfa3dcb5..34ab164b2 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -67,7 +67,7 @@ BigDonut* gBigDonut; PodiumCeremony* gPodiumCeremony; TestCourse* gTestCourse; - void CustomEngineInit() { +void CustomEngineInit() { gMarioRaceway = new MarioRaceway(); gChocoMountain = new ChocoMountain(); @@ -116,16 +116,16 @@ TestCourse* gTestCourse; gWorldInstance.Courses.push_back(gTestCourse); /* Instantiate Cups */ - Cup* mushroom = gWorldInstance.AddCup("mushroom cup", std::vector{ - gLuigiRaceway, gMooMooFarm, gKoopaTroopaBeach, gKalimariDesert}); - Cup* flower = gWorldInstance.AddCup("flower cup", std::vector{ - gToadsTurnpike, gFrappeSnowland, gChocoMountain, gMarioRaceway}); - Cup* star = gWorldInstance.AddCup("star cup", std::vector{ - gWarioStadium, gSherbetLand, gRoyalRaceway, gBowsersCastle}); - Cup* special = gWorldInstance.AddCup("special cup", std::vector{ - gDkJungle, gYoshiValley, gBansheeBoardwalk, gRainbowRoad}); - Cup* battle = gWorldInstance.AddCup("battle", std::vector{ - gBigDonut, gBlockFort, gDoubleDeck, gSkyscraper}); + Cup* mushroom = gWorldInstance.AddCup( + "mushroom cup", std::vector{ gLuigiRaceway, gMooMooFarm, gKoopaTroopaBeach, gKalimariDesert }); + Cup* flower = gWorldInstance.AddCup( + "flower cup", std::vector{ gToadsTurnpike, gFrappeSnowland, gChocoMountain, gMarioRaceway }); + Cup* star = gWorldInstance.AddCup( + "star cup", std::vector{ gWarioStadium, gSherbetLand, gRoyalRaceway, gBowsersCastle }); + Cup* special = gWorldInstance.AddCup( + "special cup", std::vector{ gDkJungle, gYoshiValley, gBansheeBoardwalk, gRainbowRoad }); + Cup* battle = + gWorldInstance.AddCup("battle", std::vector{ gBigDonut, gBlockFort, gDoubleDeck, gSkyscraper }); /* Set default course; mario raceway */ gWorldInstance.CurrentCourse = gMarioRaceway; @@ -134,312 +134,313 @@ TestCourse* gTestCourse; } extern "C" { - u32 WorldNextCup(void) { - return gWorldInstance.NextCup(); - } +u32 WorldNextCup(void) { + return gWorldInstance.NextCup(); +} - u32 WorldPreviousCup(void) { - return gWorldInstance.PreviousCup(); - } +u32 WorldPreviousCup(void) { + return gWorldInstance.PreviousCup(); +} - void SetCupIndex(int16_t courseId) { - gWorldInstance.SetCupIndex(courseId); - } +void SetCupIndex(int16_t courseId) { + gWorldInstance.SetCupIndex(courseId); +} - void SetCup() { - gWorldInstance.SetCup(); - } +void SetCup() { + gWorldInstance.SetCup(); +} - u32 GetCupIndex(void) { - printf("Cup Index: %d\n", gWorldInstance.GetCupIndex()); - return gWorldInstance.GetCupIndex(); - } +u32 GetCupIndex(void) { + printf("Cup Index: %d\n", gWorldInstance.GetCupIndex()); + return gWorldInstance.GetCupIndex(); +} - const char* GetCupName(void) { - return gWorldInstance.Cups[gWorldInstance.CupIndex]->Name; - } +const char* GetCupName(void) { + return gWorldInstance.Cups[gWorldInstance.CupIndex]->Name; +} - void LoadCourse() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->Load(); - } +void LoadCourse() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->Load(); } +} - CProperties* GetCoursePropsA() { - return (CProperties*) gWorldInstance.GetCourseProps(); - } +CProperties* GetCoursePropsA() { + return (CProperties*) gWorldInstance.GetCourseProps(); +} - size_t GetCourseIndex() { - return gWorldInstance.CourseIndex; - } +size_t GetCourseIndex() { + return gWorldInstance.CourseIndex; +} - void SetCourse(const char* name) { - gWorldInstance.SetCourse(name); - } +void SetCourse(const char* name) { + gWorldInstance.SetCourse(name); +} - void NextCourse() { - gWorldInstance.NextCourse(); - } +void NextCourse() { + gWorldInstance.NextCourse(); +} - void PreviousCourse() { - gWorldInstance.PreviousCourse(); - } +void PreviousCourse() { + gWorldInstance.PreviousCourse(); +} - void CourseManager_SpawnVehicles() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SpawnVehicles(); - } +void CourseManager_SpawnVehicles() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SpawnVehicles(); } +} - void CourseManager_UpdateVehicles() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->UpdateVehicles(); - } +void CourseManager_UpdateVehicles() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->UpdateVehicles(); } +} - void CourseManager_LoadTextures() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->LoadTextures(); - } +void CourseManager_LoadTextures() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->LoadTextures(); } +} - void CourseManager_RenderCourse(struct UnkStruct_800DC5EC* arg0) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->Render(arg0); - } +void CourseManager_RenderCourse(struct UnkStruct_800DC5EC* arg0) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->Render(arg0); } +} - void CourseManager_RenderCredits() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->RenderCredits(); - } +void CourseManager_RenderCredits() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->RenderCredits(); } +} - void CourseManager_SpawnActors() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SpawnActors(); - } +void CourseManager_SpawnActors() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SpawnActors(); } +} - void CourseManager_InitClouds() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->InitClouds(); - } +void CourseManager_InitClouds() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->InitClouds(); } +} - void CourseManager_UpdateClouds(s32 arg0, Camera* camera) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->UpdateClouds(arg0, camera); - } +void CourseManager_UpdateClouds(s32 arg0, Camera* camera) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->UpdateClouds(arg0, camera); } +} - void CourseManager_Waypoints(Player* player, int8_t playerId) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->Waypoints(player, playerId); - } +void CourseManager_Waypoints(Player* player, int8_t playerId) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->Waypoints(player, playerId); } +} - void CourseManager_GenerateCollision() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->GenerateCollision(); - } +void CourseManager_GenerateCollision() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->GenerateCollision(); } +} - void CourseManager_SomeCollisionThing(Player *player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, f32* arg6, f32* arg7) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SomeCollisionThing(player, arg1, arg2, arg3, arg4, arg5, arg6, arg7); - } +void CourseManager_SomeCollisionThing(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, + f32* arg6, f32* arg7) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SomeCollisionThing(player, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } +} - void CourseManager_MinimapSettings() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->MinimapSettings(); - } +void CourseManager_MinimapSettings() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->MinimapSettings(); } +} - void CourseManager_InitCourseObjects() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->InitCourseObjects(); - } +void CourseManager_InitCourseObjects() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->InitCourseObjects(); } +} - void CourseManager_UpdateCourseObjects() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->UpdateCourseObjects(); - } +void CourseManager_UpdateCourseObjects() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->UpdateCourseObjects(); } +} - void CourseManager_RenderCourseObjects(s32 cameraId) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->RenderCourseObjects(cameraId); - } +void CourseManager_RenderCourseObjects(s32 cameraId) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->RenderCourseObjects(cameraId); } +} - void CourseManager_SomeSounds() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SomeSounds(); - } +void CourseManager_SomeSounds() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SomeSounds(); } +} - void CourseManager_SetCourseVtxColours() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SetCourseVtxColours(); - } +void CourseManager_SetCourseVtxColours() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SetCourseVtxColours(); } +} - void CourseManager_WhatDoesThisDo(Player* player, int8_t playerId) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->WhatDoesThisDo(player, playerId); - } +void CourseManager_WhatDoesThisDo(Player* player, int8_t playerId) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->WhatDoesThisDo(player, playerId); } +} - void CourseManager_WhatDoesThisDoAI(Player* player, int8_t playerId) { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->WhatDoesThisDoAI(player, playerId); - } +void CourseManager_WhatDoesThisDoAI(Player* player, int8_t playerId) { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->WhatDoesThisDoAI(player, playerId); } +} - void CourseManager_MinimapFinishlinePosition() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->MinimapFinishlinePosition(); - } +void CourseManager_MinimapFinishlinePosition() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->MinimapFinishlinePosition(); } +} - void CourseManager_SetStaffGhost() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SetStaffGhost(); - } +void CourseManager_SetStaffGhost() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SetStaffGhost(); } +} - CProperties *CourseManager_GetProps() { - if (gWorldInstance.CurrentCourse) { - return (CProperties*) &gWorldInstance.CurrentCourse->Props; - } +CProperties* CourseManager_GetProps() { + if (gWorldInstance.CurrentCourse) { + return (CProperties*) &gWorldInstance.CurrentCourse->Props; } +} - void CourseManager_SpawnBombKarts() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->SpawnBombKarts(); - } +void CourseManager_SpawnBombKarts() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->SpawnBombKarts(); } +} - void CourseManager_Water() { - if (gWorldInstance.CurrentCourse) { - gWorldInstance.CurrentCourse->Water(); - } +void CourseManager_Water() { + if (gWorldInstance.CurrentCourse) { + gWorldInstance.CurrentCourse->Water(); } +} - size_t GetCupCursorPosition() { - return gWorldInstance.CurrentCup->CursorPosition; - } +size_t GetCupCursorPosition() { + return gWorldInstance.CurrentCup->CursorPosition; +} - void SetCupCursorPosition(size_t position) { - gWorldInstance.CurrentCup->CursorPosition = position; - } +void SetCupCursorPosition(size_t position) { + gWorldInstance.CurrentCup->CursorPosition = position; +} - size_t GetCupSize() { - return gWorldInstance.CurrentCup->GetSize(); - } +size_t GetCupSize() { + return gWorldInstance.CurrentCup->GetSize(); +} - void SetCourseFromCup() { - gWorldInstance.CurrentCourse = gWorldInstance.CurrentCup->GetCourse(); - } +void SetCourseFromCup() { + gWorldInstance.CurrentCourse = gWorldInstance.CurrentCup->GetCourse(); +} - Course* GetCourse(void) { - return gWorldInstance.CurrentCourse; - } +void* GetCourse(void) { + return gWorldInstance.CurrentCourse; +} - void SetCourseByClass(void* course) { - gWorldInstance.CurrentCourse = (Course*) course; - } +void SetCourseByClass(void* course) { + gWorldInstance.CurrentCourse = (Course*) course; +} - void* GetMarioRaceway(void) { - return gMarioRaceway; - } +void* GetMarioRaceway(void) { + return gMarioRaceway; +} - void* GetLuigiRaceway(void) { - return gLuigiRaceway; - } +void* GetLuigiRaceway(void) { + return gLuigiRaceway; +} - void* GetChocoMountain(void) { - return gChocoMountain; - } +void* GetChocoMountain(void) { + return gChocoMountain; +} - void* GetBowsersCastle(void) { - return gBowsersCastle; - } +void* GetBowsersCastle(void) { + return gBowsersCastle; +} - void* GetBansheeBoardwalk(void) { - return gBansheeBoardwalk; - } +void* GetBansheeBoardwalk(void) { + return gBansheeBoardwalk; +} - void* GetYoshiValley(void) { - return gYoshiValley; - } +void* GetYoshiValley(void) { + return gYoshiValley; +} - void* GetFrappeSnowland(void) { - return gFrappeSnowland; - } +void* GetFrappeSnowland(void) { + return gFrappeSnowland; +} - void* GetKoopaTroopaBeach(void) { - return gKoopaTroopaBeach; - } +void* GetKoopaTroopaBeach(void) { + return gKoopaTroopaBeach; +} - void* GetRoyalRaceway(void) { - return gRoyalRaceway; - } +void* GetRoyalRaceway(void) { + return gRoyalRaceway; +} - void* GetMooMooFarm(void) { - return gMooMooFarm; - } +void* GetMooMooFarm(void) { + return gMooMooFarm; +} - void* GetToadsTurnpike(void) { - return gToadsTurnpike; - } +void* GetToadsTurnpike(void) { + return gToadsTurnpike; +} - void* GetKalimariDesert(void) { - return gKalimariDesert; - } +void* GetKalimariDesert(void) { + return gKalimariDesert; +} - void* GetSherbetLand(void) { - return gSherbetLand; - } +void* GetSherbetLand(void) { + return gSherbetLand; +} - void* GetRainbowRoad(void) { - return gRainbowRoad; - } +void* GetRainbowRoad(void) { + return gRainbowRoad; +} - void* GetWarioStadium(void) { - return gWarioStadium; - } +void* GetWarioStadium(void) { + return gWarioStadium; +} - void* GetBlockFort(void) { - return gBlockFort; - } +void* GetBlockFort(void) { + return gBlockFort; +} - void* GetSkyscraper(void) { - return gSkyscraper; - } +void* GetSkyscraper(void) { + return gSkyscraper; +} - void* GetDoubleDeck(void) { - return gDoubleDeck; - } +void* GetDoubleDeck(void) { + return gDoubleDeck; +} - void* GetDkJungle(void) { - return gDkJungle; - } +void* GetDkJungle(void) { + return gDkJungle; +} - void* GetBigDonut(void) { - return gBigDonut; - } +void* GetBigDonut(void) { + return gBigDonut; +} - void* GetPodiumCeremony(void) { - return gPodiumCeremony; - } +void* GetPodiumCeremony(void) { + return gPodiumCeremony; +} - void* GetTestCourse(void) { - return gTestCourse; - } +void* GetTestCourse(void) { + return gTestCourse; +} } void push_frame() { diff --git a/src/port/Game.h b/src/port/Game.h new file mode 100644 index 000000000..1e923de6b --- /dev/null +++ b/src/port/Game.h @@ -0,0 +1,134 @@ +#include +#include "engine/Engine.h" + +#ifdef __cplusplus +extern "C" { +#endif +u32 WorldNextCup(void); + +u32 WorldPreviousCup(void); + +void SetCupIndex(int16_t courseId); +void SetCup(); +u32 GetCupIndex(void); + +const char* GetCupName(void); + +void LoadCourse(); + +CProperties* GetCoursePropsA(); + +size_t GetCourseIndex(); + +void SetCourse(const char* name); + +void NextCourse(); +void PreviousCourse(); + +void CourseManager_SpawnVehicles(); + +void CourseManager_UpdateVehicles(); + +void CourseManager_LoadTextures(); + +void CourseManager_RenderCourse(struct UnkStruct_800DC5EC* arg0); + +void CourseManager_RenderCredits(); + +void CourseManager_SpawnActors(); + +void CourseManager_InitClouds(); + +void CourseManager_UpdateClouds(s32 arg0, Camera* camera); + +void CourseManager_Waypoints(Player* player, int8_t playerId); + +void CourseManager_GenerateCollision(); + +void CourseManager_SomeCollisionThing(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, + f32* arg6, f32* arg7); + +void CourseManager_MinimapSettings(); + +void CourseManager_InitCourseObjects(); + +void CourseManager_UpdateCourseObjects(); + +void CourseManager_RenderCourseObjects(s32 cameraId); + +void CourseManager_SomeSounds(); + +void CourseManager_SetCourseVtxColours(); + +void CourseManager_WhatDoesThisDo(Player* player, int8_t playerId); + +void CourseManager_WhatDoesThisDoAI(Player* player, int8_t playerId); + +void CourseManager_MinimapFinishlinePosition(); + +void CourseManager_SetStaffGhost(); + +CProperties* CourseManager_GetProps(); + +void CourseManager_SpawnBombKarts(); + +void CourseManager_Water(); + +size_t GetCupCursorPosition(); + +void SetCupCursorPosition(size_t position); + +size_t GetCupSize(); + +void SetCourseFromCup(); + +void* GetCourse(void); + +void SetCourseByClass(void* course); + +void* GetMarioRaceway(void); + +void* GetLuigiRaceway(void); + +void* GetChocoMountain(void); + +void* GetBowsersCastle(void); + +void* GetBansheeBoardwalk(void); + +void* GetYoshiValley(void); + +void* GetFrappeSnowland(void); + +void* GetKoopaTroopaBeach(void); + +void* GetRoyalRaceway(void); + +void* GetMooMooFarm(void); + +void* GetToadsTurnpike(void); + +void* GetKalimariDesert(void); + +void* GetSherbetLand(void); + +void* GetRainbowRoad(void); + +void* GetWarioStadium(void); + +void* GetBlockFort(void); + +void* GetSkyscraper(void); + +void* GetDoubleDeck(void); + +void* GetDkJungle(void); + +void* GetBigDonut(void); + +void* GetPodiumCeremony(void); + +void* GetTestCourse(void); +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/src/racing/actors.c b/src/racing/actors.c index 0b043f519..6dfae331b 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -32,6 +32,7 @@ #include #include #include +#include "port/Game.h" // Appears to be textures // or tluts @@ -1202,7 +1203,7 @@ void init_actors_and_load_textures(void) { dma_textures(gTextureFinishLineBanner8, 0x0000025BU, 0x00000800U); dma_textures(gTexture671A88, 0x00000400U, 0x00000800U); dma_textures(gTexture6774D8, 0x00000400U, 0x00000800U); - + CourseManager_LoadTextures(); init_red_shell_texture(); diff --git a/src/racing/collision.c b/src/racing/collision.c index 19f1c730a..de308584a 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -11,6 +11,7 @@ #include "code_800029B0.h" #include #include +#include "port/Game.h" #pragma intrinsic(sqrtf) @@ -1595,7 +1596,7 @@ void add_collision_triangle(Vtx* vtx1, Vtx* vtx2, Vtx* vtx3, s8 surfaceType, u16 triangle->vtx1 = vtx1; triangle->vtx2 = vtx2; triangle->vtx3 = vtx3; - if ((triangle->vtx1->v.flag == 4) && (triangle->vtx2->v.flag == 4) && (triangle->vtx3->v.flag == 4)) { + if ((triangle->vtx1->v.flag == 4) && (triangle->vtx2->v.flag == 4) && (triangle->vtx3->v.flag == 4)) { return; } @@ -2123,7 +2124,7 @@ 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(Gfx *displayList, s8 alpha, u8 red, u8 green, u8 blue) { +void find_vtx_and_set_colours(Gfx* displayList, s8 alpha, u8 red, u8 green, u8 blue) { Gfx* gfx = (Gfx*) displayList; uintptr_t lo; uintptr_t hi; @@ -2136,7 +2137,7 @@ void find_vtx_and_set_colours(Gfx *displayList, s8 alpha, u8 red, u8 green, u8 b if (opcode == (G_ENDDL << 24)) { break; } else if (opcode == (G_DL << 24)) { - find_vtx_and_set_colours((Gfx *)hi, alpha, red, green, blue); + find_vtx_and_set_colours((Gfx*) hi, alpha, red, green, blue); } else if (opcode == (G_VTX << 24)) { // G_VTX contains an addr hi set_vertex_colours(hi, (lo >> 10) & 0x3F, ((lo >> 16) & 0xFF) >> 1, alpha, red, green, blue); diff --git a/src/racing/memory.c b/src/racing/memory.c index 845dbc645..a1da6d777 100644 --- a/src/racing/memory.c +++ b/src/racing/memory.c @@ -26,6 +26,8 @@ #include +#include "port/Game.h" + s32 sGfxSeekPosition; s32 sPackedSeekPosition; diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 3d233087e..580e8fc6a 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -21,6 +21,7 @@ #include "effects.h" #include "math.h" #include "menus.h" +#include "port/Game.h" #pragma intrinsic(sqrtf) @@ -143,7 +144,7 @@ void func_8028E298(void) { void func_8028E3A0(void) { if (D_80150120) { - if (GetCupCursorPosition() == GetCupSize()) {// CUP_COURSE_FOUR) { + if (GetCupCursorPosition() == GetCupSize()) { // CUP_COURSE_FOUR) { gGotoMode = ENDING; } else { D_800DC544++; @@ -422,19 +423,14 @@ void func_8028EC98(s32 arg0) { func_800029B0(); - if (GetCourse() == GetMarioRaceway() || - GetCourse() == GetRoyalRaceway() || - GetCourse() == GetLuigiRaceway() || + if (GetCourse() == GetMarioRaceway() || GetCourse() == GetRoyalRaceway() || GetCourse() == GetLuigiRaceway() || GetCourse() == GetWarioStadium()) { func_800C8EAC(3); } else if (GetCourse() == GetToadsTurnpike()) { func_800C8EAC(21); - } else if (GetCourse() == GetYoshiValley() || - GetCourse() == GetMooMooFarm()) { + } else if (GetCourse() == GetYoshiValley() || GetCourse() == GetMooMooFarm()) { func_800C8EAC(4); - } else if (GetCourse() == GetChocoMountain() || - GetCourse() == GetBlockFort() || - GetCourse() == GetDoubleDeck()) { + } else if (GetCourse() == GetChocoMountain() || GetCourse() == GetBlockFort() || GetCourse() == GetDoubleDeck()) { func_800C8EAC(5); } else if (GetCourse() == GetKalimariDesert()) { func_800C8EAC(10); @@ -444,15 +440,13 @@ void func_8028EC98(s32 arg0) { func_800C8EAC(9); } else if (GetCourse() == GetBansheeBoardwalk()) { func_800C8EAC(7); - } else if (GetCourse() == GetFrappeSnowland() || - GetCourse() == GetSherbetLand()) { + } else if (GetCourse() == GetFrappeSnowland() || GetCourse() == GetSherbetLand()) { func_800C8EAC(8); } else if (GetCourse() == GetRainbowRoad()) { func_800C8EAC(18); } else if (GetCourse() == GetDkJungle()) { func_800C8EAC(19); - } else if (GetCourse() == GetSkyscraper() || - GetCourse() == GetBigDonut()) { + } else if (GetCourse() == GetSkyscraper() || GetCourse() == GetBigDonut()) { func_800C8EAC(25); } } diff --git a/src/racing/render_courses.c b/src/racing/render_courses.c index ef9111d1b..3b4fd6f55 100644 --- a/src/racing/render_courses.c +++ b/src/racing/render_courses.c @@ -21,6 +21,7 @@ #include "courses/all_course_packed.h" #include "courses/all_course_offsets.h" #include +#include "port/Game.h" #include "enhancements/collision_viewer.h" diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index bc6068f24..ad2d8fa81 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -20,6 +20,7 @@ #include "port/Engine.h" #include "engine/courses/Course.h" #include "engine/Engine.h" +#include "port/Game.h" Vp D_802B8880[] = { { { { 640, 480, 511, 0 }, { 640, 480, 511, 0 } } }, @@ -361,7 +362,7 @@ void func_802A450C(Vtx* skybox) { return; } - SkyboxColours *prop = (SkyboxColours *)&CourseManager_GetProps()->Skybox; + SkyboxColours* prop = (SkyboxColours*) &CourseManager_GetProps()->Skybox; skybox[0].v.cn[0] = prop->TopRight.r; skybox[0].v.cn[1] = prop->TopRight.g; @@ -443,7 +444,8 @@ void func_802A4A0C(Vtx* vtx, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, U sp5C[0] = 0.0f; sp5C[1] = 0.0f; sp5C[2] = 30000.0f; - func_802B5564(matrix1, &sp128, camera->unk_B4, gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + func_802B5564(matrix1, &sp128, camera->unk_B4, gScreenAspect, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); func_802B5794(matrix2, camera->pos, camera->lookAt); mtxf_multiplication(matrix3, matrix1, matrix2); @@ -767,9 +769,11 @@ void render_player_one_1p_screen(void) { gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), @@ -829,9 +833,11 @@ void render_player_one_2p_screen_vertical(void) { func_802A3730(D_800DC5EC); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), @@ -895,9 +901,11 @@ void render_player_two_2p_screen_vertical(void) { #endif gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[1]), @@ -957,9 +965,11 @@ void render_player_one_2p_screen_horizontal(void) { #endif gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), @@ -1020,9 +1030,11 @@ void render_player_two_2p_screen_horizontal(void) { #endif gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[1]), @@ -1079,9 +1091,11 @@ void render_player_one_3p_4p_screen(void) { func_802A3730(D_800DC5EC); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[0], &perspNorm, gCameraZoom[0], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[0]), @@ -1138,9 +1152,11 @@ void render_player_two_3p_4p_screen(void) { func_802A3730(D_800DC5F0); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[1], &perspNorm, gCameraZoom[1], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[1]), @@ -1198,9 +1214,11 @@ void render_player_three_3p_4p_screen(void) { gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[2], &perspNorm, gCameraZoom[2], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[2], &perspNorm, gCameraZoom[2], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[2], &perspNorm, gCameraZoom[2], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[2], &perspNorm, gCameraZoom[2], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[2]), @@ -1267,9 +1285,11 @@ void render_player_four_3p_4p_screen(void) { gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); #ifdef VERSION_EU - guPerspective(&gGfxPool->mtxPersp[3], &perspNorm, gCameraZoom[3], sp9C, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[3], &perspNorm, gCameraZoom[3], sp9C, CourseManager_GetProps()->NearPersp, + CourseManager_GetProps()->FarPersp, 1.0f); #else - guPerspective(&gGfxPool->mtxPersp[3], &perspNorm, gCameraZoom[3], gScreenAspect, CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); + guPerspective(&gGfxPool->mtxPersp[3], &perspNorm, gCameraZoom[3], gScreenAspect, + CourseManager_GetProps()->NearPersp, CourseManager_GetProps()->FarPersp, 1.0f); #endif gSPPerspNormalize(gDisplayListHead++, perspNorm); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPersp[3]), diff --git a/src/render_objects.c b/src/render_objects.c index fa6d01e86..71c31fddc 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -40,6 +40,7 @@ #include #include #include +#include "port/Game.h" Lights1 D_800E45C0[] = { gdSPDefLights1(100, 0, 0, 100, 0, 0, 0, -120, 0), diff --git a/src/render_player.c b/src/render_player.c index b59f8e7c2..42f5e6d04 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -30,6 +30,7 @@ #include #include #include +#include "port/Game.h" s8 gRenderingFramebufferByPlayer[] = { 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02 }; @@ -1268,14 +1269,13 @@ bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { ((gNearestWaypointByPlayerId[arg1] >= 0x169) && (gNearestWaypointByPlayerId[arg1] < 0x170)) || ((gNearestWaypointByPlayerId[arg1] >= 0x174) && (gNearestWaypointByPlayerId[arg1] < 0x17A)) || ((gNearestWaypointByPlayerId[arg1] >= 0x17E) && - (gNearestWaypointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel + (gNearestWaypointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel 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 false; - } return false; } @@ -1290,11 +1290,11 @@ void render_light_environment_on_player(Player* player, s8 arg1) { change_player_color_effect_cmy(player, arg1, 0x004040, 0.3f); D_80164B80[arg1] = 0; } else if (((gNearestWaypointByPlayerId[arg1] >= 0xF1) && (gNearestWaypointByPlayerId[arg1] < 0xF5)) || - ((gNearestWaypointByPlayerId[arg1] >= 0xFB) && (gNearestWaypointByPlayerId[arg1] < 0xFF)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x105) && (gNearestWaypointByPlayerId[arg1] < 0x109)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x10F) && (gNearestWaypointByPlayerId[arg1] < 0x113)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x145) && (gNearestWaypointByPlayerId[arg1] < 0x14A)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && + ((gNearestWaypointByPlayerId[arg1] >= 0xFB) && (gNearestWaypointByPlayerId[arg1] < 0xFF)) || + ((gNearestWaypointByPlayerId[arg1] >= 0x105) && (gNearestWaypointByPlayerId[arg1] < 0x109)) || + ((gNearestWaypointByPlayerId[arg1] >= 0x10F) && (gNearestWaypointByPlayerId[arg1] < 0x113)) || + ((gNearestWaypointByPlayerId[arg1] >= 0x145) && (gNearestWaypointByPlayerId[arg1] < 0x14A)) || + ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x163))) { // under a lamp change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); @@ -1323,7 +1323,7 @@ void render_light_environment_on_player(Player* player, s8 arg1) { ((gNearestWaypointByPlayerId[arg1] >= 0x24C) && (gNearestWaypointByPlayerId[arg1] < 0x256)) || ((gNearestWaypointByPlayerId[arg1] >= 0x288) && (gNearestWaypointByPlayerId[arg1] < 0x269)) || ((gNearestWaypointByPlayerId[arg1] >= 0x274) && - (gNearestWaypointByPlayerId[arg1] < 0x27E))) { // under a lamp + (gNearestWaypointByPlayerId[arg1] < 0x27E))) { // under a lamp change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0x0000E0, 0.3f); D_80164B80[arg1] = 0; diff --git a/src/save.c b/src/save.c index e6d773d21..82d3ea2e5 100644 --- a/src/save.c +++ b/src/save.c @@ -10,6 +10,7 @@ #include "save_data.h" #include "staff_ghosts.h" #include "code_80057C60.h" +#include "port/Game.h" /*** macros ***/ #define PFS_COMPANY_CODE(c0, c1) ((u16) (((c0) << 8) | ((c1)))) diff --git a/src/spawn_players.c b/src/spawn_players.c index fd1d4ef88..6e015ff3b 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -26,6 +26,7 @@ #include "code_80091750.h" #include "effects.h" #include "decode.h" +#include "port/Game.h" f32 D_80165210[8]; f32 D_80165230[8]; @@ -1124,21 +1125,21 @@ void func_8003C0F0(void) { D_80165230[6] = 150.0f; D_80165230[7] = 170.0f; spawn_player(gPlayerOneCopy, 0, D_80165210[0], D_80165230[0], sp5A, 32768.0f, gCharacterSelections[0], - PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); + PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, D_80165210[1], D_80165230[1], sp5A, 32768.0f, 1, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerThree, 2, D_80165210[2], D_80165230[2], sp5A, 32768.0f, 2, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerFour, 3, D_80165210[3], D_80165230[3], sp5A, 32768.0f, 3, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerFive, 4, D_80165210[4], D_80165230[4], sp5A, 32768.0f, 4, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerSix, 5, D_80165210[5], D_80165230[5], sp5A, 32768.0f, 5, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerSeven, 6, D_80165210[6], D_80165230[6], sp5A, 32768.0f, 6, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); spawn_player(gPlayerEight, 7, D_80165210[7], D_80165230[7], sp5A, 32768.0f, 7, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); D_80164A28 = 0; } diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 4b5c4fa23..f85c87ae9 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -14,6 +14,7 @@ #include "code_80091750.h" #include "code_80057C60.h" #include "kart_dma.h" +#include "port/Game.h" u8* D_80162D80; s16 D_80162D84; diff --git a/src/update_objects.c b/src/update_objects.c index fcd8cc2bf..61ceb6492 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -38,6 +38,7 @@ #include "courses/all_course_offsets.h" #include "courses/all_course_data.h" #include +#include "port/Game.h" //! @todo unused? 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, 0.0, 0.0, 0.0, 0.0 }; @@ -2425,7 +2426,7 @@ void init_object_leaf_particle(s32 objectIndex, Vec3f arg1, s32 num) { gObjectList[objectIndex].tlutList = (u8*) common_texture_particle_leaf; gObjectList[objectIndex].sizeScaling = 0.1f; gObjectList[objectIndex].surfaceHeight = arg1[1]; - + if (GetCourse() == GetMarioRaceway()) { object_origin_pos_randomize_around_xyz(objectIndex, arg1[0], arg1[1] + 25.0, arg1[2], 0x14, 0x1E, 0x14); gObjectList[objectIndex].unk_034 = 1.5f; @@ -2886,39 +2887,39 @@ void func_80078C70(s32 arg0) { // // Uses Luigi Raceway's clouds for display purposes? // //update_clouds(sp1C, camera, gLuigiRacewayClouds); // break; - // case COURSE_YOSHI_VALLEY: /* switch 2 */ - // update_clouds(sp1C, camera, gYoshiValleyMooMooFarmClouds); - // break; - // case COURSE_FRAPPE_SNOWLAND: /* switch 2 */ - // func_80078170(sp1C, camera); - // break; - // case COURSE_KOOPA_BEACH: /* switch 2 */ - // update_clouds(sp1C, camera, gKoopaTroopaBeachClouds); - // break; - // case COURSE_ROYAL_RACEWAY: /* switch 2 */ - // update_clouds(sp1C, camera, gRoyalRacewayClouds); - // break; - // case COURSE_LUIGI_RACEWAY: /* switch 2 */ - // update_clouds(sp1C, camera, gLuigiRacewayClouds); - // break; - // case COURSE_MOO_MOO_FARM: /* switch 2 */ - // update_clouds(sp1C, camera, gYoshiValleyMooMooFarmClouds); - // break; - // case COURSE_TOADS_TURNPIKE: /* switch 2 */ - // update_stars(sp1C, camera, gToadsTurnpikeRainbowRoadStars); - // break; - // case COURSE_KALAMARI_DESERT: /* switch 2 */ - // update_clouds(sp1C, camera, gKalimariDesertClouds); - // break; - // case COURSE_SHERBET_LAND: /* switch 2 */ - // update_clouds(sp1C, camera, gSherbetLandClouds); - // break; - // case COURSE_RAINBOW_ROAD: /* switch 2 */ - // update_stars(sp1C, camera, gToadsTurnpikeRainbowRoadStars); - // break; - // case COURSE_WARIO_STADIUM: /* switch 2 */ - // update_stars(sp1C, camera, gWarioStadiumStars); - // break; + // case COURSE_YOSHI_VALLEY: /* switch 2 */ + // update_clouds(sp1C, camera, gYoshiValleyMooMooFarmClouds); + // break; + // case COURSE_FRAPPE_SNOWLAND: /* switch 2 */ + // func_80078170(sp1C, camera); + // break; + // case COURSE_KOOPA_BEACH: /* switch 2 */ + // update_clouds(sp1C, camera, gKoopaTroopaBeachClouds); + // break; + // case COURSE_ROYAL_RACEWAY: /* switch 2 */ + // update_clouds(sp1C, camera, gRoyalRacewayClouds); + // break; + // case COURSE_LUIGI_RACEWAY: /* switch 2 */ + // update_clouds(sp1C, camera, gLuigiRacewayClouds); + // break; + // case COURSE_MOO_MOO_FARM: /* switch 2 */ + // update_clouds(sp1C, camera, gYoshiValleyMooMooFarmClouds); + // break; + // case COURSE_TOADS_TURNPIKE: /* switch 2 */ + // update_stars(sp1C, camera, gToadsTurnpikeRainbowRoadStars); + // break; + // case COURSE_KALAMARI_DESERT: /* switch 2 */ + // update_clouds(sp1C, camera, gKalimariDesertClouds); + // break; + // case COURSE_SHERBET_LAND: /* switch 2 */ + // update_clouds(sp1C, camera, gSherbetLandClouds); + // break; + // case COURSE_RAINBOW_ROAD: /* switch 2 */ + // update_stars(sp1C, camera, gToadsTurnpikeRainbowRoadStars); + // break; + // case COURSE_WARIO_STADIUM: /* switch 2 */ + // update_stars(sp1C, camera, gWarioStadiumStars); + // break; //} } } diff --git a/yamls/us/data_segment2.yml b/yamls/us/data_segment2.yml index 7c78589c6..f061a97e3 100644 --- a/yamls/us/data_segment2.yml +++ b/yamls/us/data_segment2.yml @@ -14,6 +14,7 @@ - '#include ' header: - '#include ' + - '#include ' D_02007650: symbol: D_02007650 type: gfx