Back to: Build a 6502 based computer
The scan code for the esc key is $1b.
The scan code for the enter key is $0a.
ascii_tbl:
.byte "????????????????" ; 00-0F
.byte "?????q1???zsaw2?" ; 10-1F
.byte "?cxde43?? vftr5?" ; 20-2F
.byte "?nbhgy6???mju78?" ; 30-3F
.byte "?,kio09??.?l?p??" ; 40-4F
.byte "????????????????" ; 50-5F
.byte "?????????1?47???" ; 60-6F
.byte "0.2568????3??9??" ; 70-7F
.byte "????????????????" ; 80-8F
.byte "????????????????" ; 90-9F
.byte "????????????????" ; A0-AF
.byte "????????????????" ; B0-BF
.byte "????????????????" ; C0-CF
.byte "????????????????" ; D0-DF
.byte "????????????????" ; E0-EF
.byte "????????????????" ; F0-FF
keypress:
lda ascii_tbl, x ; get ascii code
cmp #$0a
beq enter_pressed
cmp #$1b
beq esc_pressed
enter_pressed:
lda #$00 ; move cursor to beginning of line 1
lda #$40 ; move cursor to beginning of line 2
lda #$14 ; move cursor to beginning of line 3
lda #$54 ; move cursor to beginning of line 4
jsr lcd_instruction
jmp keypress
esc_pressed:
lda #$1 ; Clear display
jsr lcd_instruction
rts
ascii_tbl:
.byte "????????????? `?" ; 00-0F
.byte "?????q1???zsaw2?" ; 10-1F
.byte "?cxde43?? vftr5?" ; 20-2F
.byte "?nbhgy6???mju78?" ; 30-3F
.byte "?,kio09??./l;p-?" ; 40-4F
.byte "??'?[=????",$0a,"]?\??" ; 50-5F
.byte "?????????1?47???" ; 60-6F
.byte "0.2568",$1b,"??+3-*9??" ; 70-7F
.byte "????????????????" ; 80-8F
.byte "????????????????" ; 90-9F
.byte "????????????????" ; A0-AF
.byte "????????????????" ; B0-BF
.byte "????????????????" ; C0-CF
.byte "????????????????" ; D0-DF
.byte "????????????????" ; E0-EF
.byte "????????????????" ; F0-FF