match ReadPrintMessage

This commit is contained in:
SwareJonge 2023-09-01 22:28:56 +02:00
parent 5f1e0d25bf
commit 5e4cb5a0ca
12 changed files with 645 additions and 87 deletions

View File

@ -585,6 +585,14 @@ src/Kameda/PrintDvdError.cpp:
.data: [0x80395080, 0x803950b8]
.sdata2: [0x804190c0, 0x804190e0]
src/Kameda/ReadPrintMessage.cpp:
.text: [0x801690b4, 0x8016aac4]
.rodata: [0x80370da0, 0x80370f98]
.data: [0x80395478, 0x80395548]
#.bss: [0x803fbf34, 0x803fbf70]
.sbss: [0x80416350, 0x80416358]
.sdata2: [0x80419498, 0x804194c8]
#src/Kameda/PrintWindow.cpp:
#.text: [0x8018f960, 0x80190a94]
#.rodata: [0x80375e70, 0x80376048]

View File

@ -565,6 +565,13 @@ src/Kameda/PrintDvdError.cpp:
.data: [0x80354eb0, 0x80354ee8]
.sdata2: [0x803d7bf8, 0x803d7c18]
src/Kameda/ReadPrintMessage.cpp:
.text: [0x80151af8, 0x80152374]
.rodata: [0x80337cc0, 0x80337d00]
.data: [0x803552a8, 0x80355378]
.sbss: [0x803d55d0, 0x803d55d8]
.sdata2: [0x803d7fb8, 0x803d7fe0]
src/Kaneshige/HioMgr.cpp:
.text: [0x80182d00, 0x80182e1c]
.data: [0x803559c0, 0x803559d0]

View File

@ -2112,6 +2112,10 @@ global:
0x801520b8: getBmgMessageID__16ReadPrintMessageFQ28PrintPal9MessageID
0x80152110: getBmgMessageID__16ReadPrintMessageFQ215PrintMemoryCard9MessageID
0x8015231c: getBmgMessageID__16ReadPrintMessageFi
0x803bb208: mNum__16ReadPrintMessage
0x803bb244: mStr__16ReadPrintMessage
0x803d55d0: mInfoPtr__16ReadPrintMessage
0x803d55d4: mDataPtr__16ReadPrintMessage
# PrintMemoryCard.cpp
0x80152d60: closeWindowNoSe__15PrintMemoryCardFv

View File

@ -4,7 +4,7 @@
#include <JSystem/JUtility/JUTAssert.h>
#include <JSystem/JUtility/JUTException.h>
// the 1 == 1; inside the conditions was to match TP debug, likely fakematch
// NOTE: in TP debug this doesn't match
// Panic functions
#define JUT_PANIC(MSG) \
@ -18,22 +18,14 @@
JUTAssertion::setConfirmMessage(JUTAssertion::getSDevice(), __FILE__, __LINE__, COND, #COND);
// not sure if it's conditional?
#define JUT_WARNING(COND) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
#define JUT_WARNING(COND) \
if (!(COND)) \
{ \
JUTAssertion::setWarningMessage(JUTAssertion::getSDevice(), __FILE__, __LINE__, #COND); \
}
#define JUT_WARNING_F(COND, ...) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
#define JUT_WARNING_F(COND, ...) \
if (!(COND)) \
{ \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), __FILE__, __LINE__, __VA_ARGS__); \
}
@ -45,36 +37,24 @@
JUTAssertion::setWarningMessage_f(2, __FILE__, __LINE__, __VA_ARGS__);
#define JUT_ASSERT(COND) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
if (!(COND)) \
{ \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, __LINE__, #COND); \
OSHalt("Halt"); \
OSHalt("Halt"); \
}
#define JUT_ASSERT_F(COND, ...) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
#define JUT_ASSERT_F(COND, ...) \
if (!(COND)) \
{ \
JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, __LINE__, __VA_ARGS__); \
OSHalt("Halt"); \
OSHalt("Halt"); \
}
#define JUT_ASSERT_MSG(COND, MSG) \
if ((COND)) \
{ \
1 == 1; \
} \
else \
if (!(COND)) \
{ \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, __LINE__, MSG); \
OSHalt("Halt"); \
OSHalt("Halt"); \
}
#define JUT_MINMAX_ASSERT(min, cur, max) \

