Minor fixes, start CTextParser

Former-commit-id: e39a8e4c47
This commit is contained in:
Phillip Stephens 2022-09-29 21:24:13 -07:00
parent 8659785c5c
commit 4e754e9163
7 changed files with 180 additions and 28 deletions

View File

@ -24,11 +24,11 @@ mpAllocator__7CMemory:
.global lbl_805A9460 .global lbl_805A9460
lbl_805A9460: lbl_805A9460:
.skip 0x4 .skip 0x4
.global lbl_805A9464 .global gLeakCount
lbl_805A9464: gLeakCount:
.skip 0x4 .skip 0x4
.global lbl_805A9468 .global gLeakBytes
lbl_805A9468: gLeakBytes:
.skip 0x8 .skip 0x8
.section .text, "ax" .section .text, "ax"
@ -206,10 +206,10 @@ Shutdown__7CMemoryFv:
/* 80315A68 003129C8 38 00 00 00 */ li r0, 0 /* 80315A68 003129C8 38 00 00 00 */ li r0, 0
/* 80315A6C 003129CC 3C 60 80 31 */ lis r3, cmemory_enum_alloc_cb__FRCQ210IAllocator10SAllocInfoPCv@ha /* 80315A6C 003129CC 3C 60 80 31 */ lis r3, cmemory_enum_alloc_cb__FRCQ210IAllocator10SAllocInfoPCv@ha
/* 80315A70 003129D0 38 83 5A BC */ addi r4, r3, cmemory_enum_alloc_cb__FRCQ210IAllocator10SAllocInfoPCv@l /* 80315A70 003129D0 38 83 5A BC */ addi r4, r3, cmemory_enum_alloc_cb__FRCQ210IAllocator10SAllocInfoPCv@l
/* 80315A74 003129D4 90 0D A8 A4 */ stw r0, lbl_805A9464@sda21(r13) /* 80315A74 003129D4 90 0D A8 A4 */ stw r0, gLeakCount@sda21(r13)
/* 80315A78 003129D8 80 6D 9C A8 */ lwz r3, mpAllocator__7CMemory@sda21(r13) /* 80315A78 003129D8 80 6D 9C A8 */ lwz r3, mpAllocator__7CMemory@sda21(r13)
/* 80315A7C 003129DC 38 A0 00 00 */ li r5, 0 /* 80315A7C 003129DC 38 A0 00 00 */ li r5, 0
/* 80315A80 003129E0 90 0D A8 A8 */ stw r0, lbl_805A9468@sda21(r13) /* 80315A80 003129E0 90 0D A8 A8 */ stw r0, gLeakBytes@sda21(r13)
/* 80315A84 003129E4 38 C0 00 00 */ li r6, 0 /* 80315A84 003129E4 38 C0 00 00 */ li r6, 0
/* 80315A88 003129E8 81 83 00 00 */ lwz r12, 0(r3) /* 80315A88 003129E8 81 83 00 00 */ lwz r12, 0(r3)
/* 80315A8C 003129EC 81 8C 00 30 */ lwz r12, 0x30(r12) /* 80315A8C 003129EC 81 8C 00 30 */ lwz r12, 0x30(r12)
@ -234,13 +234,13 @@ cmemory_enum_alloc_cb__FRCQ210IAllocator10SAllocInfoPCv:
/* 80315AC8 00312A28 88 03 00 09 */ lbz r0, 9(r3) /* 80315AC8 00312A28 88 03 00 09 */ lbz r0, 9(r3)
/* 80315ACC 00312A2C 28 00 00 00 */ cmplwi r0, 0 /* 80315ACC 00312A2C 28 00 00 00 */ cmplwi r0, 0
/* 80315AD0 00312A30 40 82 00 20 */ bne lbl_80315AF0 /* 80315AD0 00312A30 40 82 00 20 */ bne lbl_80315AF0
/* 80315AD4 00312A34 80 AD A8 A4 */ lwz r5, lbl_805A9464@sda21(r13) /* 80315AD4 00312A34 80 AD A8 A4 */ lwz r5, gLeakCount@sda21(r13)
/* 80315AD8 00312A38 80 8D A8 A8 */ lwz r4, lbl_805A9468@sda21(r13) /* 80315AD8 00312A38 80 8D A8 A8 */ lwz r4, gLeakBytes@sda21(r13)
/* 80315ADC 00312A3C 80 03 00 04 */ lwz r0, 4(r3) /* 80315ADC 00312A3C 80 03 00 04 */ lwz r0, 4(r3)
/* 80315AE0 00312A40 38 65 00 01 */ addi r3, r5, 1 /* 80315AE0 00312A40 38 65 00 01 */ addi r3, r5, 1
/* 80315AE4 00312A44 90 6D A8 A4 */ stw r3, lbl_805A9464@sda21(r13) /* 80315AE4 00312A44 90 6D A8 A4 */ stw r3, gLeakCount@sda21(r13)
/* 80315AE8 00312A48 7C 04 02 14 */ add r0, r4, r0 /* 80315AE8 00312A48 7C 04 02 14 */ add r0, r4, r0
/* 80315AEC 00312A4C 90 0D A8 A8 */ stw r0, lbl_805A9468@sda21(r13) /* 80315AEC 00312A4C 90 0D A8 A8 */ stw r0, gLeakBytes@sda21(r13)
lbl_80315AF0: lbl_80315AF0:
/* 80315AF0 00312A50 38 60 00 01 */ li r3, 1 /* 80315AF0 00312A50 38 60 00 01 */ li r3, 1
/* 80315AF4 00312A54 4E 80 00 20 */ blr /* 80315AF4 00312A54 4E 80 00 20 */ blr

