Skip to content

Commit

Permalink
Merge pull request #164 from mateusfavarin/main
Browse files Browse the repository at this point in the history
Rewrite DebugFont, fix WIDE_34 macro, mods cleanup
  • Loading branch information
mateusfavarin authored Jun 28, 2024
2 parents 318cd50 + 99a5017 commit 15f2f57
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 104 deletions.
5 changes: 3 additions & 2 deletions decompile/General/AltMods/Mods1.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include "OnlineCTR/menu.c"
#include "OnlineCTR/states.c"
#include "OnlineCTR/thread.c"
#include "OnlineCTR/zMirrorMode.c"
#include "OnlineCTR/speedometerData.c"
#include "OnlineCTR/debugcam.c"
#include "OnlineCTR/lapData.c"
#include "OnlineCTR/names3d.c"
#endif
#endif

Expand Down
5 changes: 0 additions & 5 deletions decompile/General/AltMods/Mods2.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// used for 16x9 (part 1)
// used for oxide
#ifdef USE_ONLINE
#include "OnlineCTR/debugcam.c"
#include "OnlineCTR/lapData.c"
#endif

#ifdef USE_16BY9
void ui16by9_ViewProj(struct PushBuffer* pb)
{
Expand Down
6 changes: 2 additions & 4 deletions decompile/General/AltMods/Mods4.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include <common.h>

#ifdef USE_ONLINE
#include "OnlineCTR/names3d.c"

void statsUpgrade()
void StatsUpgrade()
{
/*
Stat 9 is acceleration,
Expand All @@ -25,7 +23,7 @@ void DrawBoostBar(short posX, short posY, struct Driver* driver)
struct GameTracker * gGT = sdata->gGT;

short fullHeight = 3;
int fullWidth = WIDE_PICK(0x31, 0x25);
int fullWidth = WIDE_34(49);

short meterLength = ((driver->reserves * 0xE)/0x960);
if ((meterLength > fullWidth) || (driver->reserves < 0)) { meterLength = fullWidth; }
Expand Down
2 changes: 1 addition & 1 deletion decompile/General/AltMods/ModsMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void ModsMain()

#ifdef USE_ONLINE
void octr_entryHook(); octr_entryHook();
void statsUpgrade(); statsUpgrade();
void StatsUpgrade(); StatsUpgrade();
#endif

// PC port has unlimited byte budget
Expand Down
47 changes: 0 additions & 47 deletions decompile/General/AltMods/OnlineCTR/speedometerData.c

This file was deleted.

45 changes: 43 additions & 2 deletions decompile/General/DebugFont/DebugFont_DrawNumbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,48 @@

void DECOMP_DebugFont_DrawNumbers(int index, int screenPosX, int screenPosY)
{
unsigned short uVar1;
PolyFT4 * p;
GetPrimMem(p);
if (p == nullptr) { return; }

const int fontWidth = WIDE_34(7);
const int fontHeight = 7;

const PrimCode primCode = { .poly = { .renderCode = RenderCode_Polygon, .quad = 1, .textured = 1, .semiTransparency = 1 } };
p->colorCode = MakeColorCode(0, 0, 0, primCode);

s16 topX = screenPosX;
s16 bottomX = topX + fontWidth;
s16 topY = screenPosY;
s16 bottomY = topY + fontHeight;
p->v[0].pos.x = topX;
p->v[0].pos.y = topY;
p->v[1].pos.x = bottomX;
p->v[1].pos.y = topY;
p->v[2].pos.x = topX;
p->v[2].pos.y = bottomY;
p->v[3].pos.x = bottomX;
p->v[3].pos.y = bottomY;

/* Each character is 7x7 pixels,
'0' is 6th character on 2nd row */
u8 topU = sdata->debugFont.u + 7 * 5 + index * 7;
u8 bottomU = topU + 7;
u8 topV = sdata->debugFont.v + 7;
u8 bottomV = topV + 7;
p->v[0].texCoords.u = topU;
p->v[0].texCoords.v = topV;
p->v[1].texCoords.u = bottomU;
p->v[1].texCoords.v = topV;
p->v[2].texCoords.u = topU;
p->v[2].texCoords.v = bottomV;
p->v[3].texCoords.u = bottomU;
p->v[3].texCoords.v = bottomV;
p->polyClut.self = sdata->debugFont.clut;
p->polyTpage.self = sdata->debugFont.tpage;

AddPrimitive(p, sdata->gGT->pushBuffer_UI.ptrOT);
/*unsigned short uVar1;
POLY_FT4* p;
unsigned int *ot;
unsigned int uVar4;
Expand Down Expand Up @@ -37,5 +78,5 @@ void DECOMP_DebugFont_DrawNumbers(int index, int screenPosX, int screenPosY)
p->tpage = sdata->debugFont.tpage;
*(int*)p = *ot | 0x9000000;
*ot = (unsigned int)p & 0xffffff;
*ot = (unsigned int)p & 0xffffff;*/
}
15 changes: 10 additions & 5 deletions decompile/General/DebugFont/DebugFont_Init.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
void DECOMP_DebugFont_Init(struct GameTracker* gGT)
{
struct Icon* debugFontIcon = gGT->ptrIcons[0x42];

if(debugFontIcon == 0) return;

sdata->debugFont.UV = *(short*)&debugFontIcon->texLayout.u0;
sdata->debugFont.clut = debugFontIcon->texLayout.clut;
sdata->debugFont.tpage = debugFontIcon->texLayout.tpage;

u8 u = debugFontIcon->texLayout.u0;
u8 v = debugFontIcon->texLayout.v0;
u16 clut = debugFontIcon->texLayout.clut;
u16 tpage = debugFontIcon->texLayout.tpage;
sdata->debugFont.u = u;
sdata->debugFont.v = v;
sdata->debugFont.clut = clut;
sdata->debugFont.tpage = tpage;
}
2 changes: 1 addition & 1 deletion decompile/General/MAIN/MainFrame_RenderFrame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ void RenderSubmit(struct GameTracker* gGT)

void* ot = &gGT->pushBuffer[0].ptrOT[0x3ff];

#ifdef USE_ONLINE
#if 0 && defined(USE_ONLINE)
void OnlineMirrorMode(u_long* ot);
OnlineMirrorMode(ot);
#endif
Expand Down
2 changes: 1 addition & 1 deletion decompile/General/SubmitName/SubmitName_DrawMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ short DECOMP_SubmitName_DrawMenu(u_short string)
// subtract 1/8 from r.x
// subtract 1/4 from r.w
r.x = WIDE_PICK(32, 88);
r.w = WIDE_PICK(448, 336);
r.w = WIDE_34(448);

r.y = 62;
r.h = 2;
Expand Down
2 changes: 2 additions & 0 deletions decompile/General/UI/UI_AAA_BigBlock1.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <common.h>

#include "../prim.c"
#include "../DebugFont/DebugFont_Init.c"
#include "../DebugFont/DebugFont_DrawNumbers.c"

#ifndef USE_ONLINE
#include "UI_SaveLapTime.c"
Expand Down
66 changes: 45 additions & 21 deletions decompile/General/UI/UI_DrawSpeedBG.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,57 @@

// at bottom of file
#ifdef USE_ONLINE
extern const Color DrawSpeedBG_Colors[11];
extern const Point speedometerData[2][22];
#define SPEEDO_GREEN MakeColor(0, 0xb5, 0)
#define SPEEDO_YELLOW MakeColor(0xdb, 0xb5, 0)
#define SPEEDO_RED MakeColor(0xdb, 0, 0)
#define SPEEDO_PINK MakeColor(0xd8, 0, 0xcb)
#define SPEEDO_PURPLE MakeColor(0xa4, 0x21, 0xff)
#define SPEEDO_BLUE MakeColor(0x18, 0x18, 0xf3)
const Color DrawSpeedBG_Colors[11] =
{
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_GREEN, SPEEDO_YELLOW,
SPEEDO_RED, SPEEDO_RED,
SPEEDO_RED, SPEEDO_PINK,
SPEEDO_PURPLE, SPEEDO_PURPLE,
SPEEDO_BLUE,
};

const Point speedometerData[22] =
{
{ .x = WIDE_34(-65), .y = 16 }, { .x = WIDE_34(-54), .y = 13 },
{ .x = WIDE_34(-70), .y = 0 }, { .x = WIDE_34(-58), .y = 0 },
{ .x = WIDE_34(-65), .y = -16 }, { .x = WIDE_34(-54), .y = -13 },
{ .x = WIDE_34(-50), .y = -29 }, { .x = WIDE_34(-42), .y = -24 },
{ .x = WIDE_34(-25), .y = -39 }, { .x = WIDE_34(-21), .y = -32 },
{ .x = WIDE_34(0), .y = -42 }, { .x = WIDE_34(0), .y = -35 },
{ .x = WIDE_34(25), .y = -39 }, { .x = WIDE_34(21), .y = -32 },
{ .x = WIDE_34(50), .y = -29 }, { .x = WIDE_34(42), .y = -24 },
{ .x = WIDE_34(65), .y = -16 }, { .x = WIDE_34(54), .y = -13 },
{ .x = WIDE_34(70), .y = 0 }, { .x = WIDE_34(58), .y = 0 },
{ .x = WIDE_34(65), .y = 16 }, { .x = WIDE_34(54), .y = 13 },
};
#else
extern const Color DrawSpeedBG_Colors[7];
#define SPEEDO_GREEN MakeColor(0, 0xb5, 0)
#define SPEEDO_YELLOW MakeColor(0xff, 0xd1, 0)
#define SPEEDO_RED MakeColor(0xdb, 0, 0)

const Color DrawSpeedBG_Colors[7] =
{
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_YELLOW, SPEEDO_RED,
SPEEDO_RED,
};
#endif

// speedometer background
void DECOMP_UI_DrawSpeedBG(void)
{
#ifdef USE_ONLINE
Point * vertexes = &speedometerData[0];
Point * vertexesExtLine = &speedometerData[1];
int pointCount = sizeof(speedometerData) / (sizeof(Point) * 2);
Point * vertexes = &speedometerData;
Point * vertexesExtLine = &speedometerData;
int pointCount = len(speedometerData);
const short xOffset = 453;
#else
Point * vertexes = &data.speedometerBG_vertData[0];
Expand Down Expand Up @@ -100,18 +138,4 @@ void DECOMP_UI_DrawSpeedBG(void)
p->p.v[2].pos.y = p2y;
AddPrimitive(p, sdata->gGT->pushBuffer_UI.ptrOT);
}
}

