event/ → events/, and move some appropriate engine/ files there

This commit is contained in:
Remy Oukaour
2017-12-26 21:55:57 -05:00
parent 2a565f747c
commit dae16acd6f
66 changed files with 104 additions and 103 deletions

View File

@@ -1,31 +0,0 @@
TalkToTrainerScript:: ; 0xbe66a
faceplayer
trainerflagaction CHECK_FLAG
iftrue AlreadyBeatenTrainerScript
loadmemtrainer
encountermusic
jump StartBattleWithMapTrainerScript
SeenByTrainerScript:: ; 0xbe675
loadmemtrainer
encountermusic
showemote EMOTE_SHOCK, LAST_TALKED, 30
callasm TrainerWalkToPlayer
applymovement2 MovementBuffer
writeobjectxy LAST_TALKED
faceobject PLAYER, LAST_TALKED
jump StartBattleWithMapTrainerScript
StartBattleWithMapTrainerScript: ; 0xbe68a
opentext
trainertext $0
waitbutton
closetext
loadmemtrainer
startbattle
reloadmapafterbattle
trainerflagaction SET_FLAG
loadvar wRunningTrainerBattleScript, -1
AlreadyBeatenTrainerScript:
scripttalkafter

View File

@@ -1,133 +0,0 @@
Fish: ; 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
ld b, e
call GetFishGroupIndex
ld hl, FishGroups
rept 7
add hl, de
endr
call .Fish
pop hl
pop bc
pop af
ret
; 9241a
.Fish: ; 9241a
; Fish for monsters with rod b from encounter data in FishGroup at hl.
; Return monster e at level d.
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, [TimeOfDay]
and 3
cp NITE_F
jr c, .time_species
inc hl
inc hl
.time_species
ld d, [hl]
inc hl
ret
; 9245b
GetFishGroupIndex: ; 9245b
; Return the index of fishgroup d in de.
push hl
ld hl, DailyFlags
bit 2, [hl]
pop hl
jr z, .done
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
; 92488
INCLUDE "data/wild/fish.asm"

View File

@@ -1,132 +0,0 @@
FruitTreeScript:: ; 44000
callasm GetCurTreeFruit
opentext
copybytetovar CurFruit
itemtotext $0, $0
writetext FruitBearingTreeText
buttonsound
callasm TryResetFruitTrees
callasm CheckFruitTree
iffalse .fruit
writetext NothingHereText
waitbutton
jump .end
.fruit
writetext HeyItsFruitText
copybytetovar CurFruit
giveitem ITEM_FROM_MEM
iffalse .packisfull
buttonsound
writetext ObtainedFruitText
callasm PickedFruitTree
specialsound
itemnotify
jump .end
.packisfull
buttonsound
writetext FruitPackIsFullText
waitbutton
.end
closetext
end
; 44041
GetCurTreeFruit: ; 44041
ld a, [CurFruitTree]
dec a
call GetFruitTreeItem
ld [CurFruit], a
ret
; 4404c
TryResetFruitTrees: ; 4404c
ld hl, DailyFlags
bit 4, [hl]
ret nz
jp ResetFruitTrees
; 44055
CheckFruitTree: ; 44055
ld b, 2
call GetFruitTreeFlag
ld a, c
ld [ScriptVar], a
ret
; 4405f
PickedFruitTree: ; 4405f
farcall TrainerRankings_FruitPicked
ld b, 1
jp GetFruitTreeFlag
; 4406a
ResetFruitTrees: ; 4406a
xor a
ld hl, FruitTreeFlags
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, DailyFlags
set 4, [hl]
ret
; 44078
GetFruitTreeFlag: ; 44078
push hl
push de
ld a, [CurFruitTree]
dec a
ld e, a
ld d, 0
ld hl, FruitTreeFlags
call FlagAction
pop de
pop hl
ret
; 4408a
GetFruitTreeItem: ; 4408a
push hl
push de
ld e, a
ld d, 0
ld hl, FruitTreeItems
add hl, de
ld a, [hl]
pop de
pop hl
ret
; 44097
INCLUDE "data/items/fruit_trees.asm"
FruitBearingTreeText: ; 440b5
text_jump _FruitBearingTreeText
db "@"
; 440ba
HeyItsFruitText: ; 440ba
text_jump _HeyItsFruitText
db "@"
; 440bf
ObtainedFruitText: ; 440bf
text_jump _ObtainedFruitText
db "@"
; 440c4
FruitPackIsFullText: ; 440c4
text_jump _FruitPackIsFullText
db "@"
; 440c9
NothingHereText: ; 440c9
text_jump _NothingHereText
db "@"
; 440ce

