more refinements on script list stuff

This commit is contained in:
Jdog 2020-08-14 07:25:33 -07:00
parent a2f9747112
commit 73e1eff76e
7 changed files with 20 additions and 126 deletions

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,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

@ -5,12 +5,18 @@
#include "common_structs.h"
#include "types.h"
#define MAX_SCRIPT_LIST_LENGTH 128
extern ui_status gUIStatus;
extern player_data gPlayerData;
extern player_status gPlayerStatus;
extern game_status* gGameStatusPtr[1];
extern item_table_entry gItemTable[364];
extern s32* gCurrentScriptList;
extern script_context* gWorldScriptList[MAX_SCRIPT_LIST_LENGTH];
extern script_context* gBattleScriptList[MAX_SCRIPT_LIST_LENGTH];
extern script_context** gCurrentScriptListPtr;
extern s8 D_800A0900;
extern s16* D_80151328;
extern s16 D_8010CD10;

View File

@ -30,8 +30,8 @@ void* kill_script_by_ID(s32 id) {
s32 i;
script_context* scriptContextPtr;
for (i=0; i < 128; i++) {
scriptContextPtr = (script_context*) gCurrentScriptList[i];
for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) {
scriptContextPtr = gCurrentScriptListPtr[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
kill_script(scriptContextPtr);
}
@ -42,8 +42,8 @@ s32 kill_all_scripts(void) {
s32 i;
script_context* scriptContextPtr;
for(i=0; i < 128; i++) {
scriptContextPtr = (script_context*) gCurrentScriptList[i];
for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) {
scriptContextPtr = gCurrentScriptListPtr[i];
if (scriptContextPtr != NULL) {
kill_script(scriptContextPtr);
}
@ -55,8 +55,8 @@ s32 does_script_exist(s32 id) {
s32 i;
script_context* scriptContextPtr;
for(i=0; i < 128; i++) {
scriptContextPtr = (script_context*) gCurrentScriptList[i];
for(i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) {
scriptContextPtr = gCurrentScriptListPtr[i];
if (scriptContextPtr != NULL && scriptContextPtr->uniqueID == id) {
return 1;
}
@ -101,16 +101,16 @@ INCLUDE_ASM(code_e79b0_len_1920, suspend_group_others);
INCLUDE_ASM(code_e79b0_len_1920, resume_group_others);
script_context* get_script_by_index(s32 index) {
return gCurrentScriptList[index];
return gCurrentScriptListPtr[index];
}
script_context* get_script_by_id(s32 id) {
s32 i;
script_context* scriptContextPtr;
for (i=0; i < 128; i++) {
if (gCurrentScriptList[i] != 0) {
scriptContextPtr = (script_context*) gCurrentScriptList[i];
for (i=0; i < MAX_SCRIPT_LIST_LENGTH; i++) {
if (gCurrentScriptListPtr[i] != NULL) {
scriptContextPtr = gCurrentScriptListPtr[i];
if (scriptContextPtr->uniqueID == id) {
return scriptContextPtr;
}

View File

@ -3,7 +3,9 @@ gUIStatus = 0x8010EF58;
gPlayerData = 0x8010F290;
gPlayerStatus = 0x8010EFC8;
gItemTable = 0x800878E0;
gCurrentScriptList = 0x802DA890;
gWorldScriptList = 0x802DA490;
gBattleScriptList = 0x802DA690;
gCurrentScriptListPtr = 0x802DA890;
D_80147574 = 0x80147574;
gMapTransitionAlpha = 0x800A0940;