Language…
10 users online: 35TCB77, crm0622, crocodileman94, Hayashi Neru, KoJi, Maw, Metakabe, Neuromancer, Nirv, signature_steve - Guests: 240 - Bots: 319
Users: 64,795 (2,377 active)
Latest user: mathew

Kill Mario even if he has a powerup - Need help!

I am in the process of writing my first patch, and I am getting strange results. I want any damage whatsoever to kill Mario even if he has a powerup.
For some reason when Mario touches enemy, he shoots into the air like he does on death, and the death jingle plays.
Then he goes into the powerdown animation and he never dies.

Could someone please help me figure out what I am doing wrong?

Code
!instakill = $7FB400 	;You may need to change this address if it is already being used. 
			;If this address contains any value other than #$00, then instakill is active.
			;You may use UberASM to set this value on a level by level basis.

org $00F5D5
autoclean JSL Hijack

freecode

Hijack:
LDA !instakill
BNE KillMario 				;KillMario subroutine
LDA $19					;Powerup status
BEQ KillMario				;KillMario subroutine
RTL

KillMario:
JSL $00F606
The problem is that you haven't put an RTL behind "JSL $00F606" which results the game to call a wrong code. Alternatively, change "JSL $00F606" to "JML $00F606". HurtMario and KillMario end with an RTL which means a direct jump works just as well.

Side note: You don't need to use "freecode". "freedata" works just as well because you don't switch the programm bank in the code.


Code
KillMario:
JSL $00F606

It's this part. JSL returns to that call after the routine at $00F606 finishes, but you don't have anything written after that JSL, which means the code will continue into undefined territory. You should add an additional RTL after it.

That said, there's the issue that after doing so, the code will return right after that first JSL at $00F5D5, despite the fact that it no longer should run that (since Mario is already dead). Because of that, it'd be better to restructure the code a bit to use JML rather than JSL. JML doesn't push a return address, so you can use it to create "branching jumps"; for example, in this case:

Code
org $00F5D5
	autoclean JML Hijack	; jump to the hijack, but do not necessarily return here

freecode
Hijack:
	LDA !instakill
	BNE KillMario
	LDA $19
	BEQ KillMario
	JML $00F5D9		; jump back to the original routine, to continue after the hijack JML

KillMario:
	JML $00F606		; jump instead to the routine we would branch to



edit: ninja'd, but still posting for the example code

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
AHH!!! Thanks!

Switching to JML totally fixed it.

Something is wrong with my UberASM now I think. Every level kills Mario instantly no matter which Level ASM is loaded.

Here are my two *.asm files:

instakill_off.asm

Code
load:
	LDA #$00
	STA $7EB400
	rtl


instakill_on.asm

Code
load:
	LDA #$01
	STA $7EB400
	rtl


Does anyone see anything wrong with this?
Could the reason be that !instakill is defined as $7FB400 in your patch but $7EB400 in uberASM?


 
@WhiteYoshiEgg Thanks for catching that! That was definitely unintentional.

Thanks everyone for your help! My first patch ever official works as intended.

Last question for someone. I chose $7FB400 because it was an address that was used in a different patch, so obviously I need to choose a new address to store the instakill flag at.

Is there a document somewhere that shows where all the freeram addresses are?
Easiest way to find freeram is to just filter for results that have "empty" in the description, over in the RAM Map section of the site.