summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorentrpntr <entrpntr@gmail.com>2020-05-09 20:31:18 -0400
committerentrpntr <entrpntr@gmail.com>2020-05-09 20:31:18 -0400
commitfa45a690ee4b7734b371f18addcd35184df97c86 (patch)
tree9b350107641d8a614580cdd5d4d1e1c3ddcb9492 /engine
parent14f623c65c3f80ade737ba9ace7f1ba132e71939 (diff)
Add engine/overworld/landmarks.asm and engine/events/fish.asm.
Diffstat (limited to 'engine')
-rw-r--r--engine/events/fish.asm121
-rw-r--r--engine/overworld/landmarks.asm82
2 files changed, 203 insertions, 0 deletions
diff --git a/engine/events/fish.asm b/engine/events/fish.asm
new file mode 100644
index 00000000..8cdcd3f2
--- /dev/null
+++ b/engine/events/fish.asm
@@ -0,0 +1,121 @@
+Fish:
+; Using a fishing rod.
+; Fish for monsters with rod e in encounter group d.
+; Return monster d at level e.
+
+ push af
+ push bc
+ push hl
+
+ ld b, e
+ call GetFishGroupIndex
+
+ ld hl, FishGroups
+rept FISHGROUP_DATA_LENGTH
+ add hl, de
+endr
+ call .Fish
+
+ pop hl
+ pop bc
+ pop af
+ ret
+
+.Fish:
+; Fish for monsters with rod b from encounter data in FishGroup at hl.
+; Return monster d at level e.
+
+ call Random
+ cp [hl]
+ jr nc, .no_bite
+
+ ; Get encounter data by rod:
+ ; 0: Old
+ ; 1: Good
+ ; 2: Super
+ inc hl
+ ld e, b
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ; Compare the encounter chance to select a Pokemon.
+ call Random
+.loop
+ cp [hl]
+ jr z, .ok
+ jr c, .ok
+ inc hl
+ inc hl
+ inc hl
+ jr .loop
+.ok
+ inc hl
+
+ ; Species 0 reads from a time-based encounter table.
+ ld a, [hli]
+ ld d, a
+ and a
+ call z, .TimeEncounter
+
+ ld e, [hl]
+ ret
+
+.no_bite
+ ld de, 0
+ ret
+
+.TimeEncounter:
+ ; The level byte is repurposed as the index for the new table.
+ ld e, [hl]
+ ld d, 0
+ ld hl, TimeFishGroups
+rept 4
+ add hl, de
+endr
+
+ ld a, [wTimeOfDay]
+ maskbits NUM_DAYTIMES
+ cp NITE_F
+ jr c, .time_species
+ inc hl
+ inc hl
+
+.time_species
+ ld d, [hl]
+ inc hl
+ ret
+
+GetFishGroupIndex:
+; Return the index of fishgroup d in de.
+
+ ld a, d
+ cp FISHGROUP_QWILFISH
+ jr z, .qwilfish
+ cp FISHGROUP_REMORAID
+ jr z, .remoraid
+
+.done
+ dec d
+ ld e, d
+ ld d, 0
+ ret
+
+.qwilfish
+ ld a, [wFishingSwarmFlag]
+ cp FISHSWARM_QWILFISH
+ jr nz, .done
+ ld d, FISHGROUP_QWILFISH_SWARM
+ jr .done
+
+.remoraid
+ ld a, [wFishingSwarmFlag]
+ cp FISHSWARM_REMORAID
+ jr nz, .done
+ ld d, FISHGROUP_REMORAID_SWARM
+ jr .done
+
+INCLUDE "data/wild/fish.asm"
diff --git a/engine/overworld/landmarks.asm b/engine/overworld/landmarks.asm
new file mode 100644
index 00000000..bee64c75
--- /dev/null
+++ b/engine/overworld/landmarks.asm
@@ -0,0 +1,82 @@
+GetLandmarkCoords:
+; Return coordinates (d, e) of landmark e.
+ push hl
+ ld l, e
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, Landmarks
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+ ret
+
+GetLandmarkName::
+; Copy the name of landmark e to wStringBuffer1.
+ push hl
+ push de
+ push bc
+
+ ld l, e
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, Landmarks + 2
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld de, wStringBuffer1
+ ld c, 18
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .copy
+
+ pop bc
+ pop de
+ pop hl
+ ret
+
+INCLUDE "data/maps/landmarks.asm"
+
+RegionCheck:
+; Checks if the player is in Kanto or Johto.
+; If in Johto, returns 0 in e.
+; If in Kanto, returns 1 in e.
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapNumber]
+ ld c, a
+ call GetWorldMapLocation
+ cp LANDMARK_FAST_SHIP ; S.S. Aqua
+ jr z, .johto
+ cp LANDMARK_SPECIAL
+ jr nz, .checkagain
+
+; In a special map, get the backup map group / map id
+ ld a, [wBackupMapGroup]
+ ld b, a
+ ld a, [wBackupMapNumber]
+ ld c, a
+ call GetWorldMapLocation
+
+.checkagain
+ cp KANTO_LANDMARK
+ jr c, .johto
+
+; Victory Road area is considered to be Johto.
+ cp LANDMARK_VICTORY_ROAD
+ jr c, .kanto
+
+.johto
+ ld e, JOHTO_REGION
+ ret
+.kanto
+ ld e, KANTO_REGION
+ ret