-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text.s #222
base: master
Are you sure you want to change the base?
Text.s #222
Conversation
const struct unkChar *ret; | ||
const struct unkChar *strPtr = gCharmaps[gCurrentCharmap]->unk4; | ||
// Fakematch? Or just magic numbers which will make more sense once this file is documented? | ||
if (chr > 63487 && chr < 65535) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is 0xf800 to 0xfffe inclusive, which matches the logic within the block below. Looks like it accesses the raw character data by index in the kanji file (encoded as 0xf820..0xfffe, avoiding ASCII control characters), completely ignoring the 'charcode' field. I don't think this character encoding is used in the ROM, was likely used to test the fonts.
Also, the CharMapStruct
corresponds to my struct_kanji
in Ghidra, unk0 is s32 len, unk4 is a struct_kanji_char*
.
That struct corresponds to your unkChar and is struct struct_kanji_char { u32 *data; u16 charcode; u16 width /* in pixels */; u8 unk8; u8 unk9; u8 flags; u8 fillB; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And just verified in Ghidra, no control flow can reach this function with this range of values for chr
, so this is effectively dead code.
src/text2.c
Outdated
} | ||
} | ||
|
||
u32 sub_8007FA8(u32 a0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverses the nybbles in a u32, AKA flips pixels horizontally in a tile's row of data.
Probably worth renaming appropriately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like FlipPixelsHorizontally works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
u32 *r2, *r1; | ||
|
||
CpuCopy(strPtr->unk28, strPtr->unk18, 0xD00); | ||
// The reason for void casts is because we want to add 0xD00/r5 directly to pointers. Because pointers are u32, without the casts, it would multiply the value by 4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely a part of the macro or inline that invokes CpuCopy. It advances the pointers (typed void* or u8*) by the amount of copied bytes.
Ready for review |
src/text2.c
Outdated
break; | ||
} | ||
} | ||
else if (chr == 0x60) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these chr
comparisons in the last three functions should use actual chars, since they are meaningful characters.
You can use L'x'
to make the char constant have a u32 value.
src/text2.c
Outdated
sp.unk0 = sp.unkC; | ||
sp.unk2 += 5; | ||
} | ||
else if (sp.unk34 == 0x60) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, use long char comparisons
src/text2.c
Outdated
|
||
while (1) | ||
{ | ||
if (*str == 0x2E) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'.'
sp->unk20 = 1; | ||
break; | ||
} | ||
else if (str[1] == 0x7E) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these should be chars
if ((r1 % 8) != 0) | ||
return (r1 / 8) + 1; | ||
else | ||
return r1 / 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to comment a way to possibly make this match with neater code, but realized they actually wrote this out like this.
If it was a u32, this would just be a ceiling division. This is not that. It's nonsense for negative numbers.
case 68: | ||
case 78: | ||
return 6; | ||
case 87: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these a0
comparisons should use chars.
WIP