summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorentrpntr <entrpntr@gmail.com>2020-03-17 16:20:00 -0400
committerentrpntr <entrpntr@gmail.com>2020-03-17 16:20:00 -0400
commite67786a7a26ae7531301e928870b204043fb8a6a (patch)
tree579c9e876fa2cd46c13ecceed0e8f0358e347131
parentc248b30aa7487b51a9182a833b1db29f14a7267c (diff)
Cleanup of files for banks $02 and $03 for main.asm.
-rw-r--r--data/text/common_2.asm2
-rw-r--r--data/text/common_3.asm2
-rwxr-xr-xengine/battle/anim_hp_bar.asm (renamed from engine/anim_hp_bar.asm)0
-rw-r--r--engine/events/bug_contest/caught_mon.asm37
-rw-r--r--engine/events/checktime.asm19
-rwxr-xr-xengine/events/engine_flags.asm (renamed from engine/engine_flags.asm)0
-rwxr-xr-xengine/events/specials.asm (renamed from engine/specials.asm)38
-rwxr-xr-xengine/gfx/color.asm (renamed from engine/color.asm)0
-rwxr-xr-xengine/items/item_effects.asm (renamed from items/item_effects.asm)0
-rwxr-xr-xengine/items/items.asm (renamed from engine/items.asm)0
-rw-r--r--engine/math/sine.asm (renamed from engine/sine.asm)0
-rwxr-xr-xengine/overworld/variables.asm (renamed from engine/variables.asm)0
-rw-r--r--engine/pokemon/breedmon_level_growth.asm27
-rwxr-xr-xengine/pokemon/health.asm (renamed from engine/health.asm)0
-rw-r--r--engine/pokemon/knows_move.asm24
-rwxr-xr-xengine/pokemon/move_mon.asm (renamed from engine/move_mon.asm)0
-rw-r--r--engine/pokemon/search2.asm134
-rw-r--r--engine/smallflag.asm74
-rw-r--r--engine/tilesets/map_palettes.asm110
-rw-r--r--gfx/tileset_palette_maps.asm6
-rw-r--r--main.asm437
-rw-r--r--pokegold.link4
-rw-r--r--pokesilver.link4
23 files changed, 473 insertions, 445 deletions
diff --git a/data/text/common_2.asm b/data/text/common_2.asm
index bba69b4c..f9caef49 100644
--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -580,7 +580,7 @@ Text_CantTakeAnyMorePokemon_::
line "more #MON."
prompt
-Text_CaughtBugMon_::
+_ContestCaughtMonText::
text "Caught @"
text_ram wStringBuffer1
text "!"
diff --git a/data/text/common_3.asm b/data/text/common_3.asm
index 503d5a76..d89d72d2 100644
--- a/data/text/common_3.asm
+++ b/data/text/common_3.asm
@@ -445,7 +445,7 @@ Text_GotOffItem_::
text "."
prompt
-Text_KnowsMove_::
+_KnowsMoveText::
text_ram wStringBuffer1
text " knows"
line "@"
diff --git a/engine/anim_hp_bar.asm b/engine/battle/anim_hp_bar.asm
index 561cba42..561cba42 100755
--- a/engine/anim_hp_bar.asm
+++ b/engine/battle/anim_hp_bar.asm
diff --git a/engine/events/bug_contest/caught_mon.asm b/engine/events/bug_contest/caught_mon.asm
new file mode 100644
index 00000000..b2cc044a
--- /dev/null
+++ b/engine/events/bug_contest/caught_mon.asm
@@ -0,0 +1,37 @@
+BugContest_SetCaughtContestMon:
+ ld a, [wContestMon]
+ and a
+ jr z, .firstcatch
+ ld [wNamedObjectIndexBuffer], a
+ farcall DisplayAlreadyCaughtText
+ farcall DisplayCaughtContestMonStats
+ lb bc, 14, 7
+ call PlaceYesNoBox
+ ret c
+
+.firstcatch
+ call .generatestats
+ ld a, [wTempEnemyMonSpecies]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld hl, .ContestCaughtMonText
+ call PrintText
+ ret
+
+.generatestats
+ ld a, [wTempEnemyMonSpecies]
+ ld [wCurSpecies], a
+ ld [wCurPartySpecies], a
+ call GetBaseData
+ xor a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ ld hl, wContestMon
+ call ByteFill
+ xor a
+ ld [wMonType], a
+ ld hl, wContestMon
+ jp GeneratePartyMonStats
+
+.ContestCaughtMonText:
+ text_far _ContestCaughtMonText
+ text_end
diff --git a/engine/events/checktime.asm b/engine/events/checktime.asm
new file mode 100644
index 00000000..6e470e88
--- /dev/null
+++ b/engine/events/checktime.asm
@@ -0,0 +1,19 @@
+CheckTime::
+ ld a, [wTimeOfDay]
+ ld hl, .TimeOfDayTable
+ ld de, 2
+ call IsInArray
+ inc hl
+ ld c, [hl]
+ ret c
+
+ xor a
+ ld c, a
+ ret
+
+.TimeOfDayTable:
+ db MORN_F, MORN
+ db DAY_F, DAY
+ db NITE_F, NITE
+ db NITE_F, NITE
+ db -1
diff --git a/engine/engine_flags.asm b/engine/events/engine_flags.asm
index 9fa5f8c0..9fa5f8c0 100755
--- a/engine/engine_flags.asm
+++ b/engine/events/engine_flags.asm
diff --git a/engine/specials.asm b/engine/events/specials.asm
index 80d32a02..e51f3451 100755
--- a/engine/specials.asm
+++ b/engine/events/specials.asm
@@ -167,40 +167,40 @@ UnusedSetSeenMon: ; c3ac
call SetSeenMon
ret
-FindPartyMonAboveLevel: ; c3b4
+FindPartyMonAboveLevel:
ld a, [wScriptVar]
ld b, a
- farcall PartySearch_MaximumLevel ; same bank
- jr z, asm_c3f2
- jr asm_c3ec
+ farcall _FindPartyMonAboveLevel ; same bank
+ jr z, FoundNone
+ jr FoundOne
-FindPartyMonAtLeastThatHappy: ; c3c2
+FindPartyMonAtLeastThatHappy:
ld a, [wScriptVar]
ld b, a
- farcall PartySearch_MinimumHappiness ; same bank
- jr z, asm_c3f2
- jr asm_c3ec
+ farcall _FindPartyMonAtLeastThatHappy ; same bank
+ jr z, FoundNone
+ jr FoundOne
-FindPartyMonThatSpecies: ; c3d0
+FindPartyMonThatSpecies:
ld a, [wScriptVar]
ld b, a
- farcall PartySearch_SameSpecies ; same bank
- jr z, asm_c3f2
- jr asm_c3ec
+ farcall _FindPartyMonThatSpecies ; same bank
+ jr z, FoundNone
+ jr FoundOne
-FindPartyMonThatSpeciesYourTrainerID: ; c3de
+FindPartyMonThatSpeciesYourTrainerID:
ld a, [wScriptVar]
ld b, a
- farcall PartySearch_SameSpeciesAndYourID ; same bank
- jr z, asm_c3f2
- jr asm_c3ec
+ farcall _FindPartyMonThatSpeciesYourTrainerID ; same bank
+ jr z, FoundNone
+ jr FoundOne
-asm_c3ec
- ld a, $1
+FoundOne:
+ ld a, TRUE
ld [wScriptVar], a
ret
-asm_c3f2
+FoundNone:
xor a
ld [wScriptVar], a
ret
diff --git a/engine/color.asm b/engine/gfx/color.asm
index 05c13b2b..05c13b2b 100755
--- a/engine/color.asm
+++ b/engine/gfx/color.asm
diff --git a/items/item_effects.asm b/engine/items/item_effects.asm
index 274b8468..274b8468 100755
--- a/items/item_effects.asm
+++ b/engine/items/item_effects.asm
diff --git a/engine/items.asm b/engine/items/items.asm
index 428f652e..428f652e 100755
--- a/engine/items.asm
+++ b/engine/items/items.asm
diff --git a/engine/sine.asm b/engine/math/sine.asm
index e22d785a..e22d785a 100644
--- a/engine/sine.asm
+++ b/engine/math/sine.asm
diff --git a/engine/variables.asm b/engine/overworld/variables.asm
index 7e6906ee..7e6906ee 100755
--- a/engine/variables.asm
+++ b/engine/overworld/variables.asm
diff --git a/engine/pokemon/breedmon_level_growth.asm b/engine/pokemon/breedmon_level_growth.asm
new file mode 100644
index 00000000..c6356dd6
--- /dev/null
+++ b/engine/pokemon/breedmon_level_growth.asm
@@ -0,0 +1,27 @@
+GetBreedMon1LevelGrowth:
+ ld hl, wBreedMon1Stats
+ ld de, wTempMon
+ ld bc, BOXMON_STRUCT_LENGTH
+ call CopyBytes
+ callfar CalcLevel
+ ld a, [wBreedMon1Level]
+ ld b, a
+ ld a, d
+ ld e, a
+ sub b
+ ld d, a
+ ret
+
+GetBreedMon2LevelGrowth:
+ ld hl, wBreedMon2Stats
+ ld de, wTempMon
+ ld bc, BOXMON_STRUCT_LENGTH
+ call CopyBytes
+ callfar CalcLevel
+ ld a, [wBreedMon2Level]
+ ld b, a
+ ld a, d
+ ld e, a
+ sub b
+ ld d, a
+ ret
diff --git a/engine/health.asm b/engine/pokemon/health.asm
index a94a3ec3..a94a3ec3 100755
--- a/engine/health.asm
+++ b/engine/pokemon/health.asm
diff --git a/engine/pokemon/knows_move.asm b/engine/pokemon/knows_move.asm
new file mode 100644
index 00000000..9fe0f6ac
--- /dev/null
+++ b/engine/pokemon/knows_move.asm
@@ -0,0 +1,24 @@
+KnowsMove:
+ ld a, MON_MOVES
+ call GetPartyParamLocation
+ ld a, [wPutativeTMHMMove]
+ ld b, a
+ ld c, NUM_MOVES
+.loop
+ ld a, [hli]
+ cp b
+ jr z, .knows_move
+ dec c
+ jr nz, .loop
+ and a
+ ret
+
+.knows_move
+ ld hl, .KnowsMoveText
+ call PrintText
+ scf
+ ret
+
+.KnowsMoveText:
+ text_far _KnowsMoveText
+ text_end
diff --git a/engine/move_mon.asm b/engine/pokemon/move_mon.asm
index 7198910d..7198910d 100755
--- a/engine/move_mon.asm
+++ b/engine/pokemon/move_mon.asm
diff --git a/engine/pokemon/search2.asm b/engine/pokemon/search2.asm
new file mode 100644
index 00000000..c33d84ed
--- /dev/null
+++ b/engine/pokemon/search2.asm
@@ -0,0 +1,134 @@
+_FindPartyMonAboveLevel:
+ ld hl, wPartyMon1Level
+ call FindAboveLevel
+ ret
+
+_FindPartyMonAtLeastThatHappy:
+ ld hl, wPartyMon1Happiness
+ call FindAtLeastThatHappy
+ ret
+
+_FindPartyMonThatSpecies:
+ ld hl, wPartyMon1Species
+ jp FindThatSpecies
+
+_FindPartyMonThatSpeciesYourTrainerID:
+ ld hl, wPartyMon1Species
+ call FindThatSpecies
+ ret z
+ ld a, c
+ ld hl, wPartyMon1ID
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ ld a, [wPlayerID]
+ cp [hl]
+ jr nz, .nope
+ inc hl
+ ld a, [wPlayerID + 1]
+ cp [hl]
+ jr nz, .nope
+ ld a, $1
+ and a
+ ret
+
+.nope
+ xor a
+ ret
+
+FindAtLeastThatHappy:
+; Sets the bits for the Pokemon that have a happiness greater than or equal to b.
+; The lowest bits are used. Sets z if no Pokemon in your party is at least that happy.
+ ld c, $0
+ ld a, [wPartyCount]
+ ld d, a
+.loop
+ ld a, d
+ dec a
+ push hl
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld a, b
+ cp [hl]
+ pop hl
+ jr z, .greater_equal
+ jr nc, .lower
+
+.greater_equal
+ ld a, c
+ or $1
+ ld c, a
+
+.lower
+ sla c
+ dec d
+ jr nz, .loop
+ call RetroactivelyIgnoreEggs
+ ld a, c
+ and a
+ ret
+
+FindAboveLevel:
+ ld c, $0
+ ld a, [wPartyCount]
+ ld d, a
+.loop
+ ld a, d
+ dec a
+ push hl
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call AddNTimes
+ pop bc
+ ld a, b
+ cp [hl]
+ pop hl
+ jr c, .greater
+ ld a, c
+ or $1
+ ld c, a
+
+.greater
+ sla c
+ dec d
+ jr nz, .loop
+ call RetroactivelyIgnoreEggs
+ ld a, c
+ and a
+ ret
+
+FindThatSpecies:
+; Find species b in your party.
+; If you have no Pokemon, returns c = -1 and z.
+; If that species is in your party, returns its location in c, and nz.
+; Otherwise, returns z.
+ ld c, -1
+ ld hl, wPartySpecies
+.loop
+ ld a, [hli]
+ cp -1
+ ret z
+ inc c
+ cp b
+ jr nz, .loop
+ ld a, $1
+ and a
+ ret
+
+RetroactivelyIgnoreEggs:
+ ld e, %11111110
+ ld hl, wPartySpecies
+.loop
+ ld a, [hli]
+ cp -1
+ ret z
+ cp EGG
+ jr nz, .skip_notegg
+ ld a, c
+ and e
+ ld c, a
+
+.skip_notegg
+ rlc e
+ jr .loop
diff --git a/engine/smallflag.asm b/engine/smallflag.asm
new file mode 100644
index 00000000..f7d1406f
--- /dev/null
+++ b/engine/smallflag.asm
@@ -0,0 +1,74 @@
+Functionc660:
+ nop
+
+SmallFarFlagAction:
+; Perform action b on bit c in flag array hl.
+; If checking a flag, check flag array d:hl unless d is 0.
+
+; For longer flag arrays, see FlagAction.
+
+ push hl
+ push bc
+
+; Divide by 8 to get the byte we want.
+ push bc
+ srl c
+ srl c
+ srl c
+ ld b, 0
+ add hl, bc
+ pop bc
+
+; Which bit we want from the byte
+ ld a, c
+ and 7
+ ld c, a
+
+; Shift left until we can mask the bit
+ ld a, 1
+ jr z, .shifted
+.shift
+ add a
+ dec c
+ jr nz, .shift
+.shifted
+ ld c, a
+
+; What are we doing to this flag?
+ dec b
+ jr z, .set ; 1 = SET_FLAG
+ dec b
+ jr z, .check ; 2 = CHECK_FLAG
+; 0 = RESET_FLAG
+
+.reset
+ ld a, c
+ cpl
+ and [hl]
+ ld [hl], a
+ jr .done
+
+.set
+ ld a, [hl]
+ or c
+ ld [hl], a
+ jr .done
+
+.check
+ ld a, d
+ cp 0
+ jr nz, .farcheck
+
+ ld a, [hl]
+ and c
+ jr .done
+
+.farcheck
+ call GetFarByte
+ and c
+
+.done
+ pop bc
+ pop hl
+ ld c, a
+ ret
diff --git a/engine/tilesets/map_palettes.asm b/engine/tilesets/map_palettes.asm
new file mode 100644
index 00000000..0c45cf57
--- /dev/null
+++ b/engine/tilesets/map_palettes.asm
@@ -0,0 +1,110 @@
+_SwapTextboxPalettes::
+ ld hl, wTilemap
+ ld de, wAttrmap
+ ld b, SCREEN_HEIGHT
+.loop
+ ld c, SCREEN_WIDTH
+.innerloop
+ ld a, [hli]
+ push hl
+ srl a
+ jr c, .UpperNybble
+ ld hl, wTilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [wTilesetPalettes + 1]
+ adc 0
+ ld h, a
+ ld a, [hl]
+ and $f
+ bit 3, a
+ jr z, .next
+ jr .asm_8038
+
+.UpperNybble:
+ ld hl, wTilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [wTilesetPalettes + 1]
+ adc 0
+ ld h, a
+ ld a, [hl]
+ swap a
+ and $f
+ bit 3, a
+ jr z, .next
+
+.asm_8038
+ ld a, [wMapGroup]
+ dec a
+ ld hl, Unknown85d7
+ add l
+ ld l, a
+ jr nc, .asm_8044
+ inc h
+.asm_8044
+ ld a, [hl]
+
+.next
+ pop hl
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .innerloop
+ dec b
+ jr nz, .loop
+ ret
+
+_ScrollBGMapPalettes::
+ ld hl, wBGMapBuffer
+ ld de, wBGMapPalBuffer
+.loop
+ ld a, [hli]
+ push hl
+ srl a
+ jr c, .UpperNybble
+
+; .LowerNybble
+ ld hl, wTilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [wTilesetPalettes + 1]
+ adc 0
+ ld h, a
+ ld a, [hl]
+ and $f
+ bit 3, a
+ jr z, .next
+ jr .asm_8083
+
+.UpperNybble:
+ ld hl, wTilesetPalettes
+ add [hl]
+ ld l, a
+ ld a, [wTilesetPalettes + 1]
+ adc 0
+ ld h, a
+ ld a, [hl]
+ swap a
+ and $f
+ bit 3, a
+ jr z, .next
+
+.asm_8083
+ ld a, [wMapGroup]
+ dec a
+ ld hl, Unknown85d7
+ add l
+ ld l, a
+ jr nc, .asm_808f
+ inc h
+.asm_808f
+ ld a, [hl]
+
+.next
+ pop hl
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop
+ ret
diff --git a/gfx/tileset_palette_maps.asm b/gfx/tileset_palette_maps.asm
new file mode 100644
index 00000000..e814fbae
--- /dev/null
+++ b/gfx/tileset_palette_maps.asm
@@ -0,0 +1,6 @@
+INCLUDE "gfx/tilesets/palette_maps.asm"
+
+Unknown85d7:
+ rept 26 ; NUM_MAP_GROUPS
+ db PAL_BG_ROOF
+ endr
diff --git a/main.asm b/main.asm
index 36b63704..07dd24fe 100644
--- a/main.asm
+++ b/main.asm
@@ -17,431 +17,36 @@ INCLUDE "engine/events/happiness_egg.asm"
INCLUDE "engine/events/shuckle.asm"
INCLUDE "engine/events/haircut.asm"
-SECTION "bank2", ROMX, BANK[$2]
-_SwapTextboxPalettes::
- ld hl, wTilemap
- ld de, wAttrmap
- ld b, $12
-.asm_8008
- ld c, $14
-.asm_800a
- ld a, [hli]
- push hl
- srl a
- jr c, .asm_8024
- ld hl, wTilesetPalettes
- add [hl]
- ld l, a
- ld a, [wTilesetPalettes + 1]
- adc $0
- ld h, a
- ld a, [hl]
- and $f
- bit 3, a
- jr z, .asm_8045
- jr .asm_8038
-
-.asm_8024
- ld hl, wTilesetPalettes
- add [hl]
- ld l, a
- ld a, [wTilesetPalettes + 1]
- adc $0
- ld h, a
- ld a, [hl]
- swap a
- and $f
- bit 3, a
- jr z, .asm_8045
-.asm_8038
- ld a, [wMapGroup]
- dec a
- ld hl, Unknown85d7
- add l
- ld l, a
- jr nc, .asm_8044
- inc h
-.asm_8044
- ld a, [hl]
-.asm_8045
- pop hl
- ld [de], a
- inc de
- dec c
- jr nz, .asm_800a
- dec b
- jr nz, .asm_8008
- ret
-
-_ScrollBGMapPalettes:: ; 804f (2:404f)
- ld hl, wBGMapBuffer
- ld de, wBGMapPalBuffer
-.asm_8055
- ld a, [hli]
- push hl
- srl a
- jr c, .asm_806f
- ld hl, wTilesetPalettes
- add [hl]
- ld l, a
- ld a, [wTilesetPalettes + 1]
- adc $0
- ld h, a
- ld a, [hl]
- and $f
- bit 3, a
- jr z, .asm_8090
- jr .asm_8083
-
-.asm_806f
- ld hl, wTilesetPalettes
- add [hl]
- ld l, a
- ld a, [wTilesetPalettes + 1]
- adc $0
- ld h, a
- ld a, [hl]
- swap a
- and $f
- bit 3, a
- jr z, .asm_8090
-.asm_8083
- ld a, [wMapGroup]
- dec a
- ld hl, Unknown85d7
- add l
- ld l, a
- jr nc, .asm_808f
- inc h
-.asm_808f
- ld a, [hl]
-.asm_8090
- pop hl
- ld [de], a
- inc de
- dec c
- jr nz, .asm_8055
- ret
-
-INCLUDE "gfx/tilesets/palette_maps.asm"
-
-Unknown85d7:
- rept 26 ; NUM_MAP_GROUPS
- db PAL_BG_ROOF
- endr
+SECTION "bank2", ROMX
+INCLUDE "engine/tilesets/map_palettes.asm"
+INCLUDE "gfx/tileset_palette_maps.asm"
INCLUDE "engine/overworld/player_object.asm"
-INCLUDE "engine/sine.asm"
+INCLUDE "engine/math/sine.asm"
INCLUDE "engine/predef.asm"
-INCLUDE "engine/color.asm"
-
-SECTION "bank3", ROMX, BANK[$3]
-CheckTime::
- ld a, [wTimeOfDay]
- ld hl, TimeOfDayTable
- ld de, $2
- call IsInArray
- inc hl
- ld c, [hl]
- ret c
- xor a
- ld c, a
- ret
-
-TimeOfDayTable:
- db MORN_F, MORN
- db DAY_F, DAY
- db NITE_F, NITE
- db NITE_F, NITE
- db -1
+INCLUDE "engine/gfx/color.asm"
-INCLUDE "engine/engine_flags.asm"
-INCLUDE "engine/variables.asm"
-INCLUDE "engine/specials.asm"
-
-Functionc660:
- nop
-SmallFarFlagAction:
- push hl
- push bc
- push bc
- srl c
- srl c
- srl c
- ld b, $0
- add hl, bc
- pop bc
- ld a, c
- and $7
- ld c, a
- ld a, $1
- jr z, .asm_c67a
-.asm_c676
- add a
- dec c
- jr nz, .asm_c676
-.asm_c67a
- ld c, a
- dec b
- jr z, .asm_c687
- dec b
- jr z, .asm_c68c
- ld a, c
- cpl
- and [hl]
- ld [hl], a
- jr .asm_c699
-
-.asm_c687
- ld a, [hl]
- or c
- ld [hl], a
- jr .asm_c699
-
-.asm_c68c
- ld a, d
- cp $0
- jr nz, .asm_c695
- ld a, [hl]
- and c
- jr .asm_c699
-
-.asm_c695
- call GetFarByte
- and c
-.asm_c699
- pop bc
- pop hl
- ld c, a
- ret
+SECTION "bank3", ROMX
-INCLUDE "engine/health.asm"
+INCLUDE "engine/events/checktime.asm"
+INCLUDE "engine/events/engine_flags.asm"
+INCLUDE "engine/overworld/variables.asm"
+INCLUDE "engine/events/specials.asm"
+INCLUDE "engine/smallflag.asm"
+INCLUDE "engine/pokemon/health.asm"
INCLUDE "engine/events/overworld.asm"
-INCLUDE "engine/items.asm"
+INCLUDE "engine/items/items.asm"
INCLUDE "engine/overworld/player_step.asm"
-INCLUDE "engine/anim_hp_bar.asm"
-INCLUDE "engine/move_mon.asm"
+INCLUDE "engine/battle/anim_hp_bar.asm"
+INCLUDE "engine/pokemon/move_mon.asm"
INCLUDE "engine/pokemon/bills_pc_top.asm"
+INCLUDE "engine/pokemon/breedmon_level_growth.asm"
+INCLUDE "engine/pokemon/search2.asm"
+INCLUDE "engine/events/bug_contest/caught_mon.asm"
+INCLUDE "engine/items/item_effects.asm"
+INCLUDE "engine/pokemon/knows_move.asm"
-GetBreedMon1LevelGrowth:
- ld hl, wBreedMon1Species
- ld de, wTempMonSpecies
- ld bc, $20
- call CopyBytes
- callfar CalcLevel
- ld a, [wBreedMon1Level]
- ld b, a
- ld a, d
- ld e, a
- sub b
- ld d, a
- ret
-
-GetBreedMon2LevelGrowth:
- ld hl, wBreedMon2Species
- ld de, wTempMon
- ld bc, $20
- call CopyBytes
- callfar CalcLevel
- ld a, [wBreedMon2Level]
- ld b, a
- ld a, d
- ld e, a
- sub b
- ld d, a
- ret
-
-PartySearch_MaximumLevel: ; e6a9 (3:66a9)
- ld hl, wPartyMon1Level
- call PartySearch_LessThanValue
- ret
-
-PartySearch_MinimumHappiness: ; e6b0 (3:66b0)
- ld hl, wPartyMon1Happiness
- call PartySearch_GreaterThanOrEqualToValue
- ret
-
-PartySearch_SameSpecies: ; e6b7 (3:66b7)
- ld hl, wPartyMons
- jp PartySearch_GetIndexOfSpeciesInParty
-
-PartySearch_SameSpeciesAndYourID: ; e6bd (3:66bd)
- ld hl, wPartyMon1
- call PartySearch_GetIndexOfSpeciesInParty
- ret z
- ld a, c
- ld hl, wPartyMon1ID
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- ld a, [wPlayerID]
- cp [hl]
- jr nz, .nope
- inc hl
- ld a, [wPlayerID + 1]
- cp [hl]
- jr nz, .nope
- ld a, $1
- and a
- ret
-
-.nope
- xor a
- ret
-
-PartySearch_GreaterThanOrEqualToValue: ; e6e1 (3:66e1)
- ld c, $0
- ld a, [wPartyCount]
- ld d, a
-.loop
- ld a, d
- dec a
- push hl
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- pop bc
- ld a, b
- cp [hl]
- pop hl
- jr z, .shift
- jr nc, .skip
-.shift
- ld a, c
- or $1
- ld c, a
-.skip
- sla c
- dec d
- jr nz, .loop
- call PartySearch_FilterEggs
- ld a, c
- and a
- ret
-
-PartySearch_LessThanValue: ; e708 (3:6708)
- ld c, $0
- ld a, [wPokemonData]
- ld d, a
-.loop
- ld a, d
- dec a
- push hl
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- call AddNTimes
- pop bc
- ld a, b
- cp [hl]
- pop hl
- jr c, .skip
- ld a, c
- or $1
- ld c, a
-.skip
- sla c
- dec d
- jr nz, .loop
- call PartySearch_FilterEggs
- ld a, c
- and a
- ret
-
-PartySearch_GetIndexOfSpeciesInParty: ; e72d (3:672d)
- ld c, -1
- ld hl, wPartySpecies
-.loop
- ld a, [hli]
- cp $ff
- ret z
- inc c
- cp b
- jr nz, .loop
- ld a, $1
- and a
- ret
-
-PartySearch_FilterEggs: ; e73e (3:673e)
- ld e, $FF ^ 1
- ld hl, wPartySpecies
-.loop
- ld a, [hli]
- cp $ff
- ret z
- cp EGG
- jr nz, .not_egg
- ld a, c
- and e
- ld c, a
-.not_egg
- rlc e
- jr .loop
-
-BugContest_SetCaughtContestMon:
- ld a, [wContestMonSpecies]
- and a
- jr z, .asm_e76e
- ld [wd151], a
- farcall DisplayAlreadyCaughtText
- farcall DisplayCaughtContestMonStats
- lb bc, 14, 7
- call PlaceYesNoBox
- ret c
-.asm_e76e
- call GenerateBugContestMonStats
- ld a, [wTempEnemyMonSpecies]
- ld [wd151], a
- call GetPokemonName
- ld hl, Text_CaughtBugMon
- call PrintText
- ret
-
-GenerateBugContestMonStats: ; e781 (3:6781)
- ld a, [wTempEnemyMonSpecies]
- ld [wCurSpecies], a
- ld [wCurPartySpecies], a
- call GetBaseData
- xor a
- ld bc, PARTYMON_STRUCT_LENGTH
- ld hl, wContestMon
- call ByteFill
- xor a
- ld [wMonType], a
- ld hl, wContestMon
- jp GeneratePartyMonStats
-
-Text_CaughtBugMon:
- ; Caught @ !
- text_far Text_CaughtBugMon_
- db "@"
-
-INCLUDE "items/item_effects.asm"
-
-KnowsMove:
- ld a, MON_MOVES
- call GetPartyParamLocation
- ld a, [wPutativeTMHMMove]
- ld b, a
- ld c, $4
-.asm_fa28
- ld a, [hli]
- cp b
- jr z, .asm_fa31
- dec c
- jr nz, .asm_fa28
- and a
- ret
-
-.asm_fa31
- ld hl, Text_KnowsMove
- call PrintText
- scf
- ret
-
-Text_KnowsMove:
- text_far Text_KnowsMove_
- db "@"
-
-SECTION "bank4", ROMX, BANK[$4]
+SECTION "bank4", ROMX
INCLUDE "engine/overworld/player_movement.asm"
INCLUDE "engine/items/pack.asm"
diff --git a/pokegold.link b/pokegold.link
index 5eb704f5..7537b5f4 100644
--- a/pokegold.link
+++ b/pokegold.link
@@ -30,16 +30,12 @@ ROM0
org $0150
"Home"
ROMX $01
- org $4000
"bank1"
ROMX $02
- org $4000
"bank2"
ROMX $03
- org $4000
"bank3"
ROMX $04
- org $4000
"bank4"
ROMX $05
org $4000
diff --git a/pokesilver.link b/pokesilver.link
index 5eb704f5..7537b5f4 100644
--- a/pokesilver.link
+++ b/pokesilver.link
@@ -30,16 +30,12 @@ ROM0
org $0150
"Home"
ROMX $01
- org $4000
"bank1"
ROMX $02
- org $4000
"bank2"
ROMX $03
- org $4000
"bank3"
ROMX $04
- org $4000
"bank4"
ROMX $05
org $4000