-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys.asm
120 lines (100 loc) · 2.09 KB
/
keys.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
_keyLeft = 1
_keyRight = 2
_keyFire = 4
_keyUp = 8
_keyDown = 16
_keyInventory = 32
_keyJoystickUsed = 128 ; 27/10/2013 - Set so that we can set joystick enable
_joystickDeadZone = &28
.updateKeys
;{
LDA #&03
STA &FE40
LDA #0
STA keyFlags
LDA #&7f
STA &FE43
; 27/10/2013 Only check joystick if we are enabled
LDA joystickEnabledFlag
BEQ keyCheckLeft
.startJoystickPatch:
.checkJoyFire
LDA &FE40
AND #16
BNE notFired
.fired
LDA keyFlags
ORA #(_keyFire OR _keyJoystickUsed)
STA keyFlags
.notFired
LDA joyTemp
TAX
CMP #_joystickDeadZone
BCS notJoyLeft
.joyLeft
LDA keyFlags:ORA #_keyLeft:STA keyFlags
.notJoyLeft
TXA
CMP #&ff - _joystickDeadZone
BCC notJoyRight
.joyRight
LDA keyFlags:ORA #_keyRight:STA keyFlags
.notJoyRight
LDA joyTemp2
TAX
CMP #&ff - _joystickDeadZone
BCC notJoyUp
.joyUp
LDA keyFlags:ORA #_keyUp:STA keyFlags
.notJoyUp
TXA
CMP #_joystickDeadZone
BCS keyCheckLeft
.joyDown
LDA keyFlags:ORA #_keyDown:STA keyFlags
.endJoystickPatch:
.keyCheckLeft:
LDA #97:STA &FE4F:LDA &FE4F ; N flag = whether 'Z' pressed
BPL keyCheckRight
LDA keyFlags
ORA #_keyLeft
STA keyFlags
.keyCheckRight:
LDA #66:STA &FE4F:LDA &FE4F ; N flag = whether 'X' pressed
BPL keyCheckRET
LDA keyFlags
ORA #_keyRight
STA keyFlags
.keyCheckRET:
LDA #73:STA &FE4F:LDA &FE4F ; N flag = whether 'RET' pressed
BPL keyCheckUp
LDA keyFlags
ORA #_keyFire
STA keyFlags
.keyCheckUp:
LDA #72:STA &FE4F:LDA &FE4F ; N flag = whether ':' pressed
BPL keyCheckDown
LDA keyFlags
ORA #_keyUp
STA keyFlags
.keyCheckDown:
LDA #104:STA &FE4F:LDA &FE4F ; N flag = whether '/' pressed
BPL keyCheckSpace
LDA keyFlags
ORA #_keyDown
STA keyFlags
.keyCheckSpace:
LDA #98:STA &FE4F:LDA &FE4F
BPL notSpace
LDA keyFlags
ORA #_keyInventory
STA keyFlags
.notSpace:
; PULL KEYBOARD ENABLE HIGH AGAIN FOR SOUND
LDA #&ff
STA &FE43
LDA #&0B
STA &FE40
RTS
;}
PRINT "* Keys size: ", P%-updateKeys