| problems with powerup patches |
|
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - problems with powerup patches |
|
Pages: 1  |
|
|
|
| Posted on 2012-02-23 09:28:09 AM |
Link | Quote |
|
i made two powerup patches, but they don't seem to work; while code 1 crashes the game, code 2 simply does nothing...
info: code 1 contains parts of k3fka's waria dash patch; code 2 contains parts of the powerup timer generator
-code 1 creates a powerup timer (also for the mushroom; i makes mario small while he's big usually) and a cooldown timer (how long you have to wait to activate the powerup again)
Code
header
lorom
org $8E6F ; hack the routine neccesary to start
JSL Routine ;
NOP #2
org $12FF8E ; freespace
!CodeSize = Ending-Routine ;
db "STAR" ; All code preservation
dw !CodeSize-$01 ;
dw !CodeSize-$01^$FFFF ;
!RAM_PowerTimer = $60 ;TWO bytes
!RAM_CooldownTimer = $62 ;TWO bytes
!RAM_HadStarFlag = $147D ;one byte
Routine:
JSL Code
LDA $0F31 ; Restore the
STA $0F25 ; Hijacked code.
RTL
Code:
LDA $14 ; Only run every fourth frame
AND #$03
BNE Return
LDA $19 ;check if he's big
CMP #$01 ;if not, go to timerroutine
BNE HasPower
LDA $1490 ;if he has star power,
BNE SetHadStarFlag
LDA !RAM_HadStarFlag
BNE SetStarTimer
STZ !RAM_PowerTimer ;reset powerup timer
LDA !RAM_CooldownTimer
BEQ Return ;if he's not in cooldown mode, return
DEC ;otherwise decrase counter
BNE Return ;when the timer reaches zero,
LDA #$29 ;play 'correct' sound
STA $1DFC
Return:
RTL
SetHadStarFlag:
LDA #$01
STA !RAM_HadStarFlag
RTL
SetStarTimer:
STZ !RAM_HadStarFlag ;clear flag
LDA #$02FF ;set star cooldown timer
STA !RAM_CooldownTimer
RTL
HasPower:
LDA !RAM_PowerTimer
BEQ SetTimer ; Set timer if it hasn't been set
CMP #$01
BNE DecrementPowerCounter
LDA #$01 ; Set Big Mario status if timer is about to run out
STA $19
STZ $1407 ; Set not soaring
DecrementPowerCounter:
LDA !RAM_PowerTimer ; Decrement the timer
DEC
STA !RAM_PowerTimer
BEQ TurnBack ;if 00, make him big again andstart Cooldown timer
RTL
SetTimer:
LDA #$00FF ;set powerup timer
STA !RAM_PowerTimer
RTL
TurnBack:
LDA #$01 ;make mario big again
STA $19
LDA #$01FF ;set cooldown timer
STA !RAM_CooldownTimer
RTL
Ending:
-code 2 makes you able to cycle through powerups (depending on the value of the sram byte) via R and gives you the chosen powerup if you press R AND the powerup timer from code 1 is 0
Code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LR Hook - Version 1.1
; By Smallhacker
; $700378 = powercountersram, $7E13F2 = currentpowerupram
; Disables L/R and prepares them to be used for other stuff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;CHANGE THIS ADDRESS TO A FREE SECTION OF THE ROM!
!freeSpace = $108188
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro RATS_start(id)
db "STAR"
dw RATS_Endcode<id>-RATS_Startcode<id>
dw RATS_Endcode<id>-RATS_Startcode<id>^#$FFFF
RATS_Startcode<id>:
endmacro
macro RATS_end(id)
RATS_Endcode<id>:
endmacro
lorom
header
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org $00CDF6 ;Disable L/R scrolling
BRA lrSkip
org $00CE49
lrSkip:
org $008F49 ;Hijack the status bar routine
JSL NewRoutine
org !freeSpace
%RATS_start(0)
NewRoutine:
LDA $18
AND #$20
BNE buttonL
LDA $18
AND #$10
BEQ Return
LDA $17
AND #$20
BNE Return
;INSERT R BUTTON CODE HERE
LDA #$04 ;all powerups available
STA $700378 ;
LDA $62 ;Cooldown Timer
BNE Wait
LDA $700378
CMP #$02
BEQ ShroomFeather
CMP #$03
BEQ ShroomFeatherFlower
CMP #$04
BEQ ShroomFeatherFlowerStar
RTL
Return:
RTL
Wait:
LDA #$2A ;play 'incorrect' sound
STA $1DFC
RTL
ShroomFeather:
LDA $13F2
INC
CMP #$3
BEQ Reset1
RTL
Reset1:
LDA #$1
STA $13F2
RTL
ShroomFeatherFlower:
LDA $13F2
INC
CMP #$4
BEQ Reset2
RTL
Reset2:
LDA #$1
STA $13F2
RTL
ShroomFeatherFlowerStar:
LDA $13F2
INC
CMP #$5
BEQ Reset3
RTL
Reset3:
LDA #$1
STA $13F2
RTL
buttonL:
LDA $17
AND #$10
BNE Return
LDA $13F2
CMP #$01
BEQ GiveMushroom
CMP #$02
BEQ GiveFeather
CMP #$03
BEQ GiveFlower
CMP #$04
BEQ GiveStar
RTL
GiveMushroom:
STZ $19
RTL
GiveFeather:
LDA #$02
STA $19
RTL
GiveFlower:
LDA #$03
STA $19
RTL
GiveStar:
JSL $01C580
RTL
%RATS_end(0)
|
|
| Posted on 2012-02-23 09:35:41 AM |
Link | Quote |
|
Code 1 - Why are you using 16-bit values at some points when you never changed to it? e.g. SetStarTimer: and TurnBack: are two spots I see that error.
Code 2 - Only works with P2's controller.
|
| Last edited on 2012-02-23 09:39:15 AM by wiiqwertyuiop. |
|
| Posted on 2012-02-23 09:39:25 AM |
Link | Quote |
|
Originally posted by s1lverCodeSetStarTimer:
STZ !RAM_HadStarFlag ;clear flag
LDA #$02FF ;set star cooldown timer
STA !RAM_CooldownTimer
RTL
[...]
SetTimer:
LDA #$00FF ;set powerup timer
STA !RAM_PowerTimer
RTL
TurnBack:
LDA #$01 ;make mario big again
STA $19
LDA #$01FF ;set cooldown timer
STA !RAM_CooldownTimer
RTL
You can't load 16-bit values into A while it's in 8-bit mode. Either set the m bit before LDA #$xxxx and clear it afterwards, or store (ie.) #$02 and #$FF seperately.
|
|
| Posted on 2012-02-23 10:13:49 AM |
Link | Quote |
|
for code 1:
i have to change it toright?
for code 2:
i guess i have to use REP and SEP, but which value comes after it?
|
|
| Posted on 2012-02-23 10:22:42 AM |
Link | Quote |
|
For code 1:
Change the LDA #$02FF to
REP #$20
LDA #$02FF
STA !RAM_CooldownTimer
SEP #$20
and change the other two LDA #$xxxx the same way.
EDIT: Forgot the STA
|
| Last edited on 2012-02-23 10:36:13 AM by Catobat. |
|
| Posted on 2012-02-23 10:26:55 AM |
Link | Quote |
|
I think you'll want to do:
REP #$20
LDA #$xxxx
STA $xx
SEP #$20
|
|
| Posted on 2012-02-23 10:36:19 AM |
Link | Quote |
|
works now! 
thank you for helping me
|
|
|
Pages: 1  |
|
|
|
|
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - problems with powerup patches |