-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_keyboard.asm
81 lines (70 loc) · 1.9 KB
/
_keyboard.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
////////////////////////////////////////////////////////////////////////////////
//
// Project : ForestSaver - https://github.com/intoinside/ForestSaver
// Target : Commodore 64
// Author : Raffaele Intorcia - raffaele.intorcia@gmail.com
//
// Routine for keyboard managing
//
////////////////////////////////////////////////////////////////////////////////
#importonce
// Set Keyboard.ReturnPressed if return is pressed
.macro IsReturnPressed() {
lda #%11111110
sta Keyboard.DetectKeyPressed.MaskOnPortA
lda #%00000010
sta Keyboard.DetectKeyPressed.MaskOnPortB
jsr Keyboard.DetectKeyPressed
sta Keyboard.ReturnPressed
}
// Set Keyboard.IKeyPressed if I is pressed
.macro IsIKeyPressed() {
lda #%11101111
sta Keyboard.DetectKeyPressed.MaskOnPortA
lda #%00000010
sta Keyboard.DetectKeyPressed.MaskOnPortB
jsr Keyboard.DetectKeyPressed
sta Keyboard.IKeyPressed
}
// Set Keyboard.BackArrowPressed if "BACK ARROW" is pressed
.macro IsBackArrowPressed() {
lda #%01111111
sta Keyboard.DetectKeyPressed.MaskOnPortA
lda #%00000010
sta Keyboard.DetectKeyPressed.MaskOnPortB
jsr Keyboard.DetectKeyPressed
sta Keyboard.BackArrowPressed
}
.filenamespace Keyboard
Init: {
lda #1
sta KEYB.BUFFER_LEN // disable keyboard buffer
lda #127
sta KEYB.REPEAT_SWITCH // disable key repeat
}
* = * "Keyboard DetectKeyPressed"
DetectKeyPressed: {
sei
lda #%11111111
sta CIA1.PORT_A_DIRECTION
lda #%00000000
sta CIA1.PORT_B_DIRECTION
lda MaskOnPortA
sta CIA1.PORT_A
lda CIA1.PORT_B
and MaskOnPortB
beq Pressed
lda #$00
jmp !+
Pressed:
lda #$01
!:
cli
rts
MaskOnPortA: .byte $00
MaskOnPortB: .byte $00
}
ReturnPressed: .byte $00
IKeyPressed: .byte $00
BackArrowPressed: .byte $00
#import "_label.asm"