From 95fe2f6d9063adda10eefb9bef2dbbfcb897faf4 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Fri, 21 Aug 2020 00:57:45 +0200 Subject: [PATCH 1/2] Fix Gyigas' battle poisoning bug(s) --- notes/m2-notes.txt | 3 ++- src/data/status_damage_immune_table.bin | Bin 0 -> 32 bytes src/m2-bugfixes.asm | 27 ++++++++++++++++++++++++ src/m2-hack.asm | 9 ++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/data/status_damage_immune_table.bin create mode 100644 src/m2-bugfixes.asm diff --git a/notes/m2-notes.txt b/notes/m2-notes.txt index 18fc386..220b9b2 100644 --- a/notes/m2-notes.txt +++ b/notes/m2-notes.txt @@ -18,7 +18,8 @@ English names: - Jeff: 7A 95 96 96 - Poo: 80 9F 9F -0x2020C70: enemy data slots in-battle? separated by 0x94 bytes +0x2020C70: party character slots in battle. 0x94 bytes long +0x2021110: enemy slots in battle. 0x94 bytes long 0x2025038: enemy count (initial, not current) 0x20251D8: item drop 0x3000A00: Current PSI list when displaying a PSI window? diff --git a/src/data/status_damage_immune_table.bin b/src/data/status_damage_immune_table.bin new file mode 100644 index 0000000000000000000000000000000000000000..0726bd219d98aaecc0d0d868b747926238a37c05 GIT binary patch literal 32 TcmZQzU|?VYVl2R30VoIn0!sj7 literal 0 HcmV?d00001 diff --git a/src/m2-bugfixes.asm b/src/m2-bugfixes.asm new file mode 100644 index 0000000..acded93 --- /dev/null +++ b/src/m2-bugfixes.asm @@ -0,0 +1,27 @@ +//============================================================================== +//Fixes the issue where Gyigas could take damage from poison +dee6c_fix_poison_gyigas: +push {lr} +add r0,#0x44 +ldrh r0,[r0,#0] // Get the enemy's identifier +lsr r1,r0,#3 // Divide it by 8 +lsl r2,r1,#3 +sub r0,r0,r2 // Get the division's rest +ldr r2,=#status_damage_table +add r2,r2,r1 +ldrb r1,[r2,#0] // Get the byte that contains this entity's data +mov r2,#1 +lsl r2,r0 +and r2,r1 // If this is not 0, the enemy shouldn't take damage +cmp r2,#0 +bne @@end + +ldr r0,[r6,#0] // Proceed normally +mov r1,r4 +bl 0x80E9CFC + +@@end: +pop {pc} + + +//============================================================================== \ No newline at end of file diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 43db3ea..d974bb0 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1701,6 +1701,11 @@ nop //Choose character table based on alphabet loaded in .org 0x80C7578 :: bl c7578_load_letters +//============================================================================== +// Fix Gyigas' poison bug +//============================================================================== +.org 0x80DEE6C :: bl dee6c_fix_poison_gyigas + //============================================================================== // Move stuff around in order to make space for the code //============================================================================== @@ -1852,6 +1857,9 @@ flyover_tea: flyover_coffee: .include "data/flyover-coffee.asm" +status_damage_table: +.incbin "data/status_damage_immune_table.bin" + m2InsaneCultist: .incbin "data/m2-insane-cultist.bin" @@ -1961,6 +1969,7 @@ disclaimer_map: .include "syscalls.asm" .include "m2-vwf.asm" .include "m2-vwf-entries.asm" +.include "m2-bugfixes.asm" .include "m2-formatting.asm" .include "m2-customcodes.asm" .include "m2-compiled.asm" From 9a56b3d424e93847e227aa0af8d3cdd9e9c84047 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Sat, 22 Aug 2020 11:04:10 +0200 Subject: [PATCH 2/2] Fully fix poison issue --- src/data/status_damage_immune_table.bin | Bin 32 -> 0 bytes src/m2-bugfixes.asm | 64 +++++++++++++++++------- src/m2-hack.asm | 5 +- 3 files changed, 48 insertions(+), 21 deletions(-) delete mode 100644 src/data/status_damage_immune_table.bin diff --git a/src/data/status_damage_immune_table.bin b/src/data/status_damage_immune_table.bin deleted file mode 100644 index 0726bd219d98aaecc0d0d868b747926238a37c05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32 TcmZQzU|?VYVl2R30VoIn0!sj7 diff --git a/src/m2-bugfixes.asm b/src/m2-bugfixes.asm index acded93..11e520b 100644 --- a/src/m2-bugfixes.asm +++ b/src/m2-bugfixes.asm @@ -1,24 +1,54 @@ //============================================================================== -//Fixes the issue where Gyigas could take damage from poison +//Fixes the issue where Gyigas and other enemies would not use their death attack +//(or phase change) because of the poison dee6c_fix_poison_gyigas: push {lr} -add r0,#0x44 -ldrh r0,[r0,#0] // Get the enemy's identifier -lsr r1,r0,#3 // Divide it by 8 -lsl r2,r1,#3 -sub r0,r0,r2 // Get the division's rest -ldr r2,=#status_damage_table -add r2,r2,r1 -ldrb r1,[r2,#0] // Get the byte that contains this entity's data -mov r2,#1 -lsl r2,r0 -and r2,r1 // If this is not 0, the enemy shouldn't take damage -cmp r2,#0 -bne @@end -ldr r0,[r6,#0] // Proceed normally -mov r1,r4 -bl 0x80E9CFC +bl 0x80E9CFC //Normal code + +ldr r2,=#0x2024860 //Where the action's data is stored +ldr r0,[r6,#0] //Load the entity's slot +add r0,#0x44 +ldrh r1,[r0,#0] +cmp r1,#0 +beq @@normal //Characters have this set as 0 +cmp r1,#0xDA //This particular Gyigas phase does not need this... (It will reflect the poison randomly if we let it continue) +beq @@normal +ldrh r1,[r0,#4] // Get the enemy's current HP +cmp r1,#0 //Check if they're 0 +bne @@normal +ldrh r1,[r0,#6] // Get the enemy's scrolling HP +cmp r1,#0 //Check if they're 0 (probably not needed) +bne @@normal +mov r0,#0x9 //Fabricate a death check for the enemy +add r2,#0x16 +strh r0,[r2,#0] +mov r0,#0 +strh r0,[r2,#4] +mov r0,#4 //This counts as a PSI, since setting it as a normal attack would make it so the Diamond Dog would reflect it +strh r0,[r2,#6] +add r2,#0xC +strh r0,[r2,#0x6] +mov r0,#1 +strh r0,[r2,#4] +mov r0,#0 +strh r0,[r2,#0] +add r2,#0x24 +strh r0,[r2,#0] +strh r0,[r2,#0x12] +ldr r2,=#0x2025034 +mov r0,#1 +strh r0,[r2,#0] //This is a PSI. Not a physical attack +ldr r0,=#0x3005378 +mov r1,#0xC //This is PSI Cool Thing +strh r1,[r0,#0] +mov r1,#0 +strh r1,[r0,#0x10] +b @@end + +@@normal: +mov r0,#0x64 //Normal game's behaviour +strh r0,[r2,#0x16] @@end: pop {pc} diff --git a/src/m2-hack.asm b/src/m2-hack.asm index d974bb0..9e40ace 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1704,7 +1704,7 @@ nop //============================================================================== // Fix Gyigas' poison bug //============================================================================== -.org 0x80DEE6C :: bl dee6c_fix_poison_gyigas +.org 0x80DEE6C :: bl dee6c_fix_poison_gyigas :: nop :: nop :: nop //============================================================================== // Move stuff around in order to make space for the code @@ -1857,9 +1857,6 @@ flyover_tea: flyover_coffee: .include "data/flyover-coffee.asm" -status_damage_table: -.incbin "data/status_damage_immune_table.bin" - m2InsaneCultist: .incbin "data/m2-insane-cultist.bin"