Merge remote-tracking branch 'origin/master' into sr-structs

This commit is contained in:
Alex Bates 2020-08-14 23:59:42 +01:00
commit eb3ef759d7
16 changed files with 110 additions and 273 deletions

View File

@ -1,42 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel load_map_bg
/* 0DC470 80145D70 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0DC474 80145D74 AFBF001C */ sw $ra, 0x1c($sp)
/* 0DC478 80145D78 1080001B */ beqz $a0, .L80145DE8
/* 0DC47C 80145D7C AFB00018 */ sw $s0, 0x18($sp)
/* 0DC480 80145D80 0080802D */ daddu $s0, $a0, $zero
/* 0DC484 80145D84 0000202D */ daddu $a0, $zero, $zero
/* 0DC488 80145D88 3C05F5DE */ lui $a1, 0xf5de
/* 0DC48C 80145D8C 0C0B1EAF */ jal get_variable
/* 0DC490 80145D90 34A50180 */ ori $a1, $a1, 0x180
/* 0DC494 80145D94 28420035 */ slti $v0, $v0, 0x35
/* 0DC498 80145D98 1440000A */ bnez $v0, .L80145DC4
/* 0DC49C 80145D9C 0200202D */ daddu $a0, $s0, $zero
/* 0DC4A0 80145DA0 3C058015 */ lui $a1, 0x8015
/* 0DC4A4 80145DA4 24A5F120 */ addiu $a1, $a1, -0xee0
/* 0DC4A8 80145DA8 0C01BB5C */ jal strcmp
/* 0DC4AC 80145DAC 0200202D */ daddu $a0, $s0, $zero
/* 0DC4B0 80145DB0 54400004 */ bnel $v0, $zero, .L80145DC4
/* 0DC4B4 80145DB4 0200202D */ daddu $a0, $s0, $zero
/* 0DC4B8 80145DB8 3C108015 */ lui $s0, 0x8015
/* 0DC4BC 80145DBC 2610F128 */ addiu $s0, $s0, -0xed8
/* 0DC4C0 80145DC0 0200202D */ daddu $a0, $s0, $zero
.L80145DC4:
/* 0DC4C4 80145DC4 0C016B3A */ jal load_asset_by_name
/* 0DC4C8 80145DC8 27A50010 */ addiu $a1, $sp, 0x10
/* 0DC4CC 80145DCC 0040802D */ daddu $s0, $v0, $zero
/* 0DC4D0 80145DD0 3C058020 */ lui $a1, 0x8020
/* 0DC4D4 80145DD4 24A50000 */ addiu $a1, $a1, 0
/* 0DC4D8 80145DD8 0C01BB7C */ jal decode_yay0
/* 0DC4DC 80145DDC 0200202D */ daddu $a0, $s0, $zero
/* 0DC4E0 80145DE0 0C00AB1E */ jal general_heap_free
/* 0DC4E4 80145DE4 0200202D */ daddu $a0, $s0, $zero
.L80145DE8:
/* 0DC4E8 80145DE8 8FBF001C */ lw $ra, 0x1c($sp)
/* 0DC4EC 80145DEC 8FB00018 */ lw $s0, 0x18($sp)
/* 0DC4F0 80145DF0 03E00008 */ jr $ra
/* 0DC4F4 80145DF4 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel does_script_exist
/* 0E8B14 802C4164 0000282D */ daddu $a1, $zero, $zero
/* 0E8B18 802C4168 3C03802E */ lui $v1, 0x802e
/* 0E8B1C 802C416C 8C63A890 */ lw $v1, -0x5770($v1)
.L802C4170:
/* 0E8B20 802C4170 8C620000 */ lw $v0, ($v1)
/* 0E8B24 802C4174 10400006 */ beqz $v0, .L802C4190
/* 0E8B28 802C4178 24A50001 */ addiu $a1, $a1, 1
/* 0E8B2C 802C417C 8C420144 */ lw $v0, 0x144($v0)
/* 0E8B30 802C4180 14440004 */ bne $v0, $a0, .L802C4194
/* 0E8B34 802C4184 28A20080 */ slti $v0, $a1, 0x80
/* 0E8B38 802C4188 03E00008 */ jr $ra
/* 0E8B3C 802C418C 24020001 */ addiu $v0, $zero, 1
.L802C4190:
/* 0E8B40 802C4190 28A20080 */ slti $v0, $a1, 0x80
.L802C4194:
/* 0E8B44 802C4194 1440FFF6 */ bnez $v0, .L802C4170
/* 0E8B48 802C4198 24630004 */ addiu $v1, $v1, 4
/* 0E8B4C 802C419C 03E00008 */ jr $ra
/* 0E8B50 802C41A0 0000102D */ daddu $v0, $zero, $zero

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel get_script_by_id
/* 0E9158 802C47A8 0000302D */ daddu $a2, $zero, $zero
/* 0E915C 802C47AC 3C05802E */ lui $a1, 0x802e
/* 0E9160 802C47B0 8CA5A890 */ lw $a1, -0x5770($a1)
.L802C47B4:
/* 0E9164 802C47B4 8CA30000 */ lw $v1, ($a1)
/* 0E9168 802C47B8 10600006 */ beqz $v1, .L802C47D4
/* 0E916C 802C47BC 24C60001 */ addiu $a2, $a2, 1
/* 0E9170 802C47C0 8C620144 */ lw $v0, 0x144($v1)
/* 0E9174 802C47C4 14440004 */ bne $v0, $a0, .L802C47D8
/* 0E9178 802C47C8 28C20080 */ slti $v0, $a2, 0x80
/* 0E917C 802C47CC 03E00008 */ jr $ra
/* 0E9180 802C47D0 0060102D */ daddu $v0, $v1, $zero
.L802C47D4:
/* 0E9184 802C47D4 28C20080 */ slti $v0, $a2, 0x80
.L802C47D8:
/* 0E9188 802C47D8 1440FFF6 */ bnez $v0, .L802C47B4
/* 0E918C 802C47DC 24A50004 */ addiu $a1, $a1, 4
/* 0E9190 802C47E0 03E00008 */ jr $ra
/* 0E9194 802C47E4 0000102D */ daddu $v0, $zero, $zero

