FAST

by tjb0607

Game: SMW

Description: uncaps mario's speed

; note this doesn't have full support for slopes. if you want to yoink this as uberasm for your own hack, please keep that in mind.

	LDA $0100|!addr	; \ only run in gamemode 14
	EOR #$14	; |
	ORA $9D		; | and when the game isn't paused
	BEQ +		; |
	RTL		; |
	+		; /

	PHB		; \ push old data bank to stack, and set data bank to current program bank
	PHK		; | this allows inline data using db
	PLB		; / !! WARNING!! YOU *MUST* ALWAYS PLB BEFORE YOU RTL

LDA $15
BIT #$03
BEQ done
AND #$01
TAY

LDA $75    ; the logic here is a mess and im sorry
BEQ +      ; i already see a better way to implement it but it already works as is so i wont fix it
INY #2
LDA $72
BNE ++
INY #2
BRA ++
+

LDA $15
BIT #$40
BNE +
++
INY #2
BRA ++
+

LDA $13E4|!addr
CMP #$70
BNE +
++
INY #2
+         ; end very bad code

LDA speedcap,Y
BMI minus

CMP $7B
BCS done
LDY $7B
BMI done
LDA $7A
CLC
ADC #$80
STA $7A
TYA
CLV
ADC #$02
BVC +
LDA #$7F
+
STA $7B
BRA done

minus:

CMP $7B
BCC done
LDY $7B
BPL done
LDA $7A
SEC
SBC #$80
STA $7A
TYA
CLV
SBC #$02
BVC +
LDA #$80
+
STA $7B

done:
	PLB
	RTL

speedcap:
  db $DD, $24, $D1, $30, $ED, $14, $F1, $10, $F9, $08
;game's usual speed caps (+1 is added to negative speeds)
back to listings