View File

@@ -71,45 +71,7 @@ ShowPlayerNamingChoices: ; 88297
call CloseWindow
ret
ChrisNameMenuHeader: ; 882b5
db $40 ; flags
db 00, 00 ; start coords
db 11, 10 ; end coords
dw .MaleNames
db 1 ; ????
db 0 ; default option
.MaleNames: ; 882be
db $91 ; flags
db 5 ; items
db "NEW NAME@"
MalePlayerNameArray: ; 882c9
db "CHRIS@"
db "MAT@"
db "ALLAN@"
db "JON@"
db 2 ; displacement
db " NAME @" ; title
KrisNameMenuHeader: ; 882e5
db $40 ; flags
db 00, 00 ; start coords
db 11, 10 ; end coords
dw .FemaleNames
db 1 ; ????
db 0 ; default option
.FemaleNames: ; 882ee
db $91 ; flags
db 5 ; items
db "NEW NAME@"
FemalePlayerNameArray: ; 882f9
db "KRIS@"
db "AMANDA@"
db "JUANA@"
db "JODI@"
db 2 ; displacement
db " NAME @" ; title
INCLUDE "data/default_names.asm"
GetPlayerNameArray: ; 88318 This Function is never called
ld hl, PlayerName

File diff suppressed because it is too large Load Diff

View File

@@ -1,49 +0,0 @@
Pokepic:: ; 244e3
ld hl, PokepicMenuDataHeader
call CopyMenuDataHeader
call MenuBox
call UpdateSprites
call ApplyTilemap
ld b, SCGB_POKEPIC
call GetSGBLayout
xor a
ld [hBGMapMode], a
ld a, [CurPartySpecies]
ld [CurSpecies], a
call GetBaseData
ld de, VTiles1
predef GetMonFrontpic
ld a, [wMenuBorderTopCoord]
inc a
ld b, a
ld a, [wMenuBorderLeftCoord]
inc a
ld c, a
call Coord2Tile
ld a, $80
ld [hGraphicStartTile], a
lb bc, 7, 7
predef PlaceGraphic
call WaitBGMap
ret
ClosePokepic:: ; 24528
ld hl, PokepicMenuDataHeader
call CopyMenuDataHeader
call ClearMenuBoxInterior
call WaitBGMap
call GetMemSGBLayout
xor a
ld [hBGMapMode], a
call OverworldTextModeSwitch
call ApplyTilemap
call UpdateSprites
call LoadStandardFont
ret
PokepicMenuDataHeader: ; 0x24547
db $40 ; flags
db 04, 06 ; start coords
db 13, 14 ; end coords
dw NULL
db 1 ; default option

View File

@@ -1,26 +0,0 @@
ApplyPokerusTick: ; 13988
; decreases all pokemon's pokerus counter by b. if the lower nybble reaches zero, the pokerus is cured.
ld hl, PartyMon1PokerusStatus ; PartyMon1 + MON_PKRS
ld a, [PartyCount]
and a
ret z ; make sure it's not wasting time on an empty party
ld c, a
.loop
ld a, [hl]
and $f ; lower nybble is the number of days remaining
jr z, .next ; if already 0, skip
sub b ; subtract the number of days
jr nc, .ok ; max(result, 0)
xor a
.ok
ld d, a ; back up this value because we need to preserve the strain (upper nybble)
ld a, [hl]
and $f0
add d
ld [hl], a ; this prevents a cured pokemon from recontracting pokerus
.next
ld de, PARTYMON_STRUCT_LENGTH
add hl, de
dec c
jr nz, .loop
ret

View File

@@ -1,25 +0,0 @@
CheckPokerus: ; 4d860
; Return carry if a monster in your party has Pokerus
; Get number of monsters to iterate over
ld a, [PartyCount]
and a
jr z, .NoPokerus
ld b, a
; Check each monster in the party for Pokerus
ld hl, PartyMon1PokerusStatus
ld de, PARTYMON_STRUCT_LENGTH
.Check:
ld a, [hl]
and $0f ; only the bottom nybble is used
jr nz, .HasPokerus
; Next PartyMon
add hl, de
dec b
jr nz, .Check
.NoPokerus:
and a
ret
.HasPokerus:
scf
ret

View File

