Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org usermem-2
- db $bb,$6d
- PLX equ appdata ; Player X position
- PLY equ appdata+1 ; Player Y position
- ;
- Start: ;
- BCALL ClrLCDFull ;
- LD HL,0 ; Set the player to be in the upper left corner
- LD (PLX),HL ;
- Loop: ;
- BCALL GetKey ; Read a key
- PUSH AF ; Save it
- LD A,(PLX) ; Here we put a space where the player was
- LD (CurCol),A ;
- LD A,(PLY) ;
- LD (CurRow),A ;
- LD A,$20 ; $20 = space
- BCALL PutMap ; Prints A at CurCol,CurRow
- POP AF ; Get the key we stored
- LD DE,(PLX) ; Load PLX into E and PLY into D
- CP kClear ;
- RET Z ; Exit if Clear was pressed
- CP kUp ;
- JR NZ,NotUp ;
- DEC D ;
- NotUp: ;
- CP kDown ;
- JR NZ,NotDown ;
- INC D ;
- NotDown: ;
- CP kLeft ;
- JR NZ,NotLeft ;
- DEC E ;
- NotLeft: ;
- CP kRight ;
- JR NZ,NotRight ;
- INC E ;
- NotRight: ;
- LD A,E ; Keep X position between 0 and 15
- AND 15 ;
- LD E,A ;
- LD A,D ; Keep Y position between 0 and 7
- AND 7 ;
- LD D,A ;
- LD (PLX),DE ; Save E into PLX and D into PLY
- LD A,(PLX) ; Put an X where the player now is
- LD (CurCol),A ;
- LD A,(PLY) ;
- LD (CurRow),A ;
- LD A,'X' ;
- BCALL PUTMAP ;
- JP Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement