Skip to content

Instantly share code, notes, and snippets.

@biomood
Created May 30, 2011 09:37
Show Gist options
  • Save biomood/998657 to your computer and use it in GitHub Desktop.
Save biomood/998657 to your computer and use it in GitHub Desktop.
C64 - Move the cursor using the arrow keys
;*********************************************
;* Arrow Cursor, W,S,A,D *
;*********************************************
processor 6502
org $1000
;setup helpful labels
CLEAR = $E544
CHROUT = $FFD2
GETIN = $FFE4
SCNKEY = $FF9F
ENTER = $C202
INVERSE = $C204
NORMAL = $C206
MARK = $C208
JSR CLEAR
LDA #13
STA $C202
LDA #32
STA MARK
LDA #18
STA INVERSE
LDA #146
STA NORMAL
LDA #0
SCAN JSR SCNKEY ;get key
JSR GETIN ;put key in A
START CMP #87 ;W - up
BEQ UP
CMP #83 ;S - down
BEQ DOWN
CMP #65 ;A - left
BEQ LEFT
CMP #68 ;D - right
BEQ RIGHT
CMP ENTER ;end if enter clicked
BEQ END
CURSOR LDA MARK
JSR CHROUT
LDA #157
JSR CHROUT
LDA NORMAL
JSR CHROUT
LDA MARK
JSR CHROUT
LDA #157
JSR CHROUT
LDA INVERSE
JSR CHROUT
JMP SCAN
UP LDA #145
JMP PRINT
DOWN LDA #17
JMP PRINT
LEFT LDA #157
JMP PRINT
RIGHT LDA #29
JMP PRINT
PRINT JSR CHROUT
JMP CURSOR
END RTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment