aboutsummaryrefslogtreecommitdiff
path: root/src/ubox/ubox_isr.z80
blob: cceb2c6731a70b5da4c642bea4088122e7cdacfd (plain)
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
.globl _ubox_init_isr
.globl _ubox_tick
.globl ubox_isr_wait_ticks
.globl ubox_isr_wait_tick
.globl ubox_usr_isr
.globl ___sdcc_call_hl

HTIMI_HOOK = 0xfd9f

SCNCNT = 0xf3f6
REPCNT = 0xf3f7

_ubox_init_isr::
	di
	ld a, l
	ld (ubox_isr_wait_ticks), a
	xor a
	ld (ubox_isr_wait_tick), a
	ld (_ubox_tick), a
	ld (ubox_usr_isr), a
	ld (ubox_usr_isr+1), a
	ld hl, #ubox_isr
	ex de, hl
	ld hl, #HTIMI_HOOK
	ld a, #0xc3
	ld (hl), a
	inc hl
	ld (hl), e
	inc hl
	ld (hl), d
	ei
	ret

ubox_isr:
        push af
	push ix
	push iy
	push bc
	push hl
	push de

	; stop BIOS reading keyboard buffer
	xor a
	ld (SCNCNT), a
	ld (REPCNT), a

	ld hl, #ubox_isr_wait_tick
	inc (hl)
	inc hl
	inc (hl)
	inc hl
	inc hl

	; check user isr, only MSB
	ld a, (hl)
	or a
	jr z, no_user_isr

	dec hl
	ld l, (hl)
	ld h, a
	call ___sdcc_call_hl

no_user_isr:
	pop de
	pop hl
	pop bc
	pop iy
	pop ix
        pop af
	ret

.area _DATA

ubox_isr_wait_ticks: .ds 1
ubox_isr_wait_tick: .ds 1
_ubox_tick: .ds 1

ubox_usr_isr: .ds 2