match si_handle_switch, si_handle_switch_const

This commit is contained in:
Alex Bates 2020-08-17 13:05:40 +01:00
parent 934bd5a415
commit 9f50926f9b
No known key found for this signature in database
GPG Key ID: 5E11C2DB78877706
3 changed files with 21 additions and 75 deletions

View File

@ -1,37 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel si_handle_switch
/* 0E9924 802C4F74 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0E9928 802C4F78 AFB00010 */ sw $s0, 0x10($sp)
/* 0E992C 802C4F7C 0080802D */ daddu $s0, $a0, $zero
/* 0E9930 802C4F80 AFBF0014 */ sw $ra, 0x14($sp)
/* 0E9934 802C4F84 8E02000C */ lw $v0, 0xc($s0)
/* 0E9938 802C4F88 0C0B1EAF */ jal get_variable
/* 0E993C 802C4F8C 8C450000 */ lw $a1, ($v0)
/* 0E9940 802C4F90 92030007 */ lbu $v1, 7($s0)
/* 0E9944 802C4F94 0040282D */ daddu $a1, $v0, $zero
/* 0E9948 802C4F98 24630001 */ addiu $v1, $v1, 1
/* 0E994C 802C4F9C A2030007 */ sb $v1, 7($s0)
/* 0E9950 802C4FA0 00031E00 */ sll $v1, $v1, 0x18
/* 0E9954 802C4FA4 00032603 */ sra $a0, $v1, 0x18
/* 0E9958 802C4FA8 28820008 */ slti $v0, $a0, 8
/* 0E995C 802C4FAC 14400003 */ bnez $v0, .L802C4FBC
/* 0E9960 802C4FB0 24020002 */ addiu $v0, $zero, 2
.L802C4FB4:
/* 0E9964 802C4FB4 080B13ED */ j .L802C4FB4
/* 0E9968 802C4FB8 00000000 */ nop
.L802C4FBC:
/* 0E996C 802C4FBC 00441804 */ sllv $v1, $a0, $v0
/* 0E9970 802C4FC0 02031821 */ addu $v1, $s0, $v1
/* 0E9974 802C4FC4 02042021 */ addu $a0, $s0, $a0
/* 0E9978 802C4FC8 AC650118 */ sw $a1, 0x118($v1)
/* 0E997C 802C4FCC 24030001 */ addiu $v1, $zero, 1
/* 0E9980 802C4FD0 A0830110 */ sb $v1, 0x110($a0)
/* 0E9984 802C4FD4 8FBF0014 */ lw $ra, 0x14($sp)
/* 0E9988 802C4FD8 8FB00010 */ lw $s0, 0x10($sp)
/* 0E998C 802C4FDC 03E00008 */ jr $ra
/* 0E9990 802C4FE0 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel si_handle_switch_const
/* 0E9994 802C4FE4 8C82000C */ lw $v0, 0xc($a0)
/* 0E9998 802C4FE8 90830007 */ lbu $v1, 7($a0)
/* 0E999C 802C4FEC 8C450000 */ lw $a1, ($v0)
/* 0E99A0 802C4FF0 24630001 */ addiu $v1, $v1, 1
/* 0E99A4 802C4FF4 A0830007 */ sb $v1, 7($a0)
/* 0E99A8 802C4FF8 00031E00 */ sll $v1, $v1, 0x18
/* 0E99AC 802C4FFC 00031E03 */ sra $v1, $v1, 0x18
/* 0E99B0 802C5000 28620008 */ slti $v0, $v1, 8
/* 0E99B4 802C5004 14400003 */ bnez $v0, .L802C5014
/* 0E99B8 802C5008 00031080 */ sll $v0, $v1, 2
.L802C500C:
/* 0E99BC 802C500C 080B1403 */ j .L802C500C
/* 0E99C0 802C5010 00000000 */ nop
.L802C5014:
/* 0E99C4 802C5014 00821021 */ addu $v0, $a0, $v0
/* 0E99C8 802C5018 00831821 */ addu $v1, $a0, $v1
/* 0E99CC 802C501C AC450118 */ sw $a1, 0x118($v0)
/* 0E99D0 802C5020 24020001 */ addiu $v0, $zero, 1
/* 0E99D4 802C5024 A0620110 */ sb $v0, 0x110($v1)
/* 0E99D8 802C5028 03E00008 */ jr $ra
/* 0E99DC 802C502C 24020002 */ addiu $v0, $zero, 2

View File

@ -94,20 +94,31 @@ s32 si_handle_end_if(script_context* script) {
return 2;
}
INCLUDE_ASM(code_e92d0_len_5da0, si_handle_switch);
s32 si_handle_switch(script_context* script) {
bytecode value = get_variable(script, *script->ptrReadPos);
s32 switchDepth = ++script->switchDepth;
INCLUDE_ASM(code_e92d0_len_5da0, si_handle_switch_const);
/*s32 si_handle_switch_const(script_context* script) {
s32 ptrReadPos = *script->ptrReadPos;
s8 switchDepth = script->switchDepth + 1;
if (switchDepth >= 8) {
inf_loop: goto inf_loop; //todo
while (1) {}
}
script->switchBlockValue[script->switchDepth + 1] = ptrReadPos;
script->switchBlockState[script->switchDepth + 1] = 1;
script->switchBlockValue[switchDepth] = value;
script->switchBlockState[switchDepth] = 1;
return 2;
}*/
}
s32 si_handle_switch_const(script_context* script) {
bytecode value = *script->ptrReadPos;
s32 switchDepth = ++script->switchDepth;
if (switchDepth >= 8) {
while (1) {}
}
script->switchBlockValue[switchDepth] = value;
script->switchBlockState[switchDepth] = 1;
return 2;
}
INCLUDE_ASM(code_e92d0_len_5da0, si_handle_case_equal);