View File

@ -1256,7 +1256,7 @@ StartNewLine__18CTextExecuteBufferFv:
/* 80302C90 002FFBF0 80 03 00 A4 */ lwz r0, 0xa4(r3) /* 80302C90 002FFBF0 80 03 00 A4 */ lwz r0, 0xa4(r3)
/* 80302C94 002FFBF4 28 00 00 00 */ cmplwi r0, 0 /* 80302C94 002FFBF4 28 00 00 00 */ cmplwi r0, 0
/* 80302C98 002FFBF8 41 82 00 08 */ beq lbl_80302CA0 /* 80302C98 002FFBF8 41 82 00 08 */ beq lbl_80302CA0
/* 80302C9C 002FFBFC 48 00 02 05 */ bl sub_80302ea0 /* 80302C9C 002FFBFC 48 00 02 05 */ bl TerminateLine__18CTextExecuteBufferFv
lbl_80302CA0: lbl_80302CA0:
/* 80302CA0 002FFC00 3C 80 80 3D */ lis r4, lbl_803D6E90@ha /* 80302CA0 002FFC00 3C 80 80 3D */ lis r4, lbl_803D6E90@ha
/* 80302CA4 002FFC04 38 60 00 34 */ li r3, 0x34 /* 80302CA4 002FFC04 38 60 00 34 */ li r3, 0x34
@ -1394,8 +1394,8 @@ lbl_80302E30:
/* 80302E98 002FFDF8 38 21 00 20 */ addi r1, r1, 0x20 /* 80302E98 002FFDF8 38 21 00 20 */ addi r1, r1, 0x20
/* 80302E9C 002FFDFC 4E 80 00 20 */ blr /* 80302E9C 002FFDFC 4E 80 00 20 */ blr
.global sub_80302ea0 .global TerminateLine__18CTextExecuteBufferFv
sub_80302ea0: TerminateLine__18CTextExecuteBufferFv:
/* 80302EA0 002FFE00 94 21 FF F0 */ stwu r1, -0x10(r1) /* 80302EA0 002FFE00 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80302EA4 002FFE04 7C 08 02 A6 */ mflr r0 /* 80302EA4 002FFE04 7C 08 02 A6 */ mflr r0
/* 80302EA8 002FFE08 90 01 00 14 */ stw r0, 0x14(r1) /* 80302EA8 002FFE08 90 01 00 14 */ stw r0, 0x14(r1)
@ -1477,8 +1477,8 @@ lbl_80302FA0:
/* 80302FB8 002FFF18 38 21 00 30 */ addi r1, r1, 0x30 /* 80302FB8 002FFF18 38 21 00 30 */ addi r1, r1, 0x30
/* 80302FBC 002FFF1C 4E 80 00 20 */ blr /* 80302FBC 002FFF1C 4E 80 00 20 */ blr
.global __ct__20CPopStateInstructionFv .global AddPopState__18CTextExecuteBufferFv
__ct__20CPopStateInstructionFv: AddPopState__18CTextExecuteBufferFv:
/* 80302FC0 002FFF20 94 21 FF E0 */ stwu r1, -0x20(r1) /* 80302FC0 002FFF20 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 80302FC4 002FFF24 7C 08 02 A6 */ mflr r0 /* 80302FC4 002FFF24 7C 08 02 A6 */ mflr r0
/* 80302FC8 002FFF28 3C 80 80 3D */ lis r4, lbl_803D6E90@ha /* 80302FC8 002FFF28 3C 80 80 3D */ lis r4, lbl_803D6E90@ha
@ -1541,8 +1541,8 @@ lbl_80303088:
/* 803030A0 00300000 38 21 00 20 */ addi r1, r1, 0x20 /* 803030A0 00300000 38 21 00 20 */ addi r1, r1, 0x20
/* 803030A4 00300004 4E 80 00 20 */ blr /* 803030A4 00300004 4E 80 00 20 */ blr
.global __ct__21CPushStateInstructionFv .global AddPushState__18CTextExecuteBufferFv
__ct__21CPushStateInstructionFv: AddPushState__18CTextExecuteBufferFv:
/* 803030A8 00300008 94 21 FF E0 */ stwu r1, -0x20(r1) /* 803030A8 00300008 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 803030AC 0030000C 7C 08 02 A6 */ mflr r0 /* 803030AC 0030000C 7C 08 02 A6 */ mflr r0
/* 803030B0 00300010 3C 80 80 3D */ lis r4, lbl_803D6E90@ha /* 803030B0 00300010 3C 80 80 3D */ lis r4, lbl_803D6E90@ha
@ -2282,7 +2282,7 @@ EndBlock__18CTextExecuteBufferFv:
/* 80303B3C 00300A9C 80 03 00 A4 */ lwz r0, 0xa4(r3) /* 80303B3C 00300A9C 80 03 00 A4 */ lwz r0, 0xa4(r3)
/* 80303B40 00300AA0 28 00 00 00 */ cmplwi r0, 0 /* 80303B40 00300AA0 28 00 00 00 */ cmplwi r0, 0
/* 80303B44 00300AA4 41 82 00 08 */ beq lbl_80303B4C /* 80303B44 00300AA4 41 82 00 08 */ beq lbl_80303B4C
/* 80303B48 00300AA8 4B FF F3 59 */ bl sub_80302ea0 /* 80303B48 00300AA8 4B FF F3 59 */ bl TerminateLine__18CTextExecuteBufferFv
lbl_80303B4C: lbl_80303B4C:
/* 80303B4C 00300AAC 38 00 00 00 */ li r0, 0 /* 80303B4C 00300AAC 38 00 00 00 */ li r0, 0
/* 80303B50 00300AB0 90 1F 00 A4 */ stw r0, 0xa4(r31) /* 80303B50 00300AB0 90 1F 00 A4 */ stw r0, 0xa4(r31)

