Skip to content

Sideways stairs with diagonal movement

Rangi edited this page Feb 10, 2019 · 11 revisions

All the stairs in Gen 1 and 2 only go upwards. Gen 3 had a few that go downwards, like the ones descending towards Trainer Tower in FRLG, but it took until Gen 4 with its true 3D maps for sideways stairs to be introduced. ROM hacks have already implemented sideways stairs in Gen 3; this tutorial shows how to implement them in pokecrystal.

(The code for this feature was adapted from Pokémon Brass.)

Here are all the changes needed to implement diagonal stairs, applied to a copy of pokecrystal. You can clone Rangi42/pokecrystal and checkout the diagonal-stairs branch to test it for yourself.

Screenshot

TOC

1. Define the constants

Edit constants/collision_constants.asm:

 ; collision data types (see data/tilesets/*_collision.asm)
 ; TileCollisionTable indexes (see data/collision_permissions.asm)
 COLL_FLOOR             EQU $00
 ...
 COLL_DOWN_WALL         EQU $b3 ; unused
+COLL_DIAGONAL_STAIRS_RIGHT EQU $d0
+COLL_DIAGONAL_STAIRS_LEFT  EQU $d1
 COLL_FF                EQU $ff ; garbage

; collision data type nybbles
 LO_NYBBLE_GRASS      EQU $07
 HI_NYBBLE_TALL_GRASS EQU $10
 ...
 HI_NYBBLE_SIDE_WALLS EQU $b0
 HI_NYBBLE_UNUSED_C0  EQU $c0
+HI_NYBBLE_DIAGONAL_STAIRS EQU $d0

The collision constants will let us apply the diagonal step to the player once it is programmed.

Now edit constants/map_object_constants.asm:

 ; StepTypesJumptable indexes (see engine/overworld/map_objects.asm)
 	const_def
 	const STEP_TYPE_00              ; 00
 	const STEP_TYPE_SLEEP           ; 01
 	...
 	const STEP_TYPE_17              ; 17
 	const STEP_TYPE_18              ; 18
 	const STEP_TYPE_SKYFALL_TOP     ; 19
+	const STEP_TYPE_NPC_DIAGONAL_STAIRS
+	const STEP_TYPE_PLAYER_DIAGONAL_STAIRS

 ...

 ; DoPlayerMovement.DoStep arguments (see engine/overworld/player_movement.asm)
 	const_def
 	const STEP_SLOW          ; 0
 	const STEP_WALK          ; 1
 	const STEP_BIKE          ; 2
 	const STEP_LEDGE         ; 3
 	const STEP_ICE           ; 4
 	const STEP_TURN          ; 5
 	const STEP_BACK_LEDGE    ; 6
 	const STEP_WALK_IN_PLACE ; 7
+	const STEP_DIAGONAL_STAIRS
Clone this wiki locally