diff --git a/bin/DMGTRIS.GBC b/bin/DMGTRIS.GBC index 87c8dc9..75302f9 100644 Binary files a/bin/DMGTRIS.GBC and b/bin/DMGTRIS.GBC differ diff --git a/bin/DMGTRIS.pocket b/bin/DMGTRIS.pocket index ed786f2..f64430b 100644 Binary files a/bin/DMGTRIS.pocket and b/bin/DMGTRIS.pocket differ diff --git a/src/dmgfx.asm b/src/dmgfx.asm new file mode 100644 index 0000000..d1665c6 --- /dev/null +++ b/src/dmgfx.asm @@ -0,0 +1,89 @@ +; DMGTRIS +; Copyright (C) 2023 - Randy Thiemann + +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. + +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. + +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + + +IF !DEF(DMGFX_ASM) +DEF DMGFX_ASM EQU 1 + + +INCLUDE "globals.asm" + + +SECTION "DMG Intro Effect", ROM0 +DoDMGEffect:: + ld a, [wInitialA] + cp a, $11 + ret z + + ; Yeet the logo + ld c, 10 +.loop0 + wait_vblank + ldh a, [rSCY] + dec a + ldh [rSCY], a + wait_vblank_end + dec c + jr nz, .loop0 + + ld c, 45 +.loop1 + wait_vblank + ldh a, [rSCY] + inc a + inc a + ldh [rSCY], a + wait_vblank_end + dec c + jr nz, .loop1 + + ; Fade + wait_vblank + ld a, PALETTE_MONO_2 + ldh [rBGP], a + + ld c, 20 +.loop2 + wait_vblank + wait_vblank_end + dec c + jr nz, .loop2 + + wait_vblank + ld a, PALETTE_MONO_1 + ldh [rBGP], a + + ld c, 20 +.loop3 + wait_vblank + wait_vblank_end + dec c + jr nz, .loop3 + + wait_vblank + ld a, PALETTE_MONO_0 + ldh [rBGP], a + + ld c, 20 +.loop4 + wait_vblank + wait_vblank_end + dec c + jr nz, .loop4 + ret + + +ENDC diff --git a/src/include/globals.asm b/src/include/globals.asm index a7a813c..99b39a3 100644 --- a/src/include/globals.asm +++ b/src/include/globals.asm @@ -26,9 +26,9 @@ INCLUDE "structs.asm" ; Waits for PPU mode to be 0 or 1. ; We don't wait for 2 because it's super short and impractical to do much of anything in. MACRO wait_vram - ld hl, rSTAT .wvr\@ - bit STATB_BUSY, [hl] + ldh a, [rSTAT] + bit STATB_BUSY, a jr nz, .wvr\@ ENDM diff --git a/src/main.asm b/src/main.asm index b44d3ea..ebea097 100644 --- a/src/main.asm +++ b/src/main.asm @@ -68,13 +68,20 @@ Main:: ld a, l ld [wInitialL], a - ; Turn off LCD during initialization. + ; Let the DMG have some fun with the initial screen. + call DoDMGEffect + + ; Turn off LCD during initialization, but not on DMG. + ld a, [wInitialA] + cp a, $11 + jr nz, :+ + wait_vram xor a, a ldh [rLCDC], a ; Set up stack - ld sp, wStackEnd-1 +: ld sp, wStackEnd-1 ; GBC? Double speed mode and set up palettes. ld a, [wInitialA] @@ -96,7 +103,7 @@ Main:: ld de, Tiles ld hl, _VRAM ld bc, TilesEnd - Tiles - call UnsafeMemCopy + call SafeMemCopy ; Clear OAM. call ClearOAM @@ -111,7 +118,11 @@ Main:: call SFXInit ; Set up the interrupt handlers. - call InitializeLCDCInterrupt + ld a, [wInitialA] + cp a, $11 + jr nz, :+ + wait_vblank +: call InitializeLCDCInterrupt ; Switch to gameplay state. call SwitchToTitle diff --git a/src/memory.asm b/src/memory.asm index 0892b49..c43033c 100644 --- a/src/memory.asm +++ b/src/memory.asm @@ -57,5 +57,15 @@ UnsafeMemSet:: jr nz, UnsafeMemSet ret +SafeMemSet:: + wait_vram + ld [hl], d + inc hl + dec bc + ld a, b + or a, c + jr nz, SafeMemSet + ret + ENDC diff --git a/src/sprites.asm b/src/sprites.asm index 35d4f52..254d169 100644 --- a/src/sprites.asm +++ b/src/sprites.asm @@ -85,11 +85,11 @@ ClearOAM:: ld hl, _OAMRAM ld bc, $9F ld d, 0 - call UnsafeMemSet + call SafeMemSet ld hl, wShadowOAM ld bc, $9F ld d, 0 - call UnsafeMemSet + call SafeMemSet ret