View File

@ -1,12 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel get_script_by_index
/* 0E9140 802C4790 3C02802E */ lui $v0, 0x802e
/* 0E9144 802C4794 8C42A890 */ lw $v0, -0x5770($v0)
/* 0E9148 802C4798 00042080 */ sll $a0, $a0, 2
/* 0E914C 802C479C 00822021 */ addu $a0, $a0, $v0
/* 0E9150 802C47A0 03E00008 */ jr $ra
/* 0E9154 802C47A4 8C820000 */ lw $v0, ($a0)

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel kill_all_scripts
/* 0E8AC4 802C4114 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0E8AC8 802C4118 AFB00010 */ sw $s0, 0x10($sp)
/* 0E8ACC 802C411C 0000802D */ daddu $s0, $zero, $zero
/* 0E8AD0 802C4120 AFBF0014 */ sw $ra, 0x14($sp)
.L802C4124:
/* 0E8AD4 802C4124 3C03802E */ lui $v1, 0x802e
/* 0E8AD8 802C4128 8C63A890 */ lw $v1, -0x5770($v1)
/* 0E8ADC 802C412C 00101080 */ sll $v0, $s0, 2
/* 0E8AE0 802C4130 00431021 */ addu $v0, $v0, $v1
/* 0E8AE4 802C4134 8C440000 */ lw $a0, ($v0)
/* 0E8AE8 802C4138 10800003 */ beqz $a0, .L802C4148
/* 0E8AEC 802C413C 26100001 */ addiu $s0, $s0, 1
/* 0E8AF0 802C4140 0C0B0FCF */ jal kill_script
/* 0E8AF4 802C4144 00000000 */ nop
.L802C4148:
/* 0E8AF8 802C4148 2A020080 */ slti $v0, $s0, 0x80
/* 0E8AFC 802C414C 1440FFF5 */ bnez $v0, .L802C4124
/* 0E8B00 802C4150 00000000 */ nop
/* 0E8B04 802C4154 8FBF0014 */ lw $ra, 0x14($sp)
/* 0E8B08 802C4158 8FB00010 */ lw $s0, 0x10($sp)
/* 0E8B0C 802C415C 03E00008 */ jr $ra
/* 0E8B10 802C4160 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,34 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel kill_script_by_ID
/* 0E8A5C 802C40AC 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0E8A60 802C40B0 AFB10014 */ sw $s1, 0x14($sp)
/* 0E8A64 802C40B4 0080882D */ daddu $s1, $a0, $zero
/* 0E8A68 802C40B8 AFB00010 */ sw $s0, 0x10($sp)
/* 0E8A6C 802C40BC 0000802D */ daddu $s0, $zero, $zero
/* 0E8A70 802C40C0 AFBF0018 */ sw $ra, 0x18($sp)
.L802C40C4:
/* 0E8A74 802C40C4 3C03802E */ lui $v1, 0x802e
/* 0E8A78 802C40C8 8C63A890 */ lw $v1, -0x5770($v1)
/* 0E8A7C 802C40CC 00101080 */ sll $v0, $s0, 2
/* 0E8A80 802C40D0 00431021 */ addu $v0, $v0, $v1
/* 0E8A84 802C40D4 8C440000 */ lw $a0, ($v0)
/* 0E8A88 802C40D8 10800006 */ beqz $a0, .L802C40F4
/* 0E8A8C 802C40DC 26100001 */ addiu $s0, $s0, 1
/* 0E8A90 802C40E0 8C820144 */ lw $v0, 0x144($a0)
/* 0E8A94 802C40E4 14510003 */ bne $v0, $s1, .L802C40F4
/* 0E8A98 802C40E8 00000000 */ nop
/* 0E8A9C 802C40EC 0C0B0FCF */ jal kill_script
/* 0E8AA0 802C40F0 00000000 */ nop
.L802C40F4:
/* 0E8AA4 802C40F4 2A020080 */ slti $v0, $s0, 0x80
/* 0E8AA8 802C40F8 1440FFF2 */ bnez $v0, .L802C40C4
/* 0E8AAC 802C40FC 00000000 */ nop
/* 0E8AB0 802C4100 8FBF0018 */ lw $ra, 0x18($sp)
/* 0E8AB4 802C4104 8FB10014 */ lw $s1, 0x14($sp)
/* 0E8AB8 802C4108 8FB00010 */ lw $s0, 0x10($sp)
/* 0E8ABC 802C410C 03E00008 */ jr $ra
/* 0E8AC0 802C4110 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80033540
/* 00E940 80033540 3C03800A */ lui $v1, 0x800a
/* 00E944 80033544 2463A650 */ addiu $v1, $v1, -0x59b0
/* 00E948 80033548 8C620000 */ lw $v0, ($v1)
/* 00E94C 8003354C 34420008 */ ori $v0, $v0, 8
/* 00E950 80033550 AC620000 */ sw $v0, ($v1)
/* 00E954 80033554 3C038007 */ lui $v1, 0x8007
/* 00E958 80033558 8C63419C */ lw $v1, 0x419c($v1)
/* 00E95C 8003355C 24020003 */ addiu $v0, $zero, 3
/* 00E960 80033560 03E00008 */ jr $ra
/* 00E964 80033564 A06200AC */ sb $v0, 0xac($v1)

