]> Joshua Wise's Git repositories - fpgaboy.git/blame_incremental - rom.asm
Fuck shell scripts, we use makefiles here
[fpgaboy.git] / rom.asm
... / ...
CommitLineData
1 SECTION "a",HOME
2main:
3 ld c, $51
4 ld a, $FF
5 ld [c],a
6 ld sp,$DFFF
7
8 ld hl,text
9 call puts
10
11 call memtest
12 call waitsw
13 jp main
14
15text:
16 db $0D,$0A,$1B,"[1mFPGABoy Diagnostic ROM",$1B,"[0m",$0D,$0A,0
17
18memtest:
19 ld hl,memteststr
20 call puts
21
22 ld hl, $C000
23.wr:
24 ld a,h
25 xor l
26 ld [hli],a
27 ld a, $DF
28 cp h
29 jp nz, .wr
30 ld a, $80
31 cp l
32 jp nz, .wr
33
34 ld hl, $C000
35.rd:
36 ld a,h
37 xor l
38 ld b,a
39 ld a, [hli]
40 cp b
41 jp nz, .memfail
42
43 ld a, $DF
44 cp h
45 jp nz, .rd
46 ld a, $80
47 cp l
48 jp nz, .rd
49
50 ld hl, testokstr
51 call puts
52 ret
53.memfail:
54 @ decrement hl the easy way
55 ld a,[hld]
56 push hl
57 ld hl, failatstr
58 call puts
59 pop hl
60 ld a, h
61 call puthex
62 ld a, l
63 call puthex
64 ld a, $0A
65 call putc
66 ld a, $0D
67 call putc
68 ret
69
70memteststr:
71 db "Testing memory from $C000 to $DF80...",0
72testokstr:
73 db " OK!",$0D,$0A,0
74failatstr:
75 db " Test failed at $",0
76puthex:
77 push af
78 rra
79 rra
80 rra
81 rra
82 ld b,$0F
83 and b
84 ld b,$30
85 add b
86 call putc
87 pop af
88 ld b,$0F
89 and b
90 ld b,$30
91 add b
92 call putc
93 ret
94
95waitsw:
96 ld hl,waitswstr
97 call puts
98
99 ld c, $51
100 ld a, $00
101 ld [c],a
102
103 ld c, $51
104 ld b, $0
105.loop1:
106 ld a,[c]
107 cp b
108 jp z,.loop1
109.loop2:
110 ld a,[c]
111 cp b
112 jp nz,.loop2
113 ret
114
115waitswstr:
116 db "Diagnostic ROM complete; flip switches to nonzero and then to zero to reset.",$0D,$0A,0
117
118putc:
119 push af
120 ld b, 0
121 ld c, $50
122.waitport:
123 ld a,[c]
124 cp b
125 jp nz,.waitport
126 pop af
127 ld [c],a
128 ret
129
130puts:
131 ld a, [hli]
132 ld b, $00
133 cp b
134 jp z, .done
135 call putc
136 jp puts
137.done:
138 ret
139
This page took 0.0281 seconds and 4 git commands to generate.