summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2018-06-10 10:58:08 -0400
committerGitHub <noreply@github.com>2018-06-10 10:58:08 -0400
commitbfdaa1151902023fc69c97328cf12bdd88816185 (patch)
tree7d83ac3340a0535aa85269e7247008164f9b8d7d
parent886ecea86b9257ba2755b4718ede90ee18dae96e (diff)
parentd89bd1ac8b1304313bae285ada7d24601cf67d09 (diff)
Merge pull request #1 from ISSOtm/master
Catch up
-rw-r--r--Makefile2
-rw-r--r--constants.asm2
-rw-r--r--constants/map_setup_constants.asm10
-rw-r--r--constants/wram_constants.asm8
-rw-r--r--data/predef_pointers.inc4
-rw-r--r--engine/link/place_waiting_text.asm5
-rw-r--r--engine/title.asm630
-rw-r--r--gfx.asm25
-rw-r--r--gfx/title/title.pngbin0 -> 265 bytes
-rw-r--r--gfx/title/title_gold_version.pngbin0 -> 276 bytes
-rw-r--r--gfx/title/title_goldlogo.pngbin0 -> 225 bytes
-rw-r--r--gfx/title/title_hooh.pngbin0 -> 488 bytes
-rw-r--r--gfx/title/title_logo.pngbin0 -> 618 bytes
-rw-r--r--gfx/title/title_silver_version.pngbin0 -> 282 bytes
-rw-r--r--gfx/title/title_silverlogo.pngbin0 -> 243 bytes
-rw-r--r--gfx/title/titlebgdecoration.pngbin0 -> 145 bytes
-rw-r--r--home/init.asm2
-rw-r--r--home/map.asm1859
-rw-r--r--home/menu_window.asm2
-rw-r--r--home/tilemap.asm2
-rw-r--r--home/unknown_388f.asm6
-rw-r--r--macros/wram.asm1
-rw-r--r--shim.sym29
-rw-r--r--vram.asm7
-rw-r--r--wram.asm43
25 files changed, 2584 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index c816896..37561a9 100644
--- a/Makefile
+++ b/Makefile
@@ -94,8 +94,6 @@ $(BUILD)/%.o: %.asm | $$(dir $$@)
$(BUILD)/gfx/sgb/sgb_border_alt.2bpp: tools/gfx += --trim-whitespace
$(BUILD)/gfx/sgb/sgb_border_gold.2bpp: tools/gfx += --trim-whitespace
$(BUILD)/gfx/sgb/sgb_border_silver.2bpp: tools/gfx += --trim-whitespace
-$(BUILD)/gfx/title/title_gold.2bpp: tools/gfx += --trim-whitespace
-$(BUILD)/gfx/title/title_silver.2bpp: tools/gfx += --trim-whitespace
$(BUILD)/gfx/trainer_card/leaders.2bpp: tools/gfx += --trim-whitespace
$(BUILD)/gfx/trainer_card/trainer_card.2bpp: tools/gfx += --trim-whitespace
$(BUILD)/gfx/pokegear/town_map.2bpp: tools/gfx += --trim-trailing
diff --git a/constants.asm b/constants.asm
index 66383ba..88dd7ee 100644
--- a/constants.asm
+++ b/constants.asm
@@ -22,6 +22,7 @@ INCLUDE "constants/palette_constants.asm"
INCLUDE "constants/music_constants.asm"
INCLUDE "constants/landmark_constants.asm"
INCLUDE "constants/map_constants.asm"
+INCLUDE "constants/map_setup_constants.asm"
INCLUDE "constants/tileset_constants.asm"
INCLUDE "constants/map_data_constants.asm"
@@ -31,5 +32,6 @@ INCLUDE "constants/misc_constants.asm"
INCLUDE "constants/battle_anim_constants.asm"
INCLUDE "constants/menu_constants.asm"
+INCLUDE "constants/wram_constants.asm"
INCLUDE "constants/sgb_constants.asm"
INCLUDE "constants/map_object_constants.asm"
diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm
new file mode 100644
index 0000000..046fc65
--- /dev/null
+++ b/constants/map_setup_constants.asm
@@ -0,0 +1,10 @@
+
+ const_def $f1
+ const MAPSETUP_CONTINUE ; $f1
+ const MAPSETUP_F2
+ const MAPSETUP_RELOADMAP ; $f3
+ const MAPSETUP_F4
+ const MAPSETUP_F5 ; Note: entry is duplicate of $F4
+ const MAPSETUP_WARP ; $f6
+ const MAPSETUP_CONNECTION ; $f7
+ const MAPSETUP_F8
diff --git a/constants/wram_constants.asm b/constants/wram_constants.asm
new file mode 100644
index 0000000..a5e3044
--- /dev/null
+++ b/constants/wram_constants.asm
@@ -0,0 +1,8 @@
+; wWalkingDirection::
+ const_def -1
+ const STANDING ; -1
+ const DOWN ; 0
+ const UP ; 1
+ const LEFT ; 2
+ const RIGHT ; 3
+NUM_DIRECTIONS EQU const_value \ No newline at end of file
diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc
index 58b2de9..0b39ae2 100644
--- a/data/predef_pointers.inc
+++ b/data/predef_pointers.inc
@@ -40,7 +40,7 @@ GiveItemPredef::
add_predef Functiondf91
add_predef Function1128f
add_predef Function112c1
- add_predef Function28c98
+ add_predef LinkTextboxAtHL
add_predef Function2d663
add_predef Function3d5ce
add_predef PlaceGraphic
@@ -98,4 +98,4 @@ GiveItemPredef::
add_predef Functioncc000_2
add_predef Functionfdb66
add_predef Function1240b
- dbw $ff, InexplicablyEmptyFunction
+ dbw $ff, InexplicablyEmptyFunction ; 56
diff --git a/engine/link/place_waiting_text.asm b/engine/link/place_waiting_text.asm
index bfe9d7e..a9f712e 100644
--- a/engine/link/place_waiting_text.asm
+++ b/engine/link/place_waiting_text.asm
@@ -13,10 +13,7 @@ PlaceWaitingText:: ; 1:4000
jr .textbox_done
.link_textbox
- ; TODO
- ; predef Predef_LinkTextbox
- ld a, $1c
- call Predef
+ predef LinkTextboxAtHL
.textbox_done
hlcoord 4, 11
ld de, .Waiting
diff --git a/engine/title.asm b/engine/title.asm
index 961b83b..7f9d707 100644
--- a/engine/title.asm
+++ b/engine/title.asm
@@ -2,17 +2,641 @@ INCLUDE "constants.asm"
SECTION "Title screen", ROMX[$5D8C], BANK[$01]
-IntroSequence:: ; 5d8c
- ; TODO
+IntroSequence::
+ callab GameFreakIntro ; Bank $39
+ jr c, TitleSequenceStart
+ ld a, [wTitleSequenceOpeningType]
+ and a
+ jr z, .opening_sequence
+
+.pikachu_minigame
+ callab PikachuMiniGame ; Bank $38
+ jr TitleSequenceStart
+.opening_sequence
+ callab OpeningCutscene ; Bank $39
+
+TitleSequenceStart::
+ call TitleSequenceInit
+ callab SetTitleBGDecorationBorder ; Bank $02
+
+.loop
+ call TitleScreenMain
+ jr nc, .loop
+
+ call ClearBGPalettes
+ call ClearSprites
+ ld a, $01
+ ldh [hBGMapMode], a
+ call ClearTileMap
+ call UpdateTimePals
+
+ ld a, [wJumptableIndex + 1]
+ ld e, a
+ ld d, 0
+ ld hl, TitleScreenJumpTable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ jp hl
+
+TitleScreenJumpTable::
+ dw MainMenu
+ dw DebugMenu
+ dw SRAMClearMenu
+ dw IntroSequence
+
+TitleSequenceInit::
+ call ClearPalettes
+
+ xor a
+ ldh [hMapAnims], a
+ ldh [hSCY], a
+ ldh [hSCX], a
+
+ ld de, MUSIC_NONE ; Stop the music.
+ call PlayMusic
+
+ call ClearTileMap
+ call DisableLCD
+ call ClearSprites
+
+ callba InitEffectObject ; Bank $23
+ ld hl, vChars0
+ ld bc, vBGMap0 - vChars0
+
+.clear_loop
+ ld [hl], $00
+ inc hl
+ dec bc
+ ld a, b
+ or c
+ jr nz, .clear_loop
+
+ ld hl, TitleScreenGFX
+ ld de, vChars2 + 65 tiles
+ ld bc, 13 tiles
+ ld a, BANK(TitleScreenGFX)
+ call FarCopyData
+
+ ld hl, TitleScreenVersionGFX
+ ld de, vChars2 + 96 tiles
+ ld bc, 24 tiles
+ ld a, BANK(TitleScreenVersionGFX)
+ call FarCopyData
+
+ ld hl, TitleScreenHoOhGFX
+ ld de, vChars2
+ ld bc, 49 tiles
+ ld a, BANK(TitleScreenHoOhGFX)
+ call FarCopyData
+
+ ld hl, TitleScreenLogoGFX
+ ld de, vChars1
+ ld bc, 58 tiles
+ ld a, BANK(TitleScreenLogoGFX)
+ call FarCopyData
+
+ ld hl, TitleScreenGoldLogoGFX
+ ld de, vChars0 + 186 tiles
+ ld bc, 20 tiles
+ ld a, BANK(TitleScreenGoldLogoGFX)
+ call FarCopyData
+
+ call SetTitleGfx
+ ld hl, wTileMapBackup
+ ld a, $24
+ ld [hli], a
+ ld a, $00
+ ld [hli], a
+
+ ld hl, vBGMap0
+ ld bc, 128 tiles
+ ld a, " "
+ call ByteFill
+
+ ld b, $06
+ call GetSGBLayout
+ call EnableLCD
+ ld a, $01
+ ldh [hBGMapMode], a
+ call WaitBGMap
+ xor a
+ ldh [hBGMapMode], a
+ ld hl, wJumptableIndex
+ ld [hli], a ; (Possibly wJumptableIndex from Crystal)
+ ld [hli], a ; (Possibly wIntroSceneFrameCounter from Crystal)
+ ld [hli], a ; (Possibly wTitleScreenTimer from Crystal)
+ ld [hl], a ; (Possibly wTitleScreenTimer + 1 from Crystal)
+
+ call .load_position_table
+
+
+ ld a, %00011010
+ ldh [rBGP], a
+ ld a, %11100100
+ ldh [rOBP0], a
+ ret
+
+.load_position_table:
+ ld hl, FirePositionTable
+ ld c, 6 ; Load 6 flying objects on the screen.
+
+.set_fire_note_loop
+ push bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ push hl
+ ld a, $2E ; Title fire/note object effect type?
+ call InitSpriteAnimStruct
+ pop hl
+ pop bc
+ dec c
+ jr nz, .set_fire_note_loop
+ ret
+
+FirePositionTable::
+ dw $4CE0
+ dw $58A0
+ dw $6490
+ dw $70D0
+ dw $7CB0
+ dw $8800
+
+TitleFireGFX:: INCBIN "gfx/title/fire.2bpp" ; 5EB8-5F37
+TitleNotesGFX:: INCBIN "gfx/title/notes.2bpp" ; 5F38=5FB7
+
+TitleScreenMain::
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .exit
+ call TitleScreenSequence
+ callba EffectObjectJumpNoDelay ; Bank $23
+ call DelayFrame
+ and a
+ ret
+
+.exit
+ scf
+ ret
+
+TitleScreenSequence::
+ ld e, a
+ ld d, 0
+ ld hl, TitleScreenSequenceTable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+TitleScreenSequenceTable::
+ dw TitleSeq_Start
+ dw TitleSeq_LoadPokemonLogo
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_MoveTitle
+ dw TitleSeq_MoveTitleEnd
+ dw TitleSeq_InitFlashTitle
+ dw TitleSeq_FlashTitle
+
+ dw TitleSeq_PMJapaneseChara
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_WaitForNextSequence
+ dw TitleSeq_PMSubtitle
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_WaitForNextSequence
+ dw TitleSeq_Version
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_WaitForNextSequence
+ dw TitleSeq_CopyRight
+
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_WaitForNextSequence
+ dw TitleSeq_HoOh
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+ dw TitleSeq_IncreaseJumpTableIndex
+
+ dw TitleSeq_WaitForNextSequence
+ dw TitleSeq_PressButtonInit
+ dw TitleSeq_TitleScreenInputAndTimeout
+ dw TitleSeq_FadeMusicOut
+
+TitleSeq_IncreaseJumpTableIndex::
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+TitleSeq_WaitForNextSequence::
+ xor a
+ ldh [hBGMapMode], a
+ ld hl, wJumptableIndex + 2
+ ld a, [hl]
+ and a
+ jr z, .next_seq
+ dec [hl]
+ ret
+
+.next_seq
+ call TitleSeq_IncreaseJumpTableIndex
+ ret
+
+TitleSeq_LoadPokemonLogo::
+ call PrintPokemonLogo
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_Start::
+ call TitleSeq_IncreaseJumpTableIndex
+ push de
+ ld de, $002D
+ call PlaySFX ; Play "Swish" sound
+ pop de
+ ld a, $80
+ ld [wJumptableIndex + 2], a
+ call SetLYOverrides
+ ld a, $43
+ ldh [hLCDCPointer], a
+ ret
+
+TitleSeq_MoveTitle::
+ xor a
+ ldh [hBGMapMode], a
+ ld hl, wJumptableIndex + 2
+ ld a, [hl]
+ and a
+ jr z, .nextseq
+ add $04
+ ld [hl], a
+ ld e, a
+.wait
+ ldh a, [rLY]
+ cp $40
+ jr c, .wait
+ ld a, e
+ call SetLYOverrides
+ ret
+
+.nextseq
+ call TitleSeq_IncreaseJumpTableIndex
+ ret
+
+TitleSeq_MoveTitleEnd::
+ xor a
+ ldh [hLCDCPointer], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld de, MUSIC_TITLE
+ call PlayMusic ; Play "Title Theme"
+ ret
+
+TitleSeq_InitFlashTitle::
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, %00011010
+ ld [wJumptableIndex + 2], a
+ ld a, 6
+ ld [wJumptableIndex + 3], a
+ ret
+
+TitleSeq_FlashTitle::
+ ld hl, wJumptableIndex + 3
+ ld a, [hl]
+ and a
+ jr z, .exit
+ dec [hl]
+ ld a, [wJumptableIndex + 2]
+ xor %00011010
+ ld [wJumptableIndex +2 ], a
+ ldh [rBGP], a
+ call DelayFrame
+ call DelayFrame
+ ret
+
+.exit
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, %11100100
+ ldh [rBGP], a
+ ret
+
+TitleSeq_PMJapaneseChara::
+ call PrintPMJapaneseChara
+ ld a, $10
+ ld [wJumptableIndex + 2], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_PMSubtitle::
+ call PrintPMSubtitle
+ ld a, $10
+ ld [wJumptableIndex + 2], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_Version::
+ call PrintVersion
+ ld a, $10
+ ld [wJumptableIndex + 2], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_CopyRight::
+ call PrintCopyRight
+ ld a, $10
+ ld [wJumptableIndex + 2], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_HoOh::
+ call Set_HoOh
+ ld a, $10
+ ld [wJumptableIndex + 2], a
+ call TitleSeq_IncreaseJumpTableIndex
+ ld a, $01
+ ldh [hBGMapMode], a
+ ret
+
+TitleSeq_PressButtonInit::
+ ld hl, wJumptableIndex
+ inc [hl]
+ ld hl, wJumptableIndex + 2
+ ld de, DecodeNybble0Table - 3 ; DecodeNybble0Table - 3 = $0C00
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ret
+
+TitleSeq_TitleScreenInputAndTimeout::
+ ld hl, wJumptableIndex + 2
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld a, e
+ or d
+ jr z, .psbtn_reset
+ dec de
+ ld [hl], d
+ dec hl
+ ld [hl], e
+ call GetJoypad
+ ld hl, hJoyState
+ ld a, [hl]
+ and D_UP | B_BUTTON | SELECT ; UP + B + SELECT brings you to the SRAM clear screen.
+ cp D_UP | B_BUTTON | SELECT
+ jr z, .psbtn_sramclear
+ ld a, [hl]
+ and SELECT ; SELECT will bring you to the debug menu.
+ jr nz, .psbtn_gotodebug
+ ld a, [hl]
+ and $09
+ ret z
+
+.psbtn_play
+ ld a, $00 ; MainMenu
+ jr .psbtn_nextseq
+
+.psbtn_gotodebug
+if DEBUG
+ ld a, $01 ; DebugMenu
+ jr .psbtn_nextseq
+else
+ ret
+endc
+
+.psbtn_sramclear
+ ld a, $02
+
+.psbtn_nextseq
+ ld [wJumptableIndex + 1], a
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.psbtn_reset
+ ld hl, wJumptableIndex
+ inc [hl]
+ xor a
+ ld [wMusicFadeID], a
+ ld [wMusicFadeID + 1], a
+ ld hl, wMusicFade
+ ld [hl], 8
+ ret
+
+TitleSeq_FadeMusicOut::
+ ld a, [wMusicFade]
+ and a
+ ret nz
+ ld a, 3
+ ld [wJumptableIndex + 1], a
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+SetLYOverrides::
+ ld hl, wLYOverrides
+ ld c, $30
+.setly_loop
+ ld [hli], a
+ dec c
+ jr nz, .setly_loop
+ ret
+
+PrintPMSubtitle::
+ coord hl, 2, 6
+ ld b, 15
+ ld a, $69
+ jr LoadPrintArea
+
+PrintVersion::
+ coord hl, 4, 1
+ ld b, $09
+ ld a, $60
+
+LoadPrintArea::
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, LoadPrintArea
+ ret
+
+PrintPMJapaneseChara::
+ coord hl, 15, 2
+ ld a, "こ"
+ lb bc, 4, 4
+ jr PrintBoxArea
+
+PrintPokemonLogo::
+ coord hl, 15, 3
+ ld [hl], $B8
+ coord hl, 15, 4
+ ld [hl], $B9
+ coord hl, 1, 2
+ ld a, $80
+ ld bc, $0E04
+
+PrintBoxArea::
+ ld de, SCREEN_WIDTH
+ push bc
+ push hl
+
+.xloop
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .xloop
+ pop hl
+ add hl, de
+ pop bc
+ dec c
+ jr nz, PrintBoxArea
+ ret
+
+PrintCopyRight::
+ coord hl, 3, 17
+ ld a, $41
+ ld b, $0D
+
+.loop
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .loop
+ ret
+
+SRAMClearMenu::
+ call ClearTileMap
+ call GetMemSGBLayout
+ call LoadFont
+ call LoadFontExtra
+ ld hl, SRAMClear_Message
+ call PrintText
+ ld hl, SRAMClear_WinPOS
+ call CopyMenuHeader
+ call VerticalMenu
+ jp c, Init
+ ld a, [wMenuCursorY]
+ cp $01
+ jp z, Init
+
+ callab InitAllSRAMBanks ; Bank $05
+ jp Init
+
+SRAMClear_Message::
+ db "<NULL>すべての セーブデータエりアを"
+ db "<LINE>クりア しますか?<DONE>"
+
+SRAMClear_WinPOS::
+ db 0
+ db 7,14,11,19
+ dw SRAMClear_TextChoice ; menu data
+ db 1 ; default option
+
+SRAMClear_TextChoice::
+ db %11000000
+ db 2
+ db "いいえ@"
+ db "はい@"
+
+IntroCopyRightInfo::
+ call ClearTileMap
+ call LoadFontExtra
+ ld de, TitleScreenGFX
+ ld hl, $9600
+ lb bc, BANK(TitleScreenGFX), $19
+ call Request2bpp
+
+ coord hl, 5, 7
+ ld de, IntroCopyRightInfo_Text
+ jp PlaceString
+
+IntroCopyRightInfo_Text::
+ db $60, $61, $62, $63, $6D, $6E, $6F, $70, $71, $72, $4E ; "(C)1997 Nintendo\n"
+ db $60, $61, $62, $63, $73, $74, $75, $76, $77, $78, $6B, $6C, $4E ; "(C)1997 Creatures Inc.\n"
+ db $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $50 ; "(C)1997 GAME FREAK Inc.{EOL}"
+
+Set_HoOh::
+ coord hl, 7, 9
+ ld de, $000D
+ ld a, $00
+ ld b, $07
+.loop
+ ld c, $07
+.loop2
+ ld [hli], a
+ inc a
+ dec c
+ jr nz, .loop2
+ add hl, de
+ dec b
+ jr nz, .loop
+ ret
+
+; Unused code, looks like it sets the font type for the logo?
+SetTitleFont::
+ ld de, vChars1
+ ld hl, TitleScreenLogoGFX
+ ld bc, 130 tiles
+ ld a, $04
+ jp FarCopyDataDouble
+
+; Sets the type of art that will be displayed on the title screen
+; depending on wTitleSequenceOpeningType.
+SetTitleGfx::
+ ld hl, wTitleSequenceOpeningType
+ ld a, [hl]
+ xor $01
+ ld [hl], a
+ jr nz, .flame
+
+.note
+ ld hl, TitleNotesGFX
+ jr SetTitleGfxNext
+
+.flame
+ ld hl, TitleFireGFX
+SetTitleGfxNext::
+ ld de, vChars0
+ ld c, $80
+.loop
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop
+ ret
if DEBUG
SECTION "Title screen TEMPORARY", ROMX[$62A5],BANK[1] ; TODO: merge this with the main section above
else
SECTION "Title screen TEMPORARY", ROMX[$62A2],BANK[1] ; TODO: merge this with the main section above
endc
+
-GameInit:: ; 62a5
+GameInit::
call ClearWindowData
ld a, $23
ld [wce5f], a
diff --git a/gfx.asm b/gfx.asm
index fdd576b..33c37b9 100644
--- a/gfx.asm
+++ b/gfx.asm
@@ -1,11 +1,5 @@
INCLUDE "constants.asm"
-SECTION "Title Screen Sprites", ROMX[$5EB8], BANK[$01]
-TitleFireGFX::
-INCBIN "gfx/title/fire.2bpp"
-TitleNotesGFX::
-INCBIN "gfx/title/notes.2bpp"
-
SECTION "Mon Nest Icon", ROMX[$4A0F], BANK[$02]
PokedexNestIconGFX::
INCBIN "gfx/pokegear/dexmap_nest_icon.1bpp"
@@ -25,6 +19,10 @@ SECTION "Pokegear GFX", ROMX[$4F32], BANK[$02]
PokegearGFX::
INCBIN "gfx/pokegear/pokegear.2bpp"
+SECTION "Title Screen BG Decoration Border", ROMX[$51FB], BANK[$02]
+TitleBGDecorationBorder::
+INCBIN "gfx/title/titlebgdecoration.2bpp"
+
SECTION "Super Palettes", ROMX[$5B4C], BANK[$02]
INCLUDE "data/pokemon/palettes.inc"
INCLUDE "data/super_palettes.inc"
@@ -42,11 +40,18 @@ INCBIN "gfx/sgb/sgb_border_silver.2bpp"
endc
SECTION "Title Screen GFX", ROMX[$47CF], BANK[$04]
-TitleScreenGFX::
if def(GOLD)
-INCBIN "gfx/title/title_gold.2bpp"
+TitleScreenGFX:: INCBIN "gfx/title/title.2bpp"
+TitleScreenVersionGFX:: INCBIN "gfx/title/title_gold_version.2bpp"
+TitleScreenHoOhGFX:: INCBIN "gfx/title/title_hooh.2bpp"
+TitleScreenLogoGFX:: INCBIN "gfx/title/title_logo.2bpp"
+TitleScreenGoldLogoGFX:: INCBIN "gfx/title/title_goldlogo.2bpp"
else
-INCBIN "gfx/title/title_silver.2bpp"
+TitleScreenGFX:: INCBIN "gfx/title/title.2bpp"
+TitleScreenVersionGFX:: INCBIN "gfx/title/title_silver_version.2bpp"
+TitleScreenHoOhGFX:: INCBIN "gfx/title/title_hooh.2bpp"
+TitleScreenLogoGFX:: INCBIN "gfx/title/title_logo.2bpp"
+TitleScreenGoldLogoGFX:: INCBIN "gfx/title/title_silverlogo.2bpp"
endc
SECTION "Mail Icon GFX", ROMX[$5BB1], BANK[$04]
@@ -58,7 +63,7 @@ TrainerCardGFX:: INCBIN "gfx/trainer_card/trainer_card.2bpp"
TrainerCardColonGFX:: INCBIN "gfx/trainer_card/colon.2bpp" ; 0x013381--0x013391
TrainerCardIDNoGFX:: INCBIN "gfx/trainer_card/id_no.2bpp" ; 0x013391--0x0133B1
TrainerCardIDNoGFXEnd::
-TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x013BA1
+TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x133BA1
if DEBUG || def(GOLD)
db $18, $00 ; leftover of previous graphics
else
diff --git a/gfx/title/title.png b/gfx/title/title.png
new file mode 100644
index 0000000..58a8274
--- /dev/null
+++ b/gfx/title/title.png
Binary files differ
diff --git a/gfx/title/title_gold_version.png b/gfx/title/title_gold_version.png
new file mode 100644
index 0000000..e55f741
--- /dev/null
+++ b/gfx/title/title_gold_version.png
Binary files differ
diff --git a/gfx/title/title_goldlogo.png b/gfx/title/title_goldlogo.png
new file mode 100644
index 0000000..cb6b12d
--- /dev/null
+++ b/gfx/title/title_goldlogo.png
Binary files differ
diff --git a/gfx/title/title_hooh.png b/gfx/title/title_hooh.png
new file mode 100644
index 0000000..c24e79b
--- /dev/null
+++ b/gfx/title/title_hooh.png
Binary files differ
diff --git a/gfx/title/title_logo.png b/gfx/title/title_logo.png
new file mode 100644
index 0000000..79a7184
--- /dev/null
+++ b/gfx/title/title_logo.png
Binary files differ
diff --git a/gfx/title/title_silver_version.png b/gfx/title/title_silver_version.png
new file mode 100644
index 0000000..2d6d8d0
--- /dev/null
+++ b/gfx/title/title_silver_version.png
Binary files differ
diff --git a/gfx/title/title_silverlogo.png b/gfx/title/title_silverlogo.png
new file mode 100644
index 0000000..ffeda09
--- /dev/null
+++ b/gfx/title/title_silverlogo.png
Binary files differ
diff --git a/gfx/title/titlebgdecoration.png b/gfx/title/titlebgdecoration.png
new file mode 100644
index 0000000..c57bdd4
--- /dev/null
+++ b/gfx/title/titlebgdecoration.png
Binary files differ
diff --git a/home/init.asm b/home/init.asm
index 98fa129..17971c7 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -52,7 +52,7 @@ Init: ; 052f
ld [rOBP1], a
ld [rTMA], a
ld [rTAC], a
- ld [wcc38], a ; Useless, since WRAM gets cleared right after
+ ld [wTitleSequenceOpeningType], a ; Useless, since WRAM gets cleared right after
ld a, 1 << rTAC_ON | rTAC_4096_HZ
ld [rTAC], a
ld a, 1 << rLCDC_ENABLE
diff --git a/home/map.asm b/home/map.asm
index 8ec34be..b8ddee5 100644
--- a/home/map.asm
+++ b/home/map.asm
@@ -26,6 +26,11 @@ RunMapScript:: ; 20ff
pop hl
ret
+; TODO: is this used?
+WriteIntod637:: ; 2117
+ push af
+ ; TODO: figure out what variables are concerned here
+
SECTION "ClearMapBuffer", ROM0[$2123]
ClearMapBuffer:: ; 00:2123
ld hl, wMapBuffer
@@ -33,3 +38,1857 @@ ClearMapBuffer:: ; 00:2123
ld a, 0
call ByteFill
ret
+
+SetUpMapBuffer:: ; 212f
+ call ClearMapBuffer
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(UnknownMapBufferPointers)
+ call Bankswitch
+ ld hl, UnknownMapBufferPointers
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapId]
+ ld c, a
+.search
+ ld a, [hli]
+ cp $FF
+ jr z, .done
+ cp b
+ jr nz, .next_with_id
+ ld a, [hli]
+ cp c
+ jr nz, .next_without_id
+
+ ; Match found!
+ ld de, wMapScriptNumberLocation
+ call GetMapScriptNumber ; Read map script from pointed location
+ call CopyWord ; Copy map script pointer
+ ld de, wUnknownMapPointer
+ call CopyWord
+
+.done
+ pop af
+ call Bankswitch
+ ret
+
+.next_with_id
+ ld de, 7
+ add hl, de
+ jr .search
+
+.next_without_id
+ ld de, 6
+ add hl, de
+ jr .search
+
+GetMapScriptNumber:: ; 2171
+ push hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [hl]
+ ld [wMapScriptNumber], a
+ pop hl
+ ret
+
+CopyWord:: ; 217b
+ ld a, [hli]
+ ld [de], a
+ ld a, [hli]
+ inc de
+ ld [de], a
+ ret
+
+
+SetMapScriptNumber:: ; 2181
+ ld [wMapScriptNumber], a
+ ret
+
+IncMapScriptNumber:: ; 2185
+ ld hl, wMapScriptNumber
+ inc [hl]
+ ret
+
+DecMapScriptNumber:: ; 218a
+ ld hl, wMapScriptNumber
+ dec [hl]
+ ret
+
+WriteBackMapScriptNumber:: ; 218f
+ ld a, [wMapScriptNumberLocation]
+ ld l, a
+ ld a, [wMapScriptNumberLocation + 1]
+ ld h, a
+ ld a, [wMapScriptNumber]
+ ld [hl], a
+ ret
+
+
+GetMapPointer:: ; 219c
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapId]
+ ld c, a
+GetAnyMapPointer:: ; 21a4
+ push bc
+ dec b
+ ld c, b
+ ld b, 0
+ ld hl, MapGroupPointers
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop bc
+ dec c
+ ld b, 0
+ ld a, 8
+ call AddNTimes
+ ret
+
+
+SwitchToMapBank:: ; 21bb
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapId]
+ ld c, a
+SwitchToAnyMapBank:: ; 21c3
+ push hl
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ call GetAnyMapPointer
+ ld a, [hl]
+ call Bankswitch
+ pop hl
+ ret
+
+
+CopyMapPartial:: ; 213d
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ call GetMapPointer
+ ld de, wMapPartial
+ ld bc, wMapPartialEnd - wMapPartial
+ call CopyBytes
+ pop af
+ call Bankswitch
+ ret
+
+GetMapAttributesPointer:: ; 21eb
+ push bc
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapId]
+ ld c, a
+ call GetAnyMapPointer
+ ld bc, 3 ; TODO: constantify this
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop af
+ call Bankswitch
+ pop bc
+ ret
+
+GetMapEnvironment:: ; 220c
+ push hl
+ push bc
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ call GetMapPointer
+ ld bc, 2 ; TODO: constantify this
+ add hl, bc
+ ld b, [hl]
+ pop af
+ call Bankswitch
+ ld a, b
+ pop bc
+ pop hl
+ ret
+
+GetAnyMapEnvironment:: ; 2226
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ call GetAnyMapPointer
+ ld bc, 2 ; TODO: constantify this
+ add hl, bc
+ ld b, [hl]
+ pop af
+ call Bankswitch
+ ld a, b
+ ret
+
+GetWorldMapLocation:: ; 223c
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ call Bankswitch
+ call GetAnyMapPointer
+ ld bc, 5 ; TODO: constantify this
+ add hl, bc
+ ld b, [hl]
+ pop af
+ call Bankswitch
+ ld a, b
+ ret
+
+
+EmptyFunction2252:: ; 2252
+ ret
+
+
+LoadMap:: ; 2253
+ ldh a, [hMapEntryMethod]
+ and a ; Possible bug: if the entry method is $X0, this will overflow
+ ret z
+ and $0F
+ dec a
+ ld hl, .jumptable
+ call CallJumptable
+ xor a
+ ldh [hMapEntryMethod], a
+ scf
+ ret
+
+.jumptable
+ dw MapSetup_Continue
+ dw MapSetup_22af ; TODO
+ dw MapSetup_Reload
+ dw MapSetup_22de ; TODO
+ dw MapSetup_22de ; TODO
+ dw MapSetup_Warp
+ dw MapSetup_Connection
+ dw MapSetup_2275 ; TODO
+
+
+MapSetup_2275:: ; 2275
+ ldh a, [hROMBank]
+ push af
+ call MapSetup_22af ; TODO
+ pop af
+ call Bankswitch
+ ret
+
+MapSetup_Reload:: ; 2280
+ call DisableLCD
+ call DisableAudio
+ call VolumeOff
+ call SwitchToMapBank
+ call LoadGraphics
+ call ChangeMap
+ call SaveScreen
+ call LoadMapTimeOfDay
+ call EnableLCD
+ call PlayMapMusic
+ ld a, $88 ; TODO: constantify this
+ ld [wMusicFade], a
+ ld b, 9 ; TODO: constantify this
+ call GetSGBLayout
+ call LoadWildMons
+ call FadeIn
+ ret
+
+MapSetup_22af:: ; 22af
+ call DisableLCD
+ call DisableAudio
+ call VolumeOff
+ call SwitchToMapBank
+ call SetUpMapBuffer
+ call InitUnknownBuffercc9e
+ call LoadGraphics
+ call ChangeMap
+ call LoadMapTimeOfDay
+ call EnableLCD
+ call PlayMapMusic
+ ld a, $88 ; TODO: constantify this
+ ld [wMusicFade], a
+ ld b, 9 ; TODO: constantify this
+ call GetSGBLayout
+ call FadeIn
+ ret
+
+MapSetup_22de:: ; 22de
+ callab OverworldFadeOut
+
+MapSetup_Continue:: ; 22e6
+ call DisableLCD
+ call DisableAudio
+ call VolumeOff
+ callab DebugWarp
+ call CopyMapPartialAndAttributes
+ call SetUpMapBuffer
+ call InitUnknownBuffercc9e
+ call RefreshPlayerCoords
+ call GetCoordOfUpperLeftCorner
+ call LoadGraphics
+ call ChangeMap
+ call LoadMapTimeOfDay
+ call InitializeVisibleSprites
+ call EnableLCD
+ call PlayMapMusic
+ ld a, $88 ; TODO: constantify this
+ ld [wMusicFade], a
+ ld b, 9 ; TODO: constantify this
+ call GetSGBLayout
+ call LoadWildMons
+ call $242C ; TODO
+ call FadeIn
+ ret
+
+MapSetup_Warp:: ; 232c
+ callab OverworldFadeOut
+ call DisableLCD
+ call Function27C7 ; TODO
+ ld a, [wNextWarp]
+ ld [wWarpNumber], a
+ ld a, [wNextMapGroup]
+ ld [wMapGroup], a
+ ld a, [wNextMapId]
+ ld [wMapId], a
+ call CopyMapPartialAndAttributes
+ call SetUpMapBuffer
+ call InitUnknownBuffercc9e
+ call RestoreFacingAfterWarp
+ call RefreshPlayerCoords
+ call LoadGraphics
+ call ChangeMap
+ call LoadMapTimeOfDay
+ call InitializeVisibleSprites
+ call EnableLCD
+ call PlayMapMusic
+ ld b, 9 ; TODO: constantify this
+ call GetSGBLayout
+ call LoadWildMons
+ call FadeIn
+ call Function2407 ; TODO
+ ret
+
+LoadMapTimeOfDay:: ; 237c
+ callab ReplaceTimeOfDayPals
+ call LoadMapPart
+ call .ClearBGMap
+ call .PushAttrMap
+ ret
+
+.ClearBGMap ; 238e
+ ld a, HIGH(vBGMap0)
+ ld [wBGMapAnchor + 1], a
+ xor a ; LOW(vBGMap0)
+ ld [wBGMapAnchor], a
+ ldh [hSCY], a
+ ldh [hSCX], a
+
+ ld a, "■"
+ ld bc, vBGMap1 - vBGMap0
+ hlbgcoord 0, 0
+ call ByteFill
+ ret
+
+.PushAttrMap ; 23a7
+ decoord 0, 0
+ hlbgcoord 0, 0
+ ld c, SCREEN_WIDTH
+ ld b, SCREEN_HEIGHT
+.row
+ push bc
+.column
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .column
+ ld bc, BG_MAP_WIDTH - SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .row
+ ret
+
+LoadWildMons:: ; 23c1
+ callab _LoadWildMons
+ ret
+
+LoadGraphics:: ; 23ca
+ call LoadTileset
+ call LoadTilesetGFX
+ callba RefreshSprites
+ call LoadFontExtra
+ ret
+
+InitializeVisibleSprites:: ; 23dc
+ callab _InitializeVisibleSprites
+ ret
+
+FadeIn:: ; 23e5 ; This is not OverworldFadeIn, but I don't know what it is
+ call Function202c ; TODO
+ call RefreshTiles
+ ld hl, wVramState
+ set 0, [hl]
+ call Function2407
+ callab _UpdateSprites
+ call DelayFrame
+ callab OverworldFadeIn
+ ret
+
+Function2407:: ; 2407
+ ; TODO
+
+
+SECTION "Map stuff", ROM0[$2439]
+MapSetup_Connection:: ; 2439
+ call EnterMapConnection
+ call CopyMapPartialAndAttributes
+ call SetUpMapBuffer
+ call InitUnknownBuffercc9e
+ call RefreshPlayerCoords
+ call InitializeVisibleSprites
+ call ChangeMap
+ call SaveScreen
+ call FadeToMapMusic
+ ld b, 9 ; TODO: constantify this
+ call GetSGBLayout
+ call LoadWildMons
+ scf
+ ret
+
+CheckMovingOffEdgeOfMap:: ; 245e
+ ld a, [wPlayerStepDirection]
+ cp STANDING
+ ret z
+ and a ; DOWN
+ jr z, .down
+ cp UP
+ jr z, .up
+ cp LEFT
+ jr z, .left
+ cp RIGHT
+ jr z, .right
+ and a
+ ret
+
+.down
+ ld a, [wPlayerStandingMapY]
+ sub 4
+ ld b, a
+ ld a, [wMapHeight]
+ add a
+ cp b
+ jr z, .ok
+ and a
+ ret
+
+.up
+ ld a, [wPlayerStandingMapY]
+ sub 4
+ cp -1
+ jr z, .ok
+ and a
+ ret
+
+.left
+ ld a, [wPlayerStandingMapX]
+ sub 4
+ cp -1
+ jr z, .ok
+ and a
+ ret
+
+.right
+ ld a, [wPlayerStandingMapX]
+ sub 4
+ ld b, a
+ ld a, [wMapWidth]
+ add a
+ cp b
+ jr z, .ok
+ and a
+ ret
+
+.ok
+ ld a, MAPSETUP_CONNECTION
+ ldh [hMapEntryMethod], a
+ scf
+ ret
+
+EnterMapConnection: ; 24af
+; Return carry if a connection has been entered.
+ ld a, [wPlayerStepDirection]
+ and a
+ jp z, .south
+ cp UP
+ jp z, .north
+ cp LEFT
+ jp z, .west
+ cp RIGHT
+ jp z, .east
+ ret
+
+.west
+ ld a, [wWestConnectedMapGroup]
+ ld [wMapGroup], a
+ ld a, [wWestConnectedMapNumber]
+ ld [wMapId], a
+ ld a, [wWestConnectionStripXOffset]
+ ld [wXCoord], a
+ ld a, [wWestConnectionStripYOffset]
+ ld hl, wYCoord
+ add [hl]
+ ld [hl], a
+ ld c, a
+ ld hl, wWestConnectionWindow
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ srl c
+ jr z, .skip_to_load
+ ld a, [wWestConnectedMapWidth]
+ add 6
+ ld e, a
+ ld d, 0
+
+.loop
+ add hl, de
+ dec c
+ jr nz, .loop
+
+.skip_to_load
+ ld a, l
+ ld [wOverworldMapAnchor], a
+ ld a, h
+ ld [wOverworldMapAnchor + 1], a
+ jp .done
+
+.east
+ ld a, [wEastConnectedMapGroup]
+ ld [wMapGroup], a
+ ld a, [wEastConnectedMapNumber]
+ ld [wMapId], a
+ ld a, [wEastConnectionStripXOffset]
+ ld [wXCoord], a
+ ld a, [wEastConnectionStripYOffset]
+ ld hl, wYCoord
+ add [hl]
+ ld [hl], a
+ ld c, a
+ ld hl, wEastConnectionWindow
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ srl c
+ jr z, .skip_to_load2
+ ld a, [wEastConnectedMapWidth]
+ add 6
+ ld e, a
+ ld d, 0
+
+.loop2
+ add hl, de
+ dec c
+ jr nz, .loop2
+
+.skip_to_load2
+ ld a, l
+ ld [wOverworldMapAnchor], a
+ ld a, h
+ ld [wOverworldMapAnchor + 1], a
+ jp .done
+
+.north
+ ld a, [wNorthConnectedMapGroup]
+ ld [wMapGroup], a
+ ld a, [wNorthConnectedMapNumber]
+ ld [wMapId], a
+ ld a, [wNorthConnectionStripYOffset]
+ ld [wYCoord], a
+ ld a, [wNorthConnectionStripXOffset]
+ ld hl, wXCoord
+ add [hl]
+ ld [hl], a
+ ld c, a
+ ld hl, wNorthConnectionWindow
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld b, 0
+ srl c
+ add hl, bc
+ ld a, l
+ ld [wOverworldMapAnchor], a
+ ld a, h
+ ld [wOverworldMapAnchor + 1], a
+ jp .done
+
+.south
+ ld a, [wSouthConnectedMapGroup]
+ ld [wMapGroup], a
+ ld a, [wSouthConnectedMapNumber]
+ ld [wMapId], a
+ ld a, [wSouthConnectionStripYOffset]
+ ld [wYCoord], a
+ ld a, [wSouthConnectionStripXOffset]
+ ld hl, wXCoord
+ add [hl]
+ ld [hl], a
+ ld c, a
+ ld hl, wSouthConnectionWindow
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld b, 0
+ srl c
+ add hl, bc
+ ld a, l
+ ld [wOverworldMapAnchor], a
+ ld a, h
+ ld [wOverworldMapAnchor + 1], a
+.done
+ scf
+ ret
+
+
+WarpCheck:: ; 259f
+ call GetDestinationWarpPointer
+ ret nc
+ ld a, [hli]
+ ld [wNextWarp], a
+ ld a, [hli]
+ ld [wNextMapGroup], a
+ ld a, [hli]
+ ld [wNextMapId], a
+ ld a, c
+ ld [wPrevWarp], a
+ ld a, MAPSETUP_WARP
+ ldh [hMapEntryMethod], a
+ scf
+ ret
+
+GetDestinationWarpPointer: ; 25b9
+ ld a, [wPlayerStandingMapY]
+ sub 4
+ ld d, a
+ ld a, [wPlayerStandingMapX]
+ sub 4
+ ld e, a
+ ld a, [wCurrMapWarpCount]
+ ld c, a
+ and a
+ ret z
+
+ ld hl, wCurrMapWarps
+.next
+ ld a, [hli]
+ cp d
+ jr nz, .nope
+ ld a, [hl]
+ cp e
+ jr z, .found_warp
+.nope
+ push de
+ ld de, 4 ; TODO: constantify this
+ add hl, de
+ pop de
+ dec c
+ jr nz, .next
+ xor a
+ ret
+
+.found_warp
+ ld a, [wCurrMapWarpCount]
+ inc a
+ sub c
+ ld c, a
+ inc hl
+ scf
+ ret
+
+
+CopyMapPartialAndAttributes:: ; 25ea
+ call SwitchToMapBank
+ call CopyAndReadHeaders
+ call ReadObjectEvents
+ ret
+
+CopyAndReadHeaders:: ; 25f4
+ call CopyMapPartial
+ call GetMapAttributesPointer
+ ld hl, wMapAttributesPtr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wMapAttributes
+ ld c, wMapAttributesEnd - wMapAttributes
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .copy
+ call GetMapConnections
+ ld hl, wMapObjectsPtr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ inc hl
+ inc hl
+ call ReadWarps
+ call ReadSigns
+ ret
+
+GetMapConnections:: ; 261d
+ ld a, $ff
+ ld [wNorthConnectedMapGroup], a
+ ld [wSouthConnectedMapGroup], a
+ ld [wWestConnectedMapGroup], a
+ ld [wEastConnectedMapGroup], a
+
+ ld a, [wMapConnections]
+ ld b, a
+ bit 3, b
+ jr z, .no_north
+ ld de, wNorthMapConnection
+ call GetMapConnection
+.no_north
+
+ bit 2, b
+ jr z, .no_south
+ ld de, wSouthMapConnection
+ call GetMapConnection
+.no_south
+
+ bit 1, b
+ jr z, .no_west
+ ld de, wWestMapConnection
+ call GetMapConnection
+.no_west
+
+ bit 0, b
+ jr z, .no_east
+ ld de, wEastMapConnection
+ call GetMapConnection
+.no_east
+
+ ret
+
+GetMapConnection:: ; 2658
+ ld c, wSouthMapConnection - wNorthMapConnection
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .copy
+ ret
+
+
+ReadWarps:: ; 2661
+ ld a, [hli]
+ ld [wCurrMapWarpCount], a
+ and a
+ ret z
+ ld c, a
+ ld de, wCurrMapWarps
+.next
+ ld b, 5 ; TODO: constantify this
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .copy
+ inc hl
+ inc hl
+ dec c
+ jr nz, .next
+ ret
+
+
+ReadSigns:: ; 2679
+ ld a, [hli]
+ ld [wCurrMapSignCount], a
+ and a
+ ret z
+ ld c, a
+ ld de, wCurrMapSigns
+.next
+ ld b, 4
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .copy
+ dec c
+ jr nz, .next
+ ret
+
+
+ReadObjectEvents:: ; 268f
+ push hl
+ call ClearObjectStructs
+ pop de
+ ld hl, wMap2Object
+ ld a, [de]
+ inc de
+ ld [wCurrMapObjectCount], a
+ and a
+ jr z, .skip
+
+ ld c, a
+.next
+ push bc
+ push hl
+ ld a, $ff
+ ld [hli], a
+ ld b, wMap2ObjectUnused - wMap2ObjectSprite
+.copy
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec b
+ jr nz, .copy
+ pop hl
+ ld bc, wMap3Object - wMap2Object
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .next
+
+.skip
+ ld a, [wCurrMapObjectCount]
+ ld c, a
+ ld a, 16 ; 16 objects -- but this causes an overflow, since we only start from object 2
+ sub c
+ jr z, .finish
+ ld bc, 1
+ add hl, bc ; Very thorough optimization. Don't do this at home, kids.
+ ld bc, wMap3Object - wMap2Object
+.clear
+ ld [hl], 0
+ add hl, bc
+ dec a
+ jr nz, .clear
+
+.finish
+ ld h, d
+ ld l, e
+ ret
+
+ClearObjectStructs:: ; 26cf
+ xor a
+ ld [wUnkObjectStruct], a ; TODO
+ ld hl, wObject2Struct
+ ld de, wObject2Struct - wObject1Struct
+ ld c, 7
+.clear_struct
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .clear_struct
+
+ ld hl, $D00F ; TODO
+ ld de, 16
+ ld c, 4
+ xor a
+.clear_unk ; TODO
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .clear_unk
+ ret
+
+
+ReadWord:: ; 26ef ; TODO: is this used?
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ ret
+
+
+InitUnknownBuffercc9e:: ; 26f4
+ xor a
+ ld hl, wUnknownWordcc9c
+ ld [hli], a
+ ld [hli], a
+ ld hl, wUnknownBuffercc9e ; useless
+ ld bc, 14 ; TODO: constantify this
+ ld a, $ff
+ call ByteFill
+ ld hl, wUnknownMapPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld a, e
+ or d
+ jr z, .null
+
+ ld a, [wMapBuffer]
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ add hl, de
+ inc hl
+ inc hl
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ ld de, wUnknownBuffercc9e - 2
+.next
+ ld a, [bc]
+ inc bc
+ cp $ff ; Could have used one of the `inc a` below
+ jr z, .done
+ inc a
+ inc a
+ and $0f
+ ld l, a
+ ld h, 0
+ add hl, de
+ ld [hl], 0
+ jr .next
+
+.null
+ ld hl, wUnknownBuffercc9e
+ ld bc, 14 ; TODO: constantify this
+ xor a
+ call ByteFill
+.done
+ ret
+
+
+RestoreFacingAfterWarp:: ; 273d
+ ld hl, wMapObjectsPtr
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ; Point to 1st warp
+ inc hl
+ inc hl
+ inc hl
+ ld a, [wWarpNumber]
+ dec a
+ ld c, a
+ ld b, 0
+ ld a, 7 ; Size of warp ; TODO: constantify this
+ call AddNTimes
+ ld a, [hli]
+ ld [wYCoord], a
+ ld a, [hli]
+ ld [wXCoord], a
+ call GetCoordOfUpperLeftCorner
+ ret
+
+
+Function275e:: ; 275e ; TODO: is this used?
+ inc hl
+ inc hl
+ inc hl
+ ld a, [hli]
+ ld [wOverworldMapAnchor], a
+ ld a, [hl]
+ ld [wOverworldMapAnchor + 1], a
+ ld a, [wYCoord]
+ and 1
+ ld [wMetatileStandingY], a
+ ld a, [wXCoord]
+ and 1
+ ld [wMetatileStandingX], a
+ ret
+
+
+GetCoordOfUpperLeftCorner:: ; 277a
+ ld hl, wOverworldMap
+ ld a, [wXCoord]
+ bit 0, a
+ jr nz, .increment_then_halve1
+ srl a
+ add a, 1
+ jr .resume
+
+.increment_then_halve1
+ add a, 1
+ srl a
+
+.resume
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [wMapWidth]
+ add a, 6
+ ld c, a
+ ld b, 0
+ ld a, [wYCoord]
+ bit 0, a
+ jr nz, .increment_then_halve2
+ srl a
+ add a, 1
+ jr .resume2
+
+.increment_then_halve2
+ add a, 1
+ srl a
+
+.resume2
+ call AddNTimes
+ ld a, l
+ ld [wOverworldMapAnchor], a
+ ld a, h
+ ld [wOverworldMapAnchor + 1], a
+ ld a, [wYCoord]
+ and 1
+ ld [wMetatileStandingY], a
+ ld a, [wXCoord]
+ and 1
+ ld [wMetatileStandingX], a
+ ret
+
+Function27C7:: ; 27c7 ; TODO
+ call GetMapEnvironment
+ cp 2
+ jr z, .interior
+ cp 1
+ jr z, .interior
+ ret
+.interior
+ ld a, [wNextMapGroup]
+ ld b, a
+ ld a, [wNextMapId]
+ ld c, a
+ call GetAnyMapEnvironment
+ cp 3
+ jr z, .exterior
+ cp 4
+ jr z, .exterior
+ cp 6
+ jr z, .exterior
+ ret
+
+.exterior
+ ld hl, $D4B2 ; TODO: figure out what this is
+ ld a, [wPrevWarp]
+ ld [hli], a
+ ld a, [wMapGroup]
+ ld [hli], a
+ ld a, [wMapId]
+ ld [hli], a
+ ret
+
+LoadMapPart:: ; 27fb
+ callab UpdateTimeOfDayPal
+
+ ldh a, [hROMBank]
+ push af
+ ld a, [wTilesetBank]
+ call Bankswitch
+
+ call LoadMetatiles
+ ld a, "■"
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ call ByteFill
+
+ call ApplyFlashlight
+
+ pop af
+ call Bankswitch
+ ret
+
+LoadMetatiles:: ; 2822
+ ld a, [wOverworldMapAnchor]
+ ld e, a
+ ld a, [wOverworldMapAnchor + 1]
+ ld d, a
+ ld hl, wTileMapBackup
+ ld b, 5 ; TODO: constantify this
+.row
+ push de
+ push hl
+ ld c, 6 ; TODO: constantify this
+.tile
+ push bc
+ push de
+ push hl
+ ld a, [de]
+ ld c, a
+ call DrawMetatile
+ pop hl
+ ld bc, 4
+ add hl, bc
+ pop de
+ inc de
+ pop bc
+ dec c
+ jr nz, .tile
+ pop hl
+ ld de, BG_MAP_WIDTH * 3
+ add hl, de
+ pop de
+ ld a, [wMapWidth]
+ add a, 6
+ add a, e
+ ld e, a
+ jr nc, .nocarry
+ inc d
+.nocarry
+ dec b
+ jr nz, .row
+ ret
+
+ApplyFlashlight:: ; 285a
+ ld hl, wTileMapBackup
+ ld a, [wMetatileStandingY]
+ and a
+ jr z, .top_row
+ ld bc, $30 ; TODO: constantify this
+ add hl, bc
+.top_row
+ ld a, [wMetatileStandingX]
+ and a
+ jr z, .left_col
+ inc hl
+ inc hl
+.left_col
+
+ ldh a, [hOverworldFlashlightEffect]
+ and a
+ jr z, .no_flashlight
+ cp 1
+ jr z, .force_1
+ cp 2
+ jr z, .force_2
+ cp 3
+ jr z, .force_3
+ jp .force_9001
+
+.no_flashlight
+ ld de, wTileMap
+ ld b, SCREEN_HEIGHT ; TODO: constantify this
+.row
+ ld c, SCREEN_WIDTH
+.tile
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .tile
+
+ ld a, l
+ add a, 4
+ ld l, a
+ jr nc, .nocarry
+ inc h
+.nocarry
+ dec b
+ jr nz, .row
+ ret
+
+; redraw_with_flashlight force
+; force = 1, 2 or 3
+; 0 and 4 have special handling, see above and below
+redraw_with_flashlight: MACRO
+ decoord \1 * 2, \1 * 2
+ ld bc, \1 * $32 ; TODO: constantify the $32
+ add hl, bc
+ ld c, SCREEN_HEIGHT - \1 * 4
+.row\1
+ ld b, SCREEN_HEIGHT - \1 * 4
+.tile\1
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .tile\1
+ ld a, l
+ add a, 6 + \1 * 4
+ ld l, a
+ jr nc, .nohlcarry\1
+ inc h
+.nohlcarry\1
+ ld a, e
+ add a, 2 + \1 * 4
+ ld e, a
+ jr nc, .nodecarry\1
+ inc d
+.nodecarry\1
+ dec c
+ jr nz, .row\1
+ENDM
+
+.force_1 ; 289b
+ redraw_with_flashlight 1
+ ret
+
+.force_2 ; 28be
+ redraw_with_flashlight 2
+ ret
+
+.force_3 ; 28e1
+ redraw_with_flashlight 3
+ ret
+
+.force_9001 ; 2904
+ ; Actually force 4, but this also applies to larger values
+ decoord 4 * 2, 4 * 2
+ ld bc, 4 * $32 ; TODO: constantify the $32
+ add hl, bc
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ ld bc, 6 + 4 * 4
+ add hl, bc
+ ld a, e
+ add a, 2 + 4 * 4 + 1 ; Compensate missing `inc de`
+ ld e, a
+ jr nc, .nocarry9001
+ inc d
+.nocarry9001
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ ret
+
+DrawMetatile:: ; 2921
+ push hl
+ ld hl, wTilesetBlocksAddress
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ swap c
+ ld a, c
+ and $0f
+ ld b, a
+ ld a, c
+ and $f0
+ ld c, a
+ add hl, bc
+ pop de
+ lb bc, $14, 4 ; TODO: constantify $14
+.row
+REPT 4
+ ld a, [hli]
+ ld [de], a
+ inc de
+ENDR
+ ld a, e
+ add a, b
+ ld e, a
+ jr nc, .nocarry
+ inc d
+.nocarry
+ dec c
+ jr nz, .row
+ ret
+
+
+ChangeMap:: ; 294d
+ ld hl, wOverworldMap
+ ld bc, wOverworldMapEnd - wOverworldMap
+ ld a, 0
+ call ByteFill
+
+ ld hl, wOverworldMap
+ ld a, [wMapWidth]
+ ldh [hConnectedMapWidth], a
+ add a, 6
+ ldh [hConnectionStripLength], a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld c, 3
+ add hl, bc
+
+ ld a, [wMapBlocksPointer]
+ ld e, a
+ ld a, [wMapBlocksPointer + 1]
+ ld d, a
+ ld a, [wMapHeight]
+ ld b, a
+.row
+ push hl
+ ldh a, [hConnectedMapWidth]
+ ld c, a
+.col
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .col
+ pop hl
+ ldh a, [hConnectionStripLength]
+ add l
+ ld l, a
+ jr nc, .okay
+ inc h
+.okay
+ dec b
+ jr nz, .row
+
+; FillMapConnections:: ; 298e
+
+ ld a, [wNorthConnectedMapGroup]
+ cp $ff
+ jr z, .south
+ ld b, a
+ ld a, [wNorthConnectedMapNumber]
+ ld c, a
+ call SwitchToAnyMapBank
+
+ ld a, [wNorthConnectionStripPointer]
+ ld l, a
+ ld a, [wNorthConnectionStripPointer + 1]
+ ld h, a
+ ld a, [wNorthConnectionStripLocation]
+ ld e, a
+ ld a, [wNorthConnectionStripLocation + 1]
+ ld d, a
+ ld a, [wNorthConnectionStripLength]
+ ldh [hConnectionStripLength], a
+ ld a, [wNorthConnectedMapWidth]
+ ldh [hConnectedMapWidth], a
+ call FillNorthConnectionStrip
+
+.south
+ ld a, [wSouthConnectedMapGroup]
+ cp $ff
+ jr z, .west
+ ld b, a
+ ld a, [wSouthConnectedMapNumber]
+ ld c, a
+ call SwitchToAnyMapBank
+
+ ld a, [wSouthConnectionStripPointer]
+ ld l, a
+ ld a, [wSouthConnectionStripPointer + 1]
+ ld h, a
+ ld a, [wSouthConnectionStripLocation]
+ ld e, a
+ ld a, [wSouthConnectionStripLocation + 1]
+ ld d, a
+ ld a, [wSouthConnectionStripLength]
+ ldh [hConnectionStripLength], a
+ ld a, [wSouthConnectedMapWidth]
+ ldh [hConnectedMapWidth], a
+ call FillSouthConnectionStrip
+
+.west
+ ld a, [wWestConnectedMapGroup]
+ cp $ff
+ jr z, .east
+ ld b, a
+ ld a, [wWestConnectedMapNumber]
+ ld c, a
+ call SwitchToAnyMapBank
+
+ ld a, [wWestConnectionStripPointer]
+ ld l, a
+ ld a, [wWestConnectionStripPointer + 1]
+ ld h, a
+ ld a, [wWestConnectionStripLocation]
+ ld e, a
+ ld a, [wWestConnectionStripLocation + 1]
+ ld d, a
+ ld a, [wWestConnectionStripLength]
+ ld b, a
+ ld a, [wWestConnectedMapWidth]
+ ldh [hConnectionStripLength], a
+ call FillWestConnectionStrip
+
+.east
+ ld a, [wEastConnectedMapGroup]
+ cp $ff
+ jr z, .done
+ ld b, a
+ ld a, [wEastConnectedMapNumber]
+ ld c, a
+ call SwitchToAnyMapBank
+
+ ld a, [wEastConnectionStripPointer]
+ ld l, a
+ ld a, [wEastConnectionStripPointer + 1]
+ ld h, a
+ ld a, [wEastConnectionStripLocation]
+ ld e, a
+ ld a, [wEastConnectionStripLocation + 1]
+ ld d, a
+ ld a, [wEastConnectionStripLength]
+ ld b, a
+ ld a, [wEastConnectedMapWidth]
+ ldh [hConnectionStripLength], a
+ call FillEastConnectionStrip
+
+.done
+ ret
+
+FillNorthConnectionStrip::
+FillSouthConnectionStrip:: ; 2a3d
+
+ ld c, 3
+.y
+ push de
+
+ push hl
+ ldh a, [hConnectionStripLength]
+ ld b, a
+.x
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .x
+ pop hl
+
+ ldh a, [hConnectedMapWidth]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop de
+
+ ld a, [wMapWidth]
+ add a, 6
+ add e
+ ld e, a
+ jr nc, .okay
+ inc d
+.okay
+ dec c
+ jr nz, .y
+ ret
+; 25f6
+
+FillWestConnectionStrip::
+FillEastConnectionStrip:: ; 2a60
+
+.loop
+ ld a, [wMapWidth]
+ add a, 6
+ ldh [hConnectedMapWidth], a
+
+ push de
+
+ push hl
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ pop hl
+
+ ldh a, [hConnectionStripLength]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop de
+
+ ldh a, [hConnectedMapWidth]
+ add e
+ ld e, a
+ jr nc, .okay
+ inc d
+.okay
+ dec b
+ jr nz, .loop
+ ret
+
+
+SECTION "LoadTilesetGFX", ROM0[$2D26]
+LoadTilesetGFX:: ; 2d26
+ call GetMapEnvironment
+ cp 1 ; TODO: constantify this
+ jr z, .exterior
+ cp 2 ; TODO: constantify this
+ jr z, .exterior
+ ld a, [wMapTileset]
+ cp $1B ; TODO: constantify this
+ jr z, .exterior
+
+ ld a, [wTilesetTilesAddress]
+ ld e, a
+ ld a, [wTilesetTilesAddress + 1]
+ ld d, a
+ ld hl, vTileset
+ ld a, [wTilesetBank]
+ ld b, a
+ ld c, $60
+ call Get2bpp
+ xor a
+ ldh [hTileAnimFrame], a
+ ret
+
+.exterior
+ ld de, CommonExteriorTiles ; TODO: maybe find a better name
+ ld hl, vTileset
+ lb bc, BANK(CommonExteriorTiles), $20
+ call Get2bpp
+
+ ld a, [wTilesetTilesAddress]
+ ld e, a
+ ld a, [wTilesetTilesAddress + 1]
+ ld d, a
+ ld hl, vExteriorTileset
+ ld a, [wTilesetBank]
+ ld b, a
+ ld c, $40
+ call Get2bpp
+ xor a
+ ldh [hTileAnimFrame], a
+ ret
+
+
+RefreshPlayerCoords:: ; 2d74
+ ld a, [wXCoord]
+ add a, 4
+ ld d, a
+ ld hl, wPlayerStandingMapX
+ sub [hl]
+ ld [hl], d
+ ld hl, wPlayerObjectXCoord
+ ld [hl], d
+ ld hl, wPlayerLastMapX
+ ld [hl], d
+ ld d, a
+ ld a, [wYCoord]
+ add a, 4
+ ld e, a
+ ld hl, wPlayerStandingMapY
+ sub [hl]
+ ld [hl], e
+ ld hl, wPlayerObjectYCoord
+ ld [hl], e
+ ld hl, wPlayerLastMapY
+ ld [hl], e
+ ld e, a
+
+ ld a, [wObjectFollow_Leader]
+ cp 1
+ ret nz
+ ld a, [wObjectFollow_Follower]
+ and a
+ ret z
+
+ ; This piece of code has been removed in pokegold (note that the conditions above were altered, as well)
+ call GetObjectStruct
+ ld hl, 16 ; TODO: constantify this
+ add hl, bc
+ ld a, [hl]
+ add a, d
+ ld [hl], a
+ ld [wMap1ObjectXCoord], a
+ ld hl, 18 ; TODO: constantify this
+ add hl, bc
+ ld a, [hl]
+ add a, d
+ ld [hl], a
+ ld hl, 17 ; TODO: constantify this
+ add hl, bc
+ ld a, [hl]
+ add a, e
+ ld [hl], a
+ ld [wMap1ObjectYCoord], a
+ ld hl, 19
+ add hl, bc
+ ld a, [hl]
+ add a, e
+ ld [hl], a
+ ret
+
+
+BufferScreen:: ; 2dcd
+ ld hl, wOverworldMapAnchor
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wScreenSave
+ ld c, 5
+ ld b, 6
+.row
+ push bc
+ push hl
+.col
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .col
+ pop hl
+ ld a, [wMapWidth]
+ add a, 6
+ ld c, a
+ ld b, 0
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .row
+ ret
+
+SaveScreen:: ; 2df1
+ ld hl, wOverworldMapAnchor
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wScreenSave
+ ld a, [wMapWidth]
+ add 6
+ ldh [hMapObjectIndexBuffer], a
+ ld a, [wPlayerStepDirection]
+ and a
+ jr z, .down
+ cp UP
+ jr z, .up
+ cp LEFT
+ jr z, .left
+ cp RIGHT
+ jr z, .right
+ ret
+
+.up
+ ld de, wScreenSave + 6
+ ldh a, [hMapObjectIndexBuffer]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ jr .vertical
+
+.down
+ ld de, wScreenSave
+.vertical
+ ld b, 6
+ ld c, 4
+ jr .load_neighbor
+
+.left
+ ld de, wScreenSave + 1
+ inc hl
+ jr .horizontal
+
+.right
+ ld de, wScreenSave
+.horizontal
+ ld b, 5
+ ld c, 5
+
+.load_neighbor ; 2e35
+.row
+ push bc
+ push hl
+ push de
+.col
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec b
+ jr nz, .col
+ pop de
+ ld a, e
+ add a, 6
+ ld e, a
+ jr nc, .okay
+ inc d
+
+.okay
+ pop hl
+ ldh a, [hConnectionStripLength]
+ ld c, a
+ ld b, 0
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .row
+ ret
+
+
+RefreshTiles:: ; 2e52
+ call .left_right
+ call .up_down
+ ld a, [wPlayerStandingMapX]
+ ld d, a
+ ld a, [wPlayerStandingMapY]
+ ld e, a
+ call GetCoordTile
+ ld [wPlayerStandingTile], a
+ ret
+
+.up_down ; 2e67
+ ld a, [wPlayerStandingMapX]
+ ld d, a
+ ld a, [wPlayerStandingMapY]
+ ld e, a
+ push de
+ inc e
+ call GetCoordTile
+ ld [wTileDown], a
+ pop de
+ dec e
+ call GetCoordTile
+ ld [wTileUp], a
+ ret
+
+.left_right ; 2e80
+ ld a, [wPlayerStandingMapX]
+ ld d, a
+ ld a, [wPlayerStandingMapY]
+ ld e, a
+ push de
+ dec d
+ call GetCoordTile
+ ld [wTileLeft], a
+ pop de
+ inc d
+ call GetCoordTile
+ ld [wTileRight], a
+ ret
+
+
+GetFacingTileCoord:: ; 2e99
+ ld a, [wPlayerWalking] ; TODO: wPlayerDirection in Crystal. Not here?
+ and %1100
+ srl a
+ srl a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, .directions
+ add hl, de
+
+ ld d, [hl]
+ inc hl
+ ld e, [hl]
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld a, [wPlayerStandingMapX]
+ add a, d
+ ld d, a
+ ld a, [wPlayerStandingMapY]
+ add a, e
+ ld e, a
+ ld a, [hl]
+ ret
+
+.directions
+ db 0, 1
+ dw wTileDown
+
+ db 0, -1
+ dw wTileUp
+
+ db -1, 0
+ dw wTileLeft
+
+ db 1, 0
+ dw wTileRight
+
+GetCoordTile:: ; 2ece
+; Get the collision byte for tile d, e
+ call GetBlockLocation
+ ld a, [hl]
+ and a
+ jr z, .nope
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld a, [wTilesetCollisionAddress]
+ ld c, a
+ ld a, [wTilesetCollisionAddress + 1]
+ ld b, a
+ add hl, bc
+ rr d
+ jr nc, .nocarry
+ inc hl
+
+.nocarry
+ rr e
+ jr nc, .nocarry2
+ inc hl
+ inc hl
+
+.nocarry2
+ ld a, [wTilesetBank]
+ call GetFarByte
+ ret
+
+.nope
+ ld a, -1
+ ret
+
+GetBlockLocation:: ; 2ef8
+ ld a, [wMapWidth]
+ add a, 6
+ ld c, a
+ ld b, 0
+ ld hl, wOverworldMap + 1
+ add hl, bc
+ ld a, e
+ srl a
+ jr z, .nope
+ and a
+.loop
+ srl a
+ jr nc, .ok
+ add hl, bc
+
+.ok
+ sla c
+ rl b
+ and a
+ jr nz, .loop
+
+.nope
+ ld c, d
+ srl c
+ ld b, 0
+ add hl, bc
+ ret
+
+
+SECTION "LoadTileset", ROM0[$2F48]
+LoadTileset:: ; 2f48
+ push hl
+ push bc
+
+ ld hl, Tilesets
+ ld bc, wTilesetEnd - wTileset
+ ld a, [wMapTileset]
+ call AddNTimes
+
+ ld de, wTileset
+ ld bc, wTilesetEnd - wTileset
+
+ ld a, BANK(Tilesets)
+ call FarCopyBytes
+
+ ld a, 1
+ ldh [hMapAnims], a
+ xor a
+ ldh [hTileAnimFrame], a
+
+ pop bc
+ pop hl
+ ret
diff --git a/home/menu_window.asm b/home/menu_window.asm
index c4d3842..b5082ca 100644
--- a/home/menu_window.asm
+++ b/home/menu_window.asm
@@ -27,7 +27,7 @@ Function1c0a:: ; 00:1c0a
call CopyBytes
call CloseSRAM
- call OverworldTextModeSwitch
+ call LoadMapPart
xor a
call OpenSRAM
diff --git a/home/tilemap.asm b/home/tilemap.asm
index ca97f42..6d7ff38 100644
--- a/home/tilemap.asm
+++ b/home/tilemap.asm
@@ -15,7 +15,7 @@ Function360b::
call GetMemSGBLayout
jr WaitBGMap
-ClearBGPalettes::
+ClearBGPalettes:: ; 361e
call ClearPalettes
WaitBGMap:: ; 00:3621
; Tell VBlank to update BG Map
diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm
index 54aea4d..58c83fa 100644
--- a/home/unknown_388f.asm
+++ b/home/unknown_388f.asm
@@ -60,7 +60,7 @@ Function38e3::
and a
ret z
ld a, $3
- call Function2117
+ call WriteIntod637
call Function3240
ret
@@ -74,7 +74,7 @@ Function3904::
set 4, [hl]
set 6, [hl]
ld a, $b
- call Function2117
+ call WriteIntod637
ret
Function391f::
@@ -85,7 +85,7 @@ Function3910::
cp $1
jr z, .asm_392d
ld a, $4
- call Function2117
+ call WriteIntod637
ret
.asm_392d: ; 00:392d
diff --git a/macros/wram.asm b/macros/wram.asm
index 96cf5e8..da67ba5 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -309,6 +309,7 @@ map_object: MACRO
\1ObjectRange:: ds 1
\1ObjectScript:: ds 2
\1ObjectEventFlag:: ds 2
+\1ObjectUnused::
ds 2
endm
diff --git a/shim.sym b/shim.sym
index f1b9b5a..453fe55 100644
--- a/shim.sym
+++ b/shim.sym
@@ -1,10 +1,6 @@
; ROM0
00:1A7C Function1a7c
00:202C Function202c
-00:2117 Function2117
-00:23DC LoadWildMons
-00:23E5 FadeIn ; This is not OverworldFadeIn, but I don't know what it is
-00:27FB OverworldTextModeSwitch
00:2C05 StartMenuCheck
00:3111 Function3111
00:3171 Function3171
@@ -12,6 +8,7 @@
00:323E Function323e
00:3240 Function3240
00:39BA PlayCry
+00:3CA8 InitSpriteAnimStruct
00:3D86 WaitSFX
00:3D87 WaitSFX.wait
00:3DA5 MaxVolume
@@ -30,12 +27,13 @@
00:3E32 Unk_3E32
01:4031 Function4031
+01:4031 DebugMenu
01:40EB Function40eb
01:5007 Function5007
+01:5190 _UpdateSprites
01:5190 Function5190
01:53CC MainMenu
01:5D27 Function5d27
-01:6114 TitleScreenInputAndTimeout
01:63D8 ReanchorBGMap_NoOAMUpdate
01:6437 LoadFonts_NoOAMUpdate
01:6445 Function6445
@@ -56,11 +54,13 @@
02:4C7C DrawMap
02:4DC2 TownMapGfx
02:4F32 PokegearRadioGfx
+02:51D2 SetTitleBGDecorationBorder
02:528B Function928b
02:5695 CheckSGB
03:4791 DebugWarp
03:479F DebugWarp.Destinations
+03:488D Tilesets
03:4D33 Functioncd33
03:4D6F Functioncd6f
03:4DE3 Functioncde3
@@ -92,12 +92,13 @@
05:4000 Function14000
05:400A GetPlayerSprite
-05:4036 AddMapSprites
+05:4036 RefreshSprites
05:404C CheckInteriorMap
05:405B AddIndoorSprites
05:40AA AddOutdoorSprites
05:40D9 Function140d9
05:40FB LoadUsedSpritesGfx ; TODO: maybe there's a better name
+05:43B6 InitAllSRAMBanks
05:43E0 Function143e0
05:457A Function1457a
05:45B8 Function145b8
@@ -125,12 +126,14 @@
09:426A _InitScrollingMenu
09:4287 _ScrollingMenu
-0A:4C98 Function28c98
+0A:4C98 LinkTextboxAtHL
0A:4D6E Function28d6e
0A:4DA4 Function28da4
0B:5663 Function2d663
+0C:7C00 CommonExteriorTiles
+
0E:4B78 LoadTrainerClassName
0E:4BA0 LoadTrainerClassName.got_name
0E:4BA9 LoadTrainerClass
@@ -184,8 +187,10 @@
23:44BE Function8c4be
23:4940 Function8c940
23:49C6 Function8c9c6
+23:4CFD InitEffectObject
23:4D0C Function8cd0c
-23:60CC MenuMonIconGfx
+23:4d13 EffectObjectJumpNoDelay
+23:60cc MenuMonIconGfx
23:71CB Function_8f1cb
24:4000 SetClockDialog
@@ -435,7 +440,9 @@
36:73E8 MtFujiRoute_MapAttributes
36:7444 FontoRoute5_MapAttributes
36:7530 BullForestRoute3_MapAttributes
-
+38:4000 PikachuMiniGame
+39:4000 GameFreakIntro
+39:432F OpeningCutscene
3A:441D Functione841d
3A:45D8 Functione85d8
3A:47F9 Functione87f9
@@ -455,6 +462,7 @@
3F:6750 PicTestMenu
3F:6755 PicTestMenu.loop
+00:CB6F wPlayerStepDirection
00:CC22 wMenuData3
00:CE67 wPlayerName
@@ -464,7 +472,6 @@
01:D264 wPlayerBikeSurfState
; The starting house's map script number is stored at d29a. Others are probably nearby.
01:D35F wOptions
-01:D656 wMapGroup
-01:D657 wMapId
+01:D513 wWarpNumber
01:D7D2 wPartyMonOT
01:DA3B wOTPartyMonOT
diff --git a/vram.asm b/vram.asm
index 90fd040..3ebac0f 100644
--- a/vram.asm
+++ b/vram.asm
@@ -34,7 +34,12 @@ vNPCSprites2:: ; 8800
ds $80 tiles
vTileset:: ; 9000
- ds $80 tiles
+; ds $60 tiles
+ ds $20 tiles
+
+vExteriorTileset:: ; 9200
+ ds $40 tiles
+vTilesetEnd:: ; 9600
NEXTU
diff --git a/wram.asm b/wram.asm
index 24be477..3c5681f 100644
--- a/wram.asm
+++ b/wram.asm
@@ -94,7 +94,7 @@ wWhichPicTest:: ; c40b
ENDU
-SECTION "Unknown map buffer?", WRAM0[$C5E8]
+SECTION "Map buffer", WRAM0[$C5E8]
wMapBuffer::
wMapScriptNumber:: db ; c5e8
@@ -107,9 +107,9 @@ wMapBufferEnd:: ; c600
UNION
-wOverworldMapBlocks:: ; c600
+wOverworldMap:: ; c600
ds $514 ; TODO: constantify this
-wOverworldMapBlocksEnd:: ; cb14
+wOverworldMapEnd:: ; cb14
NEXTU
@@ -220,6 +220,9 @@ wMonType:: db ; cb5a
wCurSpecies:: db ; cb5b
wNamedObjectTypeBuffer:: db ; cb5c
+SECTION "CB5E", WRAM0[$CB5E]
+wJumptableIndex:: ds 4
+
SECTION "CB62", WRAM0[$CB62]
wVBCopySize:: ds 1 ; cb62
@@ -249,6 +252,9 @@ wTileUp:: db ; cb91
wTileLeft:: db ; cb92
wTileRight:: db ; cb93
+wScreenSave:: ; cb94
+ ds 6 * 5
+
SECTION "CBD2", WRAM0[$CBD2]
wcbd2:: ; cbd2
ds $14
@@ -298,7 +304,9 @@ wVBlankOccurred: db ; cc33
ds 4
-wcc38:: ; cc38 ; TODO: wceeb in pokegold, what is this?
+;Controls what type of opening (fire/notes) you get.
+wcc38::
+wTitleSequenceOpeningType:: ; cc38
db
wDebugWarpSelection:: ; cc39
@@ -311,10 +319,10 @@ wcc40:: ; cc40
SECTION "CC9C", WRAM0[$CC9C]
-wUnknownWordCC9C:: ; cc9c
+wUnknownWordcc9c:: ; cc9c
dw
-wUnknownBufferCC9E:: ; cc9e
+wUnknownBuffercc9e:: ; cc9e
ds 14
@@ -423,11 +431,13 @@ wLinkMode:: db ; cdbd
; 02 -
; 03 -
-wTargetMapUnk:: db ; cdbe ; TODO: Probably warp ID, check
-wTargetMapGroup:: db ; cdbf
-wTargetMapId:: db ; cdc0
-; cdc1
- ds $c
+wNextWarp:: db ; cdbe
+wNextMapGroup:: db ; cdbf
+wNextMapId:: db ; cdc0
+wPrevWarp:: db ; cdc1
+
+ ds 11
+
wLinkBattleRNs:: ds 10 ; cdcd
; cddd
@@ -555,6 +565,8 @@ wFollowMovementQueue:: ; ce7a
ds 5
wObjectStructs:: ; ce7f
+; Note: this might actually not be an object. TODO: Investigate (if indexing starts at 1, then this isn't an object)
+; It might just be unused/a leftover.
wUnkObjectStruct:: object_struct wUnkObject ; ce7f
wPlayerStruct:: object_struct wPlayer ; cea7
wObject1Struct:: object_struct wObject1 ; cecf
@@ -687,7 +699,10 @@ wUsedSprites:: ; d645
wUsedSpritesEnd:: ; d651
-SECTION "Map header", WRAM0[$D658]
+SECTION "Map header", WRAM0[$D656]
+
+wMapGroup:: db ; d656
+wMapId:: db ; d657
wOverworldMapAnchor:: ; d658
dw
@@ -695,8 +710,8 @@ wOverworldMapAnchor:: ; d658
wYCoord:: db ; d65a
wXCoord:: db ; d65b
-wMetaTileStandingY:: db ; d65c
-wMetaTileStandingX:: db ; d65d
+wMetatileStandingY:: db ; d65c
+wMetatileStandingX:: db ; d65d
; d65f
ds 1 ; TODO