Just for fun
This commit is contained in:
		
							parent
							
								
									fb9b90e18b
								
							
						
					
					
						commit
						29daa6e90e
					
				
							
								
								
									
										
											BIN
										
									
								
								bin/DMGTRIS.GBC
								
								
								
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/DMGTRIS.GBC
								
								
								
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,89 @@
 | 
			
		|||
; DMGTRIS
 | 
			
		||||
; Copyright (C) 2023 - Randy Thiemann <randy.thiemann@gmail.com>
 | 
			
		||||
 | 
			
		||||
; 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 <https://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								src/main.asm
								
								
								
								
							
							
						
						
									
										19
									
								
								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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue