Skip to content

Commit 72a3518

Browse files
author
Hacktix
committed
Imported bootix_dmg codebase
1 parent 5616265 commit 72a3518

File tree

2 files changed

+240
-0
lines changed

2 files changed

+240
-0
lines changed

Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
RGBASM = rgbasm
2+
RGBLINK = rgblink
3+
4+
RM_F = rm -f
5+
6+
ASFLAGS = -h
7+
LDFLAGS = -t -w -x
8+
9+
bootix_dmg.bin: bootix_dmg.o
10+
$(RGBLINK) $(LDFLAGS) -o $@ $^
11+
12+
bootix_dmg.o: bootix_dmg.asm
13+
$(RGBASM) $(ASFLAGS) -o $@ $<
14+
15+
.PHONY: clean
16+
clean:
17+
$(RM_F) bootix_dmg.o bootix_dmg.bin

bootix_dmg.asm

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
INCLUDE "inc/hardware.inc"
2+
3+
SCX_MAX_OFF EQU $10
4+
ANIM_TIMEOUT EQU 30
5+
SOUND_TIMEOUT_1 EQU 30
6+
SOUND_TIMEOUT_2 EQU 500
7+
8+
SECTION "Bootrom", ROM0[0]
9+
; Initialize SP
10+
ld sp, $FFFE
11+
12+
; Clear VRAM
13+
ld hl, $8000
14+
ClearVRAM:
15+
xor a
16+
ld [hli], a
17+
ld a, h
18+
cp $A0
19+
jr nz, ClearVRAM
20+
21+
; Initialize Audio
22+
ld c, $11
23+
ld hl, rAUDENA
24+
ld a, AUDENA_ON
25+
ld [hld], a
26+
ldh [$ff00+c], a
27+
inc c
28+
ld a, $F3
29+
ld [hld], a
30+
ldh [$ff00+c], a
31+
inc c
32+
ld a, $77
33+
ld [hld], a
34+
ldh [$ff00+c], a
35+
36+
; Initialize Channel 1
37+
ld c, $11
38+
ld a, $80
39+
ldh [$ff00+c], a
40+
inc c
41+
ld a, $F3
42+
ldh [$ff00+c], a
43+
44+
; Decode logo and load into VRAM
45+
ld de, $0104
46+
ld hl, $8010
47+
ld c, 48
48+
DecodeLoop:
49+
; Decode first 4 bits of byte
50+
ld a, [de]
51+
call LoadLogoNibble
52+
53+
; Decode second 4 bits of byte
54+
ld a, [de]
55+
swap a
56+
call LoadLogoNibble
57+
58+
; Loop if necessary
59+
inc de
60+
dec c
61+
jr nz, DecodeLoop
62+
63+
; Load Trademark Symbol into VRAM
64+
ld de, TrademarkLogo
65+
ld b, 8
66+
TrademarkLoadLoop:
67+
ld a, [de]
68+
inc de
69+
ld [hli], a
70+
inc hl
71+
dec b
72+
jr nz, TrademarkLoadLoop
73+
74+
; Initialize tilemap (Row 1)
75+
ld hl, $9904
76+
ld bc, $010C
77+
call LogoMapInit
78+
; Trademark Symbol
79+
ld a, $19
80+
ld [hl], a
81+
82+
; Initialize Tilemap (Row 2)
83+
ld hl, $9924
84+
ld c, $0C
85+
call LogoMapInit
86+
87+
; Initialize LCDC
88+
ld a, LCDCF_ON | LCDCF_BG8000 | LCDCF_BGON
89+
ldh [rLCDC], a
90+
91+
; Play intro animation
92+
ld b, SCX_MAX_OFF
93+
ld de, FadeValues
94+
IntroAnimLoop:
95+
; Set SCX to OFFSET
96+
ld a, b
97+
ldh [rSCX], a
98+
dec b
99+
100+
; Update BGP Fade
101+
ld a, e
102+
cp LOW(FadeValues+4)
103+
jr z, .skipFade
104+
ld a, [de]
105+
ldh [rBGP], a
106+
inc de
107+
.skipFade
108+
109+
; Wait...
110+
ld c, ANIM_TIMEOUT
111+
call DoTimeout
112+
113+
; Set SCX to -OFFSET
114+
xor a
115+
sub b
116+
ldh [rSCX], a
117+
dec b
118+
119+
; Wait... (Return to loop if OFFSET != 0)
120+
ld c, ANIM_TIMEOUT
121+
call DoTimeout
122+
xor a
123+
or b
124+
jr nz, IntroAnimLoop
125+
ldh [rSCX], a
126+
127+
; Play sound 1
128+
ld a, $83
129+
call PlaySound
130+
131+
; Wait...
132+
ld c, SOUND_TIMEOUT_1
133+
call DoTimeout
134+
135+
; Play sound 2
136+
ld a, $C1
137+
call PlaySound
138+
139+
; Wait...
140+
ld de, SOUND_TIMEOUT_2
141+
SoundWait2:
142+
ldh a, [rLY]
143+
cp SCRN_Y
144+
jr nz, SoundWait2
145+
dec de
146+
ld a, d
147+
or e
148+
jr nz, SoundWait2
149+
150+
; Finalize Bootrom
151+
jr EndBootrom
152+
153+
PlaySound:
154+
ld c, $13
155+
ld [$ff00+c], a
156+
inc c
157+
ld a, $87
158+
ld [$ff00+c], a
159+
ret
160+
161+
; Routine for waiting a certain amount of time
162+
DoTimeout:
163+
ldh a, [rLY]
164+
cp SCRN_Y
165+
jr nz, DoTimeout
166+
dec c
167+
jr nz, DoTimeout
168+
ret
169+
170+
; Routine for loading logo tile numbers into VRAM
171+
LogoMapInit:
172+
ld a, b
173+
ld [hli], a
174+
inc b
175+
dec c
176+
jr nz, LogoMapInit
177+
ret
178+
179+
; Routine for converting logo byte to VRAM data
180+
LoadLogoNibble:
181+
and $F0
182+
ld b, a
183+
xor a
184+
bit 7, b
185+
jr z, .skipBit1
186+
or %11000000
187+
.skipBit1
188+
bit 6, b
189+
jr z, .skipBit2
190+
or %00110000
191+
.skipBit2
192+
bit 5, b
193+
jr z, .skipBit3
194+
or %00001100
195+
.skipBit3
196+
bit 4, b
197+
jr z, .skipBit4
198+
or %00000011
199+
.skipBit4
200+
ld [hli], a
201+
inc hl
202+
ld [hli], a
203+
inc hl
204+
ret
205+
206+
; Trademark Logo
207+
TrademarkLogo:
208+
db $3C, $42, $B9, $A5, $B9, $A5, $42, $3C
209+
210+
; BGP Fade Values
211+
FadeValues:
212+
db %00000000, %01010100, %10101000, %11111100
213+
214+
; Mandatory Copyright Notice
215+
db "BOOTIX.DMG"
216+
217+
EndBootrom:
218+
; Pad remaining space with NOP
219+
ds $100-@-4, 0
220+
221+
; Disable Bootrom
222+
ld a, $01
223+
ldh [$FF50], a

0 commit comments

Comments
 (0)