summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPokeglitch <pokeglitchx@gmail.com>2018-06-14 21:46:09 -0400
committerPokeglitch <pokeglitchx@gmail.com>2018-06-14 21:46:09 -0400
commitc955c8d353f63c07cc4ac71160e4a13061192c8a (patch)
treef15070cf4b28f82ac8fa6f266d909ca11a26dcf4
parentd6b67710739c96b357f64b9457cac8750c46d1ca (diff)
Disassembled teleport
-rw-r--r--constants/map_setup_constants.asm2
-rwxr-xr-xengine/events/overworld.asm106
-rwxr-xr-xengine/items/inventory.asm6
-rw-r--r--home/overworld.asm16
-rw-r--r--shim.sym2
-rw-r--r--wram.asm19
6 files changed, 135 insertions, 16 deletions
diff --git a/constants/map_setup_constants.asm b/constants/map_setup_constants.asm
index 046fc65..7357058 100644
--- a/constants/map_setup_constants.asm
+++ b/constants/map_setup_constants.asm
@@ -3,7 +3,7 @@
const MAPSETUP_CONTINUE ; $f1
const MAPSETUP_F2
const MAPSETUP_RELOADMAP ; $f3
- const MAPSETUP_F4
+ const MAPSETUP_TELEPORT ; $f4
const MAPSETUP_F5 ; Note: entry is duplicate of $F4
const MAPSETUP_WARP ; $f6
const MAPSETUP_CONNECTION ; $f7
diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm
new file mode 100755
index 0000000..76e6b91
--- /dev/null
+++ b/engine/events/overworld.asm
@@ -0,0 +1,106 @@
+INCLUDE "constants.asm"
+
+SECTION "TeleportFunction", ROMX[$52db], BANK[$03]
+
+TeleportFunction: ; 03:52db
+ xor a
+ ld [wFieldMoveScriptID], a
+.loop
+ ld a, [wFieldMoveScriptID]
+ bit 7, a
+ jr nz, .finish
+ ld hl, .JumpTable
+ call CallJumptable
+ jr .loop
+.finish
+ and $7f
+ ld [wFieldMoveSucceeded], a
+ ret
+
+.JumpTable
+ dw .TryTeleport
+ dw .DoTeleport
+ dw .FailTeleport
+ dw .CheckIfSpawnPoint
+
+.TryTeleport: ; 03:52fc
+ call GetMapEnvironment
+ cp TOWN
+ jr z, .success
+ cp ROUTE
+ jr z, .success
+ ld a, $02
+ ld [wFieldMoveScriptID], a
+ ret
+.success
+ ld a, $03
+ ld [wFieldMoveScriptID], a
+ ret
+
+.CheckIfSpawnPoint ; 03:5313
+ ld a, [wLastSpawnMapGroup]
+ ld d, a
+ ld a, [wLastSpawnMapNumber]
+ ld e, a
+ ld hl, IsSpawnPoint
+ ld a, BANK(IsSpawnPoint)
+ call FarCall_hl
+ jr c, .not_spawn
+ ld hl, .Text_CantFindDestination
+ call MenuTextBoxBackup
+ ld a, $80
+ ld [wFieldMoveScriptID], a
+ ret
+.not_spawn
+ ld a, c
+ ld [wDebugWarpSelection], a
+ ld a, $01
+ ld [wFieldMoveScriptID], a
+ ret
+
+.Text_CantFindDestination:
+ db "<NULL>"
+ db "とびさきが みつかりません"
+ db "<PARA><DONE>"
+
+.DoTeleport: ; 03:534b
+ ldh a, [hROMBank]
+ ld hl, .TeleportScript
+ call QueueScript
+ ld a, $8f
+ ld [wFieldMoveScriptID], a
+ ret
+
+.FailTeleport: ; 03:5359
+ ld hl, .Text_CantUseHere
+ call MenuTextBoxBackup
+ ld a, $80
+ ld [wFieldMoveScriptID], a
+ scf
+ ret
+
+.Text_CantUseHere:
+ db "<NULL>"
+ db "ここでは つかえません!"
+ db "<PARA><DONE>"
+
+.TeleportScript: ; 03:5375
+ call RefreshScreen
+ ld hl, .Text_ReturnToLastMonCenter
+ call MenuTextBox
+ ld c, 60
+ call DelayFrames
+ call CloseWindow
+ call Function1fea
+ ld a, MAPSETUP_TELEPORT
+ ldh [hMapEntryMethod], a
+ ld hl, Functionfcc24
+ ld a, BANK(Functionfcc24)
+ jp FarCall_hl
+
+.Text_ReturnToLastMonCenter:
+ db "<NULL>"
+ db "さいごに たちよった"
+ db "<LINE>"
+ db "#センターにもどります"
+ db "<DONE>" \ No newline at end of file
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm
index a95f2ac..5927f6d 100755
--- a/engine/items/inventory.asm
+++ b/engine/items/inventory.asm
@@ -596,7 +596,8 @@ GetNumberedTMHM: ; 03:4D1A
SECTION "_CheckTossableItem", ROMX[$53AD], BANK[$03]
-; Return 1 in wItemAttributeParamBuffer and carry if wCurItem can't be removed from the bag.
+; Return 1 in wItemAttributeParamBuffer and
+; carry if wCurItem can't be removed from the bag.
_CheckTossableItem: ; 03:53AD
ld a, ITEMATTR_PERMISSIONS
call GetItemAttr
@@ -605,7 +606,8 @@ _CheckTossableItem: ; 03:53AD
and a
ret
-; Return 1 in wItemAttributeParamBuffer and carry if wCurItem can't be selected.
+; Return 1 in wItemAttributeParamBuffer
+; and carry if wCurItem can't be selected.
CheckSelectableItem: ; 03:53B8
ld a, ITEMATTR_PERMISSIONS
call GetItemAttr
diff --git a/home/overworld.asm b/home/overworld.asm
index afa73cc..2b37b7c 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -29,11 +29,11 @@ CheckStartmenuSelectHook:
ldh a, [hStartmenuCloseAndSelectHookEnable]
and a
ret z ; hook is disabled
- ld hl, StartmenuCloseAndSelectHookPtr
+ ld hl, wQueuedScriptAddr
ld a, [hli]
ld h, [hl]
ld l, a
- ld a, [StartmenuCloseAndSelectHookBank]
+ ld a, [wQueuedScriptBank]
call FarCall_hl
ld hl, hStartmenuCloseAndSelectHookEnable
xor a
@@ -178,18 +178,18 @@ ScheduleColumnRedrawHelper: ; 2d10 (0:2d10)
ret
if DEBUG
-SECTION "Install StartMenu Hook Function", ROM0[$35EC]
+SECTION "QueueScript", ROM0[$35EC]
else
-SECTION "Install StartMenu Hook Function", ROM0[$35B0]
+SECTION "QueueScript", ROM0[$35B0]
endc
-InstallStartmenuCloseAndSelectHook::
+QueueScript::
; Install a function that is called as soon as
; the start menu is closed or directly after
; the select button function ran
- ld [StartmenuCloseAndSelectHookBank], a
+ ld [wQueuedScriptBank], a
ld a, l
- ld [StartmenuCloseAndSelectHookPtr], a
+ ld [wQueuedScriptAddr], a
ld a, h
- ld [StartmenuCloseAndSelectHookPtr + 1], a
+ ld [wQueuedScriptAddr + 1], a
ret
diff --git a/shim.sym b/shim.sym
index 95b1d2f..f81ee1e 100644
--- a/shim.sym
+++ b/shim.sym
@@ -61,6 +61,7 @@
03:4000 Functionc000
03:4791 DebugWarp
03:479F DebugWarp.Destinations
+03:47B6 IsSpawnPoint
03:488D Tilesets
03:4D33 Functioncd33
03:4D6F Functioncd6f
@@ -460,6 +461,7 @@
3A:52C7 Music
3F:40E9 InGameDebugMenu
+3F:4C24 Functionfcc24
3F:4E3E Functionfce3e
3F:5B66 Functionfdb66
3F:6255 Functionfe255
diff --git a/wram.asm b/wram.asm
index 132a833..916f896 100644
--- a/wram.asm
+++ b/wram.asm
@@ -321,8 +321,10 @@ SECTION "CC32", WRAM0[$CC32] ; Please merge when more is disassembled
wVBlankJoyFrameCounter: db ; cc32
wVBlankOccurred: db ; cc33
+wLastSpawnMapGroup: db ;cc34
+wLastSpawnMapNumber: db ; cc35
- ds 4
+ ds 2
;Controls what type of opening (fire/notes) you get.
wcc38::
@@ -404,8 +406,8 @@ wMenuScrollPosition:: db ; cd49
wTextDest:: ds 2; cd4a
-StartmenuCloseAndSelectHookBank:: db ; cd4c
-StartmenuCloseAndSelectHookPtr:: dw ; cd4d
+wQueuedScriptBank:: db ; cd4c
+wQueuedScriptAddr:: dw ; cd4d
wPredefID:: ; cd4f
db
@@ -419,7 +421,9 @@ wPredefBC:: ; cd54
wFarCallBCBuffer:: ; cd54
dw
- ds 3 ; TODO
+ ds 2 ; TODO
+
+wFieldMoveSucceeded:: db ; cd58
wVramState:: db ; cd59
ds 3 ; TODO
@@ -466,11 +470,16 @@ wNextMapGroup:: db ; cdbf
wNextMapId:: db ; cdc0
wPrevWarp:: db ; cdc1
- ds 11
+ ds 1
+
+wFieldMoveScriptID:: db ; cdc3
+
+ ds 9
wLinkBattleRNs:: ds 10 ; cdcd
; cddd
+
SECTION "CE00", WRAM0[$CE00]
wBattleMode:: ; ce00