View File

@ -1,26 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel func_80033788
/* 00EB88 80033788 27BDFFD8 */ addiu $sp, $sp, -0x28
/* 00EB8C 8003378C 240200FF */ addiu $v0, $zero, 0xff
/* 00EB90 80033790 0000202D */ daddu $a0, $zero, $zero
/* 00EB94 80033794 0080282D */ daddu $a1, $a0, $zero
/* 00EB98 80033798 2406013F */ addiu $a2, $zero, 0x13f
/* 00EB9C 8003379C 240700EF */ addiu $a3, $zero, 0xef
/* 00EBA0 800337A0 AFBF0020 */ sw $ra, 0x20($sp)
/* 00EBA4 800337A4 AFA00010 */ sw $zero, 0x10($sp)
/* 00EBA8 800337A8 AFA00014 */ sw $zero, 0x14($sp)
/* 00EBAC 800337AC AFA00018 */ sw $zero, 0x18($sp)
/* 00EBB0 800337B0 0C00AAD7 */ jal func_8002AB5C
/* 00EBB4 800337B4 AFA2001C */ sw $v0, 0x1c($sp)
/* 00EBB8 800337B8 8FBF0020 */ lw $ra, 0x20($sp)
/* 00EBBC 800337BC 03E00008 */ jr $ra
/* 00EBC0 800337C0 27BD0028 */ addiu $sp, $sp, 0x28
/* 00EBC4 800337C4 00000000 */ nop
/* 00EBC8 800337C8 00000000 */ nop
/* 00EBCC 800337CC 00000000 */ nop

View File

