diff --git a/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145DF8.s b/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145DF8.s deleted file mode 100644 index f5f8d63c26..0000000000 --- a/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145DF8.s +++ /dev/null @@ -1,19 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_80145DF8 -/* 0DC4F8 80145DF8 3C028007 */ lui $v0, 0x8007 -/* 0DC4FC 80145DFC 8C42419C */ lw $v0, 0x419c($v0) -/* 0DC500 80145E00 94430148 */ lhu $v1, 0x148($v0) -/* 0DC504 80145E04 240400B4 */ addiu $a0, $zero, 0xb4 -/* 0DC508 80145E08 3C018016 */ lui $at, 0x8016 -/* 0DC50C 80145E0C AC2095A0 */ sw $zero, -0x6a60($at) -/* 0DC510 80145E10 3C018015 */ lui $at, 0x8015 -/* 0DC514 80145E14 A020F12F */ sb $zero, -0xed1($at) -/* 0DC518 80145E18 A444015C */ sh $a0, 0x15c($v0) -/* 0DC51C 80145E1C 306300F0 */ andi $v1, $v1, 0xf0 -/* 0DC520 80145E20 03E00008 */ jr $ra -/* 0DC524 80145E24 A4430148 */ sh $v1, 0x148($v0) - diff --git a/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145E98.s b/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145E98.s deleted file mode 100644 index 02029dead4..0000000000 --- a/papermario/asm/nonmatchings/code_dc470_len_14c0/func_80145E98.s +++ /dev/null @@ -1,18 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_80145E98 -/* 0DC598 80145E98 3082FFFF */ andi $v0, $a0, 0xffff -/* 0DC59C 80145E9C 00A22823 */ subu $a1, $a1, $v0 -/* 0DC5A0 80145EA0 00A60018 */ mult $a1, $a2 -/* 0DC5A4 80145EA4 00001012 */ mflo $v0 -/* 0DC5A8 80145EA8 04420001 */ bltzl $v0, .L80145EB0 -/* 0DC5AC 80145EAC 244200FF */ addiu $v0, $v0, 0xff -.L80145EB0: -/* 0DC5B0 80145EB0 00021203 */ sra $v0, $v0, 8 -/* 0DC5B4 80145EB4 00821021 */ addu $v0, $a0, $v0 -/* 0DC5B8 80145EB8 03E00008 */ jr $ra -/* 0DC5BC 80145EBC 3042FFFF */ andi $v0, $v0, 0xffff - diff --git a/papermario/asm/nonmatchings/code_dc470_len_14c0/read_background_size.s b/papermario/asm/nonmatchings/code_dc470_len_14c0/read_background_size.s deleted file mode 100644 index 4c70b8fcd0..0000000000 --- a/papermario/asm/nonmatchings/code_dc470_len_14c0/read_background_size.s +++ /dev/null @@ -1,25 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel read_background_size -/* 0DC528 80145E28 3C038007 */ lui $v1, 0x8007 -/* 0DC52C 80145E2C 8C63419C */ lw $v1, 0x419c($v1) -/* 0DC530 80145E30 9482000C */ lhu $v0, 0xc($a0) -/* 0DC534 80145E34 A462014E */ sh $v0, 0x14e($v1) -/* 0DC538 80145E38 9482000E */ lhu $v0, 0xe($a0) -/* 0DC53C 80145E3C A4620150 */ sh $v0, 0x150($v1) -/* 0DC540 80145E40 94820008 */ lhu $v0, 8($a0) -/* 0DC544 80145E44 A462014A */ sh $v0, 0x14a($v1) -/* 0DC548 80145E48 9482000A */ lhu $v0, 0xa($a0) -/* 0DC54C 80145E4C A462014C */ sh $v0, 0x14c($v1) -/* 0DC550 80145E50 8C820000 */ lw $v0, ($a0) -/* 0DC554 80145E54 AC620154 */ sw $v0, 0x154($v1) -/* 0DC558 80145E58 94620148 */ lhu $v0, 0x148($v1) -/* 0DC55C 80145E5C 8C840004 */ lw $a0, 4($a0) -/* 0DC560 80145E60 34420001 */ ori $v0, $v0, 1 -/* 0DC564 80145E64 A4620148 */ sh $v0, 0x148($v1) -/* 0DC568 80145E68 03E00008 */ jr $ra -/* 0DC56C 80145E6C AC640158 */ sw $a0, 0x158($v1) - diff --git a/papermario/asm/nonmatchings/code_dc470_len_14c0/set_background_size.s b/papermario/asm/nonmatchings/code_dc470_len_14c0/set_background_size.s deleted file mode 100644 index 23c6dcf6c3..0000000000 --- a/papermario/asm/nonmatchings/code_dc470_len_14c0/set_background_size.s +++ /dev/null @@ -1,17 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel set_background_size -/* 0DC570 80145E70 3C028007 */ lui $v0, 0x8007 -/* 0DC574 80145E74 8C42419C */ lw $v0, 0x419c($v0) -/* 0DC578 80145E78 94430148 */ lhu $v1, 0x148($v0) -/* 0DC57C 80145E7C A444014E */ sh $a0, 0x14e($v0) -/* 0DC580 80145E80 A4450150 */ sh $a1, 0x150($v0) -/* 0DC584 80145E84 A446014A */ sh $a2, 0x14a($v0) -/* 0DC588 80145E88 A447014C */ sh $a3, 0x14c($v0) -/* 0DC58C 80145E8C 3063FFFE */ andi $v1, $v1, 0xfffe -/* 0DC590 80145E90 03E00008 */ jr $ra -/* 0DC594 80145E94 A4430148 */ sh $v1, 0x148($v0) - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337D0.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337D0.s deleted file mode 100644 index 70ff9c2fad..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337D0.s +++ /dev/null @@ -1,11 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_800337D0 -/* 00EBD0 800337D0 3C028007 */ lui $v0, 0x8007 -/* 00EBD4 800337D4 8C42419C */ lw $v0, 0x419c($v0) -/* 00EBD8 800337D8 03E00008 */ jr $ra -/* 00EBDC 800337DC A44400B6 */ sh $a0, 0xb6($v0) - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337E0.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337E0.s deleted file mode 100644 index 604be91da6..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337E0.s +++ /dev/null @@ -1,13 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_800337E0 -/* 00EBE0 800337E0 3C028007 */ lui $v0, 0x8007 -/* 00EBE4 800337E4 8C42419C */ lw $v0, 0x419c($v0) -/* 00EBE8 800337E8 A44400BC */ sh $a0, 0xbc($v0) -/* 00EBEC 800337EC A44400BA */ sh $a0, 0xba($v0) -/* 00EBF0 800337F0 03E00008 */ jr $ra -/* 00EBF4 800337F4 A44400B8 */ sh $a0, 0xb8($v0) - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337F8.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337F8.s deleted file mode 100644 index 9fe01e20ba..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_800337F8.s +++ /dev/null @@ -1,24 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_800337F8 -/* 00EBF8 800337F8 3C058007 */ lui $a1, 0x8007 -/* 00EBFC 800337FC 8CA5419C */ lw $a1, 0x419c($a1) -/* 00EC00 80033800 84A200B6 */ lh $v0, 0xb6($a1) -/* 00EC04 80033804 94A300B6 */ lhu $v1, 0xb6($a1) -/* 00EC08 80033808 14400003 */ bnez $v0, .L80033818 -/* 00EC0C 8003380C 00641023 */ subu $v0, $v1, $a0 -/* 00EC10 80033810 03E00008 */ jr $ra -/* 00EC14 80033814 24020001 */ addiu $v0, $zero, 1 - -.L80033818: -/* 00EC18 80033818 A4A200B6 */ sh $v0, 0xb6($a1) -/* 00EC1C 8003381C 00021400 */ sll $v0, $v0, 0x10 -/* 00EC20 80033820 04420001 */ bltzl $v0, .L80033828 -/* 00EC24 80033824 A4A000B6 */ sh $zero, 0xb6($a1) -.L80033828: -/* 00EC28 80033828 03E00008 */ jr $ra -/* 00EC2C 8003382C 0000102D */ daddu $v0, $zero, $zero - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033830.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033830.s deleted file mode 100644 index 16e04f4d8b..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033830.s +++ /dev/null @@ -1,27 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_80033830 -/* 00EC30 80033830 3C058007 */ lui $a1, 0x8007 -/* 00EC34 80033834 8CA5419C */ lw $a1, 0x419c($a1) -/* 00EC38 80033838 240600FF */ addiu $a2, $zero, 0xff -/* 00EC3C 8003383C 84A200B6 */ lh $v0, 0xb6($a1) -/* 00EC40 80033840 94A300B6 */ lhu $v1, 0xb6($a1) -/* 00EC44 80033844 14460003 */ bne $v0, $a2, .L80033854 -/* 00EC48 80033848 00641021 */ addu $v0, $v1, $a0 -/* 00EC4C 8003384C 03E00008 */ jr $ra -/* 00EC50 80033850 24020001 */ addiu $v0, $zero, 1 - -.L80033854: -/* 00EC54 80033854 A4A200B6 */ sh $v0, 0xb6($a1) -/* 00EC58 80033858 00021400 */ sll $v0, $v0, 0x10 -/* 00EC5C 8003385C 00021403 */ sra $v0, $v0, 0x10 -/* 00EC60 80033860 28420100 */ slti $v0, $v0, 0x100 -/* 00EC64 80033864 50400001 */ beql $v0, $zero, .L8003386C -/* 00EC68 80033868 A4A600B6 */ sh $a2, 0xb6($a1) -.L8003386C: -/* 00EC6C 8003386C 03E00008 */ jr $ra -/* 00EC70 80033870 0000102D */ daddu $v0, $zero, $zero - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033874.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033874.s deleted file mode 100644 index ffac556583..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/func_80033874.s +++ /dev/null @@ -1,30 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel func_80033874 -/* 00EC74 80033874 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 00EC78 80033878 AFB00010 */ sw $s0, 0x10($sp) -/* 00EC7C 8003387C 3C108007 */ lui $s0, 0x8007 -/* 00EC80 80033880 2610419C */ addiu $s0, $s0, 0x419c -/* 00EC84 80033884 AFBF0014 */ sw $ra, 0x14($sp) -/* 00EC88 80033888 8E020000 */ lw $v0, ($s0) -/* 00EC8C 8003388C 844200B6 */ lh $v0, 0xb6($v0) -/* 00EC90 80033890 44820000 */ mtc1 $v0, $f0 -/* 00EC94 80033894 00000000 */ nop -/* 00EC98 80033898 46800020 */ cvt.s.w $f0, $f0 -/* 00EC9C 8003389C 44050000 */ mfc1 $a1, $f0 -/* 00ECA0 800338A0 0C04DF62 */ jal func_80137D88 -/* 00ECA4 800338A4 0000202D */ daddu $a0, $zero, $zero -/* 00ECA8 800338A8 8E020000 */ lw $v0, ($s0) -/* 00ECAC 800338AC 904500B9 */ lbu $a1, 0xb9($v0) -/* 00ECB0 800338B0 904600BB */ lbu $a2, 0xbb($v0) -/* 00ECB4 800338B4 904700BD */ lbu $a3, 0xbd($v0) -/* 00ECB8 800338B8 0C04DF84 */ jal func_80137E10 -/* 00ECBC 800338BC 0000202D */ daddu $a0, $zero, $zero -/* 00ECC0 800338C0 8FBF0014 */ lw $ra, 0x14($sp) -/* 00ECC4 800338C4 8FB00010 */ lw $s0, 0x10($sp) -/* 00ECC8 800338C8 03E00008 */ jr $ra -/* 00ECCC 800338CC 27BD0018 */ addiu $sp, $sp, 0x18 - diff --git a/papermario/asm/nonmatchings/code_ebd0_len_6a0/start_battle_countdown.s b/papermario/asm/nonmatchings/code_ebd0_len_6a0/start_battle_countdown.s deleted file mode 100644 index d8aef05595..0000000000 --- a/papermario/asm/nonmatchings/code_ebd0_len_6a0/start_battle_countdown.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -.include "include/macro.inc" - -glabel start_battle_countdown -/* 00ECD0 800338D0 24020005 */ addiu $v0, $zero, 5 -/* 00ECD4 800338D4 3C01800A */ lui $at, 0x800a -/* 00ECD8 800338D8 A0220900 */ sb $v0, 0x900($at) -/* 00ECDC 800338DC 03E00008 */ jr $ra -/* 00ECE0 800338E0 00000000 */ nop - diff --git a/papermario/include/common_structs.h b/papermario/include/common_structs.h index d426be60e4..7f448ee906 100644 --- a/papermario/include/common_structs.h +++ b/papermario/include/common_structs.h @@ -39,13 +39,27 @@ typedef struct { /* 0x0AA */ s8 unk_AA; /* 0x0AB */ char unk_AB[1]; /* 0x0AC */ s8 unk_AC; - /* 0x0AD */ char unk_AD[0x87]; + /* 0x0AD */ char unk_AD[0x09]; + + /* 0x0B6 */ s16 fade_status; + /* 0x0B8 */ s16 boot_logos_unk1; + /* 0x0BA */ s16 boot_logos_unk2; + /* 0x0BC */ s16 boot_logos_unk3; + /* 0x0BE */ char unk_BE[0x76]; /* 0x134 */ u16 unk_134; /* 0x136 */ char unk_136[0x6]; /* 0x13C */ s16 unk_13C; /* 0x13E */ char unk_13E[0xA]; /* 0x148 */ s16 unk_148; - /* 0x14A */ char unk_14A[0x1E]; + /* 0x14A */ s16 unk_14A; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 unk_150; + /* 0x152 */ char unk_152[2]; + /* 0x154 */ s32 unk_154; + /* 0x158 */ s32 unk_158; + /* 0x15C */ s16 unk_15C; + /* 0x15E */ char unk_15E[0xA]; /* 0x168 */ s32 unk_168; } game_status; @@ -468,4 +482,13 @@ typedef struct { /* 0x164 */ s32* ptrCurrentLine; } script_context; // size = 0x168; +typedef struct { + /* 0x00 */ u32 palette; + /* 0x04 */ u32 raster; + /* 0x08 */ u16 startX; + /* 0x0A */ u16 startY; + /* 0x0C */ u16 width; + /* 0x0E */ u16 height; +} bg_header; // size = 0x10 + #endif diff --git a/papermario/include/variables.h b/papermario/include/variables.h index 6aa1c3c1ba..54abdcd8be 100644 --- a/papermario/include/variables.h +++ b/papermario/include/variables.h @@ -10,9 +10,12 @@ extern player_data gPlayerData; extern player_status gPlayerStatus; extern game_status* gGameStatusPtr[1]; extern item_table_entry gItemTable[364]; +extern s8 D_800A0900; extern s16* D_80151328; extern s16 D_8010CD10; extern s16 D_8010CD12; +extern s32 D_801595A0; +extern s8 D_8014F12F; extern u16 gMapTransitionAlpha; extern u16 D_800A0942; diff --git a/papermario/src/code_dc470_len_14c0.c b/papermario/src/code_dc470_len_14c0.c index 76bfbb6a93..d1f4927ae5 100644 --- a/papermario/src/code_dc470_len_14c0.c +++ b/papermario/src/code_dc470_len_14c0.c @@ -1,13 +1,71 @@ #include "common.h" INCLUDE_ASM(code_dc470_len_14c0, load_map_bg); +/* close match +void load_map_bg (s32 arg0){ + s32 tempvar0 = arg0; + s32 flowerfields_bg1 = 0x80140EE0; + s32 tempvar3 = get_variable(0, 0xF5DE0180); + if (tempvar0 == 0) + { + return; + } + else + { + if (tempvar3 > 0x0034) + { + if (strcmp(tempvar0, 0x8014F120) == 0) + { + tempvar0 = flowerfields_bg1; + } + load_asset_by_name (tempvar0, 0); + } + } + decode_yay0(tempvar0, 0x80200000); + general_heap_free(tempvar0); +} +*/ -INCLUDE_ASM(code_dc470_len_14c0, func_80145DF8); +void func_80145DF8(void) { + game_status* gameStatus = *gGameStatusPtr; + D_801595A0 = 0; + D_8014F12F = 0; + gameStatus->unk_15C = 0xB4; + gameStatus->unk_148 = gameStatus->unk_148 & 0xF0; + return; +} -INCLUDE_ASM(code_dc470_len_14c0, read_background_size); +u16 read_background_size(bg_header *bg) { + game_status* gameStatus = *gGameStatusPtr; + gameStatus->unk_14E = bg->width; + gameStatus->unk_150 = bg->height; + gameStatus->unk_14A = bg->startX; + gameStatus->unk_14C = bg->startY; + gameStatus->unk_154 = bg->palette; + gameStatus->unk_158 = bg->raster; + gameStatus->unk_148 = gameStatus->unk_148 | 1; + return; +} -INCLUDE_ASM(code_dc470_len_14c0, set_background_size); +u16 set_background_size(s16 startX, s16 startY, s16 sizeX, s16 sizeY) { + game_status* gameStatus = *gGameStatusPtr; + gameStatus->unk_148 = gameStatus->unk_148 & 0xFFFE; + gameStatus->unk_14E = startX; + gameStatus->unk_150 = startY; + gameStatus->unk_14A = sizeX; + gameStatus->unk_14C = sizeY; + return; +} -INCLUDE_ASM(code_dc470_len_14c0, func_80145E98); +s32 func_80145E98(s32 arg0, s32 arg1, s32 arg2) { + s32 temp_lo; + + temp_lo = (arg1 - (arg0 & 0xFFFF)) * arg2; + if (temp_lo < 0) { + temp_lo = temp_lo + 0xFF; + } + temp_lo = arg0 + (temp_lo >> 0x08); + return temp_lo & 0xFFFF; +} INCLUDE_ASM(code_dc470_len_14c0, func_80145EC0); diff --git a/papermario/src/code_ebd0_len_6a0.c b/papermario/src/code_ebd0_len_6a0.c index 0e017eb358..5f738ac852 100644 --- a/papermario/src/code_ebd0_len_6a0.c +++ b/papermario/src/code_ebd0_len_6a0.c @@ -1,15 +1,59 @@ #include "common.h" -INCLUDE_ASM(code_ebd0_len_6a0, func_800337D0); +void func_800337D0(s16 new_fade_status) { + game_status* gameStatus = *gGameStatusPtr; + gameStatus->fade_status = new_fade_status; + return; +} -INCLUDE_ASM(code_ebd0_len_6a0, func_800337E0); +void func_800337E0(s16 arg0) { + game_status* gameStatus = *gGameStatusPtr; + gameStatus->boot_logos_unk3 = arg0; + gameStatus->boot_logos_unk2 = arg0; + gameStatus->boot_logos_unk1 = arg0; +} -INCLUDE_ASM(code_ebd0_len_6a0, func_800337F8); +s16 func_800337F8(subtract_val) { + game_status* gameStatus = *gGameStatusPtr; + if (gameStatus->fade_status != 0){ + gameStatus->fade_status -= subtract_val; + if (gameStatus->fade_status << 0x10 < 0){ + gameStatus->fade_status = 0; + } + } + else { + return 1; + } + return 0; +} -INCLUDE_ASM(code_ebd0_len_6a0, func_80033830); +s16 func_80033830(add_val) { + game_status* gameStatus = *gGameStatusPtr; + if (gameStatus->fade_status != 0xFF){ + gameStatus->fade_status += add_val; + if ((gameStatus->fade_status >= 0x100)){ + gameStatus->fade_status = 0xFF; + } + } + else { + return 1; + } + return 0; +} -INCLUDE_ASM(code_ebd0_len_6a0, func_80033874); +void func_80137D88(s32, f32); +void func_80137E10(s32, u8, u8, u8); + +void func_80033874(void) { + + func_80137D88(0, (f32) (*gGameStatusPtr)->fade_status); + func_80137E10(0, (*gGameStatusPtr)->boot_logos_unk1, (*gGameStatusPtr)->boot_logos_unk2, (*gGameStatusPtr)->boot_logos_unk3); + return 0; +} + +s8 start_battle_countdown(void) { + D_800A0900 = 5; +} -INCLUDE_ASM(code_ebd0_len_6a0, start_battle_countdown); INCLUDE_ASM(code_ebd0_len_6a0, step_battle); diff --git a/papermario/undefined_syms.txt b/papermario/undefined_syms.txt index c2357687d5..1e0c9eb5bc 100644 --- a/papermario/undefined_syms.txt +++ b/papermario/undefined_syms.txt @@ -33,6 +33,7 @@ D_80074021 = 0x80074021; D_800959D4 = 0x800959D4; D_8009A5D8 = 0x8009A5D8; D_8009A650 = 0x8009A650; +D_800A0900 = 0x800A0900; D_800DC500 = 0x800DC500; D_8010F6D0 = 0x8010F6D0; D_8010F304 = 0x8010F304; @@ -53,12 +54,14 @@ D_00316D90 = 0x00316D90; D_00316F30 = 0x00316F30; D_8010D000 = 0x8010D000; +D_8014F12F = 0x8014F12F; D_8014F140 = 0x8014F140; D_80151308 = 0x80151308; D_80151328 = 0x80151328; gCurrentDoorSoundsSet = 0x80151340; +D_801595A0 = 0x801595A0; D_8015C7C0 = 0x8015C7C0; func_802A91F8 = 0x802A91F8;