diff options
author | U-Fish-PC\Daniel <corrnondacqb@yahoo.com> | 2014-06-09 15:10:49 -0400 |
---|---|---|
committer | U-Fish-PC\Daniel <corrnondacqb@yahoo.com> | 2014-06-09 15:10:49 -0400 |
commit | d266f788b4ba251c5a41f47745c941d81e5d7d88 (patch) | |
tree | 004892d1cc02111732dcb81ef9734ab13ab49ef5 /home/init.asm | |
parent | 683a62cc1cb7d07b4c88eeec9333c415da8f0bdc (diff) | |
parent | fc123e360b147221b5b44d265cdf38feabe99bbe (diff) |
Merge branch 'master' of https://github.com/yenatch/pokered
Diffstat (limited to 'home/init.asm')
-rw-r--r-- | home/init.asm | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/home/init.asm b/home/init.asm new file mode 100644 index 00000000..939e81b5 --- /dev/null +++ b/home/init.asm @@ -0,0 +1,139 @@ +SoftReset:: + call StopAllSounds + call GBPalWhiteOut + ld c, $20 + 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 + ld [$ff01], a + ld [$ff02], a + ld [$ff4b], a + ld [$ff4a], a + ld [$ff06], a + ld [$ff07], a + ld [$ff47], a + ld [$ff48], a + 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 + ld [MBC3RomBank], a + call WriteDMACodeToHRAM + + xor a + ld [$ffd7], a + ld [$ff41], a + ld [$ffae], a + ld [$ffaf], a + ld [$ff0f], a + ld a, 1 << VBLANK + 1 << TIMER + 1 << SERIAL + ld [rIE], a + + ld a, 144 ; move the window off-screen + ld [$ffb0], a + ld [rWY], a + ld a, 7 + ld [rWX], a + + ld a, $ff + ld [$ffaa], 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 + + ld a, $40 ; PREDEF_SGB_BORDER + call Predef + + ld a, $1f + ld [wc0ef], a + ld [wc0f0], a + ld a, $9c + ld [$ffbd], a + xor a + ld [$ffbc], a + dec a + ld [wcfcb], a + + ld a, $32 ; PREDEF_INTRO + call Predef + + 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:: + ld a, Bank(Func_9876) + ld [wc0ef], a + ld [wc0f0], a + xor a + ld [wMusicHeaderPointer], a + ld [wc0ee], a + ld [wcfca], a + dec a + jp PlaySound |