Hi everyone!
I will admit that I'm only about 3-4 days into learning about ASM, so I'm sorry for these noobie questions.
I have read various tutorials and tried to search, but couldn't find an answer to this question...
If patching can only overwrite code, how do I add code via patch if I don't want to overwrite what's in that org?
For example, I wanted touching a coin to decrease PowerUp status, and if small, die.
I'll include the code below. I am patching the original SMW code.
I hijack at 008F28 and the code seems to work fine. Except, I have 99 lives. I'm guessing this is because I overwrote the 4 lines below the hijack which deals with lives, I think.
So how can I insert code without impacting the other code around it? I understand if I'm replacing functionality, but in this case I'm adding to it.
Also, how does this impact balancing the bytes?
My apologies if this isn't super clear, just let me know if it's not. :S
Thanks in advance!
I will admit that I'm only about 3-4 days into learning about ASM, so I'm sorry for these noobie questions.
I have read various tutorials and tried to search, but couldn't find an answer to this question...
If patching can only overwrite code, how do I add code via patch if I don't want to overwrite what's in that org?
For example, I wanted touching a coin to decrease PowerUp status, and if small, die.
I'll include the code below. I am patching the original SMW code.
I hijack at 008F28 and the code seems to work fine. Except, I have 99 lives. I'm guessing this is because I overwrote the 4 lines below the hijack which deals with lives, I think.
So how can I insert code without impacting the other code around it? I understand if I'm replacing functionality, but in this case I'm adding to it.
Also, how does this impact balancing the bytes?
My apologies if this isn't super clear, just let me know if it's not. :S
Thanks in advance!
Code
Org $008F28 ; routine to hack autoclean JSL OurCode ; jump to our code NOP #14 freecode OurCode: LDA $0019 ; load powerup status CMP #$0 ; is powerup status >0? BEQ .kill ; if powerup status is small, kill Mario DEC $0019 ; decrease powerup value RTL .kill LDA #$90 ; STA $7D ; LDA #$09 ; STA $1DFB ; LDA #$FF ; STA $0DDA ; LDA #$09 ; KillMario STA $71 ; STZ $140D ; LDA #$30 ; STA $1496 ; STA $9D ; STZ $1407 ; STZ $188A ; RTL