diff options
-rw-r--r-- | constants/map_data_constants.asm | 4 | ||||
-rwxr-xr-x | engine/events/overworld.asm | 2 | ||||
-rwxr-xr-x | engine/overworld/spawn_points.asm | 60 | ||||
-rw-r--r-- | home/map.asm | 2 | ||||
-rw-r--r-- | shim.sym | 4 | ||||
-rw-r--r-- | wram.asm | 2 |
6 files changed, 68 insertions, 6 deletions
diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm index 075a7f1..ee9823e 100644 --- a/constants/map_data_constants.asm +++ b/constants/map_data_constants.asm @@ -7,3 +7,7 @@ const ENVIRONMENT_5 const GATE const DUNGEON + +; SpawnPoints indexes (see data/maps/spawn_points.asm) +const_value = -1 + const SPAWN_N_A
\ No newline at end of file diff --git a/engine/events/overworld.asm b/engine/events/overworld.asm index 8a6d0f4..ec43e46 100755 --- a/engine/events/overworld.asm +++ b/engine/events/overworld.asm @@ -51,7 +51,7 @@ TeleportFunction: ; 03:52db ret
.not_spawn
ld a, c
- ld [wDebugWarpSelection], a
+ ld [wDefaultSpawnpoint], a
ld a, $01
ld [wFieldMoveScriptID], a
ret
diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm new file mode 100755 index 0000000..17c2949 --- /dev/null +++ b/engine/overworld/spawn_points.asm @@ -0,0 +1,60 @@ +INCLUDE "constants.asm"
+
+SECTION "LoadSpawnPoint", ROMX[$4791], BANK[$03]
+
+LoadSpawnPoint: ; 03:4791
+; loads the spawn point in wDefaultSpawnpoint
+ push hl
+ push de
+ ld a, [wDefaultSpawnpoint]
+ and a
+ jr z, .skip
+ dec a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, SpawnPoints
+ add hl, de
+ ld a, [hli]
+ ld [wMapGroup], a
+ ld a, [hli]
+ ld [wMapId], a
+ ld a, [hli]
+ ld [wXCoord], a
+ ld a, [hli]
+ ld [wYCoord], a
+.skip
+ pop de
+ pop hl
+ ret
+
+IsSpawnPoint: ; 03:47b6
+; Checks if the map loaded in de is a spawn point.
+; Returns carry if it's a spawn point.
+ ld hl, SpawnPoints
+ ld c, 1
+.loop
+ ld a, [hl]
+ cp SPAWN_N_A
+ jr z, .fail
+ cp d
+ jr nz, .next
+ inc hl
+ ld a, [hld]
+ cp e
+ jr z, .succeed
+.next
+ push bc
+ ld bc, 4
+ add hl, bc
+ pop bc
+ inc c
+ jr .loop
+.fail
+ and a
+ ret
+.succeed
+ scf
+ ret
+
diff --git a/home/map.asm b/home/map.asm index aac770c..8105781 100644 --- a/home/map.asm +++ b/home/map.asm @@ -331,7 +331,7 @@ MapSetup_Continue:: ; 22e6 call DisableLCD call DisableAudio call VolumeOff - callab DebugWarp + callab LoadSpawnPoint call CopyMapPartialAndAttributes call SetUpMapBuffer call InitUnknownBuffercc9e @@ -59,9 +59,7 @@ 02:5695 CheckSGB 03:4000 Functionc000 -03:4791 DebugWarp -03:479F DebugWarp.Destinations -03:47B6 IsSpawnPoint +03:47D5 SpawnPoints 03:488D Tilesets 03:4D33 Functioncd33 03:4D6F Functioncd6f @@ -331,7 +331,7 @@ wcc38:: wTitleSequenceOpeningType:: ; cc38 db -wDebugWarpSelection:: ; cc39 +wDefaultSpawnpoint:: ; cc39 db wMovementBufferCount:: db ; cc3a |