diff options
| author | coco875 <59367621+coco875@users.noreply.github.com> | 2025-12-07 15:34:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-07 07:34:53 -0700 |
| commit | 02ad54ca72f5baf4614cb9b7c30f8dd780764d90 (patch) | |
| tree | bd2719a154830d4c538e0caf91eb845ddb45552d /src/engine | |
| parent | eec7d650482134352b7cde4801b979ce1ed2044e (diff) | |
Refactor yaml and remove segment (#531)
* move yaml (still need to fix header path)
* fix header
* change kart to karts and add migration
* fix include
* Update migration.py
* fix common_texture_debug_font extraction
* Update torch
* update torch and header
* unduplicate texture for tumble
* Update torch
* Update migration.py
* put the sort by default
* fix replace_segmented_textures_with_o2r_textures
* Update torch
* fix yamls
* add manual_segments in data of course
* comment out replace_segmented_textures_with_o2r_textures and segment 3
* remove segment 5
* (wip) remove segment 6
still plenty of thing to do
* more vtx
* more change
* Update torch
* small fix
* Update BansheeBoardwalk.cpp
* fix blockFort
* Delete test.yaml
* fix bowser castle and simplify track sections
* fix choco mountain
* clean banshee
* fix dk jungle
* fix double deck
* fix macos
* fix error
* fix macos ci
* Update torch
* Update torch
* fix frappe snowland
* fix kalimari desert
* fix koopa troopa beach
* fix luigi raceway
* fix mario raceway and simplify thing
* fix moo moo farm
* fix rainbow road
* Update torch
* Update torch
* hopefully fix windows error
* fix a small error
* fix royal raceway (and podium in theory)
* fix sherbet_land
* fix skyscraper
* fix toads turnpike
* fix wario stadium
* fix yoshi valley
* update torch
* more clang tidy rules
* REMOVE totally SEGMENT (sorry for the PR)
* remove unused field in course and props and unused packed asset
* fix kart texture
* fix particle
* fix track section and transparency
* try fix mode extra
* fix macos build and render
* fix collision in extra
* small change and try fix windows error
* a little of clean
* more cleanup
* forget header and more clean up
* Update Makefile
* fix credits
* fix kart texture offset
* remove LoadTextures and add Unload
* fix definitevely mirror mode
* add unload but it's not perfect
* revert a bad fix
* clean no longer used python script
* fix crash with player
* being able to load the same course twice
* add a comment on DrawWater
* fix render of transparent object
* better hack
* add a proper migration instruction
* fix number
* add basic modsmanager
* add meta/mods.toml
* Update EditorMath.h
* Update ModsManager.cpp
* basic modManager (maybe I should rename it ModLoader)
* use range on dependencies
* add information about mods.toml
* fix coment
* some rename around
* Delete beta-to-v1.md
* Update migrations.md
* Update textures-pack.md
* Update modding.md
* Update modding.md
* clean yamls_old
* move to mods in engine
* rename ModsManger to ModManager
* move init and unload at the top
* rename ModsMetadata to ModMetadata
* fix header
* Update ModManager.cpp
* put core mods at top
Diffstat (limited to 'src/engine')
96 files changed, 1480 insertions, 1487 deletions
diff --git a/src/engine/HM_Intro.cpp b/src/engine/HM_Intro.cpp index 1e05d1639..bbbd6d910 100644 --- a/src/engine/HM_Intro.cpp +++ b/src/engine/HM_Intro.cpp @@ -167,8 +167,7 @@ void HarbourMastersIntro::HM_DrawIntro() { void HarbourMastersIntro::Setup() { u16 perspNorm; - - move_segment_table_to_dmem(); + gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); // Setup camera perspective diff --git a/src/engine/ModelLoader.cpp b/src/engine/ModelLoader.cpp deleted file mode 100644 index b73d98aee..000000000 --- a/src/engine/ModelLoader.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "ModelLoader.h" -#include "port/Engine.h" -#include "engine/courses/Course.h" - -extern "C" { -#include "memory.h" -} - -void ModelLoader::Add(LoadModelList list) { - _deferredList.push_back(list); -} - -void ModelLoader::Load() { - if (_hasRan) { // Ensure this does not get ran multiple times - printf("ModelLoader.cpp has already been ran once.\n"); - return; - } - _hasRan = true; - - // Set to track processed courses - std::unordered_set<std::shared_ptr<Course>> processedCourses; - - for (auto& list : _deferredList) { - // Check if the course has already been processed - if (processedCourses.find(list.course) != processedCourses.end()) { - continue; // Skip if already processed - } - - // Process the course - ModelLoader::Extract(list.course); - - // Mark this course as processed - processedCourses.insert(list.course); - } -} - -void ModelLoader::Extract(std::shared_ptr<Course> course) { - std::shared_ptr<Course> saveCourse = gWorldInstance.CurrentCourse; - gWorldInstance.CurrentCourse = course; // Quick hack so that `get_texture` will find the right textures. - - size_t vtxSize = (ResourceGetSizeByName(course->vtx) / sizeof(CourseVtx)) * sizeof(Vtx); - size_t texSegSize; - - // Convert course vtx to vtx - Vtx* vtx = reinterpret_cast<Vtx*>(malloc(vtxSize)); - if (vtx == NULL) { - printf("ModelLoader: Failed to allocate vertex buffer for course: %s\n", course->Props.Name); - return; - } - func_802A86A8(reinterpret_cast<CourseVtx*>(LOAD_ASSET_RAW(course->vtx)), vtx, vtxSize / sizeof(Vtx)); - - // Extract packed DLs - u8* packed = reinterpret_cast<u8*>(LOAD_ASSET_RAW(course->gfx)); - Gfx* gfx = reinterpret_cast<Gfx*>(malloc(sizeof(Gfx) * course->gfxSize)); // Size of unpacked DLs - if (gfx == NULL) { - printf("ModelLoader: Failed to allocate course displaylist memory for course: %s\n", course->Props.Name); - return; - } - - displaylist_unpack(reinterpret_cast<uintptr_t*>(gfx), reinterpret_cast<uintptr_t>(packed), 0); - - // Now that the data has been retrieved, extract the model data and save to provided buffers. - for (auto& list : _deferredList) { - // Ensure the list matches the course being extracted. - if (list.course != course) { - return; - } - - memcpy(list.vtxBuffer, &vtx[list.vtxStart], list.vtxBufferSize * sizeof(Vtx)); - memcpy(list.gfxBuffer, &gfx[list.gfxStart], list.gfxBufferSize * sizeof(Gfx)); - - UpdateVtx(list); - - } - - free(vtx); - free(gfx); - - _deferredList.clear(); - gWorldInstance.CurrentCourse = saveCourse; -} - -void ModelLoader::UpdateVtx(LoadModelList list) { - for (size_t i = 0; i < list.gfxStart + list.gfxBufferSize; i++) { - Gfx* gfx = &list.gfxBuffer[i]; - - // Check if the current Gfx command is G_VTX - if (GFX_GET_OPCODE(gfx->words.w0) == (G_VTX << 24)) { - // Re-write the vtx to point at the provided vtx buffer. - size_t vtxIndex = (gfx->words.w1 / sizeof(Vtx)) - list.vtxStart; - gfx->words.w1 = reinterpret_cast<uintptr_t>(&list.vtxBuffer[vtxIndex]); - } - } -} diff --git a/src/engine/ModelLoader.h b/src/engine/ModelLoader.h deleted file mode 100644 index 0bc233706..000000000 --- a/src/engine/ModelLoader.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once - -#include <libultraship.h> -#include "engine/courses/Course.h" - -extern "C" { -#include "common_structs.h" -} - -class Course; - -/** - * - * Lists are deferred until load time so that models that use the same course may all use the same extraction - * - * Note ensure that the buffers passed to LoadModelList are big enough for the requested data. - * - * This class should only be ran once. - * - * - * Usage: - * - * ModelLoader::LoadModelList bowserStatueList = { - .course = gBowsersCastle, - .gfxBuffer = &gBowserStatueGfx[0], - .gfxBufferSize = 162, - .gfxStart = (0x2BB8 / 8), // This is 0x2BB8 / sizeof(N64Gfx) not sizeof(Gfx) - .vtxBuffer = &gBowserStatueVtx[0], - .vtxBufferSize = 717, - .vtxStart = 1942, - }; - * - * gModelLoader.Add(bowserStatueList); - */ - -class ModelLoader { - -public: - struct LoadModelList { - std::shared_ptr<Course> course; - - Gfx* gfxBuffer; // buffer for output gfx - size_t gfxBufferSize; - size_t gfxStart; // The starting point to extract data in NumGfx - - Vtx* vtxBuffer; // buffer for output vtx - size_t vtxBufferSize; - size_t vtxStart; // The starting point to extract data in NumVtx - }; - - void Add(LoadModelList list); - void Load(); -private: - struct CourseMap { - - }; - - void Extract(std::shared_ptr<Course> course); - void UpdateVtx(LoadModelList list); - - std::vector<LoadModelList> _deferredList; - bool _hasRan = false; -}; diff --git a/src/engine/PlayerBombKart.cpp b/src/engine/PlayerBombKart.cpp index 7f8d05f8d..7b571d003 100644 --- a/src/engine/PlayerBombKart.cpp +++ b/src/engine/PlayerBombKart.cpp @@ -3,7 +3,8 @@ extern "C" { #include "common_structs.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" +#include "assets/textures/common_data.h" #include "camera.h" #include "render_objects.h" #include "math_util_2.h" diff --git a/src/engine/RaceManager.cpp b/src/engine/RaceManager.cpp index ae1ef828f..75b871cde 100644 --- a/src/engine/RaceManager.cpp +++ b/src/engine/RaceManager.cpp @@ -13,9 +13,54 @@ extern "C" { RaceManager::RaceManager(World& world) : WorldContext(world) { } +std::unordered_map<uintptr_t, std::shared_ptr<Vtx>> mirroredVtxCache; + +// Populates a collision mesh for mirror mode +extern "C" void add_triangle_to_collision_mesh(Vtx* vtx1, Vtx* vtx2, Vtx* vtx3, Vtx** outVtx1, Vtx** outVtx2, Vtx** outVtx3) { + if (gIsMirrorMode != 0) { + auto getOrCreateMirrored = [](Vtx* original) -> Vtx* { + uintptr_t key = reinterpret_cast<uintptr_t>(original); + + auto it = mirroredVtxCache.find(key); + if (it != mirroredVtxCache.end()) { + return it->second.get(); + } + + auto newVtx = std::make_shared<Vtx>(*original); + newVtx->v.ob[0] = -newVtx->v.ob[0]; + + mirroredVtxCache[key] = newVtx; + + return newVtx.get(); + }; + + Vtx* m1 = getOrCreateMirrored(vtx1); + Vtx* m2 = getOrCreateMirrored(vtx2); + Vtx* m3 = getOrCreateMirrored(vtx3); + + // don't invert winding here, already done in the gfx + *outVtx1 = m1; + *outVtx2 = m2; + *outVtx3 = m3; + + } else { + // Pas de miroir, on passe les originaux + *outVtx1 = vtx1; + *outVtx2 = vtx2; + *outVtx3 = vtx3; + } +} + void RaceManager::Load() { - if (WorldContext.CurrentCourse) { - WorldContext.CurrentCourse->Load(); + if (WorldContext.GetCurrentCourse()) { + mirroredVtxCache.clear(); + WorldContext.GetCurrentCourse()->Load(); + } +} + +void RaceManager::UnLoad() { + if (WorldContext.GetCurrentCourse()) { + WorldContext.GetCurrentCourse()->UnLoad(); } } @@ -29,7 +74,7 @@ void RaceManager::PreInit() { } void RaceManager::BeginPlay() { - auto course = WorldContext.CurrentCourse; + auto course = WorldContext.GetCurrentCourse(); if (course) { // Do not spawn finishline in credits or battle mode. And if bSpawnFinishline. diff --git a/src/engine/RaceManager.h b/src/engine/RaceManager.h index fb38bb33c..1df65f06b 100644 --- a/src/engine/RaceManager.h +++ b/src/engine/RaceManager.h @@ -1,5 +1,17 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif +#include <libultraship/libultra/gbi.h> + +void add_triangle_to_collision_mesh(Vtx* vtx1, Vtx* vtx2, Vtx* vtx3, Vtx** outVtx1, Vtx** outVtx2, Vtx** outVtx3); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus class World; /** @@ -22,6 +34,7 @@ class RaceManager { public: RaceManager(World& world); virtual void Load(); // virtual required here in the base class to allow inherited classes to override + virtual void UnLoad(); virtual void PreInit(); virtual void BeginPlay(); virtual void PostInit(); @@ -29,3 +42,5 @@ public: protected: World& WorldContext; }; + +#endif
\ No newline at end of file diff --git a/src/engine/Smoke.cpp b/src/engine/Smoke.cpp index 6a4566df4..2ae315a84 100644 --- a/src/engine/Smoke.cpp +++ b/src/engine/Smoke.cpp @@ -13,7 +13,8 @@ extern "C" { #include "code_80057C60.h" #include "update_objects.h" #include "math_util_2.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" +#include "assets/textures/common_data.h" } //! @todo: This should be an Object class one day diff --git a/src/engine/World.cpp b/src/engine/World.cpp index cca7a2199..0922e6c6e 100644 --- a/src/engine/World.cpp +++ b/src/engine/World.cpp @@ -17,8 +17,8 @@ extern "C" { #include "defines.h" #include "audio/external.h" #include "menus.h" -#include "common_data.h" -#include "mario_raceway_data.h" +#include "assets/models/common_data.h" +#include "assets/models/tracks/mario_raceway/mario_raceway_data.h" } std::shared_ptr<Course> CurrentCourse; @@ -41,8 +41,18 @@ void World::AddCup(Cup* cup) { Cups.push_back(cup); } +void World::SetCurrentCourse(std::shared_ptr<Course> course) { + if (CurrentCourse) { + UnLoadCourse(); + } + if (CurrentCourse == course) { + return; + } + CurrentCourse = std::move(course); +} + void World::SetCourseFromCup() { - CurrentCourse = CurrentCup->GetCourse(); + SetCurrentCourse(CurrentCup->GetCourse()); } TrainCrossing* World::AddCrossing(Vec3f position, u32 waypointMin, u32 waypointMax, f32 approachRadius, @@ -91,7 +101,7 @@ void World::SetCupIndex(size_t index) { CupIndex = index; } -void World::SetCup(Cup* cup) { +void World::SetCurrentCup(Cup* cup) { if (cup) { CurrentCup = cup; CurrentCup->CursorPosition = 0; @@ -102,7 +112,7 @@ void World::SetCourse(const char* name) { //! @todo Use content dictionary instead for (size_t i = 0; i < Courses.size(); i++) { if (strcmp(Courses[i]->Props.Name, name) == 0) { - CurrentCourse = Courses[i]; + SetCurrentCourse(Courses[i]); break; } } @@ -115,7 +125,7 @@ void World::NextCourse() { } else { CourseIndex = 0; } - gWorldInstance.CurrentCourse = Courses[CourseIndex]; + gWorldInstance.SetCurrentCourse(Courses[CourseIndex]); } void World::PreviousCourse() { @@ -124,7 +134,7 @@ void World::PreviousCourse() { } else { CourseIndex = Courses.size() - 1; } - gWorldInstance.CurrentCourse = Courses[CourseIndex]; + gWorldInstance.SetCurrentCourse(Courses[CourseIndex]); } AActor* World::AddActor(AActor* actor) { diff --git a/src/engine/World.h b/src/engine/World.h index 4e1e6e06e..214814f1f 100644 --- a/src/engine/World.h +++ b/src/engine/World.h @@ -9,6 +9,7 @@ #include "TrainCrossing.h" #include <memory> #include <unordered_map> +#include <utility> #include "RaceManager.h" #include "Actor.h" #include "StaticMeshActor.h" @@ -16,6 +17,7 @@ #include "editor/Editor.h" #include "editor/GameObject.h" +#include "port/Game.h" extern "C" { #include "camera.h" @@ -46,6 +48,9 @@ typedef struct Matrix { : Hud(200), Objects(1000) {} }; +private: + std::shared_ptr<Course> CurrentCourse; + Cup* CurrentCup; public: explicit World(); @@ -81,7 +86,10 @@ public: void Reset(void); // Sets OObjects or AActors static member variables back to default values void AddCup(Cup*); - void SetCup(Cup* cup); + void SetCurrentCup(Cup* cup); + Cup* GetCurrentCup() { + return CurrentCup; + } void SetCupIndex(size_t index); const char* GetCupName(); u32 GetCupIndex(); @@ -92,6 +100,12 @@ public: World* GetWorld(void); void ClearWorld(void); + // getter/setter for current course + std::shared_ptr<Course> GetCurrentCourse() { + return CurrentCourse; + } + + void SetCurrentCourse(std::shared_ptr<Course> course); // These are only for browsing through the course list void SetCourse(const char*); @@ -99,7 +113,7 @@ public: void SetCourseByType() { for (const auto& course : Courses) { if (dynamic_cast<T*>(course.get())) { - CurrentCourse = course; + SetCurrentCourse(course); return; } } @@ -110,10 +124,6 @@ public: Matrix Mtx; - - std::shared_ptr<Course> CurrentCourse; - Cup* CurrentCup; - std::vector<Cup*> Cups; size_t CupIndex = 1; diff --git a/src/engine/actors/BowserStatue.cpp b/src/engine/actors/BowserStatue.cpp index af9036fc3..258dc9de3 100644 --- a/src/engine/actors/BowserStatue.cpp +++ b/src/engine/actors/BowserStatue.cpp @@ -6,7 +6,7 @@ extern "C" { #include "common_structs.h" #include "math_util.h" #include "main.h" -#include "assets/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" } Vtx gBowserStatueVtx[717]; diff --git a/src/engine/actors/BowserStatue.h b/src/engine/actors/BowserStatue.h index 51d58c0f1..1e4fbaff2 100644 --- a/src/engine/actors/BowserStatue.h +++ b/src/engine/actors/BowserStatue.h @@ -7,7 +7,7 @@ extern "C" { #include "common_structs.h" -#include "assets/other_textures.h" +#include "assets/textures/other_textures.h" } extern Vtx gBowserStatueVtx[717]; diff --git a/src/engine/actors/Cloud.cpp b/src/engine/actors/Cloud.cpp index 34f6466c9..70acd4101 100644 --- a/src/engine/actors/Cloud.cpp +++ b/src/engine/actors/Cloud.cpp @@ -11,7 +11,7 @@ extern "C" { #include "math_util.h" #include "actor_types.h" #include "actors.h" -#include "other_textures.h" +#include "assets/textures/other_textures.h" extern f32 gKartHopInitialVelocityTable[]; extern f32 gKartGravityTable[]; } diff --git a/src/engine/actors/FallingRock.cpp b/src/engine/actors/FallingRock.cpp index 80e968294..958c23e71 100644 --- a/src/engine/actors/FallingRock.cpp +++ b/src/engine/actors/FallingRock.cpp @@ -2,7 +2,8 @@ #include <libultra/gbi.h> #include "CoreMath.h" -#include <assets/choco_mountain_data.h> +#include <assets/textures/tracks/choco_mountain/choco_mountain_data.h> +#include <assets/models/tracks/choco_mountain/choco_mountain_data.h> #include "port/interpolation/FrameInterpolation.h" #include "port/Game.h" diff --git a/src/engine/actors/Finishline.cpp b/src/engine/actors/Finishline.cpp index 52fa9c895..ef2846997 100644 --- a/src/engine/actors/Finishline.cpp +++ b/src/engine/actors/Finishline.cpp @@ -5,7 +5,7 @@ #include "Finishline.h" #include "engine/Actor.h" #include "World.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "src/port/Game.h" #include "port/interpolation/FrameInterpolation.h" diff --git a/src/engine/actors/MarioSign.cpp b/src/engine/actors/MarioSign.cpp index b5fc51860..3ca926b02 100644 --- a/src/engine/actors/MarioSign.cpp +++ b/src/engine/actors/MarioSign.cpp @@ -1,7 +1,7 @@ #include "MarioSign.h" #include <libultra/gbi.h> -#include <assets/mario_raceway_data.h> +#include <assets/models/tracks/mario_raceway/mario_raceway_data.h> #include "CoreMath.h" extern "C" { diff --git a/src/engine/actors/Ship.h b/src/engine/actors/Ship.h index c1f082c78..9c05a7184 100644 --- a/src/engine/actors/Ship.h +++ b/src/engine/actors/Ship.h @@ -8,7 +8,7 @@ extern "C" { #include "common_structs.h" -#include "assets/other_textures.h" +#include "assets/textures/other_textures.h" } class AShip : public AActor { diff --git a/src/engine/actors/SpaghettiShip.cpp b/src/engine/actors/SpaghettiShip.cpp index 63ed048ec..880933b42 100644 --- a/src/engine/actors/SpaghettiShip.cpp +++ b/src/engine/actors/SpaghettiShip.cpp @@ -52,7 +52,7 @@ void ASpaghettiShip::Draw(Camera *camera) { Mat4 resultMtx; Vec3f hullPos = {Pos[0], Pos[1], Pos[2]}; Vec3s hullRot = {Rot[0], Rot[1], Rot[2]}; - Vec3s rot = {WheelRot.pitch, WheelRot.yaw, WheelRot.roll}; + Vec3s rot = {(s16) WheelRot.pitch, (s16) WheelRot.yaw, (s16) WheelRot.roll}; gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); diff --git a/src/engine/actors/SpaghettiShip.h b/src/engine/actors/SpaghettiShip.h index fef2e05a5..2f90202f7 100644 --- a/src/engine/actors/SpaghettiShip.h +++ b/src/engine/actors/SpaghettiShip.h @@ -8,7 +8,7 @@ extern "C" { #include "common_structs.h" -#include "assets/other_textures.h" +#include "assets/textures/other_textures.h" } class ASpaghettiShip : public AActor { diff --git a/src/engine/actors/Starship.h b/src/engine/actors/Starship.h index c76c10c68..d0e775e2f 100644 --- a/src/engine/actors/Starship.h +++ b/src/engine/actors/Starship.h @@ -8,7 +8,7 @@ extern "C" { #include "common_structs.h" -#include "assets/other_textures.h" +#include "assets/textures/other_textures.h" } class AStarship : public AActor { diff --git a/src/engine/actors/Text.cpp b/src/engine/actors/Text.cpp index 06a74c54d..c6f84e8d2 100644 --- a/src/engine/actors/Text.cpp +++ b/src/engine/actors/Text.cpp @@ -12,10 +12,10 @@ extern "C" { #include "defines.h" #include "main.h" #include "menu_items.h" -#include "assets/data_segment2.h" +#include "assets/models/data_segment2.h" #include "render_player.h" #include "math_util.h" -#include "assets/texture_data_2.h" +#include "assets/textures/texture_data_2.h" #include "render_objects.h" #include "common_structs.h" #include "code_80005FD0.h" diff --git a/src/engine/actors/WarioSign.cpp b/src/engine/actors/WarioSign.cpp index 66cffcb4b..dac6b55b9 100644 --- a/src/engine/actors/WarioSign.cpp +++ b/src/engine/actors/WarioSign.cpp @@ -1,7 +1,7 @@ #include "WarioSign.h" #include <libultra/gbi.h> -#include <assets/wario_stadium_data.h> +#include <assets/models/tracks/wario_stadium/wario_stadium_data.h> extern "C" { #include "common_structs.h" diff --git a/src/engine/courses/BansheeBoardwalk.cpp b/src/engine/courses/BansheeBoardwalk.cpp index b9634cd60..c3ea03e60 100644 --- a/src/engine/courses/BansheeBoardwalk.cpp +++ b/src/engine/courses/BansheeBoardwalk.cpp @@ -1,18 +1,22 @@ +#include <cstdint> #include <libultraship.h> #include <libultra/gbi.h> +#include <unordered_map> #include <vector> #include <memory> #include "BansheeBoardwalk.h" #include "World.h" +#include "align_asset_macro.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" #include "engine/objects/CheepCheep.h" #include "engine/objects/TrashBin.h" #include "engine/objects/Bat.h" #include "engine/objects/Boos.h" -#include "assets/banshee_boardwalk_data.h" -#include "assets/boo_frames.h" +#include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/other/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/textures/boo_frames.h" extern "C" { #include "main.h" @@ -28,47 +32,17 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course.h" -extern const char *banshee_boardwalk_dls[]; +extern const char *banshee_boardwalk_dls[100]; } -const course_texture banshee_boardwalk_textures[] = { - { gTexture6447C4, 0x0106, 0x0800, 0x0 }, - { gTexture676FB0, 0x0525, 0x0800, 0x0 }, - { gTexture643B3C, 0x0798, 0x0800, 0x0 }, - { gTexture64BB60, 0x0169, 0x0800, 0x0 }, - { gTexture64BCCC, 0x0450, 0x0800, 0x0 }, - { gTexture64FBF4, 0x0274, 0x0800, 0x0 }, - { gTexture651B20, 0x041D, 0x0800, 0x0 }, - { gTexture66262C, 0x02F7, 0x0800, 0x0 }, - { gTexture668728, 0x01F5, 0x0800, 0x0 }, - { gTexture66A3DC, 0x07C5, 0x0800, 0x0 }, - { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTexture66CD64, 0x02C0, 0x0800, 0x0 }, - { gTexture66D698, 0x0370, 0x0800, 0x0 }, - { gTexture66E608, 0x05E8, 0x0800, 0x0 }, - { gTexture67B388, 0x03D2, 0x0800, 0x0 }, - { gTextureSignWelcome0, 0x0A2E, 0x1000, 0x0 }, - { gTextureSignWelcome1, 0x0A0A, 0x1000, 0x0 }, - { gTextureSignWoodenBack0, 0x06EF, 0x1000, 0x0 }, - { gTextureSignWoodenBack1, 0x06D1, 0x1000, 0x0 }, - { gTextureSignWoodRedArrow, 0x04E1, 0x1000, 0x0 }, - { gTexture68D940, 0x057D, 0x0800, 0x0 }, - { gTexture685AC0, 0x07CC, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - BansheeBoardwalk::BansheeBoardwalk() { - this->vtx = d_course_banshee_boardwalk_vertex; - this->gfx = d_course_banshee_boardwalk_packed_dls; - this->gfxSize = 3689; - Props.textures = banshee_boardwalk_textures; Props.Minimap.Texture = minimap_banshee_boardwalk; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -141,24 +115,44 @@ BansheeBoardwalk::BansheeBoardwalk() { Props.Sequence = MusicSeq::MUSIC_SEQ_BANSHEE_BOARDWALK; Props.WaterLevel = -80.0f; - for (size_t i = 0; i < 100; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) banshee_boardwalk_dls[i], Props.textures); - } } void BansheeBoardwalk::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(banshee_boardwalk_dls); i++) { + InvertTriangleWindingByName(banshee_boardwalk_dls[i]); + } + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_7228); + + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_5CD0); + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_4E60); + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_69B0); + + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_580); + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_60); + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_540); + + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_6310); + + InvertTriangleWindingByName(d_course_banshee_boardwalk_dl_B278); + + // transparent DLs + InvertTriangleWindingByName(d_course_banshee_boardwalk_packed_dl_878); + } + D_800DC5BC = 1; D_801625EC = 0; D_801625F4 = 0; D_801625F0 = 0; - parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_banshee_boardwalk_track_sections)); + parse_course_displaylists((TrackSections*) LOAD_ASSET_RAW(d_course_banshee_boardwalk_track_sections)); func_80295C6C(); - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07000878), 128, 0, 0, 0); + find_vtx_and_set_colours((Gfx*) d_course_banshee_boardwalk_packed_dl_878, 128, 0, 0, 0); } -void BansheeBoardwalk::LoadTextures() { +void BansheeBoardwalk::UnLoad() { + RestoreTriangleWinding(); } void BansheeBoardwalk::BeginPlay() { @@ -264,7 +258,7 @@ void BansheeBoardwalk::Render(struct UnkStruct_800DC5EC* arg0) { gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_DECALRGBA); // d_course_banshee_boardwalk_packed_dl_7228 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07007228))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_7228); gSPFogPosition(gDisplayListHead++, D_802B87B0, D_802B87B4); @@ -279,11 +273,11 @@ void BansheeBoardwalk::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); // d_course_banshee_boardwalk_packed_dl_5CD0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07005CD0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_5CD0); // d_course_banshee_boardwalk_packed_dl_4E60 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07004E60))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_4E60); // d_course_banshee_boardwalk_packed_dl_69B0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070069B0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_69B0); render_course_segments(banshee_boardwalk_dls, arg0); @@ -293,15 +287,15 @@ void BansheeBoardwalk::Render(struct UnkStruct_800DC5EC* arg0) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH); // d_course_banshee_boardwalk_packed_dl_580 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000580))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_580); // d_course_banshee_boardwalk_packed_dl_60 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000060))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_60); // d_course_banshee_boardwalk_packed_dl_540 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000540))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_540); if (camera->pos[1] < -20.0f) { // d_course_banshee_boardwalk_packed_dl_6310 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07006310))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_6310); } spA8[0] = camera->pos[0]; spA8[1] = -82.0f; @@ -347,13 +341,13 @@ void BansheeBoardwalk::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pat gDPSetBlendMask(gDisplayListHead++, 0xFF); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); // d_course_banshee_boardwalk_packed_dl_878 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*) 0x07000878)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_banshee_boardwalk_packed_dl_878); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); gDPPipeSync(gDisplayListHead++); } void BansheeBoardwalk::CreditsSpawnActors() { - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000878), 0x32, 0, 0, 0); + find_vtx_and_set_colours((Gfx*) d_course_banshee_boardwalk_packed_dl_878, 0x32, 0, 0, 0); } void BansheeBoardwalk::Destroy() { diff --git a/src/engine/courses/BansheeBoardwalk.h b/src/engine/courses/BansheeBoardwalk.h index cc5b72213..a299709db 100644 --- a/src/engine/courses/BansheeBoardwalk.h +++ b/src/engine/courses/BansheeBoardwalk.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/banshee_boardwalk_vertices.h" - #include "assets/banshee_boardwalk_displaylists.h" - #include "assets/banshee_boardwalk_data.h" + #include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_vertices.h" + #include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_displaylists.h" + #include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; //virtual void InitClouds() override; virtual void InitCourseObjects() override; diff --git a/src/engine/courses/BigDonut.cpp b/src/engine/courses/BigDonut.cpp index 1c8fd5b76..b5c6bbff3 100644 --- a/src/engine/courses/BigDonut.cpp +++ b/src/engine/courses/BigDonut.cpp @@ -6,7 +6,8 @@ #include "BigDonut.h" #include "World.h" #include "engine/objects/BombKart.h" -#include "assets/big_donut_data.h" +#include "assets/models/tracks/big_donut/big_donut_data.h" +#include "assets/other/tracks/big_donut/big_donut_data.h" extern "C" { #include "main.h" @@ -22,27 +23,16 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" -extern const char* big_donut_dls[]; extern s16 currentScreenSection; } -const course_texture big_donut_textures[] = { - { gTexture66ABA4, 0x0312, 0x0800, 0x0 }, { gTexture6747C4, 0x0145, 0x0800, 0x0 }, - { gTexture67490C, 0x021C, 0x0800, 0x0 }, { gTexture64BA50, 0x0110, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - BigDonut::BigDonut() { - this->vtx = d_course_big_donut_vertex; - this->gfx = d_course_big_donut_packed_dls; - this->gfxSize = 528; - Props.textures = big_donut_textures; Props.Minimap.Texture = minimap_big_donut; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -114,20 +104,30 @@ BigDonut::BigDonut() { void BigDonut::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + InvertTriangleWindingByName(d_course_big_donut_packed_dl_DE8); + InvertTriangleWindingByName(d_course_big_donut_packed_dl_450); + InvertTriangleWindingByName(d_course_big_donut_packed_dl_AC0); + InvertTriangleWindingByName(d_course_big_donut_packed_dl_D20); + InvertTriangleWindingByName(d_course_big_donut_packed_dl_230); + } // d_course_big_donut_packed_dl_1018 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x07001018), 6); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_big_donut_packed_dl_1018, 6); // d_course_big_donut_packed_dl_450 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x07000450), 6); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_big_donut_packed_dl_450, 6); // d_course_big_donut_packed_dl_AC0 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x07000AC0), 6); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_big_donut_packed_dl_AC0, 6); // d_course_big_donut_packed_dl_B58 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x07000B58), 6); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_big_donut_packed_dl_B58, 6); // d_course_big_donut_packed_dl_230 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x07000230), 6); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_big_donut_packed_dl_230, 6); func_80295C6C(); } +void BigDonut::UnLoad() { +} + void BigDonut::BeginPlay() { spawn_all_item_boxes((ActorSpawnData*) LOAD_ASSET_RAW(d_course_big_donut_item_box_spawns)); @@ -153,16 +153,16 @@ void BigDonut::Render(struct UnkStruct_800DC5EC* arg0) { 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++, (segmented_gfx_to_virtual((void*) 0x07000DE8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_big_donut_packed_dl_DE8); } // d_course_big_donut_packed_dl_450 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*) 0x07000450))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_big_donut_packed_dl_450); // d_course_big_donut_packed_dl_AC0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*) 0x07000AC0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_big_donut_packed_dl_AC0); // d_course_big_donut_packed_dl_D20 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*) 0x07000D20))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_big_donut_packed_dl_D20); // d_course_big_donut_packed_dl_230 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*) 0x07000230))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_big_donut_packed_dl_230); } void BigDonut::RenderCredits() { diff --git a/src/engine/courses/BigDonut.h b/src/engine/courses/BigDonut.h index bc10105e1..751d3cbcb 100644 --- a/src/engine/courses/BigDonut.h +++ b/src/engine/courses/BigDonut.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/big_donut_vertices.h" - #include "assets/big_donut_displaylists.h" - #include "assets/big_donut_data.h" + #include "assets/models/tracks/big_donut/big_donut_vertices.h" + #include "assets/models/tracks/big_donut/big_donut_displaylists.h" + #include "assets/models/tracks/big_donut/big_donut_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -22,6 +22,7 @@ public: explicit BigDonut(); virtual void Load() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void Render(struct UnkStruct_800DC5EC*) override; virtual void RenderCredits() override; diff --git a/src/engine/courses/BlockFort.cpp b/src/engine/courses/BlockFort.cpp index 0ec9cb555..a80e4a619 100644 --- a/src/engine/courses/BlockFort.cpp +++ b/src/engine/courses/BlockFort.cpp @@ -5,8 +5,10 @@ #include "BlockFort.h" #include "World.h" +#include "align_asset_macro.h" #include "engine/objects/BombKart.h" -#include "assets/block_fort_data.h" +#include "assets/models/tracks/block_fort/block_fort_data.h" +#include "assets/other/tracks/block_fort/block_fort_data.h" extern "C" { #include "main.h" @@ -22,29 +24,17 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course_offsets.h" -extern const char* block_fort_dls[]; extern s16 currentScreenSection; } -const course_texture block_fort_textures[] = { - { gTexture64286C, 0x010A, 0x0800, 0x0 }, { gTextureGrayCheckerboard, 0x010C, 0x0800, 0x0 }, - { gTextureGrayCobblestone, 0x010C, 0x0800, 0x0 }, { gTexture64275C, 0x0110, 0x0800, 0x0 }, - { gTexture642978, 0x010D, 0x0800, 0x0 }, { gTexture6747C4, 0x0145, 0x0800, 0x0 }, - { gTexture6442D4, 0x0138, 0x0800, 0x0 }, { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - BlockFort::BlockFort() { - this->vtx = d_course_block_fort_vertex; - this->gfx = d_course_block_fort_packed_dls; - this->gfxSize = 699; - Props.textures = block_fort_textures; Props.Minimap.Texture = minimap_block_fort; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -118,11 +108,17 @@ BlockFort::BlockFort() { void BlockFort::Load() { Course::Load(); - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*) 0x070015C0), 1); + if (gIsMirrorMode != 0) { + InvertTriangleWindingByName(d_course_block_fort_packed_dl_15C0); + } + generate_collision_mesh_with_default_section_id((Gfx*) d_course_block_fort_packed_dl_15C0, 1); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } +void BlockFort::UnLoad() { +} + void BlockFort::BeginPlay() { spawn_all_item_boxes((ActorSpawnData*) LOAD_ASSET_RAW(d_course_block_fort_item_box_spawns)); @@ -143,7 +139,7 @@ void BlockFort::Render(struct UnkStruct_800DC5EC* arg0) { gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); // d_course_block_fort_packed_dl_15C0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*) 0x070015C0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_block_fort_packed_dl_15C0); } void BlockFort::Waypoints(Player* player, int8_t playerId) { diff --git a/src/engine/courses/BlockFort.h b/src/engine/courses/BlockFort.h index f0e4c6aa6..296809b03 100644 --- a/src/engine/courses/BlockFort.h +++ b/src/engine/courses/BlockFort.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/block_fort_vertices.h" - #include "assets/block_fort_displaylists.h" - #include "assets/block_fort_data.h" + #include "assets/models/tracks/block_fort/block_fort_vertices.h" + #include "assets/models/tracks/block_fort/block_fort_displaylists.h" + #include "assets/models/tracks/block_fort/block_fort_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,6 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void Render(struct UnkStruct_800DC5EC*) override; virtual void Waypoints(Player*, int8_t) override; diff --git a/src/engine/courses/BowsersCastle.cpp b/src/engine/courses/BowsersCastle.cpp index 9258683ce..32550a636 100644 --- a/src/engine/courses/BowsersCastle.cpp +++ b/src/engine/courses/BowsersCastle.cpp @@ -4,12 +4,14 @@ #include <memory> #include "BowsersCastle.h" +#include "align_asset_macro.h" #include "engine/World.h" #include "engine/courses/Course.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" #include "engine/objects/Thwomp.h" -#include "bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" +#include "assets/other/tracks/bowsers_castle/bowsers_castle_data.h" extern "C" { #include "main.h" @@ -25,7 +27,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -33,46 +35,10 @@ extern "C" { #include "code_8003DC40.h" #include "memory.h" #include "course.h" - extern const char *bowsers_castle_dls[]; + extern const char *bowsers_castle_dls[108]; } -const course_texture bowsers_castle_textures[] = { - { gTexture64313C, 0x01B8, 0x0800, 0x0 }, - { gTexture6528DC, 0x0278, 0x0800, 0x0 }, - { gTexture66ED38, 0x010E, 0x0800, 0x0 }, - { gTexture676C6C, 0x0110, 0x0800, 0x0 }, - { gTexture676EA8, 0x0108, 0x0800, 0x0 }, - { gTexture679D34, 0x0106, 0x0800, 0x0 }, - { gTextureGrass6, 0x023B, 0x0800, 0x0 }, - { gTexture6522E0, 0x05FC, 0x0800, 0x0 }, - { gTexture651F40, 0x039F, 0x0800, 0x0 }, - { gTextureRoofTile, 0x0129, 0x0800, 0x0 }, - { gTextureSignBowser0, 0x07D0, 0x1000, 0x0 }, - { gTextureSignBowser1, 0x064D, 0x1000, 0x0 }, - { gTexture66ABA4, 0x0312, 0x0800, 0x0 }, - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, - { gTexture6733CC, 0x020E, 0x0800, 0x0 }, - { gTexture673118, 0x02B1, 0x0800, 0x0 }, - { gTexture673FF8, 0x035B, 0x0800, 0x0 }, - { gTexture674B28, 0x0230, 0x0800, 0x0 }, - { gTextureSignGreenArrow, 0x025B, 0x1000, 0x0 }, - { gTexture68D834, 0x010A, 0x0800, 0x0 }, - { gTexture676D7C, 0x012C, 0x0800, 0x0 }, - { gTexture67ADF0, 0x0595, 0x0800, 0x0 }, - { gTexture67EFEC, 0x016F, 0x0800, 0x0 }, - { gTexture653DB0, 0x06AE, 0x0800, 0x0 }, - { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTexture673990, 0x02D8, 0x0800, 0x0 }, - { gTexture67A370, 0x05AA, 0x0800, 0x0 }, - { gTexture67A91C, 0x04D1, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - BowsersCastle::BowsersCastle() { - this->vtx = d_course_bowsers_castle_vertex; - this->gfx = d_course_bowsers_castle_packed_dls; - this->gfxSize = 4900; - Props.textures = bowsers_castle_textures; Props.Minimap.Texture = minimap_bowsers_castle; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -146,21 +112,28 @@ BowsersCastle::BowsersCastle() { Props.WaterLevel = -50.0f; WaterVolumes.push_back({20.0f, 1549.0f, 1859.0f, -1402.0f, -1102.0f}); - for (size_t i = 0; i < 108; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) bowsers_castle_dls[i], Props.textures); - } } void BowsersCastle::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(bowsers_castle_dls); i++) { + InvertTriangleWindingByName(bowsers_castle_dls[i]); + } + InvertTriangleWindingByName(d_course_bowsers_castle_packed_dl_6A80); + + InvertTriangleWindingByName(d_course_bowsers_castle_packed_dl_248); + + InvertTriangleWindingByName(d_course_bowsers_castle_dl_9228); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_bowsers_castle_addr)); func_80295C6C(); - find_vtx_and_set_colours(segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07001350)), 0x32, 0, 0, 0); + find_vtx_and_set_colours((Gfx*) d_course_bowsers_castle_packed_dl_1350, 0x32, 0, 0, 0); } -void BowsersCastle::LoadTextures() { - dma_textures(gTextureShrub, 0x000003FFU, 0x00000800U); // 0x03009000 +void BowsersCastle::UnLoad() { + RestoreTriangleWinding(); } void BowsersCastle::BeginPlay() { @@ -297,7 +270,7 @@ void BowsersCastle::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_bowsers_castle_packed_dl_6A80 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07006A80))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_bowsers_castle_packed_dl_6A80); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); @@ -312,7 +285,7 @@ void BowsersCastle::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_bowsers_castle_packed_dl_248 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000248))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_bowsers_castle_packed_dl_248); } void BowsersCastle::RenderCredits() { @@ -360,7 +333,7 @@ void BowsersCastle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCo } void BowsersCastle::CreditsSpawnActors() { - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07001350), 0x32, 0, 0, 0); + find_vtx_and_set_colours((Gfx*) d_course_bowsers_castle_packed_dl_1350, 0x32, 0, 0, 0); } void BowsersCastle::Destroy() { diff --git a/src/engine/courses/BowsersCastle.h b/src/engine/courses/BowsersCastle.h index b52af2a26..5f62cd320 100644 --- a/src/engine/courses/BowsersCastle.h +++ b/src/engine/courses/BowsersCastle.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/bowsers_castle_vertices.h" - #include "assets/bowsers_castle_displaylists.h" - #include "assets/bowsers_castle_data.h" + #include "assets/models/tracks/bowsers_castle/bowsers_castle_vertices.h" + #include "assets/models/tracks/bowsers_castle/bowsers_castle_displaylists.h" + #include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; void SpawnStockThwomp(); virtual void BeginPlay() override; //virtual void InitClouds() override; diff --git a/src/engine/courses/ChocoMountain.cpp b/src/engine/courses/ChocoMountain.cpp index 8fa1c1d19..e04aa825f 100644 --- a/src/engine/courses/ChocoMountain.cpp +++ b/src/engine/courses/ChocoMountain.cpp @@ -5,8 +5,10 @@ #include "ChocoMountain.h" #include "World.h" +#include "align_asset_macro.h" #include "engine/objects/BombKart.h" -#include "choco_mountain_data.h" +#include "assets/models/tracks/choco_mountain/choco_mountain_data.h" +#include "assets/other/tracks/choco_mountain/choco_mountain_data.h" #include "engine/actors/Finishline.h" #include "engine/actors/FallingRock.h" @@ -24,7 +26,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -33,38 +35,10 @@ extern "C" { #include "memory.h" #include "course_offsets.h" #include "course.h" - extern const char *choco_mountain_dls[]; + extern const char *choco_mountain_dls[96]; } -const course_texture choco_mountain_textures[] = { - { gTexture64619C, 0x0124, 0x0800, 0x0 }, - { gTexture64647C, 0x0829, 0x1000, 0x0 }, - { gTexture647F4C, 0x05BC, 0x1000, 0x0 }, - { gTexture64FBF4, 0x0274, 0x0800, 0x0 }, - { gTexture653DB0, 0x06AE, 0x0800, 0x0 }, - { gTexture652B54, 0x0606, 0x0800, 0x0 }, - { gTexture65315C, 0x04A9, 0x0800, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignNintendoRed0, 0x02A6, 0x1000, 0x0 }, - { gTextureSignNintendoRed1, 0x02F7, 0x1000, 0x0 }, - { gTexture6774D8, 0x0113, 0x0800, 0x0 }, - { gTextureSignFallingRocks, 0x012C, 0x0800, 0x0 }, - { gTextureSignBackside, 0x011E, 0x0800, 0x0 }, - { gTexture679C04, 0x012F, 0x0800, 0x0 }, - { gTexture67B864, 0x014C, 0x0800, 0x0 }, - { gTexture67DC20, 0x03EF, 0x0800, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, - { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - ChocoMountain::ChocoMountain() { - this->vtx = d_course_choco_mountain_vertex; - this->gfx = d_course_choco_mountain_packed_dls; - this->gfxSize = 2910; - Props.textures = choco_mountain_textures; Props.Minimap.Texture = minimap_choco_mountain; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -136,13 +110,24 @@ ChocoMountain::ChocoMountain() { Props.Sequence = MusicSeq::MUSIC_SEQ_CHOCO_MOUNTAIN; Props.WaterLevel = -80.0f; - for (size_t i = 0; i < 96; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) choco_mountain_dls[i], Props.textures); - } } void ChocoMountain::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(choco_mountain_dls); i++) { + InvertTriangleWindingByName(choco_mountain_dls[i]); + } + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_4608); + + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_5A70); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_828); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_8E0); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_5868); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_448); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_5D8); + InvertTriangleWindingByName(d_course_choco_mountain_packed_dl_718); + } D_800DC5BC = 1; D_801625EC = 255; D_801625F4 = 255; @@ -155,17 +140,17 @@ void ChocoMountain::Load() { // Spawn guardrail only for CC_50 and time trials. if ((gCCSelection != CC_50) && (gModeSelection != TIME_TRIALS)) { // d_course_choco_mountain_packed_dl_0 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000000))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_0)); // d_course_choco_mountain_packed_dl_98 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000098))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_98)); // d_course_choco_mountain_packed_dl_178 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000178))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_178)); // d_course_choco_mountain_packed_dl_280 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000280))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_280)); // d_course_choco_mountain_packed_dl_340 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000340))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_340)); // d_course_choco_mountain_packed_dl_3C8 - nullify_displaylist((uintptr_t) segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070003C8))); + nullify_displaylist((uintptr_t) LOAD_ASSET_RAW(d_course_choco_mountain_packed_dl_3C8)); } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_choco_mountain_addr)); @@ -173,7 +158,8 @@ void ChocoMountain::Load() { func_80295C6C(); } -void ChocoMountain::LoadTextures() { +void ChocoMountain::UnLoad() { + RestoreTriangleWinding(); } void ChocoMountain::BeginPlay() { @@ -248,7 +234,7 @@ void ChocoMountain::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_choco_mountain_packed_dl_4608 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07004608))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_4608); } gDPSetCycleType(gDisplayListHead++, G_CYC_2CYCLE); gDPSetFogColor(gDisplayListHead++, D_801625EC, D_801625F4, D_801625F0, 0xFF); @@ -261,13 +247,13 @@ void ChocoMountain::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); // d_course_choco_mountain_packed_dl_5A70 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07005A70))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_5A70); // d_course_choco_mountain_packed_dl_828 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000828))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_828); // d_course_choco_mountain_packed_dl_8E0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070008E0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_8E0); // d_course_choco_mountain_packed_dl_5868 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07005868))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_5868); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); render_course_segments(choco_mountain_dls, arg0); @@ -276,12 +262,12 @@ void ChocoMountain::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_PASS2); // d_course_choco_mountain_packed_dl_448 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000448))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_448); // d_course_choco_mountain_packed_dl_5D8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070005D8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_5D8); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_choco_mountain_packed_dl_718 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000718))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_choco_mountain_packed_dl_718); gSPClearGeometryMode(gDisplayListHead++, G_FOG); gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); gDPPipeSync(gDisplayListHead++); diff --git a/src/engine/courses/ChocoMountain.h b/src/engine/courses/ChocoMountain.h index b592ba9df..45df1ed5b 100644 --- a/src/engine/courses/ChocoMountain.h +++ b/src/engine/courses/ChocoMountain.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/choco_mountain_vertices.h" - #include "assets/choco_mountain_displaylists.h" - #include "assets/choco_mountain_data.h" + #include "assets/models/tracks/choco_mountain/choco_mountain_vertices.h" + #include "assets/models/tracks/choco_mountain/choco_mountain_displaylists.h" + #include "assets/models/tracks/choco_mountain/choco_mountain_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void SomeSounds() override; diff --git a/src/engine/courses/Course.cpp b/src/engine/courses/Course.cpp index 3ad991f0a..2cc812d9f 100644 --- a/src/engine/courses/Course.cpp +++ b/src/engine/courses/Course.cpp @@ -1,4 +1,7 @@ #include <libultraship.h> +#include <unordered_set> +#include <string> +#include <cstring> #include "Course.h" #include "MarioRaceway.h" @@ -8,6 +11,8 @@ #include "port/resource/type/TrackSections.h" #include "engine/editor/SceneManager.h" #include "Registry.h" +#include "resourcebridge.h" +#include "align_asset_macro.h" extern "C" { #include "main.h" @@ -17,7 +22,7 @@ extern "C" { #include "some_data.h" #include "code_8006E9C0.h" #include "code_8003DC40.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "render_objects.h" #include "save.h" #include "replays.h" @@ -40,6 +45,204 @@ void ResizeMinimap(MinimapProps* minimap) { } } +static std::unordered_set<std::string> gModifiedGfxSet; + +static void SwapTriangleVertices(Gfx* cmd) { + int8_t opcode = cmd->words.w0 >> 24; + + if (opcode == G_TRI1) { + uint32_t w1 = cmd->words.w1; + uint8_t v0 = (w1 >> 16) & 0xFF; + uint8_t v1 = (w1 >> 8) & 0xFF; + uint8_t v2 = w1 & 0xFF; + + cmd->words.w1 = (v0 << 16) | (v2 << 8) | v1; + } + else if (opcode == G_TRI1_OTR) { + uint32_t w0 = cmd->words.w0; + uint32_t w1 = cmd->words.w1; + uint16_t v0 = w0 & 0xFFFF; + uint16_t v1 = (w1 >> 16) & 0xFFFF; + uint16_t v2 = w1 & 0xFFFF; + + cmd->words.w0 = (opcode << 24) | v0; + cmd->words.w1 = (v2 << 16) | v1; + } + else if (opcode == G_TRI2 || opcode == G_QUAD) { + uint32_t w0 = cmd->words.w0; + uint8_t v0_a = (w0 >> 16) & 0xFF; + uint8_t v1_a = (w0 >> 8) & 0xFF; + uint8_t v2_a = w0 & 0xFF; + + uint32_t w1 = cmd->words.w1; + uint8_t v0_b = (w1 >> 16) & 0xFF; + uint8_t v1_b = (w1 >> 8) & 0xFF; + uint8_t v2_b = w1 & 0xFF; + + cmd->words.w0 = (opcode << 24) | (v0_a << 16) | (v2_a << 8) | v1_a; + cmd->words.w1 = (v0_b << 16) | (v2_b << 8) | v1_b; + } +} + +static void InvertTriangleWindingInternal(Gfx* gfx, const char* gfxName, bool shouldSwap) { + if (gfx == nullptr) { + return; + } + + if (GameEngine_OTRSigCheck((char*)gfx)) { + gfx = (Gfx*)LOAD_ASSET(gfx); + } + + if (gfxName != nullptr) { + std::string nameStr(gfxName); + if (gModifiedGfxSet.find(nameStr) != gModifiedGfxSet.end()) { + return; + } + gModifiedGfxSet.insert(nameStr); + } + + Gfx* cmd = gfx; + + for (int i = 0; i < 0x1FFF; i++) { + int8_t opcode = cmd->words.w0 >> 24; + + switch (opcode) { + case G_TRI1: + case G_TRI1_OTR: + case G_TRI2: + case G_QUAD: + if (shouldSwap) { + SwapTriangleVertices(cmd); + } + break; + case G_DL: { + Gfx* subDL = (Gfx*)(uintptr_t)cmd->words.w1; + InvertTriangleWindingInternal(subDL, nullptr, shouldSwap); + break; + } + case G_DL_OTR_HASH: { + cmd++; + i++; + uint64_t hash = ((uint64_t)cmd->words.w0 << 32) | cmd->words.w1; + const char* name = ResourceGetNameByCrc(hash); + if (name != nullptr) { + bool subShouldSwap = (strstr(name, "packed") != nullptr); + Gfx* subDL = (Gfx*)ResourceGetDataByCrc(hash); + InvertTriangleWindingInternal(subDL, name, subShouldSwap); + } + break; + } + case G_DL_OTR_FILEPATH: { + const char* name = (const char*)(uintptr_t)cmd->words.w1; + if (name != nullptr) { + bool subShouldSwap = (strstr(name, "packed") != nullptr); + Gfx* subDL = (Gfx*)ResourceGetDataByName(name); + InvertTriangleWindingInternal(subDL, name, subShouldSwap); + } + break; + } + case G_VTX_OTR_FILEPATH: + case G_VTX_OTR_HASH: + cmd++; + i++; + break; + case G_MARKER: { + cmd++; + i++; + uint64_t hash = ((uint64_t)cmd->words.w0 << 32) | cmd->words.w1; + const char* name = ResourceGetNameByCrc(hash); + if (name != nullptr && gfxName == nullptr) { + std::string nameStr(name); + if (gModifiedGfxSet.find(nameStr) != gModifiedGfxSet.end()) { + return; + } + gModifiedGfxSet.insert(nameStr); + shouldSwap = (strstr(name, "packed") != nullptr); + } + break; + } + case G_MTX_OTR: + case G_SETTIMG_OTR_HASH: + cmd++; + i++; + break; + case G_ENDDL: + return; + default: + break; + } + + cmd++; + } +} + +void InvertTriangleWinding(Gfx* gfx) { + InvertTriangleWindingInternal(gfx, nullptr, false); +} + +void InvertTriangleWindingByName(const char* name) { + if (name == nullptr) { + return; + } + Gfx* gfx = (Gfx*)ResourceGetDataByName(name); + bool shouldSwap = (strstr(name, "packed") != nullptr); + InvertTriangleWindingInternal(gfx, name, shouldSwap); +} + +void RestoreTriangleWinding() { + for (const std::string& name : gModifiedGfxSet) { + if (strstr(name.c_str(), "packed") == nullptr) { + continue; + } + + Gfx* gfx = (Gfx*)ResourceGetDataByName(name.c_str()); + if (gfx == nullptr) { + continue; + } + + Gfx* cmd = gfx; + + for (int i = 0; i < 0x1FFF; i++) { + int8_t opcode = cmd->words.w0 >> 24; + + switch (opcode) { + case G_TRI1: + case G_TRI1_OTR: + case G_TRI2: + case G_QUAD: + SwapTriangleVertices(cmd); + break; + + case G_DL_OTR_HASH: + case G_VTX_OTR_FILEPATH: + case G_VTX_OTR_HASH: + case G_MARKER: + case G_MTX_OTR: + case G_SETTIMG_OTR_HASH: + cmd++; + i++; + break; + + case G_ENDDL: + goto next_gfx; + + default: + break; + } + + cmd++; + } + next_gfx:; + } + + gModifiedGfxSet.clear(); +} + +bool IsTriangleWindingInverted() { + return !gModifiedGfxSet.empty(); +} + + Course::Course() { Props.SetText(Props.Name, "Blank Track", sizeof(Props.Name)); Props.SetText(Props.DebugName, "blnktrck", sizeof(Props.DebugName)); @@ -111,12 +314,12 @@ Course::Course() { // Load custom track from code void Course::Load(Vtx* vtx, Gfx* gfx) { - gSegmentTable[4] = reinterpret_cast<uintptr_t>(&vtx[0]); - gSegmentTable[7] = reinterpret_cast<uintptr_t>(&gfx[0]); - Course::Init(); } +void Course::UnLoad() { +} + void Course::LoadO2R(std::string trackPath) { if (!trackPath.empty()) { SceneFilePtr = (trackPath + "/scene.json"); @@ -161,7 +364,7 @@ void Course::Load() { bIsMod = true; // auto res = std::dynamic_pointer_cast<MK64::TrackSectionsO2RClass>(ResourceLoad(TrackSectionsPtr.c_str())); - TrackSectionsO2R* sections = (TrackSectionsO2R*) LOAD_ASSET_RAW(TrackSectionsPtr.c_str()); + TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(TrackSectionsPtr.c_str()); size_t size = ResourceGetSizeByName(TrackSectionsPtr.c_str()); if (sections != nullptr) { @@ -178,55 +381,13 @@ void Course::Load() { return; } - // Stock - size_t vtxSize = (ResourceGetSizeByName(this->vtx) / sizeof(CourseVtx)) * sizeof(Vtx); - size_t texSegSize; - - // Convert course vtx to vtx - Vtx* vtx = reinterpret_cast<Vtx*>(allocate_memory(vtxSize)); - gSegmentTable[4] = reinterpret_cast<uintptr_t>(&vtx[0]); - func_802A86A8(reinterpret_cast<CourseVtx*>(LOAD_ASSET_RAW(this->vtx)), vtx, vtxSize / sizeof(Vtx)); - - // Load and allocate memory for course textures - const course_texture* asset = this->Props.textures; - u8* freeMemory = NULL; - u8* texture = NULL; - size_t size = 0; - texSegSize = 0; - while (asset->addr) { - size = ResourceGetTexSizeByName(asset->addr); - freeMemory = (u8*) allocate_memory(size); - - texture = (u8*) (asset->addr); - if (texture) { - if (asset == &this->Props.textures[0]) { - gSegmentTable[5] = reinterpret_cast<uintptr_t>(&freeMemory[0]); - } - strcpy(reinterpret_cast<char*>(freeMemory), asset->addr); - // memcpy(freeMemory, texture, size); - texSegSize += size; - // printf("Texture Addr: 0x%llX, size 0x%X\n", &freeMemory[0], size); - } - asset++; - } - - // Extract packed DLs - u8* packed = reinterpret_cast<u8*>(LOAD_ASSET_RAW(this->gfx)); - Gfx* gfx = (Gfx*) allocate_memory(sizeof(Gfx) * this->gfxSize); // Size of unpacked DLs - if (gfx == NULL) { - printf("Failed to allocate course displaylist memory\n"); - } - - gSegmentTable[7] = reinterpret_cast<uintptr_t>(&gfx[0]); - displaylist_unpack(reinterpret_cast<uintptr_t*>(gfx), reinterpret_cast<uintptr_t>(packed), 0); - Course::Init(); } // C++ version of parse_course_displaylists() -void Course::ParseCourseSections(TrackSectionsO2R* sections, size_t size) { +void Course::ParseCourseSections(TrackSections* sections, size_t size) { printf("\n[Track] Generating Collision Meshes...\n"); - for (size_t i = 0; i < (size / sizeof(TrackSectionsO2R)); i++) { + for (size_t i = 0; i < (size / sizeof(TrackSections)); i++) { if (sections[i].flags & 0x8000) { D_8015F59C = 1; // single-sided wall } else { @@ -242,8 +403,9 @@ void Course::ParseCourseSections(TrackSectionsO2R* sections, size_t size) { } else { D_8015F5A4 = 0; } - printf(" %s\n", sections[i].addr.c_str()); - generate_collision_mesh((Gfx*) LOAD_ASSET_RAW(sections[i].addr.c_str()), sections[i].surfaceType, + const char* name = ResourceGetNameByCrc(sections[i].crc); + printf(" %s\n", name); + generate_collision_mesh((Gfx*) ResourceGetDataByCrc(sections[i].crc), sections[i].surfaceType, sections[i].sectionId); } printf("[Track] Collision Mesh Generation Complete!\n\n"); @@ -268,7 +430,7 @@ void Course::TestPath() { } f32 height = spawn_actor_on_surface(x, 2000.0f, z); - Vec3f itemPos = { x, height, z }; + Vec3f itemPos = { (f32) x, height, (f32) z }; add_actor_to_empty_slot(itemPos, rot, vel, ACTOR_ITEM_BOX); } } @@ -293,9 +455,6 @@ void Course::Init() { D_800DC5C8 = 0; } -void Course::LoadTextures() { -} - void Course::BeginPlay() { printf("[Track] BeginPlay\n"); TestPath(); @@ -388,10 +547,10 @@ void Course::Render(struct UnkStruct_800DC5EC* arg0) { // d_course_big_donut_packed_dl_DE8 } - TrackSectionsO2R* sections = (TrackSectionsO2R*) LOAD_ASSET_RAW(TrackSectionsPtr.c_str()); + TrackSections* sections = (TrackSections*) LOAD_ASSET_RAW(TrackSectionsPtr.c_str()); size_t size = ResourceGetSizeByName(TrackSectionsPtr.c_str()); - for (size_t i = 0; i < (size / sizeof(TrackSectionsO2R)); i++) { - gSPDisplayList(gDisplayListHead++, (Gfx*) LOAD_ASSET_RAW(sections[i].addr.c_str())); + for (size_t i = 0; i < (size / sizeof(TrackSections)); i++) { + gSPDisplayList(gDisplayListHead++, (Gfx*) ResourceGetDataByCrc(sections[i].crc)); } } } @@ -403,7 +562,7 @@ f32 Course::GetWaterLevel(FVector pos, Collision* collision) { float highestWater = -FLT_MAX; bool found = false; - for (const auto& volume : gWorldInstance.CurrentCourse->WaterVolumes) { + for (const auto& volume : gWorldInstance.GetCurrentCourse()->WaterVolumes) { if (pos.x >= volume.MinX && pos.x <= volume.MaxX && pos.z >= volume.MinZ && pos.z <= volume.MaxZ) { // Choose the highest water volume the player is over if (!found || volume.Height > highestWater) { @@ -414,7 +573,7 @@ f32 Course::GetWaterLevel(FVector pos, Collision* collision) { } // If player is not over-top of a water volume then return the courses default water level - return found ? highestWater : gWorldInstance.CurrentCourse->Props.WaterLevel; + return found ? highestWater : gWorldInstance.GetCurrentCourse()->Props.WaterLevel; } void Course::ScrollingTextures() { diff --git a/src/engine/courses/Course.h b/src/engine/courses/Course.h index 80e61fdbd..c1eeb488a 100644 --- a/src/engine/courses/Course.h +++ b/src/engine/courses/Course.h @@ -65,6 +65,12 @@ typedef struct MinimapProps { } MinimapProps; void ResizeMinimap(MinimapProps* minimap); +void ReverseGfx(Gfx* gfx); + +void InvertTriangleWinding(Gfx* gfx); +void InvertTriangleWindingByName(const char* name); +void RestoreTriangleWinding(); +bool IsTriangleWindingInverted(); typedef struct Properties { char Name[128]; @@ -90,7 +96,6 @@ typedef struct Properties { CloudData *Clouds; CloudData *CloudList; SkyboxColours Skybox; - const course_texture* textures; enum MusicSeq Sequence; float WaterLevel; // Used for effects, and Lakitu pick up height. Not necessarily the visual water model height. @@ -302,10 +307,6 @@ public: // Ex. DK Jungle where there's a waterfall and you can drive above and below it. std::vector<WaterVolume> WaterVolumes; - const char* vtx = nullptr; - const char* gfx = nullptr; - size_t gfxSize = 0; - const course_texture* textures = nullptr; bool bSpawnFinishline = true; std::optional<FVector> FinishlineSpawnPoint; @@ -324,8 +325,8 @@ public: virtual void LoadO2R(std::string trackPath); // Load custom track from o2r virtual void Load(); // Decompress and load stock courses or from o2r but TrackSectionsPtr must be set. virtual void Load(Vtx* vtx, Gfx *gfx); // Load custom track from code. Load must be overridden and then call to this base class method impl. - virtual void LoadTextures(); - virtual void ParseCourseSections(TrackSectionsO2R* sections, size_t size); + virtual void UnLoad(); + virtual void ParseCourseSections(TrackSections* sections, size_t size); /** * @brief BeginPlay This function is called once at the start of gameplay. @@ -350,6 +351,7 @@ public: virtual void Waypoints(Player* player, int8_t playerId); virtual f32 GetWaterLevel(FVector pos, Collision* collision); virtual void ScrollingTextures(); + // Draw transparent models (water, signs, arrows, etc.) virtual void DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection); virtual void Destroy(); diff --git a/src/engine/courses/DKJungle.cpp b/src/engine/courses/DKJungle.cpp index 261f4b672..77e5bab88 100644 --- a/src/engine/courses/DKJungle.cpp +++ b/src/engine/courses/DKJungle.cpp @@ -7,7 +7,8 @@ #include "World.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" -#include "assets/dks_jungle_parkway_data.h" +#include "assets/models/tracks/dks_jungle_parkway/dks_jungle_parkway_data.h" +#include "assets/other/tracks/dks_jungle_parkway/dks_jungle_parkway_data.h" #include "engine/vehicles/Boat.h" #include "engine/vehicles/Utils.h" @@ -27,7 +28,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -36,43 +37,11 @@ extern "C" { #include "memory.h" #include "sounds.h" #include "course.h" - extern const char *d_course_dks_jungle_parkway_unknown_dl_list[]; + extern const char *d_course_dks_jungle_parkway_unknown_dl_list[105]; extern s16 currentScreenSection; } -const course_texture dks_jungle_parkway_textures[] = { - { gTexture648508, 0x01FE, 0x1000, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureWoodBridgeSlats, 0x0DAB, 0x1000, 0x0 }, - { gTexture654460, 0x0B12, 0x1000, 0x0 }, - { gTexture654F74, 0x0A24, 0x1000, 0x0 }, - { gTexture655998, 0x059F, 0x0800, 0x0 }, - { gTexture655F38, 0x0BB9, 0x1000, 0x0 }, - { gTexture656AF4, 0x0AD3, 0x1000, 0x0 }, - { gTexture6575C8, 0x0DA7, 0x1000, 0x0 }, - { gTexture658370, 0x0DBA, 0x1000, 0x0 }, - { gTexture65912C, 0x0DBC, 0x1000, 0x0 }, - { gTexture659EE8, 0x0EF5, 0x1000, 0x0 }, - { gTexture65ADE0, 0x0D5A, 0x1000, 0x0 }, - { gTexture65BB3C, 0x0D9E, 0x1000, 0x0 }, - { gTexture65C8DC, 0x0CF5, 0x1000, 0x0 }, - { gTexture65D5D4, 0x0D18, 0x1000, 0x0 }, - { gTexture65E2EC, 0x02B0, 0x0800, 0x0 }, - { gTexture65EAEC, 0x034A, 0x0800, 0x0 }, - { gTexture65E59C, 0x054F, 0x1000, 0x0 }, - { gTexture65EE38, 0x0CDE, 0x1000, 0x0 }, - { gTexture65FB18, 0x03EE, 0x0800, 0x0 }, - { gTextureSignPinkArrow, 0x0198, 0x0800, 0x0 }, - { gTextureWaves0, 0x04D0, 0x0800, 0x0 }, - { gTexture683844, 0x0655, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - DKJungle::DKJungle() { - this->vtx = d_course_dks_jungle_parkway_vertex; - this->gfx = d_course_dks_jungle_parkway_packed_dls; - this->gfxSize = 4997; - Props.textures = dks_jungle_parkway_textures; Props.Minimap.Texture = minimap_dks_jungle_parkway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -143,18 +112,30 @@ DKJungle::DKJungle() { Props.Sequence = MusicSeq::MUSIC_SEQ_DK_JUNGLE; Props.WaterLevel = -475.0f; - for (size_t i = 0; i < 104; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) d_course_dks_jungle_parkway_unknown_dl_list[i], Props.textures); - } } void DKJungle::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(d_course_dks_jungle_parkway_unknown_dl_list); i++) { + InvertTriangleWindingByName(d_course_dks_jungle_parkway_unknown_dl_list[i]); + } + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_92D8); + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_3E40); + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_3EB0); + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_3DD0); + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_36A8); + InvertTriangleWindingByName(d_course_dks_jungle_parkway_packed_dl_3F30); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_dks_jungle_parkway_addr)); func_80295C6C(); // d_course_dks_jungle_parkway_packed_dl_3FA8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07003FA8), 120, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_dks_jungle_parkway_packed_dl_3FA8, 120, 255, 255, 255); +} + +void DKJungle::UnLoad() { + RestoreTriangleWinding(); } f32 DKJungle::GetWaterLevel(FVector pos, Collision* collision) { @@ -188,12 +169,6 @@ f32 DKJungle::GetWaterLevel(FVector pos, Collision* collision) { return -33.9f; } -void DKJungle::LoadTextures() { - dma_textures(gTextureDksJungleParkwayKiwanoFruit1, 0x0000032FU, 0x00000400U); // 0x03009000 - dma_textures(gTextureDksJungleParkwayKiwanoFruit2, 0x00000369U, 0x00000400U); // 0x03009800 - dma_textures(gTextureDksJungleParkwayKiwanoFruit3, 0x00000364U, 0x00000400U); // 0x0300A000 -} - void DKJungle::BeginPlay() { spawn_all_item_boxes((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_dks_jungle_parkway_item_box_spawns)); @@ -299,7 +274,7 @@ void DKJungle::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_dks_jungle_parkway_packed_dl_92D8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x070092D8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_92D8); } gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); @@ -336,26 +311,25 @@ void DKJungle::ScrollingTextures() { D_802B87BC = 0; } // d_course_dks_jungle_parkway_packed_dl_3DD0 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x07003DD0), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_3DD0, 0, D_802B87BC); // d_course_dks_jungle_parkway_packed_dl_3E40 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x07003E40), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40, 0, D_802B87BC); // d_course_dks_jungle_parkway_packed_dl_3EB0 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x07003EB0), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0, 0, D_802B87BC); // d_course_dks_jungle_parkway_packed_dl_3F30 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x07003F30), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30, 0, D_802B87BC); // d_course_dks_jungle_parkway_packed_dl_36A8 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x070036A8), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8, 0, D_802B87BC); D_802B87C4 -= 20; if (D_802B87C4 < 0) { D_802B87C4 = 0xFF; } // d_course_dks_jungle_parkway_packed_dl_9880 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x07009880), 0, D_802B87C4); + find_and_set_tile_size((uintptr_t) (Gfx*) d_course_dks_jungle_parkway_packed_dl_9880, 0, D_802B87C4); evaluate_collision_players_palm_trees(); } void DKJungle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - Mat4 matrix; gDPPipeSync(gDisplayListHead++); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); @@ -363,55 +337,52 @@ void DKJungle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); - mtxf_identity(matrix); - render_set_position(matrix, 0); - gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_INTER, G_RM_NOOP2); if (pathCounter < 17) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); if ((pathCounter >= 6) && (pathCounter < 13)) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); // d_course_dks_jungle_parkway_packed_dl_3DD0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003DD0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3DD0); } } else if ((pathCounter == 21) || (pathCounter == 22)) { if (playerDirection == 3) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } if ((playerDirection == 1) || (playerDirection == 0)) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } else { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } } else if (pathCounter == 24) { if ((playerDirection == 0) || (playerDirection == 3)) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } } else if (pathCounter == 23) { if (playerDirection == 3) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } else if (playerDirection == 0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); // d_course_dks_jungle_parkway_packed_dl_36A8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070036A8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_36A8); } } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); @@ -419,38 +390,38 @@ void DKJungle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter case 5: if (playerDirection != 3) { // d_course_dks_jungle_parkway_packed_dl_3DD0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003DD0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3DD0); } break; case 17: switch (playerDirection) { case 0: // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); break; case 1: // d_course_dks_jungle_parkway_packed_dl_3DD0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003DD0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3DD0); // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); break; case 2: // d_course_dks_jungle_parkway_packed_dl_ - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); break; case 3: // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); break; } break; @@ -458,49 +429,49 @@ void DKJungle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter switch (playerDirection) { case 0: // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); break; case 1: // d_course_dks_jungle_parkway_packed_dl_3DD0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003DD0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3DD0); // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); break; case 2: // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); break; } break; case 21: if ((playerDirection == 0) || (playerDirection == 1)) { // d_course_dks_jungle_parkway_packed_dl_3E40 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003E40)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3E40); // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); } else { // d_course_dks_jungle_parkway_packed_dl_3EB0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003EB0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3EB0); } break; case 22: if (playerDirection == 0) { // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); } break; case 23: if (playerDirection != 1) { // d_course_dks_jungle_parkway_packed_dl_3F30 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07003F30)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_dks_jungle_parkway_packed_dl_3F30); } break; } @@ -511,7 +482,7 @@ void DKJungle::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter void DKJungle::CreditsSpawnActors() { // d_course_dks_jungle_parkway_packed_dl_3FA8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07003FA8), 0x78, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_dks_jungle_parkway_packed_dl_3FA8, 0x78, 0xFF, 0xFF, 0xFF); } void DKJungle::Destroy() { } diff --git a/src/engine/courses/DKJungle.h b/src/engine/courses/DKJungle.h index 84767a94a..0b7f09524 100644 --- a/src/engine/courses/DKJungle.h +++ b/src/engine/courses/DKJungle.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/dks_jungle_parkway_vertices.h" - #include "assets/dks_jungle_parkway_displaylists.h" - #include "assets/dks_jungle_parkway_data.h" + #include "assets/models/tracks/dks_jungle_parkway/dks_jungle_parkway_vertices.h" + #include "assets/models/tracks/dks_jungle_parkway/dks_jungle_parkway_displaylists.h" + #include "assets/models/tracks/dks_jungle_parkway/dks_jungle_parkway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual f32 GetWaterLevel(FVector pos, Collision* collision) override; virtual void BeginPlay() override; //virtual void InitClouds() override; diff --git a/src/engine/courses/DoubleDeck.cpp b/src/engine/courses/DoubleDeck.cpp index e92bc22d8..ad7de5700 100644 --- a/src/engine/courses/DoubleDeck.cpp +++ b/src/engine/courses/DoubleDeck.cpp @@ -5,8 +5,10 @@ #include "DoubleDeck.h" #include "World.h" +#include "align_asset_macro.h" #include "engine/objects/BombKart.h" -#include "assets/double_deck_data.h" +#include "assets/models/tracks/double_deck/double_deck_data.h" +#include "assets/other/tracks/double_deck/double_deck_data.h" extern "C" { #include "main.h" @@ -22,27 +24,16 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" - extern const char *double_deck_dls[]; extern s16 currentScreenSection; } -const course_texture double_deck_textures[] = { - { gTextureGrayCobblestone, 0x010C, 0x0800, 0x0 }, - { gTexture642978, 0x010D, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - DoubleDeck::DoubleDeck() { - this->vtx = d_course_double_deck_vertex; - this->gfx = d_course_double_deck_packed_dls; - this->gfxSize = 699; - Props.textures = double_deck_textures; Props.Minimap.Texture = minimap_double_deck; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -116,13 +107,15 @@ DoubleDeck::DoubleDeck() { void DoubleDeck::Load() { Course::Load(); - - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*)0x07000738), 1); + if (gIsMirrorMode != 0) { + InvertTriangleWindingByName(d_course_double_deck_packed_dl_738); + } + generate_collision_mesh_with_default_section_id((Gfx*) d_course_double_deck_packed_dl_738, 1); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } -void DoubleDeck::LoadTextures() { +void DoubleDeck::UnLoad() { } void DoubleDeck::BeginPlay() { @@ -154,7 +147,7 @@ void DoubleDeck::Render(struct UnkStruct_800DC5EC* arg0) { gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_double_deck_packed_dl_738 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000738))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_double_deck_packed_dl_738); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); } diff --git a/src/engine/courses/DoubleDeck.h b/src/engine/courses/DoubleDeck.h index 2ebb5d9c3..354ab116a 100644 --- a/src/engine/courses/DoubleDeck.h +++ b/src/engine/courses/DoubleDeck.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/double_deck_vertices.h" - #include "assets/double_deck_displaylists.h" - #include "assets/double_deck_data.h" + #include "assets/models/tracks/double_deck/double_deck_vertices.h" + #include "assets/models/tracks/double_deck/double_deck_displaylists.h" + #include "assets/models/tracks/double_deck/double_deck_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void SomeSounds() override; diff --git a/src/engine/courses/FrappeSnowland.cpp b/src/engine/courses/FrappeSnowland.cpp index 1be4bf04a..dbba9efbf 100644 --- a/src/engine/courses/FrappeSnowland.cpp +++ b/src/engine/courses/FrappeSnowland.cpp @@ -9,8 +9,9 @@ #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" #include "engine/objects/Snowman.h" -#include "assets/frappe_snowland_data.h" -#include "assets/boo_frames.h" +#include "assets/models/tracks/frappe_snowland/frappe_snowland_data.h" +#include "assets/other/tracks/frappe_snowland/frappe_snowland_data.h" +#include "assets/textures/boo_frames.h" extern "C" { #include "main.h" @@ -26,7 +27,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -35,23 +36,11 @@ extern "C" { #include "update_objects.h" #include "course_offsets.h" #include "course.h" - extern const char *d_course_frappe_snowland_dl_list[]; + extern const char *d_course_frappe_snowland_dl_list[68]; extern s8 gPlayerCount; } -const course_texture frappe_snowland_textures[] = { - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, { gTexture675434, 0x0245, 0x0800, 0x0 }, - { gTexture677F04, 0x0213, 0x0800, 0x0 }, { gTexture678118, 0x0314, 0x0800, 0x0 }, - { gTexture679258, 0x04E3, 0x1000, 0x0 }, { gTexture67973C, 0x04C6, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - FrappeSnowland::FrappeSnowland() { - this->vtx = d_course_frappe_snowland_vertex; - this->gfx = d_course_frappe_snowland_packed_dls; - this->gfxSize = 4140; - Props.textures = frappe_snowland_textures; Props.Minimap.Texture = minimap_frappe_snowland; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -123,21 +112,24 @@ FrappeSnowland::FrappeSnowland() { Props.Sequence = MusicSeq::MUSIC_SEQ_FRAPPE_SNOWLAND; Props.WaterLevel = -50.0f; - for (size_t i = 0; i < 68; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) d_course_frappe_snowland_dl_list[i], Props.textures); - } } void FrappeSnowland::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(d_course_frappe_snowland_dl_list); i++) { + InvertTriangleWindingByName(d_course_frappe_snowland_dl_list[i]); + } + + InvertTriangleWindingByName(d_course_frappe_snowland_packed_dl_65E0); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_frappe_snowland_addr)); func_80295C6C(); } -void FrappeSnowland::LoadTextures() { - dma_textures(gTextureFrappeSnowlandTreeLeft, 0x00000454U, 0x00000800U); // 0x03009000 - dma_textures(gTextureFrappeSnowlandTreeRight, 0x00000432U, 0x00000800U); // 0x03009800 +void FrappeSnowland::UnLoad() { + RestoreTriangleWinding(); } void FrappeSnowland::BeginPlay() { @@ -218,7 +210,7 @@ void FrappeSnowland::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_frappe_snowland_packed_dl_65E0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070065E0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_frappe_snowland_packed_dl_65E0); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); diff --git a/src/engine/courses/FrappeSnowland.h b/src/engine/courses/FrappeSnowland.h index 8f01559a9..aa9052f57 100644 --- a/src/engine/courses/FrappeSnowland.h +++ b/src/engine/courses/FrappeSnowland.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/frappe_snowland_vertices.h" - #include "assets/frappe_snowland_displaylists.h" - #include "assets/frappe_snowland_data.h" + #include "assets/models/tracks/frappe_snowland/frappe_snowland_vertices.h" + #include "assets/models/tracks/frappe_snowland/frappe_snowland_displaylists.h" + #include "assets/models/tracks/frappe_snowland/frappe_snowland_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -22,7 +22,7 @@ public: explicit FrappeSnowland(); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitClouds() override; virtual void UpdateClouds(s32 sp1C, Camera* camera) override; diff --git a/src/engine/courses/Harbour.cpp b/src/engine/courses/Harbour.cpp index db81d065b..9b76457cf 100644 --- a/src/engine/courses/Harbour.cpp +++ b/src/engine/courses/Harbour.cpp @@ -13,9 +13,9 @@ #include "engine/actors/Starship.h" #include "engine/objects/Object.h" #include "engine/objects/BombKart.h" -#include "assets/mario_raceway_data.h" -#include "assets/bowsers_castle_data.h" -#include "assets/bowsers_castle_displaylists.h" +#include "assets/models/tracks/mario_raceway/mario_raceway_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_displaylists.h" #include "engine/actors/Tree.h" #include "engine/actors/Cloud.h" #include "engine/vehicles/Train.h" @@ -44,7 +44,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -517,8 +517,6 @@ TrackPathPoint harbour_path[] = { }; Harbour::Harbour() { - this->gfxSize = 100; - this->textures = NULL; Props.Minimap.Texture = minimap_mario_raceway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -592,14 +590,25 @@ Harbour::Harbour() { } TrackSections harbour_surfaces[] = { - { road_map_001_mesh, 1, 255, 0x0000 }, - { ground_map_mesh, 8, 255, 0x0000 }, + { (uintptr_t) road_map_001_mesh, 1, 255, 0x0000 }, + { (uintptr_t) ground_map_mesh, 8, 255, 0x0000 }, { 0x00000000, 0, 0, 0x00000 }, }; void Harbour::Load() { Course::Load(road_map_001_mesh_vtx_0, NULL); + if (gIsMirrorMode != 0) { + InvertTriangleWinding(ground_map_mesh); + InvertTriangleWinding(road_map_001_mesh); + InvertTriangleWinding(bush_map_004_mesh); + InvertTriangleWinding(castle_map_002_mesh); + InvertTriangleWinding(statue_map_005_mesh); + InvertTriangleWinding(trees_map_003_mesh); + InvertTriangleWinding(water_water1_mesh); + InvertTriangleWinding(moon_moon_mesh); + } + // The light gets overridden in hm_intro, reset to normal ground_f3d_material_013_lights = gdSPDefLights1( 0x7F, 0x7F, 0x7F, @@ -618,8 +627,7 @@ void Harbour::Load() { Props.WaterLevel = gCourseMinY - 10.0f; } -void Harbour::LoadTextures() { - dma_textures(gTextureTrees1, 0x0000035BU, 0x00000800U); // 0x03009000 +void Harbour::UnLoad() { } void Harbour::BeginPlay() { diff --git a/src/engine/courses/Harbour.h b/src/engine/courses/Harbour.h index 834154f84..69524cfbf 100644 --- a/src/engine/courses/Harbour.h +++ b/src/engine/courses/Harbour.h @@ -4,14 +4,14 @@ #include "Course.h" extern "C" { - #include "mario_raceway_vertices.h" - #include "mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_vertices.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" #include "objects.h" #include "path_spawn_metadata.h" - #include "mario_raceway_data.h" extern const course_texture test_course_textures[]; } @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void WhatDoesThisDo(Player* player, int8_t playerId) override; virtual void WhatDoesThisDoAI(Player* player, int8_t playerId) override; diff --git a/src/engine/courses/KalimariDesert.cpp b/src/engine/courses/KalimariDesert.cpp index 4886174f1..1c523e0e4 100644 --- a/src/engine/courses/KalimariDesert.cpp +++ b/src/engine/courses/KalimariDesert.cpp @@ -7,7 +7,8 @@ #include "engine/World.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" -#include "kalimari_desert_data.h" +#include "assets/models/tracks/kalimari_desert/kalimari_desert_data.h" +#include "assets/other/tracks/kalimari_desert/kalimari_desert_data.h" #include "engine/vehicles/Utils.h" #include "engine/vehicles/Train.h" @@ -26,37 +27,17 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course.h" - extern const char *kalimari_desert_dls[]; + extern const char *kalimari_desert_dls[80]; } -const course_texture kalimari_desert_textures[] = { - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, { gTextureSignNintendoRed0, 0x02A6, 0x1000, 0x0 }, - { gTextureSignNintendoRed1, 0x02F7, 0x1000, 0x0 }, { gTexture67490C, 0x021C, 0x0800, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { gTexture646CA8, 0x073A, 0x1000, 0x0 }, { gTexture6473E4, 0x05AD, 0x1000, 0x0 }, - { gTexture647994, 0x05B5, 0x1000, 0x0 }, { gTexture668920, 0x03D9, 0x0800, 0x0 }, - { gTextureRailroadTrack, 0x0B5B, 0x1000, 0x0 }, { gTextureRailroadCrossingTrack, 0x0208, 0x1000, 0x0 }, - { gTexture67291C, 0x059C, 0x0800, 0x0 }, { gTextureFenceBarbedWire, 0x021E, 0x1000, 0x0 }, - { gTexture67D304, 0x091C, 0x1000, 0x0 }, { gTexture67E010, 0x0415, 0x0800, 0x0 }, - { gTexture67EEAC, 0x0140, 0x0800, 0x0 }, { gTextureSignShellShot0, 0x038C, 0x1000, 0x0 }, - { gTextureSignShellShot1, 0x0247, 0x1000, 0x0 }, { gTextureSignKoopaAir0, 0x0360, 0x1000, 0x0 }, - { gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - KalimariDesert::KalimariDesert() { - this->vtx = d_course_kalimari_desert_vertex; - this->gfx = d_course_kalimari_desert_packed_dls; - this->gfxSize = 5328; - Props.textures = kalimari_desert_textures; Props.Minimap.Texture = minimap_kalimari_desert; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -126,25 +107,31 @@ KalimariDesert::KalimariDesert() { Props.Skybox.FloorBottomLeft = {0, 0, 0}; Props.Skybox.FloorTopLeft = {255, 192, 0}; Props.Sequence = MusicSeq::MUSIC_SEQ_KALIMARI_DESERT; - for (size_t i = 0; i < 80; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) kalimari_desert_dls[i], Props.textures); - } } void KalimariDesert::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(kalimari_desert_dls); i++) { + InvertTriangleWindingByName(kalimari_desert_dls[i]); + } + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_71C8); + + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_1ED8); + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_1B18); + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_8330); + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_998); + InvertTriangleWindingByName(d_course_kalimari_desert_packed_dl_270); + } + parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_kalimari_desert_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } -void KalimariDesert::LoadTextures() { - dma_textures(gTextureCactus1Left, 0x0000033EU, 0x00000800U); // 0x03009000 - dma_textures(gTextureCactus1Right, 0x000002FBU, 0x00000800U); // 0x03009800 - dma_textures(gTextureCactus2Left, 0x000002A8U, 0x00000800U); // 0x0300A000 - dma_textures(gTextureCactus2Right, 0x00000374U, 0x00000800U); // 0x0300A800 - dma_textures(gTextureCactus3, 0x000003AFU, 0x00000800U); // 0x0300B000 +void KalimariDesert::UnLoad() { + RestoreTriangleWinding(); } void KalimariDesert::BeginPlay() { @@ -265,25 +252,25 @@ void KalimariDesert::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_kalimari_desert_packed_dl_71C8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x070071C8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_71C8); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); render_course_segments(kalimari_desert_dls, arg0); // d_course_kalimari_desert_packed_dl_1ED8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07001ED8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_1ED8); // d_course_kalimari_desert_packed_dl_1B18 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07001B18))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_1B18); // d_course_kalimari_desert_packed_dl_8330 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07008330))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_8330); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_kalimari_desert_packed_dl_998 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000998))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_998); // d_course_kalimari_desert_packed_dl_270 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000270))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_kalimari_desert_packed_dl_270); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); } diff --git a/src/engine/courses/KalimariDesert.h b/src/engine/courses/KalimariDesert.h index fe8b21f23..4b9cc4247 100644 --- a/src/engine/courses/KalimariDesert.h +++ b/src/engine/courses/KalimariDesert.h @@ -6,9 +6,9 @@ #include "engine/vehicles/Train.h" extern "C" { - #include "assets/kalimari_desert_vertices.h" - #include "assets/kalimari_desert_displaylists.h" - #include "assets/kalimari_desert_data.h" + #include "assets/models/tracks/kalimari_desert/kalimari_desert_vertices.h" + #include "assets/models/tracks/kalimari_desert/kalimari_desert_displaylists.h" + #include "assets/models/tracks/kalimari_desert/kalimari_desert_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -27,7 +27,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void SomeSounds() override; diff --git a/src/engine/courses/KoopaTroopaBeach.cpp b/src/engine/courses/KoopaTroopaBeach.cpp index ca1c19f9e..d22580c2c 100644 --- a/src/engine/courses/KoopaTroopaBeach.cpp +++ b/src/engine/courses/KoopaTroopaBeach.cpp @@ -9,8 +9,9 @@ #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" #include "engine/objects/Crab.h" +#include "assets/models/tracks/koopa_troopa_beach/koopa_troopa_beach_data.h" +#include "assets/other/tracks/koopa_troopa_beach/koopa_troopa_beach_data.h" #include "engine/objects/Seagull.h" -#include "assets/koopa_troopa_beach_data.h" extern "C" { #include "main.h" @@ -26,7 +27,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -34,35 +35,12 @@ extern "C" { #include "code_8003DC40.h" #include "memory.h" #include "course.h" - extern const char *koopa_troopa_beach_dls[]; + extern const char *d_course_koopa_troopa_beach_dl_list1[148]; + extern const char *koopa_troopa_beach_dls2[148]; extern s8 gPlayerCount; } -const course_texture koopa_troopa_beach_textures[] = { - { gTexture643B3C, 0x0798, 0x0800, 0x0 }, - { gTexture66A3DC, 0x07C5, 0x0800, 0x0 }, - { gTextureSignWoodRedArrow, 0x04E1, 0x1000, 0x0 }, - { gTexture66DD38, 0x0330, 0x1000, 0x0 }, - { gTexture643430, 0x0604, 0x0800, 0x0 }, - { gTexture660D8C, 0x0126, 0x0800, 0x0 }, - { gTexture6609D0, 0x03BB, 0x1000, 0x0 }, - { gTextureGrass12, 0x0874, 0x0800, 0x0 }, - { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, - { gTexture67BEE8, 0x02D0, 0x0800, 0x0 }, - { gTextureSandFinish, 0x022E, 0x0800, 0x0 }, - { gTextureWheelSteamEngine, 0x020F, 0x0800, 0x0 }, - { gTexture669570, 0x0E6B, 0x1000, 0x0 }, - { gTextureWaves1, 0x05C4, 0x0800, 0x0 }, - { gTextureWaves2, 0x0488, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - KoopaTroopaBeach::KoopaTroopaBeach() { - this->vtx = d_course_koopa_troopa_beach_vertex; - this->gfx = d_course_koopa_troopa_beach_packed_dls; - this->gfxSize = 5720; - Props.textures = koopa_troopa_beach_textures; Props.Minimap.Texture = minimap_koopa_troopa_beach; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -137,26 +115,32 @@ KoopaTroopaBeach::KoopaTroopaBeach() { Props.WaterLevel = 0.0f; gWaterVelocity = -0.1f; WaterVolumes.push_back({0.8f, 67.0f, 239.0f, 2233.0f, 2405.0f}); - for (size_t i = 0; i < 148; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) d_course_koopa_troopa_beach_dl_list1[i], Props.textures); - } - for (size_t i = 0; i < 148; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) koopa_troopa_beach_dls2[i], Props.textures); - } } void KoopaTroopaBeach::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(d_course_koopa_troopa_beach_dl_list1); i++) { + InvertTriangleWindingByName(d_course_koopa_troopa_beach_dl_list1[i]); + } + for (size_t i = 0; i < ARRAY_COUNT(koopa_troopa_beach_dls2); i++) { + InvertTriangleWindingByName(koopa_troopa_beach_dls2[i]); + } + InvertTriangleWindingByName(d_course_koopa_troopa_beach_packed_dl_9CC0); + InvertTriangleWindingByName(d_course_koopa_troopa_beach_packed_dl_9688); + InvertTriangleWindingByName(d_course_koopa_troopa_beach_packed_dl_2C0); + InvertTriangleWindingByName(d_course_koopa_troopa_beach_packed_dl_9E70); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_koopa_troopa_beach_addr)); func_80295C6C(); - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x0700ADE0), 150, 255, 255, 255); - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x0700A540), 150, 255, 255, 255); - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07009E70), 150, 255, 255, 255); - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07000358), 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_koopa_troopa_beach_packed_dl_ADE0, 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_koopa_troopa_beach_packed_dl_A540, 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_koopa_troopa_beach_packed_dl_9E70, 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_koopa_troopa_beach_packed_dl_358, 150, 255, 255, 255); } -void KoopaTroopaBeach::LoadTextures() { +void KoopaTroopaBeach::UnLoad() { + RestoreTriangleWinding(); } void KoopaTroopaBeach::BeginPlay() { @@ -247,18 +231,18 @@ void KoopaTroopaBeach::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_koopa_troopa_beach_packed_dl_9CC0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07009CC0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_koopa_troopa_beach_packed_dl_9CC0); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_koopa_troopa_beach_packed_dl_9688 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07009688))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_koopa_troopa_beach_packed_dl_9688); render_course_segments((const char**)d_course_koopa_troopa_beach_dl_list1, arg0); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_koopa_troopa_beach_packed_dl_2C0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070002C0))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_koopa_troopa_beach_packed_dl_2C0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPPipeSync(gDisplayListHead++); } @@ -292,9 +276,9 @@ void KoopaTroopaBeach::ScrollingTextures() { } // waterfall animation // d_course_koopa_troopa_beach_packed_dl_9D58 - find_and_set_tile_size((uintptr_t)segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07009D58)), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) d_course_koopa_troopa_beach_packed_dl_9D58, 0, D_802B87BC); // d_course_koopa_troopa_beach_packed_dl_9CD0 - find_and_set_tile_size((uintptr_t)segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07009CD0)), 0, D_802B87C4); + find_and_set_tile_size((uintptr_t) d_course_koopa_troopa_beach_packed_dl_9CD0, 0, D_802B87C4); D_802B87CC = random_int(300) / 40; if (D_802B87C8 < 0) { D_802B87C8 = random_int(300) / 40; @@ -303,12 +287,11 @@ void KoopaTroopaBeach::ScrollingTextures() { } // Waterfall bubbling effect? (unused) // d_course_koopa_troopa_beach_packed_dl_2E8 - find_and_set_tile_size((uintptr_t)segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070002E8)), D_802B87C8, D_802B87CC); + find_and_set_tile_size((uintptr_t) d_course_koopa_troopa_beach_packed_dl_2E8, D_802B87C8, D_802B87CC); } void KoopaTroopaBeach::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - Mat4 matrix; Vec3f vector; gDPPipeSync(gDisplayListHead++); @@ -327,15 +310,13 @@ void KoopaTroopaBeach::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pat case 37: gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_koopa_troopa_beach_packed_dl_9E70 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07009E70)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_koopa_troopa_beach_packed_dl_9E70); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); break; } vector[0] = 0.0f; vector[1] = Props.WaterLevel; vector[2] = 0.0f; - mtxf_translate(matrix, vector); - render_set_position(matrix, 0); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_INTER, G_RM_NOOP2); gDPSetBlendMask(gDisplayListHead++, 0xFF); diff --git a/src/engine/courses/KoopaTroopaBeach.h b/src/engine/courses/KoopaTroopaBeach.h index 7ebd8bac8..2c6d45397 100644 --- a/src/engine/courses/KoopaTroopaBeach.h +++ b/src/engine/courses/KoopaTroopaBeach.h @@ -7,9 +7,9 @@ #include "World.h" extern "C" { - #include "assets/koopa_troopa_beach_vertices.h" - #include "assets/koopa_troopa_beach_displaylists.h" - #include "assets/koopa_troopa_beach_data.h" + #include "assets/models/tracks/koopa_troopa_beach/koopa_troopa_beach_vertices.h" + #include "assets/models/tracks/koopa_troopa_beach/koopa_troopa_beach_displaylists.h" + #include "assets/models/tracks/koopa_troopa_beach/koopa_troopa_beach_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -28,7 +28,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void UpdateCourseObjects() override; diff --git a/src/engine/courses/LuigiRaceway.cpp b/src/engine/courses/LuigiRaceway.cpp index cb2fd3e14..2ebde3087 100644 --- a/src/engine/courses/LuigiRaceway.cpp +++ b/src/engine/courses/LuigiRaceway.cpp @@ -1,3 +1,4 @@ +#include <cstdint> #include <libultraship.h> #include <libultra/gbi.h> #include <vector> @@ -5,8 +6,10 @@ #include "LuigiRaceway.h" #include "World.h" +#include "align_asset_macro.h" #include "engine/objects/BombKart.h" -#include "assets/luigi_raceway_data.h" +#include "assets/models/tracks/luigi_raceway/luigi_raceway_data.h" +#include "assets/other/tracks/luigi_raceway/luigi_raceway_data.h" #include "engine/objects/HotAirBalloon.h" #include "engine/actors/Finishline.h" #include "engine/objects/GrandPrixBalloons.h" @@ -25,7 +28,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -36,59 +39,11 @@ extern "C" { #include "framebuffer_effects.h" #include "skybox_and_splitscreen.h" #include "course.h" -extern const char* luigi_raceway_dls[]; +extern const char* luigi_raceway_dls[120]; extern s16 currentScreenSection; } -const course_texture luigi_raceway_textures[] = { - { gTextureSignShellShot0, 0x038C, 0x1000, 0x0 }, - { gTextureSignShellShot1, 0x0247, 0x1000, 0x0 }, - { gTextureCheckerboardYellowBlue, 0x013A, 0x0800, 0x0 }, - { gTexture64619C, 0x0124, 0x0800, 0x0 }, - { gTextureCheckerboardBlueGreen, 0x0139, 0x0800, 0x0 }, - { gTextureGrass3, 0x0372, 0x0800, 0x0 }, - { gTextureFlagRed, 0x019E, 0x0800, 0x0 }, - { gTexture65100C, 0x0120, 0x0800, 0x0 }, - { gTexture65112C, 0x0150, 0x0800, 0x0 }, - { gTexture653608, 0x07A7, 0x0800, 0x0 }, - { gTextureGrass11, 0x01F8, 0x0800, 0x0 }, - { gTextureSignLuigiFace0, 0x05C9, 0x1000, 0x0 }, - { gTextureSignLuigiFace1, 0x065F, 0x1000, 0x0 }, - { gTexture66C7A8, 0x0149, 0x0800, 0x0 }, - { gTexture670AC8, 0x0FBF, 0x1000, 0x0 }, - { gTexture671A88, 0x012D, 0x0800, 0x0 }, - { gTexture6735DC, 0x03B1, 0x0800, 0x0 }, - { gTexture673C68, 0x038D, 0x0800, 0x0 }, - { gTexture6747C4, 0x0145, 0x0800, 0x0 }, - { gTextureRoad1, 0x02D2, 0x1000, 0x0 }, - { gTextureRoad2, 0x02AE, 0x1000, 0x0 }, - { gTextureRoadFinish1, 0x026B, 0x1000, 0x0 }, - { gTexture67BBD8, 0x0310, 0x0800, 0x0 }, - { gTexture68272C, 0x01F9, 0x1000, 0x0 }, - { gTexture682928, 0x01F9, 0x1000, 0x0 }, - { gTexture682B24, 0x01F9, 0x1000, 0x0 }, - { gTexture682D20, 0x01F9, 0x1000, 0x0 }, - { gTexture682F1C, 0x01F9, 0x1000, 0x0 }, - { gTexture683118, 0x01F9, 0x1000, 0x0 }, - { gTextureSignBlue64, 0x0567, 0x1000, 0x0 }, - { gTextureSignKoopaAir0, 0x0360, 0x1000, 0x0 }, - { gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, - { gTextureSignNintendoRed0, 0x02A6, 0x1000, 0x0 }, - { gTextureSignNintendoRed1, 0x02F7, 0x1000, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, - { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - LuigiRaceway::LuigiRaceway() { - this->vtx = d_course_luigi_raceway_vertex; - this->gfx = d_course_luigi_raceway_packed_dls; - this->gfxSize = 6377; - Props.textures = luigi_raceway_textures; Props.Minimap.Texture = minimap_luigi_raceway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -159,22 +114,25 @@ LuigiRaceway::LuigiRaceway() { Props.Skybox.FloorBottomLeft = { 0, 0, 0 }; Props.Skybox.FloorTopLeft = { 216, 232, 248 }; Props.Sequence = MusicSeq::MUSIC_SEQ_LUIGI_RACEWAY; - for (size_t i = 0; i < 120; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) luigi_raceway_dls[i], Props.textures); - } } void LuigiRaceway::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(luigi_raceway_dls); i++) { + InvertTriangleWindingByName(luigi_raceway_dls[i]); + } + InvertTriangleWindingByName(d_course_luigi_raceway_packed_dl_9EC0); + InvertTriangleWindingByName(d_course_luigi_raceway_packed_dl_E0); + InvertTriangleWindingByName(d_course_luigi_raceway_packed_dl_68); + } parse_course_displaylists((TrackSections*) LOAD_ASSET_RAW(d_course_luigi_raceway_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } -void LuigiRaceway::LoadTextures() { - dma_textures(gTextureTrees5Left, 0x000003E8U, 0x00000800U); // 0x03009000 - dma_textures(gTextureTrees5Right, 0x000003E8U, 0x00000800U); // 0x03009800 +void LuigiRaceway::UnLoad() { + RestoreTriangleWinding(); } void LuigiRaceway::BeginPlay() { @@ -254,59 +212,41 @@ void LuigiRaceway::SetStaffGhost() { D_80162DE4 = 1; } -void LuigiRaceway::Jumbotron() { - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0x0000, G_TX_RENDERTILE, 0, - G_TX_NOMIRROR | G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 6, G_TX_NOLOD); - gDPSetTileSize(gDisplayListHead++, G_TX_RENDERTILE, 0, 0, 0x00FC, 0x007C); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0xF800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBA20), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x10800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBA60), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x11800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBAA0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x12800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBAE0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x13800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBB20), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x14800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0xBB60), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPTileSync(gDisplayListHead++); +void LuigiRaceway::CopyJumbotron(s32 ulx, s32 uly, s16 portionToDraw, u16* source) { + // Add CVar if we want to expose a user toggle for only updating 1/6 of the jumbotron per frame + bool updateWholeJumbo = true; + + if (portionToDraw == -1 || updateWholeJumbo) { + copy_framebuffer(ulx, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture68272C)); + copy_framebuffer(ulx + 64, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682928)); + copy_framebuffer(ulx, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682B24)); + copy_framebuffer(ulx + 64, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682D20)); + copy_framebuffer(ulx, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682F1C)); + copy_framebuffer(ulx + 64, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture683118)); + } else { + switch (portionToDraw) { + case 0: + copy_framebuffer(ulx, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture68272C)); + break; + case 1: + copy_framebuffer(ulx + 64, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682928)); + break; + case 2: + copy_framebuffer(ulx, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682B24)); + break; + case 3: + copy_framebuffer(ulx + 64, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682D20)); + break; + case 4: + copy_framebuffer(ulx, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682F1C)); + break; + case 5: + copy_framebuffer(ulx + 64, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture683118)); + break; + default: + break; + } + } } void LuigiRaceway::Render(struct UnkStruct_800DC5EC* arg0) { @@ -321,32 +261,31 @@ void LuigiRaceway::Render(struct UnkStruct_800DC5EC* arg0) { // Invalidate Jumbotron textures so they update each frame // This could be more efficient if we exposed the non-opcode based invalidation to be called // inside copy_framebuffers_port - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0xF800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x10800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x11800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x12800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x13800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x14800); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture68272C); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682928); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682B24); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682D20); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682F1C); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture683118); 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_luigi_raceway_packed_dl_9EC0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07009EC0)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_luigi_raceway_packed_dl_9EC0); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - LuigiRaceway::Jumbotron(); render_course_segments(luigi_raceway_dls, arg0); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_luigi_raceway_packed_dl_E0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070000E0)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_luigi_raceway_packed_dl_E0); // d_course_luigi_raceway_packed_dl_68 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000068)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_luigi_raceway_packed_dl_68); D_800DC5DC = 88; D_800DC5E0 = 72; @@ -370,8 +309,8 @@ void LuigiRaceway::Render(struct UnkStruct_800DC5EC* arg0) { * The jumbo television screen used to be split into six sections to fit into the n64's texture size * restrictions It isn't split into six sections anymore */ - copy_jumbotron_fb_port(D_800DC5DC, D_800DC5E0, currentScreenSection, (u16*) gPortFramebuffers[prevFrame], - (u16*) (gSegmentTable[5] + 0xF800)); + CopyJumbotron(D_800DC5DC, D_800DC5E0, currentScreenSection, + (u16*) gPortFramebuffers[prevFrame]); } } diff --git a/src/engine/courses/LuigiRaceway.h b/src/engine/courses/LuigiRaceway.h index 48a7d8c08..53d9b8060 100644 --- a/src/engine/courses/LuigiRaceway.h +++ b/src/engine/courses/LuigiRaceway.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { -#include "assets/luigi_raceway_vertices.h" -#include "assets/luigi_raceway_displaylists.h" -#include "assets/luigi_raceway_data.h" +#include "assets/models/tracks/luigi_raceway/luigi_raceway_vertices.h" +#include "assets/models/tracks/luigi_raceway/luigi_raceway_displaylists.h" +#include "assets/models/tracks/luigi_raceway/luigi_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -16,7 +16,7 @@ extern const course_texture luigi_raceway_textures[]; } class LuigiRaceway : public Course { - void Jumbotron(); + void CopyJumbotron(s32 ulx, s32 uly, s16 portionToDraw, u16* source); public: virtual ~LuigiRaceway() = default; // Virtual destructor for proper cleanup in derived classes @@ -27,7 +27,7 @@ class LuigiRaceway : public Course { // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void SomeSounds() override; diff --git a/src/engine/courses/MarioRaceway.cpp b/src/engine/courses/MarioRaceway.cpp index 2afba1e9f..cff1e42b2 100644 --- a/src/engine/courses/MarioRaceway.cpp +++ b/src/engine/courses/MarioRaceway.cpp @@ -25,58 +25,20 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" - #include "mario_raceway_data.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_data.h" + #include "assets/other/tracks/mario_raceway/mario_raceway_data.h" #include "collision.h" #include "memory.h" #include "courses/staff_ghost_data.h" #include "course.h" - extern const char *mario_raceway_dls[]; + extern const char *mario_raceway_dls[68]; } -const course_texture mario_raceway_textures[] = { - { gTextureCheckerboardYellowPink, 0x0149, 0x0800, 0x0 }, - { gTexture64619C, 0x0124, 0x0800, 0x0 }, - { gTextureGrass1, 0x0125, 0x0800, 0x0 }, - { gTexture64BB60, 0x0169, 0x0800, 0x0 }, - { gTextureGrass7, 0x05DE, 0x0800, 0x0 }, - { gTextureGrass5, 0x023F, 0x0800, 0x0 }, - { gTextureFlagRed, 0x019E, 0x0800, 0x0 }, - { gTexture663F90, 0x0122, 0x0800, 0x0 }, - { gTexture6642A4, 0x0162, 0x0800, 0x0 }, - { gTexture6640B4, 0x01EF, 0x0800, 0x0 }, - { gTextureGrass10, 0x01F8, 0x0800, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, - { gTexture66C8F4, 0x01A1, 0x0800, 0x0 }, - { gTextureSignNintendoRed0, 0x02A6, 0x1000, 0x0 }, - { gTextureSignNintendoRed1, 0x02F7, 0x1000, 0x0 }, - { gTexture670AC8, 0x0FBF, 0x1000, 0x0 }, - { gTexture674354, 0x046F, 0x0800, 0x0 }, - { gTextureRoad0, 0x0300, 0x1000, 0x0 }, - { gTextureRoadFinish0, 0x0338, 0x1000, 0x0 }, - { gTexture67B9B0, 0x0225, 0x0800, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, - { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { gTextureSignShellShot0, 0x038C, 0x1000, 0x0 }, - { gTextureSignShellShot1, 0x0247, 0x1000, 0x0 }, - { gTextureSignKoopaAir0, 0x0360, 0x1000, 0x0 }, - { gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - MarioRaceway::MarioRaceway() { - this->vtx = d_course_mario_raceway_vertex; - this->gfx = d_course_mario_raceway_packed_dls; - this->gfxSize = 3367; - - Props.textures = mario_raceway_textures; Props.Minimap.Texture = minimap_mario_raceway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -148,26 +110,43 @@ MarioRaceway::MarioRaceway() { Props.Skybox.FloorBottomLeft = {0, 0, 0}; Props.Skybox.FloorTopLeft = {0, 0, 0}; Props.Sequence = MusicSeq::MUSIC_SEQ_MARIO_RACEWAY; - for (size_t i = 0; i < 68; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) mario_raceway_dls[i], Props.textures); - } } void MarioRaceway::Load() { Course::Load(); - generate_collision_mesh_with_defaults(segmented_gfx_to_virtual((void*)0x07001140)); + // Invert winding in mirror mode before generating collision meshes + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(mario_raceway_dls); i++) { + InvertTriangleWindingByName(mario_raceway_dls[i]); + } + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_1140); + + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_3508); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_3240); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_14A0); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_450); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_240); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_E0); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_160); + + // pipe collision mesh + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_8E8); + InvertTriangleWindingByName(d_course_mario_raceway_packed_dl_2D68); + } + + generate_collision_mesh_with_defaults((Gfx*) d_course_mario_raceway_packed_dl_1140); // Generate pipe collision mesh if (gScreenModeSelection == SCREEN_MODE_1P) { // d_course_mario_raceway_packed_dl_8E8 - generate_collision_mesh_with_defaults(segmented_gfx_to_virtual((void*)0x070008E8)); + generate_collision_mesh_with_defaults((Gfx*) d_course_mario_raceway_packed_dl_8E8); } else { if (CVarGetInteger("gDisableLod", 1) == true) { - generate_collision_mesh_with_defaults(segmented_gfx_to_virtual((void*)0x070008E8)); + generate_collision_mesh_with_defaults((Gfx*) d_course_mario_raceway_packed_dl_8E8); } else { // d_course_mario_raceway_packed_dl_2D68 - generate_collision_mesh_with_defaults(segmented_gfx_to_virtual((void*)0x07002D68)); + generate_collision_mesh_with_defaults((Gfx*) d_course_mario_raceway_packed_dl_2D68); } } @@ -176,8 +155,8 @@ void MarioRaceway::Load() { Props.WaterLevel = gCourseMinY - 10.0f; } -void MarioRaceway::LoadTextures() { - dma_textures(gTextureTrees1, 0x0000035BU, 0x00000800U); // 0x03009000 +void MarioRaceway::UnLoad() { + RestoreTriangleWinding(); } void MarioRaceway::BeginPlay() { @@ -264,6 +243,20 @@ void MarioRaceway::SetStaffGhost() { D_80162DE4 = 0; } +void render_mario_raceway_pipe(void) { + if (gScreenModeSelection == SCREEN_MODE_1P) { + // d_course_mario_raceway_packed_dl_8E8 + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_8E8); + } else { + if (CVarGetInteger("gDisableLod", 1) == true) { + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_8E8); + return; + } + // d_course_mario_raceway_packed_dl_2D68 + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_2D68); + } +} + void MarioRaceway::Render(struct UnkStruct_800DC5EC* arg0) { u16 sp22 = arg0->pathCounter; u16 temp_t0 = arg0->playerDirection; @@ -274,7 +267,7 @@ void MarioRaceway::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_mario_raceway_packed_dl_3050 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07003050)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_3050); } gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); @@ -355,18 +348,18 @@ void MarioRaceway::Render(struct UnkStruct_800DC5EC* arg0) { } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07003508)))); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07003240)))); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070014A0)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_3508); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_3240); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_14A0); render_course_segments(mario_raceway_dls, arg0); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000450)))); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000240)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_450); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_240); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070000E0)))); - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000160)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_E0); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_mario_raceway_packed_dl_160); } void MarioRaceway::RenderCredits() { @@ -374,7 +367,6 @@ void MarioRaceway::RenderCredits() { } void MarioRaceway::CreditsSpawnActors() { - dma_textures(gTextureTrees1, 0x35B, 0x800); spawn_foliage((struct ActorSpawnData*)LOAD_ASSET_RAW(d_course_mario_raceway_tree_spawns)); } diff --git a/src/engine/courses/MarioRaceway.h b/src/engine/courses/MarioRaceway.h index e237f1538..1e99add7e 100644 --- a/src/engine/courses/MarioRaceway.h +++ b/src/engine/courses/MarioRaceway.h @@ -4,15 +4,14 @@ #include "Course.h" extern "C" { - #include "mario_raceway_vertices.h" - #include "mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_vertices.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" #include "objects.h" #include "path_spawn_metadata.h" - #include "mario_raceway_data.h" - extern const course_texture mario_raceway_textures[]; } class MarioRaceway : public Course { @@ -25,7 +24,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void SomeSounds() override; diff --git a/src/engine/courses/MooMooFarm.cpp b/src/engine/courses/MooMooFarm.cpp index 375a4e743..c509d7822 100644 --- a/src/engine/courses/MooMooFarm.cpp +++ b/src/engine/courses/MooMooFarm.cpp @@ -7,7 +7,8 @@ #include "World.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" -#include "assets/moo_moo_farm_data.h" +#include "assets/models/tracks/moo_moo_farm/moo_moo_farm_data.h" +#include "assets/other/tracks/moo_moo_farm/moo_moo_farm_data.h" #include "engine/objects/MoleGroup.h" #include "engine/objects/Mole.h" @@ -25,7 +26,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -33,48 +34,12 @@ extern "C" { #include "memory.h" #include "code_80086E70.h" #include "course.h" - extern const char *moo_moo_farm_dls[]; + extern const char *moo_moo_farm_dls[92]; extern s16 currentScreenSection; extern s8 gPlayerCount; } -const course_texture moo_moo_farm_textures[] = { - { gTextureWoodDoor0, 0x0294, 0x1000, 0x0 }, - { gTextureGrass2, 0x0415, 0x0800, 0x0 }, - { gTexture64AF50, 0x0140, 0x0800, 0x0 }, - { gTexture64B090, 0x0365, 0x0800, 0x0 }, - { gTexture64B54C, 0x038C, 0x0800, 0x0 }, - { gTexture64B3F8, 0x0153, 0x0800, 0x0 }, - { gTextureSignNintendo0, 0x0541, 0x1000, 0x0 }, - { gTextureSignNintendo1, 0x0512, 0x1000, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, - { gTexture674D58, 0x030C, 0x1000, 0x0 }, - { gTexture675064, 0x01BB, 0x0800, 0x0 }, - { gTexture675220, 0x0212, 0x0800, 0x0 }, - { gTexture6775EC, 0x0233, 0x1000, 0x0 }, - { gTexture683314, 0x02DC, 0x1000, 0x0 }, - { gTexture68CDA0, 0x0110, 0x0800, 0x0 }, - { gTexture6442D4, 0x0138, 0x0800, 0x0 }, - { gTexture64440C, 0x029D, 0x1000, 0x0 }, - { gTexture6446AC, 0x0116, 0x0800, 0x0 }, - { gTextureMooMooFarmSignLeft, 0x0A66, 0x1000, 0x0 }, - { gTextureMooMooFarmSignRight, 0x0A64, 0x1000, 0x0 }, - { gTexture64ACAC, 0x02A3, 0x0800, 0x0 }, - { gTexture66D698, 0x0370, 0x0800, 0x0 }, - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, - { gTextureWheelSteamEngineReal, 0x022F, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - MooMooFarm::MooMooFarm() { - this->vtx = d_course_moo_moo_farm_vertex; - this->gfx = d_course_moo_moo_farm_packed_dls; - this->gfxSize = 3304; - Props.textures = moo_moo_farm_textures; Props.Minimap.Texture = minimap_moo_moo_farm; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -144,32 +109,28 @@ MooMooFarm::MooMooFarm() { Props.Skybox.FloorBottomLeft = {0, 0, 0}; Props.Skybox.FloorTopLeft = {255, 184, 99}; Props.Sequence = MusicSeq::MUSIC_SEQ_MOO_MOO_FARM; - for (size_t i = 0; i < 92; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) moo_moo_farm_dls[i], Props.textures); - } } void MooMooFarm::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(moo_moo_farm_dls); i++) { + InvertTriangleWindingByName(moo_moo_farm_dls[i]); + } + InvertTriangleWindingByName(d_course_moo_moo_farm_packed_dl_4DF8); + InvertTriangleWindingByName(d_course_moo_moo_farm_packed_dl_5640); + InvertTriangleWindingByName(d_course_moo_moo_farm_dl_13FF8); + InvertTriangleWindingByName(d_course_moo_moo_farm_packed_dl_5410); + InvertTriangleWindingByName(d_course_moo_moo_farm_dl_14060); + InvertTriangleWindingByName(d_course_moo_moo_farm_packed_dl_10C0); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_moo_moo_farm_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; } -void MooMooFarm::LoadTextures() { - dma_textures(gTextureTrees4Left, 0x000003E8U, 0x00000800U); // 0x03009000 - dma_textures(gTextureTrees4Right, 0x000003E8U, 0x00000800U); // 0x03009800 - dma_textures(gTextureCow01Left, 0x00000400U, 0x00000800U); // 0x0300A000 - dma_textures(gTextureCow01Right, 0x00000400U, 0x00000800U); // 0x0300A800 - dma_textures(gTextureCow02Left, 0x00000400U, 0x00000800U); // 0x0300B000 - dma_textures(gTextureCow02Right, 0x00000400U, 0x00000800U); // 0x0300B800 - dma_textures(gTextureCow03Left, 0x00000400U, 0x00000800U); // 0x0300C000 - dma_textures(gTextureCow03Right, 0x00000400U, 0x00000800U); // 0x0300C800 - dma_textures(gTextureCow04Left, 0x00000400U, 0x00000800U); // 0x0300D000 - dma_textures(gTextureCow04Right, 0x00000400U, 0x00000800U); // 0x0300D800 - dma_textures(gTextureCow05Left, 0x00000400U, 0x00000800U); // 0x0300E000 - dma_textures(gTextureCow05Right, 0x00000400U, 0x00000800U); // 0x0300E800 +void MooMooFarm::UnLoad() { + RestoreTriangleWinding(); } void MooMooFarm::BeginPlay() { @@ -310,9 +271,9 @@ void MooMooFarm::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEI, G_CC_MODULATEI); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_moo_moo_farm_packed_dl_4DF8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07004DF8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_moo_moo_farm_packed_dl_4DF8); // d_course_moo_moo_farm_packed_dl_5640 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07005640)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_moo_moo_farm_packed_dl_5640); gSPFogPosition(gDisplayListHead++, D_802B87B0, D_802B87B4); render_course_segments(moo_moo_farm_dls, arg0); @@ -340,13 +301,13 @@ void MooMooFarm::Render(struct UnkStruct_800DC5EC* arg0) { if ((temp_s0 >= 16) && (temp_s0 < 24)) { if ((temp_s1 == 2) || (temp_s1 == 3)) { // d_course_moo_moo_farm_packed_dl_5410 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07005410)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_moo_moo_farm_packed_dl_5410); } } else if (temp_s0 < 9) { if (temp_s1 == 2) { // d_course_moo_moo_farm_packed_dl_5410 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07005410)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_moo_moo_farm_packed_dl_5410); } } if (temp_s0 < 4) { @@ -369,7 +330,7 @@ void MooMooFarm::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); // d_course_moo_moo_farm_packed_dl_10C0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070010C0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_moo_moo_farm_packed_dl_10C0); } void MooMooFarm::RenderCredits() { @@ -377,18 +338,6 @@ void MooMooFarm::RenderCredits() { } void MooMooFarm::CreditsSpawnActors() { - dma_textures(gTextureTrees4Left, 0x3E8, 0x800); - dma_textures(gTextureTrees4Right, 0x3E8, 0x800); - dma_textures(gTextureCow01Left, 0x400, 0x800); - dma_textures(gTextureCow01Right, 0x400, 0x800); - dma_textures(gTextureCow02Left, 0x400, 0x800); - dma_textures(gTextureCow02Right, 0x400, 0x800); - dma_textures(gTextureCow03Left, 0x400, 0x800); - dma_textures(gTextureCow03Right, 0x400, 0x800); - dma_textures(gTextureCow04Left, 0x400, 0x800); - dma_textures(gTextureCow04Right, 0x400, 0x800); - dma_textures(gTextureCow05Left, 0x400, 0x800); - dma_textures(gTextureCow05Right, 0x400, 0x800); spawn_foliage((struct ActorSpawnData*) LOAD_ASSET_RAW(d_course_moo_moo_farm_tree_spawn)); } diff --git a/src/engine/courses/MooMooFarm.h b/src/engine/courses/MooMooFarm.h index 3c18e5024..8468ca8aa 100644 --- a/src/engine/courses/MooMooFarm.h +++ b/src/engine/courses/MooMooFarm.h @@ -5,9 +5,9 @@ #include "engine/objects/Mole.h" extern "C" { - #include "assets/moo_moo_farm_vertices.h" - #include "assets/moo_moo_farm_displaylists.h" - #include "assets/moo_moo_farm_data.h" + #include "assets/models/tracks/moo_moo_farm/moo_moo_farm_vertices.h" + #include "assets/models/tracks/moo_moo_farm/moo_moo_farm_displaylists.h" + #include "assets/models/tracks/moo_moo_farm/moo_moo_farm_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -28,7 +28,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void WhatDoesThisDo(Player* player, int8_t playerId) override; virtual void WhatDoesThisDoAI(Player* player, int8_t playerId) override; diff --git a/src/engine/courses/PodiumCeremony.cpp b/src/engine/courses/PodiumCeremony.cpp index c41d96904..48cd2478b 100644 --- a/src/engine/courses/PodiumCeremony.cpp +++ b/src/engine/courses/PodiumCeremony.cpp @@ -6,8 +6,10 @@ #include "PodiumCeremony.h" #include "World.h" #include "engine/objects/BombKart.h" -#include "assets/royal_raceway_data.h" -#include "assets/ceremony_data.h" +#include "assets/models/tracks/royal_raceway/royal_raceway_data.h" +#include "assets/other/tracks/royal_raceway/royal_raceway_data.h" +#include "assets/models/ceremony_data.h" +#include "assets/other/ceremony_data.h" #include "engine/objects/Trophy.h" #include "engine/objects/Podium.h" #include "engine/objects/CheepCheep.h" @@ -28,7 +30,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -40,58 +42,7 @@ extern "C" { extern const char *royal_raceway_dls[]; } -const course_texture podium_ceremony_textures[] = { - { gTexture64619C, 0x0124, 0x0800, 0x0 }, - { gTexture645134, 0x052C, 0x0800, 0x0 }, - { gTextureWoodDoor1, 0x0903, 0x1000, 0x0 }, - { gTexture64BB60, 0x0169, 0x0800, 0x0 }, - { gTextureGrass3, 0x0372, 0x0800, 0x0 }, - { gTexture64F9E8, 0x020B, 0x1000, 0x0 }, - { gTextureFlagRed, 0x019E, 0x0800, 0x0 }, - { gTextureCrownJewelBlue, 0x0301, 0x0800, 0x0 }, - { gTextureCrown, 0x0106, 0x0800, 0x0 }, - { gTextureCrownJewelPink, 0x0313, 0x0800, 0x0 }, - { gTextureSignKoopaAir0, 0x0360, 0x1000, 0x0 }, - { gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, - { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTextureCheckerboardPink, 0x0157, 0x0800, 0x0 }, - { gTexture670AC8, 0x0FBF, 0x1000, 0x0 }, - { gTextureRoad0, 0x0300, 0x1000, 0x0 }, - { gTextureRoadFinish0, 0x0338, 0x1000, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, - { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { gTextureCastleBricks, 0x0B33, 0x1000, 0x0 }, - { gTextureCastleBridge, 0x0428, 0x0800, 0x0 }, - { gTextureGrass8, 0x02CB, 0x0800, 0x0 }, - { gTextureGrass9, 0x0421, 0x0800, 0x0 }, - { gTexture6646B8, 0x0298, 0x1000, 0x0 }, - { gTexture664408, 0x02AE, 0x1000, 0x0 }, - { gTextureBricksRed, 0x0C55, 0x1000, 0x0 }, - { gTexture665C0C, 0x059D, 0x0800, 0x0 }, - { gTexture6661AC, 0x01F7, 0x0800, 0x0 }, - { gTexture6663A4, 0x05F6, 0x0800, 0x0 }, - { gTexture667BAC, 0x067A, 0x0800, 0x0 }, - { gTextureFlagRed2, 0x0186, 0x0800, 0x0 }, - { gTexture66DB60, 0x01D6, 0x0800, 0x0 }, - { gTextureStainglassPeach0, 0x0ED1, 0x1000, 0x0 }, - { gTextureStainglassPeach1, 0x0DA9, 0x1000, 0x0 }, - { gTextureFencePostWooden, 0x083D, 0x1000, 0x0 }, - { gTexture648508, 0x01FE, 0x1000, 0x0 }, - { gTexture6449D4, 0x075D, 0x0800, 0x0 }, - { gTexture67FE0C, 0x02DE, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - PodiumCeremony::PodiumCeremony() { - this->vtx = d_course_royal_raceway_vertex; - this->gfx = d_course_royal_raceway_packed_dls; - this->gfxSize = 5670; - Props.textures = podium_ceremony_textures; Props.Minimap.Width = 0; Props.Minimap.Height = 0; Props.Minimap.Pos[0].X = 262; @@ -167,7 +118,7 @@ void PodiumCeremony::Load() { func_80295C6C(); } -void PodiumCeremony::LoadTextures() { +void PodiumCeremony::UnLoad() { } void PodiumCeremony::BeginPlay() { @@ -263,23 +214,23 @@ void PodiumCeremony::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_royal_raceway_packed_dl_B030 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700B030)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_B030); } gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_royal_raceway_packed_dl_A648 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700A648)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_A648); render_course_segments(royal_raceway_dls, arg0); // d_course_royal_raceway_packed_dl_11A8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070011A8)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_11A8); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_royal_raceway_packed_dl_8A0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070008A0)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_8A0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); } diff --git a/src/engine/courses/PodiumCeremony.h b/src/engine/courses/PodiumCeremony.h index 6026d7f9f..403f7f310 100644 --- a/src/engine/courses/PodiumCeremony.h +++ b/src/engine/courses/PodiumCeremony.h @@ -5,9 +5,9 @@ #include "Course.h" extern "C" { - #include "assets/royal_raceway_vertices.h" - #include "assets/royal_raceway_displaylists.h" - #include "assets/royal_raceway_data.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_vertices.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_displaylists.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -26,7 +26,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; //virtual void InitClouds() override; virtual void InitCourseObjects() override; diff --git a/src/engine/courses/RainbowRoad.cpp b/src/engine/courses/RainbowRoad.cpp index bfc64e976..dcfd4856d 100644 --- a/src/engine/courses/RainbowRoad.cpp +++ b/src/engine/courses/RainbowRoad.cpp @@ -8,7 +8,8 @@ #include "engine/actors/Finishline.h" #include "engine/objects/ChainChomp.h" #include "engine/objects/BombKart.h" -#include "assets/rainbow_road_data.h" +#include "assets/models/tracks/rainbow_road/rainbow_road_data.h" +#include "assets/other/tracks/rainbow_road/rainbow_road_data.h" extern "C" { #include "main.h" @@ -24,31 +25,17 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course.h" - extern const char *rainbow_road_dls[]; + extern const char *rainbow_road_dls[48]; } -const course_texture rainbow_road_textures[] = { - { gTextureStarOutline, 0x037A, 0x0800, 0x0 }, - { gTexture67A1B8, 0x01B7, 0x0800, 0x0 }, - { gTextureCheckerboardBlackWhite, 0x0107, 0x0800, 0x0 }, - { gTexture662A34, 0x0106, 0x0800, 0x0 }, - { gTextureRainbow, 0x025D, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - - RainbowRoad::RainbowRoad() { - this->vtx = d_course_rainbow_road_vertex; - this->gfx = d_course_rainbow_road_packed_dls; - this->gfxSize = 5670; - Props.textures = rainbow_road_textures; Props.Minimap.Texture = minimap_rainbow_road; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -123,23 +110,28 @@ RainbowRoad::RainbowRoad() { void RainbowRoad::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(rainbow_road_dls); i++) { + InvertTriangleWindingByName(rainbow_road_dls[i]); + } + } D_800DC5C8 = 1; parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_rainbow_road_addr)); func_80295C6C(); // d_course_rainbow_road_packed_dl_2068 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07002068), 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_2068, 150, 255, 255, 255); // d_course_rainbow_road_packed_dl_1E18 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001E18), 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_1E18, 150, 255, 255, 255); // d_course_rainbow_road_packed_dl_1318 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001318), 255, 255, 255, 0); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_1318, 255, 255, 255, 0); if (gGamestate != CREDITS_SEQUENCE) { // d_course_rainbow_road_packed_dl_1FB8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001FB8), 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_1FB8, 150, 255, 255, 255); } } -void RainbowRoad::LoadTextures() { +void RainbowRoad::UnLoad() { + RestoreTriangleWinding(); } void RainbowRoad::BeginPlay() { @@ -217,11 +209,8 @@ void RainbowRoad::Waypoints(Player* player, int8_t playerId) { } void RainbowRoad::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - Mat4 matrix; gDPPipeSync(gDisplayListHead++); - mtxf_identity(matrix); - render_set_position(matrix, 0); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); render_course_segments(rainbow_road_dls, screen); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); @@ -231,11 +220,11 @@ void RainbowRoad::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCoun void RainbowRoad::CreditsSpawnActors() { // d_course_rainbow_road_packed_dl_2068 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07002068), 150, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_2068, 150, 0xFF, 0xFF, 0xFF); // d_course_rainbow_road_packed_dl_1E18 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001E18), 150, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_1E18, 150, 0xFF, 0xFF, 0xFF); // d_course_rainbow_road_packed_dl_1318 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001318), 255, 0xFF, 0xFF, 0); + find_vtx_and_set_colours((Gfx*) d_course_rainbow_road_packed_dl_1318, 255, 0xFF, 0xFF, 0); } void RainbowRoad::Destroy() {} diff --git a/src/engine/courses/RainbowRoad.h b/src/engine/courses/RainbowRoad.h index 282655ace..ffe3286ca 100644 --- a/src/engine/courses/RainbowRoad.h +++ b/src/engine/courses/RainbowRoad.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/rainbow_road_vertices.h" - #include "assets/rainbow_road_displaylists.h" - #include "assets/rainbow_road_data.h" + #include "assets/models/tracks/rainbow_road/rainbow_road_vertices.h" + #include "assets/models/tracks/rainbow_road/rainbow_road_displaylists.h" + #include "assets/models/tracks/rainbow_road/rainbow_road_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitClouds() override; virtual void UpdateClouds(s32, Camera*) override; diff --git a/src/engine/courses/RoyalRaceway.cpp b/src/engine/courses/RoyalRaceway.cpp index 1fc6a10b9..6362a2c15 100644 --- a/src/engine/courses/RoyalRaceway.cpp +++ b/src/engine/courses/RoyalRaceway.cpp @@ -7,7 +7,8 @@ #include "World.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" -#include "assets/royal_raceway_data.h" +#include "assets/models/tracks/royal_raceway/royal_raceway_data.h" +#include "assets/other/tracks/royal_raceway/royal_raceway_data.h" #include "engine/objects/GrandPrixBalloons.h" extern "C" { @@ -24,7 +25,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -32,61 +33,10 @@ extern "C" { #include "memory.h" #include "courses/staff_ghost_data.h" #include "course.h" - extern const char *royal_raceway_dls[]; + extern const char *royal_raceway_dls[132]; } -const course_texture royal_raceway_textures[] = { - { gTexture64619C, 0x0124, 0x0800, 0x0 }, - { gTexture645134, 0x052C, 0x0800, 0x0 }, - { gTextureWoodDoor1, 0x0903, 0x1000, 0x0 }, - { gTexture64BB60, 0x0169, 0x0800, 0x0 }, - { gTextureGrass3, 0x0372, 0x0800, 0x0 }, - { gTexture64F9E8, 0x020B, 0x1000, 0x0 }, - { gTextureFlagRed, 0x019E, 0x0800, 0x0 }, - { gTextureCrownJewelBlue, 0x0301, 0x0800, 0x0 }, - { gTextureCrown, 0x0106, 0x0800, 0x0 }, - { gTextureCrownJewelPink, 0x0313, 0x0800, 0x0 }, - { gTextureSignKoopaAir0, 0x0360, 0x1000, 0x0 }, - { gTextureSignKoopaAir1, 0x0304, 0x1000, 0x0 }, - { gTexture6684F8, 0x010D, 0x0800, 0x0 }, - { gTextureSignLuigis0, 0x0287, 0x1000, 0x0 }, - { gTextureSignLuigis1, 0x02AF, 0x1000, 0x0 }, - { gTextureSignMarioStar0, 0x02D2, 0x1000, 0x0 }, - { gTextureSignMarioStar1, 0x02B1, 0x1000, 0x0 }, - { gTexture66CA98, 0x02C9, 0x0800, 0x0 }, - { gTextureCheckerboardPink, 0x0157, 0x0800, 0x0 }, - { gTexture670AC8, 0x0FBF, 0x1000, 0x0 }, - { gTextureRoad0, 0x0300, 0x1000, 0x0 }, - { gTextureRoadFinish0, 0x0338, 0x1000, 0x0 }, - { gTextureSignYoshi, 0x04DF, 0x1000, 0x0 }, - { gTextureCheckerboardBlueGray, 0x04A1, 0x1000, 0x0 }, - { gTextureCastleBricks, 0x0B33, 0x1000, 0x0 }, - { gTextureCastleBridge, 0x0428, 0x0800, 0x0 }, - { gTextureGrass8, 0x02CB, 0x0800, 0x0 }, - { gTextureGrass9, 0x0421, 0x0800, 0x0 }, - { gTexture6646B8, 0x0298, 0x1000, 0x0 }, - { gTexture664408, 0x02AE, 0x1000, 0x0 }, - { gTextureBricksRed, 0x0C55, 0x1000, 0x0 }, - { gTexture665C0C, 0x059D, 0x0800, 0x0 }, - { gTexture6661AC, 0x01F7, 0x0800, 0x0 }, - { gTexture6663A4, 0x05F6, 0x0800, 0x0 }, - { gTexture667BAC, 0x067A, 0x0800, 0x0 }, - { gTextureFlagRed2, 0x0186, 0x0800, 0x0 }, - { gTexture66DB60, 0x01D6, 0x0800, 0x0 }, - { gTextureStainglassPeach0, 0x0ED1, 0x1000, 0x0 }, - { gTextureStainglassPeach1, 0x0DA9, 0x1000, 0x0 }, - { gTextureFencePostWooden, 0x083D, 0x1000, 0x0 }, - { gTexture648508, 0x01FE, 0x1000, 0x0 }, - { gTexture6449D4, 0x075D, 0x0800, 0x0 }, - { gTexture67FE0C, 0x02DE, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - RoyalRaceway::RoyalRaceway() { - this->vtx = d_course_royal_raceway_vertex; - this->gfx = d_course_royal_raceway_packed_dls; - this->gfxSize = 5670; - Props.textures = royal_raceway_textures; Props.Minimap.Texture = minimap_royal_raceway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -158,21 +108,25 @@ RoyalRaceway::RoyalRaceway() { Props.Sequence = MusicSeq::MUSIC_SEQ_ROYAL_RACEWAY; Props.WaterLevel = -60.0f; - for (size_t i = 0; i < 132; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) royal_raceway_dls[i], Props.textures); - } } void RoyalRaceway::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(royal_raceway_dls); i++) { + InvertTriangleWindingByName(royal_raceway_dls[i]); + } + InvertTriangleWindingByName(d_course_royal_raceway_packed_dl_B030); + InvertTriangleWindingByName(d_course_royal_raceway_packed_dl_A648); + InvertTriangleWindingByName(d_course_royal_raceway_packed_dl_11A8); + InvertTriangleWindingByName(d_course_royal_raceway_packed_dl_8A0); + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_royal_raceway_addr)); func_80295C6C(); } -void RoyalRaceway::LoadTextures() { - dma_textures(gTextureTrees3, 0x000003E8U, 0x00000800U); // 0x03009000 - dma_textures(gTextureTrees7, 0x000003E8U, 0x00000800U); // 0x03009800 +void RoyalRaceway::UnLoad() { + RestoreTriangleWinding(); } void RoyalRaceway::BeginPlay() { @@ -255,23 +209,23 @@ void RoyalRaceway::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_royal_raceway_packed_dl_B030 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700B030)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_B030); } gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_royal_raceway_packed_dl_A648 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700A648)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_A648); render_course_segments(royal_raceway_dls, arg0); // d_course_royal_raceway_packed_dl_11A8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070011A8)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_11A8); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_royal_raceway_packed_dl_8A0 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x070008A0)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_royal_raceway_packed_dl_8A0); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); } @@ -297,7 +251,7 @@ void RoyalRaceway::ScrollingTextures() { D_802B87BC = 0xFF; } // d_course_royal_raceway_packed_dl_A6A8 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x0700A6A8), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) d_course_royal_raceway_packed_dl_A6A8, 0, D_802B87BC); // d_course_royal_raceway_packed_dl_A648 - find_and_set_tile_size((uintptr_t) segmented_gfx_to_virtual((void*)0x0700A648), 0, D_802B87BC); + find_and_set_tile_size((uintptr_t) d_course_royal_raceway_packed_dl_A648, 0, D_802B87BC); } diff --git a/src/engine/courses/RoyalRaceway.h b/src/engine/courses/RoyalRaceway.h index 7fe973edd..4b8552b09 100644 --- a/src/engine/courses/RoyalRaceway.h +++ b/src/engine/courses/RoyalRaceway.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/royal_raceway_vertices.h" - #include "assets/royal_raceway_displaylists.h" - #include "assets/royal_raceway_data.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_vertices.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_displaylists.h" + #include "assets/models/tracks/royal_raceway/royal_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void WhatDoesThisDo(Player* player, int8_t playerId) override; diff --git a/src/engine/courses/SherbetLand.cpp b/src/engine/courses/SherbetLand.cpp index 4d72e8095..a27f954d3 100644 --- a/src/engine/courses/SherbetLand.cpp +++ b/src/engine/courses/SherbetLand.cpp @@ -7,8 +7,10 @@ #include "World.h" #include "engine/actors/Finishline.h" #include "engine/objects/BombKart.h" -#include "assets/sherbet_land_data.h" +#include "assets/models/tracks/sherbet_land/sherbet_land_data.h" +#include "assets/other/tracks/sherbet_land/sherbet_land_data.h" #include "engine/objects/Penguin.h" +#include "resourcebridge.h" extern "C" { #include "main.h" @@ -24,31 +26,18 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course.h" - extern const char *sherbet_land_dls[]; - extern const char *sherbet_land_dls_2[]; + extern const char *sherbet_land_dls[72]; + extern const char *sherbet_land_dls_2[72]; } -const course_texture sherbet_land_textures[] = { - { gTexture643B3C, 0x0798, 0x0800, 0x0 }, { gTexture66D024, 0x04EA, 0x0800, 0x0 }, - { gTexture678118, 0x0314, 0x0800, 0x0 }, { gTextureSignWoodRedArrow, 0x04E1, 0x1000, 0x0 }, - { gTexture678CC8, 0x058E, 0x0800, 0x0 }, { gTexture67842C, 0x050E, 0x0800, 0x0 }, - { gTexture67893C, 0x038B, 0x0800, 0x0 }, { gTexture651984, 0x019C, 0x0800, 0x0 }, - { gTexture651428, 0x055B, 0x0800, 0x0 }, { gTexture662924, 0x0110, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - SherbetLand::SherbetLand() { - this->vtx = d_course_sherbet_land_vertex; - this->gfx = d_course_sherbet_land_packed_dls; - this->gfxSize = 1803; - Props.textures = sherbet_land_textures; Props.Minimap.Texture = minimap_sherbet_land; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -123,23 +112,28 @@ SherbetLand::SherbetLand() { Props.Sequence = MusicSeq::MUSIC_SEQ_FRAPPE_SNOWLAND; Props.WaterLevel = -18.0f; - for (size_t i = 0; i < 72; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) sherbet_land_dls[i], Props.textures); - } - for (size_t i = 0; i < 72; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) sherbet_land_dls_2[i], Props.textures); - } } void SherbetLand::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(sherbet_land_dls); i++) { + InvertTriangleWindingByName(sherbet_land_dls[i]); + } + for (size_t i = 0; i < ARRAY_COUNT(sherbet_land_dls_2); i++) { + InvertTriangleWindingByName(sherbet_land_dls_2[i]); + } + } parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_sherbet_land_addr)); func_80295C6C(); // d_course_sherbet_land_packed_dl_1EB8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001EB8), 180, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_sherbet_land_packed_dl_1EB8, 180, 255, 255, 255); // d_course_sherbet_land_packed_dl_2308 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07002308), 150, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_sherbet_land_packed_dl_2308, 150, 255, 255, 255); +} + +void SherbetLand::UnLoad() { + RestoreTriangleWinding(); } f32 SherbetLand::GetWaterLevel(FVector pos, Collision* collision) { @@ -220,8 +214,6 @@ void SherbetLand::RenderCredits() { } void SherbetLand::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - Mat4 matrix; - gDPPipeSync(gDisplayListHead++); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); @@ -229,9 +221,6 @@ void SherbetLand::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCoun gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIA, G_CC_MODULATEIA); gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); - - mtxf_identity(matrix); - render_set_position(matrix, 0); render_course_segments(sherbet_land_dls_2, screen); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); @@ -240,14 +229,14 @@ void SherbetLand::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCoun gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); // d_course_sherbet_land_packed_dl_2B48 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07002B48)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_sherbet_land_packed_dl_2B48); } gDPPipeSync(gDisplayListHead++); } void SherbetLand::CreditsSpawnActors() { // d_course_sherbet_land_packed_dl_1EB8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07001EB8), 180, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_sherbet_land_packed_dl_1EB8, 180, 0xFF, 0xFF, 0xFF); // d_course_sherbet_land_packed_dl_2308 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*)0x07002308), 150, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_sherbet_land_packed_dl_2308, 150, 0xFF, 0xFF, 0xFF); } diff --git a/src/engine/courses/SherbetLand.h b/src/engine/courses/SherbetLand.h index eb62e2807..ecc72aedf 100644 --- a/src/engine/courses/SherbetLand.h +++ b/src/engine/courses/SherbetLand.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/sherbet_land_vertices.h" - #include "assets/sherbet_land_displaylists.h" - #include "assets/sherbet_land_data.h" + #include "assets/models/tracks/sherbet_land/sherbet_land_vertices.h" + #include "assets/models/tracks/sherbet_land/sherbet_land_displaylists.h" + #include "assets/models/tracks/sherbet_land/sherbet_land_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,6 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; + virtual void UnLoad() override; virtual f32 GetWaterLevel(FVector pos, Collision* collision) override; virtual void BeginPlay() override; virtual void UpdateCourseObjects() override; diff --git a/src/engine/courses/Skyscraper.cpp b/src/engine/courses/Skyscraper.cpp index 53232257d..0abd6caa5 100644 --- a/src/engine/courses/Skyscraper.cpp +++ b/src/engine/courses/Skyscraper.cpp @@ -6,7 +6,8 @@ #include "Skyscraper.h" #include "World.h" #include "engine/objects/BombKart.h" -#include "assets/skyscraper_data.h" +#include "assets/models/tracks/skyscraper/skyscraper_data.h" +#include "assets/other/tracks/skyscraper/skyscraper_data.h" extern "C" { #include "main.h" @@ -22,48 +23,16 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" - extern const char *skyscraper_dls[]; extern s16 currentScreenSection; } -const course_texture skyscraper_textures[] = { - { gTexture6457D8, 0x0160, 0x0800, 0x0 }, - { gTexture6462C0, 0x01B9, 0x0800, 0x0 }, - { gTexture6864E8, 0x0807, 0x1000, 0x0 }, - { gTexture686CF0, 0x08B7, 0x1000, 0x0 }, - { gTexture6875A8, 0x093F, 0x1000, 0x0 }, - { gTexture687EE8, 0x0883, 0x1000, 0x0 }, - { gTexture68876C, 0x0AC2, 0x1000, 0x0 }, - { gTexture689230, 0x09CE, 0x1000, 0x0 }, - { gTexture689C00, 0x0884, 0x1000, 0x0 }, - { gTexture68A484, 0x07D6, 0x1000, 0x0 }, - { gTexture68AC5C, 0x0A47, 0x1000, 0x0 }, - { gTexture68B6A4, 0x07C5, 0x1000, 0x0 }, - { gTexture68BE6C, 0x04A1, 0x1000, 0x0 }, - { gTexture68C310, 0x030D, 0x1000, 0x0 }, - { gTexture64B8D8, 0x0177, 0x0800, 0x0 }, - { gTexture645660, 0x0176, 0x0800, 0x0 }, - { gTextureNumberYellowBlue1, 0x01AE, 0x0800, 0x0 }, - { gTextureNumberYellowBlue2, 0x01C6, 0x0800, 0x0 }, - { gTextureNumberYellowBlue3, 0x01CC, 0x0800, 0x0 }, - { gTextureNumberYellowBlue4, 0x01E4, 0x0800, 0x0 }, - { gTexture668608, 0x0120, 0x0800, 0x0 }, - { gTexture67B75C, 0x0108, 0x0800, 0x0 }, - { gTexture6835F0, 0x0252, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - Skyscraper::Skyscraper() { - this->vtx = d_course_skyscraper_vertex; - this->gfx = d_course_skyscraper_packed_dls; - this->gfxSize = 548; - Props.textures = skyscraper_textures; Props.Minimap.Texture = minimap_skyscraper; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -138,15 +107,23 @@ Skyscraper::Skyscraper() { void Skyscraper::Load() { Course::Load(); - + if (gIsMirrorMode != 0) { + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_FE8); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_C60); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_B70); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_6B8); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_570); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_10C8); + InvertTriangleWindingByName(d_course_skyscraper_packed_dl_258); + } // d_course_skyscraper_packed_dl_1110 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*)0x07001110), 1); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_skyscraper_packed_dl_1110, 1); // d_course_skyscraper_packed_dl_258 - generate_collision_mesh_with_default_section_id((Gfx*) segmented_gfx_to_virtual((void*)0x07000258), 1); + generate_collision_mesh_with_default_section_id((Gfx*) d_course_skyscraper_packed_dl_258, 1); func_80295C6C(); } -void Skyscraper::LoadTextures() { +void Skyscraper::UnLoad() { } void Skyscraper::BeginPlay() { @@ -177,21 +154,21 @@ void Skyscraper::Render(struct UnkStruct_800DC5EC* arg0) { gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH); gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); // d_course_skyscraper_packed_dl_FE8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000FE8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_FE8); // d_course_skyscraper_packed_dl_C60 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000C60))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_C60); // d_course_skyscraper_packed_dl_B70 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000B70))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_B70); // d_course_skyscraper_packed_dl_6B8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x070006B8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_6B8); // d_course_skyscraper_packed_dl_570 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000570))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_570); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_skyscraper_packed_dl_10C8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x070010C8))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_10C8); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_skyscraper_packed_dl_258 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual((void*)0x07000258))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_skyscraper_packed_dl_258); } void Skyscraper::RenderCredits() {} diff --git a/src/engine/courses/Skyscraper.h b/src/engine/courses/Skyscraper.h index ed6592121..f7a323037 100644 --- a/src/engine/courses/Skyscraper.h +++ b/src/engine/courses/Skyscraper.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/skyscraper_vertices.h" - #include "assets/skyscraper_displaylists.h" - #include "assets/skyscraper_data.h" + #include "assets/models/tracks/skyscraper/skyscraper_vertices.h" + #include "assets/models/tracks/skyscraper/skyscraper_displaylists.h" + #include "assets/models/tracks/skyscraper/skyscraper_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; //virtual void InitClouds() override; virtual void InitCourseObjects() override; diff --git a/src/engine/courses/TestCourse.cpp b/src/engine/courses/TestCourse.cpp index f4a6710ac..c60198329 100644 --- a/src/engine/courses/TestCourse.cpp +++ b/src/engine/courses/TestCourse.cpp @@ -13,9 +13,9 @@ #include "engine/actors/Starship.h" #include "engine/objects/Object.h" #include "engine/objects/BombKart.h" -#include "assets/mario_raceway_data.h" -#include "assets/bowsers_castle_data.h" -#include "assets/bowsers_castle_displaylists.h" +#include "assets/models/tracks/mario_raceway/mario_raceway_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_displaylists.h" #include "engine/actors/Tree.h" #include "engine/actors/Cloud.h" #include "engine/vehicles/Train.h" @@ -45,7 +45,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -60,8 +60,6 @@ extern "C" { } TestCourse::TestCourse() { - this->gfxSize = 100; - this->textures = NULL; Props.Minimap.Texture = minimap_mario_raceway; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -139,6 +137,10 @@ TestCourse::TestCourse() { void TestCourse::Load() { Course::Load(mario_Plane_001_mesh_vtx_1, NULL); + if (gIsMirrorMode != 0) { + InvertTriangleWinding(mario_Plane_001_mesh); + } + generate_collision_mesh_with_defaults(mario_Plane_001_mesh); parse_course_displaylists((TrackSections*)test_course_addr); @@ -146,8 +148,7 @@ void TestCourse::Load() { Props.WaterLevel = gCourseMinY - 10.0f; } -void TestCourse::LoadTextures() { - dma_textures(gTextureTrees1, 0x0000035BU, 0x00000800U); // 0x03009000 +void TestCourse::UnLoad() { } void TestCourse::BeginPlay() { diff --git a/src/engine/courses/TestCourse.h b/src/engine/courses/TestCourse.h index d44e0a266..8bbb93634 100644 --- a/src/engine/courses/TestCourse.h +++ b/src/engine/courses/TestCourse.h @@ -4,14 +4,14 @@ #include "Course.h" extern "C" { - #include "mario_raceway_vertices.h" - #include "mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_vertices.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_displaylists.h" + #include "assets/models/tracks/mario_raceway/mario_raceway_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" #include "objects.h" #include "path_spawn_metadata.h" - #include "mario_raceway_data.h" extern const course_texture test_course_textures[]; } @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void WhatDoesThisDo(Player* player, int8_t playerId) override; virtual void WhatDoesThisDoAI(Player* player, int8_t playerId) override; diff --git a/src/engine/courses/ToadsTurnpike.cpp b/src/engine/courses/ToadsTurnpike.cpp index 69fcc7724..af0cb51d4 100644 --- a/src/engine/courses/ToadsTurnpike.cpp +++ b/src/engine/courses/ToadsTurnpike.cpp @@ -6,7 +6,8 @@ #include "ToadsTurnpike.h" #include "World.h" #include "engine/objects/BombKart.h" -#include "assets/toads_turnpike_data.h" +#include "assets/models/tracks/toads_turnpike/toads_turnpike_data.h" +#include "assets/other/tracks/toads_turnpike/toads_turnpike_data.h" #include "engine/actors/Finishline.h" #include "engine/vehicles/Bus.h" #include "engine/vehicles/Car.h" @@ -29,7 +30,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -37,39 +38,12 @@ extern "C" { #include "memory.h" #include "code_80086E70.h" #include "course.h" - extern const char *d_course_toads_turnpike_dl_list[]; + extern const char *d_course_toads_turnpike_dl_list[81]; extern s16 currentScreenSection; extern s8 gPlayerCount; } -const course_texture toads_turnpike_textures[] = { - { gTexture645134, 0x052C, 0x0800, 0x0 }, - { gTexture64FE68, 0x0258, 0x1000, 0x0 }, - { gTexture6607C0, 0x0105, 0x0800, 0x0 }, - { gTexture6608C8, 0x0106, 0x0800, 0x0 }, - { gTextureGrass11, 0x01F8, 0x0800, 0x0 }, - { gTextureSignNintendoRed0, 0x02A6, 0x1000, 0x0 }, - { gTextureSignNintendoRed1, 0x02F7, 0x1000, 0x0 }, - { gTexture671A88, 0x012D, 0x0800, 0x0 }, - { gTextureRoad2, 0x02AE, 0x1000, 0x0 }, - { gTextureRoad3, 0x0286, 0x1000, 0x0 }, - { gTextureRoad4, 0x0282, 0x1000, 0x0 }, - { gTextureRoadFinish0, 0x0338, 0x1000, 0x0 }, - { gTextureSignToadYellow, 0x0723, 0x1000, 0x0 }, - { gTextureSignToadGreen, 0x071F, 0x1000, 0x0 }, - { gTextureSignMergingLanes, 0x0118, 0x0800, 0x0 }, - { gTexture65127C, 0x01AB, 0x0800, 0x0 }, - { gTextureRoad5, 0x02B9, 0x1000, 0x0 }, - { gTextureSignToadRed, 0x0610, 0x1000, 0x0 }, - { gTexture668228, 0x0130, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - ToadsTurnpike::ToadsTurnpike() { - this->vtx = d_course_toads_turnpike_vertex; - this->gfx = d_course_toads_turnpike_packed_dls; - this->gfxSize = 3427; - Props.textures = toads_turnpike_textures; Props.Minimap.Texture = minimap_toads_turnpike; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -145,14 +119,20 @@ ToadsTurnpike::ToadsTurnpike() { Props.Skybox.FloorBottomLeft = {0, 0, 0}; Props.Skybox.FloorTopLeft = {209, 65, 23}; Props.Sequence = MusicSeq::MUSIC_SEQ_TOADS_TURNPIKE; - for (size_t i = 0; i < 80; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) d_course_toads_turnpike_dl_list[i], Props.textures); - } } void ToadsTurnpike::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(d_course_toads_turnpike_dl_list); i++) { + InvertTriangleWindingByName(d_course_toads_turnpike_dl_list[i]); + } + InvertTriangleWindingByName(d_course_toads_turnpike_packed_dl_0); + InvertTriangleWindingByName(d_course_toads_turnpike_packed_dl_68); + InvertTriangleWindingByName(d_course_toads_turnpike_packed_dl_D8); + } + D_801625EC = 43; D_801625F4 = 13; D_801625F0 = 4; @@ -163,7 +143,8 @@ void ToadsTurnpike::Load() { Props.WaterLevel = gCourseMinY - 10.0f; } -void ToadsTurnpike::LoadTextures() { +void ToadsTurnpike::UnLoad() { + RestoreTriangleWinding(); } void ToadsTurnpike::BeginPlay() { @@ -276,11 +257,11 @@ void ToadsTurnpike::Render(struct UnkStruct_800DC5EC* arg0) { gDPSetRenderMode(gDisplayListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2); gDPSetCombineMode(gDisplayListHead++, G_CC_DECALRGBA, G_CC_PASS2); // d_course_toads_turnpike_packed_dl_0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07000000)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_toads_turnpike_packed_dl_0); // d_course_toads_turnpike_packed_dl_68 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x07000068)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_toads_turnpike_packed_dl_68); // d_course_toads_turnpike_packed_dl_D8 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*)0x070000D8)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_toads_turnpike_packed_dl_D8); gSPClearGeometryMode(gDisplayListHead++, G_FOG); gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); } diff --git a/src/engine/courses/ToadsTurnpike.h b/src/engine/courses/ToadsTurnpike.h index de145849d..9c72a466e 100644 --- a/src/engine/courses/ToadsTurnpike.h +++ b/src/engine/courses/ToadsTurnpike.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/toads_turnpike_vertices.h" - #include "assets/toads_turnpike_displaylists.h" - #include "assets/toads_turnpike_data.h" + #include "assets/models/tracks/toads_turnpike/toads_turnpike_vertices.h" + #include "assets/models/tracks/toads_turnpike/toads_turnpike_displaylists.h" + #include "assets/models/tracks/toads_turnpike/toads_turnpike_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitClouds() override; virtual void UpdateClouds(s32, Camera*) override; diff --git a/src/engine/courses/WarioStadium.cpp b/src/engine/courses/WarioStadium.cpp index 6904ad45b..9f900b885 100644 --- a/src/engine/courses/WarioStadium.cpp +++ b/src/engine/courses/WarioStadium.cpp @@ -6,7 +6,8 @@ #include "WarioStadium.h" #include "World.h" #include "engine/objects/BombKart.h" -#include "assets/wario_stadium_data.h" +#include "assets/models/tracks/wario_stadium/wario_stadium_data.h" +#include "assets/other/tracks/wario_stadium/wario_stadium_data.h" #include "engine/actors/WarioSign.h" #include "engine/actors/Finishline.h" @@ -24,7 +25,7 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" @@ -33,39 +34,11 @@ extern "C" { #include "memory.h" #include "skybox_and_splitscreen.h" #include "course.h" -extern const char* wario_stadium_dls[]; +extern const char* wario_stadium_dls[108]; extern s16 currentScreenSection; } -const course_texture wario_stadium_textures[] = { - { gTexture67F15C, 0x02F1, 0x0800, 0x0 }, - { gTexture67F450, 0x0194, 0x0800, 0x0 }, - { gTextureSignWarioFace, 0x0825, 0x1000, 0x0 }, - { gTexture670AC8, 0x0FBF, 0x1000, 0x0 }, - { gTextureCheckerboardBlackWhite, 0x0107, 0x0800, 0x0 }, - { gTexture64C11C, 0x0695, 0x0800, 0x0 }, - { gTexture64C7B4, 0x046C, 0x0800, 0x0 }, - { gTexture668228, 0x0130, 0x0800, 0x0 }, - { gTexture668358, 0x01A0, 0x0800, 0x0 }, - { gTexture66AEB8, 0x0201, 0x0800, 0x0 }, - { gTexture677A40, 0x0275, 0x0800, 0x0 }, - { gTexture67E428, 0x0A81, 0x1000, 0x0 }, - { gTexture643A34, 0x0106, 0x0800, 0x0 }, - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, - { gTexture68272C, 0x01F9, 0x1000, 0x0 }, - { gTexture682928, 0x01F9, 0x1000, 0x0 }, - { gTexture682B24, 0x01F9, 0x1000, 0x0 }, - { gTexture682D20, 0x01F9, 0x1000, 0x0 }, - { gTexture682F1C, 0x01F9, 0x1000, 0x0 }, - { gTexture683118, 0x01F9, 0x1000, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - WarioStadium::WarioStadium() { - this->vtx = d_course_wario_stadium_vertex; - this->gfx = d_course_wario_stadium_packed_dls; - this->gfxSize = 5272; - Props.textures = wario_stadium_textures; Props.Minimap.Texture = minimap_wario_stadium; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -141,36 +114,44 @@ WarioStadium::WarioStadium() { Props.Skybox.FloorBottomLeft = { 0, 0, 0 }; Props.Skybox.FloorTopLeft = { 0, 0, 0 }; Props.Sequence = MusicSeq::MUSIC_SEQ_WARIO_STADIUM; - for (size_t i = 0; i < 108; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) wario_stadium_dls[i], Props.textures); - } } void WarioStadium::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(wario_stadium_dls); i++) { + InvertTriangleWindingByName(wario_stadium_dls[i]); + } + InvertTriangleWindingByName(d_course_wario_stadium_packed_dl_A0C8); + InvertTriangleWindingByName(d_course_wario_stadium_packed_dl_A228); + InvertTriangleWindingByName(d_course_wario_stadium_packed_dl_A88); + InvertTriangleWindingByName(d_course_wario_stadium_packed_dl_EC0); + } + parse_course_displaylists((TrackSections*) LOAD_ASSET_RAW(d_course_wario_stadium_addr)); func_80295C6C(); Props.WaterLevel = gCourseMinY - 10.0f; // d_course_wario_stadium_packed_dl_C50 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000C50), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_C50, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_BD8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000BD8), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_BD8, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_B60 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000B60), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_B60, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_AE8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000AE8), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_AE8, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_CC8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000CC8), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_CC8, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_D50 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000D50), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_D50, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_DD0 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000DD0), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_DD0, 100, 255, 255, 255); // d_course_wario_stadium_packed_dl_E48 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000E48), 100, 255, 255, 255); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_E48, 100, 255, 255, 255); } -void WarioStadium::LoadTextures() { +void WarioStadium::UnLoad() { + RestoreTriangleWinding(); } void WarioStadium::BeginPlay() { @@ -219,58 +200,41 @@ void WarioStadium::WhatDoesThisDo(Player* player, int8_t playerId) { void WarioStadium::WhatDoesThisDoAI(Player* player, int8_t playerId) { } -void WarioStadium::Jumbotron() { - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0x0000, G_TX_RENDERTILE, 0, - G_TX_NOMIRROR | G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 6, G_TX_NOLOD); - gDPSetTileSize(gDisplayListHead++, G_TX_RENDERTILE, 0, 0, 0x00FC, 0x007C); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x8800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x179B0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0x9800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x179F0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0xA800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x17A30), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0xB800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x17A70), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0xC800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x17AB0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); - gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gSegmentTable[5] + 0xD800); - gDPTileSync(gDisplayListHead++); - gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, - G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadSync(gDisplayListHead++); - gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 2047, 128); - gSPVertex(gDisplayListHead++, (uintptr_t) segment_vtx_to_virtual(0x17AF0), 4, 0); - gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0, 0, 2, 3, 0); +void WarioStadium::CopyJumbotron(s32 ulx, s32 uly, s16 portionToDraw, u16* source) { + // Add CVar if we want to expose a user toggle for only updating 1/6 of the jumbotron per frame + u8 updateWholeJumbo = true; + + if (portionToDraw == -1 || updateWholeJumbo) { + copy_framebuffer(ulx, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture68272C)); + copy_framebuffer(ulx + 64, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682928)); + copy_framebuffer(ulx, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682B24)); + copy_framebuffer(ulx + 64, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682D20)); + copy_framebuffer(ulx, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682F1C)); + copy_framebuffer(ulx + 64, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture683118)); + } else { + switch (portionToDraw) { + case 0: + copy_framebuffer(ulx, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture68272C)); + break; + case 1: + copy_framebuffer(ulx + 64, uly, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682928)); + break; + case 2: + copy_framebuffer(ulx, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682B24)); + break; + case 3: + copy_framebuffer(ulx + 64, uly + 32, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682D20)); + break; + case 4: + copy_framebuffer(ulx, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture682F1C)); + break; + case 5: + copy_framebuffer(ulx + 64, uly + 64, 64, 32, source, (u16*) LOAD_ASSET_RAW(gTexture683118)); + break; + default: + break; + } + } } void WarioStadium::Render(struct UnkStruct_800DC5EC* arg0) { @@ -283,32 +247,31 @@ void WarioStadium::Render(struct UnkStruct_800DC5EC* arg0) { // Invalidate Jumbotron textures so they update each frame // This could be more efficient if we exposed the non-opcode based invalidation to be called // inside copy_framebuffers_port - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x8800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0x9800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0xA800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0xB800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0xC800); - gSPInvalidateTexCache(gDisplayListHead++, gSegmentTable[5] + 0xD800); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture68272C); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682928); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682B24); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682D20); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture682F1C); + gSPInvalidateTexCache(gDisplayListHead++, (uintptr_t) gTexture683118); 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_wario_stadium_packed_dl_A0C8 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700A0C8)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_wario_stadium_packed_dl_A0C8); } gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATERGBA, G_CC_MODULATERGBA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - WarioStadium::Jumbotron(); render_course_segments(wario_stadium_dls, arg0); // d_course_wario_stadium_packed_dl_A228 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x0700A228)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_wario_stadium_packed_dl_A228); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2); gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); // d_course_wario_stadium_packed_dl_A88 - gSPDisplayList(gDisplayListHead++, (segmented_gfx_to_virtual(reinterpret_cast<void*>(0x07000A88)))); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_wario_stadium_packed_dl_A88); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); D_800DC5DC = 88; @@ -329,8 +292,7 @@ void WarioStadium::Render(struct UnkStruct_800DC5EC* arg0) { * The jumbo television screen used to be split into six sections to fit into the n64's texture size * restrictions It isn't split into six sections anymore */ - copy_jumbotron_fb_port(D_800DC5DC, D_800DC5E0, currentScreenSection, (u16*) gPortFramebuffers[prevFrame], - (u16*) (gSegmentTable[5] + 0x8800)); + CopyJumbotron(D_800DC5DC, D_800DC5E0, currentScreenSection, (u16*) gPortFramebuffers[prevFrame]); } } @@ -345,7 +307,6 @@ void WarioStadium::SomeCollisionThing(Player* player, Vec3f arg1, Vec3f arg2, Ve void WarioStadium::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCounter, uint16_t cameraRot, uint16_t playerDirection) { - Mat4 matrix; gDPPipeSync(gDisplayListHead++); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); @@ -356,15 +317,12 @@ void WarioStadium::DrawWater(struct UnkStruct_800DC5EC* screen, uint16_t pathCou gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); - mtxf_identity(matrix); - render_set_position(matrix, 0); - gSPClearGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetCombineMode(gDisplayListHead++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2); gDPSetPrimColor(gDisplayListHead++, 0, 0, 0xFF, 0xFF, 0x00, 0xFF); // d_course_wario_stadium_packed_dl_EC0 - gSPDisplayList(gDisplayListHead++, segmented_gfx_to_virtual((void*) 0x07000EC0)); + gSPDisplayList(gDisplayListHead++, (Gfx*) d_course_wario_stadium_packed_dl_EC0); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 1, 1, G_OFF); gSPSetGeometryMode(gDisplayListHead++, G_CULL_BACK); gDPSetAlphaCompare(gDisplayListHead++, G_AC_NONE); @@ -383,21 +341,21 @@ void WarioStadium::CreditsSpawnActors() { vec3f_set(position, -2622.0f, 79.0f, 739.0f); add_actor_to_empty_slot(position, rotation, velocity, ACTOR_WARIO_SIGN); // d_course_wario_stadium_packed_dl_C50 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000C50), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_C50, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_BD8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000BD8), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_BD8, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_B60 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000B60), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_B60, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_AE8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000AE8), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_AE8, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_CC8 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000CC8), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_CC8, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_D50 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000D50), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_D50, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_DD0 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000DD0), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_DD0, 0x64, 0xFF, 0xFF, 0xFF); // d_course_wario_stadium_packed_dl_E48 - find_vtx_and_set_colours(segmented_gfx_to_virtual((void*) 0x07000E48), 0x64, 0xFF, 0xFF, 0xFF); + find_vtx_and_set_colours((Gfx*) d_course_wario_stadium_packed_dl_E48, 0x64, 0xFF, 0xFF, 0xFF); } void WarioStadium::Destroy() { diff --git a/src/engine/courses/WarioStadium.h b/src/engine/courses/WarioStadium.h index 91f613c1b..eb8c253f4 100644 --- a/src/engine/courses/WarioStadium.h +++ b/src/engine/courses/WarioStadium.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { -#include "assets/wario_stadium_vertices.h" -#include "assets/wario_stadium_displaylists.h" -#include "assets/wario_stadium_data.h" +#include "assets/models/tracks/wario_stadium/wario_stadium_vertices.h" +#include "assets/models/tracks/wario_stadium/wario_stadium_displaylists.h" +#include "assets/models/tracks/wario_stadium/wario_stadium_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -16,7 +16,7 @@ extern const course_texture wario_stadium_textures[]; } class WarioStadium : public Course { - void Jumbotron(); + void CopyJumbotron(s32 ulx, s32 uly, s16 portionToDraw, u16* source); public: virtual ~WarioStadium() = default; // Virtual destructor for proper cleanup in derived classes @@ -27,7 +27,7 @@ class WarioStadium : public Course { // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitClouds() override; virtual void UpdateClouds(s32, Camera*) override; diff --git a/src/engine/courses/YoshiValley.cpp b/src/engine/courses/YoshiValley.cpp index 4576b53ca..c2506e568 100644 --- a/src/engine/courses/YoshiValley.cpp +++ b/src/engine/courses/YoshiValley.cpp @@ -10,8 +10,8 @@ #include "engine/objects/BombKart.h" #include "engine/objects/Hedgehog.h" #include "engine/objects/Flagpole.h" -#include "assets/yoshi_valley_data.h" -#include "assets/boo_frames.h" +#include "assets/models/tracks/yoshi_valley/yoshi_valley_data.h" +#include "assets/other/tracks/yoshi_valley/yoshi_valley_data.h" extern "C" { #include "main.h" @@ -27,40 +27,17 @@ extern "C" { #include "code_80005FD0.h" #include "spawn_players.h" #include "render_objects.h" - #include "assets/common_data.h" + #include "assets/models/common_data.h" #include "save.h" #include "replays.h" #include "actors.h" #include "collision.h" #include "memory.h" #include "course.h" - extern const char *d_course_yoshi_valley_dl_list[]; + extern const char *d_course_yoshi_valley_dl_list[124]; } -const course_texture yoshi_valley_textures[] = { - { gTexture66EBF0, 0x0146, 0x0800, 0x0 }, - { gTextureWoodBridgeSlats, 0x0DAB, 0x1000, 0x0 }, - { gTexture65E2EC, 0x02B0, 0x0800, 0x0 }, - { gTexture6846DC, 0x04EA, 0x0800, 0x0 }, - { gTextureFenceRope, 0x0540, 0x0800, 0x0 }, - { gTexture685108, 0x04D4, 0x0800, 0x0 }, - { gTexture64CC20, 0x0EC3, 0x1000, 0x0 }, - { gTextureGrass4, 0x05C3, 0x0800, 0x0 }, - { gTexture6775EC, 0x0233, 0x1000, 0x0 }, - { gTexture68E2D0, 0x087F, 0x0800, 0x0 }, - { gTextureCheckerboardBlackWhite, 0x0107, 0x0800, 0x0 }, - { gTexture643B3C, 0x0798, 0x0800, 0x0 }, - { gTextureSignWoodRedArrow, 0x04E1, 0x1000, 0x0 }, - { gTexture68DEC0, 0x0410, 0x0800, 0x0 }, - { 0x00000000, 0x0000, 0x0000, 0x0 }, -}; - YoshiValley::YoshiValley() { - this->vtx = d_course_yoshi_valley_vertex; - this->gfx = d_course_yoshi_valley_packed_dls; - this->gfxSize = 4140; - Props.textures = yoshi_valley_textures; - Props.Minimap.Texture = minimap_yoshi_valley; Props.Minimap.Width = ResourceGetTexWidthByName(Props.Minimap.Texture); Props.Minimap.Height = ResourceGetTexHeightByName(Props.Minimap.Texture); @@ -128,14 +105,17 @@ YoshiValley::YoshiValley() { Props.Skybox.FloorBottomLeft = {0, 0, 0}; Props.Skybox.FloorTopLeft = {95, 40, 15}; Props.Sequence = MusicSeq::MUSIC_SEQ_YOSHI_VALLEY; - for (size_t i = 0; i < 124; i++) { - replace_segmented_textures_with_o2r_textures((Gfx*) d_course_yoshi_valley_dl_list[i], Props.textures); - } } void YoshiValley::Load() { Course::Load(); + if (gIsMirrorMode != 0) { + for (size_t i = 0; i < ARRAY_COUNT(d_course_yoshi_valley_dl_list); i++) { + InvertTriangleWindingByName(d_course_yoshi_valley_dl_list[i]); + } + } + Lights1 lights4 = gdSPDefLights1(100, 100, 100, 255, 254, 254, 0, 0, 120); set_track_light_direction(&lights4, -0x38F0, 0x1C70, 1); parse_course_displaylists((TrackSections*)LOAD_ASSET_RAW(d_course_yoshi_valley_addr)); @@ -143,8 +123,8 @@ void YoshiValley::Load() { Props.WaterLevel = gCourseMinY - 10.0f; } -void YoshiValley::LoadTextures() { - dma_textures(gTextureTrees2, 0x000003E8U, 0x00000800U); // 0x03009000 +void YoshiValley::UnLoad() { + RestoreTriangleWinding(); } void YoshiValley::BeginPlay() { diff --git a/src/engine/courses/YoshiValley.h b/src/engine/courses/YoshiValley.h index b4ec8d442..88a306533 100644 --- a/src/engine/courses/YoshiValley.h +++ b/src/engine/courses/YoshiValley.h @@ -4,9 +4,9 @@ #include "Course.h" extern "C" { - #include "assets/yoshi_valley_vertices.h" - #include "assets/yoshi_valley_displaylists.h" - #include "assets/yoshi_valley_data.h" + #include "assets/models/tracks/yoshi_valley/yoshi_valley_vertices.h" + #include "assets/models/tracks/yoshi_valley/yoshi_valley_displaylists.h" + #include "assets/models/tracks/yoshi_valley/yoshi_valley_data.h" #include "course_offsets.h" #include "camera.h" #include "data/some_data.h" @@ -25,7 +25,7 @@ public: // virtual void Load(const char* courseVtx, // course_texture* textures, const char* displaylists, size_t dlSize); virtual void Load() override; - virtual void LoadTextures() override; + virtual void UnLoad() override; virtual void BeginPlay() override; virtual void InitCourseObjects() override; virtual void UpdateCourseObjects() override; diff --git a/src/engine/editor/Collision.cpp b/src/engine/editor/Collision.cpp index 026a79bd0..5a6d734ba 100644 --- a/src/engine/editor/Collision.cpp +++ b/src/engine/editor/Collision.cpp @@ -10,7 +10,7 @@ extern "C" { #include "main.h" -#include "other_textures.h" +#include "assets/textures/other_textures.h" } namespace Editor { diff --git a/src/engine/editor/SceneManager.cpp b/src/engine/editor/SceneManager.cpp index bd3414474..f34b18adb 100644 --- a/src/engine/editor/SceneManager.cpp +++ b/src/engine/editor/SceneManager.cpp @@ -33,7 +33,7 @@ namespace Editor { std::string SceneFile = ""; void SaveLevel() { - auto props = gWorldInstance.CurrentCourse->Props; + auto props = gWorldInstance.GetCurrentCourse()->Props; if ((CurrentArchive) && (!SceneFile.empty())) { nlohmann::json data; diff --git a/src/engine/mods/ModManager.cpp b/src/engine/mods/ModManager.cpp new file mode 100644 index 000000000..0d66b8e09 --- /dev/null +++ b/src/engine/mods/ModManager.cpp @@ -0,0 +1,284 @@ +#include "archive/Archive.h" +#include "ModMetadata.h" +#include "libultraship/src/resource/archive/FolderArchive.h" +#include "libultraship/src/resource/archive/O2rArchive.h" +#include "port/Engine.h" +#include "semver.hpp" +#include "utils/StringHelper.h" +#include <memory> +#include <optional> +#include <string> + +#include "ModManager.h" + +void CheckMK64O2RExists(); +void FindAndLoadMods(); +void PrintModInfo(); +void DetectCyclicDependencies(); +void DetectOutdatedDependencies(); +void SortModsByDependencies(); + +std::vector<std::tuple<ModMetadata, std::shared_ptr<Ship::Archive>>> Mods = {}; +const std::string main_path = Ship::Context::GetPathRelativeToAppDirectory("mk64.o2r"); +const std::string assets_path = Ship::Context::LocateFileAcrossAppDirs("spaghetti.o2r"); + +void InitModsSystem() { + CheckMK64O2RExists(); + + FindAndLoadMods(); + + PrintModInfo(); + + DetectCyclicDependencies(); + + DetectOutdatedDependencies(); + + SortModsByDependencies(); + + std::vector<std::shared_ptr<Ship::Archive>> loadedArchives; + loadedArchives.reserve(Mods.size()); + for (const auto& [_, archive] : Mods) { + if (archive == nullptr) { + continue; + } + loadedArchives.push_back(archive); + } + auto context = GameEngine::Instance->context; + auto resourceManager = context->GetResourceManager(); + auto archiveManager = resourceManager->GetArchiveManager(); + archiveManager->SetArchives(std::make_shared<std::vector<std::shared_ptr<Ship::Archive>>>(loadedArchives)); +} + +void UnloadMods() { + Mods.clear(); +} + +void GenerateAssetsMods() { + if (GameEngine::ShowYesNoBox("No O2R Files", "No O2R files found. Generate one now?") == IDYES) { + if (!GameEngine::GenAssetFile()) { + GameEngine::ShowMessage("Error", "An error occured, no O2R file was generated.\n\nExiting..."); + exit(1); + } + } else { + exit(1); + } +} + +std::vector<std::string> ListMods() { + std::vector<std::string> archiveFiles; + if (std::filesystem::exists(main_path)) { + archiveFiles.push_back(main_path); + } else { // should not happen, but just in case + GenerateAssetsMods(); + archiveFiles.push_back(main_path); + } + + if (std::filesystem::exists(assets_path)) { + archiveFiles.push_back(assets_path); + } + + const std::string mods_path = Ship::Context::GetPathRelativeToAppDirectory("mods"); + + if (std::filesystem::exists(mods_path) && std::filesystem::is_directory(mods_path)) { + for (const auto& p : std::filesystem::directory_iterator(mods_path)) { + auto ext = p.path().extension().string(); + if (StringHelper::IEquals(ext, ".zip") || StringHelper::IEquals(ext, ".o2r") || std::filesystem::is_directory(p.path())) { + archiveFiles.push_back(p.path().generic_string()); + } + } + } + + return archiveFiles; +} + +std::optional<std::vector<std::string>> CheckCyclicDependencies() { + auto list = std::vector<std::string>{}; + for (const auto& [metaA, _] : Mods) { + for (const auto& [metaB, _] : Mods) { + if (metaA.name != metaB.name) { + // If A depends on B and B depends on A, we have a cycle + if (metaA.dependencies.contains(metaB.name) && + metaB.dependencies.contains(metaA.name)) { + list.push_back(metaA.name + " <-> " + metaB.name); + } + } + } + } + if (!list.empty()) { + return list; + } + return std::nullopt; +} + +std::optional<std::vector<std::string>> CheckOutdatedDependencies(const ModMetadata& mod) { + auto list = std::vector<std::string>{}; + for (const auto& [depName, depVersion] : mod.dependencies) { + bool found = false; + for (const auto& [otherMeta, _] : Mods) { + if (otherMeta.name == depName) { + found = true; + auto range = depVersion.first; + if (!range.contains(otherMeta.version)) { + list.push_back(depName + " (required: " + depVersion.second + ", found: " + otherMeta.version.to_string() + ")"); + } + break; + } + } + if (!found) { + list.push_back(depName + " (required: " + depVersion.second + ", found: none)"); + } + } + if (!list.empty()) { + return list; + } + return std::nullopt; +} + +void SortModsByDependencies() { + // Core assets that should always be loaded first (at the bottom of the priority stack) + static const std::vector<std::string> coreAssets = { "mk64-assets", "extended-assets" }; + + std::sort(Mods.begin(), Mods.end(), + [](const std::tuple<ModMetadata, std::shared_ptr<Ship::Archive>>& a, + const std::tuple<ModMetadata, std::shared_ptr<Ship::Archive>>& b) { + const ModMetadata& metaA = std::get<0>(a); + const ModMetadata& metaB = std::get<0>(b); + + // Check if either mod is a core asset + auto itA = std::find(coreAssets.begin(), coreAssets.end(), metaA.name); + auto itB = std::find(coreAssets.begin(), coreAssets.end(), metaB.name); + bool isACoreAsset = itA != coreAssets.end(); + bool isBCoreAsset = itB != coreAssets.end(); + + // Core assets should come first (lower priority index) + if (isACoreAsset && !isBCoreAsset) { + return true; + } + if (!isACoreAsset && isBCoreAsset) { + return false; + } + // If both are core assets, sort by their order in coreAssets + if (isACoreAsset && isBCoreAsset) { + return itA < itB; + } + + // If A depends on B, A should come after B + if (metaA.dependencies.contains(metaB.name)) { + return false; + } + // If B depends on A, B should come after A + if (metaB.dependencies.contains(metaA.name)) { + return true; + } + // Otherwise, maintain original order + return false; + }); +} + +void AddModMetadata(const ModMetadata& metadata, const std::shared_ptr<Ship::Archive>& archive) { + Mods.push_back(std::make_tuple(metadata, archive)); +} + +void AddCoreDependencies() { + ModMetadata meta; + meta.name = "spaghettikart-core"; + semver::parse(SPAGHETTI_VERSION, meta.version); + + semver::range_set<int, int, int> mk64Ver; + semver::parse("1.0.0-alpha1", mk64Ver); + semver::range_set<int, int, int> assetsVer; + semver::parse("1.0.0-alpha1", assetsVer); + meta.dependencies = { + {"mk64-assets", {mk64Ver, "1.0.0-alpha1"}}, + {"extended-assets", {assetsVer, "1.0.0-alpha1"}}, + }; + AddModMetadata(meta, nullptr); +} + +void CheckMK64O2RExists() { + if (!std::filesystem::exists(main_path)) { + GenerateAssetsMods(); + } +} + +void FindAndLoadMods() { + Mods.clear(); + AddCoreDependencies(); + auto list = ListMods(); + for (const auto& path : list) { + const std::string extension = std::filesystem::path(path).extension().string(); + std::shared_ptr<Ship::Archive> archive = nullptr; + if (StringHelper::IEquals(extension, ".o2r") || StringHelper::IEquals(extension, ".zip")) { + archive = dynamic_pointer_cast<Ship::Archive>(std::make_shared<Ship::O2rArchive>(path)); + } else if (StringHelper::IEquals(extension, "") && std::filesystem::is_directory(path)) { + archive = dynamic_pointer_cast<Ship::Archive>(std::make_shared<Ship::FolderArchive>(path)); + } else if (StringHelper::IEquals(extension, ".disabled")) { + // Skip disabled mods + continue; + } else { + SPDLOG_WARN("The file {} has an unrecognized extension ({}), ignoring it.", path, extension); + continue; + } + + int nb_unknown_files = 0; + archive->Load(); + ModMetadata metadata; + auto mods_file = archive->LoadFile("mods.toml"); + if (mods_file != nullptr) { + metadata = ModMetadata::LoadFromTOML(std::string(mods_file->Buffer->data(), mods_file->Buffer->size())); + SPDLOG_INFO("Loaded mod: {}\n{}", metadata.name, metadata.ToString()); + } else { + const std::string msg = "The archive at path " + path + + " is missing a mods.toml file. The Mod are likely incompatible.\n\n" + "Do you want to continue loading the mods?"; + if (GameEngine::ShowYesNoBox("Missing mods.toml", msg.c_str()) == IDNO) { + exit(1); + } + metadata.name = std::filesystem::path(path).stem().string(); + semver::parse("0.0.0", metadata.version); + SPDLOG_WARN("The mod at path {} is missing a mods.toml file. Using default metadata:\n{}", path, metadata.ToString()); + } + + AddModMetadata(metadata, archive); + } +} + +void DetectCyclicDependencies() { + if (auto cyclicDeps = CheckCyclicDependencies(); cyclicDeps.has_value()) { + std::string msg = "Cyclic dependencies detected between the following mods:\n"; + for (const auto& cycle : cyclicDeps.value()) { + msg += " - " + cycle + "\n"; + } + msg += "\nPlease resolve these cyclic dependencies before continuing.\n"; + GameEngine::ShowMessage("Cyclic Dependency Issues", msg.c_str()); + exit(1); + } +} + +void DetectOutdatedDependencies() { + bool exitDueToErrors = false; + std::string allDepIssues; + + for (const auto& [meta, _] : Mods) { + if (auto toUpdate = CheckOutdatedDependencies(meta); toUpdate.has_value()) { + exitDueToErrors = true; + allDepIssues += "The mod \"" + meta.name + "\" has the following missing or outdated dependencies:\n"; + for (const auto& dep : toUpdate.value()) { + allDepIssues += " - " + dep + "\n"; + } + } + } + + if (exitDueToErrors) { + allDepIssues += "\nPlease resolve these dependency issues before continuing.\n"; + GameEngine::ShowMessage("Dependency Issues", allDepIssues.c_str()); + exit(1); + } +} + +void PrintModInfo() { + SPDLOG_INFO("[ModManager] Detected Mods:"); + for (const auto& [meta, _] : Mods) { + SPDLOG_INFO(" - {} v{}", meta.name, meta.version.to_string()); + } +} diff --git a/src/engine/mods/ModManager.h b/src/engine/mods/ModManager.h new file mode 100644 index 000000000..af0baa2e9 --- /dev/null +++ b/src/engine/mods/ModManager.h @@ -0,0 +1,4 @@ +#pragma once + +void InitModsSystem(); +void UnloadMods();
\ No newline at end of file diff --git a/src/engine/mods/ModMetadata.cpp b/src/engine/mods/ModMetadata.cpp new file mode 100644 index 000000000..9d29e35a4 --- /dev/null +++ b/src/engine/mods/ModMetadata.cpp @@ -0,0 +1,12 @@ +#include "ModMetadata.h" +#include <spdlog/spdlog.h> + +std::string ModMetadata::ToString() const { + std::string result = "Mod Name: " + name + "\n"; + result += "Version: " + version.to_string() + "\n"; + result += "Dependencies:\n"; + for (const auto& [depName, depVersion] : dependencies) { + result.append(" - ").append(depName).append(": ").append(depVersion.second).append("\n"); + } + return result; +}
\ No newline at end of file diff --git a/src/engine/mods/ModMetadata.h b/src/engine/mods/ModMetadata.h new file mode 100644 index 000000000..ed66ebf3d --- /dev/null +++ b/src/engine/mods/ModMetadata.h @@ -0,0 +1,48 @@ +#pragma once + +#ifdef __cplusplus +#include "spdlog/spdlog.h" +#include <string> +#include <map> +#include <toml++/toml.hpp> +#include "semver.hpp" + +struct ModMetadata { + std::string name; + semver::version<int, int, int> version; + std::map<std::string, std::pair<semver::range_set<int, int, int>, std::string>> dependencies; + + ModMetadata() {} + static ModMetadata LoadFromTOML(const std::string& tomlContent) { + ModMetadata metadata; + try { + auto table = toml::parse(tomlContent); + auto mods_property = table["mod"]; + + if (auto nameValue = mods_property["name"].value<std::string>()) { + metadata.name = *nameValue; + } + + if (auto versionValue = mods_property["version"].value<std::string>()) { + semver::parse(*versionValue, metadata.version); + } + + if (auto *depsTable = table["dependencies"].as_table()) { + for (const auto& [key, value] : *depsTable) { + if (auto depVersion = value.value<std::string>()) { + semver::range_set<int, int, int> parsedVersion; + semver::parse(*depVersion, parsedVersion); + metadata.dependencies[std::string(key)] = std::make_pair(parsedVersion, *depVersion); + } + } + } + } catch (const toml::parse_error& err) { + SPDLOG_ERROR("Failed to parse mods.toml: {}", err.what()); + } + + return metadata; + } + + std::string ToString() const; +}; +#endif
\ No newline at end of file diff --git a/src/engine/objects/Bat.cpp b/src/engine/objects/Bat.cpp index 25c28c751..2b6f01230 100644 --- a/src/engine/objects/Bat.cpp +++ b/src/engine/objects/Bat.cpp @@ -6,8 +6,9 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/banshee_boardwalk_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/textures/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/BombKart.cpp b/src/engine/objects/BombKart.cpp index c465aea43..4ba5ff843 100644 --- a/src/engine/objects/BombKart.cpp +++ b/src/engine/objects/BombKart.cpp @@ -24,6 +24,7 @@ extern "C" { #include "code_80005FD0.h" #include "math_util_2.h" #include "collision.h" +#include <assets/models/common_data.h> extern s8 gPlayerCount; } diff --git a/src/engine/objects/Boos.cpp b/src/engine/objects/Boos.cpp index a22b0edd0..20b16355e 100644 --- a/src/engine/objects/Boos.cpp +++ b/src/engine/objects/Boos.cpp @@ -6,10 +6,11 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/banshee_boardwalk_data.h" -#include "assets/common_data.h" -#include "assets/boo_frames.h" -#include "assets/other_textures.h" +#include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/textures/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/models/common_data.h" +#include "assets/textures/boo_frames.h" +#include "assets/textures/other_textures.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/ChainChomp.cpp b/src/engine/objects/ChainChomp.cpp index 9f750831b..b9c59606d 100644 --- a/src/engine/objects/ChainChomp.cpp +++ b/src/engine/objects/ChainChomp.cpp @@ -4,8 +4,10 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/rainbow_road_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/rainbow_road/rainbow_road_data.h" +#include "assets/textures/tracks/rainbow_road/rainbow_road_data.h" +#include "assets/other/tracks/rainbow_road/rainbow_road_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/CheepCheep.cpp b/src/engine/objects/CheepCheep.cpp index a2432f57e..f52af62a1 100644 --- a/src/engine/objects/CheepCheep.cpp +++ b/src/engine/objects/CheepCheep.cpp @@ -1,8 +1,8 @@ #include "CheepCheep.h" #include "port/Game.h" -#include "assets/banshee_boardwalk_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/models/common_data.h" extern "C" { diff --git a/src/engine/objects/Crab.cpp b/src/engine/objects/Crab.cpp index 9e4e4687b..c24c07221 100644 --- a/src/engine/objects/Crab.cpp +++ b/src/engine/objects/Crab.cpp @@ -21,7 +21,9 @@ extern "C" { #include "code_80005FD0.h" #include "some_data.h" #include "ceremony_and_credits.h" -#include "assets/koopa_troopa_beach_data.h" +#include "assets/models/tracks/koopa_troopa_beach/koopa_troopa_beach_data.h" +#include "assets/textures/tracks/koopa_troopa_beach/koopa_troopa_beach_data.h" +#include "assets/models/common_data.h" } size_t OCrab::_count = 0; diff --git a/src/engine/objects/Flagpole.cpp b/src/engine/objects/Flagpole.cpp index 58581e3c9..ec7588720 100644 --- a/src/engine/objects/Flagpole.cpp +++ b/src/engine/objects/Flagpole.cpp @@ -5,8 +5,8 @@ extern "C" { #include "code_800029B0.h" #include "render_objects.h" #include "update_objects.h" -#include "assets/yoshi_valley_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/yoshi_valley/yoshi_valley_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/GrandPrixBalloons.cpp b/src/engine/objects/GrandPrixBalloons.cpp index 05ba880c6..2180f85c0 100644 --- a/src/engine/objects/GrandPrixBalloons.cpp +++ b/src/engine/objects/GrandPrixBalloons.cpp @@ -1,8 +1,9 @@ #include "GrandPrixBalloons.h" #include "port/Game.h" -#include "assets/other_textures.h" -#include "assets/common_data.h" +#include "assets/textures/other_textures.h" +#include "assets/textures/some_data.h" +#include "assets/models/common_data.h" #include "port/interpolation/FrameInterpolation.h" extern "C" { diff --git a/src/engine/objects/Hedgehog.cpp b/src/engine/objects/Hedgehog.cpp index a36853a91..a166cd348 100644 --- a/src/engine/objects/Hedgehog.cpp +++ b/src/engine/objects/Hedgehog.cpp @@ -6,8 +6,9 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/yoshi_valley_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/yoshi_valley/yoshi_valley_data.h" +#include "assets/textures/tracks/yoshi_valley/yoshi_valley_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/HotAirBalloon.cpp b/src/engine/objects/HotAirBalloon.cpp index b30c8e3ed..74de17230 100644 --- a/src/engine/objects/HotAirBalloon.cpp +++ b/src/engine/objects/HotAirBalloon.cpp @@ -5,8 +5,8 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/luigi_raceway_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/luigi_raceway/luigi_raceway_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/Lakitu.cpp b/src/engine/objects/Lakitu.cpp index 392fe9100..d4c4b18c7 100644 --- a/src/engine/objects/Lakitu.cpp +++ b/src/engine/objects/Lakitu.cpp @@ -24,7 +24,7 @@ extern "C" { #include "defines.h" #include "code_80005FD0.h" #include "collision.h" -#include "assets/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" #include "ceremony_and_credits.h" #include "objects.h" #include "update_objects.h" @@ -34,6 +34,7 @@ extern "C" { #include "race_logic.h" #include "effects.h" #include "memory.h" +#include <assets/models/common_data.h> extern s8 gPlayerCount; } diff --git a/src/engine/objects/Mole.cpp b/src/engine/objects/Mole.cpp index 9bc470f90..92d357873 100644 --- a/src/engine/objects/Mole.cpp +++ b/src/engine/objects/Mole.cpp @@ -17,9 +17,11 @@ extern "C" { #include "code_80005FD0.h" #include "some_data.h" #include "ceremony_and_credits.h" -#include "assets/moo_moo_farm_data.h" +#include "assets/models/tracks/moo_moo_farm/moo_moo_farm_data.h" +#include "assets/textures/tracks/moo_moo_farm/moo_moo_farm_data.h" #include "sounds.h" #include "external.h" +#include <assets/models/common_data.h> } #include "port/interpolation/FrameInterpolation.h" diff --git a/src/engine/objects/Penguin.cpp b/src/engine/objects/Penguin.cpp index 262446abb..27c009489 100644 --- a/src/engine/objects/Penguin.cpp +++ b/src/engine/objects/Penguin.cpp @@ -23,7 +23,7 @@ extern "C" { #include "code_80005FD0.h" #include "math_util_2.h" #include "collision.h" -#include "assets/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" #include "ceremony_and_credits.h" #include "objects.h" #include "update_objects.h" diff --git a/src/engine/objects/Podium.cpp b/src/engine/objects/Podium.cpp index d5e09d799..621ba91ab 100644 --- a/src/engine/objects/Podium.cpp +++ b/src/engine/objects/Podium.cpp @@ -1,5 +1,5 @@ #include "Podium.h" -#include "assets/ceremony_data.h" +#include "assets/models/ceremony_data.h" extern "C" { #include "main.h" @@ -10,7 +10,7 @@ extern "C" { #include "podium_ceremony_actors.h" #include "math_util.h" #include "math_util_2.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" #include "some_data.h" #include "code_80091440.h" #include "code_80086E70.h" diff --git a/src/engine/objects/Seagull.cpp b/src/engine/objects/Seagull.cpp index 61a7f39ca..8eff07740 100644 --- a/src/engine/objects/Seagull.cpp +++ b/src/engine/objects/Seagull.cpp @@ -21,6 +21,7 @@ extern "C" { #include "code_80005FD0.h" #include "some_data.h" #include "ceremony_and_credits.h" +#include "assets/models/common_data.h" extern SplineData D_800E6034; extern SplineData D_800E60F0; extern SplineData D_800E61B4; diff --git a/src/engine/objects/Snowman.cpp b/src/engine/objects/Snowman.cpp index dd98e2df0..6e6335f2c 100644 --- a/src/engine/objects/Snowman.cpp +++ b/src/engine/objects/Snowman.cpp @@ -4,8 +4,9 @@ extern "C" { #include "render_objects.h" #include "update_objects.h" -#include "assets/frappe_snowland_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/frappe_snowland/frappe_snowland_data.h" +#include "assets/textures/tracks/frappe_snowland/frappe_snowland_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/Thwomp.cpp b/src/engine/objects/Thwomp.cpp index b597f26ba..324f32cfb 100644 --- a/src/engine/objects/Thwomp.cpp +++ b/src/engine/objects/Thwomp.cpp @@ -26,12 +26,14 @@ extern "C" { #include "code_80005FD0.h" #include "math_util_2.h" #include "collision.h" -#include "assets/bowsers_castle_data.h" +#include "assets/models/tracks/bowsers_castle/bowsers_castle_data.h" +#include "assets/textures/tracks/bowsers_castle/bowsers_castle_data.h" #include "ceremony_and_credits.h" #include "objects.h" #include "update_objects.h" #include "render_objects.h" #include "some_data.h" +#include "assets/models/common_data.h" extern s8 gPlayerCount; } @@ -758,7 +760,7 @@ void OThwomp::Draw(s32 cameraId) { void OThwomp::DrawModel(s32 objectIndex) { if ((gObjectList[objectIndex].state >= 2) && (func_80072354(objectIndex, 0x00000040) != 0)) { - FrameInterpolation_RecordOpenChild("Thwomp_Main", (uintptr_t) TAG_THWOMP(this)); + FrameInterpolation_RecordOpenChild("Thwomp_Main", TAG_THWOMP(this)); func_8004A7AC(objectIndex, 1.75f); rsp_set_matrix_transformation(gObjectList[objectIndex].pos, gObjectList[objectIndex].orientation, gObjectList[objectIndex].sizeScaling); diff --git a/src/engine/objects/TrashBin.cpp b/src/engine/objects/TrashBin.cpp index 871151b8f..954b9491a 100644 --- a/src/engine/objects/TrashBin.cpp +++ b/src/engine/objects/TrashBin.cpp @@ -10,8 +10,8 @@ extern "C" { #include "code_800029B0.h" #include "render_objects.h" #include "update_objects.h" -#include "assets/banshee_boardwalk_data.h" -#include "assets/common_data.h" +#include "assets/models/tracks/banshee_boardwalk/banshee_boardwalk_data.h" +#include "assets/models/common_data.h" #include "math_util.h" #include "math_util_2.h" #include "code_80086E70.h" diff --git a/src/engine/objects/Trophy.cpp b/src/engine/objects/Trophy.cpp index ba5435953..865ccc822 100644 --- a/src/engine/objects/Trophy.cpp +++ b/src/engine/objects/Trophy.cpp @@ -1,6 +1,6 @@ #include "Trophy.h" -#include "assets/common_data.h" -#include "assets/data_segment2.h" +#include "assets/models/common_data.h" +#include "assets/models/data_segment2.h" #include "port/Game.h" extern "C" { @@ -8,7 +8,7 @@ extern "C" { #include "defines.h" #include "update_objects.h" #include "code_80057C60.h" -#include "assets/ceremony_data.h" +#include "assets/models/ceremony_data.h" #include "podium_ceremony_actors.h" #include "engine/particles/StarEmitter.h" #include "math_util.h" diff --git a/src/engine/particles/StarEmitter.cpp b/src/engine/particles/StarEmitter.cpp index cd1b60b25..fafb7a007 100644 --- a/src/engine/particles/StarEmitter.cpp +++ b/src/engine/particles/StarEmitter.cpp @@ -5,7 +5,7 @@ extern "C" { #include "render_objects.h" -#include "common_data.h" +#include "assets/models/common_data.h" #include "code_80057C60.h" #include "update_objects.h" #include "code_80086E70.h" diff --git a/src/engine/vehicles/Train.cpp b/src/engine/vehicles/Train.cpp index 6e0738033..23724fad6 100644 --- a/src/engine/vehicles/Train.cpp +++ b/src/engine/vehicles/Train.cpp @@ -23,7 +23,7 @@ extern "C" { #include "code_80057C60.h" #include "math_util_2.h" #include "render_objects.h" -#include "assets/common_data.h" +#include "assets/models/common_data.h" // #include "common_structs.h" } |