View File

@ -694,7 +694,7 @@ lbl_80304C24:
/* 80304C3C 00301B9C 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 80304C3C 00301B9C 54 60 06 3F */ clrlwi. r0, r3, 0x18
/* 80304C40 00301BA0 41 82 00 10 */ beq lbl_80304C50 /* 80304C40 00301BA0 41 82 00 10 */ beq lbl_80304C50
/* 80304C44 00301BA4 7F A3 EB 78 */ mr r3, r29 /* 80304C44 00301BA4 7F A3 EB 78 */ mr r3, r29
/* 80304C48 00301BA8 4B FF E4 61 */ bl __ct__21CPushStateInstructionFv /* 80304C48 00301BA8 4B FF E4 61 */ bl AddPushState__18CTextExecuteBufferFv
/* 80304C4C 00301BAC 48 00 00 44 */ b lbl_80304C90 /* 80304C4C 00301BAC 48 00 00 44 */ b lbl_80304C90
lbl_80304C50: lbl_80304C50:
/* 80304C50 00301BB0 3C 80 80 3F */ lis r4, lbl_803ED718@ha /* 80304C50 00301BB0 3C 80 80 3F */ lis r4, lbl_803ED718@ha
@ -706,7 +706,7 @@ lbl_80304C50:
/* 80304C68 00301BC8 54 60 06 3F */ clrlwi. r0, r3, 0x18 /* 80304C68 00301BC8 54 60 06 3F */ clrlwi. r0, r3, 0x18
/* 80304C6C 00301BCC 41 82 00 10 */ beq lbl_80304C7C /* 80304C6C 00301BCC 41 82 00 10 */ beq lbl_80304C7C
/* 80304C70 00301BD0 7F A3 EB 78 */ mr r3, r29 /* 80304C70 00301BD0 7F A3 EB 78 */ mr r3, r29
/* 80304C74 00301BD4 4B FF E3 4D */ bl __ct__20CPopStateInstructionFv /* 80304C74 00301BD4 4B FF E3 4D */ bl AddPopState__18CTextExecuteBufferFv
/* 80304C78 00301BD8 48 00 00 18 */ b lbl_80304C90 /* 80304C78 00301BD8 48 00 00 18 */ b lbl_80304C90
lbl_80304C7C: lbl_80304C7C:
/* 80304C7C 00301BDC 7F 83 E3 78 */ mr r3, r28 /* 80304C7C 00301BDC 7F 83 E3 78 */ mr r3, r28
@ -1655,7 +1655,7 @@ lbl_8030598C:
.global lbl_805AE478 .global lbl_805AE478
lbl_805AE478: lbl_805AE478:
# ROM: 0x3FAD18 # ROM: 0x3FAD18
.4byte 0x42C80000 .float 100.0
.4byte 0 .4byte 0
.global lbl_805AE480 .global lbl_805AE480
@ -1667,7 +1667,6 @@ lbl_805AE480:
lbl_805AE488: lbl_805AE488:
# ROM: 0x3FAD28 # ROM: 0x3FAD28
.float 1.0 .float 1.0
.4byte 0
.section .rodata .section .rodata
@ -1676,10 +1675,9 @@ lbl_805AE488:
lbl_803D6EA0: lbl_803D6EA0:
# ROM: 0x3D3EA0 # ROM: 0x3D3EA0
.asciz "%02x%02x%02x%02x" .asciz "%02x%02x%02x%02x"
.byte 0x3F, 0x3F, 0x28 .asciz "??(??)"
.4byte 0x3F3F2900 .asciz ","
.4byte 0x2C004100 .asciz "A"
.4byte 0x53410053 .asciz "SA"
.4byte 0x49000000 .asciz "SI"
.4byte 0

