-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathlocks.asm
More file actions
107 lines (98 loc) · 2 KB
/
locks.asm
File metadata and controls
107 lines (98 loc) · 2 KB
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
;; getLcdLock [Hardware]
;; Locks the LCD to the current thread.
getLCDLock:
push af
call getCurrentThreadId
ld (hwLockLCD), a
call checkLegacyLcdMode
jr nz, _
call setLegacyLcdMode
_: pop af
ret
;; getIOLock [Hardware]
;; Locks the I/O port to the current thread.
;; Note that the I/O port can be used by several processes - it's usually best to
;; leave it unlocked and let the kernel do your I/O.
getIOLock:
push af
call getCurrentThreadId
ld (hwLockIO), a
pop af
ret
;; getKeypadLock [Hardware]
;; Locks the keyboard to the current thread.
getKeypadLock:
push af
call getCurrentThreadId
ld (hwLockKeypad), a
; Flush keys
call flushKeys
_: call getScanCode
jr z, -_
pop af
ret
;; getUSBLock [Hardware]
;; Locks the USB port to the current thread.
getUSBLock:
push af
call getCurrentThreadId
ld (hwLockUSB), a
pop af
ret
;; hasLCDLock [Hardware]
;; Sets Z if the current thread has a lock on the LCD.
hasLCDLock:
push hl
push af
call getCurrentThreadId
ld hl, hwLockLCD
cp (hl)
pop hl
ld a, h
pop hl
ret
;; hasIOLock [Hardware]
;; Sets Z if the current thread has a lock on the I/O port.
hasIOLock:
push hl
push af
call getCurrentThreadId
ld hl, hwLockIO
cp (hl)
pop hl
ld a, h
pop hl
ret
;; hasKeypadLock [Hardware]
;; Sets Z if the current thread has a lock on the keyboard.
hasKeypadLock:
push hl
push af
call getCurrentThreadId
ld hl, hwLockKeypad
cp (hl)
pop hl
ld a, h
pop hl
ret
;; hasUSBLock [Hardware]
;; Sets Z if the current thread has a lock on the USB.
hasUSBLock:
#ifdef USB
push hl
push af
call getCurrentThreadId
ld hl, hwLockUSB
cp (hl)
pop hl
ld a, h
pop hl
ret
#else
push bc
ld b, a
or a
ld a, b
pop bc
#endif
ret