Skip to content

Instantly share code, notes, and snippets.

@SelvinPL
Last active September 15, 2024 12:45
Show Gist options
  • Select an option

  • Save SelvinPL/acd390e5c5d5ead9e37de86f86a3f104 to your computer and use it in GitHub Desktop.

Select an option

Save SelvinPL/acd390e5c5d5ead9e37de86f86a3f104 to your computer and use it in GitHub Desktop.
INCLUDE "hardware.inc"
SECTION "HRAM", HRAM
wait_for_vblank:
ds 1
SECTION "VBLANK", ROM0[INT_HANDLER_VBLANK]
push af
xor a
ldh [wait_for_vblank], a
pop af
reti
SECTION "HEADER", ROM0[$100]
jp EntryPoint
ds $150 - @, 0
EntryPoint:
ldh [rNR52], a
ld hl, $e000
ld sp, hl
ld a, IEF_VBLANK | IEF_STAT
ldh [rIE], a
ei
call WaitVBlank
xor a
ldh [rLCDC], a
di
call SetupLogo
ld a, LCDCF_ON | LCDCF_BGON
ldh [rLCDC], a
ld a, %11100100
ldh [rBGP], a
ei
ld b, 4
: call WaitVBlank
call TitleLoop
jr :-
SetupLogo::
ld hl, $9010
ld de, $104
: ld a, [de]
swap a
and $f
call TranslateLogo
ld [hl+], a
inc hl
ld [hl+], a
inc hl
ld a, [de]
and $f
call TranslateLogo
ld [hl+], a
inc hl
ld [hl+], a
inc hl
inc de
ld a, e
sub $34
jp c, :-
ld hl, $990f
ld a, $0c
: ld [hl-], a
dec a
jp nz, :-
ld hl, $992f
ld b, $0c
ld a, $18
: ld [hl-], a
dec a
dec b
jp nz, :-
ret
WaitVBlank::
push af
ld a, 1
ldh [wait_for_vblank], a
: halt
nop
ldh a, [wait_for_vblank]
or a
jr nz, :-
pop af
ret
TitleLoop::
dec b
ret nz
ld hl, rSCY
inc [hl]
ld b, 2
ret
TranslateLogo::
ld b, 0
ld c, 3
: bit 0, a
jr Z, :+
push af
ld a, b
or a, c
ld b, a
pop af
: sla c
sla c
srl a
jr NZ, :--
ld a, b
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment