ref: a238e4bd55f7934a0201a2a523c739be70820760
parent: 66b74f2a36823b08bd991a786ed711158f5514a0
parent: 87c36ebbc0504cea089ef484b0c6d61b640ced1e
author: Bryan Bishop <[email protected]>
date: Fri Mar 22 06:18:05 EDT 2013
Merge pull request #125 from yenatch/master fishing encounter data
--- a/constants.asm
+++ b/constants.asm
@@ -3249,6 +3249,8 @@
MUSIC_BATTLE_TOWER_LOBBY EQU 101
MUSIC_MOBILE_CENTER EQU 102
+MUSIC_MAHOGANY_MART EQU 100 ; grandfathered from gold
+
; sound
_4CH1 EQU $c0
_3CH1 EQU $80
@@ -3414,6 +3416,30 @@
BATTLETYPE_TREE EQU $08
BATTLETYPE_FORCEITEM EQU $0a
BATTLETYPE_SUICUNE EQU $0c
+
+
+; battle variables
+BATTLE_VARS_SUBSTATUS1 EQU 0
+BATTLE_VARS_SUBSTATUS2 EQU 1
+BATTLE_VARS_SUBSTATUS3 EQU 2
+BATTLE_VARS_SUBSTATUS4 EQU 3
+BATTLE_VARS_SUBSTATUS5 EQU 4
+BATTLE_VARS_SUBSTATUS1_OPP EQU 5
+BATTLE_VARS_SUBSTATUS2_OPP EQU 6
+BATTLE_VARS_SUBSTATUS3_OPP EQU 7
+BATTLE_VARS_SUBSTATUS4_OPP EQU 8
+BATTLE_VARS_SUBSTATUS5_OPP EQU 9
+BATTLE_VARS_STATUS EQU 10
+BATTLE_VARS_STATUS_OPP EQU 11
+BATTLE_VARS_MOVE_ANIM EQU 12
+BATTLE_VARS_MOVE_EFFECT EQU 13
+BATTLE_VARS_MOVE_POWER EQU 14
+BATTLE_VARS_MOVE_TYPE EQU 15
+BATTLE_VARS_MOVE EQU 16
+BATTLE_VARS_LAST_COUNTER_MOVE EQU 17
+BATTLE_VARS_LAST_COUNTER_MOVE_OPP EQU 18
+BATTLE_VARS_LAST_MOVE EQU 19
+BATTLE_VARS_LAST_MOVE_OPP EQU 20
; joypad
--- a/main.asm
+++ b/main.asm
@@ -3415,8 +3415,22 @@
jp AddNTimes
; 392d
-INCBIN "baserom.gbc",$392d,$3b86 - $392d
+INCBIN "baserom.gbc", $392d, $3985 - $392d
+SetPlayerTurn: ; 3985
+ xor a
+ ld [hBattleTurn], a
+ ret
+; 3989
+
+SetEnemyTurn: ; 3989
+ ld a, 1
+ ld [hBattleTurn], a
+ ret
+; 398e
+
+INCBIN "baserom.gbc", $398e, $3b86 - $398e
+
LoadMusicByte: ; 3b86
; load music data into CurMusicByte
; input:
@@ -11200,7 +11214,14 @@
KantoMap:
INCBIN "baserom.gbc", $92168, $922d1 - $92168
-INCBIN "baserom.gbc", $922d1, $93a31 - $922d1
+
+INCBIN "baserom.gbc", $922d1, $92402 - $922d1
+
+
+INCLUDE "stats/wild/fish.asm"
+
+
+INCBIN "baserom.gbc", $926c7, $93a31 - $926c7
SECTION "bank25",DATA,BANK[$25]
--- /dev/null
+++ b/stats/wild/fish.asm
@@ -1,0 +1,502 @@
+FishAction: ; 92402
+; Using a fishing rod.
+; Fish for monsters with rod e in encounter group d.
+; Return monster e at level d.
+
+ push af
+ push bc
+ push hl
+
+; Get the fishing group for this map.
+ ld b, e
+ call GetFishGroupHeader
+
+ ld hl, FishGroupHeaders
+ ; encounter chance
+ add hl, de
+ ; pointer to old rod data
+ add hl, de
+ add hl, de
+ ; pointer to good rod data
+ add hl, de
+ add hl, de
+ ; pointer to super rod data
+ add hl, de
+ add hl, de
+
+ call Fish
+
+ pop hl
+ pop bc
+ pop af
+ ret
+; 9241a
+
+
+Fish: ; 9241a
+; Grandfathered from Red.
+
+; Fish for monsters with rod b from encounter data in FishGroup at hl.
+; Return monster e at level d.
+
+ call RNG
+
+; Got a bite?
+ cp [hl]
+ jr nc, .NoBite
+
+; 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
+
+; Encounter chance for this monster:
+ call RNG
+
+.CheckEncounter
+ cp [hl]
+ jr z, .ReadMon
+ jr c, .ReadMon
+
+; Next monster...
+ inc hl
+ inc hl
+ inc hl
+ jr .CheckEncounter
+
+.ReadMon
+; We're done with the encounter chance
+ inc hl
+
+; Species 0 triggers a read from a time-based encounter table.
+ ld a, [hli]
+ ld d, a
+ and a
+ call z, .TimeEncounter
+
+; Level
+ ld e, [hl]
+ ret
+
+.NoBite
+ 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
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+
+; One nightmon, then one daymon
+ ld a, [TimeOfDay]
+ and 3
+ cp NITE
+ jr c, .TimeSpecies
+ inc hl
+ inc hl
+
+.TimeSpecies
+ ld d, [hl]
+ inc hl
+ ret
+; 9245b
+
+
+
+
+GetFishGroupHeader: ; 9245b
+; Return fishing encounter group header d in de.
+
+ push hl
+ ld hl, $dc1e
+ bit 2, [hl]
+ pop hl
+ jr z, .end
+
+; Groups 11 and 12 have special attributes.
+ ld a, d
+ cp 11
+ jr z, .group11
+ cp 12
+ jr z, .group12
+
+.end
+ dec d
+ ld e, d
+ ld d, 0
+ ret
+
+.group11
+ ld a, [$dfce]
+ cp 1
+ jr nz, .end
+ ld d, 6
+ jr .end
+
+.group12
+ ld a, [$dfce]
+ cp 2
+ jr nz, .end
+ ld d, 7
+ jr .end
+; 92488
+
+
+FishGroupHeaders:
+
+FishGroup1Header: ; 92488
+ db $80 ; 50%
+ dw FishGroup1_Old
+ dw FishGroup1_Good
+ dw FishGroup1_Super
+
+FishGroup2Header: ; 9248f
+ db $80 ; 50%
+ dw FishGroup2_Old
+ dw FishGroup2_Good
+ dw FishGroup2_Super
+
+FishGroup3Header: ; 92496
+ db $80 ; 50%
+ dw FishGroup3_Old
+ dw FishGroup3_Good
+ dw FishGroup3_Super
+
+FishGroup4Header: ; 9249d
+ db $80 ; 50%
+ dw FishGroup4_Old
+ dw FishGroup4_Good
+ dw FishGroup4_Super
+
+FishGroup5Header: ; 924a4
+ db $80 ; 50%
+ dw FishGroup5_Old
+ dw FishGroup5_Good
+ dw FishGroup5_Super
+
+FishGroup6Header: ; 924ab
+ db $80 ; 50%
+ dw FishGroup6_Old
+ dw FishGroup6_Good
+ dw FishGroup6_Super
+
+FishGroup7Header: ; 924b2
+ db $80 ; 50%
+ dw FishGroup7_Old
+ dw FishGroup7_Good
+ dw FishGroup7_Super
+
+FishGroup8Header: ; 924b9
+ db $80 ; 50%
+ dw FishGroup8_Old
+ dw FishGroup8_Good
+ dw FishGroup8_Super
+
+FishGroup9Header: ; 924c0
+ db $80 ; 50%
+ dw FishGroup9_Old
+ dw FishGroup9_Good
+ dw FishGroup9_Super
+
+FishGroup10Header: ; 924c7
+ db $80 ; 50%
+ dw FishGroup10_Old
+ dw FishGroup10_Good
+ dw FishGroup10_Super
+
+FishGroup11Header: ; 924ce
+ db $80 ; 50%
+ dw FishGroup11_Old
+ dw FishGroup11_Good
+ dw FishGroup11_Super
+
+FishGroup12Header: ; 924d5
+ db $80 ; 50%
+ dw FishGroup12_Old
+ dw FishGroup12_Good
+ dw FishGroup12_Super
+
+FishGroup13Header: ; 924dc
+ db $80 ; 50%
+ dw FishGroup11_Old
+ dw FishGroup11_Good
+ dw FishGroup11_Super
+
+FishGroup1:
+FishGroup1_Old: ; 924e3
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, KRABBY, 10
+FishGroup1_Good: ; 924ec
+ db $59, MAGIKARP, 20
+ db $b2, KRABBY, 20
+ db $e6, KRABBY, 20
+ db $ff, $0, 0
+FishGroup1_Super: ; 924f8
+ db $66, KRABBY, 40
+ db $b2, $0, 1
+ db $e6, KRABBY, 40
+ db $ff, KINGLER, 40
+
+FishGroup2:
+FishGroup2_Old: ; 92504
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, TENTACOOL, 10
+FishGroup2_Good: ; 9250d
+ db $59, MAGIKARP, 20
+ db $b2, TENTACOOL, 20
+ db $e6, CHINCHOU, 20
+ db $ff, $0, 2
+FishGroup2_Super: ; 92519
+ db $66, CHINCHOU, 40
+ db $b2, $0, 3
+ db $e6, TENTACRUEL, 40
+ db $ff, LANTURN, 40
+
+FishGroup3:
+FishGroup3_Old: ; 92525
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, GOLDEEN, 10
+FishGroup3_Good: ; 9252e
+ db $59, MAGIKARP, 20
+ db $b2, GOLDEEN, 20
+ db $e6, GOLDEEN, 20
+ db $ff, $0, 4
+FishGroup3_Super: ; 9253a
+ db $66, GOLDEEN, 40
+ db $b2, $0, 5
+ db $e6, MAGIKARP, 40
+ db $ff, SEAKING, 40
+
+FishGroup4:
+FishGroup4_Old: ; 92546
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, POLIWAG, 10
+FishGroup4_Good: ; 9254f
+ db $59, MAGIKARP, 20
+ db $b2, POLIWAG, 20
+ db $e6, POLIWAG, 20
+ db $ff, $0, 6
+FishGroup4_Super: ; 9255b
+ db $66, POLIWAG, 40
+ db $b2, $0, 7
+ db $e6, MAGIKARP, 40
+ db $ff, POLIWAG, 40
+
+FishGroup5:
+FishGroup5_Old: ; 92567
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, MAGIKARP, 10
+FishGroup5_Good: ; 92570
+ db $59, MAGIKARP, 20
+ db $b2, MAGIKARP, 20
+ db $e6, MAGIKARP, 20
+ db $ff, $0, 8
+FishGroup5_Super: ; 9257c
+ db $66, MAGIKARP, 40
+ db $b2, $0, 9
+ db $e6, MAGIKARP, 40
+ db $ff, DRAGONAIR, 40
+
+FishGroup6:
+FishGroup6_Old: ; 92588
+ db $b3, MAGIKARP, 5
+ db $d9, MAGIKARP, 5
+ db $ff, QWILFISH, 5
+FishGroup6_Good: ; 92591
+ db $59, MAGIKARP, 20
+ db $b2, QWILFISH, 20
+ db $e6, QWILFISH, 20
+ db $ff, $0, 10
+FishGroup6_Super: ; 9259d
+ db $66, QWILFISH, 40
+ db $b2, $0, 11
+ db $e6, QWILFISH, 40
+ db $ff, QWILFISH, 40
+
+FishGroup7:
+FishGroup7_Old: ; 925a9
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, REMORAID, 10
+FishGroup7_Good: ; 925b2
+ db $59, MAGIKARP, 20
+ db $b2, REMORAID, 20
+ db $e6, REMORAID, 20
+ db $ff, $0, 12
+FishGroup7_Super: ; 925be
+ db $66, REMORAID, 40
+ db $b2, $0, 13
+ db $e6, REMORAID, 40
+ db $ff, REMORAID, 40
+
+FishGroup8:
+FishGroup8_Old: ; 925ca
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, MAGIKARP, 10
+FishGroup8_Good: ; 925d3
+ db $59, MAGIKARP, 20
+ db $b2, MAGIKARP, 20
+ db $e6, MAGIKARP, 20
+ db $ff, $0, 14
+FishGroup8_Super: ; 925df
+ db $66, MAGIKARP, 40
+ db $b2, $0, 15
+ db $e6, MAGIKARP, 40
+ db $ff, MAGIKARP, 40
+
+FishGroup9:
+FishGroup9_Old: ; 925eb
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, MAGIKARP, 10
+FishGroup9_Good: ; 925f4
+ db $59, MAGIKARP, 10
+ db $b2, MAGIKARP, 10
+ db $e6, MAGIKARP, 10
+ db $ff, $0, 16
+FishGroup9_Super: ; 92600
+ db $66, MAGIKARP, 10
+ db $b2, $0, 17
+ db $e6, MAGIKARP, 10
+ db $ff, DRAGONAIR, 10
+
+FishGroup10:
+FishGroup10_Old: ; 9260c
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, KRABBY, 10
+FishGroup10_Good: ; 92615
+ db $59, MAGIKARP, 20
+ db $b2, KRABBY, 20
+ db $e6, KRABBY, 20
+ db $ff, $0, 18
+FishGroup10_Super: ; 92621
+ db $66, KRABBY, 40
+ db $b2, $0, 19
+ db $e6, KINGLER, 40
+ db $ff, SEADRA, 40
+
+FishGroup11:
+FishGroup11_Old: ; 9262d
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, TENTACOOL, 10
+FishGroup11_Good: ; 92636
+ db $59, MAGIKARP, 20
+ db $b2, TENTACOOL, 20
+ db $e6, TENTACOOL, 20
+ db $ff, $0, 20
+FishGroup11_Super: ; 92642
+ db $66, TENTACOOL, 40
+ db $b2, $0, 21
+ db $e6, MAGIKARP, 40
+ db $ff, QWILFISH, 40
+
+FishGroup12:
+FishGroup12_Old: ; 9264e
+ db $b3, MAGIKARP, 10
+ db $d9, MAGIKARP, 10
+ db $ff, POLIWAG, 10
+FishGroup12_Good: ; 92657
+ db $59, MAGIKARP, 20
+ db $b2, POLIWAG, 20
+ db $e6, POLIWAG, 20
+ db $ff, $0, 6
+FishGroup12_Super: ; 92663
+ db $66, POLIWAG, 40
+ db $b2, $0, 7
+ db $e6, MAGIKARP, 40
+ db $ff, REMORAID, 40
+
+; 9266f
+
+TimeFishGroups: ; 9266f
+; 0
+ db CORSOLA, 20 ; nite
+ db STARYU, 20 ; day
+; 1
+ db CORSOLA, 40 ; nite
+ db STARYU, 40 ; day
+; 2
+ db SHELLDER, 20 ; nite
+ db SHELLDER, 20 ; day
+; 3
+ db SHELLDER, 40 ; nite
+ db SHELLDER, 40 ; day
+; 4
+ db GOLDEEN, 20 ; nite
+ db GOLDEEN, 20 ; day
+; 5
+ db GOLDEEN, 40 ; nite
+ db GOLDEEN, 40 ; day
+; 6
+ db POLIWAG, 20 ; nite
+ db POLIWAG, 20 ; day
+; 7
+ db POLIWAG, 40 ; nite
+ db POLIWAG, 40 ; day
+; 8
+ db DRATINI, 20 ; nite
+ db DRATINI, 20 ; day
+; 9
+ db DRATINI, 40 ; nite
+ db DRATINI, 40 ; day
+; 10
+ db QWILFISH, 20 ; nite
+ db QWILFISH, 20 ; day
+; 11
+ db QWILFISH, 40 ; nite
+ db QWILFISH, 40 ; day
+; 12
+ db REMORAID, 20 ; nite
+ db REMORAID, 20 ; day
+; 13
+ db REMORAID, 40 ; nite
+ db REMORAID, 40 ; day
+; 14
+ db GYARADOS, 20 ; nite
+ db GYARADOS, 20 ; day
+; 15
+ db GYARADOS, 40 ; nite
+ db GYARADOS, 40 ; day
+; 16
+ db DRATINI, 10 ; nite
+ db DRATINI, 10 ; day
+; 17
+ db DRATINI, 10 ; nite
+ db DRATINI, 10 ; day
+; 18
+ db HORSEA, 20 ; nite
+ db HORSEA, 20 ; day
+; 19
+ db HORSEA, 40 ; nite
+ db HORSEA, 40 ; day
+; 20
+ db TENTACOOL, 20 ; nite
+ db TENTACOOL, 20 ; day
+; 21
+ db TENTACOOL, 40 ; nite
+ db TENTACOOL, 40 ; day
+
+; 926c7
+
--- a/wram.asm
+++ b/wram.asm
@@ -565,10 +565,8 @@
BattleScriptBuffer: ; c68a
ds 40
-BattleScriptBufferLocLo: ; c6b2
- ds 1
-BattleScriptBufferLocHi: ; c6b3
- ds 1
+BattleScriptBufferLoc: ; c6b2
+ ds 2
ds 25
@@ -1286,6 +1284,11 @@
Box14Name: ; dbea
ds 9
+SECTION "steps", BSS[$dc73]
+StepCount: ; dc73
+ ds 1
+PoisonStepCount: ; dc74
+ ds 1
SECTION "FlypointPermissions", BSS[$dca5]
FlypointPerms: ; dca5