#ifndef USE_ONLINE
#define SPEEDO_GREEN MakeColor(0, 0xb5, 0)
#define SPEEDO_YELLOW MakeColor(0xff, 0xd1, 0)
#define SPEEDO_RED MakeColor(0xdb, 0, 0)

const Color DrawSpeedBG_Colors[7] =
{
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_GREEN, SPEEDO_GREEN,
SPEEDO_YELLOW, SPEEDO_RED,
SPEEDO_RED,
};
#endif
}
4 changes: 2 additions & 2 deletions decompile/General/UI/UI_JumpMeter_Draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void DECOMP_UI_JumpMeter_Draw(short posX, short posY, struct Driver* driver)
#else
*(u_int *)&p->r0 = 0x28ffffff;
#endif
p->x1 = posX + WIDE_34(0xe);
p->x3 = posX + WIDE_34(0xe);
p->x1 = posX + WIDE_34(13);
p->x3 = posX + WIDE_34(13);
p->x0 = box.x;
p->y0 = box.y;
p->y1 = box.y;
Expand Down
12 changes: 6 additions & 6 deletions decompile/General/zGlobal_DATA.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,9 +1718,9 @@ struct Data data =
.font_charPixWidth =
{
0, // DEBUG (removed)
WIDE_PICK(17, 13), // BIG
WIDE_PICK(13, 10), // SMALL
WIDE_PICK(14, 11), // CREDITS
WIDE_34(17), // BIG
WIDE_34(13), // SMALL
WIDE_34(14), // CREDITS
},

