Decathlon

by soapagent

Game: SMW

Description: Mario moves like Activision Decathlon -- see code comments for controls

; [UNTESTED] DECATHLON:
; ASM snippet for SMW by SMWAgent09AF
; In order to move horizontally, you must alternate right and left on the D-pad.
; You can press X to switch between right and left movement.
; Hold up + Y/X to enter door/pipe.

!decath_status = $7f90e1
!decath_vx = $7f90e2
!decath_polarity = $7f90e3
!decath_button = $7f90e4

; Base ASM file - feel free to copy/paste this and use this for your own code.

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

LDA !carl_initialized   ; \ If this FreeRAM is 0, we were just loaded
BEQ init             ; / So initialize the RAM

LDA $18              ; \
AND #$40             ; | Flip direction if X was pressed
BEQ flip             ; /

LDA $15              ; \ 
AND #$48             ; | If X/Y and Up are held down,
BEQ door             ; / Enter door/pipe

LDA $16              ; \
AND #$03             ; | Check if either left or right
STA !decath_button   ; | was newly pressed this frame
CMP #$00             ; | If not, do nothing
BEQ zero             ; /
LDA !decath_polarity ; \ Check if the correct (i.e. opposite)
CMP !decath_button   ; | direction was pressed
BEQ zero             ; / If not, do nothing
LDA !decath_button
STA !decath_polarity
LDA #$40
ADC !decath_vx
STA $7b
RTL

init:
LDA #$00
STA !decath_vx
LDA #$01
STA !decath_status
LDA #$02
STA !decath_polarity
BRA zero

flip:
LDA !decath_vx
ADC #$80
CLC
CLV
STA !decath_vx
RTL

door:
LDA #$06
STA $71
RTL

zero:
LDA #$00
STA $7b
RTL
back to listings