Widescreen progress

This commit is contained in:
Niko 2023-04-08 17:12:35 -04:00
parent 41939ee632
commit 3bdb6522a4
4 changed files with 308 additions and 4 deletions

View File

@ -18,10 +18,20 @@ common, exe, DecalHUD_DrawPolyGT4, 0x0, src/hookPolyGT4.s
common, exe, DotLights_AudioAndVideo, 0x0, src/hookDotLights.s
common, exe, UI_Map_DrawMap, 0x0, src/UI_Map_DrawMap.c
common, exe, UI_DrawSlideMeter, 0x0, src/UI_DrawSlideMeter.c
common, exe, UI_Map_GetIconPos, 0x0, src/UI_Map_GetIconPos.c
common, exe, TileView_UpdateFrustum, 0x0, src/TileView_UpdateFrustum.c
// note to self, still need UI_DrawRankedDrivers,
// squish 11 functions
// all decompile folder except for: UI_DrawSlideMeter, UI_DrawSpeedBG, UI_DrawSpeedNeedle
common, exe, UI_DrawNumWumpa, 0x0, ../../../Decompile/General/UI/UI_DrawNumWumpa.c ../../../Decompile/General/UI/UI_DrawNumKey.c ../../../Decompile/General/UI/UI_DrawNumRelic.c ../../../Decompile/General/UI/UI_DrawNumTrophy.c ../../../Decompile/General/UI/UI_DrawNumCrystal.c ../../../Decompile/General/UI/UI_DrawNumTimebox.c src/UI_DrawSpeedBG.c src/UI_DrawSpeedNeedle.c ../../../Decompile/General/UI/UI_JumpMeter_Draw.c ../../../Decompile/General/UI/UI_JumpMeter_Update.c src/UI_DrawSlideMeter.c, UI_ElevenFuncs.bin
// Requierd for relocated 11 UI functions
common, exe, UI_RenderFrame_Racing, 0x0, ../../../Decompile/General/UI/UI_RenderFrame_Racing.c
common, exe, UI_RenderFrame_AdvHub, 0x0, ../../../Decompile/General/UI/UI_RenderFrame_AdvHub.c
common, exe, UI_RenderFrame_CrystChall, 0x0, ../../../Decompile/General/UI/UI_RenderFrame_CrystChall.c
common, 232, AH_Map_Main, 0x0, ../../../Decompile/General/232/232_24_AH_Map_Main.c
// === Vertical 2P (USA only) ===
// combined above

View File

@ -20,9 +20,6 @@ void DECOMP_UI_DrawSlideMeter(short posX, short posY, struct Driver* driver)
// replace every 0x31 with 37(dec)
// also move everything 0x31/2 pixels left
// also, force dont draw speedometer
sdata->HudAndDebugFlags &= ~8;
meterLength = 0;
// height of bar in 1P or 2P

View File

