summaryrefslogtreecommitdiff
path: root/engine/init_map.asm
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2017-12-23 13:17:46 -0500
committerGitHub <noreply@github.com>2017-12-23 13:17:46 -0500
commit878092004956418bfd77bfdb9fc9dd7f640f80d2 (patch)
tree3a97e3eb15d5c545977038e67589f92158e5bf23 /engine/init_map.asm
parenta6656a986bf9dde51561cab090648e0117b173ad (diff)
parent3c37bfc6fa2570a0a77c1230673910257ecf32df (diff)
Merge pull request #419 from roukaour/master
More reorganization and documentation
Diffstat (limited to 'engine/init_map.asm')
-rw-r--r--engine/init_map.asm103
1 files changed, 103 insertions, 0 deletions
diff --git a/engine/init_map.asm b/engine/init_map.asm
new file mode 100644
index 000000000..5dd6c7b8a
--- /dev/null
+++ b/engine/init_map.asm
@@ -0,0 +1,103 @@
+ReanchorBGMap_NoOAMUpdate:: ; 6454
+ call DelayFrame
+ ld a, [hOAMUpdate]
+ push af
+
+ ld a, $1
+ ld [hOAMUpdate], a
+ ld a, [hBGMapMode]
+ push af
+ xor a
+ ld [hBGMapMode], a
+
+ call .ReanchorBGMap
+
+ pop af
+ ld [hBGMapMode], a
+ pop af
+ ld [hOAMUpdate], a
+ ld hl, VramState
+ set 6, [hl]
+ ret
+
+.ReanchorBGMap:
+ xor a
+ ld [hLCDCPointer], a
+ ld [hBGMapMode], a
+ ld a, $90
+ ld [hWY], a
+ call OverworldTextModeSwitch
+ ld a, VBGMap1 / $100
+ call .LoadBGMapAddrIntoHRAM
+ call _OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
+ callba LoadOW_BGPal7
+ callba ApplyPals
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ xor a
+ ld [hBGMapMode], a
+ ld [hWY], a
+ callba HDMATransfer_FillBGMap0WithBlack ; no need to farcall
+ ld a, VBGMap0 / $100
+ call .LoadBGMapAddrIntoHRAM
+ xor a
+ ld [wBGMapAnchor], a
+ ld a, VBGMap0 / $100
+ ld [wBGMapAnchor + 1], a
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ call ApplyBGMapAnchorToObjects
+ ret
+
+.LoadBGMapAddrIntoHRAM: ; 64b9
+ ld [hBGMapAddress + 1], a
+ xor a
+ ld [hBGMapAddress], a
+ ret
+
+LoadFonts_NoOAMUpdate:: ; 64bf
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+
+ call .LoadGFX
+
+ pop af
+ ld [hOAMUpdate], a
+ ret
+
+.LoadGFX:
+ call LoadFontsExtra
+ ld a, $90
+ ld [hWY], a
+ call SafeUpdateSprites
+ call LoadStandardFont
+ ret
+
+HDMATransfer_FillBGMap0WithBlack: ; 64db
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+
+ ld a, "<BLACK>" ; $60
+ ld hl, wDecompressScratch
+ ld bc, wScratchAttrMap - wDecompressScratch
+ call ByteFill
+ ld a, wDecompressScratch / $100
+ ld [rHDMA1], a
+ ld a, wDecompressScratch % $100
+ ld [rHDMA2], a
+ ld a, (VBGMap0 % $8000) / $100
+ ld [rHDMA3], a
+ ld a, (VBGMap0 % $8000) % $100
+ ld [rHDMA4], a
+ ld a, $3f
+ ld [hDMATransfer], a
+ call DelayFrame
+
+ pop af
+ ld [rSVBK], a
+ ret