diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2024-10-05 15:31:31 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-05 15:31:31 -0600 |
| commit | 75297759ee906b103ff9714dad17e683f1757b7f (patch) | |
| tree | 2a81aff6c8e1d2be2806f34f8850c74499980479 /src/engine/courses/TestCourse.cpp | |
| parent | 447fd8b29057e8dcc223507e6b7d6bc448c6f7d8 (diff) | |
[modding] Course Mod Support (#104)
* Course Manager
* Course
* Test
* Render
* That escalated quickly
* update
* properties
* Properties
* test
* Fix compile
* Add World
* skycolours
* Skybox Colours done
* Cleanup
* test
* Game runs again
* update
* Game run again
* Cup Works
* continue
* Add Courses
* clouds
* changes
* fixes
* update
* Fix compile
* update
* A few changes
* More Updates
* More refactors
* Fixes
* Fix ai behaviour
* Changes
* Fix courses
* test course test not working
* CUSTOM
* TestCourse works kinda
* fixes
* test course works
* cleanup
---------
Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/engine/courses/TestCourse.cpp')
| -rw-r--r-- | src/engine/courses/TestCourse.cpp | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/src/engine/courses/TestCourse.cpp b/src/engine/courses/TestCourse.cpp new file mode 100644 index 000000000..f999457fd --- /dev/null +++ b/src/engine/courses/TestCourse.cpp @@ -0,0 +1,250 @@ +#include <libultraship.h> +#include <libultra/gbi.h> +#include <vector> +#include <memory> + +#include "TestCourse.h" +#include "GameObject.h" +#include "World.h" +#include "BombKart.h" + +extern "C" { + #include "main.h" + #include "camera.h" + #include "course_offsets.h" + #include "code_800029B0.h" + #include "render_courses.h" + #include "code_8006E9C0.h" + #include "code_80057C60.h" + #include "defines.h" + #include "math_util.h" + #include "external.h" + #include "code_80005FD0.h" + #include "spawn_players.h" + #include "render_objects.h" + #include "assets/common_data.h" + #include "save.h" + #include "staff_ghosts.h" + #include "actors.h" + #include "collision.h" + #include "memory.h" + typedef struct { + Gfx* addr; + u8 surfaceType; + u8 sectionId; + u16 flags; + } TrackSections; + extern Gfx test_course_dls[]; + extern Vtx mario_Plane_001_mesh_vtx_1[]; + extern Gfx mario_Plane_001_mesh[]; + extern TrackWaypoint test_course_path[]; + extern TrackSections test_course_addr[]; +} + +TestCourse::TestCourse() { + this->gfxSize = 100; + this->textures = NULL; + + Props.Id = "mk:test_course"; + Props.Name = "Test Course"; + Props.DebugName = "test track"; + Props.CourseLength = "100m"; + + Props.AIBehaviour = D_0D008F28; + Props.AIMaximumSeparation = 50.0f; + Props.AIMinimumSeparation = 0.3f; + Props.SomePtr = D_800DCB34; + Props.AISteeringSensitivity = 48; + + Props.NearPersp = 9.0f; + Props.FarPersp = 4500.0f; + + Props.PathSizes = {52, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}; + + Props.D_0D009418[0] = 4.1666665f; + Props.D_0D009418[1] = 5.5833334f; + Props.D_0D009418[2] = 6.1666665f; + Props.D_0D009418[3] = 6.75f; + + Props.D_0D009568[0] = 3.75f; + Props.D_0D009568[1] = 5.1666665f; + Props.D_0D009568[2] = 5.75f; + Props.D_0D009568[3] = 6.3333334f; + + Props.D_0D0096B8[0] = 3.3333332f; + Props.D_0D0096B8[1] = 3.9166667f; + Props.D_0D0096B8[2] = 4.5f; + Props.D_0D0096B8[3] = 5.0833334f; + + Props.D_0D009808[0] = 3.75f; + Props.D_0D009808[1] = 5.1666665f; + Props.D_0D009808[2] = 5.75f; + Props.D_0D009808[3] = 6.3333334f; + + //Props.PathTable[0] = test_course_path; + Props.PathTable[1] = NULL; + Props.PathTable[2] = NULL; + Props.PathTable[3] = NULL; + + //Props.PathTable2[0] = test_course_path; + Props.PathTable2[1] = NULL; + Props.PathTable2[2] = NULL; + Props.PathTable2[3] = NULL; + + Props.Clouds = gKalimariDesertClouds; + Props.CloudList = gLuigiRacewayClouds; + Props.MinimapFinishlineX = 0; + Props.MinimapFinishlineY = 0; + + Props.Skybox.TopRight = {120, 140, 188}; + Props.Skybox.BottomRight = {216, 232, 248}; + Props.Skybox.BottomLeft = {216, 232, 248}; + Props.Skybox.TopLeft = {40, 184, 208}; + Props.Skybox.FloorTopRight = {0, 0, 0}; + Props.Skybox.FloorBottomRight = {0, 0, 0}; + Props.Skybox.FloorBottomLeft = {0, 0, 0}; + Props.Skybox.FloorTopLeft = {0, 0, 0}; +} + +void TestCourse::Load() { + gSegmentTable[4] = reinterpret_cast<uintptr_t>(&mario_Plane_001_mesh_vtx_1[0]); + //gSegmentTable[7] = reinterpret_cast<uintptr_t>(&gfx[0]); +} + +void TestCourse::LoadTextures() { + dma_textures(gTextureTrees1, 0x0000035BU, 0x00000800U); + D_802BA058 = dma_textures(gTexturePiranhaPlant1, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant2, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant3, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant4, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant5, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant6, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant7, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant8, 0x000003E8U, 0x00000800U); + dma_textures(gTexturePiranhaPlant9, 0x000003E8U, 0x00000800U); +} + +void TestCourse::SpawnActors() { +struct ActorSpawnData itemboxes[] = { + { 40, 0, -800, 0}, + { -40, 0, -800, 0}, + { 0, 0, -800, 0}, + { 999, 6, 482, 0}, + { 1064, 8, 275, {0}}, + { 1028, 5, -39 , {0}}, + { 320, 0, 1020, {0}}, + { 293, 0, 950, {0}}, + {{ -32768, 0, 0 }, {0}}, +}; + +struct ActorSpawnData rocks[] = { + {{ 200, 3000, 200 }, {0}}, + {{ 350, 2500, 300 }, {1}}, + {{ 400, 2000, 350 }, {2}}, + {{ -32768, 0, 0 }, {0}}, +}; + spawn_all_item_boxes((const char*)itemboxes); + spawn_falling_rocks((const char*)rocks); +} + +void TestCourse::Init() {} + +// Likely sets minimap boundaries +void TestCourse::MinimapSettings() { + D_8018D220 = reinterpret_cast<uint8_t (*)[1024]>(dma_textures(gTextureExhaust5, 0x443, 0x1000)); + D_8018D2A0 = 0.022f; + D_8018D2E0 = 6; + D_8018D2E8 = 28; + D_8018D2C0[0] = 260; + D_8018D2D8[0] = 170; + D_80165718 = 0; + D_80165720 = 5; + D_80165728 = -240; +} + +void TestCourse::InitCourseObjects() {} + +void TestCourse::SomeSounds() {} + +void TestCourse::WhatDoesThisDo(Player* player, int8_t playerId) { + if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x19B) && + ((s16) gNearestWaypointByPlayerId[playerId] < 0x1B9)) { + if (D_80165300[playerId] != 1) { + func_800CA288(playerId, 0x55); + } + D_80165300[playerId] = 1; + } else { + if (D_80165300[playerId] != 0) { + func_800CA2B8(playerId); + D_80165300[playerId] = 0; + } + } +} + +void TestCourse::WhatDoesThisDoAI(Player* player, int8_t playerId) { + if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x19B) && + ((s16) gNearestWaypointByPlayerId[playerId] < 0x1B9)) { + if (D_80165300[playerId] != 1) { + func_800CA2E4(playerId, 0x55); + } + D_80165300[playerId] = 1; + } else { + if (D_80165300[playerId] != 0) { + func_800CA30C(playerId); + D_80165300[playerId] = 0; + } + } +} + +void TestCourse::SpawnBombKarts() { + World* world = GetWorld(); + + if (world) { + world->SpawnObject(std::make_unique<OBombKart>(40, 3, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(100, 3, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(265, 3, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(285, 1, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(420, 1, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(0, 0, 0.8333333, 0, 0, 0, 0)); + world->SpawnObject(std::make_unique<OBombKart>(0, 0, 0.8333333, 0, 0, 0, 0)); + } +} + +// Positions the finishline on the minimap +void TestCourse::MinimapFinishlinePosition() { + //! todo: Place hard-coded values here. + draw_hud_2d_texture_8x8(this->Props.MinimapFinishlineX, this->Props.MinimapFinishlineY, (u8*) common_texture_minimap_finish_line); +} + +void TestCourse::SetStaffGhost() {} + +void TestCourse::BeginPlay() { } +void TestCourse::Render(struct UnkStruct_800DC5EC* arg0) { + gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); + gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); + func_802B5D64(D_800DC610, D_802B87D4, 0, 1); + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); + + if (func_80290C20(arg0->camera) == 1) { + gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); + gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); + // d_course_big_donut_packed_dl_DE8 + } + gSPDisplayList(gDisplayListHead++, mario_Plane_001_mesh); +} + +void TestCourse::RenderCredits() { +} + +void TestCourse::Collision() {} + +void TestCourse::GenerateCollision() { + generate_collision_mesh_with_defaults(mario_Plane_001_mesh); + + parse_course_displaylists((const char*)test_course_addr); + func_80295C6C(); + D_8015F8E4 = gCourseMinY - 10.0f; +} + +void TestCourse::Destroy() { } |
