]> Joshua Wise's Git repositories - fpgaboy.git/blame - bootrom.asm
Add a dirty hack to make the sim pipe directly to the readout script.
[fpgaboy.git] / bootrom.asm
CommitLineData
6bd4619b
JW
1 SECTION "a",HOME[$00]
2
3 LD SP,$fffe ; $0000 Setup Stack
4
5 XOR A ; $0003 Zero the memory from $8000-$9FFF (VRAM)
6 LD HL,$9fff ; $0004
7Addr_0007:
8 LD [HLD],A ; $0007
9 BIT 7,H ; $0008
10 JR NZ, Addr_0007 ; $000a
11
12 LD HL,$ff26 ; $000c Setup Audio
13 LD C,$11 ; $000f
14 LD A,$80 ; $0011
15 LD [HLD],A ; $0013
16 LD [C],A ; $0014
17 INC C ; $0015
18 LD A,$f3 ; $0016
19 LD [C],A ; $0018
20 LD [HLD],A ; $0019
21 LD A,$77 ; $001a
22 LD [HLD],A ; $001c
23
24 LD A,$fc ; $001d Setup BG palette
25 LD [$FF47],A ; $001f
26
27 LD DE,$0104 ; $0021 Convert and load logo data from cart into Video RAM
28 LD HL,$8010 ; $0024
29Addr_0027:
30 LD A,[DE] ; $0027
c279b666
JW
31 CALL a95 ; $0028
32 CALL a96 ; $002b
6bd4619b
JW
33 INC DE ; $002e
34 LD A,E ; $002f
35 CP $34 ; $0030
36 JR NZ, Addr_0027 ; $0032
37
b4f3ac35 38 LD DE,Addr_00D8 ; $0034 Load 8 additional bytes into Video RAM
6bd4619b
JW
39 LD B,$08 ; $0037
40Addr_0039:
41 LD A,[DE] ; $0039
42 INC DE ; $003a
43 LD [HLI],A ; $003b
44 INC HL ; $003c
45 DEC B ; $003d
46 JR NZ, Addr_0039 ; $003e
47
48 LD A,$19 ; $0040 Setup background tilemap
49 LD [$9910],A ; $0042
50 LD HL,$992f ; $0045
51Addr_0048:
52 LD C,$0c ; $0048
53Addr_004A:
54 DEC A ; $004a
55 JR Z, Addr_0055 ; $004b
56 LD [HLD],A ; $004d
57 DEC C ; $004e
58 JR NZ, Addr_004A ; $004f
59 LD L,$0f ; $0051
60 JR Addr_0048 ; $0053
61
62 ; === Scroll logo on screen, and play logo sound===
63
64Addr_0055:
65 LD H,A ; $0055 Initialize scroll count, H=0
66 LD A,$64 ; $0056
67 LD D,A ; $0058 set loop count, D=$64
68 LD [$FF42],A ; $0059 Set vertical scroll register
69 LD A,$91 ; $005b
70 LD [$FF40],A ; $005d Turn on LCD, showing Background
71 INC B ; $005f Set B=1
72Addr_0060:
73 LD E,$02 ; $0060
74Addr_0062:
75 LD C,$0c ; $0062
76Addr_0064:
77 LD A,[$FF44] ; $0064 wait for screen frame
78 CP $90 ; $0066
79 JR NZ, Addr_0064 ; $0068
80 DEC C ; $006a
81 JR NZ, Addr_0064 ; $006b
82 DEC E ; $006d
83 JR NZ, Addr_0062 ; $006e
84
85 LD C,$13 ; $0070
86 INC H ; $0072 increment scroll count
87 LD A,H ; $0073
88 LD E,$83 ; $0074
89 CP $62 ; $0076 $62 counts in, play sound #1
90 JR Z, Addr_0080 ; $0078
91 LD E,$c1 ; $007a
92 CP $64 ; $007c
93 JR NZ, Addr_0086 ; $007e $64 counts in, play sound #2
94Addr_0080:
95 LD A,E ; $0080 play sound
96 LD [C],A ; $0081
97 INC C ; $0082
98 LD A,$87 ; $0083
99 LD [C],A ; $0085
100Addr_0086:
101 LD A,[$FF42] ; $0086
102 SUB B ; $0088
103 LD [$FF42],A ; $0089 scroll logo up if B=1
104 DEC D ; $008b
105 JR NZ, Addr_0060 ; $008c
106
107 DEC B ; $008e set B=0 first time
108 JR NZ, Addr_00E0 ; $008f ... next time, cause jump to "Nintendo Logo check"
109
110 LD D,$20 ; $0091 use scrolling loop to pause
111 JR Addr_0060 ; $0093
112
113 ; ==== Graphic routine ====
114
c279b666
JW
115a95: LD C,A ; $0095 "Double up" all the bits of the graphics data
116a96: LD B,$04 ; $0096 and store in Video RAM
6bd4619b
JW
117Addr_0098:
118 PUSH BC ; $0098
119 RL C ; $0099
120 RLA ; $009b
121 POP BC ; $009c
122 RL C ; $009d
123 RLA ; $009f
124 DEC B ; $00a0
125 JR NZ, Addr_0098 ; $00a1
126 LD [HLI],A ; $00a3
127 INC HL ; $00a4
128 LD [HLI],A ; $00a5
129 INC HL ; $00a6
130 RET ; $00a7
131
b4f3ac35 132NintendoLogo:
6bd4619b
JW
133 ;Nintendo Logo
134 DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
135 DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
136 DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
137
138Addr_00D8:
139 ;More video data
140 DB $3C,$42,$B9,$A5,$B9,$A5,$42,$3C
141
142 ; ===== Nintendo logo comparison routine =====
143
144Addr_00E0:
145 LD HL,$0104 ; $00e0 ; point HL to Nintendo logo in cart
b4f3ac35 146 LD DE,NintendoLogo ; $00e3 ; point DE to Nintendo logo in DMG rom
6bd4619b
JW
147
148Addr_00E6:
149 LD A,[DE] ; $00e6
150 INC DE ; $00e7
151 CP [HL] ; $00e8 ;compare logo data in cart to DMG rom
152.fuq JR NZ,.fuq ; $00e9 ;if not a match, lock up here
153 INC HL ; $00eb
154 LD A,L ; $00ec
155 CP $34 ; $00ed ;do this for $30 bytes
156 JR NZ, Addr_00E6 ; $00ef
157
158 LD B,$19 ; $00f1
159 LD A,B ; $00f3
160Addr_00F4:
161 ADD [HL] ; $00f4
162 INC HL ; $00f5
163 DEC B ; $00f6
164 JR NZ, Addr_00F4 ; $00f7
165 ADD [HL] ; $00f9
166.fuq: JR NZ,.fuq ; $00fa ; if $19 + bytes from $0134-$014D don't add to $00
167 ; ... lock up
168
169 LD A,$01 ; $00fc
170 LD [$FF50],A ; $00fe ;turn off DMG rom
b4f3ac35
JW
171
172
173 SECTION "b",HOME[$100]
174boot: jr .running ; $0100
175 nop ; $0102
176 nop ; $0103
177 ;Nintendo Logo ; $0104
178 DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D
179 DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99
180 DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E
181 ;$0134
182 DB $00,$E7,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00
183 ;$0144
184 DB $00,$00,$00,$00,$00,$00,$00,$00, $00,$00,$00,$00,$00,$00,$00,$00
185.running:
186 ld a, $FF
187 ld [$FF51], A
01878f5f
JW
188 ld a, $00
189 ld [$FF25], a
09c1936c
JW
190.diq: ld A, [$FF51]
191 cp 0
192 jr z, .diq
01878f5f
JW
193 ld a, 0
194 LD [$FF40],A
09c1936c
JW
195 jp $0000
196
This page took 0.041769 seconds and 4 git commands to generate.