pokered/home/init.asm

138 lines
1.9 KiB
NASM
Raw Normal View History

2014-05-31 08:22:15 +00:00
SoftReset::
call StopAllSounds
call GBPalWhiteOut
ld c, 32
2014-05-31 08:22:15 +00:00
call DelayFrames
; fallthrough
Init::
; Program init.
rLCDC_DEFAULT EQU %11100011
; * LCD enabled
; * Window tile map at $9C00
; * Window display enabled
; * BG and window tile data at $8800
; * BG tile map at $9800
; * 8x8 OBJ size
; * OBJ display enabled
; * BG display enabled
di
xor a
ld [rIF], a
ld [rIE], a
ld [$ff43], a
ld [$ff42], a
2014-08-09 05:39:13 +00:00
ld [rSB], a
2015-02-07 10:43:08 +00:00
ld [rSC], a
2015-07-15 02:46:52 +00:00
ld [rWX], a
2014-05-31 08:22:15 +00:00
ld [$ff4a], a
ld [$ff06], a
ld [$ff07], a
2015-07-13 20:35:35 +00:00
ld [rBGP], a
ld [rOBP0], a
2014-05-31 08:22:15 +00:00
ld [$ff49], a
ld a, rLCDC_ENABLE_MASK
ld [rLCDC], a
call DisableLCD
ld sp, wStack
ld hl, $c000 ; start of WRAM
ld bc, $2000 ; size of WRAM
.loop
ld [hl], 0
inc hl
dec bc
ld a, b
or c
jr nz, .loop
call ClearVram
ld hl, $ff80
ld bc, $ffff - $ff80
call FillMemory
call ClearSprites
ld a, Bank(WriteDMACodeToHRAM)
ld [H_LOADEDROMBANK], a
2014-09-14 18:29:18 +00:00
ld [MBC1RomBank], a
2014-05-31 08:22:15 +00:00
call WriteDMACodeToHRAM
xor a
2014-09-14 18:29:18 +00:00
ld [hTilesetType], a
2014-05-31 08:22:15 +00:00
ld [$ff41], a
2015-02-07 10:43:08 +00:00
ld [hSCX], a
ld [hSCY], a
2014-05-31 08:22:15 +00:00
ld [$ff0f], a
ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL
ld [rIE], a
ld a, 144 ; move the window off-screen
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-31 08:22:15 +00:00
ld [rWY], a
ld a, 7
ld [rWX], a
2015-02-07 10:43:08 +00:00
ld a, CONNECTION_NOT_ESTABLISHED
ld [hSerialConnectionStatus], a
2014-05-31 08:22:15 +00:00
ld h, vBGMap0 / $100
call ClearBgMap
ld h, vBGMap1 / $100
call ClearBgMap
ld a, rLCDC_DEFAULT
ld [rLCDC], a
ld a, 16
ld [hSoftReset], a
call StopAllSounds
ei
2014-06-16 20:25:46 +00:00
predef LoadSGB
2014-05-31 08:22:15 +00:00
ld a, BANK(SFX_1f_67)
2014-05-31 08:22:15 +00:00
ld [wc0ef], a
ld [wc0f0], a
ld a, $9c
ld [H_AUTOBGTRANSFERDEST + 1], a
2014-05-31 08:22:15 +00:00
xor a
ld [H_AUTOBGTRANSFERDEST], a
2014-05-31 08:22:15 +00:00
dec a
2014-09-13 07:50:56 +00:00
ld [wUpdateSpritesEnabled], a
2014-05-31 08:22:15 +00:00
2014-06-16 20:25:46 +00:00
predef PlayIntro
2014-05-31 08:22:15 +00:00
call DisableLCD
call ClearVram
call GBPalNormal
call ClearSprites
ld a, rLCDC_DEFAULT
ld [rLCDC], a
jp SetDefaultNamesBeforeTitlescreen
ClearVram:
ld hl, $8000
ld bc, $2000
xor a
jp FillMemory
StopAllSounds::
2014-06-09 20:18:29 +00:00
ld a, BANK(Music2_UpdateMusic)
2014-05-31 08:22:15 +00:00
ld [wc0ef], a
ld [wc0f0], a
xor a
ld [wMusicHeaderPointer], a
ld [wc0ee], a
ld [wcfca], a
dec a
jp PlaySound