View File

@ -11,18 +11,17 @@ class PrintDvdError
public:
enum MessageID
{
// TODO
mcError0,
mcError1,
mcError2,
mcError3,
mcError4,
mcError5,
mcError6,
mcError7,
mcError8,
mcError9,
mcError10
mcFatalError,
mcRetryError,
mcError2, // Unused?
mcCoverOpen,
mcDiskError,
mcLANError0,
mcLANError1,
mcLANError2,
mcLANError3,
mcLANDisconnect,
mcLANDisconnectError
};
PrintDvdError(JKRHeap *heap);

View File

@ -9,22 +9,64 @@ class PrintMemoryCard
public:
PrintMemoryCard(JKRHeap *heap); // 0x8016be58
enum MessageID {
enum MessageID
{
mcNoCardContinue,
mcNoUseContinue,
mcWithouMKContinue,
mcBrokenNoSaveContinue,
mcBrokenGoFormat,
mcNoFileNoSave,
mcGameSavingNoTouch,
mcGetSavingNoTouch,
mcMissSaved,
mcInCardPushButton,
mcChangeCardPushButton,
mcMissFormat,
mcFormatLost,
mcFormatNoTouch,
mcNoSaveContinue,
mcMakeFile,
mcMakeFileNoTouch,
mcMadeFile,
mcMissMakeFile,
mcNoSpaceGoIPL,
mcTooManyFilesGoIPL,
mcNoUse,
mcWithoutMK,
mcBrokenNoUse,
mcBrokenNeedFormat,
mcGstLoad,
mcLoaded,
mcNoSpaceNoSave,
mcTooManyFiles,
mcGstSave,
mcSaved,
mcGstOverwrite,
mcNoGst,
mcGstNoLoad,
mcGstBrokenNoLoad,
mcBrokenNoLoad,
// these are lan related for whatever reason
mcTooManyFilesContinue, // begin lan setup
mcNoSpaceContinue, // disconnect lan link
mcMsg38, // disconnecting LAN Link
mcMsg39, // Quit are you sure?
mcMsg40 // black screen, no text here, also panic if bmg gets requested
};
void reset(); // 0x8016bf24
void init(MessageID); // 0x8016bf90
void changeMessage(); // 0x8016bfac
void draw(); // 0x8016c3e0
void calc(); // 0x8016c410
void closeWindow(); // 0x8016c92c
void closeWindowNoSe(); // 0x8016c9f8
void setBmgPtr(); // 0x8016ca9c
void isMessage(); // 0x8016cb0c
void getChoiceType(); // 0x8016cb98
void getWindowSize(); // 0x8016cc34
void getWindowColor(); // 0x8016cd00
void reset(); // 0x8016bf24
void init(MessageID); // 0x8016bf90
void changeMessage(); // 0x8016bfac
void draw(); // 0x8016c3e0
void calc(); // 0x8016c410
void closeWindow(); // 0x8016c92c
void closeWindowNoSe(); // 0x8016c9f8
void setBmgPtr(); // 0x8016ca9c
void isMessage(); // 0x8016cb0c
void getChoiceType(); // 0x8016cb98
void getWindowSize(); // 0x8016cc34
void getWindowColor(); // 0x8016cd00
// Inline/Unused
// void initWindow();
// ~PrintMemoryCard();

View File

@ -7,9 +7,12 @@
class PrintProgressive
{
public:
enum MessageID
enum MessageID // according to debug test screen
{
mcShow_Progressive,
mcSet_Progressive,
mcSet_Interlaced,
mcShow_Logo
};
PrintProgressive(JKRHeap *); // 0x8016aac4
void init(MessageID); // 0x8016b138

View File

@ -8,27 +8,102 @@
#include "Kameda/PrintMemoryCard.h"
#include "Kawano/PrintPal.h"
// Move to JSystem?
struct Header
{
u32 signature;
u32 dataType;
u32 dataSize;
u32 numBlocks;
u8 charset;
u8 _pad[0xf];
};
struct Block
{
u32 kind;
u32 size;
u8 data[];
};
enum BlockKind
{
BLOCK_KIND_INF = 0x494e4631,
BLOCK_KIND_DAT = 0x44415431,
BLOCK_KIND_STR = 0x53545231,
BLOCK_KIND_MID = 0x4d494431
};
struct Entry
{
u32 offset;
u16 rate;
s8 charSpace;
};
struct Inf
{
u32 kind;
u32 size;
u16 numEntries;
u16 entrySize;
u16 groupID;
u8 defaultColor;
u8 _pad[0x1];
Entry entries[];
};
struct Mid
{
u32 kind;
u32 size;
u16 numEntries;
u8 format;
u8 info;
u8 _pad[0x4];
u32 messageIds[];
};
struct BMC
{
Header header;
struct
{
struct
{
u32 kind;
u32 size;
} header;
u16 numColors;
u16 colorFormat;
u32 entries[256];
// padding bytes, 32 byte alignment
} colorTable;
};
namespace ReadPrintMessage
{ // Autogenerated
// Global
u32 getColor(void *bmcPtr, int index); // 0x801690b4
u8 getDefaultColor(void *bmgPtr); // 0x80169330
u16 getRate(void *, int); // 0x801694ec
s8 getCharSpace(void *, int); // 0x801696b4
char *getMessage(void *, int); // 0x8016987c
u32 getColor(void *bmcPtr, int index); // 0x801690b4
u8 getDefaultColor(void *bmgPtr); // 0x80169330
u16 getRate(void *bmgPtr, int); // 0x801694ec
s8 getCharSpace(void *bmgPtr, int); // 0x801696b4
char *getMessage(void *bmgPtr, int); // 0x8016987c
void tagCnv(char *, void *, J2DTextBox::TFontSize, int, char *); // 0x80169a50
int getBmgMessageID(PrintDvdError::MessageID); // 0x8016a600
int getBmgMessageID(PrintProgressive::MessageID); // 0x8016a6f8
int getBmgMessageID(PrintPal::MessageID); // 0x801520b8(PAL)
int getBmgMessageID(PrintMemoryCard::MessageID); // 0x8016a7a8
int getBmgMessageID(PrintMemoryCard::MessageID); // 0x8016a7a8
int getBmgMessageID(int); // 0x8016aa10
extern int mNum; // 0x803fbf34
extern char *mStr; // 0x803fbf70
extern void *mInfoPtr; // 0x80416350
extern void *mDataPtr; // 0x80416354
// Inline/Unused
// void readBmg(void *);
void readBmg(void *bmgPtr);
extern int mNum[10]; // 0x803fbf34
extern char *mStr[5]; // 0x803fbf70
extern Inf *mInfoPtr; // 0x80416350
extern Block *mDataPtr; // 0x80416354
}; // namespace ReadPrintMessage

View File

@ -5,8 +5,11 @@
class PrintPal {
public:
enum MessageID {
enum MessageID // Based of how it's structured in the file itself, might be wrong
{
mcShow_PAL,
mcSet_60Hz,
mcSet_50Hz
};
PrintPal(JKRHeap *heap);

View File

@ -17,45 +17,45 @@ void PrintDvdError::init(int errorId) {
switch (errorId)
{
case 1:
mBmgId = getBmgMessageID(mcError3);
mBmgId = getBmgMessageID(mcCoverOpen);
mBmgFile = getPtr(mcDvd);
break;
case 2:
case 3:
mBmgId = getBmgMessageID(mcError4);
case 2: // No Disk
case 3: // Wrong Disk
mBmgId = getBmgMessageID(mcDiskError);
mBmgFile = getPtr(mcDvd);
break;
case 4:
mBmgId = getBmgMessageID(mcError1);
mBmgId = getBmgMessageID(mcRetryError);
mBmgFile = getPtr(mcDvd);
break;
case 5:
mBmgId = getBmgMessageID(mcError0);
mBmgId = getBmgMessageID(mcFatalError);
mBmgFile = getPtr(mcDvd);
break;
case 6:
case 7:
mBmgId = getBmgMessageID(mcError7);
mBmgId = getBmgMessageID(mcLANError2);
mBmgFile = getPtr(mcLan);
break;
case 8:
mBmgId = getBmgMessageID(mcError8);
mBmgId = getBmgMessageID(mcLANError3);
mBmgFile = getPtr(mcLan);
break;
case 9:
mBmgId = getBmgMessageID(mcError6);
mBmgId = getBmgMessageID(mcLANError1);
mBmgFile = getPtr(mcLan);
break;
case 10:
mBmgId = getBmgMessageID(mcError5);
mBmgId = getBmgMessageID(mcLANError0);
mBmgFile = getPtr(mcLan);
break;
case 11:
mBmgId = getBmgMessageID(mcError9);
mBmgId = getBmgMessageID(mcLANDisconnect);
mBmgFile = getPtr(mcLan);
break;
case 12:
mBmgId = getBmgMessageID(mcError10);
mBmgId = getBmgMessageID(mcLANDisconnectError);
mBmgFile = getPtr(mcLan);
break;
default:

View File

@ -0,0 +1,437 @@
#include <string.h>
#include <JSystem/JUtility/JUTDbg.h>
#include <JSystem/J2D/J2DPane.h>
#include "Kameda/ReadPrintMessage.h"
namespace ReadPrintMessage
{
int mNum[10];
char *mStr[5];
Inf *mInfoPtr;
Block *mDataPtr;
u32 getColor(void *bmcPtr, int index)
{
#line 35
JUT_ASSERT(bmcPtr != 0);
BMC *ptr = (BMC *)bmcPtr;
JUT_ASSERT(ptr->header.signature == 'MGCL');
JUT_ASSERT(ptr->header.dataType == 'bmc1');
JUT_ASSERT(ptr->header.dataSize == 1088);
JUT_ASSERT(ptr->header.numBlocks == 1);
JUT_ASSERT(ptr->colorTable.header.kind == 'CLT1');
JUT_ASSERT(ptr->colorTable.numColors == 256);
JUT_ASSERT(ptr->colorTable.colorFormat == 0);
JUT_MINMAX_ASSERT(0, index, 256);
return ptr->colorTable.entries[index];
}
void readBmg(void *bmgPtr)
{
#line 58
JUT_ASSERT(bmgPtr != 0);
Header *headerPtr = (Header *)bmgPtr;
Block *blockPtr = (Block *)(headerPtr + 1);
JUT_ASSERT(headerPtr->signature == 'MESG');
JUT_ASSERT(headerPtr->dataType == 'bmg1');
// JUT_ASSERT(headerPtr->dataSize == 1088);
JUT_ASSERT(headerPtr->numBlocks <= 2);
for (int i = 0; i < headerPtr->numBlocks; i++)
{
Block *curBlock = blockPtr;
blockPtr = (Block *)((u8 *)blockPtr + blockPtr->size);
switch (curBlock->kind)
{
case BLOCK_KIND_INF:
mInfoPtr = (Inf *)curBlock;
break;
case BLOCK_KIND_DAT:
mDataPtr = curBlock;
break;
default:
#line 80
JUT_ASSERT(0);
}
}
}
u8 getDefaultColor(void *bmgPtr)
{
readBmg(bmgPtr);
return mInfoPtr->defaultColor;
}
u16 getRate(void *bmgPtr, int idx)
{
readBmg(bmgPtr);
return mInfoPtr->entries[idx].rate;
}
s8 getCharSpace(void *bmgPtr, int idx)
{
readBmg(bmgPtr);
return mInfoPtr->entries[idx].charSpace;
}
char *getMessage(void *bmgPtr, int idx)
{
readBmg(bmgPtr);
return (char *)&mDataPtr->data[mInfoPtr->entries[idx].offset];
}
void tagCnv(char *msg, void *bmcPtr, J2DTextBox::TFontSize fontSize, int n, char *txtBuf)
{
while (*msg && n--)
{
u8 excapeBuf[32];
char buf[32];
if (*msg != 0x1a)
{ // no escape sequence, normal formatting
*txtBuf++ = *msg++;
continue;
}
*msg++;
u8 sz = *msg++;
u8 tagGroup = *msg++;
u16 tagID = (*msg++ << 8);
tagID += *msg++;
for (u8 i = 0; i < sz - 5; i++)
excapeBuf[i] = *msg++;
switch (tagGroup)
{
case 0:
{
switch (tagID)
{
case 0:
{
JUtility::TColor color = getColor(bmcPtr, excapeBuf[0]);
JUtility::TColor gradient = getColor(bmcPtr, excapeBuf[1]);
snprintf(buf, sizeof(buf), "\x1b"
"CC[%02X%02X%02X%02X]"
"\x1b"
"GC[%02X%02X%02X%02X]",
color.r, color.g, color.b, color.a,
gradient.r, gradient.g, gradient.b, gradient.a);
break;
}
default:
#line 193
JUT_ASSERT(0);
}
break;
}
case 1:
JUT_MINMAX_ASSERT(0, tagID, 10);
snprintf(buf, sizeof(buf), "%d", mNum[tagID]);
break;
case 2:
JUT_MINMAX_ASSERT(0, tagID, 10);
snprintf(buf, sizeof(buf), "%02d", mNum[tagID]);
break;
case 3:
JUT_MINMAX_ASSERT(0, tagID, 10);
snprintf(buf, sizeof(buf), "%03d", mNum[tagID]);
break;
case 4:
JUT_MINMAX_ASSERT(0, tagID, 5);
snprintf(buf, sizeof(buf), "%s", mStr[tagID]);
break;
case 0xff:
switch (tagID)
{
case 0:
JUtility::TColor color = getColor(bmcPtr, excapeBuf[0]);
snprintf(buf, sizeof(buf), "\x1b"
"CC[%02X%02X%02X%02X]"
"\x1b"
"GC[%02X%02X%02X%02X]",
color.r, color.g, color.b, color.a,
color.r, color.g, color.b, color.a);
break;
case 1:
u16 scalar = (u16)((excapeBuf[0] << 8) + excapeBuf[1]);
int fontX = fontSize.x * scalar / 100.0f;
int fonty = fontSize.y * scalar / 100.0f;
snprintf(buf, sizeof(buf), "\x1b"
"FX[%d]"
"\x1b"
"FY[%d]",
fontX,
fonty);
break;
default:
#line 240
JUT_ASSERT(0);
break;
}
break;
default:
JUT_ASSERT(0);
break;
}
for (char *bufPtr = buf; *bufPtr != 0;)
*txtBuf++ = *bufPtr++;
}
*txtBuf = 0;
}
int getBmgMessageID(PrintDvdError::MessageID msgID)
{
int id;
switch (msgID)
{
case PrintDvdError::mcFatalError:
id = 0;
break;
case PrintDvdError::mcRetryError:
id = 2;
break;
case PrintDvdError::mcCoverOpen:
id = 3;
break;
case PrintDvdError::mcDiskError:
id = 1;
break;
case PrintDvdError::mcLANError0:
id = 0x50005;
break;
case PrintDvdError::mcLANError1:
id = 0x50006;
break;
case PrintDvdError::mcLANError2:
id = 0x50007;
break;
case PrintDvdError::mcLANError3:
id = 0x50008;
break;
case PrintDvdError::mcLANDisconnect:
id = 0x50003;
break;
case PrintDvdError::mcLANDisconnectError:
id = 0x50004;
break;
default:
#line 301
JUT_ASSERT(0);
break;
}
return id % 65536;
}
int getBmgMessageID(PrintProgressive::MessageID msgID)
{
int id;
switch (msgID)
{
case PrintProgressive::mcShow_Progressive:
id = 0x10002;
break;
case PrintProgressive::mcSet_Progressive:
id = 0x10001;
break;
case PrintProgressive::mcSet_Interlaced:
id = 0x10000;
break;
case PrintProgressive::mcShow_Logo: // there's no text here, so panic
default:
#line 330
JUT_ASSERT(0);
break;
}
return id % 65536;
}
int getBmgMessageID(PrintPal::MessageID msgID)
{
int id;
switch (msgID)
{
case PrintPal::mcShow_PAL:
id = 0x30000;
break;
case PrintPal::mcSet_60Hz:
id = 0x30001;
break;
case PrintPal::mcSet_50Hz:
id = 0x30002;
break;
default:
JUT_ASSERT(0);
break;
}
return id % 65536;
}
int getBmgMessageID(PrintMemoryCard::MessageID msgID)
{
int id;
switch (msgID)
{ // TODO
case PrintMemoryCard::mcNoCardContinue:
id = 0x20017;
break;
case PrintMemoryCard::mcNoUseContinue:
id = 0x2001e;
break;
case PrintMemoryCard::mcWithouMKContinue:
id = 0x20023;
break;
case PrintMemoryCard::mcBrokenNoSaveContinue:
id = 0x20003;
break;
case PrintMemoryCard::mcBrokenGoFormat:
id = 0x20000;
break;
case PrintMemoryCard::mcNoFileNoSave:
id = 0x20018;
break;
case PrintMemoryCard::mcGameSavingNoTouch:
id = 0x20008;
break;
case PrintMemoryCard::mcGetSavingNoTouch:
id = 0x2000e;
break;
case PrintMemoryCard::mcMissSaved:
id = 0x20016;
break;
case PrintMemoryCard::mcInCardPushButton:
id = 0x2000f;
break;
case PrintMemoryCard::mcChangeCardPushButton:
id = 0x20005;
break;
case PrintMemoryCard::mcMissFormat:
id = 0x20014;
break;
case PrintMemoryCard::mcFormatLost:
id = 0x20006;
break;
case PrintMemoryCard::mcFormatNoTouch:
id = 0x20007;
break;
case PrintMemoryCard::mcNoSaveContinue:
id = 0x2001a;
break;
case PrintMemoryCard::mcMakeFile:
id = 0x20012;
break;
case PrintMemoryCard::mcMakeFileNoTouch:
id = 0x20013;
break;
case PrintMemoryCard::mcMadeFile:
id = 0x20011;
break;
case PrintMemoryCard::mcMissMakeFile:
id = 0x20015;
break;
case PrintMemoryCard::mcNoSpaceGoIPL:
id = 0x2001b;
break;
case PrintMemoryCard::mcTooManyFilesGoIPL:
id = 0x20021;
break;
case PrintMemoryCard::mcNoUse:
id = 0x2001d;
break;
case PrintMemoryCard::mcWithoutMK:
id = 0x20022;
break;
case PrintMemoryCard::mcBrokenNoUse:
id = 0x20004;
break;
case PrintMemoryCard::mcBrokenNeedFormat:
id = 0x20001;
break;
case PrintMemoryCard::mcGstLoad:
id = 0x2000a;
break;
case PrintMemoryCard::mcLoaded:
id = 0x20010;
break;
case PrintMemoryCard::mcNoSpaceNoSave:
id = 0x2001c;
break;
case PrintMemoryCard::mcTooManyFiles:
id = 0x20020;
break;
case PrintMemoryCard::mcGstSave:
id = 0x2000d;
break;
case PrintMemoryCard::mcSaved:
id = 0x2001f;
break;
case PrintMemoryCard::mcGstOverwrite:
id = 0x2000c;
break;
case PrintMemoryCard::mcNoGst:
id = 0x20019;
break;
case PrintMemoryCard::mcGstNoLoad:
id = 0x2000b;
break;
case PrintMemoryCard::mcGstBrokenNoLoad:
id = 0x20009;
break;
case PrintMemoryCard::mcBrokenNoLoad:
id = 0x20002;
break;
case PrintMemoryCard::mcMsg40:
default:
#line 486
JUT_ASSERT(0);
break;
case PrintMemoryCard::mcTooManyFilesContinue:
id = 0x50000;
break;
case PrintMemoryCard::mcNoSpaceContinue:
id = 0x50002;
break;
case PrintMemoryCard::mcMsg38:
id = 0x50003;
break;
case PrintMemoryCard::mcMsg39:
id = 0x80003;
break;
}
return id % 65536;
}
int getBmgMessageID(int msgID)
{
int id;
switch (msgID)
{
case 0:
id = 0x40000;
break;
case 1:
id = 0x40002;
break;
case 2:
id = 0x40001;
break;
default:
#line 526
JUT_ASSERT(0);
break;
}
return id % 65536;
}
}