@ -0,0 +1,151 @@
#include <common.h>
// at bottom of file
extern unsigned short DrawSpeedBG_Colors[6*2];
// speedometer background
void DECOMP_UI_DrawSpeedBG(void)
{
struct GameTracker* gGT;
u_int color_gradient0, color_gradient1;
u_long* ot;
POLY_G4 *p;
short* vertData;
short* upperHalf;
struct DB* backDB;
int i;
gGT = sdata->gGT;
vertData = &data.speedometerBG_vertData;
upperHalf = &vertData[0x1c];
backDB = gGT->backBuffer;
for (i = 0; i < 7; i++)
{
// white
CTR_Box_DrawWirePrims(
upperHalf[0] + 0x1e0, upperHalf[1] + 0xbe,
upperHalf[2] + 0x1e0, upperHalf[3] + 0xbe,
0xff, 0xff, 0xff,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
// black
CTR_Box_DrawWirePrims(
upperHalf[0] + 0x1e1, upperHalf[1] + 0xbf,
upperHalf[2] + 0x1e1, upperHalf[3] + 0xbf,
0, 0, 0,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
upperHalf += 4;
}
for (i = 0; i < 6; i++)
{
// white
CTR_Box_DrawWirePrims(
vertData[0] + 0x1e0, vertData[1] + 0xbe,
vertData[4] + 0x1e0, vertData[5] + 0xbe,
0xff, 0xff, 0xff,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
// white
CTR_Box_DrawWirePrims(
vertData[2] + 0x1e0, vertData[3] + 0xbe,
vertData[6] + 0x1e0, vertData[7] + 0xbe,
0xff, 0xff, 0xff,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
// black
CTR_Box_DrawWirePrims(
vertData[0] + 0x1e1, vertData[1] + 0xbf,
vertData[4] + 0x1e1, vertData[5] + 0xbf,
0, 0, 0,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
// black
CTR_Box_DrawWirePrims(
vertData[2] + 0x1e1, vertData[3] + 0xbf,
vertData[6] + 0x1e1, vertData[7] + 0xbf,
0, 0, 0,
gGT->tileView_UI.ptrOT,
&backDB->primMem);
// reset prim
p = backDB->primMem.curr;
if (p > (u_long *)backDB->primMem.endMin100)
return;
backDB->primMem.curr = p + 1;
color_gradient0 = DrawSpeedBG_Colors[i*2 + 0];
color_gradient1 = DrawSpeedBG_Colors[i*2 + 1];
*(int*)&p->r0 = color_gradient0; // RGB0
*(int*)&p->r1 = color_gradient0; // RGB1
*(int*)&p->r2 = color_gradient1; // RGB2
*(int*)&p->r3 = color_gradient1; // RGB3
setPolyG4(p);
setXY4(p,
vertData[0] + 0x1e0, vertData[1] + 0xbe,
vertData[2] + 0x1e0, vertData[3] + 0xbe,
vertData[4] + 0x1e0, vertData[5] + 0xbe,
vertData[6] + 0x1e0, vertData[7] + 0xbe);
// inline AddPrim
ot = gGT->tileView_UI.ptrOT;
*(int*)p = *ot | 0x8000000;
*ot = (u_int)p & 0xffffff;
vertData += 4;
}
vertData = &data.speedometerBG_vertData;
for (i = 0; i < 6; i++)
{
p = backDB->primMem.curr;
if (p > (u_long *)backDB->primMem.endMin100)
return;
backDB->primMem.curr = p + 1;
setlen(p, 8);
setcode(p, 0xe1);
setRGB0(p, 0, 0xa, 0);
setRGB1(p, 0, 0, 0);
setRGB2(p, 0, 0, 0);
setRGB3(p, 0, 0, 0);
p->pad0 = 0x32;
setXY4(p, 0, 0,
vertData[2] + 0x1e0, vertData[3] + 0xbe,
vertData[6] + 0x1e0, vertData[7] + 0xbe,
data.speedometerBG_vertData[0x1a] + 0x1e0, data.speedometerBG_vertData[3] + 0xbe);
// inline AddPrim
ot = gGT->tileView_UI.ptrOT;
*(int*)p = *ot | 0x8000000;
*ot = (u_int)p & 0xffffff;
vertData += 4;
}
return;
}
#define SPEEDO_GREEN 0xb500
#define SPEEDO_YELLOW 0xd1ff
#define SPEEDO_RED 0xdb
unsigned short DrawSpeedBG_Colors[6*2] =
{
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_GREEN, SPEEDO_YELLOW,
SPEEDO_YELLOW, SPEEDO_RED,
SPEEDO_RED, SPEEDO_RED,
SPEEDO_RED, SPEEDO_RED
};

View File

@ -0,0 +1,146 @@
#include <common.h>
int MapToRange(int, int, int, int, int);
int MATH_Cos(int);
int MATH_Sin(int);
void DECOMP_UI_DrawSpeedNeedle(short posX, short posY, struct Driver * driver)
{
struct GameTracker* gGT;
short needle;
int angle1;
int angle2;
u_long*primmemCurr;
struct DB* backDB;
int scale;
int length;
int ratio;
int minRange;
int maxRange;
int minScale;
int maxScale;
int speed;
int iVar9;
POLY_G3* p;
gGT = sdata->gGT;
backDB = gGT->backBuffer;
scale = driver->const_SpeedometerScale_ClassStat;
iVar9 = scale << 0x10;
maxScale = scale + driver->const_SacredFireSpeed >> 8;
speed = driver->unk36E << 0x10; // is this actually speed?
minScale = 0;
iVar9 = iVar9 >> 0x18;
if (scale < speed >> 0x10) {
maxRange = 0x700;
minRange = 0x980;
minScale = (iVar9 * 0x1a5e0) / 64000;
} else {
maxRange = 0x980;
minRange = 0xd90;
maxScale = iVar9;
}
// Map value from [oldMin, oldMax] to [newMin, newMax]
// inverting newMin and newMax will give an inverse range mapping
needle = MapToRange(((speed >> 0x18) * 0x1a5e0) / 64000, minScale, (maxScale * 0x1a5e0) / 64000, minRange, maxRange);
angle1 = needle;
angle2 = angle1 + 0x400;
// PrimMem ptrCurrent
primmemCurr = backDB->primMem.curr;
p = 0;
// trigonometry lookup table
int cos[2] = {MATH_Cos(angle1), MATH_Cos(angle2)};
int sin[2] = {MATH_Sin(angle1), MATH_Sin(angle2)};
// if there is room for more
if (primmemCurr <= (u_long*) backDB->primMem.endMin100) {
// increment prim pointer
backDB->primMem.curr = primmemCurr + 7;
p = (POLY_G3*) primmemCurr;
}
if (p == 0) return;
setPolyG3(p);
setRGB0(p, 0x5b, 0x5b, 0);
setRGB1(p, 0x32, 0x2b, 1);
setRGB2(p, 0xff, 0xbb, 0);
ratio = ((cos[1] << 2) >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x2 = posX + (sin[1] * 3 >> 0xb) + 0x41;
p->y2 = posY + (ratio >> 9) + 0x29;
ratio = (cos[0] * 3 >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x1 = posX - ((sin[0] * 3 >> 0xb) + -0x41);
p->y1 = posY - ((ratio >> 9) + -0x29);
ratio = (cos[0] * 0x1e >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x0 = posX + (sin[0] * 0x1e >> 0xb) + 0x41;
p->y0 = posY + (ratio >> 9) + 0x29;
// pointer to OT memory
primmemCurr = gGT->tileView_UI.ptrOT;
*(int *)p = *primmemCurr | 0x6000000;
*primmemCurr = (u_int) p & 0xffffff;
// PrimMem ptrCurrent
primmemCurr = backDB->primMem.curr;
p = 0;
// if there is room for more
if (primmemCurr <= (u_long*) backDB->primMem.endMin100) {
// increment prim pointer
backDB->primMem.curr = primmemCurr + 7;
p = (POLY_G3*) primmemCurr;
}
if (p == 0) return;
setPolyG3(p);
setRGB0(p, 0xff, 0xff, 0xff);
setRGB1(p, 0x9c, 0x69, 0);
setRGB2(p, 0xff, 0xff, 0);
ratio = ((cos[1] << 2) >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x2 = posX - ((sin[1] * 3 >> 0xb) + -0x41);
p->y2 = posY - ((ratio >> 9) + -0x29);
ratio = (cos[0] * 3 >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x1 = posX - ((sin[0] * 3 >> 0xb) + -0x41);
p->y1 = posY - ((ratio >> 9) + -0x29);
ratio = (cos[0] * 0x1e >> 0xb) * 0x140;
if (ratio < 0) {
ratio += 0x1ff;
}
p->x0 = posX + ((sin[0] * 0x1e >> 0xb) + 0x41);
p->y0 = posY + ((ratio >> 9) + 0x29);
// pointer to OT memory
primmemCurr = gGT->tileView_UI.ptrOT;
*(int *)p = *primmemCurr | 0x6000000;
*primmemCurr = (u_int) p & 0xffffff;
return;
}