Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; refresh screen
- ld I, $FFF
- ld (I), $1
- ; ---------------------
- ; set screen text color to black
- ld I, $FFD
- ld (I), $F
- ; ---------------------
- .loop
- ; this will fix any trailing behind the pixel
- ld A, $20
- ld I, $FFE
- ld (I), A
- ; ---------------------
- call updatePixel ; call the update pixel function
- ; show the pixel
- ld A, $81 ; this is the pixel HEX value
- ld I, $FFE
- ld (I), A
- ; ---------------------
- ; refresh screen
- ld I, $FFF
- ld (I), $1
- ; ---------------------
- jmp loop ; loop back
- .updatePixel
- ld I, $FF9 ; load the current key pressed
- ld A, (I) ; store it in register A
- ld B, #0 ; reset B to 0 (so we would not add B always)
- add B, A ; move A to B
- eql A, $3 ; check if its Left key
- call left ; if true call .left
- eql A, $4 ; check if its Right key
- call right ; if true call .right
- eql A, $1 ; check if its Up key
- call up ; if true call .up
- eql A, $2 ; check if its down key
- call down ; if true call .down
- ret
- .left ; left movement
- ; load screen X pos and update it
- ld I, $FFA
- ld A, (I)
- sub A, #1
- ld (I), A
- ; ---------------------
- call resetKey ; reset the key
- ret
- .right ; right movement
- ; load screen X pos and update it
- ld I, $FFA
- ld A, (I)
- add A, #1
- ld (I), A
- ; ---------------------
- call resetKey ; reset the key
- ret
- .up ; up movement
- ; load screen Y pos and update it
- ld I, $FFB
- ld A, (I)
- sub A, #1
- ld (I), A
- ; ---------------------
- call resetKey ; reset the key
- ret
- .down ; down movement
- ; load screen Y pos and update it
- ld I, $FFB
- ld A, (I)
- add A, #1
- ld (I), A
- ; ---------------------
- call resetKey ; reset the key
- ret
- .resetKey
- ; moves B value to A
- ld A, #0
- add A, B
- ret
Advertisement
Add Comment
Please, Sign In to add comment