#if BUILD >= UsaRetail
Expand All @@ -1736,9 +1736,9 @@ struct Data data =
.font_puncPixWidth =
{
0, // DEBUG (removed)
WIDE_PICK(11, 8), // BIG
WIDE_PICK(7, 5), // SMALL
WIDE_PICK(11, 8), // CREDITS
WIDE_34(11), // BIG
WIDE_34(7), // SMALL
WIDE_34(11), // CREDITS
},

// starts at ascii 0x21 '!'
Expand Down
8 changes: 4 additions & 4 deletions decompile/buildList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ common, exe, CTR_CycleTex_Model, 0x0, General/CTR/CTR_CycleTex_Model.c
common, exe, CTR_MatrixToRot, 0x0, General/CTR/CTR_MatrixToRot.c

// DebugFont
common, exe, DebugFont_Init, 0x0, General/DebugFont/DebugFont_Init.c General/DebugFont/DebugFont_DrawNumbers.c, DebugFont.bin
//common, exe, DebugFont_Init, 0x0, General/DebugFont/DebugFont_Init.c General/DebugFont/DebugFont_DrawNumbers.c, DebugFont.bin

// DecalFont
common, exe, DecalFont_GetLineWidth, 0x0, General/DecalFont/DecalFont_GetLineWidth.c
Expand Down Expand Up @@ -372,8 +372,8 @@ common, exe, Music_Start, 0x0, General/HOWL/h116_Music_Start.c
common, exe, Music_End, 0x0, General/HOWL/h117_Music_End.c
common, exe, Music_GetHighestSongPlayIndex, 0x0, General/HOWL/h118_Music_GetHighestSongPlayIndex.c

