User Tools

Site Tools


Table of Contents

Wall Jump

By Parasite.

This code allows Samus to wall-jump similar to Super Metroid. It is (probably) intended for X816 but should assemble with ASM6 with little or no modification.


; This code allows for a wall-jump in Metroid (NES)
; Copyright 2002-2004 Parasyte
; The above copyright notice may not be removed or changed.
; Notes:
; Simply overwrite the data at file address 0x01CADF (38 bytes, max)
; with this code. Then set the hook by patching 0x01CC34 to 0xCF,0xCA

.org $CACF		;assemble our code to run at this (CPU) address
;.mem 8			;setup accumulator and index regs for NES code
;.index 8

BtnRight	= $01		;Joypad button definitions.
BtnLeft		= $02
BtnDown		= $04
BtnUp		= $08
BtnStart	= $10
BtnSelect	= $20
BtnB		= $40
BtnA		= $80

JoypadDown	= $12
Joypad		= $14

JumpSpeed	= $0308

DoJump		= $CD40		;Makes Samus Jump

WallToLeft	= $E880		;Checks for a wall to the left of Samus, returns result in C flag: Set = no, Clear = yes.
WallToRight	= $E88B		;Checks for a wall to the right of Samus, returns result in C flag: Set = no, Clear = yes.

;--Entry Point
; Inputs:	None
; Outputs:	None
; Description:	Checks if Samus is able to wall jump, performs action if possible.

	lda JoypadDown		;Is A button just pressed?
	bpl exit

	lda #BtnRight
	bit Joypad		;D-Pad Right held?
	bne +

	bit Joypad		;D-Pad Left held?
	beq exit

	;Check if able to wall jump to the left.
	jsr WallToRight
	bcs exit
	bcc ++			;Branch always.

	;Check if able to wall jump to the right.
+	jsr WallToLeft
	bcs exit

++	lda JumpSpeed		;Is Samus in a slow decent?
	bne exit

	jsr DoJump

	jmp $CCC2		;Bye-bye!

Optional Tweak

As an optional tweak, you can require the player to have a certain item. For instance, you could have the player start with the morph-ball ability, and use the Maru Mari (i.e. morph-ball) item give the player wall-jump instead.

Add the following to the declarations

; Adjust the value to modify which item the player needs to wall-jump
gr_WallJump	= %00000100

Add the following to the beginning of the actual code

; Exit if the player does not have wall-jump
lda #gr_WallJump
bit SamusGear
beq exit

Read Me

There doesn't appear to be a readme.

metroid/asm/walljump.txt · Last modified: 2015/02/28 22:59 by