@ -1,37 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel MakeLerp
/* 0F8F60 802D45B0 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0F8F64 802D45B4 AFB10014 */ sw $s1, 0x14($sp)
/* 0F8F68 802D45B8 0080882D */ daddu $s1, $a0, $zero
/* 0F8F6C 802D45BC AFBF0018 */ sw $ra, 0x18($sp)
/* 0F8F70 802D45C0 AFB00010 */ sw $s0, 0x10($sp)
/* 0F8F74 802D45C4 8E30000C */ lw $s0, 0xc($s1)
/* 0F8F78 802D45C8 8E050000 */ lw $a1, ($s0)
/* 0F8F7C 802D45CC 0C0B1EAF */ jal get_variable
/* 0F8F80 802D45D0 26100004 */ addiu $s0, $s0, 4
/* 0F8F84 802D45D4 AE2200B4 */ sw $v0, 0xb4($s1)
/* 0F8F88 802D45D8 8E050000 */ lw $a1, ($s0)
/* 0F8F8C 802D45DC 26100004 */ addiu $s0, $s0, 4
/* 0F8F90 802D45E0 0C0B1EAF */ jal get_variable
/* 0F8F94 802D45E4 0220202D */ daddu $a0, $s1, $zero
/* 0F8F98 802D45E8 AE2200B8 */ sw $v0, 0xb8($s1)
/* 0F8F9C 802D45EC 8E050000 */ lw $a1, ($s0)
/* 0F8FA0 802D45F0 26100004 */ addiu $s0, $s0, 4
/* 0F8FA4 802D45F4 0C0B1EAF */ jal get_variable
/* 0F8FA8 802D45F8 0220202D */ daddu $a0, $s1, $zero
/* 0F8FAC 802D45FC AE2200C0 */ sw $v0, 0xc0($s1)
/* 0F8FB0 802D4600 8E050000 */ lw $a1, ($s0)
/* 0F8FB4 802D4604 0C0B1EAF */ jal get_variable
/* 0F8FB8 802D4608 0220202D */ daddu $a0, $s1, $zero
/* 0F8FBC 802D460C AE2200B0 */ sw $v0, 0xb0($s1)
/* 0F8FC0 802D4610 AE2000BC */ sw $zero, 0xbc($s1)
/* 0F8FC4 802D4614 8FBF0018 */ lw $ra, 0x18($sp)
/* 0F8FC8 802D4618 8FB10014 */ lw $s1, 0x14($sp)
/* 0F8FCC 802D461C 8FB00010 */ lw $s0, 0x10($sp)
/* 0F8FD0 802D4620 24020002 */ addiu $v0, $zero, 2
/* 0F8FD4 802D4624 03E00008 */ jr $ra
/* 0F8FD8 802D4628 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -10,11 +10,19 @@ extern player_data gPlayerData;
extern player_status gPlayerStatus;
extern game_status* gGameStatusPtr[1];
extern item_table_entry gItemTable[364];
extern script_context* gWorldScriptList[128];
extern script_context* gBattleScriptList[128];
extern script_context** gCurrentScriptListPtr[128];
extern s8 D_800A0900;
extern s16* D_80151328;
extern s16 D_8010CD10;
extern s16 D_8010CD12;
extern s32 D_801595A0;
extern char gCloudyFlowerFieldsBg[]; // "fla_bg"
extern char gSunnyFlowerFieldsBg[]; // "flb_bg"
extern bg_header gBackgroundImage;
extern s8 D_8014F12F;
// Triggers

View File

@ -29,7 +29,7 @@ void func_80036130(void) {
D_800A0944 = 0x00;
if (gameStatus->prevArea != gameStatus->areaID) {
gameStatus->changedArea = 0x01;
gameStatus->changedArea = 1;
gameStatus->prevArea = gameStatus->areaID;
} else {
gameStatus->changedArea = 0;

View File

@ -1,25 +1,26 @@
#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);
void load_map_bg(char* optAssetName) {
UNK_PTR compressedData;
u32 assetSize;
char* assetName;
if (optAssetName == NULL) return;
assetName = optAssetName;
// StoryProgress check
if (get_variable(0, 0xF5DE0180) >= 0x35) {
// Use sunny Flower Fields bg rather than cloudy
// TODO: these globals should be string literals
if (!strcmp(assetName, gCloudyFlowerFieldsBg)) {
assetName = gSunnyFlowerFieldsBg;
}
}
decode_yay0(tempvar0, 0x80200000);
general_heap_free(tempvar0);
compressedData = load_asset_by_name(assetName, &assetSize);
decode_yay0(compressedData, &gBackgroundImage);
general_heap_free(compressedData);
}
*/
void func_80145DF8(void) {
game_status* gameStatus = *gGameStatusPtr;

View File

@ -26,11 +26,43 @@ INCLUDE_ASM(code_e79b0_len_1920, func_802C3EE4);
INCLUDE_ASM(code_e79b0_len_1920, kill_script);
INCLUDE_ASM(code_e79b0_len_1920, kill_script_by_ID);
void* kill_script_by_ID(s32 id) {
s32 i;
script_context* scriptContextPtr;
INCLUDE_ASM(code_e79b0_len_1920, kill_all_scripts);
for (i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
kill_script(scriptContextPtr);
}
}
}
INCLUDE_ASM(code_e79b0_len_1920, does_script_exist);
s32 kill_all_scripts(void) {
s32 i;
script_context* scriptContextPtr;
for(i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL) {
kill_script(scriptContextPtr);
}
}
return;
}
s32 does_script_exist(s32 id) {
s32 i;
script_context* scriptContextPtr;
for(i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
return 1;
}
}
return 0;
}
INCLUDE_ASM(code_e79b0_len_1920, does_script_exist_by_ref);
@ -68,9 +100,25 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others);
INCLUDE_ASM(code_e79b0_len_1920, resume_group_others);
INCLUDE_ASM(code_e79b0_len_1920, get_script_by_index);
script_context* get_script_by_index(s32 index) {
return (*gCurrentScriptListPtr)[index];
}
script_context* get_script_by_id(s32 id) {
s32 i;
script_context* scriptContextPtr;
for (i=0; i < ARRAY_COUNT(gCurrentScriptListPtr); i++) {
if ((*gCurrentScriptListPtr)[i] != NULL) {
scriptContextPtr = (*gCurrentScriptListPtr)[i];
if (scriptContextPtr->uniqueID == id) {
return scriptContextPtr;
}
}
}
return 0;
}
INCLUDE_ASM(code_e79b0_len_1920, get_script_by_id);
INCLUDE_ASM(code_e79b0_len_1920, set_script_flags);