@@ -1,160 +0,0 @@
GivePokerusAndConvertBerries: ; 2ed44
call ConvertBerriesToBerryJuice
ld hl, PartyMon1PokerusStatus
ld a, [PartyCount]
ld b, a
ld de, PARTYMON_STRUCT_LENGTH
; Check to see if any of your Pokemon already has Pokerus.
; If so, sample its spread through your party.
; This means that you cannot get Pokerus de novo while
; a party member has an active infection.
.loopMons
ld a, [hl]
and $f
jr nz, .TrySpreadPokerus
add hl, de
dec b
jr nz, .loopMons
; If we haven't been to Goldenrod City at least once,
; prevent the contraction of Pokerus.
ld hl, StatusFlags2
bit 6, [hl]
ret z
call Random
ld a, [hRandomAdd]
and a
ret nz
ld a, [hRandomSub]
cp $3
ret nc ; 3/65536 chance (00 00, 00 01 or 00 02)
ld a, [PartyCount]
ld b, a
.randomMonSelectLoop
call Random
and $7
cp b
jr nc, .randomMonSelectLoop
ld hl, PartyMon1PokerusStatus
call GetPartyLocation ; get pokerus byte of random mon
ld a, [hl]
and $f0
ret nz ; if it already has pokerus, do nothing
.randomPokerusLoop ; Simultaneously sample the strain and duration
call Random
and a
jr z, .randomPokerusLoop
ld b, a
and $f0
jr z, .load_pkrs
ld a, b
and $7
inc a
.load_pkrs
ld b, a ; this should come before the label
swap b
and $3
inc a
add b
ld [hl], a
ret
.TrySpreadPokerus:
call Random
cp 1 + 33 percent
ret nc ; 1/3 chance
ld a, [PartyCount]
cp 1
ret z ; only one mon, nothing to do
ld c, [hl]
ld a, b
cp 2
jr c, .checkPreviousMonsLoop ; no more mons after this one, go backwards
call Random
cp 1 + 50 percent
jr c, .checkPreviousMonsLoop ; 1/2 chance, go backwards
.checkFollowingMonsLoop
add hl, de
ld a, [hl]
and a
jr z, .infectMon
ld c, a
and $3
ret z ; if mon has cured pokerus, stop searching
dec b ; go on to next mon
ld a, b
cp 1
jr nz, .checkFollowingMonsLoop ; no more mons left
ret
.checkPreviousMonsLoop
ld a, [PartyCount]
cp b
ret z ; no more mons
ld a, l
sub e
ld l, a
ld a, h
sbc d
ld h, a
ld a, [hl]
and a
jr z, .infectMon
ld c, a
and $3
ret z ; if mon has cured pokerus, stop searching
inc b ; go on to next mon
jr .checkPreviousMonsLoop
.infectMon
ld a, c
and $f0
ld b, a
ld a, c
swap a
and $3
inc a
add b
ld [hl], a
ret
; any berry held by a Shuckle may be converted to berry juice
ConvertBerriesToBerryJuice: ; 2ede6
ld hl, StatusFlags2
bit 6, [hl]
ret z
call Random
cp $10
ret nc ; 1/16 chance
ld hl, PartyMons
ld a, [PartyCount]
.partyMonLoop
push af
push hl
ld a, [hl]
cp SHUCKLE
jr nz, .loopMon
ld bc, MON_ITEM
add hl, bc
ld a, [hl]
cp BERRY
jr z, .convertToJuice
.loopMon
pop hl
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop af
dec a
jr nz, .partyMonLoop
ret
.convertToJuice
ld a, BERRY_JUICE
ld [hl], a
pop hl
pop af
ret

View File

