diff options
author | Daniel Harding <33dannye@gmail.com> | 2020-05-16 21:42:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 21:42:24 -0500 |
commit | 8a924f1f783572ff395f617f99546b4c949c8b04 (patch) | |
tree | 1b6c7de331cb983256651b11b8adf413a3a434f1 /engine/overworld/spawn_points.asm | |
parent | 88d7e9a34a8b610b358cec1ccc6660634ca9ce80 (diff) | |
parent | ed94962edf1668aba3f60938e8a5ba8040e2a59c (diff) |
Merge pull request #30 from entrpntr/spring-cleaning
Spring Cleaning
Diffstat (limited to 'engine/overworld/spawn_points.asm')
-rw-r--r-- | engine/overworld/spawn_points.asm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/engine/overworld/spawn_points.asm b/engine/overworld/spawn_points.asm new file mode 100644 index 00000000..1b92b1e0 --- /dev/null +++ b/engine/overworld/spawn_points.asm @@ -0,0 +1,56 @@ +EnterMapSpawnPoint: + ; loads the spawn point in wDefaultSpawnpoint + push hl + push de + ld a, [wDefaultSpawnpoint] + cp SPAWN_N_A + jr z, .spawn_n_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 [wMapNumber], a + ld a, [hli] + ld [wXCoord], a + ld a, [hli] + ld [wYCoord], a +.spawn_n_a + pop de + pop hl + ret + +IsSpawnPoint: +; Checks if the map loaded in de is a spawn point. Returns carry if it's a spawn point. + ld hl, SpawnPoints + ld c, 0 +.loop + ld a, [hl] + cp SPAWN_N_A + jr z, .nope + cp d + jr nz, .next + inc hl + ld a, [hld] + cp e + jr z, .yes + +.next + push bc + ld bc, 4 ; length of a spawn table entry + add hl, bc + pop bc + inc c + jr .loop + +.nope + and a + ret + +.yes + scf + ret |