;Mgamerz Enhanced Enemies Mod v0.001
;12/17/2016
;Apply to MMBN3 ENGLISH WHITE version only! Apply with ARMIPS:
;armips filename.asm
input equ whitevanilla.gba ; Put the name of your ROM here
fspace equ 0x800000; Put the ROM free space offset here
.gba
.open input,output.gba,8000000h
rngaddress EQU 0x080016a2|1b
timestopchipcall EQU 08008E54h
GetPlayer EQU 0x080013E0
RecoveryChipRoutine EQU 0x80ADB04
SpawnObject EQU 0x08003084
;FieldConfiguration EQU 0x
SetPanelTeam EQU 0x0800B7C4
;Flashman Chips
flashmanchipcount EQU 4h
flashmanChipHookAddress EQU 0x080B6726
gutsmanChipHookAddress EQU 0x080B8592
gutsmanZPunchHookAddress EQU 0x080B84C6
gutsmanChipCount EQU 4h
gutsmanZPunchChipCount EQU 3h
gutsmanMovesBeforeZPunch EQU 6h
teamfamily EQU 3Fh
areafamily EQU 0h
stagefamily EQU 4h
trumpyfamily EQU 26h
sensorfamily EQU 3Eh
grabbackfamily EQU 15h
mpchipfamily EQU 18h
.org 08235156h ;Free Space
.align 2
rngRoutine:
ldr r0, =rngaddress
bx r0
pop r15
;setPanelToTeam:
; ldr r0 =fieldConfiguration
;callTimestopChipWithoutTimestop:
;requires routine and parameters.
;healSelf:
;r0 = how much to heal
;r5 = who to heal
;bl RecoveryChipRoutine
;===========================FLASH MAN==========================
armRaiseMove:
;Hijack at 080D7A66
push r1-r3,r5,r6
push r14
;b performBulbSpawn
push r0
ldrh r0, [r5,24h] ;GetHP
ldr r4, =12Ch
cmp r0,r4
pop r0
bgt notInRecoveryThreshold
inRecoveryThreshold:
ldr r0, =0x7D ;how much HP to heal at level 0 (125)
ldr r4, [r5,4h] ;get level
add r4, r4, 1h ; prevents *0
mul r0, r4 ;multiply how much HP to heal
bl RecoveryChipRoutine
mov r1, 0h ;0 = Navi Pixelated Summon
strb r1, [r5, 0xC]
mov r1, 1h ;Give Flashman another chip to use as he may run out.
strb r1, [r5,0x1A] ;0xA offset is how many chips an AI have to use, but r5 is incremented by 4 here for some reason.
pop r1
pop r1-r3,r5,r6; including get rid of return address, we will set our own to resume control
ldr r0, =080D7A84h|1b
bx r0 ;ignore post spawn
notInRecoveryThreshold:
push r1-r3
bl rngRoutine ;GET RNG result AND PUT INTO r0
mov r1, 0Ah ;remainder 0 = steal, anything else = bulbs
swi 6; Divide, remainder is in r1
mov r0, 0h
cmp r0, r1
pop r1
pop r2
pop r3
bne performBulbSpawn
stealPanels:
;position is on the stack it seems...?
mov r0, 9h
b armRaiseFinish
;mov r2, 1h
;bl SetPanelTeam
;pop r1 ;don't care
pop r1-r3,r5,r6
ldr r0, =080D7A84h|1b
bx r0 ;ignore post spawn
performBulbSpawn:
mov r0, 11h
armRaiseFinish:
bl SpawnObject
pop r15 ;finish
snakeTrace:
push r14
bl GetPlayer ;load X,Y into r0 r1
;r0 - Player Current X
;r1 - Player Current Y
push r1
push r3 ;temporary variable
ldr r1, [sp,0xC] ;next X pos of bulb
add r1, r1, 1h
cmp r0, r1 ;compare next X+1 (same) vs Megaman's X
ldrb r2,[r5,13h] ; highjacks at 080D7688 ;Current Y position
bne snakeTraceNotLinedUp ;exit if numbers aren't the same
snakeTraceLinedUp:
pop r3
pop r0 ;Player Y
cmp r2, r0 ;compare Y coordinates. also used by the routine we return to
bne snakeTraceDifferentYs
b snakeTraceLinedUpExit ;same Ys.
snakeTraceDifferentYs:
str r1, [sp,0x4] ;store same X if our current Y is not the same as the player Y (hit and leave field)
snakeTraceLinedUpExit:
pop r15
snakeTraceNotLinedUp:
pop r3
mov r1, 1h
cmp r1, 1h ;force same y
pop r1
;mov r2, 1h
;cmp r2, 2h ;Same Y
pop r15
loadFlashmanRandomChip:
push r14
bl rngRoutine ;GET RNG result AND PUT INTO r0
mov r1, flashmanchipcount ;number of chips in selection list
swi 6; Divide
ldr r0,=@@flashmanChipLookupTable ;Load address of chip lookup table (defined below)
mov r2,0x03 ; Load r2 with 3
mul r1,r2 ;Multiply the remainder result by the size of the structs (3 bytes) - this will provide an offset into the chip lookup table
add r0,r0,r1 ;calculate the address using the offset, store in r0
ldrb r3, [r0,0x02] ;load byte from *r0 (offset 2 forward) into r3 (dmg)
ldrb r1, [r0,0x01] ;load byte from *r0 (offset 1 forward) into r1 (sublevel)
ldrb r0, [r0,0x00] ;load byte from *r0 (direct addr) into r0 (family)
ldrb r2,[r5,16h] ; ...this is actually the object's alliance enemy/allied
pop r15
.pool
@@flashmanChipLookupTable:
.byte teamfamily, 1h, 0h
;.byte areafamily, 1h, 10h
.byte stagefamily, 4h, 0h
.byte trumpyfamily, 2h, 0h
;Flashman zap throwdown
.align 4
flashmanThrowdownAction:
.align 2
push r1,r2,r5,r6
push r14
bl rngRoutine ;GET RNG result AND PUT INTO r0
mov r1, 0x3 ;number of available actions
swi 6; Divide
ldr r0,=@@flashmanThrowdownLookupTable ;Load address of actions
add r0,r0,r1 ;calculate the address using the offset, store in r0
ldr r0, [r0]
pop r15
.pool
@@flashmanThrowdownLookupTable:
.byte 0x35 ;Mine
.byte 0x3A ;NoBeam
.byte 0x10 ;ZapAttack
;-----------------------------GUTS MAN----------------------
;This block is unused right now due to spam issues
;loadGutsmanRandomChip:
;push r14
;bl rngRoutine
;mov r1, gutsmanchipcount
;swi 6; Divide
;ldr r0,=@@gutsmanChipLookupTable ;Load address of chip lookup table (defined below)
;mov r2,0x03 ; Load r2 with 3
;mul r1,r2 ;Multiple the remainder result by the size of the structs (3 bytes) - this will provide ;an offset into the chip lookup table
;add r0,r0,r1 ;calculate the address using the offset, store in r0
;ldrb r3, [r0,0x02] ;load byte from *r0 (offset 2 forward) into r3 (dmg)
;ldrb r1, [r0,0x01] ;load byte from *r0 (offset 1 forward) into r1 (sublevel)
;ldrb r0, [r0,0x00] ;load byte from *r0 (direct addr) into r0 (family)
;ldrb r2,[r5,16h] ; ...this is actually the object's alliance enemy/allied
;pop r15
;.pool
;@@gutsmanChipLookupTable:
;.byte teamfamily, 0h, 0h
;.byte areafamily, 1h, 10h
;.byte stagefamily, 4h, 0h
;.byte trumpyfamily, 1h, 0h
;.align 4
loadZPunchRandomChip:
.align 2
push r14
bl rngRoutine
mov r1, gutsmanZPunchChipCount
swi 6; Divide
ldr r0,=@@gutsmanZPunchLookupTable ;Load address of chip lookup table (defined below)
mov r2,0x03 ; Load r2 with 3
mul r1,r2 ;Multiple the remainder result by the size of the structs (3 bytes) - this will provide an offset into the chip lookup table
add r0,r0,r1 ;calculate the address using the offset, store in r0
ldrb r3, [r0,0x02] ;load byte from *r0 (offset 2 forward) into r3 (dmg)
ldrb r1, [r0,0x01] ;load byte from *r0 (offset 1 forward) into r1 (sublevel)
ldrb r0, [r0,0x00] ;load byte from *r0 (direct addr) into r0 (family;)
ldrb r2,[r5,16h] ; ...this is actually the object's alliance enemy/allied
pop r15
.pool
@@gutsmanZPunchLookupTable:
;.byte teamfamily, 0h, 0h
;.byte areafamily, 1h, 10h
;.byte stagefamily, 4h, 0h
.byte trumpyfamily, 2h, 0h
.byte sensorfamily, 2h, 100h
.byte mpchipfamily, 2h, 0h
;==================HOOKS================
.org flashmanChipHookAddress
flashmanChipHook:
bl loadFlashmanRandomChip
nop
.org 0x080D7A66 ;Flashman Bulb Spawn (Arm Raise Move to heal)
flashmanArmRaiseMoveHook:
bl armRaiseMove
nop
nop
.org 0x080D7664 ;In the Follow Trace Y calculation area (will only affect follow and not zigzag tracer)
snakeTraceHook:
bl snakeTrace
nop
nop
.org 0x080D7850 ;Flashman zap throwdown
flashmanThrowdownHook:
bl flashmanThrowdownAction
;.org gutsmanChipHookAddress
;gutsmanAreaGrabChipHook:
;bl loadGutsmanRandomChip
;nop
;.org gutsmanZPunchHookAddress
; bl loadZPunchRandomChip ;Hook z-punch chip and use my routine instead
;nop
;=================PATCHES===============
;--------------HP SPEED PATCH---------------------
;Makes HP display change faster than default (which is 2)
;.org 0x08010E22
;mov r0, 4h
;--------------Flashman Patches---------
;--------------GUTSMAN PATCHES----------
;.org 0x080B7DF0 ;gutsmans sets move counter here to 0xFF so Z-Punch attack no longer comes up
;mov r0, #0x0 ;reset to 0 instead so he can use it again. this is the amount of moves he has done.
;.org 0x080b7de8 ;gutsmans checks if his move count is same as this in order to activate Z-Punch
;cmp r0, gutsmanMovesBeforeZPunch
;.org 0x080b7dcc ;gutsman checks this value and if his hp is less he can use zpunch. by default it is division by 2 by shifting to the right by 1.
;add r1, r1, 1 ;add 1 HP so its one over the max. Can use zpunch anytime now
;.org 0x080b8590 ;gutsmans areagrab response chip
;mov r0, grabbackfamily
;mov r1, 0x1 ;grabrevenge sublevel
;ldrb r2,[r5,#0x16]
;mov r3,#0x32 ;50 damage per hit
;-.org 0x080ae6a4 ;gutsman beta AI - delay after shockwave
;-.byte 0x64 ;contact damage
.org 0x08019b68 ;flashman beta HP
.byte 0xe8
.byte 0x03 ;1000 HP 0x03e8
.close
; eof
Comments