@@ -9,6 +9,7 @@ include "intro.inc"
99
1010MACRO INTRO_META_INIT
1111 ld hl , MAP_INTRO_\ 1 + ROW_INTRO_\ 1 * TILEMAP_WIDTH + COL_INTRO_\ 1
12+ rst WaitVRAM ; Wait for VRAM to become accessible
1213 ld a , T_INTRO_\ 1 ; Load top left tile ID
1314 ld [ hli ], a ; Set top left tile and advance to the right
1415 ld a , T_INTRO_\ 1 + 2 ; Load top right tile ID
5152; License: CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
5253
5354SECTION "Start" , ROM0 [ $ 0100 ]
54- di ; Disable interrupts during setup
55- jr EntryPoint ; Jump past the header space to our actual code
56- ds $ 150 - @ , 0 ; Allocate space for RGBFIX to insert our ROM header
55+ di ; Disable interrupts during setup
56+ jr EntryPoint ; Jump past the header space to our actual code
57+ ds $ 150 - @ , 0 ; Allocate space for RGBFIX to insert our ROM header
5758
5859EntryPoint:
59- ld sp , $ E000 ; Set the stack pointer to the end of WRAM
60+ ld sp , $ E000 ; Set the stack pointer to the end of WRAM
6061
6162 xor a
6263 ldh [ rAUDENA ], a ; Shut down audio circuitry
@@ -104,17 +105,9 @@ EntryPoint:
104105 cp OAM_SIZE ; End of OAM reached?
105106 jr nz , .clearOAMLoop ; If not, continue looping
106107
107- .waitVBlank
108- ldh a , [ rLY ] ; Read the LY register to check the current scanline
109- cp SCREEN_HEIGHT_PX ; Compare the current scanline to the first scanline of VBlank
110- jr c , .waitVBlank ; Loop as long as the carry flag is set
111-
112- xor a ; Once we exit the loop we're safely in VBlank
113- ldh [ rLCDC ], a ; Disable the LCD (must be done during VBlank to protect the LCD)
114-
115108 ld de , IntroTiles
116109 ld hl , STARTOF(VRAM) | T_INTRO_REG << 4
117- COPY_1BPP Intro
110+ COPY_1BPP_SAFE Intro
118111
119112 call ClearBackground ; Clear the logo from the background
120113 INTRO_META_INIT BY ; Draw BY on the background
@@ -275,8 +268,9 @@ ClearBackground:
275268
276269ClearLogo:
277270 ld c , LOGO_WIDTH + 1 ; Clear ®
278- xor a
279271. loop
272+ rst WaitVRAM ; Wait for VRAM to become accessible
273+ xor a
280274 ld [ hli ], a
281275 dec c
282276 jr nz , . loop
@@ -290,16 +284,18 @@ ClearWindow:
290284
291285SetWindow:
292286 ld hl , TILEMAP1 + 4
293- ld a , T_LOGO
287+ ld b , T_LOGO
294288 call .logo
295289 ld l , TILEMAP_WIDTH + 4
296290 ; Fall through
297291
298292.logo:
299293 ld c , LOGO_WIDTH
300294. loop
301- ld [ hli ], a
302- inc a
295+ rst WaitVRAM
296+ ld [ hl ], b
297+ inc l
298+ inc b
303299 dec c
304300 jr nz , . loop
305301 ret
0 commit comments