diff --git a/decompile/General/AltMods/Mods1.c b/decompile/General/AltMods/Mods1.c index f84d5fe78..21a1813dc 100644 --- a/decompile/General/AltMods/Mods1.c +++ b/decompile/General/AltMods/Mods1.c @@ -8,6 +8,21 @@ #include "OnlineCTR/debugcam.c" #include "OnlineCTR/lapData.c" #include "OnlineCTR/names3d.c" + +void StatsUpgrade() +{ + /* + Stat 9 is acceleration, + Stats 11 and 12 speed related + */ + for (int i = 9; i < 13; i++) + { + for (int j = 0; j < 4; j++) + { + data.metaPhys[i].value[j] = data.metaPhys[i].value[4]; // copy MAX + } + } +} #endif #endif diff --git a/decompile/General/AltMods/Mods2.c b/decompile/General/AltMods/Mods2.c index 5803c5270..f2e6c6c90 100644 --- a/decompile/General/AltMods/Mods2.c +++ b/decompile/General/AltMods/Mods2.c @@ -1,5 +1,140 @@ // used for 16x9 (part 1) // used for oxide +#include + +#ifdef USE_ONLINE +Color HsvToRgb(int h, int s, int v); +#endif + +#ifdef USE_BOOSTBAR +void DrawBoostBar(short posX, short posY, struct Driver* driver) +{ + #ifdef USE_ONLINE + const int numberBarDivisions = 5; + const Color barEmptyColor = MakeColor(0x80, 0x80, 0x80); + #endif + + struct GameTracker * gGT = sdata->gGT; + short fullHeight = 3; + #ifdef USE_ONLINE + short fullWidth = WIDE_34(96); + int numBarsFilled = driver->reserves / SECONDS(1); + int numFullBarsFilled = driver->reserves / SECONDS(5); + int reserveLength = driver->reserves % SECONDS(5); + int meterLength = (fullWidth * reserveLength) / SECONDS(5); + posX += 35; + #else + short fullWidth = WIDE_34(49); + short meterLength = ((driver->reserves * 0xE)/0x960); + if ((meterLength > fullWidth) || (driver->reserves < 0)) { meterLength = fullWidth; } + #endif + + RECT box; + short topX = posX - fullWidth; + short topY = posY - fullHeight; + box.x = topX; + box.y = topY; + box.w = fullWidth; + box.h = fullHeight; + + struct DB * backDB = gGT->backBuffer; + + DECOMP_CTR_Box_DrawWireBox(&box, MakeColor(0, 0, 0), gGT->pushBuffer_UI.ptrOT); + + #ifdef USE_ONLINE + int spacing = fullWidth / numberBarDivisions; + int remainder = fullWidth % numberBarDivisions; + for (int i = 0; i < numberBarDivisions - 1; i++) + { + LineF2 * p; + GetPrimMem(p); + if (p == nullptr) { return; } + + const PrimCode primCode = { .line = { .renderCode = RenderCode_Line } }; + const Color colorCode = MakeColorCode(0, 0, 0, primCode); + p->colorCode = colorCode; + s16 xPos = posX - (spacing * (i + 1)); + if (remainder > 0) { xPos--; remainder--; } + p->v[0].pos.x = xPos; + p->v[0].pos.y = topY; + p->v[1].pos.x = xPos; + p->v[1].pos.y = topY + fullHeight; + AddPrimitive(p, gGT->pushBuffer_UI.ptrOT); + } + #endif + + const PrimCode primCode = { .poly = { .quad = 1, .renderCode = RenderCode_Polygon } }; + + #ifdef USE_ONLINE + char barNumberStr[2]; + int strLen = 2; + if (numFullBarsFilled < 10) + { + barNumberStr[0] = (numFullBarsFilled % 10) + '0'; + strLen--; + } + else + { + barNumberStr[0] = (numFullBarsFilled / 10) + '0'; + barNumberStr[1] = (numFullBarsFilled % 10) + '0'; + } + DECOMP_DecalFont_DrawLineStrlen(barNumberStr, strLen, topX - 2, topY - 3, FONT_SMALL, PENTA_WHITE | JUSTIFY_RIGHT); + + ColorCode colorCode; + ColorCode bgBarColor = barEmptyColor; + if (numFullBarsFilled > 0) { bgBarColor = HsvToRgb(5 * numberBarDivisions * (numFullBarsFilled - 1), (int)(255 * 0.5), (int)(255 * 0.5)); } + colorCode = HsvToRgb(5 * numBarsFilled, (int)(255 * 0.9), (int)(255 * 1.0)); + colorCode.code = primCode; + bgBarColor.code = primCode; + #else + /* === BoostBar === + red: 0-2s + yellow: 2s-4s + green: 4s-full + blue: full-saffi + purple: saffi */ + ColorCode colorCode = MakeColorCode(0xFF, 0, 0, primCode); // red + if (driver->reserves < 0) { + colorCode = MakeColorCode(0xFF, 0x0, 0xFF, primCode); // purple + } + else if (meterLength == fullWidth) { + colorCode = MakeColorCode(0, 0, 0xFF, primCode); // blue + } + else if (driver->reserves >= SECONDS(4)) { + colorCode = MakeColorCode(0, 0xFF, 0, primCode); // green + } + else if (driver->reserves >= SECONDS(2)) { + colorCode = MakeColorCode(0xFF, 0xFF, 0, primCode); // yellow + } + #endif + + for (int i = 0; i < 2; i++) + { + PolyF4 * p; + GetPrimMem(p); + if (p == nullptr) { return; } + + p->colorCode = colorCode; + p->v[0].pos.x = posX - meterLength; + p->v[0].pos.y = topY; + p->v[1].pos.x = posX; + p->v[1].pos.y = topY; + p->v[2].pos.x = posX - meterLength; + p->v[2].pos.y = posY; + p->v[3].pos.x = posX; + p->v[3].pos.y = posY; + AddPrimitive(p, gGT->pushBuffer_UI.ptrOT); + + #ifdef USE_ONLINE + colorCode = bgBarColor; + #else + colorCode = MakeColorCode(0x80, 0x80, 0x80, primCode); // Gray color for Prim #2 + #endif + meterLength = fullWidth; + } +} +#endif + #ifdef USE_16BY9 void ui16by9_ViewProj(struct PushBuffer* pb) { diff --git a/decompile/General/AltMods/Mods4.c b/decompile/General/AltMods/Mods4.c index 7e9293ad1..e69de29bb 100644 --- a/decompile/General/AltMods/Mods4.c +++ b/decompile/General/AltMods/Mods4.c @@ -1,90 +0,0 @@ -#include - -#ifdef USE_ONLINE -void StatsUpgrade() -{ - /* - Stat 9 is acceleration, - Stats 11 and 12 speed related - */ - for (int i = 9; i < 13; i++) - { - for (int j = 0; j < 4; j++) - { - data.metaPhys[i].value[j] = data.metaPhys[i].value[4]; // copy MAX - } - } -} -#endif - -#ifdef USE_BOOSTBAR -void DrawBoostBar(short posX, short posY, struct Driver* driver) -{ - struct GameTracker * gGT = sdata->gGT; - - short fullHeight = 3; - int fullWidth = WIDE_34(49); - - short meterLength = ((driver->reserves * 0xE)/0x960); - if ((meterLength > fullWidth) || (driver->reserves < 0)) { meterLength = fullWidth; } - - RECT box; - box.x = posX - fullWidth; - box.y = posY - fullHeight; - box.w = fullWidth; - box.h = fullHeight; - - struct DB * backDB = gGT->backBuffer; - - DECOMP_CTR_Box_DrawWireBox( - &box, MakeColor(0, 0, 0), - gGT->pushBuffer_UI.ptrOT); - - int topY = posY - fullHeight; - - /* === BoostBar === - red: 0-2s - yellow: 2s-4s - green: 4s-full - blue: full-saffi - purple: saffi */ - - PrimCode primCode = { .poly = { .quad = 1, .renderCode = RenderCode_Polygon } }; - ColorCode colorCode = MakeColorCode(0xFF, 0, 0, primCode); // red - - if (driver->reserves < 0) { - colorCode = MakeColorCode(0xFF, 0x0, 0xFF, primCode); // purple - } - else if (meterLength == fullWidth) { - colorCode = MakeColorCode(0, 0, 0xFF, primCode); // blue - } - else if (driver->reserves >= SECONDS(4)) { - colorCode = MakeColorCode(0, 0xFF, 0, primCode); // green - } - else if (driver->reserves >= SECONDS(2)) { - colorCode = MakeColorCode(0xFF, 0xFF, 0, primCode); // yellow - } - - for (int i = 0; i < 2; i++) - { - PolyF4 * p; - GetPrimMem(p); - if (p == nullptr) { return; } - - p->colorCode = colorCode; - p->v[0].pos.x = posX - meterLength; - p->v[0].pos.y = topY; - p->v[1].pos.x = posX; - p->v[1].pos.y = topY; - p->v[2].pos.x = posX - meterLength; - p->v[2].pos.y = posY; - p->v[3].pos.x = posX; - p->v[3].pos.y = posY; - AddPrimitive(p, gGT->pushBuffer_UI.ptrOT); - - // Gray color for Prim #2 - colorCode = MakeColorCode(0x80, 0x80, 0x80, primCode); - meterLength = fullWidth; - } -} -#endif \ No newline at end of file diff --git a/decompile/General/AltMods/Mods7.c b/decompile/General/AltMods/Mods7.c index e69de29bb..b1bc3d4e6 100644 --- a/decompile/General/AltMods/Mods7.c +++ b/decompile/General/AltMods/Mods7.c @@ -0,0 +1,50 @@ +#ifdef USE_BOOSTBAR +#ifdef USE_ONLINE + +Color HsvToRgb(int h, int s, int v) +{ + Color rgb; + h = h & 0xFF; // modulo 256 + int region, remainder, p, q, t; + + if (s == 0) + { + rgb.r = v; + rgb.g = v; + rgb.b = v; + return rgb; + } + + region = h / 43; + remainder = (h - (region * 43)) * 6; + + p = (v * (255 - s)) >> 8; + q = (v * (255 - ((s * remainder) >> 8))) >> 8; + t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8; + + switch (region) + { + case 0: + rgb.r = v; rgb.g = t; rgb.b = p; + break; + case 1: + rgb.r = q; rgb.g = v; rgb.b = p; + break; + case 2: + rgb.r = p; rgb.g = v; rgb.b = t; + break; + case 3: + rgb.r = p; rgb.g = q; rgb.b = v; + break; + case 4: + rgb.r = t; rgb.g = p; rgb.b = v; + break; + default: + rgb.r = v; rgb.g = p; rgb.b = q; + break; + } + + return rgb; +} +#endif +#endif \ No newline at end of file diff --git a/decompile/General/AltMods/OnlineCTR/states.c b/decompile/General/AltMods/OnlineCTR/states.c index f6bd1b5aa..8d721cc9b 100644 --- a/decompile/General/AltMods/OnlineCTR/states.c +++ b/decompile/General/AltMods/OnlineCTR/states.c @@ -206,8 +206,11 @@ void StatePS1_Lobby_WaitForLoading() FONT_SMALL,JUSTIFY_CENTER|ORANGE); } +static bool initRace = true; + void StatePS1_Lobby_StartLoading() { + initRace = true; PrintCharacterStats(); PrintRecvTrack(); @@ -295,7 +298,6 @@ static void Ghostify() extern struct CheckpointTracker checkpointTracker[8]; extern unsigned int checkpointTimes[(MAX_LAPS * CPS_PER_LAP) + 1]; -static bool initRace = true; extern int bestLap; static void OnRaceInit() @@ -348,7 +350,7 @@ void StatePS1_Game_WaitForRace() DECOMP_RECTMENU_DrawInnerRect( &drawTimeRECT, 1, gGT->backBuffer->otMem.startPlusFour); - + for(i = 0; i < 8; i++) { octr->Shoot[i].boolNow = 0; @@ -361,26 +363,26 @@ void StatePS1_Game_StartRace() { int i; Ghostify(); - + for(i = 1; i < 8; i++) { if(octr->Shoot[i].boolNow != 0) { octr->Shoot[i].boolNow = 0; - + struct Driver* d = sdata->gGT->drivers[i]; - + if(octr->Shoot[i].boolJuiced) d->numWumpas = 10; - + d->heldItemID = octr->Shoot[i].Weapon; - + // copy/paste from ShootOnCirclePress int weapon; weapon = d->heldItemID; - + // Missiles and Bombs share code, - // Change Bomb1x, Bomb3x, Missile3x, to Missile1x + // Change Bomb1x, Bomb3x, Missile3x, to Missile1x if( (weapon == 1) || (weapon == 10) || @@ -389,10 +391,10 @@ void StatePS1_Game_StartRace() { weapon = 2; } - + DECOMP_VehPickupItem_ShootNow( - d, - weapon, + d, + weapon, octr->Shoot[i].flags); } } @@ -400,5 +402,4 @@ void StatePS1_Game_StartRace() void StatePS1_Game_EndRace() { - initRace = true; } \ No newline at end of file diff --git a/decompile/General/UI/UI_DrawSlideMeter.c b/decompile/General/UI/UI_DrawSlideMeter.c index da4807851..291536e7c 100644 --- a/decompile/General/UI/UI_DrawSlideMeter.c +++ b/decompile/General/UI/UI_DrawSlideMeter.c @@ -3,8 +3,15 @@ void DECOMP_UI_DrawSlideMeter(short posX, short posY, struct Driver* driver) { const struct GameTracker * gGT = sdata->gGT; - int barWidth = WIDE_PICK(0x31, 0x25); + int barWidth = WIDE_34(49); + #ifdef USE_ONLINE + const int xOffset = 2; + int barHeight = 10; + posX += xOffset; + barWidth += xOffset; + #else int barHeight = gGT->numPlyrCurrGame > 2 ? 3 : 7; + #endif int meterLength = 0; if (driver->turbo_MeterRoomLeft != 0) { @@ -54,6 +61,10 @@ void DECOMP_UI_DrawSlideMeter(short posX, short posY, struct Driver* driver) #ifdef USE_BOOSTBAR void DrawBoostBar(short posX, short posY, struct Driver* driver); - DrawBoostBar(posX, posY+5, driver); + #ifdef USE_ONLINE + DrawBoostBar(posX - xOffset, posY + 5, driver); + #else + DrawBoostBar(posX, posY + 5, driver); + #endif #endif } \ No newline at end of file diff --git a/decompile/General/UI/UI_DrawSpeedNeedle.c b/decompile/General/UI/UI_DrawSpeedNeedle.c index 6c48fdf23..a5d63240d 100644 --- a/decompile/General/UI/UI_DrawSpeedNeedle.c +++ b/decompile/General/UI/UI_DrawSpeedNeedle.c @@ -5,7 +5,9 @@ void DECOMP_UI_DrawSpeedNeedle(short posX, short posY, struct Driver * driver) int minScale = 0; #ifdef USE_ONLINE int maxScale = 100; // USF - int speed = MATH_FastSqrt((driver->xSpeed * driver->xSpeed) + (driver->zSpeed * driver->zSpeed), 0); + int speed = driver->kartState == KS_ENGINE_REVVING ? + driver->unk36E : + MATH_FastSqrt((driver->xSpeed * driver->xSpeed) + (driver->zSpeed * driver->zSpeed), 0); #else int maxScale = FP8_INT(driver->const_AccelSpeed_ClassStat) + FP8_INT(driver->const_SacredFireSpeed); int speed = driver->unk36E; // is this actually speed? diff --git a/decompile/General/UI/UI_RenderFrame_Racing.c b/decompile/General/UI/UI_RenderFrame_Racing.c index 9a6430f7c..9caaa5947 100644 --- a/decompile/General/UI/UI_RenderFrame_Racing.c +++ b/decompile/General/UI/UI_RenderFrame_Racing.c @@ -214,8 +214,8 @@ void DECOMP_UI_RenderFrame_Racing() { #ifdef USE_ONLINE DECOMP_UI_DrawSpeedNeedle(hudStructPtr[9].x + offset, hudStructPtr[9].y, playerStruct); - DECOMP_UI_DrawSlideMeter(hudStructPtr[8].x + offset - 8, hudStructPtr[8].y, playerStruct); - DECOMP_UI_JumpMeter_Draw(hudStructPtr[8].x + offset + 17, hudStructPtr[8].y - 7, playerStruct); + DECOMP_UI_DrawSlideMeter(hudStructPtr[8].x + offset - 8, hudStructPtr[8].y + 3, playerStruct); + DECOMP_UI_JumpMeter_Draw(hudStructPtr[8].x + offset + 18, hudStructPtr[8].y - 7, playerStruct); DECOMP_UI_DrawSpeedBG(); #else DECOMP_UI_DrawSpeedNeedle(hudStructPtr[9].x + offset, hudStructPtr[9].y, playerStruct); @@ -232,7 +232,7 @@ void DECOMP_UI_RenderFrame_Racing() if ((gameMode1 & BATTLE_MODE) == 0) { #ifdef USE_ONLINE - DECOMP_UI_DrawSlideMeter(hudStructPtr[8].x + offset - 8, hudStructPtr[8].y, playerStruct); + DECOMP_UI_DrawSlideMeter(hudStructPtr[8].x + offset - 8, hudStructPtr[8].y + 3, playerStruct); #else // Draw powerslide meter DECOMP_UI_DrawSlideMeter(hudStructPtr[8].x + offset, hudStructPtr[8].y, playerStruct); diff --git a/include/common.h b/include/common.h index 06bd672a5..435614eb9 100644 --- a/include/common.h +++ b/include/common.h @@ -16,7 +16,7 @@ //#define USE_BIGQUEUE // Requires RAMEX: Extended loading queue //#define USE_HIGH1P // Requires BIGQUEUE: All high model drivers //#define USE_RANDOM // Requires HIGH1P: Character Randomizer -#define USE_ONLINE // Requires HIGH1P: Online Multiplayer +//#define USE_ONLINE // Requires HIGH1P: Online Multiplayer //#define USE_HIGHMP // Requires RAMEX: Multiplayer Maxed mod //#define USE_VR // Virtual Reality