// GTE_AudioLR_Inst
// GTE_AudioLR_Driver
// GTE_AudioLR_Inst
// GTE_AudioLR_Driver
// GTE_GetSquaredLength
common, exe, OtherFX_RecycleNew, 0x0, General/HOWL/h122_OtherFX_RecycleNew.c
// OtherFX_RecycleMute
Expand Down Expand Up @@ -512,7 +512,7 @@ common, exe, MEMCARD_ChecksumLoad, 0x0, General/MEMCARD/MEMCARD_ChecksumLoad.c
common, exe, MEMCARD_StringInit, 0x0, General/MEMCARD/MEMCARD_StringInit.c
common, exe, MEMCARD_StringSet, 0x0, General/MEMCARD/MEMCARD_StringSet.c
common, exe, MEMCARD_InitCard, 0x0, General/MEMCARD/MEMCARD_InitCard.c
common, exe, MEMCARD_CloseCard, 0x0, General/MEMCARD/MEMCARD_CloseCard.c
common, exe, MEMCARD_CloseCard, 0x0, General/MEMCARD/MEMCARD_CloseCard.c
common, exe, MEMCARD_GetNextSwEvent, 0x0, General/MEMCARD/MEMCARD_GetNextSwEvent.c
common, exe, MEMCARD_GetNextHwEvent, 0x0, General/MEMCARD/MEMCARD_GetNextHwEvent.c
common, exe, MEMCARD_WaitForHwEvent, 0x0, General/MEMCARD/MEMCARD_WaitForHwEvent.c
Expand Down
4 changes: 2 additions & 2 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@
// param1 - normal
// param2 - widescreen
#ifdef USE_16BY9
#define WIDE_34(x) (((x)*750)/1000)
#define WIDE_34(x) ((((x)*750) + 500)/1000)
#define WIDE_PICK(x,y) (y)
#else
#define WIDE_34(x) (x)
Expand Down
3 changes: 2 additions & 1 deletion include/regionsEXE.h
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,8 @@ struct sData

#else // had to, we were desperate

short UV;
unsigned char u;
unsigned char v;
short padding[3];

#endif
Expand Down

0 comments on commit 15f2f57

Please sign in to comment.