GBS = 1

INCLUDE "includes.asm"
INCLUDE "gbs_rst.asm"

SECTION "GBS Header", ROM0[$390]
	charmap " ", $20
	db "GBS"         ;signature
	db 1             ;version
	db NUM_MUSIC - 1 ;number of songs
	db 1             ;first song
	dw $400          ;load address
	dw GBS_Init      ;init address
	dw GBS_Play      ;play address
	dw Stack         ;stack pointer
	db 0             ;rTMA
	db 0             ;rTAC
GBS_TitleText:
	db "Pokemon Prism"
	ds GBS_TitleText - @ + 32
GBS_AuthorText:
	db ""
	ds GBS_AuthorText - @ + 32
GBS_CopyrightText:
	db "2017 RainbowDevs 2001 Nintendo"
	ds GBS_CopyrightText - @ + 32

SECTION "GBS Main", ROM0[$440]
GBS_Init:
	di
	inc a
	ld e, a
	ld d, 0
	ld a, 1 << VBLANK
	ld [rIE], a
	ld a, 1 << 5 ; stereo on
	ld [wOptions], a
	ei
	call TurnSoundOff
	jp PlayMusic

GBS_Play:
	call UpdateSound
	reti

DelayFrame::
; Wait for one frame
	ld a, 1
	ld [wVBlankOccurred], a

; Wait for the next VBlank, halting to conserve battery
.halt
	halt ; rgbasm adds a nop after this instruction by default
	ld a, [wVBlankOccurred]
	and a
	jr nz, .halt
	ret

INCLUDE "home/farcall.asm"
INCLUDE "home/jumptable.asm"
INCLUDE "home/audio.asm"
