The idea for the four verbs of movement (N, S, E, W) is the same, see if there is an exit and match LOC according to the direction. To go north I add the number of rows to loc and to go south I add the rest. To go east I add 1 to loc and to go east I add the remainder.
As I had to add or subtract and the quantity was different I made 4 subroutines.
Time later, I went through the code and discovered that I could do it with a single routine, which I'll tell you about in Movement Improvement.
This is the code for the four verbs.
Norte ; North
; Put the exit in the first
; four bits of y
jsr MovementCommands
tya
; Take the fourth bits
; the first one indicates the north
and #%00001000
; If it is 0 there is no exit
; to north, so it is time to print
; a message
beq NoSalida
; In this map, going north
; is adding 3
lda loc
clc
adc #$3
; Rememeber to store the new loc
sta loc
jmp End
Sur ; South
jsr MovementCommands
tya
and #%00000100
beq NoSalida ; No exit
lda loc
; A substraction
; The opposit one than north
sec
sbc #$3
sta loc
jmp End
Este ; East
jsr MovementCommands
tya
and #%00000010
beq NoSalida ; No exit
lda loc
clc
adc #$1
sta loc
jmp End
Oeste ; West
jsr MovementCommands
tya
and #%00000001
beq NoSalida ; No exit
lda loc
sec
sbc #$1
sta loc
jmp End
NoSalida
; Print no exit
lda #no_exit
jsr PRINT
rts
End
; Jump to the subrotuine sahich perints the
; description of the LOC
jsr PrintContent
rts