View File

@ -0,0 +1,17 @@
#ifndef __CTEXTCOLOR_HPP__
#define __CTEXTCOLOR_HPP__
#include <types.h>
class CTextColor {
public:
CTextColor(uchar r, uchar g, uchar b, uchar a)
: mR(r), mG(g), mB(b), mA(a) {}
private:
uchar mR;
uchar mG;
uchar mB;
uchar mA;
};
#endif

View File

@ -0,0 +1,8 @@
#ifndef __CTEXTEXECUTEBUFFER_HPP__
#define __CTEXTEXECUTEBUFFER_HPP__
class CTextExecuteBuffer {
};
#endif

View File

@ -0,0 +1,30 @@
#ifndef __CTEXTPARSER_HPP__
#define __CTEXTPARSER_HPP__
#include <types.h>
#include <rstl/string.hpp>
#include <Kyoto/Text/CTextColor.hpp>
class IObjectStore;
class CTextExecuteBuffer;
class CTextParser {
public:
CTextParser(IObjectStore& store);
void ParseText(CTextExecuteBuffer&, const wchar_t* str, int len);
uint GetAssetIdFromString(const rstl::string& str);
uint GetFont(const wchar_t* str, int len);
uint GetImage(const wchar_t* str, int len);
uint HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* str, int len);
void ParseTag(CTextExecuteBuffer&, const wchar_t* str, int len);
static bool BeginsWith(const wchar_t* str1, int len, const wchar_t* str2);
static bool Equals(const wchar_t* str1, int len, const wchar_t* str2);
static uint ParseInt(const wchar_t* str, int len, bool);
static uint FromHex(wchar_t c);
static uint GetColorValue(const wchar_t* str);
CTextColor ParseColor(const wchar_t* str, int len);
private:
IObjectStore& mObjectStore;
};
#endif

