I fiddled around the sprite for fun and didn't expect to get any results, but I got something semi-working. After some testing it's not 100% consistent, maybe somebody can shed some light on this matter.
The original code of the Attacking segment:
Code
Attacking:
STZ !15D0,x
JSL $01803A|!BankB ; interact with Mario and with other sprites
%SubHorzPos() ;\ make sprite face Mario
TYA ; |
STA !RAM_SpriteDir,x ;/
LDA !1540,x ;\ if attack cycle not complete,
BNE .DontReset ;/ branch
LDA #$70 ;\ reset cycle
STA !1540,x
Since this is the beginning of the sprite routine, I thought I could just insert a check for the sprite state in there and end level if it's not alive anymore:
Code
Attacking:
STZ !15D0,x
JSL $01803A|!BankB ; interact with Mario and with other sprites
%SubHorzPos() ;\ make sprite face Mario
TYA ; |
STA !RAM_SpriteDir,x ;/
LDA !14C8,x ;\ check sprite state
CMP #$08 ;| don't end level if alive
BEQ + ;/
INC $73C6|!Base2 ;\
LDA #$FF ;| end level
STA $7493|!Base2 ;|
LDA.b #!ExitSong ;|
STA $7DFB|!Base2 ;/
+ LDA !1540,x ;\ if attack cycle not complete,
BNE .DontReset ;/ branch
LDA #$70 ;\ reset cycle
STA !1540,x
Alright. So, after testing it, it sort of works... most of the time. Doing the fight a few times in succession (about 5-6), I noticed following things:
-) one time, killing the Magikoopa did not end the level
-) sometimes, the Magikoopa magic will spawn different sprites instead of the yellow koopa after hitting a turn block (I've had a moving coin and a thwomp)
Obviously my fiddlings were just for testing purposes, so I didn't expect them to work flawlessly. But maybe someone is able to point out what causes those inconsistencies I witnessed?