diff --git a/asm/non_matchings/render_objects/func_8004F168.s b/asm/non_matchings/render_objects/func_8004F168.s index 9e763f137..8f51fc84e 100644 --- a/asm/non_matchings/render_objects/func_8004F168.s +++ b/asm/non_matchings/render_objects/func_8004F168.s @@ -26,8 +26,8 @@ glabel func_8004F168 /* 04FDC8 8004F1C8 46002082 */ mul.s $f2, $f4, $f0 /* 04FDCC 8004F1CC 01284821 */ addu $t1, $t1, $t0 /* 04FDD0 8004F1D0 3C0A8019 */ lui $t2, %hi(D_8018D2F0) # $t2, 0x8019 -/* 04FDD4 8004F1D4 3C0C8019 */ lui $t4, %hi(D_8018D2B0) # $t4, 0x8019 -/* 04FDD8 8004F1D8 858CD2B0 */ lh $t4, %lo(D_8018D2B0)($t4) +/* 04FDD4 8004F1D4 3C0C8019 */ lui $t4, %hi(gMinimapWidth) # $t4, 0x8019 +/* 04FDD8 8004F1D8 858CD2B0 */ lh $t4, %lo(gMinimapWidth)($t4) /* 04FDDC 8004F1DC 854AD2F0 */ lh $t2, %lo(D_8018D2F0)($t2) /* 04FDE0 8004F1E0 8529D2C0 */ lh $t1, %lo(D_8018D2C0)($t1) # -0x2d40($t1) /* 04FDE4 8004F1E4 4600120D */ trunc.w.s $f8, $f2 @@ -50,9 +50,9 @@ glabel func_8004F168 /* 04FE24 8004F224 00084C00 */ sll $t1, $t0, 0x10 /* 04FE28 8004F228 85ADD2D8 */ lh $t5, %lo(D_8018D2D8)($t5) # -0x2d28($t5) /* 04FE2C 8004F22C 85CED2F8 */ lh $t6, %lo(D_8018D2F8)($t6) -/* 04FE30 8004F230 3C198019 */ lui $t9, %hi(D_8018D2B8) # $t9, 0x8019 +/* 04FE30 8004F230 3C198019 */ lui $t9, %hi(gMinimapHeight) # $t9, 0x8019 /* 04FE34 8004F234 4600628D */ trunc.w.s $f10, $f12 -/* 04FE38 8004F238 8739D2B8 */ lh $t9, %lo(D_8018D2B8)($t9) +/* 04FE38 8004F238 8739D2B8 */ lh $t9, %lo(gMinimapHeight)($t9) /* 04FE3C 8004F23C 00095403 */ sra $t2, $t1, 0x10 /* 04FE40 8004F240 030A2021 */ addu $a0, $t8, $t2 /* 04FE44 8004F244 3C188019 */ lui $t8, %hi(D_8018D2E8) # $t8, 0x8019 diff --git a/src/code_80057C60.c b/src/code_80057C60.c index d9be361fa..a17b52bf5 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -1037,14 +1037,14 @@ void func_800591B4(void) { if (D_80165800[0] != 0) { func_8004EE54(0); if (gModeSelection != BATTLE) { - func_8004F020(0); + set_minimap_finishline_position(0); } func_8004F3E4(0); } if ((gScreenModeSelection == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL) && (D_80165800[1] != 0)) { func_8004EE54(1); if (gModeSelection != BATTLE) { - func_8004F020(1); + set_minimap_finishline_position(1); } func_8004F3E4(1); } @@ -1122,7 +1122,8 @@ void render_hud_2p_vertical_player_two(void) { void render_hud_lap_3p_4p(s32 playerId) { if (gModeSelection != BATTLE) { if (D_801657F8 && gIsHUDVisible) { - draw_hud_2d_texture_32x8(playerHUD[playerId].lapX, playerHUD[playerId].lapY, (u8*) common_texture_hud_lap); + //draw_hud_2d_texture_32x8(playerHUD[playerId].lapX, playerHUD[playerId].lapY, (u8*) common_texture_hud_lap); + draw_hud_2d_texture(playerHUD[playerId].lapX, playerHUD[playerId].lapY, 32, 8, common_texture_hud_lap); draw_lap_count(playerHUD[playerId].lapX - 12, playerHUD[playerId].lapY + 4, playerHUD[playerId].alsoLapCount); } diff --git a/src/code_80057C60.h b/src/code_80057C60.h index 4b6ed7613..483d7cbb2 100644 --- a/src/code_80057C60.h +++ b/src/code_80057C60.h @@ -546,17 +546,15 @@ extern u8* D_8018D248[]; extern f32 D_8018D2A0; extern s32 D_8018D2A4; extern s32 D_8018D2AC; -extern s16 D_8018D2B0; +extern s16 gMinimapWidth; extern s32 D_8018D2B4; -extern s16 D_8018D2B8; +extern s16 gMinimapHeight; extern s32 D_8018D2BC; extern s16 D_8018D2C0[]; extern s32 D_8018D2C8[]; extern s16 D_8018D2D8[]; extern s16 D_8018D2E0; extern s16 D_8018D2E8; -extern s16 D_8018D2F0; -extern s16 D_8018D2F8; extern u16 D_8018D300; extern u16 D_8018D308; extern u16 D_8018D310; diff --git a/src/code_80057C60_var.c b/src/code_80057C60_var.c index d0e929ee6..43340892c 100644 --- a/src/code_80057C60_var.c +++ b/src/code_80057C60_var.c @@ -111,9 +111,9 @@ f32 D_8018D2A0; s32 D_8018D2A4; UNUSED s32 D_8018D2A8; s32 D_8018D2AC; -s16 D_8018D2B0; +s16 gMinimapWidth; s32 D_8018D2B4; -s16 D_8018D2B8; +s16 gMinimapHeight; s32 D_8018D2BC; s16 D_8018D2C0[4]; s32 D_8018D2C8[4]; @@ -122,9 +122,7 @@ s16 D_8018D2E0; UNUSED s32 D_8018D2E4; s16 D_8018D2E8; UNUSED s32 D_8018D2EC; -s16 D_8018D2F0; UNUSED s32 D_8018D2F4; -s16 D_8018D2F8; UNUSED s32 D_8018D2FC; u16 D_8018D300; UNUSED s32 D_8018D304; diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 452536de9..28d97ed54 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -165,10 +165,10 @@ void init_item_window(s32 objectIndex) { void func_8006EEE8(s32 courseId) { D_8018D240 = (uintptr_t) CourseManager_GetProps()->MinimapTexture; - // This is incredibly dumb. D_800E5548 ought to be something more like - // `u16 D_800E5548[][2]` but that doesn't match for some insane reason - D_8018D2B0 = CourseManager_GetProps()->D_800E5548[0]; // D_800E5548[courseId * 2]; - D_8018D2B8 = CourseManager_GetProps()->D_800E5548[1]; // D_800E5548[courseId * 2 + 1]; + // This is incredibly dumb. MinimapDimensions ought to be something more like + // `u16 MinimapDimensions[][2]` but that doesn't match for some insane reason + gMinimapWidth = CourseManager_GetProps()->MinimapDimensions.X; // MinimapDimensions[courseId * 2]; + gMinimapHeight = CourseManager_GetProps()->MinimapDimensions.Z; // MinimapDimensions[courseId * 2 + 1]; } void func_8006EF60(void) { @@ -344,7 +344,7 @@ void func_8006F008(void) { // D_8018D2E8 = 31; } if (gIsMirrorMode != 0) { - D_8018D2E0 = D_8018D2B0 - D_8018D2E0; + D_8018D2E0 = gMinimapWidth - D_8018D2E0; } if (gPlayerCount == 4) { D_8018D2C0[0] = 160; @@ -571,8 +571,6 @@ void func_8006FA94(void) { gHUDDisable = D_8018D214; D_801657AE = gHUDDisable; D_8018D20C = 0; - D_8018D2F8 = 0; - D_8018D2F0 = D_8018D2F8; D_8018D320 = 3; D_8018D2AC = 0; D_8018D2BC = 0; diff --git a/src/code_8006E9C0.h b/src/code_8006E9C0.h index ad8c2f977..e5e9bc8d3 100644 --- a/src/code_8006E9C0.h +++ b/src/code_8006E9C0.h @@ -32,7 +32,6 @@ void init_hud_three_four_player(void); void init_hud_two_player_horizontal(void); extern s16 D_800E5520[]; -extern s16 D_800E5548[]; extern u8* gCourseOutlineTextures[0x14]; // 800e54d0 #endif diff --git a/src/data/some_data.c b/src/data/some_data.c index 1a2acd086..cb8d1f3d3 100644 --- a/src/data/some_data.c +++ b/src/data/some_data.c @@ -206,7 +206,7 @@ s16 D_800E5520[] = { 0x1000, 0x0c00, 0x0800, 0x0c00, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, }; -s16 D_800E5548[] = { +s16 minimapDimensions[] = { 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, 0x0060, 0x0040, 0x0040, 0x0080, 0x0040, 0x0040, 0x0060, 0x0040, 0x0040, 0x0040, 0x0060, 0x0040, 0x0040, 0x0040, 0x0040, 0x0040, diff --git a/src/data/some_data.h b/src/data/some_data.h index 6ee5272b0..c0651aa2b 100644 --- a/src/data/some_data.h +++ b/src/data/some_data.h @@ -25,7 +25,7 @@ extern Vtx gBalloonVertexPlane1[]; extern Vtx gBalloonVertexPlane2[]; extern u8* gCourseOutlineTextures[]; extern s16 D_800E5520[]; -extern s16 D_800E5548[]; +extern s16 minimapDimensions[]; extern u16 D_800E55A0[]; extern u16 D_800E55B0[]; extern u8 D_800E55D0[][3]; diff --git a/src/engine/CoreMath.h b/src/engine/CoreMath.h new file mode 100644 index 000000000..551d8083b --- /dev/null +++ b/src/engine/CoreMath.h @@ -0,0 +1,99 @@ +#pragma once + +#include + +/** + * @file CoreMath.h + * + * Basic vector structs for manipulating 2D and 3D coordinates + * + */ + + +struct FVector { + float x, y, z; + + FVector& operator=(const FVector& other) { + x = other.x; + y = other.y; + z = other.z; + return *this; + } +}; + +/** + * For providing X and Z when you do not need Y + * Some actors set themselves on the surface automatically + * which means it does not use a Y coordinate + * The train follows a set Y value. The hedgehog's patrolPoint only uses X and Z. + */ +struct FVector2D { + float x, z; + + FVector2D& operator=(const FVector2D& other) { + x = other.x; + z = other.z; + return *this; + } +}; + +// Sets integer X Z coordinates +struct IVector2D { + int32_t X, Z; + + IVector2D() : X(0), Z(0) {} // Default constructor + + IVector2D(int32_t x, int32_t z) : X(x), Z(z) {} // Constructor to initialize with values + + + IVector2D& operator=(const IVector2D& other) { + X = other.X; + Z = other.Z; + return *this; + } +}; + +struct FRotation { + float pitch, yaw, roll; + + FRotation& operator=(const FRotation& other) { + pitch = other.pitch; + yaw = other.yaw; + roll = other.roll; + return *this; + } +}; + +/** + * For selecting a section of a course path + * Usage: IPathSpan(point1, point2) --> IPathSpan(40, 65) + */ +struct IPathSpan { + int Start, End; + + // Default Constructor + IPathSpan() : Start(0), End(0) {} + + // Parameterized Constructor + IPathSpan(int InStart, int InEnd) + : Start(InStart), End(InEnd) {} + + // Copy Assignment Operator + IPathSpan& operator=(const IPathSpan& Other) { + if (this != &Other) { // Avoid self-assignment + Start = Other.Start; + End = Other.End; + } + return *this; + } + + // Equality Operator + bool operator==(const IPathSpan& Other) const { + return Start == Other.Start && End == Other.End; + } + + // Inequality Operator + bool operator!=(const IPathSpan& Other) const { + return !(*this == Other); + } +}; diff --git a/src/engine/Engine.h b/src/engine/Engine.h index 45fa3a61d..98e9a99fc 100644 --- a/src/engine/Engine.h +++ b/src/engine/Engine.h @@ -20,6 +20,11 @@ typedef struct { RGB8 FloorTopLeft; } SkyboxColours; +typedef struct { + int32_t X; + int32_t Z; +} IVector2D_C; + typedef struct { const char* Id; const char* Name; @@ -28,7 +33,7 @@ typedef struct { const char* AIBehaviour; const char* MinimapTexture; s32 LakituTowType; - s16 D_800E5548[2]; + IVector2D_C MinimapDimensions; float AIMaximumSeparation; float AIMinimumSeparation; float NearPersp; diff --git a/src/engine/World.h b/src/engine/World.h index 4fdf55bc8..a8e9932f5 100644 --- a/src/engine/World.h +++ b/src/engine/World.h @@ -1,6 +1,7 @@ #pragma once #include +#include "CoreMath.h" #include "objects/Object.h" #include "Cup.h" #include "vehicles/Vehicle.h" @@ -24,80 +25,6 @@ extern "C" { #include "engine/Engine.h" }; -struct FVector { - float x, y, z; - - FVector& operator=(const FVector& other) { - x = other.x; - y = other.y; - z = other.z; - return *this; - } -}; - -/** - * For providing X and Z when you do not need Y - * Some actors set themselves on the surface automatically - * which means it does not use a Y coordinate - * The train follows a set Y value. The hedgehog's patrolPoint only uses X and Z. - */ -struct FVector2D { - float x, z; - - FVector2D& operator=(const FVector2D& other) { - x = other.x; - z = other.z; - return *this; - } -}; - -struct FRotation { - float pitch, yaw, roll; - - FRotation& operator=(const FRotation& other) { - pitch = other.pitch; - yaw = other.yaw; - roll = other.roll; - return *this; - } -}; - -/** - * For selecting a section of a course path - * Usage: IPathSpan(point1, point2) --> IPathSpan(40, 65) - */ -struct IPathSpan { - int Start, End; - - // Default Constructor - IPathSpan() : Start(0), End(0) {} - - // Parameterized Constructor - IPathSpan(int InStart, int InEnd) - : Start(InStart), End(InEnd) {} - - // Copy Assignment Operator - IPathSpan& operator=(const IPathSpan& Other) { - if (this != &Other) { // Avoid self-assignment - Start = Other.Start; - End = Other.End; - } - return *this; - } - - // Equality Operator - bool operator==(const IPathSpan& Other) const { - return Start == Other.Start && End == Other.End; - } - - // Inequality Operator - bool operator!=(const IPathSpan& Other) const { - return !(*this == Other); - } -}; - - - class OObject; class Cup; // <-- Forward declaration class Course; diff --git a/src/engine/courses/BansheeBoardwalk.cpp b/src/engine/courses/BansheeBoardwalk.cpp index 7f1847900..944d2a25c 100644 --- a/src/engine/courses/BansheeBoardwalk.cpp +++ b/src/engine/courses/BansheeBoardwalk.cpp @@ -68,8 +68,7 @@ BansheeBoardwalk::BansheeBoardwalk() { this->gfxSize = 3689; Props.textures = banshee_boardwalk_textures; Props.MinimapTexture = gTextureCourseOutlineBansheeBoardwalk; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:banshee_boardwalk"; Props.Name = "banshee boardwalk"; diff --git a/src/engine/courses/BigDonut.cpp b/src/engine/courses/BigDonut.cpp index c3abe1add..c0d4b1f7f 100644 --- a/src/engine/courses/BigDonut.cpp +++ b/src/engine/courses/BigDonut.cpp @@ -44,8 +44,7 @@ BigDonut::BigDonut() { this->gfxSize = 528; Props.textures = big_donut_textures; Props.MinimapTexture = gTextureCourseOutlineBigDonut; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "big donut"; Props.DebugName = "doughnut"; diff --git a/src/engine/courses/BlockFort.cpp b/src/engine/courses/BlockFort.cpp index 948eaf5e0..61eb3c0b1 100644 --- a/src/engine/courses/BlockFort.cpp +++ b/src/engine/courses/BlockFort.cpp @@ -46,8 +46,8 @@ BlockFort::BlockFort() { this->gfxSize = 699; Props.textures = block_fort_textures; Props.MinimapTexture = gTextureCourseOutlineBlockFort; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); + Props.Name = "block fort"; Props.DebugName = "block"; diff --git a/src/engine/courses/BowsersCastle.cpp b/src/engine/courses/BowsersCastle.cpp index 49ae93385..5174c5ea1 100644 --- a/src/engine/courses/BowsersCastle.cpp +++ b/src/engine/courses/BowsersCastle.cpp @@ -72,8 +72,7 @@ BowsersCastle::BowsersCastle() { this->gfxSize = 4900; Props.textures = bowsers_castle_textures; Props.MinimapTexture = gTextureCourseOutlineBowsersCastle; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:bowsers_castle"; Props.Name = "bowser's castle"; diff --git a/src/engine/courses/ChocoMountain.cpp b/src/engine/courses/ChocoMountain.cpp index 292d12076..04065dff5 100644 --- a/src/engine/courses/ChocoMountain.cpp +++ b/src/engine/courses/ChocoMountain.cpp @@ -64,8 +64,7 @@ ChocoMountain::ChocoMountain() { this->gfxSize = 2910; Props.textures = choco_mountain_textures; Props.MinimapTexture = gTextureCourseOutlineChocoMountain; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:choco_mountain"; Props.Name = "choco mountain"; diff --git a/src/engine/courses/Course.h b/src/engine/courses/Course.h index 381ba0340..f7bca6809 100644 --- a/src/engine/courses/Course.h +++ b/src/engine/courses/Course.h @@ -3,9 +3,9 @@ #include - // C-compatible function declaration #ifdef __cplusplus +#include "CoreMath.h" #include "engine/objects/Lakitu.h" extern "C" { #endif @@ -57,7 +57,7 @@ public: const char* AIBehaviour; const char* MinimapTexture; s32 LakituTowType; - s16 D_800E5548[2]; + IVector2D MinimapDimensions; float AIMaximumSeparation; float AIMinimumSeparation; float NearPersp; diff --git a/src/engine/courses/DKJungle.cpp b/src/engine/courses/DKJungle.cpp index 9daf7ad3f..e3e7bf3f5 100644 --- a/src/engine/courses/DKJungle.cpp +++ b/src/engine/courses/DKJungle.cpp @@ -72,8 +72,7 @@ DKJungle::DKJungle() { this->gfxSize = 4997; Props.textures = dks_jungle_parkway_textures; Props.MinimapTexture = gTextureCourseOutlineDksJungleParkway; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "d.k.'s jungle parkway"; Props.DebugName = "jungle"; diff --git a/src/engine/courses/DoubleDeck.cpp b/src/engine/courses/DoubleDeck.cpp index d5fe16763..1d5e16c60 100644 --- a/src/engine/courses/DoubleDeck.cpp +++ b/src/engine/courses/DoubleDeck.cpp @@ -44,8 +44,7 @@ DoubleDeck::DoubleDeck() { this->gfxSize = 699; Props.textures = double_deck_textures; Props.MinimapTexture = gTextureCourseOutlineDoubleDeck; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "double deck"; Props.DebugName = "deck"; diff --git a/src/engine/courses/FrappeSnowland.cpp b/src/engine/courses/FrappeSnowland.cpp index 3481e1e2b..5c0b4df43 100644 --- a/src/engine/courses/FrappeSnowland.cpp +++ b/src/engine/courses/FrappeSnowland.cpp @@ -5,6 +5,7 @@ #include "FrappeSnowland.h" #include "World.h" +#include "CoreMath.h" #include "engine/actors/AFinishline.h" #include "engine/objects/BombKart.h" #include "engine/objects/Snowman.h" @@ -51,8 +52,7 @@ FrappeSnowland::FrappeSnowland() { this->gfxSize = 4140; Props.textures = frappe_snowland_textures; Props.MinimapTexture = gTextureCourseOutlineFrappeSnowland; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "frappe snowland"; Props.DebugName = "snow"; diff --git a/src/engine/courses/KalimariDesert.cpp b/src/engine/courses/KalimariDesert.cpp index 8f00441ec..ffd19a86e 100644 --- a/src/engine/courses/KalimariDesert.cpp +++ b/src/engine/courses/KalimariDesert.cpp @@ -58,8 +58,7 @@ KalimariDesert::KalimariDesert() { this->gfxSize = 5328; Props.textures = kalimari_desert_textures; Props.MinimapTexture = gTextureCourseOutlineKalimariDesert; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 96; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "kalimari desert"; Props.DebugName = "desert"; diff --git a/src/engine/courses/KalimariDesert.h b/src/engine/courses/KalimariDesert.h index c25e9ba22..c4fed1d8f 100644 --- a/src/engine/courses/KalimariDesert.h +++ b/src/engine/courses/KalimariDesert.h @@ -1,6 +1,7 @@ #pragma once #include +#include "CoreMath.h" #include "Course.h" #include "engine/vehicles/Train.h" diff --git a/src/engine/courses/KoopaTroopaBeach.cpp b/src/engine/courses/KoopaTroopaBeach.cpp index 499a62bf7..6beca16b6 100644 --- a/src/engine/courses/KoopaTroopaBeach.cpp +++ b/src/engine/courses/KoopaTroopaBeach.cpp @@ -1,5 +1,6 @@ #include #include +#include "../CoreMath.h" #include #include @@ -61,8 +62,7 @@ KoopaTroopaBeach::KoopaTroopaBeach() { this->gfxSize = 5720; Props.textures = koopa_troopa_beach_textures; Props.MinimapTexture = gTextureCourseOutlineKoopaTroopaBeach; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:koopa_beach"; Props.Name = "koopa troopa beach"; diff --git a/src/engine/courses/KoopaTroopaBeach.h b/src/engine/courses/KoopaTroopaBeach.h index 8237b7628..c10b5cede 100644 --- a/src/engine/courses/KoopaTroopaBeach.h +++ b/src/engine/courses/KoopaTroopaBeach.h @@ -1,6 +1,7 @@ #pragma once #include +#include "../CoreMath.h" #include "Course.h" #include "World.h" diff --git a/src/engine/courses/LuigiRaceway.cpp b/src/engine/courses/LuigiRaceway.cpp index 5f6a78f97..78522df74 100644 --- a/src/engine/courses/LuigiRaceway.cpp +++ b/src/engine/courses/LuigiRaceway.cpp @@ -88,8 +88,7 @@ LuigiRaceway::LuigiRaceway() { this->gfxSize = 6377; Props.textures = luigi_raceway_textures; Props.MinimapTexture = gTextureCourseOutlineLuigiRaceway; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 96; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:luigi_raceway"; Props.Name = "luigi raceway"; diff --git a/src/engine/courses/MarioRaceway.cpp b/src/engine/courses/MarioRaceway.cpp index 05a4cc438..6690a5d89 100644 --- a/src/engine/courses/MarioRaceway.cpp +++ b/src/engine/courses/MarioRaceway.cpp @@ -73,8 +73,7 @@ MarioRaceway::MarioRaceway() { this->gfxSize = 3367; Props.textures = mario_raceway_textures; Props.MinimapTexture = gTextureCourseOutlineMarioRaceway; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:mario_raceway"; Props.Name = "Mario Raceway"; diff --git a/src/engine/courses/MooMooFarm.cpp b/src/engine/courses/MooMooFarm.cpp index f46f263ee..109857353 100644 --- a/src/engine/courses/MooMooFarm.cpp +++ b/src/engine/courses/MooMooFarm.cpp @@ -74,8 +74,7 @@ MooMooFarm::MooMooFarm() { this->gfxSize = 3304; Props.textures = moo_moo_farm_textures; Props.MinimapTexture = gTextureCourseOutlineMooMooFarm; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "moo moo farm"; Props.DebugName = "farm"; diff --git a/src/engine/courses/PodiumCeremony.cpp b/src/engine/courses/PodiumCeremony.cpp index 5c4bbe7fb..a6d170960 100644 --- a/src/engine/courses/PodiumCeremony.cpp +++ b/src/engine/courses/PodiumCeremony.cpp @@ -89,8 +89,7 @@ PodiumCeremony::PodiumCeremony() { this->gfx = d_course_royal_raceway_packed_dls; this->gfxSize = 5670; Props.textures = podium_ceremony_textures; - Props.D_800E5548[0] = 0; - Props.D_800E5548[1] = 0; + Props.MinimapDimensions = IVector2D(0, 0); Props.Name = "royal raceway"; Props.DebugName = "p circuit"; diff --git a/src/engine/courses/PodiumCeremony.h b/src/engine/courses/PodiumCeremony.h index 7f9de6b1d..bb17e8f8d 100644 --- a/src/engine/courses/PodiumCeremony.h +++ b/src/engine/courses/PodiumCeremony.h @@ -1,6 +1,7 @@ #pragma once #include +#include "CoreMath.h" #include "Course.h" extern "C" { diff --git a/src/engine/courses/RainbowRoad.cpp b/src/engine/courses/RainbowRoad.cpp index 4cc7e2a51..4c0c32bb3 100644 --- a/src/engine/courses/RainbowRoad.cpp +++ b/src/engine/courses/RainbowRoad.cpp @@ -48,8 +48,7 @@ RainbowRoad::RainbowRoad() { this->gfxSize = 5670; Props.textures = rainbow_road_textures; Props.MinimapTexture = gTextureCourseOutlineRainbowRoad; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 96; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "rainbow road"; Props.DebugName = "rainbow"; diff --git a/src/engine/courses/RoyalRaceway.cpp b/src/engine/courses/RoyalRaceway.cpp index 733d42a92..2ea0022ca 100644 --- a/src/engine/courses/RoyalRaceway.cpp +++ b/src/engine/courses/RoyalRaceway.cpp @@ -86,8 +86,7 @@ RoyalRaceway::RoyalRaceway() { this->gfxSize = 5670; Props.textures = royal_raceway_textures; Props.MinimapTexture = gTextureCourseOutlineRoyalRaceway; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "royal raceway"; Props.DebugName = "p circuit"; diff --git a/src/engine/courses/SherbetLand.cpp b/src/engine/courses/SherbetLand.cpp index 0153bf0a8..bfcacca4a 100644 --- a/src/engine/courses/SherbetLand.cpp +++ b/src/engine/courses/SherbetLand.cpp @@ -49,8 +49,7 @@ SherbetLand::SherbetLand() { this->gfxSize = 1803; Props.textures = sherbet_land_textures; Props.MinimapTexture = gTextureCourseOutlineSherbetLand; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "sherbet land"; Props.DebugName = "sherbet"; diff --git a/src/engine/courses/Skyscraper.cpp b/src/engine/courses/Skyscraper.cpp index da3cca777..f7c092bee 100644 --- a/src/engine/courses/Skyscraper.cpp +++ b/src/engine/courses/Skyscraper.cpp @@ -65,8 +65,7 @@ Skyscraper::Skyscraper() { this->gfxSize = 548; Props.textures = skyscraper_textures; Props.MinimapTexture = gTextureCourseOutlineSkyscraper; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "skyscraper"; Props.DebugName = "skyscraper"; diff --git a/src/engine/courses/TestCourse.cpp b/src/engine/courses/TestCourse.cpp index 682db53c5..2a094c6a1 100644 --- a/src/engine/courses/TestCourse.cpp +++ b/src/engine/courses/TestCourse.cpp @@ -1,5 +1,6 @@ #include #include +#include "CoreMath.h" #include #include @@ -61,8 +62,7 @@ TestCourse::TestCourse() { this->gfxSize = 100; this->textures = NULL; Props.MinimapTexture = gTextureCourseOutlineMarioRaceway; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Id = "mk:test_course"; Props.Name = "Test Course"; diff --git a/src/engine/courses/ToadsTurnpike.cpp b/src/engine/courses/ToadsTurnpike.cpp index 47ed10111..88371411f 100644 --- a/src/engine/courses/ToadsTurnpike.cpp +++ b/src/engine/courses/ToadsTurnpike.cpp @@ -70,8 +70,7 @@ ToadsTurnpike::ToadsTurnpike() { this->gfxSize = 3427; Props.textures = toads_turnpike_textures; Props.MinimapTexture = gTextureCourseOutlineToadsTurnpike; - Props.D_800E5548[0] = 128; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "toad's turnpike"; Props.DebugName = "highway"; diff --git a/src/engine/courses/WarioStadium.cpp b/src/engine/courses/WarioStadium.cpp index 3c68c662e..522a6509d 100644 --- a/src/engine/courses/WarioStadium.cpp +++ b/src/engine/courses/WarioStadium.cpp @@ -66,8 +66,7 @@ WarioStadium::WarioStadium() { this->gfxSize = 5272; Props.textures = wario_stadium_textures; Props.MinimapTexture = gTextureCourseOutlineWarioStadium; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "wario stadium"; Props.DebugName = "stadium"; diff --git a/src/engine/courses/YoshiValley.cpp b/src/engine/courses/YoshiValley.cpp index 25c11daf8..f7f3d1871 100644 --- a/src/engine/courses/YoshiValley.cpp +++ b/src/engine/courses/YoshiValley.cpp @@ -1,5 +1,6 @@ #include #include +#include "CoreMath.h" #include #include @@ -60,8 +61,7 @@ YoshiValley::YoshiValley() { Props.textures = yoshi_valley_textures; Props.MinimapTexture = gTextureCourseOutlineYoshiValley; - Props.D_800E5548[0] = 64; - Props.D_800E5548[1] = 64; + Props.MinimapDimensions = IVector2D(ResourceGetTexWidthByName(Props.MinimapTexture), ResourceGetTexHeightByName(Props.MinimapTexture)); Props.Name = "yoshi valley"; Props.DebugName = "maze"; diff --git a/src/engine/objects/Crab.cpp b/src/engine/objects/Crab.cpp index b05bc85e3..3a71e075d 100644 --- a/src/engine/objects/Crab.cpp +++ b/src/engine/objects/Crab.cpp @@ -2,6 +2,8 @@ #include #include "Crab.h" #include +#include "CoreMath.h" + #include "port/Game.h" diff --git a/src/engine/objects/Crab.h b/src/engine/objects/Crab.h index 281b080ca..4cadd3b87 100644 --- a/src/engine/objects/Crab.h +++ b/src/engine/objects/Crab.h @@ -3,6 +3,7 @@ #include #include #include "engine/objects/Object.h" +#include "CoreMath.h" #include "World.h" extern "C" { diff --git a/src/math_util_2.c b/src/math_util_2.c index f2b85daeb..7cb396242 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -718,6 +718,19 @@ void func_80042330(s32 x, s32 y, u16 angle, f32 scale) { AddHudMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } +void func_80042330_unchanged(s32 x, s32 y, u16 angle, f32 scale) { + Mat4 matrix; + //printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0)); + + mtxf_translation_x_y_rotate_z_scale_x_y(matrix, x, y, angle, scale); + // convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], matrix); + // gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]), + // G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AddHudMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +} + +// Allows a different way of lining up the portraits at the end of race sequence void func_80042330_portrait(s32 x, s32 y, u16 angle, f32 scale, s16 lapCount) { Mat4 matrix; //printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0)); diff --git a/src/math_util_2.h b/src/math_util_2.h index 2944fddc1..a62c9697b 100644 --- a/src/math_util_2.h +++ b/src/math_util_2.h @@ -70,6 +70,7 @@ void func_80041D24(void); void func_80041D34(void); void set_matrix_hud_screen(void); void func_80042330(s32, s32, u16, f32); +void func_80042330_unchanged(s32 x, s32 y, u16 angle, f32 scale); void func_80042330_portrait(s32, s32, u16, f32, s16); void func_80042330_wide(s32, s32, u16, f32); void mtxf_set_matrix_transformation(Mat4, Vec3f, Vec3su, f32); diff --git a/src/menu_items.c b/src/menu_items.c index 6b6fde7fb..4ac0a30fe 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -3259,7 +3259,15 @@ Gfx* func_800987D0(Gfx* displayListHead, u32 arg1, u32 arg2, u32 width, u32 heig return displayListHead; } -// draw a box filled with a solid color +/** + * Draw a box filled with a solid color + * + * Renders + * + * Menus: Black box behind textures such as: "1P Game, 2P Game, Mario GP, 50CC, OK, etc." + * + * + */ Gfx* draw_box_fill(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, s32 red, s32 green, s32 blue, s32 alpha) { red &= 0xFF; green &= 0xFF; @@ -3298,6 +3306,17 @@ Gfx* draw_box_fill(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, s32 } // draw a box filled with a solid color + +/** + * Draw a box filled with a solid color + * + * Renders + * + * All game modes: + * Cinematic borders + * + * + */ Gfx* draw_box_fill_wide(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, s32 red, s32 green, s32 blue, s32 alpha) { red &= 0xFF; @@ -3333,12 +3352,17 @@ Gfx* draw_box_fill_wide(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry GPACK_RGBA5551(red, green, (u32) blue, alpha))); gDPFillWideRectangle(displayListHead++, OTRGetDimensionFromLeftEdge(ulx), uly, OTRGetDimensionFromRightEdge(lrx), lry); - // gDPFillRectangle(displayListHead++, ulx, uly, lrx, lry); + gDPFillRectangle(displayListHead++, ulx, uly, lrx, lry); gSPDisplayList(displayListHead++, D_02008058); return displayListHead; } -// draw a box with a solid outline +/** + * Draw a box with a solid outline + * + * Menus best lap time at start menu + * + */ Gfx* draw_box(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 red, u32 green, u32 blue, u32 alpha) { red &= 0xFF; green &= 0xFF; @@ -3375,6 +3399,15 @@ Gfx* draw_box(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 red, return displayListHead; } +/** + * Renders + * + * Menus: Menu transition swipes, course label highlight + * + * All game modes: Background cover at pause screen + * + * + */ Gfx* draw_box_wide(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 red, u32 green, u32 blue, u32 alpha) { red &= 0xFF; green &= 0xFF; @@ -3412,6 +3445,46 @@ Gfx* draw_box_wide(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 return displayListHead; } +// Renders pause background +Gfx* draw_box_wide_pause_background(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 red, u32 green, u32 blue, u32 alpha) { + red &= 0xFF; + green &= 0xFF; + blue &= 0xFF; + alpha &= 0xFF; + if (lrx < ulx) { + swap_values(&ulx, &lrx); + } + if (lry < uly) { + swap_values(&uly, &lry); + } + // if ((ulx >= SCREEN_WIDTH) || (uly >= SCREEN_HEIGHT)) { + // return displayListHead; + // } + + // if (ulx < 0) { + // ulx = 0; + // } + // if (uly < 0) { + // uly = 0; + // } + + // if ((lrx < 0) || (lry < 0)) { + // return displayListHead; + // } + // if (lrx > SCREEN_WIDTH) { + // lrx = SCREEN_WIDTH; + // } + // if (lry > SCREEN_HEIGHT) { + // lry = SCREEN_HEIGHT; + // } + gSPDisplayList(displayListHead++, D_02008008); + gDPSetPrimColor(displayListHead++, 0, 0, red, green, blue, alpha); + gDPFillWideRectangle(displayListHead++, ulx, uly, + lrx, lry); + gDPPipeSync(displayListHead++); + return displayListHead; +} + Gfx* func_80098FC8(Gfx* displayListHead, s32 ulx, s32 uly, s32 lrx, s32 lry) { return draw_box_fill(displayListHead, ulx, uly, lrx, lry, 0, 0, 0, 0xFF); } @@ -3436,7 +3509,7 @@ void load_texture(const char* texture) { } /** - * If you need to reset a texture cache after a modification, + * If you need to reset a texture after a modification, * this will reload the texture. */ void load_texture_reset_cache(const char* texture) { @@ -3456,6 +3529,7 @@ void load_texture_reset_cache(const char* texture) { sMenuTextureEntries += 1; } +// Provide an index for sMenuTextureMap void replace_texture(s32 index, const char* newTexture) { sMenuTextureList[sMenuTextureMap[index].offset] = newTexture; sMenuTextureMap[index].textureData = newTexture; @@ -7772,6 +7846,8 @@ void render_pause_menu_versus(MenuItem* arg0) { s32 temp_t4; s32 var_s0; s32 var_s1; + s32 leftEdge; + s32 rightEdge; Unk_D_800E70A0* temp_s3; struct UnkStruct_800DC5EC* temp_v0; @@ -7780,8 +7856,41 @@ void render_pause_menu_versus(MenuItem* arg0) { temp_t0 = temp_v0->screenStartY; temp_t3 = temp_v0->screenWidth / 2; temp_t4 = temp_v0->screenHeight / 2; - gDisplayListHead = draw_box_wide(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, - temp_t0 + temp_t4, 0, 0, 0, 0x0000008C); + + switch(gScreenModeSelection) { + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + leftEdge = OTRGetDimensionFromLeftEdge(0); + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - rightEdge, temp_t0 - temp_t4, rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + leftEdge = OTRGetDimensionFromLeftEdge(0); + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - rightEdge, temp_t0 - temp_t4, leftEdge + rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + // Left side players + if ((temp_v0->player == gPlayerOne) || (temp_v0->player == gPlayerThree)) { + leftEdge = OTRGetDimensionFromLeftEdge(0); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + + // Right side players + } else if ((temp_v0->player == gPlayerTwo) || (temp_v0->player == gPlayerFour)) { + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + + } + break; + default: + gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + } + temp_s3 = &D_800E8540[(gScreenModeSelection * 4) + (gIsGamePaused - 1)]; for (var_s0 = 0; var_s0 < 4; var_s0++) { if (var_s0 > 0) { @@ -7811,8 +7920,25 @@ void render_pause_grand_prix(MenuItem* arg0) { temp_t0 = temp_v0->screenStartY; temp_t3 = temp_v0->screenWidth / 2; temp_t4 = temp_v0->screenHeight / 2; - gDisplayListHead = draw_box_wide(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, - temp_t0 + temp_t4, 0, 0, 0, 140); + + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + gDisplayListHead = draw_box_wide(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + s32 leftEdge = OTRGetDimensionFromLeftEdge(0); + s32 rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide(gDisplayListHead, leftEdge - rightEdge, temp_t0 - temp_t4, leftEdge + rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + default: + gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + } + temp_s3 = &D_800E85C0[(gScreenModeSelection * 4) + (gIsGamePaused - 1)]; temp_s0 = ((get_string_width(gCupNames[GetCupIndex()]) * one) + 10.0f) / 2; temp_s1 = ((get_string_width(D_800E76CC[gCCSelection]) * one) + 10.0f) / 2; @@ -7836,6 +7962,8 @@ void render_pause_battle(MenuItem* arg0) { s32 temp_t4; s32 var_a1; s32 var_s1; + s32 leftEdge; + s32 rightEdge; Unk_D_800E70A0* temp_s3; temp_v0 = &D_8015F480[gIsGamePaused - 1]; @@ -7843,8 +7971,41 @@ void render_pause_battle(MenuItem* arg0) { temp_t0 = temp_v0->screenStartY; temp_t3 = temp_v0->screenWidth / 2; temp_t4 = temp_v0->screenHeight / 2; - gDisplayListHead = draw_box_wide(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, - temp_t0 + temp_t4, 0, 0, 0, 0x0000008C); + + switch(gScreenModeSelection) { + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + leftEdge = OTRGetDimensionFromLeftEdge(0); + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - rightEdge, temp_t0 - temp_t4, rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + leftEdge = OTRGetDimensionFromLeftEdge(0); + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - rightEdge, temp_t0 - temp_t4, rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + // Left side players + if ((temp_v0->player == gPlayerOne) || (temp_v0->player == gPlayerThree)) { + leftEdge = OTRGetDimensionFromLeftEdge(0); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, leftEdge - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + + // Right side players + } else if ((temp_v0->player == gPlayerTwo) || (temp_v0->player == gPlayerFour)) { + rightEdge = OTRGetDimensionFromRightEdge(SCREEN_WIDTH); + gDisplayListHead = draw_box_wide_pause_background(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + rightEdge, + temp_t0 + temp_t4, 0, 0, 0, 140); + + } + break; + default: + gDisplayListHead = draw_box(gDisplayListHead, temp_v1 - temp_t3, temp_t0 - temp_t4, temp_v1 + temp_t3, + temp_t0 + temp_t4, 0, 0, 0, 140); + break; + } + temp_s3 = &D_800E8600[(gScreenModeSelection * 4) + (gIsGamePaused - 1)]; for (var_a1 = 0; var_a1 < 4; var_a1++) { if (var_a1 > 0) { @@ -7852,7 +8013,7 @@ void render_pause_battle(MenuItem* arg0) { } else { var_s1 = var_a1; } - text_rainbow_effect(arg0->state - 0x29, var_a1, TEXT_YELLOW); + text_rainbow_effect(arg0->state - 41, var_a1, TEXT_YELLOW); print_text_mode_1(temp_s3->column - 2, temp_s3->row + 13 * var_a1, gTextPauseButton[var_s1], 0, 0.75f, 0.75f); } } diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index a8763cac0..6c43b48bb 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -454,6 +454,28 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdge(float v) { return ((int) ceilf(OTRGetDimensionFromRightEdge(v))); } +/** + * Centers an item in a given area. + * + * Adds the number of extended screen pixels to the location to center. + * This allows stretching the game window really wide, and the item will stay in-place. + * + * This is not for centering in the direct center of the screen. + * + * How to use: + * + * s32 center = OTRCalculateCenterOfAreaFromRightEdge((SCREEN_WIDTH / 4) + (SCREEN_WIDTH / 2)); + * x = center - (texWidth / 2) + * x2 = center + (texWidth / 2) + */ +extern "C" uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center) { + return ((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2) + center; +} + +extern "C" uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center) { + return ((OTRGetDimensionFromLeftEdge(0) - SCREEN_WIDTH) / 2) + center; +} + // Gets the width of the current render target area extern "C" uint32_t OTRGetGameRenderWidth() { return gfx_current_dimensions.width; diff --git a/src/port/Engine.h b/src/port/Engine.h index 16ad40299..94f0e4d33 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -52,6 +52,8 @@ class GameEngine { int16_t OTRGetRectDimensionFromRightEdge(float v); uint32_t OTRGetGameRenderWidth(); uint32_t OTRGetGameRenderHeight(); + uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center); + uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center); }; #endif @@ -77,6 +79,6 @@ int16_t OTRGetRectDimensionFromLeftEdge(float v); int16_t OTRGetRectDimensionFromRightEdge(float v); uint32_t OTRGetGameRenderWidth(void); uint32_t OTRGetGameRenderHeight(void); -#ifdef __cplusplus -} +uint32_t OTRCalculateCenterOfAreaFromRightEdge(int32_t center); +uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center); #endif diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c index eaa6015d5..6c51fb266 100644 --- a/src/racing/skybox_and_splitscreen.c +++ b/src/racing/skybox_and_splitscreen.c @@ -303,11 +303,11 @@ void func_802A4300(void) { gDPFillRectangle(gDisplayListHead++, 157, 0, 159, 239); break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: - gDPFillRectangle(gDisplayListHead++, 0, 119, 319, 121); + gDPFillWideRectangle(gDisplayListHead++, OTRGetDimensionFromLeftEdge(0), 119, OTRGetGameRenderWidth(), 121); break; case SCREEN_MODE_3P_4P_SPLITSCREEN: gDPFillRectangle(gDisplayListHead++, 157, 0, 159, 239); - gDPFillRectangle(gDisplayListHead++, 0, 119, 319, 121); + gDPFillWideRectangle(gDisplayListHead++, OTRGetDimensionFromLeftEdge(0), 119, OTRGetGameRenderWidth(), 121); break; } gDPPipeSync(gDisplayListHead++); @@ -731,7 +731,7 @@ void func_802A5760(void) { gDPSetFillColor(gDisplayListHead++, 0x00010001); gDPPipeSync(gDisplayListHead++); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 160, 120, SCREEN_WIDTH, SCREEN_HEIGHT); - gDPFillRectangle(gDisplayListHead++, 160, 120, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); + gDPFillRectangle(gDisplayListHead++, 160, 120, OTRGetDimensionFromRightEdge(320), SCREEN_HEIGHT - 1); gDPPipeSync(gDisplayListHead++); gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); diff --git a/src/render_objects.c b/src/render_objects.c index 749e88fc2..d6d6b6a27 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -510,14 +510,35 @@ void func_800462A8(u8* texture, Vtx* arg1, s32 width, s32 arg3, s32 height) { void func_800463B0(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8* texture, Vtx* arg5, s32 arg6, s32 arg7, UNUSED s32 arg8, s32 arg9) { - func_80042330(arg0, arg1, arg2, arg3); + + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + func_80042330(arg0, arg1, arg2, arg3); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + func_80042330_unchanged(arg0, arg1, arg2, arg3); + break; + } + gSPDisplayList(gDisplayListHead++, D_0D007928); func_80045D0C(texture, arg5, arg6, arg7, arg9); } void func_80046424(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8* texture, Vtx* arg5, s32 arg6, s32 arg7, UNUSED s32 arg8, s32 arg9) { - func_80042330(arg0, arg1, arg2, arg3); + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + func_80042330(arg0, arg1, arg2, arg3); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + func_80042330_unchanged(arg0, arg1, arg2, arg3); + break; + } + gSPDisplayList(gDisplayListHead++, D_0D007968); func_8004B614(D_801656C0, D_801656D0, D_801656E0, 128, 128, 128, 255); func_80045D0C(texture, arg5, arg6, arg7, arg9); @@ -1535,6 +1556,15 @@ void func_8004B72C(s32 primRed, s32 primGreen, s32 primBlue, s32 envRed, s32 env PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); } +/** + * Renders + * + * Menus: Mario Kart 64 Logo, Debug text + * + * 1P: Coloured square in third hud mode that players go around. + * + * + */ void render_texture_rectangle(s32 x, s32 y, s32 width, s32 height, s32 s, s32 w, s32 mode) { s32 xh = (((x + width) - 1) << 2); @@ -1557,12 +1587,21 @@ void render_texture_rectangle(s32 x, s32 y, s32 width, s32 height, s32 s, s32 w, 1 << 10); } +/** + * Renders + * + * For all game modes + * + * Minimap, CurrLap, Lap time + * + * + */ void render_texture_rectangle_wide(s32 x, s32 y, s32 width, s32 height, s32 arg4, s32 arg5, s32 arg6) { s32 xh = (((x + width) - 1)); s32 yh = (((y + height) - 1) << 2); s32 xl = ((x)); - s32 yl = y * 4; + s32 yl = y << 2; s32 xh2 = (((x + width))); s32 yh2 = ((y + height) << 2); @@ -1574,33 +1613,63 @@ void render_texture_rectangle_wide(s32 x, s32 y, s32 width, s32 height, s32 arg4 s32 coordX2 = 0; if (arg6 == 0) { - if ((xl - (width / 2)) < (SCREEN_WIDTH / 2)) { - coordX = (s32)OTRGetDimensionFromLeftEdge(xl) << 2; - coordX2 = (s32)(xh) << 2; - } else { - coordX = (s32)OTRGetDimensionFromRightEdge(xl) << 2; - coordX2 = (s32)OTRGetDimensionFromRightEdge(xh) << 2; + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_3P_4P_SPLITSCREEN: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + if ((xl - (width / 2)) < (SCREEN_WIDTH / 2)) { + coordX = (s32)OTRGetDimensionFromLeftEdge(xl) << 2; + coordX2 = (s32)(xh) << 2; + } else { + coordX = (s32)OTRGetDimensionFromRightEdge(xl) << 2; + coordX2 = (s32)OTRGetDimensionFromRightEdge(xh) << 2; + } + //! @todo Update to F3DEX. Uses OLD definition for gspTextureRectangle. + gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, coordX2, yh, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 4 << 10, + 1 << 10); + break; + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + gSPTextureRectangle(gDisplayListHead++, xl << 2, yl, xh << 2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, + 1 << 10); + break; } - //! @todo Update to F3DEX. Uses OLD definition for gspTextureRectangle. - gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, coordX2, yh, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 4 << 10, - 1 << 10); //OTRGetDimensionFromLeftEdge //gSPTextureRectangle(gDisplayListHead++, xl, yl, xh, yh, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 4 << 10, // 1 << 10); - } else { - - if ((xl - (width / 2)) < (SCREEN_WIDTH / 2)) { - coordX = (s32)OTRGetDimensionFromLeftEdge(xl) << 2; - coordX2 = (s32)(xh2) << 2; - } else { - coordX = (s32)OTRGetDimensionFromRightEdge(xl) << 2; - coordX2 = (s32)OTRGetDimensionFromRightEdge(xh2) << 2; + } else { // minimap + switch(gScreenModeSelection) { + case SCREEN_MODE_3P_4P_SPLITSCREEN: + if (gPlayerCount == 3) { + // Center item in area of screen + s32 center = (s32)((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2) + ((SCREEN_WIDTH / 4) + (SCREEN_WIDTH / 2)); + s32 coordX = (s32)(center - (width / 2)) << 2; + s32 coordX2 = (s32)(center + (width / 2)) << 2; + gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, + coordX2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, + 1 << 10); + } else { // 4 players + s32 renderWidth = SCREEN_WIDTH; + s32 center = (renderWidth / 2); + coordX = (s32)(center - (width / 2)) << 2; + coordX2 = (s32)(center + (width / 2)) << 2; + gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, + coordX2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, + 1 << 10); + } + break; + default: + if ((xl - (width / 2)) < (SCREEN_WIDTH / 2)) { + coordX = (s32)OTRGetDimensionFromLeftEdge(xl) << 2; + coordX2 = (s32)(xh2) << 2; + } else { + coordX = (s32)OTRGetDimensionFromRightEdge(xl) << 2; + coordX2 = (s32)OTRGetDimensionFromRightEdge(xh2) << 2; + } + gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, + coordX2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, + 1 << 10); + break; } - gSPWideTextureRectangle(gDisplayListHead++, coordX, yl, - coordX2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, - 1 << 10); - - } //gSPTextureRectangle(gDisplayListHead++, xl, yl, xh2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, // 1 << 10); @@ -1636,6 +1705,7 @@ void func_8004B97C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { } } +// Positions item window, the Lap 1/2/3, TIME texture, and minimap on the screen. void func_8004B97C_wide(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { UNUSED s32 pad[2]; s32 sp2C; @@ -1715,6 +1785,7 @@ void func_8004BA98(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s } } +// Display lap count (but not the texture that says lap) void func_8004BA98_wide(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6) { UNUSED s32 pad[2]; s32 sp34; @@ -1741,7 +1812,16 @@ void func_8004BA98_wide(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 ar sp30 = 0; phi_a3 = arg3 + arg1; } - render_texture_rectangle_wide(sp34, sp30, sp2C, phi_a3, phi_v0, phi_v1, arg6); + + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + render_texture_rectangle_wide(sp34, sp30, sp2C, phi_a3, phi_v0, phi_v1, arg6); + break; + default: + render_texture_rectangle(sp34, sp30, sp2C, phi_a3, phi_v0, phi_v1, arg6); + break; + } } } @@ -1846,6 +1926,15 @@ UNUSED void func_8004C35C() { } void draw_hud_2d_texture(s32 x, s32 y, u32 width, u32 height, u8* texture) { + gSPDisplayList(gDisplayListHead++, D_0D008108); + gSPDisplayList(gDisplayListHead++, D_0D007EF8); + gDPSetAlphaCompare(gDisplayListHead++, G_AC_THRESHOLD); + load_texture_block_rgba16_mirror(texture, width, height); + func_8004B97C(x - (width >> 1), y - (height >> 1), width, height, 0); + gSPDisplayList(gDisplayListHead++, D_0D007EB8); +} + +void draw_hud_2d_texture_wide(s32 x, s32 y, u32 width, u32 height, u8* texture) { gSPDisplayList(gDisplayListHead++, D_0D008108); gSPDisplayList(gDisplayListHead++, D_0D007EF8); gDPSetAlphaCompare(gDisplayListHead++, G_AC_THRESHOLD); @@ -1951,23 +2040,32 @@ void func_8004CA58(s32 arg0, s32 arg1, f32 arg2, u8* texture, s32 arg4, s32 arg5 } void draw_hud_2d_texture_8x8(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 8, 8, texture); + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + draw_hud_2d_texture_wide(x, y, 8, 8, texture); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + draw_hud_2d_texture(x, y, 8, 8, texture); + break; + } } UNUSED void draw_hud_2d_texture_8x16(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 8, 16, texture); + draw_hud_2d_texture_wide(x, y, 8, 16, texture); } UNUSED void draw_hud_2d_texture_16x16(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 16, 16, texture); + draw_hud_2d_texture_wide(x, y, 16, 16, texture); } void draw_hud_2d_texture_32x8(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 32, 8, texture); + draw_hud_2d_texture_wide(x, y, 32, 8, texture); } void draw_hud_2d_texture_32x16(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 32, 16, texture); + draw_hud_2d_texture_wide(x, y, 32, 16, texture); } UNUSED void func_8004CBC0(s32 arg0, s32 arg1, f32 arg2, u8* texture) { @@ -1975,7 +2073,7 @@ UNUSED void func_8004CBC0(s32 arg0, s32 arg1, f32 arg2, u8* texture) { } UNUSED void draw_hud_2d_texture_32x32(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 32, 32, texture); + draw_hud_2d_texture_wide(x, y, 32, 32, texture); } UNUSED void func_8004CC24(s32 arg0, s32 arg1, u8* texture) { @@ -1983,7 +2081,7 @@ UNUSED void func_8004CC24(s32 arg0, s32 arg1, u8* texture) { } UNUSED void draw_hud_2d_texture_40x32(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 40, 32, texture); + draw_hud_2d_texture_wide(x, y, 40, 32, texture); } UNUSED void func_8004CC84(s32 x, s32 y, u8* texture) { @@ -1991,7 +2089,7 @@ UNUSED void func_8004CC84(s32 x, s32 y, u8* texture) { } UNUSED void func_8004CCB4(s32 x, s32 y, u8* texture) { - draw_hud_2d_texture(x, y, 64, 32, texture); + draw_hud_2d_texture_wide(x, y, 64, 32, texture); } UNUSED void func_8004CCE4(s32 arg0, s32 arg1, f32 arg2, u8* texture) { @@ -2460,7 +2558,8 @@ void draw_simplified_lap_count(s32 playerId) { draw_hud_2d_texture_32x8((s32) playerHUD[playerId].lapX, playerHUD[playerId].lapY + 3, (u8*) common_texture_hud_lap); draw_hud_2d_texture_32x16(playerHUD[playerId].lapX + 0x1C, (s32) playerHUD[playerId].lapY, - (u8*) gHudLapTextures[playerHUD[playerId].alsoLapCount]); + (u8*) gHudLapTextures[playerHUD[playerId].alsoLapCount]); + } void func_8004E800(s32 playerId) { @@ -2540,13 +2639,13 @@ void func_8004ED40(s32 arg0) { void func_8004EE54(s32 arg0) { if (gIsMirrorMode != 0) { - func_8004D4E8(D_8018D2C0[arg0] + D_8018D2F0, D_8018D2D8[arg0] + D_8018D2F8, (u8*) D_8018D240, (s32) D_8018D300, - (s32) D_8018D308, (s32) D_8018D310, 0x000000FF, (s32) D_8018D2B0, (s32) D_8018D2B8, - (s32) D_8018D2B0, (s32) D_8018D2B8); + func_8004D4E8(D_8018D2C0[arg0], D_8018D2D8[arg0], (u8*) D_8018D240, (s32) D_8018D300, + (s32) D_8018D308, (s32) D_8018D310, 0x000000FF, (s32) gMinimapWidth, (s32) gMinimapHeight, + (s32) gMinimapWidth, (s32) gMinimapHeight); } else { - func_8004D37C(D_8018D2C0[arg0] + D_8018D2F0, D_8018D2D8[arg0] + D_8018D2F8, (u8*) D_8018D240, (s32) D_8018D300, - (s32) D_8018D308, (s32) D_8018D310, 0x000000FF, (s32) D_8018D2B0, (s32) D_8018D2B8, - (s32) D_8018D2B0, (s32) D_8018D2B8); + func_8004D37C(D_8018D2C0[arg0], D_8018D2D8[arg0], (u8*) D_8018D240, (s32) D_8018D300, + (s32) D_8018D308, (s32) D_8018D310, 0x000000FF, (s32) gMinimapWidth, (s32) gMinimapHeight, + (s32) gMinimapWidth, (s32) gMinimapHeight); } } @@ -2554,21 +2653,28 @@ void func_8004EF9C(s32 arg0) { s16 temp_t0; s16 temp_v0; - temp_v0 = CourseManager_GetProps()->D_800E5548[0]; // D_800E5548[arg0 * 2]; - temp_t0 = CourseManager_GetProps()->D_800E5548[1]; // D_800E5548[arg0 * 2 + 1]; + temp_v0 = CourseManager_GetProps()->MinimapDimensions.X; + temp_t0 = CourseManager_GetProps()->MinimapDimensions.Z; func_8004D37C(0x00000104, 0x0000003C, CourseManager_GetProps()->MinimapTexture, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, temp_v0, temp_t0, temp_v0, temp_t0); } -void func_8004F020(s32 arg0) { +void set_minimap_finishline_position(s32 arg0) { f32 var_f0; f32 var_f2; + s32 center = 0; - //! @todo: Hardcode these x and y values. Because why not? - CourseManager_MinimapFinishlinePosition(); +//! @todo: Hardcode these x and y values. Because why not? - var_f2 = ((D_8018D2C0[arg0] + D_8018D2F0) - (D_8018D2B0 / 2)) + D_8018D2E0; - var_f0 = ((D_8018D2D8[arg0] + D_8018D2F8) - (D_8018D2B8 / 2)) + D_8018D2E8; + if (gPlayerCount == 3) { + center = ((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2) + ((SCREEN_WIDTH / 4) + (SCREEN_WIDTH / 2)); + } else { + center = D_8018D2C0[arg0]; + } + +//minimap center pos - minimap left edge + offset + var_f2 = (center - (gMinimapWidth / 2)) + D_8018D2E0; + var_f0 = (D_8018D2D8[arg0] - (gMinimapHeight / 2)) + D_8018D2E8; if (GetCourse() == GetMarioRaceway()) { var_f0 = var_f0 - 2.0; } else if (GetCourse() == GetChocoMountain()) { @@ -2577,6 +2683,8 @@ void func_8004F020(s32 arg0) { var_f0 = var_f0 + 4.0; } + //! @todo Get course minimap props from course. + CourseManager_MinimapFinishlinePosition(); draw_hud_2d_texture_8x8(var_f2, var_f0, (u8*) common_texture_minimap_finish_line); } @@ -2591,13 +2699,21 @@ void func_8004F168(s32 arg0, s32 playerId, s32 characterId) { f32 thing1; s16 temp_a0; s16 temp_a1; + s32 center = 0; Player* player = &gPlayerOne[playerId]; if (player->type & (1 << 15)) { thing0 = player->pos[0] * D_8018D2A0; thing1 = player->pos[2] * D_8018D2A0; - temp_a0 = ((D_8018D2C0[arg0] + D_8018D2F0) - (D_8018D2B0 / 2)) + D_8018D2E0 + (s16) (thing0); - temp_a1 = ((D_8018D2D8[arg0] + D_8018D2F8) - (D_8018D2B8 / 2)) + D_8018D2E8 + (s16) (thing1); + + if (gPlayerCount == 3) { + center = ((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2) + ((SCREEN_WIDTH / 4) + (SCREEN_WIDTH / 2)); + } else { + center = D_8018D2C0[arg0]; + } + + temp_a0 = (center - (gMinimapWidth / 2)) + D_8018D2E0 + (s16) (thing0); + temp_a1 = (D_8018D2D8[arg0] - (gMinimapHeight / 2)) + D_8018D2E8 + (s16) (thing1); if (characterId != 8) { if ((gGPCurrentRaceRankByPlayerId[playerId] == 0) && (gModeSelection != 3) && (gModeSelection != 1)) { #if EXPLICIT_AND == 1 @@ -2624,7 +2740,7 @@ void func_8004F168(s32 arg0, s32 playerId, s32 characterId) { if (gGPCurrentRaceRankByPlayerId[playerId] == 0) { func_8004C450(temp_a0, temp_a1, 8, 8, (u8*) common_texture_minimap_progress_dot); } else { - draw_hud_2d_texture(temp_a0, temp_a1, 8, 8, (u8*) common_texture_minimap_progress_dot); + draw_hud_2d_texture_wide(temp_a0, temp_a1, 8, 8, (u8*) common_texture_minimap_progress_dot); } } } @@ -3149,9 +3265,9 @@ void func_80050E34(s32 playerId, s32 arg1) { gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_hud_type_C_rank_tiny_font); rsp_load_texture(common_texture_hud_type_C_rank_tiny_font[arg1 + 1], 8, 8); if (spB8 != 0) { - func_80042330_portrait(spD0 + 0x26, (spC4 + spCC) + 4, 0U, 1.0f, lapCount); + func_80042330_unchanged(spD0 + 0x26, (spC4 + spCC) + 4, 0U, 1.0f, lapCount); } else { - func_80042330_portrait(spD0 + 0x1B, (spC4 + spCC) + 4, 0U, 1.0f, lapCount); + func_80042330_unchanged(spD0 + 0x1B, (spC4 + spCC) + 4, 0U, 1.0f, lapCount); } gSPDisplayList(gDisplayListHead++, D_0D006950); if ((player == gPlayerOne) && (gScreenModeSelection == SCREEN_MODE_1P)) { diff --git a/src/render_objects.h b/src/render_objects.h index 61ec7d80b..f27730b6e 100644 --- a/src/render_objects.h +++ b/src/render_objects.h @@ -217,7 +217,7 @@ void func_8004C024(s16, s16, s16, u16, u16, u16, u16); void func_8004C148(s16, s16, s16, u16, u16, u16, u16); void func_8004C354(void); void func_8004C35C(void); -void draw_hud_2d_texture(s32, s32, u32, u32, u8*); +void draw_hud_2d_texture_wide(s32, s32, u32, u32, u8*); void func_8004C450(s32, s32, u32, u32, u8*); void func_8004C53C(s32, s32, u32, u32, u8*); void func_8004C628(s32, s32, u32, u32, u8*); @@ -296,7 +296,7 @@ void func_8004ED40(s32); void func_8004EE54(s32); void func_8004EF9C(s32); -void func_8004F020(s32); +void set_minimap_finishline_position(s32); void func_8004F168(s32, s32, s32); void func_8004F3E4(s32); s32 func_8004F674(s32*, s32); diff --git a/src/save.c b/src/save.c index 9c5a7e698..607e4b1a3 100644 --- a/src/save.c +++ b/src/save.c @@ -567,7 +567,7 @@ s32 validate_save_data_checksum_backup(void) { // Check if controller has a Controller Pak connected. // Return PAK if it does, otherwise return NO_PAK. s32 check_for_controller_pak(s32 controller) { - u8 controllerBitpattern; + u8 controllerBitpattern = 0; UNUSED s32 phi_v0; if ((controller >= MAXCONTROLLERS) || (controller < 0)) {