Merge pull request #249 from DavidSM64/menu

Finished decompiling font.c
This commit is contained in:
David Benepe
2022-10-02 20:52:15 -05:00
committed by GitHub
5 changed files with 133 additions and 884 deletions
+11 -16
View File
@@ -1,23 +1,18 @@
IndentWidth: 4
Language: Cpp
UseTab: Never
ColumnLimit: 0
AlignAfterOpenBracket: Align
SortIncludes: false
ColumnLimit: 104
PointerAlignment: Right
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
SpaceAfterCStyleCast: true
BreakBeforeBraces: Attach
SpaceAfterCStyleCast: false
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: NonAssignment
Cpp11BracedListStyle: false
IndentCaseLabels: true
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: Align
AlignOperands: true
BreakBeforeTernaryOperators: true
BreakBeforeBinaryOperators: None
AllowShortBlocksOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AlignEscapedNewlines: Left
AlignTrailingComments: true
SortIncludes: false
UseTab: Never
+8 -8
View File
@@ -113,15 +113,15 @@ s32 is_drumstick_unlocked(void) {
}
```
As of September 27th, 2022, this is our current score:
As of October 2nd, 2022, this is our current score:
```
========================================================
ADVENTURE ONE (ASM -> C Decompilation)
------------------- 31.46% Complete --------------------
# Decompiled functions: 1273
# GLOBAL_ASM remaining: 561
# NON_MATCHING functions: 15
# NON_EQUIVALENT WIP functions: 101
------------------- 31.77% Complete --------------------
# Decompiled functions: 1275
# GLOBAL_ASM remaining: 558
# NON_MATCHING functions: 14
# NON_EQUIVALENT WIP functions: 100
--------------------- Game Status ----------------------
Balloons: 16/47, Keys: 2/4, Trophies: 1/5
T.T. Amulets: 1/4, Wizpig Amulets: 1/4
@@ -131,13 +131,13 @@ As of September 27th, 2022, this is our current score:
ADVENTURE TWO (Cleanup & Documentation)
------------------- 5.39% Complete --------------------
# Documented functions: 195
# Undocumented remaining: 1639
# Undocumented remaining: 1638
--------------------- Game Status ----------------------
Balloons: 3/47, Keys: 0/4, Trophies: 0/5
T.T. Amulets: 0/4, Wizpig Amulets: 0/4
--------------------------------------------------------
We are collecting the fourth balloon on Timber's Island.
========================================================
========================================================
```
---
File diff suppressed because it is too large Load Diff
@@ -1,194 +0,0 @@
glabel render_dialogue_text
/* 0C5D68 800C5168 27BDFEB8 */ addiu $sp, $sp, -0x148
/* 0C5D6C 800C516C AFB00018 */ sw $s0, 0x18($sp)
/* 0C5D70 800C5170 00808025 */ move $s0, $a0
/* 0C5D74 800C5174 AFBF001C */ sw $ra, 0x1c($sp)
/* 0C5D78 800C5178 AFA5014C */ sw $a1, 0x14c($sp)
/* 0C5D7C 800C517C AFA60150 */ sw $a2, 0x150($sp)
/* 0C5D80 800C5180 14E00003 */ bnez $a3, .L800C5190
/* 0C5D84 800C5184 AFA70154 */ sw $a3, 0x154($sp)
/* 0C5D88 800C5188 100000A3 */ b .L800C5418
/* 0C5D8C 800C518C 00001025 */ move $v0, $zero
.L800C5190:
/* 0C5D90 800C5190 3C048013 */ lui $a0, %hi(D_8012A7EC) # $a0, 0x8013
/* 0C5D94 800C5194 8C84A7EC */ lw $a0, %lo(D_8012A7EC)($a0)
/* 0C5D98 800C5198 00007940 */ sll $t7, $zero, 5
/* 0C5D9C 800C519C 00001825 */ move $v1, $zero
/* 0C5DA0 800C51A0 00003825 */ move $a3, $zero
/* 0C5DA4 800C51A4 240500FF */ li $a1, 255
/* 0C5DA8 800C51A8 008F1021 */ addu $v0, $a0, $t7
.L800C51AC:
/* 0C5DAC 800C51AC 90580001 */ lbu $t8, 1($v0)
/* 0C5DB0 800C51B0 0003C940 */ sll $t9, $v1, 5
/* 0C5DB4 800C51B4 14B80002 */ bne $a1, $t8, .L800C51C0
/* 0C5DB8 800C51B8 00000000 */ nop
/* 0C5DBC 800C51BC 03243821 */ addu $a3, $t9, $a0
.L800C51C0:
/* 0C5DC0 800C51C0 24630001 */ addiu $v1, $v1, 1
/* 0C5DC4 800C51C4 28610040 */ slti $at, $v1, 0x40
/* 0C5DC8 800C51C8 10200003 */ beqz $at, .L800C51D8
/* 0C5DCC 800C51CC 24420020 */ addiu $v0, $v0, 0x20
/* 0C5DD0 800C51D0 10E0FFF6 */ beqz $a3, .L800C51AC
/* 0C5DD4 800C51D4 00000000 */ nop
.L800C51D8:
/* 0C5DD8 800C51D8 10E0008E */ beqz $a3, .L800C5414
/* 0C5DDC 800C51DC 240500FF */ li $a1, 255
/* 0C5DE0 800C51E0 00105080 */ sll $t2, $s0, 2
/* 0C5DE4 800C51E4 3C0B8013 */ lui $t3, %hi(gDialogueBoxBackground) # $t3, 0x8013
/* 0C5DE8 800C51E8 8D6BA7E8 */ lw $t3, %lo(gDialogueBoxBackground)($t3)
/* 0C5DEC 800C51EC 8FAC014C */ lw $t4, 0x14c($sp)
/* 0C5DF0 800C51F0 01505021 */ addu $t2, $t2, $s0
/* 0C5DF4 800C51F4 24028000 */ li $v0, -32768
/* 0C5DF8 800C51F8 000A50C0 */ sll $t2, $t2, 3
/* 0C5DFC 800C51FC 15820005 */ bne $t4, $v0, .L800C5214
/* 0C5E00 800C5200 014B4021 */ addu $t0, $t2, $t3
/* 0C5E04 800C5204 850D000C */ lh $t5, 0xc($t0)
/* 0C5E08 800C5208 00000000 */ nop
/* 0C5E0C 800C520C 000D7043 */ sra $t6, $t5, 1
/* 0C5E10 800C5210 AFAE014C */ sw $t6, 0x14c($sp)
.L800C5214:
/* 0C5E14 800C5214 8FAF0150 */ lw $t7, 0x150($sp)
/* 0C5E18 800C5218 3C0B8013 */ lui $t3, %hi(gFonts) # $t3, 0x8013
/* 0C5E1C 800C521C 15E20005 */ bne $t7, $v0, .L800C5234
/* 0C5E20 800C5220 00000000 */ nop
/* 0C5E24 800C5224 8518000E */ lh $t8, 0xe($t0)
/* 0C5E28 800C5228 00000000 */ nop
/* 0C5E2C 800C522C 0018C843 */ sra $t9, $t8, 1
/* 0C5E30 800C5230 AFB90150 */ sw $t9, 0x150($sp)
.L800C5234:
/* 0C5E34 800C5234 9102001D */ lbu $v0, 0x1d($t0)
/* 0C5E38 800C5238 8FA3015C */ lw $v1, 0x15c($sp)
/* 0C5E3C 800C523C 10A2002F */ beq $a1, $v0, .L800C52FC
/* 0C5E40 800C5240 00025280 */ sll $t2, $v0, 0xa
/* 0C5E44 800C5244 8D6BA7E4 */ lw $t3, %lo(gFonts)($t3)
/* 0C5E48 800C5248 306C0005 */ andi $t4, $v1, 5
/* 0C5E4C 800C524C 1180001B */ beqz $t4, .L800C52BC
/* 0C5E50 800C5250 014B4821 */ addu $t1, $t2, $t3
/* 0C5E54 800C5254 8FA60158 */ lw $a2, 0x158($sp)
/* 0C5E58 800C5258 8FA40154 */ lw $a0, 0x154($sp)
/* 0C5E5C 800C525C 27A50040 */ addiu $a1, $sp, 0x40
/* 0C5E60 800C5260 AFA7003C */ sw $a3, 0x3c($sp)
/* 0C5E64 800C5264 AFA80030 */ sw $t0, 0x30($sp)
/* 0C5E68 800C5268 0C0317D8 */ jal parse_string_with_number
/* 0C5E6C 800C526C AFA9002C */ sw $t1, 0x2c($sp)
/* 0C5E70 800C5270 8FA80030 */ lw $t0, 0x30($sp)
/* 0C5E74 800C5274 8FA5014C */ lw $a1, 0x14c($sp)
/* 0C5E78 800C5278 9106001D */ lbu $a2, 0x1d($t0)
/* 0C5E7C 800C527C 0C031368 */ jal func_800C4DA0
/* 0C5E80 800C5280 27A40040 */ addiu $a0, $sp, 0x40
/* 0C5E84 800C5284 8FA3015C */ lw $v1, 0x15c($sp)
/* 0C5E88 800C5288 8FA4014C */ lw $a0, 0x14c($sp)
/* 0C5E8C 800C528C 8FA7003C */ lw $a3, 0x3c($sp)
/* 0C5E90 800C5290 8FA80030 */ lw $t0, 0x30($sp)
/* 0C5E94 800C5294 8FA9002C */ lw $t1, 0x2c($sp)
/* 0C5E98 800C5298 306D0001 */ andi $t5, $v1, 1
/* 0C5E9C 800C529C 11A00005 */ beqz $t5, .L800C52B4
/* 0C5EA0 800C52A0 00027043 */ sra $t6, $v0, 1
/* 0C5EA4 800C52A4 00822023 */ subu $a0, $a0, $v0
/* 0C5EA8 800C52A8 24840001 */ addiu $a0, $a0, 1
/* 0C5EAC 800C52AC 10000003 */ b .L800C52BC
/* 0C5EB0 800C52B0 AFA4014C */ sw $a0, 0x14c($sp)
.L800C52B4:
/* 0C5EB4 800C52B4 008E2023 */ subu $a0, $a0, $t6
/* 0C5EB8 800C52B8 AFA4014C */ sw $a0, 0x14c($sp)
.L800C52BC:
/* 0C5EBC 800C52BC 306F0002 */ andi $t7, $v1, 2
/* 0C5EC0 800C52C0 11E00007 */ beqz $t7, .L800C52E0
/* 0C5EC4 800C52C4 306C0008 */ andi $t4, $v1, 8
/* 0C5EC8 800C52C8 8FB80150 */ lw $t8, 0x150($sp)
/* 0C5ECC 800C52CC 95390022 */ lhu $t9, 0x22($t1)
/* 0C5ED0 800C52D0 00000000 */ nop
/* 0C5ED4 800C52D4 03195023 */ subu $t2, $t8, $t9
/* 0C5ED8 800C52D8 254B0001 */ addiu $t3, $t2, 1
/* 0C5EDC 800C52DC AFAB0150 */ sw $t3, 0x150($sp)
.L800C52E0:
/* 0C5EE0 800C52E0 11800006 */ beqz $t4, .L800C52FC
/* 0C5EE4 800C52E4 00000000 */ nop
/* 0C5EE8 800C52E8 952E0022 */ lhu $t6, 0x22($t1)
/* 0C5EEC 800C52EC 8FAD0150 */ lw $t5, 0x150($sp)
/* 0C5EF0 800C52F0 000E7843 */ sra $t7, $t6, 1
/* 0C5EF4 800C52F4 01AFC023 */ subu $t8, $t5, $t7
/* 0C5EF8 800C52F8 AFB80150 */ sw $t8, 0x150($sp)
.L800C52FC:
/* 0C5EFC 800C52FC 8D040024 */ lw $a0, 0x24($t0)
/* 0C5F00 800C5300 8FB00158 */ lw $s0, 0x158($sp)
/* 0C5F04 800C5304 14800004 */ bnez $a0, .L800C5318
/* 0C5F08 800C5308 25030024 */ addiu $v1, $t0, 0x24
/* 0C5F0C 800C530C AD070024 */ sw $a3, 0x24($t0)
/* 0C5F10 800C5310 10000014 */ b .L800C5364
/* 0C5F14 800C5314 ACE0001C */ sw $zero, 0x1c($a3)
.L800C5318:
/* 0C5F18 800C5318 10800010 */ beqz $a0, .L800C535C
/* 0C5F1C 800C531C 00801025 */ move $v0, $a0
/* 0C5F20 800C5320 90990001 */ lbu $t9, 1($a0)
/* 0C5F24 800C5324 00000000 */ nop
/* 0C5F28 800C5328 0219082A */ slt $at, $s0, $t9
/* 0C5F2C 800C532C 1020000B */ beqz $at, .L800C535C
/* 0C5F30 800C5330 00000000 */ nop
.L800C5334:
/* 0C5F34 800C5334 2443001C */ addiu $v1, $v0, 0x1c
/* 0C5F38 800C5338 8C42001C */ lw $v0, 0x1c($v0)
/* 0C5F3C 800C533C 00000000 */ nop
/* 0C5F40 800C5340 10400006 */ beqz $v0, .L800C535C
/* 0C5F44 800C5344 00000000 */ nop
/* 0C5F48 800C5348 904A0001 */ lbu $t2, 1($v0)
/* 0C5F4C 800C534C 00000000 */ nop
/* 0C5F50 800C5350 020A082A */ slt $at, $s0, $t2
/* 0C5F54 800C5354 1420FFF7 */ bnez $at, .L800C5334
/* 0C5F58 800C5358 00000000 */ nop
.L800C535C:
/* 0C5F5C 800C535C AC670000 */ sw $a3, ($v1)
/* 0C5F60 800C5360 ACE2001C */ sw $v0, 0x1c($a3)
.L800C5364:
/* 0C5F64 800C5364 A0F00001 */ sb $s0, 1($a3)
/* 0C5F68 800C5368 8FAB0154 */ lw $t3, 0x154($sp)
/* 0C5F6C 800C536C 00000000 */ nop
/* 0C5F70 800C5370 ACEB0004 */ sw $t3, 4($a3)
/* 0C5F74 800C5374 8FAC014C */ lw $t4, 0x14c($sp)
/* 0C5F78 800C5378 00000000 */ nop
/* 0C5F7C 800C537C A4EC0008 */ sh $t4, 8($a3)
/* 0C5F80 800C5380 8FAE0150 */ lw $t6, 0x150($sp)
/* 0C5F84 800C5384 A4E0000C */ sh $zero, 0xc($a3)
/* 0C5F88 800C5388 A4E0000E */ sh $zero, 0xe($a3)
/* 0C5F8C 800C538C A4EE000A */ sh $t6, 0xa($a3)
/* 0C5F90 800C5390 910D0014 */ lbu $t5, 0x14($t0)
/* 0C5F94 800C5394 00000000 */ nop
/* 0C5F98 800C5398 A0ED0010 */ sb $t5, 0x10($a3)
/* 0C5F9C 800C539C 910F0015 */ lbu $t7, 0x15($t0)
/* 0C5FA0 800C53A0 00000000 */ nop
/* 0C5FA4 800C53A4 A0EF0011 */ sb $t7, 0x11($a3)
/* 0C5FA8 800C53A8 91180016 */ lbu $t8, 0x16($t0)
/* 0C5FAC 800C53AC 00000000 */ nop
/* 0C5FB0 800C53B0 A0F80012 */ sb $t8, 0x12($a3)
/* 0C5FB4 800C53B4 91190017 */ lbu $t9, 0x17($t0)
/* 0C5FB8 800C53B8 00000000 */ nop
/* 0C5FBC 800C53BC A0F90013 */ sb $t9, 0x13($a3)
/* 0C5FC0 800C53C0 910A0018 */ lbu $t2, 0x18($t0)
/* 0C5FC4 800C53C4 00000000 */ nop
/* 0C5FC8 800C53C8 A0EA0014 */ sb $t2, 0x14($a3)
/* 0C5FCC 800C53CC 910B0019 */ lbu $t3, 0x19($t0)
/* 0C5FD0 800C53D0 00000000 */ nop
/* 0C5FD4 800C53D4 A0EB0015 */ sb $t3, 0x15($a3)
/* 0C5FD8 800C53D8 910C001A */ lbu $t4, 0x1a($t0)
/* 0C5FDC 800C53DC 00000000 */ nop
/* 0C5FE0 800C53E0 A0EC0016 */ sb $t4, 0x16($a3)
/* 0C5FE4 800C53E4 910E001B */ lbu $t6, 0x1b($t0)
/* 0C5FE8 800C53E8 00000000 */ nop
/* 0C5FEC 800C53EC A0EE0017 */ sb $t6, 0x17($a3)
/* 0C5FF0 800C53F0 910D001C */ lbu $t5, 0x1c($t0)
/* 0C5FF4 800C53F4 00000000 */ nop
/* 0C5FF8 800C53F8 A0ED0018 */ sb $t5, 0x18($a3)
/* 0C5FFC 800C53FC 910F001D */ lbu $t7, 0x1d($t0)
/* 0C6000 800C5400 00000000 */ nop
/* 0C6004 800C5404 A0EF0019 */ sb $t7, 0x19($a3)
/* 0C6008 800C5408 9518001E */ lhu $t8, 0x1e($t0)
/* 0C600C 800C540C 00000000 */ nop
/* 0C6010 800C5410 A4F8001A */ sh $t8, 0x1a($a3)
.L800C5414:
/* 0C6014 800C5414 00E01025 */ move $v0, $a3
.L800C5418:
/* 0C6018 800C5418 8FBF001C */ lw $ra, 0x1c($sp)
/* 0C601C 800C541C 8FB00018 */ lw $s0, 0x18($sp)
/* 0C6020 800C5420 03E00008 */ jr $ra
/* 0C6024 800C5424 27BD0148 */ addiu $sp, $sp, 0x148
+114 -117
View File
@@ -32,15 +32,7 @@ s8 sDialogueBoxIsOpen = FALSE;
// Descending powers of 10
s32 gDescPowsOf10[9] = {
1000000000,
100000000,
10000000,
1000000,
100000,
10000,
1000,
100,
10,
1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10,
};
// The dialogue box will draw in pieces, using properties from each line. It starts with a box
@@ -64,7 +56,9 @@ s8 sDialogueBoxDimensions[48] = {
#undef INWARDS
#undef OUTWARDS
OSDevMgr __osPiDevMgr = { 0, NULL, NULL, NULL, NULL, NULL, NULL, };
OSDevMgr __osPiDevMgr = {
0, NULL, NULL, NULL, NULL, NULL, NULL,
};
/*******************************/
@@ -74,7 +68,7 @@ s32 gNumberOfFonts;
FontData *gFonts;
DialogueBoxBackground *gDialogueBoxBackground;
unk8012A7EC *D_8012A7EC;
s32 D_8012A7F0; //Boolean value, seems to be related to X placement of menus on the X Axis?
s32 D_8012A7F0; // Boolean value, seems to be related to X placement of menus on the X Axis?
s8 sDialogueBoxCloseTimer;
s32 D_8012A7F8;
s32 D_8012A7FC;
@@ -90,16 +84,17 @@ void load_fonts(void) {
fontAssetData = load_asset_section_from_rom(ASSET_FONTS);
gFonts = (FontData *)(fontAssetData); // ???
gFonts = (FontData *) (fontAssetData); // ???
gNumberOfFonts = *(fontAssetData);
gFonts = (FontData *)(fontAssetData + 1);
gFonts = (FontData *) (fontAssetData + 1);
for (i = 0; i < gNumberOfFonts; i++) {
gFonts[i].unk28[0] = 0;
}
gDialogueBoxBackground = (DialogueBoxBackground *)allocate_from_main_pool_safe(DIALOGUEBOXBACKGROUND_TOTAL_SIZE + unk8012A7EC_TOTAL_SIZE, COLOUR_TAG_YELLOW);
D_8012A7EC = (unk8012A7EC *)&gDialogueBoxBackground[DIALOGUEBOXBACKGROUND_COUNT];
gDialogueBoxBackground = (DialogueBoxBackground *) allocate_from_main_pool_safe(
DIALOGUEBOXBACKGROUND_TOTAL_SIZE + unk8012A7EC_TOTAL_SIZE, COLOUR_TAG_YELLOW);
D_8012A7EC = (unk8012A7EC *) &gDialogueBoxBackground[DIALOGUEBOXBACKGROUND_COUNT];
for (i = 0; i < DIALOGUEBOXBACKGROUND_COUNT; i++) {
gDialogueBoxBackground[i].xpos = 0;
@@ -246,14 +241,16 @@ void draw_text(Gfx **displayList, s32 xpos, s32 ypos, char *text, AlignmentFlags
func_800C45A4(displayList, temp, text, alignmentFlags, 1.0f);
}
UNUSED void func_800C44C0(Gfx **displayList, s32 dialogueBoxID, char *text, AlignmentFlags alignmentFlags) {
UNUSED void func_800C44C0(Gfx **displayList, s32 dialogueBoxID, char *text,
AlignmentFlags alignmentFlags) {
if (dialogueBoxID >= 0 && dialogueBoxID < DIALOGUEBOXBACKGROUND_COUNT) {
DialogueBoxBackground *temp = &gDialogueBoxBackground[dialogueBoxID];
func_800C45A4(displayList, temp, text, alignmentFlags, 1.0f);
}
}
UNUSED void func_800C4510(Gfx **displayList, s32 dialogueBoxID, s32 xpos, s32 ypos, char *text, AlignmentFlags alignmentFlags) {
UNUSED void func_800C4510(Gfx **displayList, s32 dialogueBoxID, s32 xpos, s32 ypos, char *text,
AlignmentFlags alignmentFlags) {
if (dialogueBoxID >= 0 && dialogueBoxID < DIALOGUEBOXBACKGROUND_COUNT) {
DialogueBoxBackground *temp = &gDialogueBoxBackground[dialogueBoxID];
temp->xpos = (xpos == POS_CENTRED) ? temp->width >> 1 : xpos;
@@ -262,9 +259,8 @@ UNUSED void func_800C4510(Gfx **displayList, s32 dialogueBoxID, s32 xpos, s32 yp
}
}
#ifdef NON_MATCHING
//A few minor regalloc differences are all that's left.
void func_800C45A4(Gfx **dlist, DialogueBoxBackground *arg1, char *text, AlignmentFlags alignmentFlags, f32 arg4) {
void func_800C45A4(Gfx **dlist, DialogueBoxBackground *arg1, char *text, AlignmentFlags alignmentFlags,
f32 arg4) {
s32 temp_f4;
s32 temp_t9;
s32 ypos;
@@ -280,90 +276,83 @@ void func_800C45A4(Gfx **dlist, DialogueBoxBackground *arg1, char *text, Alignme
s32 textureHeight;
s32 xAlignmentDiff;
s32 yAlignmentDiff;
s32 newTempY;
s32 lastTextureIndex;
s32 charIndex;
s32 var_t0;
s32 newData;
s32 textureIndex;
s32 lastTextureIndex;
FontData *fontData;
s32 charIndex;
s32 newTempX;
s32 newTempY;
char curChar;
lastTextureIndex = -1;
xAlignmentDiff = -1;
lastTextureIndex = -1;
if (text != NULL) {
textureLry = 0;
xpos = arg1->xpos;
ypos = arg1->ypos;
fontData = &gFonts[arg1->font];
gSPDisplayList((*dlist)++, dDialogueBoxBegin);
if (arg1 != gDialogueBoxBackground) {
temp_f4 = (((arg1->y2 - arg1->y1) + 1) / (f32)2) * arg4;
temp_f4 = (((arg1->y2 - arg1->y1) + 1) / ((f32) 2)) * arg4;
temp_t9 = (arg1->y1 + arg1->y2) >> 1;
gDPSetScissor((*dlist)++,
G_SC_NON_INTERLACE,
arg1->x1,
temp_t9 - temp_f4,
arg1->x2,
temp_t9 + temp_f4
);
gDPSetScissor((*dlist)++, 0, arg1->x1, temp_t9 - temp_f4, arg1->x2, temp_t9 + temp_f4);
}
if (alignmentFlags & 5) {
if (alignmentFlags & (HORZ_ALIGN_RIGHT | HORZ_ALIGN_CENTER)) {
xAlignmentDiff = func_800C4DA0(text, xpos, arg1->font);
if (alignmentFlags & 1) {
if (alignmentFlags & HORZ_ALIGN_RIGHT) {
xpos = (xpos - xAlignmentDiff) + 1;
} else {
xpos -= xAlignmentDiff >> 1;
}
}
if (alignmentFlags & 2) {
if (alignmentFlags & VERT_ALIGN_BOTTOM) {
ypos = (ypos - fontData->unk22) + 1;
}
if (alignmentFlags & 8) {
if (alignmentFlags & VERT_ALIGN_MIDDLE) {
ypos -= fontData->unk22 >> 1;
}
if (arg1->textBGColourA != 0) {
gDPSetEnvColor((*dlist)++, arg1->textBGColourR, arg1->textBGColourG, arg1->textBGColourB, arg1->textBGColourA);
gDPSetEnvColor((*dlist)++, arg1->textBGColourR, arg1->textBGColourG, arg1->textBGColourB,
arg1->textBGColourA);
if (xAlignmentDiff == -1) {
xAlignmentDiff = func_800C4DA0(text, xpos, arg1->font);
}
newTempY = (fontData->unk22 + ypos - 1);
gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(dDialogueBoxDrawModes[1]), 2);
gDPFillRectangle((*dlist)++,
(xpos + arg1->x1),
(ypos + arg1->y1),
(xpos + arg1->x1 + (0, xAlignmentDiff) - 1), //0 comma operator is likely a fakematch
(newTempY + arg1->y1)
);
newTempX = xpos + xAlignmentDiff - 1;
newTempY = (ypos + fontData->unk22 - 1);
gDkrDmaDisplayList((*dlist)++, (u32)(((char *) dDialogueBoxDrawModes[1]) - 0x80000000), 2);
gDPFillRectangle((*dlist)++, xpos + arg1->x1, ypos + arg1->y1, newTempX + arg1->x1,
newTempY + arg1->y1);
gDPPipeSync((*dlist)++);
}
gDPSetPrimColor((*dlist)++, 0, 0, 255, 255, 255, arg1->opacity);
gDPSetEnvColor((*dlist)++, arg1->textColourR, arg1->textColourG, arg1->textColourB, arg1->textColourA);
gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(dDialogueBoxDrawModes[0]), 2);
gDPSetPrimColor((*dlist)++, textureLry, 0, 255, 255, 255, arg1->opacity);
gDPSetEnvColor((*dlist)++, arg1->textColourR, arg1->textColourG, arg1->textColourB,
arg1->textColourA);
gDkrDmaDisplayList((*dlist)++, (u32)(((char *) dDialogueBoxDrawModes[0]) - 0x80000000), 2);
gDPPipeSync((*dlist)++);
xpos += arg1->unk20;
ypos += arg1->unk22;
for (charIndex = 0; text[charIndex] != '\0' && arg1->y2 >= ypos; xpos += var_t0, charIndex++) {
for (charIndex = 0; (text[charIndex] != '\0') && (arg1->y2 >= ypos);
xpos += var_t0, charIndex++) {
curChar = text[charIndex];
newData = 0;
var_t0 = 0;
//Check the ASCII Range
if ((curChar < 0x21) || (curChar >= 0x80)) {
switch (curChar ) {
case ' ': //Space
switch (curChar) {
case ' ':
xpos += fontData->unk24;
break;
case '\n': //Line Feed
case '\n':
xpos = arg1->unk20;
ypos += fontData->unk22;
break;
case '\t': //Tab
case '\t':
xpos += fontData->unk26 - ((xpos - arg1->unk20) % fontData->unk26);
break;
case '\v': //VT - Vertical Tab
case '\v':
ypos += fontData->unk22;
break;
case '\r': //Carriage Return
case '\r':
xpos = arg1->unk20;
break;
default:
@@ -371,14 +360,15 @@ void func_800C45A4(Gfx **dlist, DialogueBoxBackground *arg1, char *text, Alignme
break;
}
} else {
curChar -= 0x20; //Convert lowercase to upper case
curChar -= 0x20;
textureIndex = fontData->unk100[curChar].unk0;
if (textureIndex != 0xFF) {
newData = 1;
if (lastTextureIndex != textureIndex) {
lastTextureIndex = textureIndex;
texture = fontData->texturePointers[textureIndex];
gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(texture->cmd), texture->numberOfCommands);
gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(texture->cmd),
texture->numberOfCommands);
}
textureWidth = fontData->unk100[curChar].unk2;
textureHeight = fontData->unk100[curChar].unk3;
@@ -386,47 +376,46 @@ void func_800C45A4(Gfx **dlist, DialogueBoxBackground *arg1, char *text, Alignme
textureT = fontData->unk100[curChar].unk5;
xAlignmentDiff = fontData->unk100[curChar].unk6;
yAlignmentDiff = fontData->unk100[curChar].unk7;
var_t0 = (fontData->unk20 == 0) ? fontData->unk100[curChar].unk1 : fontData->unk20;
var_t0 =
(fontData->unk20 == 0) ? (fontData->unk100[curChar].unk1) : (fontData->unk20);
newData = 1;
}
}
if (newData) {
textureUlx = ((arg1->x1 + xpos) + textureWidth) * 4;
textureUly = (arg1->y1 + ypos + textureHeight) * 4;
textureUly = ((arg1->y1 + ypos) + textureHeight) * 4;
textureLrx = (xAlignmentDiff * 4) + textureUlx;
textureLry = (yAlignmentDiff * 4) + textureUly;
textureS *= 32; //upper left coordinate for the texture derived from X
textureT *= 32; //upper left coordinate for the texture derived from Y
newTempY = (yAlignmentDiff * 4) + textureUly;
textureS *= 32;
textureT *= 32;
if ((textureUlx < 0) && (textureLrx > 0)) {
textureS += -textureUlx * 8;
textureS += (-textureUlx) * 8;
textureUlx = 0;
}
if ((textureUly < 0) && (textureLry > 0)) {
textureT += -textureUly * 8;
if ((textureUly <= (0 - 1)) && (newTempY > 0)) {
textureT += (-textureUly) * 8;
textureUly = 0;
}
gSPTextureRectangle((*dlist)++, textureUlx, textureUly, textureLrx, textureLry, 0, textureS, textureT, 1024, 1024);
gSPTextureRectangle((*dlist)++, textureUlx, textureUly, textureLrx, newTempY, 0,
textureS, textureT, 1024, 1024);
if (lastTextureIndex)
;
}
if (D_8012A7F0 && (var_t0 != 0)) {
if (D_8012A7F0 && var_t0) {
var_t0--;
}
}
arg1->xpos = xpos - arg1->unk20;
arg1->ypos = ypos - arg1->unk22;
gDPPipeSync((*dlist)++);
if (arg1 != gDialogueBoxBackground) {
func_80067A3C(dlist);
}
func_8007B3D0(dlist);
gDPPipeSync((*dlist)++);
}
}
#else
GLOBAL_ASM("asm/non_matchings/font/func_800C45A4.s")
#endif
s32 func_800C4DA0(char *text, s32 x, s32 font) {
s32 diffX, thisDiffX;
@@ -452,8 +441,8 @@ s32 func_800C4DA0(char *text, s32 x, s32 font) {
diffX += fontData->unk24;
}
} else {
ch -= 0x20; //Convert lower case to upper case ASCII
ch -= 0x20; // Convert lower case to upper case ASCII
if (fontData->unk100[ch].unk0 != 0xFF) {
if (fontData->unk20 == 0) {
diffX += fontData->unk100[ch].unk1;
@@ -475,18 +464,18 @@ void set_current_dialogue_box_coords(s32 dialogueBoxID, s32 x1, s32 y1, s32 x2,
temp->xpos = 0;
temp->ypos = 0;
if (x1 < x2) {
temp->x1 = (s16)x1;
temp->x2 = (s16)x2;
temp->x1 = (s16) x1;
temp->x2 = (s16) x2;
} else {
temp->x2 = (s16)x1;
temp->x1 = (s16)x2;
temp->x2 = (s16) x1;
temp->x1 = (s16) x2;
}
if (y1 < y2) {
temp->y1 = (s16)y1;
temp->y2 = (s16)y2;
temp->y1 = (s16) y1;
temp->y2 = (s16) y2;
} else {
temp->y2 = (s16)y1;
temp->y1 = (s16)y2;
temp->y2 = (s16) y1;
temp->y1 = (s16) y2;
}
temp->width = (temp->x2 - temp->x1) + 1;
temp->height = (temp->y2 - temp->y1) + 1;
@@ -502,7 +491,8 @@ void set_dialogue_font(s32 dialogueBoxID, s32 font) {
}
}
void set_current_dialogue_background_colour(s32 dialogueBoxID, s32 red, s32 green, s32 blue, s32 alpha) {
void set_current_dialogue_background_colour(s32 dialogueBoxID, s32 red, s32 green, s32 blue,
s32 alpha) {
if (dialogueBoxID > 0 && dialogueBoxID < DIALOGUEBOXBACKGROUND_COUNT) {
DialogueBoxBackground *temp = &gDialogueBoxBackground[dialogueBoxID];
temp->backgroundColourR = red;
@@ -561,23 +551,25 @@ void func_800C50D8(s32 dialogueBoxID) {
// Unused?
void func_800C510C(s32 dialogueBoxID, char *text, s32 arg2, s32 arg3) {
render_dialogue_text(dialogueBoxID, gDialogueBoxBackground[dialogueBoxID].xpos, gDialogueBoxBackground[dialogueBoxID].ypos, text, arg2, arg3);
render_dialogue_text(dialogueBoxID, gDialogueBoxBackground[dialogueBoxID].xpos,
gDialogueBoxBackground[dialogueBoxID].ypos, text, arg2, arg3);
}
#ifdef NON_EQUIVALENT
void *render_dialogue_text(s32 dialogueBoxID, s32 posX, s32 posY, char *text, s32 arg4, s32 flags) {
char parsedNumber;
DialogueBox *textBox;
FontData *fontData;
s32 temp_v0_2;
s32 i;
s32 var_a0;
char buffer[256];
unk8012A7EC *ret;
DialogueBox *textBox;
s32 i;
DialogueBoxBackground *bg;
FontData *fontData;
DialogueBox **textBoxPtr;
if (text == NULL) {
return NULL;
}
for (i = 0, ret = NULL; (i < 64) && (ret == NULL); i++) {
if (D_8012A7EC[i].unk1 == 0xFF) {
ret = &D_8012A7EC[i];
@@ -595,8 +587,8 @@ void *render_dialogue_text(s32 dialogueBoxID, s32 posX, s32 posY, char *text, s3
if (bg->font != FONT_UNK_FF) {
fontData = &gFonts[bg->font];
if (flags & 5) {
parse_string_with_number(text, &parsedNumber, arg4);
temp_v0_2 = func_800C4DA0(&parsedNumber, posX, bg->font);
parse_string_with_number(text, &buffer, arg4);
temp_v0_2 = func_800C4DA0(&buffer, posX, bg->font);
if (flags & 1) {
posX = (posX - temp_v0_2) + 1;
} else {
@@ -614,21 +606,21 @@ void *render_dialogue_text(s32 dialogueBoxID, s32 posX, s32 posY, char *text, s3
bg->textBox = (DialogueBox *) ret;
ret->nextBox = NULL;
} else {
textBox = bg->textBox;
//Feels like this should be a while loop, but it matches worse
if ((bg->textBox != NULL) && (arg4 < bg->textBox->textNum)) {
do {
textBox = textBox->nextBox;
} while (textBox != NULL && arg4 < textBox->textNum);
textBoxPtr = &bg->textBox;
textBox = *textBoxPtr;
while (textBox != NULL && arg4 < textBox->textNum) {
textBoxPtr = &textBox->nextBox;
textBox = textBox->nextBox;
}
*textBoxPtr = ret;
ret->nextBox = textBox;
}
ret->unk1 = arg4;
ret->text = text;
ret->posX = posX;
ret->posY = posY;
ret->unkC = 0;
ret->unkE = 0;
ret->posY = posY;
ret->textColourR = bg->textColourR;
ret->textColourG = bg->textColourG;
ret->textColourB = bg->textColourB;
@@ -644,9 +636,6 @@ void *render_dialogue_text(s32 dialogueBoxID, s32 posX, s32 posY, char *text, s3
return ret;
}
#else
GLOBAL_ASM("asm/non_matchings/font/render_dialogue_text.s")
#endif
/**
* Unused function that moved a dialogue box ID to the front of the stack.
@@ -806,7 +795,7 @@ void s32_to_string(char **outString, s32 number) {
// Loop through digit places.
hasDigit = FALSE;
i = 0;
while(i < 9) {
while (i < 9) {
pow = gDescPowsOf10[i++];
digit = '0';
if (number >= pow) {
@@ -837,7 +826,7 @@ void render_fill_rectangle(Gfx **dlist, s32 ulx, s32 uly, s32 lrx, s32 lry) {
u32 width = GET_VIDEO_WIDTH(widthAndHeight);
u32 height = GET_VIDEO_HEIGHT(widthAndHeight);
if (lrx >= 0 && (u32)ulx < width && lry >= 0 && (u32)uly < height) {
if (lrx >= 0 && (u32) ulx < width && lry >= 0 && (u32) uly < height) {
if (ulx < 0) {
ulx = 0;
}
@@ -867,22 +856,30 @@ void render_dialogue_box(Gfx **dlist, Mtx **mat, VertexList **verts, s32 dialogu
gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(&dDialogueBoxDrawModes[1]), 2);
gDPSetEnvColor((*dlist)++, 0, 0, 0, 0);
if ((dialogueBox->x2 - dialogueBox->x1) < 10 || (dialogueBox->y2 - dialogueBox->y1) < 10) {
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, dialogueBox->y2 + 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2,
dialogueBox->y2 + 2);
} else {
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 + 2, dialogueBox->x1 + 2, dialogueBox->y2 - 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, dialogueBox->y1 + 2);
render_fill_rectangle(dlist, dialogueBox->x2 - 2, dialogueBox->y1 + 2, dialogueBox->x2 + 2, dialogueBox->y2 - 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y2 - 2, dialogueBox->x2 + 2, dialogueBox->y2 + 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 + 2, dialogueBox->x1 + 2,
dialogueBox->y2 - 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2,
dialogueBox->y1 + 2);
render_fill_rectangle(dlist, dialogueBox->x2 - 2, dialogueBox->y1 + 2, dialogueBox->x2 + 2,
dialogueBox->y2 - 2);
render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y2 - 2, dialogueBox->x2 + 2,
dialogueBox->y2 + 2);
}
gDPPipeSync((*dlist)++);
gDPSetEnvColor((*dlist)++, dialogueBox->backgroundColourR, dialogueBox->backgroundColourG, dialogueBox->backgroundColourB, dialogueBox->backgroundColourA);
gDPSetEnvColor((*dlist)++, dialogueBox->backgroundColourR, dialogueBox->backgroundColourG,
dialogueBox->backgroundColourB, dialogueBox->backgroundColourA);
// Loops through sDialogueBoxDimensions, rendering fillrects until it forms a rounded rectangle.
// The array determines the width and height of each entry before drawing it.
for (i = 0; sDialogueBoxDimensions[i] >= 0; i += 5) {
x1 = sDialogueBoxDimensions[i] + dialogueBox->x1;
y1 = (sDialogueBoxDimensions[i + 1]) ? sDialogueBoxDimensions[i + 2] + dialogueBox->y2 : sDialogueBoxDimensions[i + 2] + dialogueBox->y1;
y1 = (sDialogueBoxDimensions[i + 1]) ? sDialogueBoxDimensions[i + 2] + dialogueBox->y2
: sDialogueBoxDimensions[i + 2] + dialogueBox->y1;
x2 = dialogueBox->x2 - sDialogueBoxDimensions[i];
y2 = (sDialogueBoxDimensions[i + 3]) ? sDialogueBoxDimensions[i + 4] + dialogueBox->y2 : sDialogueBoxDimensions[i + 4] + dialogueBox->y1;
y2 = (sDialogueBoxDimensions[i + 3]) ? sDialogueBoxDimensions[i + 4] + dialogueBox->y2
: sDialogueBoxDimensions[i + 4] + dialogueBox->y1;
render_fill_rectangle(dlist, x1, y1, x2, y2);
}
gDPPipeSync((*dlist)++);
@@ -927,7 +924,7 @@ void parse_string_with_number(char *input, char *output, s32 number) {
s32_to_string(&output, number);
input++;
} else {
*output = (signed char)*input; //It's either this cast, or change the function signature
*output = (signed char) *input; // It's either this cast, or change the function signature
input++;
output++;
}