-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeyhandler.asm
104 lines (82 loc) · 2.21 KB
/
keyhandler.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
;-------------------------------------------------------------------------------
; handle input, set carry flag if continuing
handleKeypress
jsr GETIN
beq handleKeypress
cmp #DOWN_ARROW
beq down
cmp #UP_ARROW
beq up
cmp #RIGHT_ARROW
beq right
cmp #LEFT_ARROW
beq left
cmp #PLUS_KEY
beq plus
cmp #MINUS_KEY
beq minus
cmp #F1_KEY
beq jumpToHelp
cmp #G_KEY
beq jumpToGo
cmp #Q_KEY
clc
beq exit
sec
exit rts
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
jumpToGo
jmp showGoScreen
jumpToHelp
jmp showHelpScreen
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; move down one row
down moveForward #bytesInLine
; move up one row
up moveBack #bytesInLine
; move down one screen
right moveForward #displayedBytes
; move up one screen
left moveBack #displayedBytes
; move forward one byte
plus moveForward #1
; move back one byte
minus moveBack #1
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
defm moveForward
ldx #/1
jsr moveBaseForward
sec
rts
endm
defm moveBack
ldx #/1
jsr moveBaseBack
sec
rts
endm
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
; add x to address displayed at the top left
moveBaseForward
txa
clc
adc base
bcc @skip
inc base+1
@skip sta base
rts
; subtract x from address displayed at the top left
moveBaseBack
lda base
stx base
sec
sbc base
bcs @skip
dec base+1
@skip sta base
rts
;-------------------------------------------------------------------------------