port: make the legal screen render correctly

also, total errno death in the same commit because I am dumb
This commit is contained in:
fgsfds committed 2023-07-30 21:24:39 +02:00
1 parent da94644c38
commit f91401cb95
41 files changed
+466 -324

No files matched your search

+8 -8
View File
@@ -708,8 +708,8 @@ Gfx *bgRenderGdlInXray(Gfx *gdl, s8 *readgdl, Vtx *vertices, s16 arg3[3])
// empty
} else if (readgdl[0] == G_VTX) {
Gfx *cmd = (Gfx *) readgdl;
s32 dmemindex = cmd->bytes[1] & 0xf;
s32 numvertices = ((u32) cmd->bytes[1] >> 4) + 1;
s32 dmemindex = cmd->bytes[GFX_W0_BYTE(1)] & 0xf;
s32 numvertices = ((u32) cmd->bytes[GFX_W0_BYTE(1)] >> 4) + 1;
u32 offset = cmd->words.w1 & 0xffffff;
for (i = 0; i < numvertices; i++) {
@@ -3608,9 +3608,9 @@ bool bgTestHitOnObj(struct coord *arg0, struct coord *arg1, struct coord *arg2,
break;
} else if (gdl->dma.cmd == G_VTX) {
ptr = var800a6470;
count = gdl->bytes[1] & 0xf;
count = gdl->bytes[GFX_W0_BYTE(1)] & 0xf;
offset = (gdl->words.w1 & 0xffffff);
numvertices = (((u32)gdl->bytes[1] >> 4) & 0xf) + 1;
numvertices = (((u32) gdl->bytes[GFX_W0_BYTE(1)] >> 4) & 0xf) + 1;
vtx = (Vtx *)((uintptr_t)vertices + offset);
vtx -= count;
@@ -3909,9 +3909,9 @@ bool bgTestHitOnChr(struct model *model, struct coord *arg1, struct coord *arg2,
i = word / sizeof(Mtxf);
mtx = &model->matrices[i];
} else if (gdl->dma.cmd == G_VTX) {
count = (gdl->bytes[1] & 0xf);
count = (gdl->bytes[GFX_W0_BYTE(1)] & 0xf);
word = gdl->words.w1 & 0xffffff;
numvertices = ((u32)gdl->bytes[1] >> 4) + 1;
numvertices = ((u32) gdl->bytes[GFX_W0_BYTE(1)] >> 4) + 1;
vtx = (Vtx *)((uintptr_t)vertices + word);
if (count < spdc) {
@@ -4172,7 +4172,7 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a
vtx = bgFindVerticesForGdl(roomnum, gdl);
iter = &gdl[batch->gbicmdindex];
vtx = (Vtx *)((iter->words.w1 & 0xffffff) + (s32)vtx);
numvertices = (((u32)iter->bytes[1] >> 4) & 0xf) + 1;
numvertices = (((u32) iter->bytes[GFX_W0_BYTE(1)] >> 4) & 0xf) + 1;
ptr = var800a6470;
while (numvertices > 0) {
@@ -4302,7 +4302,7 @@ bool bgTestHitInVtxBatch(struct coord *arg0, struct coord *arg1, struct coord *a
tmpgdl = iter;
while (tmpgdl->bytes[0] != G_SETTIMG && tmpgdl > gdl) {
while (tmpgdl->bytes[GFX_W0_BYTE(0)] != G_SETTIMG && tmpgdl > gdl) {
tmpgdl--;
}
+1
View File
@@ -4210,6 +4210,7 @@ void fileLoad(u8 *dst, u32 allocationlen, romptr_t *romaddrptr, struct fileinfo
// byteswap/preprocess file according to g_LoadType right after inflating it
const u32 dstsize = allocationlen ? info->loadedsize : romsize;
romdataFilePreprocess(filenum, g_LoadType, dst, dstsize);
g_LoadType = LOADTYPE_NONE;
#endif
}
+20 -20
View File
@@ -295,7 +295,7 @@ char *filemgrMenuTextFailReason(struct menuitem *item)
L_OPTIONS_330, // "Game note delete failed."
};
return langGet(reasons[g_Menus[g_MpPlayerNum].fm.errno]);
return langGet(reasons[g_Menus[g_MpPlayerNum].fm.errnum]);
}
/**
@@ -314,7 +314,7 @@ MenuItemHandlerResult filemgrDeviceNameForErrorMenuHandler(s32 operation, struct
return true;
}
switch (g_Menus[g_MpPlayerNum].fm.errno) {
switch (g_Menus[g_MpPlayerNum].fm.errnum) {
case FILEERROR_OUTOFMEMORY:
case FILEERROR_ALREADYLOADED:
case FILEERROR_PAKDAMAGED:
@@ -336,7 +336,7 @@ char *filemgrMenuTextDeviceNameForError(struct menuitem *item)
{
sprintf(g_StringPointer, "%s", filemgrGetDeviceName(g_Menus[g_MpPlayerNum].fm.device1 & 0x7f));
if (g_Menus[g_MpPlayerNum].fm.errno != FILEERROR_PAKREMOVED) {
if (g_Menus[g_MpPlayerNum].fm.errnum != FILEERROR_PAKREMOVED) {
s32 i = 0;
while (g_StringPointer[i] != '\0') {
@@ -363,9 +363,9 @@ const char var7f1b3024[] = "MyResult: %d\n";
const char var7f1b3034[] = "PakOperationSearch>> Search for pak: %x = %d\n";
#endif
void filemgrPushErrorDialog(u16 errno)
void filemgrPushErrorDialog(u16 errnum)
{
g_Menus[g_MpPlayerNum].fm.errno = errno;
g_Menus[g_MpPlayerNum].fm.errnum = errnum;
menuPushDialog(&g_FilemgrErrorMenuDialog);
}
@@ -788,7 +788,7 @@ void filemgrRetrySave(s32 context)
bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
{
s32 errno = 0;
s32 errnum = 0;
bool showfilesaved = (g_Menus[g_MpPlayerNum].fm.isretryingsave & 1) != 0;
const s32 filetypes[] = {
@@ -806,18 +806,18 @@ bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
// fall through
case FILEOP_SAVE_GAME_000:
case FILEOP_SAVE_GAME_001:
errno = gamefileSave(device,
errnum = gamefileSave(device,
g_Menus[g_MpPlayerNum].fm.fileid,
g_Menus[g_MpPlayerNum].fm.deviceserial);
break;
case FILEOP_SAVE_MPPLAYER:
errno = mpplayerfileSave(
errnum = mpplayerfileSave(
(s32) g_Menus[g_MpPlayerNum].fm.unke44, device,
g_Menus[g_MpPlayerNum].fm.fileid,
g_Menus[g_MpPlayerNum].fm.deviceserial);
break;
case FILEOP_SAVE_MPSETUP:
errno = mpsetupfileSave(device,
errnum = mpsetupfileSave(device,
g_Menus[g_MpPlayerNum].fm.fileid,
g_Menus[g_MpPlayerNum].fm.deviceserial);
showfilesaved = true;
@@ -829,24 +829,24 @@ bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
#if VERSION >= VERSION_NTSC_1_0
func0f0d5690(g_Menus[g_MpPlayerNum].fm.unke44, g_Menus[g_MpPlayerNum].fm.filename);
#endif
errno = pakSaveAtGuid(device,
errnum = pakSaveAtGuid(device,
g_Menus[g_MpPlayerNum].fm.fileid,
filetypes[g_Menus[g_MpPlayerNum].fm.fileop - 6],
g_Menus[g_MpPlayerNum].fm.unke44, &newfileid, NULL);
var80075bd0[g_Menus[g_MpPlayerNum].fm.fileop - 6] = 1;
break;
case FILEOP_LOAD_GAME:
errno = gamefileLoad(device);
errnum = gamefileLoad(device);
break;
case FILEOP_LOAD_MPPLAYER:
errno = mpplayerfileLoad(
errnum = mpplayerfileLoad(
(s32) g_Menus[g_MpPlayerNum].fm.unke44,
device,
g_Menus[g_MpPlayerNum].fm.fileid,
g_Menus[g_MpPlayerNum].fm.deviceserial);
break;
case FILEOP_LOAD_MPSETUP:
errno = mpsetupfileLoad(device,
errnum = mpsetupfileLoad(device,
g_Menus[g_MpPlayerNum].fm.fileid,
g_Menus[g_MpPlayerNum].fm.deviceserial);
break;
@@ -854,35 +854,35 @@ bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
case FILEOP_READ_MPSETUP:
case FILEOP_READ_MPPLAYER:
#if VERSION >= VERSION_NTSC_1_0
errno = pakReadBodyAtGuid(device, g_Menus[g_MpPlayerNum].fm.fileid, g_Menus[g_MpPlayerNum].fm.unke44, 0);
errnum = pakReadBodyAtGuid(device, g_Menus[g_MpPlayerNum].fm.fileid, g_Menus[g_MpPlayerNum].fm.unke44, 0);
#else
errno = pakReadBodyAtGuid(device, g_Menus[g_MpPlayerNum].fm.fileid, g_Menus[g_MpPlayerNum].fm.unke44,
errnum = pakReadBodyAtGuid(device, g_Menus[g_MpPlayerNum].fm.fileid, g_Menus[g_MpPlayerNum].fm.unke44,
g_FileTypeSizes[g_Menus[g_MpPlayerNum].fm.fileop - FILEOP_READ_GAME]);
#endif
break;
}
if (errno == 0 && closeonsuccess) {
if (errnum == 0 && closeonsuccess) {
menuCloseDialog();
}
if (FILEOP_IS_SAVE(g_Menus[g_MpPlayerNum].fm.fileop)) {
if (errno == 0) {
if (errnum == 0) {
filemgrHandleSuccess();
}
if (showfilesaved && errno == 0) {
if (showfilesaved && errnum == 0) {
menuPushDialog(&g_FilemgrFileSavedMenuDialog);
}
} else {
if (errno == 0) {
if (errnum == 0) {
filemgrHandleSuccess();
}
}
menuUpdateCurFrame();
return errno;
return errnum;
}
#if VERSION >= VERSION_NTSC_1_0
+23 -22
View File
@@ -13,6 +13,7 @@
#include "lib/memp.h"
#include "data.h"
#include "types.h"
#include "platform.h"
#define SPACE_WIDTH 5
@@ -111,38 +112,38 @@ u32 var8007fb34 = 0x00000000;
u32 var8007fb38 = 0x00000000;
u16 var8007fb3c[] = {
0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00,
0xff00, 0xff24, 0xff48, 0xff6c, 0xff90, 0xffb4, 0xffd8, 0xffff,
PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00),
PD_BE16(0xff00), PD_BE16(0xff24), PD_BE16(0xff48), PD_BE16(0xff6c), PD_BE16(0xff90), PD_BE16(0xffb4), PD_BE16(0xffd8), PD_BE16(0xffff),
};
u16 var8007fb5c[] = {
0xff00, 0xff58, 0xff74, 0xff90, 0xffac, 0xffc8, 0xffe4, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
PD_BE16(0xff00), PD_BE16(0xff58), PD_BE16(0xff74), PD_BE16(0xff90), PD_BE16(0xffac), PD_BE16(0xffc8), PD_BE16(0xffe4), PD_BE16(0xffff),
PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff), PD_BE16(0xffff),
};
u16 var8007fb7c[] = {
0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00,
0xff00, 0xff18, 0xff30, 0xff5c, 0xff88, 0xffb4, 0xffd8, 0xffff,
PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00), PD_BE16(0xff00),
PD_BE16(0xff00), PD_BE16(0xff18), PD_BE16(0xff30), PD_BE16(0xff5c), PD_BE16(0xff88), PD_BE16(0xffb4), PD_BE16(0xffd8), PD_BE16(0xffff),
};
#if VERSION == VERSION_JPN_FINAL
u16 var800801d8jf[] = {
0xff00,
0xff11,
0xff22,
0xff33,
0xff44,
0xff55,
0xff66,
0xff77,
0xff88,
0xff99,
0xffaa,
0xffbb,
0xffcc,
0xffdd,
0xffee,
0xffff,
PD_BE16(0xff00),
PD_BE16(0xff11),
PD_BE16(0xff22),
PD_BE16(0xff33),
PD_BE16(0xff44),
PD_BE16(0xff55),
PD_BE16(0xff66),
PD_BE16(0xff77),
PD_BE16(0xff88),
PD_BE16(0xff99),
PD_BE16(0xffaa),
PD_BE16(0xffbb),
PD_BE16(0xffcc),
PD_BE16(0xffdd),
PD_BE16(0xffee),
PD_BE16(0xffff),
};
#endif
+4 -4
View File
@@ -1406,7 +1406,7 @@ s32 _pakCreateCameraFile(s8 device, s32 *outfileid)
bool pakResizeNote(s8 device, s32 numpages)
{
s32 stack1[2];
s32 errno;
s32 errnum;
struct pak *devicedata;
s32 stack2[2];
OSPfsState *note;
@@ -1416,10 +1416,10 @@ bool pakResizeNote(s8 device, s32 numpages)
pakQueryNumFreePages(device);
numbytes = numpages * 256;
errno = _pakResizeNote(PFS(device), ROM_COMPANYCODE, ROM_GAMECODE, g_PakNoteGameName, g_PakNoteExtName, numbytes);
pakHandleResult(errno, device, true, LINE_1802);
errnum = _pakResizeNote(PFS(device), ROM_COMPANYCODE, ROM_GAMECODE, g_PakNoteGameName, g_PakNoteExtName, numbytes);
pakHandleResult(errnum, device, true, LINE_1802);
if (errno == PAK_ERR1_OK) {
if (errnum == PAK_ERR1_OK) {
devicedata = &g_Paks[device];
note = &devicedata->pakdata.notes[devicedata->pdnoteindex];
+1 -1
View File
@@ -978,7 +978,7 @@ s32 texLoadFromGdl(Gfx *arg0, s32 gdlsizeinbytes, Gfx *arg2, struct texpool *poo
Vtx *vtx;
if (spe0) {
start = s5->bytes[1] & 0xf;
start = s5->bytes[GFX_W0_BYTE(1)] & 0xf;
count = s5->vtx.unk08 + 1;
vtx = (Vtx *)(s5->dma.addr & 0x00ffffff);
+5 -3
View File
@@ -1909,6 +1909,7 @@ s32 texInflateLookupFromBuffer(u8 *src, s32 width, s32 height, u8 *dst, u8 *look
*/
void texSwapAltRowBytes(u8 *dst, s32 width, s32 height, s32 format)
{
#ifdef PLATFORM_N64 // I'm assuming this is required on N64 because the GPU reads them in words
s32 x;
s32 y;
s32 alignedwidth;
@@ -1966,6 +1967,7 @@ void texSwapAltRowBytes(u8 *dst, s32 width, s32 height, s32 format)
row += alignedwidth * 2;
}
}
#endif
}
/**
@@ -2074,10 +2076,10 @@ void texLoadFromDisplayList(Gfx *gdl, struct texpool *pool, s32 arg2)
{
u8 *bytes = (u8 *)gdl;
while (bytes[0] != (u8)G_ENDDL) {
while (bytes[GFX_W0_BYTE(0)] != (u8)G_ENDDL) {
// Look for GBI sequence: fd...... abcd....
if (bytes[0] == G_SETTIMG && bytes[4] == 0xab && bytes[5] == 0xcd) {
texLoad((s32 *)((s32)bytes + 4), pool, arg2);
if (bytes[GFX_W0_BYTE(0)] == G_SETTIMG && bytes[GFX_W1_BYTE(0)] == 0xab && bytes[GFX_W1_BYTE(1)] == 0xcd) {
texLoad((s32 *)((uintptr_t)bytes + 4), pool, arg2);
}
bytes += 8;