View File

@ -0,0 +1,99 @@
#include <Kyoto/Text/CTextParser.hpp>
#include <Kyoto/Text/CTextExecuteBuffer.hpp>
#include <Kyoto/IObjectStore.hpp>
CTextParser::CTextParser(IObjectStore& store)
: mObjectStore(store) {}
void CTextParser::ParseText(CTextExecuteBuffer& buffer, const wchar_t* str, int len) {
}
uint CTextParser::GetAssetIdFromString(const rstl::string& str) {
}
uint CTextParser::GetFont(const wchar_t* str, int len) {
return -1;
}
uint CTextParser::GetImage(const wchar_t* str, int len) {
return -1;
}
uint CTextParser::HandleUserTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) {
return 0;
}
void CTextParser::ParseTag(CTextExecuteBuffer& buffer, const wchar_t* string, int len) {
}
bool CTextParser::BeginsWith(const wchar_t* str1, int len, const wchar_t* str2) {
int i = 0;
for (; str2[i] != L'\x0' && i < len; ++i) {
if (str1[i] != str2[i]) {
return false;
}
}
return str2[i] == L'\x0';
}
bool CTextParser::Equals(const wchar_t* str1, int len, const wchar_t* str2) {
int i = 0;
for (;str2[i] != L'\x0' && i < len; ++i) {
if (str1[i] != str2[i]) {
return false;
}
}
return str2[i] == L'\x0';
}
uint CTextParser::ParseInt(const wchar_t* str, int len, bool signVal) {
bool neg = false;
int procCur = 0;
if (signVal && len > 0 && *str == L'-') {
neg = true;
procCur = 1;
}
int val = 0;
while (len > procCur) {
val *= 10;
wchar_t ch = str[procCur];
val += ch - L'0';
++procCur;
}
return neg ? -val : val;
}
uint CTextParser::FromHex(wchar_t ch) {
if (ch >= L'0' && ch <= L'9')
return ch - L'0';
if (ch >= L'A' && ch <= L'F')
return ch - L'A' + 10;
if (ch >= L'a' && ch <= L'f')
return ch - L'a' + 10;
return 0;
}
uint CTextParser::GetColorValue(const wchar_t* str) {
uint a = (FromHex(str[0]) << 4);
uint b = FromHex(str[1]);
return b + a;
}
CTextColor CTextParser::ParseColor(const wchar_t* str, int len) {
uint r = GetColorValue(str + 1);
uint g = GetColorValue(str + 3);
uint b = GetColorValue(str + 5);
uint a = len == 9 ? GetColorValue(str + 7) : 255;
return CTextColor(r, g, b, a);
}