Cleanup of files for banks $02 and $03 for main.asm.

This commit is contained in:
entrpntr 2020-03-17 16:20:00 -04:00
parent c248b30aa7
commit e67786a7a2
23 changed files with 473 additions and 445 deletions

View File

@ -580,7 +580,7 @@ Text_CantTakeAnyMorePokemon_::
line "more #MON."
prompt
Text_CaughtBugMon_::
_ContestCaughtMonText::
text "Caught @"
text_ram wStringBuffer1
text "!"

View File

@ -445,7 +445,7 @@ Text_GotOffItem_::
text "."
prompt
Text_KnowsMove_::
_KnowsMoveText::
text_ram wStringBuffer1
text " knows"
line "@"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

134
engine/pokemon/search2.asm Normal file
View File

@ -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

74
engine/smallflag.asm Normal file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1,6 @@
INCLUDE "gfx/tilesets/palette_maps.asm"
Unknown85d7:
rept 26 ; NUM_MAP_GROUPS
db PAL_BG_ROOF
endr

437
main.asm
View File

@ -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"
INCLUDE "engine/gfx/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
SECTION "bank3", ROMX
TimeOfDayTable:
db MORN_F, MORN
db DAY_F, DAY
db NITE_F, NITE
db NITE_F, NITE
db -1
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
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"

View File

@ -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

View File

@ -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