@@ -1,213 +0,0 @@
ProfOaksPC: ; 0x265d3
ld hl, OakPCText1
call MenuTextBox
call YesNoBox
jr c, .shutdown
call ProfOaksPCBoot ; player chose "yes"?
.shutdown
ld hl, OakPCText4
call PrintText
call JoyWaitAorB
call ExitMenu
ret
ProfOaksPCBoot ; 0x265ee
ld hl, OakPCText2
call PrintText
call Rate
call PlaySFX ; sfx loaded by previous Rate function call
call JoyWaitAorB
call WaitSFX
ret
ProfOaksPCRating: ; 0x26601
call Rate
push de
ld de, MUSIC_NONE
call PlayMusic
pop de
call PlaySFX
call JoyWaitAorB
call WaitSFX
ret
Rate: ; 0x26616
; calculate Seen/Owned
ld hl, PokedexSeen
ld b, EndPokedexSeen - PokedexSeen
call CountSetBits
ld [wd002], a
ld hl, PokedexCaught
ld b, EndPokedexCaught - PokedexCaught
call CountSetBits
ld [wd003], a
; print appropriate rating
call .UpdateRatingBuffers
ld hl, OakPCText3
call PrintText
call JoyWaitAorB
ld a, [wd003]
ld hl, OakRatings
call FindOakRating
push de
call PrintText
pop de
ret
.UpdateRatingBuffers: ; 0x26647
ld hl, StringBuffer3
ld de, wd002
call .UpdateRatingBuffer
ld hl, StringBuffer4
ld de, wd003
call .UpdateRatingBuffer
ret
.UpdateRatingBuffer: ; 0x2665a
push hl
ld a, "@"
ld bc, ITEM_NAME_LENGTH
call ByteFill
pop hl
lb bc, PRINTNUM_RIGHTALIGN | 1, 3
call PrintNum
ret
FindOakRating: ; 0x2666b
; return sound effect in de
; return text pointer in hl
nop
ld c, a
.loop
ld a, [hli]
cp c
jr nc, .match
rept 4
inc hl
endr
jr .loop
.match
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld h, [hl]
ld l, a
ret
OakRatings: ; 0x2667f
; if you caught at most this many, play this sound, load this text
dbww 9, SFX_DEX_FANFARE_LESS_THAN_20, OakRating01
dbww 19, SFX_DEX_FANFARE_LESS_THAN_20, OakRating02
dbww 34, SFX_DEX_FANFARE_20_49, OakRating03
dbww 49, SFX_DEX_FANFARE_20_49, OakRating04
dbww 64, SFX_DEX_FANFARE_50_79, OakRating05
dbww 79, SFX_DEX_FANFARE_50_79, OakRating06
dbww 94, SFX_DEX_FANFARE_80_109, OakRating07
dbww 109, SFX_DEX_FANFARE_80_109, OakRating08
dbww 124, SFX_CAUGHT_MON, OakRating09
dbww 139, SFX_CAUGHT_MON, OakRating10
dbww 154, SFX_DEX_FANFARE_140_169, OakRating11
dbww 169, SFX_DEX_FANFARE_140_169, OakRating12
dbww 184, SFX_DEX_FANFARE_170_199, OakRating13
dbww 199, SFX_DEX_FANFARE_170_199, OakRating14
dbww 214, SFX_DEX_FANFARE_200_229, OakRating15
dbww 229, SFX_DEX_FANFARE_200_229, OakRating16
dbww 239, SFX_DEX_FANFARE_230_PLUS, OakRating17
dbww 248, SFX_DEX_FANFARE_230_PLUS, OakRating18
dbww 255, SFX_DEX_FANFARE_230_PLUS, OakRating19
OakPCText1: ; 0x266de
text_jump _OakPCText1
db "@"
OakPCText2: ; 0x266e3
text_jump _OakPCText2
db "@"
OakPCText3: ; 0x266e8
text_jump _OakPCText3
db "@"
OakRating01:
text_jump _OakRating01
db "@"
OakRating02:
text_jump _OakRating02
db "@"
OakRating03:
text_jump _OakRating03
db "@"
OakRating04:
text_jump _OakRating04
db "@"
OakRating05:
text_jump _OakRating05
db "@"
OakRating06:
text_jump _OakRating06
db "@"
OakRating07:
text_jump _OakRating07
db "@"
OakRating08:
text_jump _OakRating08
db "@"
OakRating09:
text_jump _OakRating09
db "@"
OakRating10:
text_jump _OakRating10
db "@"
OakRating11:
text_jump _OakRating11
db "@"
OakRating12:
text_jump _OakRating12
db "@"
OakRating13:
text_jump _OakRating13
db "@"
OakRating14:
text_jump _OakRating14
db "@"
OakRating15:
text_jump _OakRating15
db "@"
OakRating16:
text_jump _OakRating16
db "@"
OakRating17:
text_jump _OakRating17
db "@"
OakRating18:
text_jump _OakRating18
db "@"
OakRating19:
text_jump _OakRating19
db "@"
OakPCText4: ; 0x2674c
text_jump _OakPCText4
db "@"

View File

@@ -1,4 +1,3 @@
Special:: ; c01b
; Run script special de.
ld hl, SpecialsPointers

File diff suppressed because it is too large Load Diff