View File

@ -1,7 +1,12 @@
#include "common.h"
INCLUDE_ASM(code_e940_len_290, func_80033540);
void func_80033540(void) {
D_8009A650[0] |= 8;
(*gGameStatusPtr)->loadMenuState = 3;
}
INCLUDE_ASM(code_e940_len_290, func_80033568);
INCLUDE_ASM(code_e940_len_290, func_80033788);
void func_80033788(void) {
func_8002AB5C(0, 0, 0x13F, 0xEF, 0, 0, 0, 0xFF);
}

View File

@ -1,6 +1,22 @@
#include "common.h"
INCLUDE_ASM(code_f8f60_len_1560, MakeLerp);
s32 MakeLerp(script_context* script, s32 initialCall) {
s32* ptrReadPos = script->ptrReadPos;
s32* ptrNextPos = *ptrReadPos++;
s32* ptrNextPos2;
s32* ptrNextPos3;
s32* ptrNextPos4;
script->varTable[12] = get_variable(script, ptrNextPos);
ptrNextPos2 = *ptrReadPos++;
script->varTable[13] = get_variable(script, ptrNextPos2);
ptrNextPos3 = *ptrReadPos++;
script->varTable[15] = get_variable(script, ptrNextPos3);
ptrNextPos4 = *ptrReadPos++;
script->varTable[11] = get_variable(script, ptrNextPos4);
script->varTable[14] = 0;
return 2;
}
INCLUDE_ASM(code_f8f60_len_1560, UpdateLerp);

View File

@ -3,6 +3,9 @@ gUIStatus = 0x8010EF58;
gPlayerData = 0x8010F290;
gPlayerStatus = 0x8010EFC8;
gItemTable = 0x800878E0;
gWorldScriptList = 0x802DA490;
gBattleScriptList = 0x802DA690;
gCurrentScriptListPtr = 0x802DA890;
D_80147574 = 0x80147574;
gMapTransitionAlpha = 0x800A0940;
@ -36,6 +39,7 @@ D_8009A650 = 0x8009A650;
D_800A0900 = 0x800A0900;
D_800DC500 = 0x800DC500;
D_8010F6D0 = 0x8010F6D0;
gBackgroundImage = 0x80200000;
D_802C3000 = 0x802C3000;
D_802DBD40 = 0x802DBD40;
D_802E0D90 = 0x802E0D90;
@ -52,6 +56,8 @@ D_00316D90 = 0x00316D90;
D_00316F30 = 0x00316F30;
D_8010D000 = 0x8010D000;
gCloudyFlowerFieldsBg = 0x8014F120;
gSunnyFlowerFieldsBg = 0x8014F128;
D_8014F12F = 0x8014F12F;
D_8014F140 = 0x8014F140;
D_80151308 = 0x80151308;