My 1st ASM and it’s ugly.
What I try to do:
Have Critical DMG calculation check for Class ID to
either apply a x3DMG (vanilla [DMGx2]+DMG) on generic criticals
or a x5DMG [(DMGx4)+DMG] on specified class (in this example, Eirik’as Lord ID 0x2)
Vanilla CRT claculation (Taken from CrazyColors' doc)
0802B50C 683B ldr r3,[r7] @Critical but no lethality.
0802B50E 681A ldr r2,[r3]
0802B510 0351 lsl r1,r2,#0xD
0802B512 0B49 lsr r1,r1,#0xD
0802B514 4321 orr r1,r4
0802B516 4815 ldr r0,=#0x7FFFF
0802B518 4001 and r1,r0
0802B51A 4815 ldr r0,=#0xFFF80000
0802B51C 4010 and r0,r2
0802B51E 4308 orr r0,r1
0802B520 6018 str r0,[r3]
0802B522 2004 mov r0,#0x4
0802B524 5E29 ldsh r1,[r5,r0] @Load damage
0802B526 0048 lsl r0,r1,#0x1
0802B528 1840 add r0,r0,r1
0802B52A 80A8 strh r0,[r5,#0x4] @Store back.
I try to insert a CallHack jump in @2B51C which will bring me in front of @2B528
where the multiplied DMG is getting added once more by itself.
The EA file:
#ifndef FE8
ERROR “You’re not assembling to an FE8 ROM!”
#endif
#include EAStdlib.event
#include “Extensions/Hack Installation.txt”
#ifndef Free_Space
#define Free_Space 0xB2A610 // Vanilla free space
ORG Free_Space
#endif
PUSH
ORG $2B51C
callHack_r0(Hack)
POP
ALIGN 4
Hack:
#incbin “Lord(0x2)CRTx5.dmp”
^Use r0 for the CallHack which I feel is wrong but can’t get it work even with r1-3.
The ASM file:
.thumb
@called from 2B51C
push {r0-r5,r14}
and r0,r2
orr r0,r1
str r0,[r3]
mov r0,#0x4 @This and the above 3 lines are copied from the original
ldsh r1,[r5,r0] @Load DMG in r1
ldr r3,[r6,#0x4] @Load Class data in r3
ldrb r3,[r0,#0x4] @Load byte 0x4 (Class ID) in r3
cmp r3,#0x2 @Compare and check for Lord(0x2) class
bne NotALord @If not a Lord(0x2) go to NotALord
lsl r1,#2 @Multiply r1 by 4 (r1 being the stored DMG)
b JoinUp
NotALord:
lsl r1,#1 @Multiply r1 by 2 (r1 being the stored DMG)
JoinUp:
pop {r0-r5}
bx r0
^Which is wrong because the game crashes on a save load.
Someone please help me fix this.