-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.z80
87 lines (81 loc) · 2.06 KB
/
debug.z80
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
print_debug_keymatrix:
; render the keyboard matrix
ld hl, 0
ld (hl), 255
inc hl
ld (hl), 0
inc hl
ld (hl), 255
inc h
ld l,0
ld de, keyb_buffer
ld c,9
@outer_loop:
ld b,8
ld a,(de)
@inner_loop:
rrca
jr c, @key_detected
@key_not_detected:
ld (hl), 0
jr @next
@key_detected:
ld (hl), 255
@next:
inc hl
ld (hl), 0
inc hl
djnz @-inner_loop
inc de
inc h
ld l,0
dec c
jr nz, @-outer_loop
@keys_and_latches:
inc h
inc h
ld l,0
ld a, (controller_flags_dirs)
ld b,4
@inner_loop:
rrca
jr c, @+key_detected
@key_not_detected:
ld (hl), 17*1
jr @+next
@key_detected:
ld (hl), 17*3
@next:
inc hl
ld (hl), 0
inc hl
djnz @-inner_loop
ret
debug_wait_for_a_bit:
; useful to insert a reasonably size delay, good for setting
; breakpoints in simice
ld c, 0
@loop1:
ld b, 0
@loop2:
nop
nop
nop
nop
nop
nop
nop
nop
djnz @-loop2
dec c
jr nz, @-loop1
ret
fatal:
; this is like our version of assert. called when something
; has gone horribly wrong, during a DEBUG build
ld a, c
inc c
and 0x17
out (BORDER), a
nop
jp fatal