ref: 4e6adcddff69fd53ce342ead502a0699cd5f75ba
dir: /home/init.asm/
SoftReset:: call StopAllSounds call GBPalWhiteOut ld c, 32 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 [rSCX], a ld [rSCY], a ld [rSB], a ld [rSC], a ld [rWX], a ld [rWY], a ld [rTMA], a ld [rTAC], a ld [rBGP], a ld [rOBP0], a ld [rOBP1], a ld a, rLCDC_ENABLE_MASK ld [rLCDC], a call DisableLCD ld sp, wStack ld hl, WRAM0_Begin ld bc, WRAM1_End - WRAM0_Begin .loop ld [hl], 0 inc hl dec bc ld a, b or c jr nz, .loop call ClearVram ld hl, HRAM_Begin ld bc, HRAM_End - HRAM_Begin call FillMemory call ClearSprites ld a, BANK(WriteDMACodeToHRAM) ld [hLoadedROMBank], a ld [MBC1RomBank], a call WriteDMACodeToHRAM xor a ld [hTilesetType], a ld [rSTAT], a ld [hSCX], a ld [hSCY], a ld [rIF], a ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL ld [rIE], a ld a, 144 ; move the window off-screen ld [hWY], a ld [rWY], a ld a, 7 ld [rWX], a ld a, CONNECTION_NOT_ESTABLISHED ld [hSerialConnectionStatus], a 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 predef LoadSGB ld a, BANK(SFX_Shooting_Star) ld [wAudioROMBank], a ld [wAudioSavedROMBank], a ld a, $9c ld [hAutoBGTransferDest + 1], a xor a ld [hAutoBGTransferDest], a dec a ld [wUpdateSpritesEnabled], a predef PlayIntro call DisableLCD call ClearVram call GBPalNormal call ClearSprites ld a, rLCDC_DEFAULT ld [rLCDC], a jp SetDefaultNamesBeforeTitlescreen ClearVram:: ld hl, VRAM_Begin ld bc, VRAM_End - VRAM_Begin xor a jp FillMemory StopAllSounds:: ld a, BANK(Audio1_UpdateMusic) ld [wAudioROMBank], a ld [wAudioSavedROMBank], a xor a ld [wAudioFadeOutControl], a ld [wNewSoundID], a ld [wLastMusicSoundID], a dec a jp PlaySound