LowGravity

by tjb0607

Game: SMW

Description: low gravity

; custom gravity uberasm by tjb
; changes mario's gravity by a configurable amount.
; by default, sets the gravity to 2/3 of the vanilla gravity.

!higrav = 0		; set this to 1 if you want high gravity instead of low gravity.

	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 $1407		; \ don't mess with gravity if... mario is flying,
	ORA $9D			; | mario's movement is locked,
	ORA $13D4		; | the game is paused,
	ORA $74			; | mario's on a net/vine,
	ORA $75			; | mario's swimming,
	ORA $1493		; | or the level is over.
	BNE ret		; /

	LDA $72			; \ don't mess with gravity if player is on the ground.
	BEQ ret		; /

	LDA $187A		; \ if on yoshi...
	BEQ +			; |
	LDA $141E		; | don't mess with gravity if yoshi has wings.
	BNE ret		; |
	+			; /

	LDX #$00		; \ set X to #$00 if not holding A/B
	LDA $15			; | or #$01 if holding A/B
	BPL +			; |
	INX			; |
	+			; /

	LDA $7D
if !higrav == 0
	SEC
	SBC GravityChange,X
	BVC +			; \ if that caused an underflow,
	LDA #$80		; | clamp to #$80
	+			; /
else
	CLC
	ADC GravityChange,X
endif
	STA $7D

ret:
	PLB
	RTL

GravityChange:
	db $02, $01	; first value is without holding A/B, second is with holding A/B
	; this is effectively subtracted from/added to the vanilla gravity values of $06, $03. (ROM addr $00D7A5)
	; by default (-$02, -$01), this results in an effective gravity of $04, $02.
back to listings