Add space between arguments in assembly instructions and remove redundant a in instructions like add a, x

This commit is contained in:
xCrystal 2017-12-30 01:54:27 +01:00
parent 94b9a86c8b
commit 237aeb8fbd
50 changed files with 7221 additions and 7221 deletions

View file

@ -47,61 +47,61 @@ FadeInCreditsText:
DisplayCreditsMon: DisplayCreditsMon:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
call FillMiddleOfScreenWithWhite call FillMiddleOfScreenWithWhite
; display the next monster from CreditsMons ; display the next monster from CreditsMons
ld hl,wNumCreditsMonsDisplayed ld hl, wNumCreditsMonsDisplayed
ld c,[hl] ; how many monsters have we displayed so far? ld c, [hl] ; how many monsters have we displayed so far?
inc [hl] inc [hl]
ld b,0 ld b, 0
ld hl,CreditsMons ld hl, CreditsMons
add hl,bc ; go that far in the list of monsters and get the next one add hl, bc ; go that far in the list of monsters and get the next one
ld a,[hl] ld a, [hl]
ld [wcf91],a ld [wcf91], a
ld [wd0b5],a ld [wd0b5], a
coord hl, 8, 6 coord hl, 8, 6
call GetMonHeader call GetMonHeader
call LoadFrontSpriteByMonIndex call LoadFrontSpriteByMonIndex
ld hl,vBGMap0 + $c ld hl, vBGMap0 + $c
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld hl,vBGMap0 ld hl, vBGMap0
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
ld a,$A7 ld a, $A7
ld [rWX],a ld [rWX], a
ld hl,vBGMap1 ld hl, vBGMap1
call CreditsCopyTileMapToVRAM call CreditsCopyTileMapToVRAM
call FillMiddleOfScreenWithWhite call FillMiddleOfScreenWithWhite
ld a,%11111100 ; make the mon a black silhouette ld a, %11111100 ; make the mon a black silhouette
ld [rBGP],a ld [rBGP], a
; scroll the mon left by one tile 7 times ; scroll the mon left by one tile 7 times
ld bc,7 ld bc, 7
.scrollLoop1 .scrollLoop1
call ScrollCreditsMonLeft call ScrollCreditsMonLeft
dec c dec c
jr nz,.scrollLoop1 jr nz, .scrollLoop1
; scroll the mon left by one tile 20 times ; scroll the mon left by one tile 20 times
; This time, we have to move the window left too in order to hide the text that ; This time, we have to move the window left too in order to hide the text that
; is wrapping around to the right side of the screen. ; is wrapping around to the right side of the screen.
ld c,20 ld c, 20
.scrollLoop2 .scrollLoop2
call ScrollCreditsMonLeft call ScrollCreditsMonLeft
ld a,[rWX] ld a, [rWX]
sub 8 sub 8
ld [rWX],a ld [rWX], a
dec c dec c
jr nz,.scrollLoop2 jr nz, .scrollLoop2
xor a xor a
ld [hWY],a ld [hWY], a
ld a,%11000000 ld a, %11000000
ld [rBGP],a ld [rBGP], a
ret ret
INCLUDE "data/credit_mons.asm" INCLUDE "data/credit_mons.asm"

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
DecrementPP: DecrementPP:
; after using a move, decrement pp in battle and (if not transformed?) in party ; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de] ld a, [de]
cp a, STRUGGLE cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle" ; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1 ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; wPlayerBattleStatus2 status flags later ; wPlayerBattleStatus2 status flags later
and a, (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES) and (1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << ATTACKING_MULTIPLE_TIMES)
ret nz ; if any of these statuses are true, don't decrement PP ret nz ; if any of these statuses are true, don't decrement PP
bit USING_RAGE, [hl] bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage ret nz ; don't decrement PP either if Pokemon is using Rage

View file

@ -1,7 +1,7 @@
DisplayEffectiveness: DisplayEffectiveness:
ld a, [wDamageMultipliers] ld a, [wDamageMultipliers]
and a, $7F and $7F
cp a, $0A cp $0A
ret z ret z
ld hl, SuperEffectiveText ld hl, SuperEffectiveText
jr nc, .done jr nc, .done

View file

@ -1,43 +1,43 @@
ReadTrainer: ReadTrainer:
; don't change any moves in a link battle ; don't change any moves in a link battle
ld a,[wLinkState] ld a, [wLinkState]
and a and a
ret nz ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF ; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
; XXX first is total enemy pokemon? ; XXX first is total enemy pokemon?
; XXX second is species of first pokemon? ; XXX second is species of first pokemon?
ld hl,wEnemyPartyCount ld hl, wEnemyPartyCount
xor a xor a
ld [hli],a ld [hli], a
dec a dec a
ld [hl],a ld [hl], a
; get the pointer to trainer data for this class ; get the pointer to trainer data for this class
ld a,[wCurOpponent] ld a, [wCurOpponent]
sub $C9 ; convert value from pokemon to trainer sub $C9 ; convert value from pokemon to trainer
add a,a add a
ld hl,TrainerDataPointers ld hl, TrainerDataPointers
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc ; hl points to trainer class add hl, bc ; hl points to trainer class
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld a,[wTrainerNo] ld a, [wTrainerNo]
ld b,a ld b, a
; At this point b contains the trainer number, ; At this point b contains the trainer number,
; and hl points to the trainer class. ; and hl points to the trainer class.
; Our next task is to iterate through the trainers, ; Our next task is to iterate through the trainers,
; decrementing b each time, until we get to the right one. ; decrementing b each time, until we get to the right one.
.outer .outer
dec b dec b
jr z,.IterateTrainer jr z, .IterateTrainer
.inner .inner
ld a,[hli] ld a, [hli]
and a and a
jr nz,.inner jr nz, .inner
jr .outer jr .outer
; if the first byte of trainer data is FF, ; if the first byte of trainer data is FF,
@ -46,17 +46,17 @@ ReadTrainer:
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move ; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
; else the first byte is the level of every pokemon on the team ; else the first byte is the level of every pokemon on the team
.IterateTrainer .IterateTrainer
ld a,[hli] ld a, [hli]
cp $FF ; is the trainer special? cp $FF ; is the trainer special?
jr z,.SpecialTrainer ; if so, check for special moves jr z, .SpecialTrainer ; if so, check for special moves
ld [wCurEnemyLVL],a ld [wCurEnemyLVL], a
.LoopTrainerData .LoopTrainerData
ld a,[hli] ld a, [hli]
and a ; have we reached the end of the trainer data? and a ; have we reached the end of the trainer data?
jr z,.FinishUp jr z, .FinishUp
ld [wcf91],a ; write species somewhere (XXX why?) ld [wcf91], a ; write species somewhere (XXX why?)
ld a,ENEMY_PARTY_DATA ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation],a ld [wMonDataLocation], a
push hl push hl
call AddPartyMon call AddPartyMon
pop hl pop hl
@ -66,101 +66,101 @@ ReadTrainer:
; - each pokemon has a specific level ; - each pokemon has a specific level
; (as opposed to the whole team being of the same level) ; (as opposed to the whole team being of the same level)
; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move ; - if [wLoneAttackNo] != 0, one pokemon on the team has a special move
ld a,[hli] ld a, [hli]
and a ; have we reached the end of the trainer data? and a ; have we reached the end of the trainer data?
jr z,.AddLoneMove jr z, .AddLoneMove
ld [wCurEnemyLVL],a ld [wCurEnemyLVL], a
ld a,[hli] ld a, [hli]
ld [wcf91],a ld [wcf91], a
ld a,ENEMY_PARTY_DATA ld a, ENEMY_PARTY_DATA
ld [wMonDataLocation],a ld [wMonDataLocation], a
push hl push hl
call AddPartyMon call AddPartyMon
pop hl pop hl
jr .SpecialTrainer jr .SpecialTrainer
.AddLoneMove .AddLoneMove
; does the trainer have a single monster with a different move ; does the trainer have a single monster with a different move
ld a,[wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc ld a, [wLoneAttackNo] ; Brock is 01, Misty is 02, Erika is 04, etc
and a and a
jr z,.AddTeamMove jr z, .AddTeamMove
dec a dec a
add a,a add a
ld c,a ld c, a
ld b,0 ld b, 0
ld hl,LoneMoves ld hl, LoneMoves
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld d,[hl] ld d, [hl]
ld hl,wEnemyMon1Moves + 2 ld hl, wEnemyMon1Moves + 2
ld bc,wEnemyMon2 - wEnemyMon1 ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes call AddNTimes
ld [hl],d ld [hl], d
jr .FinishUp jr .FinishUp
.AddTeamMove .AddTeamMove
; check if our trainer's team has special moves ; check if our trainer's team has special moves
; get trainer class number ; get trainer class number
ld a,[wCurOpponent] ld a, [wCurOpponent]
sub 200 sub 200
ld b,a ld b, a
ld hl,TeamMoves ld hl, TeamMoves
; iterate through entries in TeamMoves, checking each for our trainer class ; iterate through entries in TeamMoves, checking each for our trainer class
.IterateTeamMoves .IterateTeamMoves
ld a,[hli] ld a, [hli]
cp b cp b
jr z,.GiveTeamMoves ; is there a match? jr z, .GiveTeamMoves ; is there a match?
inc hl ; if not, go to the next entry inc hl ; if not, go to the next entry
inc a inc a
jr nz,.IterateTeamMoves jr nz, .IterateTeamMoves
; no matches found. is this trainer champion rival? ; no matches found. is this trainer champion rival?
ld a,b ld a, b
cp SONY3 cp SONY3
jr z,.ChampionRival jr z, .ChampionRival
jr .FinishUp ; nope jr .FinishUp ; nope
.GiveTeamMoves .GiveTeamMoves
ld a,[hl] ld a, [hl]
ld [wEnemyMon5Moves + 2],a ld [wEnemyMon5Moves + 2], a
jr .FinishUp jr .FinishUp
.ChampionRival ; give moves to his team .ChampionRival ; give moves to his team
; pidgeot ; pidgeot
ld a,SKY_ATTACK ld a, SKY_ATTACK
ld [wEnemyMon1Moves + 2],a ld [wEnemyMon1Moves + 2], a
; starter ; starter
ld a,[wRivalStarter] ld a, [wRivalStarter]
cp STARTER3 cp STARTER3
ld b,MEGA_DRAIN ld b, MEGA_DRAIN
jr z,.GiveStarterMove jr z, .GiveStarterMove
cp STARTER1 cp STARTER1
ld b,FIRE_BLAST ld b, FIRE_BLAST
jr z,.GiveStarterMove jr z, .GiveStarterMove
ld b,BLIZZARD ; must be squirtle ld b, BLIZZARD ; must be squirtle
.GiveStarterMove .GiveStarterMove
ld a,b ld a, b
ld [wEnemyMon6Moves + 2],a ld [wEnemyMon6Moves + 2], a
.FinishUp .FinishUp
; clear wAmountMoneyWon addresses ; clear wAmountMoneyWon addresses
xor a xor a
ld de,wAmountMoneyWon ld de, wAmountMoneyWon
ld [de],a ld [de], a
inc de inc de
ld [de],a ld [de], a
inc de inc de
ld [de],a ld [de], a
ld a,[wCurEnemyLVL] ld a, [wCurEnemyLVL]
ld b,a ld b, a
.LastLoop .LastLoop
; update wAmountMoneyWon addresses (money to win) based on enemy's level ; update wAmountMoneyWon addresses (money to win) based on enemy's level
ld hl,wTrainerBaseMoney + 1 ld hl, wTrainerBaseMoney + 1
ld c,2 ; wAmountMoneyWon is a 3-byte number ld c, 2 ; wAmountMoneyWon is a 3-byte number
push bc push bc
predef AddBCDPredef predef AddBCDPredef
pop bc pop bc
inc de inc de
inc de inc de
dec b dec b
jr nz,.LastLoop ; repeat wCurEnemyLVL times jr nz, .LastLoop ; repeat wCurEnemyLVL times
ret ret

View file

@ -1,21 +1,21 @@
SaveTrainerName: SaveTrainerName:
ld hl,TrainerNamePointers ld hl, TrainerNamePointers
ld a,[wTrainerClass] ld a, [wTrainerClass]
dec a dec a
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc add hl, bc
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld de,wcd6d ld de, wcd6d
.CopyCharacter .CopyCharacter
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
cp "@" cp "@"
jr nz,.CopyCharacter jr nz, .CopyCharacter
ret ret
TrainerNamePointers: TrainerNamePointers:

View file

@ -263,10 +263,10 @@ ReadMove:
push de push de
push bc push bc
dec a dec a
ld hl,Moves ld hl, Moves
ld bc,MoveEnd - Moves ld bc, MoveEnd - Moves
call AddNTimes call AddNTimes
ld de,wEnemyMoveNum ld de, wEnemyMoveNum
call CopyData call CopyData
pop bc pop bc
pop de pop de
@ -338,33 +338,33 @@ INCLUDE "data/trainer_parties.asm"
TrainerAI: TrainerAI:
and a and a
ld a,[wIsInBattle] ld a, [wIsInBattle]
dec a dec a
ret z ; if not a trainer, we're done here ret z ; if not a trainer, we're done here
ld a,[wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
ret z ret z
ld a,[wTrainerClass] ; what trainer class is this? ld a, [wTrainerClass] ; what trainer class is this?
dec a dec a
ld c,a ld c, a
ld b,0 ld b, 0
ld hl,TrainerAIPointers ld hl, TrainerAIPointers
add hl,bc add hl, bc
add hl,bc add hl, bc
add hl,bc add hl, bc
ld a,[wAICount] ld a, [wAICount]
and a and a
ret z ; if no AI uses left, we're done here ret z ; if no AI uses left, we're done here
inc hl inc hl
inc a inc a
jr nz,.getpointer jr nz, .getpointer
dec hl dec hl
ld a,[hli] ld a, [hli]
ld [wAICount],a ld [wAICount], a
.getpointer .getpointer
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
call Random call Random
jp hl jp hl
@ -442,17 +442,17 @@ CooltrainerMAI:
CooltrainerFAI: CooltrainerFAI:
cp $40 cp $40
ld a,$A ld a, $A
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
jp c,AIUseHyperPotion jp c, AIUseHyperPotion
ld a,5 ld a, 5
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AISwitchIfEnoughMons jp AISwitchIfEnoughMons
BrockAI: BrockAI:
; if his active monster has a status condition, use a full heal ; if his active monster has a status condition, use a full heal
ld a,[wEnemyMonStatus] ld a, [wEnemyMonStatus]
and a and a
ret z ret z
jp AIUseFullHeal jp AIUseFullHeal
@ -470,7 +470,7 @@ LtSurgeAI:
ErikaAI: ErikaAI:
cp $80 cp $80
ret nc ret nc
ld a,$A ld a, $A
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseSuperPotion jp AIUseSuperPotion
@ -488,7 +488,7 @@ BlaineAI:
SabrinaAI: SabrinaAI:
cp $40 cp $40
ret nc ret nc
ld a,$A ld a, $A
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseHyperPotion jp AIUseHyperPotion
@ -496,7 +496,7 @@ SabrinaAI:
Sony2AI: Sony2AI:
cp $20 cp $20
ret nc ret nc
ld a,5 ld a, 5
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUsePotion jp AIUsePotion
@ -504,7 +504,7 @@ Sony2AI:
Sony3AI: Sony3AI:
cp $20 cp $20
ret nc ret nc
ld a,5 ld a, 5
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseFullRestore jp AIUseFullRestore
@ -512,7 +512,7 @@ Sony3AI:
LoreleiAI: LoreleiAI:
cp $80 cp $80
ret nc ret nc
ld a,5 ld a, 5
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseSuperPotion jp AIUseSuperPotion
@ -524,10 +524,10 @@ BrunoAI:
AgathaAI: AgathaAI:
cp $14 cp $14
jp c,AISwitchIfEnoughMons jp c, AISwitchIfEnoughMons
cp $80 cp $80
ret nc ret nc
ld a,4 ld a, 4
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseSuperPotion jp AIUseSuperPotion
@ -535,7 +535,7 @@ AgathaAI:
LanceAI: LanceAI:
cp $80 cp $80
ret nc ret nc
ld a,5 ld a, 5
call AICheckIfHPBelowFraction call AICheckIfHPBelowFraction
ret nc ret nc
jp AIUseHyperPotion jp AIUseHyperPotion
@ -547,133 +547,133 @@ GenericAI:
; end of individual trainer AI routines ; end of individual trainer AI routines
DecrementAICount: DecrementAICount:
ld hl,wAICount ld hl, wAICount
dec [hl] dec [hl]
scf scf
ret ret
AIPlayRestoringSFX: AIPlayRestoringSFX:
ld a,SFX_HEAL_AILMENT ld a, SFX_HEAL_AILMENT
jp PlaySoundWaitForCurrent jp PlaySoundWaitForCurrent
AIUseFullRestore: AIUseFullRestore:
call AICureStatus call AICureStatus
ld a,FULL_RESTORE ld a, FULL_RESTORE
ld [wAIItem],a ld [wAIItem], a
ld de,wHPBarOldHP ld de, wHPBarOldHP
ld hl,wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a,[hld] ld a, [hld]
ld [de],a ld [de], a
inc de inc de
ld a,[hl] ld a, [hl]
ld [de],a ld [de], a
inc de inc de
ld hl,wEnemyMonMaxHP + 1 ld hl, wEnemyMonMaxHP + 1
ld a,[hld] ld a, [hld]
ld [de],a ld [de], a
inc de inc de
ld [wHPBarMaxHP],a ld [wHPBarMaxHP], a
ld [wEnemyMonHP + 1],a ld [wEnemyMonHP + 1], a
ld a,[hl] ld a, [hl]
ld [de],a ld [de], a
ld [wHPBarMaxHP+1],a ld [wHPBarMaxHP+1], a
ld [wEnemyMonHP],a ld [wEnemyMonHP], a
jr AIPrintItemUseAndUpdateHPBar jr AIPrintItemUseAndUpdateHPBar
AIUsePotion: AIUsePotion:
; enemy trainer heals his monster with a potion ; enemy trainer heals his monster with a potion
ld a,POTION ld a, POTION
ld b,20 ld b, 20
jr AIRecoverHP jr AIRecoverHP
AIUseSuperPotion: AIUseSuperPotion:
; enemy trainer heals his monster with a super potion ; enemy trainer heals his monster with a super potion
ld a,SUPER_POTION ld a, SUPER_POTION
ld b,50 ld b, 50
jr AIRecoverHP jr AIRecoverHP
AIUseHyperPotion: AIUseHyperPotion:
; enemy trainer heals his monster with a hyper potion ; enemy trainer heals his monster with a hyper potion
ld a,HYPER_POTION ld a, HYPER_POTION
ld b,200 ld b, 200
; fallthrough ; fallthrough
AIRecoverHP: AIRecoverHP:
; heal b HP and print "trainer used $(a) on pokemon!" ; heal b HP and print "trainer used $(a) on pokemon!"
ld [wAIItem],a ld [wAIItem], a
ld hl,wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a,[hl] ld a, [hl]
ld [wHPBarOldHP],a ld [wHPBarOldHP], a
add b add b
ld [hld],a ld [hld], a
ld [wHPBarNewHP],a ld [wHPBarNewHP], a
ld a,[hl] ld a, [hl]
ld [wHPBarOldHP+1],a ld [wHPBarOldHP+1], a
ld [wHPBarNewHP+1],a ld [wHPBarNewHP+1], a
jr nc,.next jr nc, .next
inc a inc a
ld [hl],a ld [hl], a
ld [wHPBarNewHP+1],a ld [wHPBarNewHP+1], a
.next .next
inc hl inc hl
ld a,[hld] ld a, [hld]
ld b,a ld b, a
ld de,wEnemyMonMaxHP + 1 ld de, wEnemyMonMaxHP + 1
ld a,[de] ld a, [de]
dec de dec de
ld [wHPBarMaxHP],a ld [wHPBarMaxHP], a
sub b sub b
ld a,[hli] ld a, [hli]
ld b,a ld b, a
ld a,[de] ld a, [de]
ld [wHPBarMaxHP+1],a ld [wHPBarMaxHP+1], a
sbc b sbc b
jr nc,AIPrintItemUseAndUpdateHPBar jr nc, AIPrintItemUseAndUpdateHPBar
inc de inc de
ld a,[de] ld a, [de]
dec de dec de
ld [hld],a ld [hld], a
ld [wHPBarNewHP],a ld [wHPBarNewHP], a
ld a,[de] ld a, [de]
ld [hl],a ld [hl], a
ld [wHPBarNewHP+1],a ld [wHPBarNewHP+1], a
; fallthrough ; fallthrough
AIPrintItemUseAndUpdateHPBar: AIPrintItemUseAndUpdateHPBar:
call AIPrintItemUse_ call AIPrintItemUse_
coord hl, 2, 2 coord hl, 2, 2
xor a xor a
ld [wHPBarType],a ld [wHPBarType], a
predef UpdateHPBar2 predef UpdateHPBar2
jp DecrementAICount jp DecrementAICount
AISwitchIfEnoughMons: AISwitchIfEnoughMons:
; enemy trainer switches if there are 3 or more unfainted mons in party ; enemy trainer switches if there are 3 or more unfainted mons in party
ld a,[wEnemyPartyCount] ld a, [wEnemyPartyCount]
ld c,a ld c, a
ld hl,wEnemyMon1HP ld hl, wEnemyMon1HP
ld d,0 ; keep count of unfainted monsters ld d, 0 ; keep count of unfainted monsters
; count how many monsters haven't fainted yet ; count how many monsters haven't fainted yet
.loop .loop
ld a,[hli] ld a, [hli]
ld b,a ld b, a
ld a,[hld] ld a, [hld]
or b or b
jr z,.Fainted ; has monster fainted? jr z, .Fainted ; has monster fainted?
inc d inc d
.Fainted .Fainted
push bc push bc
ld bc, wEnemyMon2 - wEnemyMon1 ld bc, wEnemyMon2 - wEnemyMon1
add hl,bc add hl, bc
pop bc pop bc
dec c dec c
jr nz,.loop jr nz, .loop
ld a,d ; how many available monsters are there? ld a, d ; how many available monsters are there?
cp 2 ; don't bother if only 1 or 2 cp 2 ; don't bother if only 1 or 2
jp nc,SwitchEnemyMon jp nc, SwitchEnemyMon
and a and a
ret ret
@ -681,14 +681,14 @@ SwitchEnemyMon:
; prepare to withdraw the active monster: copy hp, number, and status to roster ; prepare to withdraw the active monster: copy hp, number, and status to roster
ld a,[wEnemyMonPartyPos] ld a, [wEnemyMonPartyPos]
ld hl,wEnemyMon1HP ld hl, wEnemyMon1HP
ld bc,wEnemyMon2 - wEnemyMon1 ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes call AddNTimes
ld d,h ld d, h
ld e,l ld e, l
ld hl,wEnemyMonHP ld hl, wEnemyMonHP
ld bc,4 ld bc, 4
call CopyData call CopyData
ld hl, AIBattleWithdrawText ld hl, AIBattleWithdrawText
@ -696,13 +696,13 @@ SwitchEnemyMon:
; This wFirstMonsNotOutYet variable is abused to prevent the player from ; This wFirstMonsNotOutYet variable is abused to prevent the player from
; switching in a new mon in response to this switch. ; switching in a new mon in response to this switch.
ld a,1 ld a, 1
ld [wFirstMonsNotOutYet],a ld [wFirstMonsNotOutYet], a
callab EnemySendOut callab EnemySendOut
xor a xor a
ld [wFirstMonsNotOutYet],a ld [wFirstMonsNotOutYet], a
ld a,[wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
ret z ret z
scf scf
@ -715,120 +715,120 @@ AIBattleWithdrawText:
AIUseFullHeal: AIUseFullHeal:
call AIPlayRestoringSFX call AIPlayRestoringSFX
call AICureStatus call AICureStatus
ld a,FULL_HEAL ld a, FULL_HEAL
jp AIPrintItemUse jp AIPrintItemUse
AICureStatus: AICureStatus:
; cures the status of enemy's active pokemon ; cures the status of enemy's active pokemon
ld a,[wEnemyMonPartyPos] ld a, [wEnemyMonPartyPos]
ld hl,wEnemyMon1Status ld hl, wEnemyMon1Status
ld bc,wEnemyMon2 - wEnemyMon1 ld bc, wEnemyMon2 - wEnemyMon1
call AddNTimes call AddNTimes
xor a xor a
ld [hl],a ; clear status in enemy team roster ld [hl], a ; clear status in enemy team roster
ld [wEnemyMonStatus],a ; clear status of active enemy ld [wEnemyMonStatus], a ; clear status of active enemy
ld hl,wEnemyBattleStatus3 ld hl, wEnemyBattleStatus3
res 0,[hl] res 0, [hl]
ret ret
AIUseXAccuracy: ; unused AIUseXAccuracy: ; unused
call AIPlayRestoringSFX call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
set 0,[hl] set 0, [hl]
ld a,X_ACCURACY ld a, X_ACCURACY
jp AIPrintItemUse jp AIPrintItemUse
AIUseGuardSpec: AIUseGuardSpec:
call AIPlayRestoringSFX call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
set 1,[hl] set 1, [hl]
ld a,GUARD_SPEC ld a, GUARD_SPEC
jp AIPrintItemUse jp AIPrintItemUse
AIUseDireHit: ; unused AIUseDireHit: ; unused
call AIPlayRestoringSFX call AIPlayRestoringSFX
ld hl,wEnemyBattleStatus2 ld hl, wEnemyBattleStatus2
set 2,[hl] set 2, [hl]
ld a,DIRE_HIT ld a, DIRE_HIT
jp AIPrintItemUse jp AIPrintItemUse
AICheckIfHPBelowFraction: AICheckIfHPBelowFraction:
; return carry if enemy trainer's current HP is below 1 / a of the maximum ; return carry if enemy trainer's current HP is below 1 / a of the maximum
ld [H_DIVISOR],a ld [H_DIVISOR], a
ld hl,wEnemyMonMaxHP ld hl, wEnemyMonMaxHP
ld a,[hli] ld a, [hli]
ld [H_DIVIDEND],a ld [H_DIVIDEND], a
ld a,[hl] ld a, [hl]
ld [H_DIVIDEND + 1],a ld [H_DIVIDEND + 1], a
ld b,2 ld b, 2
call Divide call Divide
ld a,[H_QUOTIENT + 3] ld a, [H_QUOTIENT + 3]
ld c,a ld c, a
ld a,[H_QUOTIENT + 2] ld a, [H_QUOTIENT + 2]
ld b,a ld b, a
ld hl,wEnemyMonHP + 1 ld hl, wEnemyMonHP + 1
ld a,[hld] ld a, [hld]
ld e,a ld e, a
ld a,[hl] ld a, [hl]
ld d,a ld d, a
ld a,d ld a, d
sub b sub b
ret nz ret nz
ld a,e ld a, e
sub c sub c
ret ret
AIUseXAttack: AIUseXAttack:
ld b,$A ld b, $A
ld a,X_ATTACK ld a, X_ATTACK
jr AIIncreaseStat jr AIIncreaseStat
AIUseXDefend: AIUseXDefend:
ld b,$B ld b, $B
ld a,X_DEFEND ld a, X_DEFEND
jr AIIncreaseStat jr AIIncreaseStat
AIUseXSpeed: AIUseXSpeed:
ld b,$C ld b, $C
ld a,X_SPEED ld a, X_SPEED
jr AIIncreaseStat jr AIIncreaseStat
AIUseXSpecial: AIUseXSpecial:
ld b,$D ld b, $D
ld a,X_SPECIAL ld a, X_SPECIAL
; fallthrough ; fallthrough
AIIncreaseStat: AIIncreaseStat:
ld [wAIItem],a ld [wAIItem], a
push bc push bc
call AIPrintItemUse_ call AIPrintItemUse_
pop bc pop bc
ld hl,wEnemyMoveEffect ld hl, wEnemyMoveEffect
ld a,[hld] ld a, [hld]
push af push af
ld a,[hl] ld a, [hl]
push af push af
push hl push hl
ld a,ANIM_AF ld a, ANIM_AF
ld [hli],a ld [hli], a
ld [hl],b ld [hl], b
callab StatModifierUpEffect callab StatModifierUpEffect
pop hl pop hl
pop af pop af
ld [hli],a ld [hli], a
pop af pop af
ld [hl],a ld [hl], a
jp DecrementAICount jp DecrementAICount
AIPrintItemUse: AIPrintItemUse:
ld [wAIItem],a ld [wAIItem], a
call AIPrintItemUse_ call AIPrintItemUse_
jp DecrementAICount jp DecrementAICount
AIPrintItemUse_: AIPrintItemUse_:
; print "x used [wAIItem] on z!" ; print "x used [wAIItem] on z!"
ld a,[wAIItem] ld a, [wAIItem]
ld [wd11e],a ld [wd11e], a
call GetItemName call GetItemName
ld hl, AIBattleUseItemText ld hl, AIBattleUseItemText
jp PrintText jp PrintText

View file

@ -1,78 +1,78 @@
; function that performs initialization for DisplayTextID ; function that performs initialization for DisplayTextID
DisplayTextIDInit: DisplayTextIDInit:
xor a xor a
ld [wListMenuID],a ld [wListMenuID], a
ld a,[wAutoTextBoxDrawingControl] ld a, [wAutoTextBoxDrawingControl]
bit 0,a bit 0, a
jr nz,.skipDrawingTextBoxBorder jr nz, .skipDrawingTextBoxBorder
ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID) ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID)
and a and a
jr nz,.notStartMenu jr nz, .notStartMenu
; if text ID is 0 (i.e. the start menu) ; if text ID is 0 (i.e. the start menu)
; Note that the start menu text border is also drawn in the function directly ; Note that the start menu text border is also drawn in the function directly
; below this, so this seems unnecessary. ; below this, so this seems unnecessary.
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
; start menu with pokedex ; start menu with pokedex
coord hl, 10, 0 coord hl, 10, 0
ld b,$0e ld b, $0e
ld c,$08 ld c, $08
jr nz,.drawTextBoxBorder jr nz, .drawTextBoxBorder
; start menu without pokedex ; start menu without pokedex
coord hl, 10, 0 coord hl, 10, 0
ld b,$0c ld b, $0c
ld c,$08 ld c, $08
jr .drawTextBoxBorder jr .drawTextBoxBorder
; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box ; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
.notStartMenu .notStartMenu
coord hl, 0, 12 coord hl, 0, 12
ld b,$04 ld b, $04
ld c,$12 ld c, $12
.drawTextBoxBorder .drawTextBoxBorder
call TextBoxBorder call TextBoxBorder
.skipDrawingTextBoxBorder .skipDrawingTextBoxBorder
ld hl,wFontLoaded ld hl, wFontLoaded
set 0,[hl] set 0, [hl]
ld hl,wFlags_0xcd60 ld hl, wFlags_0xcd60
bit 4,[hl] bit 4, [hl]
res 4,[hl] res 4, [hl]
jr nz,.skipMovingSprites jr nz, .skipMovingSprites
call UpdateSprites call UpdateSprites
.skipMovingSprites .skipMovingSprites
; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite ; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
; this is done because when you talk to an NPC, they turn to look your way ; this is done because when you talk to an NPC, they turn to look your way
; the original direction they were facing must be restored after the dialogue is over ; the original direction they were facing must be restored after the dialogue is over
ld hl,wSpriteStateData1 + $19 ld hl, wSpriteStateData1 + $19
ld c,$0f ld c, $0f
ld de,$0010 ld de, $0010
.spriteFacingDirectionCopyLoop .spriteFacingDirectionCopyLoop
ld a,[hl] ld a, [hl]
inc h inc h
ld [hl],a ld [hl], a
dec h dec h
add hl,de add hl, de
dec c dec c
jr nz,.spriteFacingDirectionCopyLoop jr nz, .spriteFacingDirectionCopyLoop
; loop to force all the sprites in the middle of animation to stand still ; loop to force all the sprites in the middle of animation to stand still
; (so that they don't like they're frozen mid-step during the dialogue) ; (so that they don't like they're frozen mid-step during the dialogue)
ld hl,wSpriteStateData1 + 2 ld hl, wSpriteStateData1 + 2
ld de,$0010 ld de, $0010
ld c,e ld c, e
.spriteStandStillLoop .spriteStandStillLoop
ld a,[hl] ld a, [hl]
cp a,$ff ; is the sprite visible? cp $ff ; is the sprite visible?
jr z,.nextSprite jr z, .nextSprite
; if it is visible ; if it is visible
and a,$fc and $fc
ld [hl],a ld [hl], a
.nextSprite .nextSprite
add hl,de add hl, de
dec c dec c
jr nz,.spriteStandStillLoop jr nz, .spriteStandStillLoop
ld b,$9c ; window background address ld b, $9c ; window background address
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
xor a xor a
ld [hWY],a ; put the window on the screen ld [hWY], a ; put the window on the screen
call LoadFontTilePatterns call LoadFontTilePatterns
ld a,$01 ld a, $01
ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank ld [H_AUTOBGTRANSFERENABLED], a ; enable continuous WRAM to VRAM transfer each V-blank
ret ret

View file

@ -6,7 +6,7 @@ AnimateHallOfFame:
call LoadFontTilePatterns call LoadFontTilePatterns
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
call DisableLCD call DisableLCD
ld hl,vBGMap0 ld hl, vBGMap0
ld bc, $800 ld bc, $800
ld a, " " ld a, " "
call FillMemory call FillMemory

View file

@ -1,85 +1,85 @@
DoInGameTradeDialogue: DoInGameTradeDialogue:
; trigger the trade offer/action specified by wWhichTrade ; trigger the trade offer/action specified by wWhichTrade
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
ld hl,TradeMons ld hl, TradeMons
ld a,[wWhichTrade] ld a, [wWhichTrade]
ld b,a ld b, a
swap a swap a
sub b sub b
sub b sub b
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld [wInGameTradeGiveMonSpecies],a ld [wInGameTradeGiveMonSpecies], a
ld a,[hli] ld a, [hli]
ld [wInGameTradeReceiveMonSpecies],a ld [wInGameTradeReceiveMonSpecies], a
ld a,[hli] ld a, [hli]
push af push af
ld de,wInGameTradeMonNick ld de, wInGameTradeMonNick
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyData call CopyData
pop af pop af
ld l,a ld l, a
ld h,0 ld h, 0
ld de,InGameTradeTextPointers ld de, InGameTradeTextPointers
add hl,hl add hl, hl
add hl,de add hl, de
ld a,[hli] ld a, [hli]
ld [wInGameTradeTextPointerTablePointer],a ld [wInGameTradeTextPointerTablePointer], a
ld a,[hl] ld a, [hl]
ld [wInGameTradeTextPointerTablePointer + 1],a ld [wInGameTradeTextPointerTablePointer + 1], a
ld a,[wInGameTradeGiveMonSpecies] ld a, [wInGameTradeGiveMonSpecies]
ld de,wInGameTradeGiveMonName ld de, wInGameTradeGiveMonName
call InGameTrade_GetMonName call InGameTrade_GetMonName
ld a,[wInGameTradeReceiveMonSpecies] ld a, [wInGameTradeReceiveMonSpecies]
ld de,wInGameTradeReceiveMonName ld de, wInGameTradeReceiveMonName
call InGameTrade_GetMonName call InGameTrade_GetMonName
ld hl,wCompletedInGameTradeFlags ld hl, wCompletedInGameTradeFlags
ld a,[wWhichTrade] ld a, [wWhichTrade]
ld c,a ld c, a
ld b,FLAG_TEST ld b, FLAG_TEST
predef FlagActionPredef predef FlagActionPredef
ld a,c ld a, c
and a and a
ld a,$4 ld a, $4
ld [wInGameTradeTextPointerTableIndex],a ld [wInGameTradeTextPointerTableIndex], a
jr nz,.printText jr nz, .printText
; if the trade hasn't been done yet ; if the trade hasn't been done yet
xor a xor a
ld [wInGameTradeTextPointerTableIndex],a ld [wInGameTradeTextPointerTableIndex], a
call .printText call .printText
ld a,$1 ld a, $1
ld [wInGameTradeTextPointerTableIndex],a ld [wInGameTradeTextPointerTableIndex], a
call YesNoChoice call YesNoChoice
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jr nz,.printText jr nz, .printText
call InGameTrade_DoTrade call InGameTrade_DoTrade
jr c,.printText jr c, .printText
ld hl, TradedForText ld hl, TradedForText
call PrintText call PrintText
.printText .printText
ld hl,wInGameTradeTextPointerTableIndex ld hl, wInGameTradeTextPointerTableIndex
ld a,[hld] ; wInGameTradeTextPointerTableIndex ld a, [hld] ; wInGameTradeTextPointerTableIndex
ld e,a ld e, a
ld d,0 ld d, 0
ld a,[hld] ; wInGameTradeTextPointerTablePointer + 1 ld a, [hld] ; wInGameTradeTextPointerTablePointer + 1
ld l,[hl] ; wInGameTradeTextPointerTablePointer ld l, [hl] ; wInGameTradeTextPointerTablePointer
ld h,a ld h, a
add hl,de add hl, de
add hl,de add hl, de
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
jp PrintText jp PrintText
; copies name of species a to hl ; copies name of species a to hl
InGameTrade_GetMonName: InGameTrade_GetMonName:
push de push de
ld [wd11e],a ld [wd11e], a
call GetMonName call GetMonName
ld hl,wcd6d ld hl, wcd6d
pop de pop de
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
jp CopyData jp CopyData
@ -88,53 +88,53 @@ INCLUDE "data/trades.asm"
InGameTrade_DoTrade: InGameTrade_DoTrade:
xor a ; NORMAL_PARTY_MENU xor a ; NORMAL_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a ld [wPartyMenuTypeOrMessageID], a
dec a dec a
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
call DisplayPartyMenu call DisplayPartyMenu
push af push af
call InGameTrade_RestoreScreen call InGameTrade_RestoreScreen
pop af pop af
ld a,$1 ld a, $1
jp c,.tradeFailed ; jump if the player didn't select a pokemon jp c, .tradeFailed ; jump if the player didn't select a pokemon
ld a,[wInGameTradeGiveMonSpecies] ld a, [wInGameTradeGiveMonSpecies]
ld b,a ld b, a
ld a,[wcf91] ld a, [wcf91]
cp b cp b
ld a,$2 ld a, $2
jr nz,.tradeFailed ; jump if the selected mon's species is not the required one jr nz, .tradeFailed ; jump if the selected mon's species is not the required one
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
ld hl,wPartyMon1Level ld hl, wPartyMon1Level
ld bc, wPartyMon2 - wPartyMon1 ld bc, wPartyMon2 - wPartyMon1
call AddNTimes call AddNTimes
ld a,[hl] ld a, [hl]
ld [wCurEnemyLVL],a ld [wCurEnemyLVL], a
ld hl,wCompletedInGameTradeFlags ld hl, wCompletedInGameTradeFlags
ld a,[wWhichTrade] ld a, [wWhichTrade]
ld c,a ld c, a
ld b,FLAG_SET ld b, FLAG_SET
predef FlagActionPredef predef FlagActionPredef
ld hl, ConnectCableText ld hl, ConnectCableText
call PrintText call PrintText
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
push af push af
ld a,[wCurEnemyLVL] ld a, [wCurEnemyLVL]
push af push af
call LoadHpBarAndStatusTilePatterns call LoadHpBarAndStatusTilePatterns
call InGameTrade_PrepareTradeData call InGameTrade_PrepareTradeData
predef InternalClockTradeAnim predef InternalClockTradeAnim
pop af pop af
ld [wCurEnemyLVL],a ld [wCurEnemyLVL], a
pop af pop af
ld [wWhichPokemon],a ld [wWhichPokemon], a
ld a,[wInGameTradeReceiveMonSpecies] ld a, [wInGameTradeReceiveMonSpecies]
ld [wcf91],a ld [wcf91], a
xor a xor a
ld [wMonDataLocation],a ; not used ld [wMonDataLocation], a ; not used
ld [wRemoveMonFromBox],a ld [wRemoveMonFromBox], a
call RemovePokemon call RemovePokemon
ld a,$80 ; prevent the player from naming the mon ld a, $80 ; prevent the player from naming the mon
ld [wMonDataLocation],a ld [wMonDataLocation], a
call AddPartyMon call AddPartyMon
call InGameTrade_CopyDataToReceivedMon call InGameTrade_CopyDataToReceivedMon
callab EvolveTradeMon callab EvolveTradeMon
@ -142,12 +142,12 @@ InGameTrade_DoTrade:
call InGameTrade_RestoreScreen call InGameTrade_RestoreScreen
callba RedrawMapView callba RedrawMapView
and a and a
ld a,$3 ld a, $3
jr .tradeSucceeded jr .tradeSucceeded
.tradeFailed .tradeFailed
scf scf
.tradeSucceeded .tradeSucceeded
ld [wInGameTradeTextPointerTableIndex],a ld [wInGameTradeTextPointerTableIndex], a
ret ret
InGameTrade_RestoreScreen: InGameTrade_RestoreScreen:

View file

@ -5,81 +5,81 @@
; [wItemQuantity] = item quantity ; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful ; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory_: AddItemToInventory_:
ld a,[wItemQuantity] ; a = item quantity ld a, [wItemQuantity] ; a = item quantity
push af push af
push bc push bc
push de push de
push hl push hl
push hl push hl
ld d,PC_ITEM_CAPACITY ; how many items the PC can hold ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
ld a,wNumBagItems & $FF ld a, wNumBagItems & $FF
cp l cp l
jr nz,.checkIfInventoryFull jr nz, .checkIfInventoryFull
ld a,wNumBagItems >> 8 ld a, wNumBagItems >> 8
cp h cp h
jr nz,.checkIfInventoryFull jr nz, .checkIfInventoryFull
; if the destination is the bag ; if the destination is the bag
ld d,BAG_ITEM_CAPACITY ; how many items the bag can hold ld d, BAG_ITEM_CAPACITY ; how many items the bag can hold
.checkIfInventoryFull .checkIfInventoryFull
ld a,[hl] ld a, [hl]
sub d sub d
ld d,a ld d, a
ld a,[hli] ld a, [hli]
and a and a
jr z,.addNewItem jr z, .addNewItem
.loop .loop
ld a,[hli] ld a, [hli]
ld b,a ; b = ID of current item in table ld b, a ; b = ID of current item in table
ld a,[wcf91] ; a = ID of item being added ld a, [wcf91] ; a = ID of item being added
cp b ; does the current item in the table match the item being added? cp b ; does the current item in the table match the item being added?
jp z,.increaseItemQuantity ; if so, increase the item's quantity jp z, .increaseItemQuantity ; if so, increase the item's quantity
inc hl inc hl
ld a,[hl] ld a, [hl]
cp a,$ff ; is it the end of the table? cp $ff ; is it the end of the table?
jr nz,.loop jr nz, .loop
.addNewItem ; add an item not yet in the inventory .addNewItem ; add an item not yet in the inventory
pop hl pop hl
ld a,d ld a, d
and a ; is there room for a new item slot? and a ; is there room for a new item slot?
jr z,.done jr z, .done
; if there is room ; if there is room
inc [hl] ; increment the number of items in the inventory inc [hl] ; increment the number of items in the inventory
ld a,[hl] ; the number of items will be the index of the new item ld a, [hl] ; the number of items will be the index of the new item
add a add a
dec a dec a
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc ; hl = address to store the item add hl, bc ; hl = address to store the item
ld a,[wcf91] ld a, [wcf91]
ld [hli],a ; store item ID ld [hli], a ; store item ID
ld a,[wItemQuantity] ld a, [wItemQuantity]
ld [hli],a ; store item quantity ld [hli], a ; store item quantity
ld [hl],$ff ; store terminator ld [hl], $ff ; store terminator
jp .success jp .success
.increaseItemQuantity ; increase the quantity of an item already in the inventory .increaseItemQuantity ; increase the quantity of an item already in the inventory
ld a,[wItemQuantity] ld a, [wItemQuantity]
ld b,a ; b = quantity to add ld b, a ; b = quantity to add
ld a,[hl] ; a = existing item quantity ld a, [hl] ; a = existing item quantity
add b ; a = new item quantity add b ; a = new item quantity
cp a,100 cp 100
jp c,.storeNewQuantity ; if the new quantity is less than 100, store it jp c, .storeNewQuantity ; if the new quantity is less than 100, store it
; if the new quantity is greater than or equal to 100, ; if the new quantity is greater than or equal to 100,
; try to max out the current slot and add the rest in a new slot ; try to max out the current slot and add the rest in a new slot
sub a,99 sub 99
ld [wItemQuantity],a ; a = amount left over (to put in the new slot) ld [wItemQuantity], a ; a = amount left over (to put in the new slot)
ld a,d ld a, d
and a ; is there room for a new item slot? and a ; is there room for a new item slot?
jr z,.increaseItemQuantityFailed jr z, .increaseItemQuantityFailed
; if so, store 99 in the current slot and store the rest in a new slot ; if so, store 99 in the current slot and store the rest in a new slot
ld a,99 ld a, 99
ld [hli],a ld [hli], a
jp .loop jp .loop
.increaseItemQuantityFailed .increaseItemQuantityFailed
pop hl pop hl
and a and a
jr .done jr .done
.storeNewQuantity .storeNewQuantity
ld [hl],a ld [hl], a
pop hl pop hl
.success .success
scf scf
@ -88,8 +88,8 @@ AddItemToInventory_:
pop de pop de
pop bc pop bc
pop bc pop bc
ld a,b ld a, b
ld [wItemQuantity],a ; restore the initial value from when the function was called ld [wItemQuantity], a ; restore the initial value from when the function was called
ret ret
; function to remove an item (in varying quantities) from the player's bag or PC box ; function to remove an item (in varying quantities) from the player's bag or PC box
@ -100,49 +100,49 @@ AddItemToInventory_:
RemoveItemFromInventory_: RemoveItemFromInventory_:
push hl push hl
inc hl inc hl
ld a,[wWhichPokemon] ; index (within the inventory) of the item being removed ld a, [wWhichPokemon] ; index (within the inventory) of the item being removed
sla a sla a
add l add l
ld l,a ld l, a
jr nc,.noCarry jr nc, .noCarry
inc h inc h
.noCarry .noCarry
inc hl inc hl
ld a,[wItemQuantity] ; quantity being removed ld a, [wItemQuantity] ; quantity being removed
ld e,a ld e, a
ld a,[hl] ; a = current quantity ld a, [hl] ; a = current quantity
sub e sub e
ld [hld],a ; store new quantity ld [hld], a ; store new quantity
ld [wMaxItemQuantity],a ld [wMaxItemQuantity], a
and a and a
jr nz,.skipMovingUpSlots jr nz, .skipMovingUpSlots
; if the remaining quantity is 0, ; if the remaining quantity is 0,
; remove the emptied item slot and move up all the following item slots ; remove the emptied item slot and move up all the following item slots
.moveSlotsUp .moveSlotsUp
ld e,l ld e, l
ld d,h ld d, h
inc de inc de
inc de ; de = address of the slot following the emptied one inc de ; de = address of the slot following the emptied one
.loop ; loop to move up the following slots .loop ; loop to move up the following slots
ld a,[de] ld a, [de]
inc de inc de
ld [hli],a ld [hli], a
cp a,$ff cp $ff
jr nz,.loop jr nz, .loop
; update menu info ; update menu info
xor a xor a
ld [wListScrollOffset],a ld [wListScrollOffset], a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wBagSavedMenuItem],a ld [wBagSavedMenuItem], a
ld [wSavedListScrollOffset],a ld [wSavedListScrollOffset], a
pop hl pop hl
ld a,[hl] ; a = number of items in inventory ld a, [hl] ; a = number of items in inventory
dec a ; decrement the number of items dec a ; decrement the number of items
ld [hl],a ; store new number of items ld [hl], a ; store new number of items
ld [wListCount],a ld [wListCount], a
cp a,2 cp 2
jr c,.done jr c, .done
ld [wMaxMenuItem],a ld [wMaxMenuItem], a
jr .done jr .done
.skipMovingUpSlots .skipMovingUpSlots
pop hl pop hl

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,11 @@
; Loads tile patterns for tiles used in the pokedex. ; Loads tile patterns for tiles used in the pokedex.
LoadPokedexTilePatterns: LoadPokedexTilePatterns:
call LoadHpBarAndStatusTilePatterns call LoadHpBarAndStatusTilePatterns
ld de,PokedexTileGraphics ld de, PokedexTileGraphics
ld hl,vChars2 + $600 ld hl, vChars2 + $600
lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10 lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
call CopyVideoData call CopyVideoData
ld de,PokeballTileGraphics ld de, PokeballTileGraphics
ld hl,vChars2 + $720 ld hl, vChars2 + $720
lb bc, BANK(PokeballTileGraphics), $01 lb bc, BANK(PokeballTileGraphics), $01
jp CopyVideoData ; load pokeball tile for marking caught mons jp CopyVideoData ; load pokeball tile for marking caught mons

View file

@ -3,60 +3,60 @@ DrawStartMenu:
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
; menu with pokedex ; menu with pokedex
coord hl, 10, 0 coord hl, 10, 0
ld b,$0e ld b, $0e
ld c,$08 ld c, $08
jr nz,.drawTextBoxBorder jr nz, .drawTextBoxBorder
; shorter menu if the player doesn't have the pokedex ; shorter menu if the player doesn't have the pokedex
coord hl, 10, 0 coord hl, 10, 0
ld b,$0c ld b, $0c
ld c,$08 ld c, $08
.drawTextBoxBorder .drawTextBoxBorder
call TextBoxBorder call TextBoxBorder
ld a,D_DOWN | D_UP | START | B_BUTTON | A_BUTTON ld a, D_DOWN | D_UP | START | B_BUTTON | A_BUTTON
ld [wMenuWatchedKeys],a ld [wMenuWatchedKeys], a
ld a,$02 ld a, $02
ld [wTopMenuItemY],a ; Y position of first menu choice ld [wTopMenuItemY], a ; Y position of first menu choice
ld a,$0b ld a, $0b
ld [wTopMenuItemX],a ; X position of first menu choice ld [wTopMenuItemX], a ; X position of first menu choice
ld a,[wBattleAndStartSavedMenuItem] ; remembered menu selection from last time ld a, [wBattleAndStartSavedMenuItem] ; remembered menu selection from last time
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
xor a xor a
ld [wMenuWatchMovingOutOfBounds],a ld [wMenuWatchMovingOutOfBounds], a
ld hl,wd730 ld hl, wd730
set 6,[hl] ; no pauses between printing each letter set 6, [hl] ; no pauses between printing each letter
coord hl, 12, 2 coord hl, 12, 2
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
; case for not having pokedex ; case for not having pokedex
ld a,$06 ld a, $06
jr z,.storeMenuItemCount jr z, .storeMenuItemCount
; case for having pokedex ; case for having pokedex
ld de,StartMenuPokedexText ld de, StartMenuPokedexText
call PrintStartMenuItem call PrintStartMenuItem
ld a,$07 ld a, $07
.storeMenuItemCount .storeMenuItemCount
ld [wMaxMenuItem],a ; number of menu items ld [wMaxMenuItem], a ; number of menu items
ld de,StartMenuPokemonText ld de, StartMenuPokemonText
call PrintStartMenuItem call PrintStartMenuItem
ld de,StartMenuItemText ld de, StartMenuItemText
call PrintStartMenuItem call PrintStartMenuItem
ld de,wPlayerName ; player's name ld de, wPlayerName ; player's name
call PrintStartMenuItem call PrintStartMenuItem
ld a,[wd72e] ld a, [wd72e]
bit 6,a ; is the player using the link feature? bit 6, a ; is the player using the link feature?
; case for not using link feature ; case for not using link feature
ld de,StartMenuSaveText ld de, StartMenuSaveText
jr z,.printSaveOrResetText jr z, .printSaveOrResetText
; case for using link feature ; case for using link feature
ld de,StartMenuResetText ld de, StartMenuResetText
.printSaveOrResetText .printSaveOrResetText
call PrintStartMenuItem call PrintStartMenuItem
ld de,StartMenuOptionText ld de, StartMenuOptionText
call PrintStartMenuItem call PrintStartMenuItem
ld de,StartMenuExitText ld de, StartMenuExitText
call PlaceString call PlaceString
ld hl,wd730 ld hl, wd730
res 6,[hl] ; turn pauses between printing letters back on res 6, [hl] ; turn pauses between printing letters back on
ret ret
StartMenuPokedexText: StartMenuPokedexText:
@ -84,6 +84,6 @@ PrintStartMenuItem:
push hl push hl
call PlaceString call PlaceString
pop hl pop hl
ld de,SCREEN_WIDTH * 2 ld de, SCREEN_WIDTH * 2
add hl,de add hl, de
ret ret

View file

@ -2,133 +2,133 @@ MainMenu:
; Check save file ; Check save file
call InitOptions call InitOptions
xor a xor a
ld [wOptionsInitialized],a ld [wOptionsInitialized], a
inc a inc a
ld [wSaveFileStatus],a ld [wSaveFileStatus], a
call CheckForPlayerNameInSRAM call CheckForPlayerNameInSRAM
jr nc,.mainMenuLoop jr nc, .mainMenuLoop
predef LoadSAV predef LoadSAV
.mainMenuLoop .mainMenuLoop
ld c,20 ld c, 20
call DelayFrames call DelayFrames
xor a ; LINK_STATE_NONE xor a ; LINK_STATE_NONE
ld [wLinkState],a ld [wLinkState], a
ld hl,wPartyAndBillsPCSavedMenuItem ld hl, wPartyAndBillsPCSavedMenuItem
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
ld [hl],a ld [hl], a
ld [wDefaultMap],a ld [wDefaultMap], a
ld hl,wd72e ld hl, wd72e
res 6,[hl] res 6, [hl]
call ClearScreen call ClearScreen
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
call LoadFontTilePatterns call LoadFontTilePatterns
ld hl,wd730 ld hl, wd730
set 6,[hl] set 6, [hl]
ld a,[wSaveFileStatus] ld a, [wSaveFileStatus]
cp a,1 cp 1
jr z,.noSaveFile jr z, .noSaveFile
; there's a save file ; there's a save file
coord hl, 0, 0 coord hl, 0, 0
ld b,6 ld b, 6
ld c,13 ld c, 13
call TextBoxBorder call TextBoxBorder
coord hl, 2, 2 coord hl, 2, 2
ld de,ContinueText ld de, ContinueText
call PlaceString call PlaceString
jr .next2 jr .next2
.noSaveFile .noSaveFile
coord hl, 0, 0 coord hl, 0, 0
ld b,4 ld b, 4
ld c,13 ld c, 13
call TextBoxBorder call TextBoxBorder
coord hl, 2, 2 coord hl, 2, 2
ld de,NewGameText ld de, NewGameText
call PlaceString call PlaceString
.next2 .next2
ld hl,wd730 ld hl, wd730
res 6,[hl] res 6, [hl]
call UpdateSprites call UpdateSprites
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
ld [wMenuJoypadPollCount],a ld [wMenuJoypadPollCount], a
inc a inc a
ld [wTopMenuItemX],a ld [wTopMenuItemX], a
inc a inc a
ld [wTopMenuItemY],a ld [wTopMenuItemY], a
ld a,A_BUTTON | B_BUTTON | START ld a, A_BUTTON | B_BUTTON | START
ld [wMenuWatchedKeys],a ld [wMenuWatchedKeys], a
ld a,[wSaveFileStatus] ld a, [wSaveFileStatus]
ld [wMaxMenuItem],a ld [wMaxMenuItem], a
call HandleMenuInput call HandleMenuInput
bit 1,a ; pressed B? bit 1, a ; pressed B?
jp nz,DisplayTitleScreen ; if so, go back to the title screen jp nz, DisplayTitleScreen ; if so, go back to the title screen
ld c,20 ld c, 20
call DelayFrames call DelayFrames
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld b,a ld b, a
ld a,[wSaveFileStatus] ld a, [wSaveFileStatus]
cp a,2 cp 2
jp z,.skipInc jp z, .skipInc
; If there's no save file, increment the current menu item so that the numbers ; If there's no save file, increment the current menu item so that the numbers
; are the same whether or not there's a save file. ; are the same whether or not there's a save file.
inc b inc b
.skipInc .skipInc
ld a,b ld a, b
and a and a
jr z,.choseContinue jr z, .choseContinue
cp a,1 cp 1
jp z,StartNewGame jp z, StartNewGame
call DisplayOptionMenu call DisplayOptionMenu
ld a,1 ld a, 1
ld [wOptionsInitialized],a ld [wOptionsInitialized], a
jp .mainMenuLoop jp .mainMenuLoop
.choseContinue .choseContinue
call DisplayContinueGameInfo call DisplayContinueGameInfo
ld hl,wCurrentMapScriptFlags ld hl, wCurrentMapScriptFlags
set 5,[hl] set 5, [hl]
.inputLoop .inputLoop
xor a xor a
ld [hJoyPressed],a ld [hJoyPressed], a
ld [hJoyReleased],a ld [hJoyReleased], a
ld [hJoyHeld],a ld [hJoyHeld], a
call Joypad call Joypad
ld a,[hJoyHeld] ld a, [hJoyHeld]
bit 0,a bit 0, a
jr nz,.pressedA jr nz, .pressedA
bit 1,a bit 1, a
jp nz,.mainMenuLoop ; pressed B jp nz, .mainMenuLoop ; pressed B
jr .inputLoop jr .inputLoop
.pressedA .pressedA
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call ClearScreen call ClearScreen
ld a,PLAYER_DIR_DOWN ld a, PLAYER_DIR_DOWN
ld [wPlayerDirection],a ld [wPlayerDirection], a
ld c,10 ld c, 10
call DelayFrames call DelayFrames
ld a,[wNumHoFTeams] ld a, [wNumHoFTeams]
and a and a
jp z,SpecialEnterMap jp z, SpecialEnterMap
ld a,[wCurMap] ; map ID ld a, [wCurMap] ; map ID
cp a,HALL_OF_FAME cp HALL_OF_FAME
jp nz,SpecialEnterMap jp nz, SpecialEnterMap
xor a xor a
ld [wDestinationMap],a ld [wDestinationMap], a
ld hl,wd732 ld hl, wd732
set 2,[hl] ; fly warp or dungeon warp set 2, [hl] ; fly warp or dungeon warp
call SpecialWarpIn call SpecialWarpIn
jp SpecialEnterMap jp SpecialEnterMap
InitOptions: InitOptions:
ld a,1 ; no delay ld a, 1 ; no delay
ld [wLetterPrintingDelayFlags],a ld [wLetterPrintingDelayFlags], a
ld a,3 ; medium speed ld a, 3 ; medium speed
ld [wOptions],a ld [wOptions], a
ret ret
LinkMenu: LinkMenu:
@ -428,154 +428,154 @@ SaveScreenInfoText:
DisplayOptionMenu: DisplayOptionMenu:
coord hl, 0, 0 coord hl, 0, 0
ld b,3 ld b, 3
ld c,18 ld c, 18
call TextBoxBorder call TextBoxBorder
coord hl, 0, 5 coord hl, 0, 5
ld b,3 ld b, 3
ld c,18 ld c, 18
call TextBoxBorder call TextBoxBorder
coord hl, 0, 10 coord hl, 0, 10
ld b,3 ld b, 3
ld c,18 ld c, 18
call TextBoxBorder call TextBoxBorder
coord hl, 1, 1 coord hl, 1, 1
ld de,TextSpeedOptionText ld de, TextSpeedOptionText
call PlaceString call PlaceString
coord hl, 1, 6 coord hl, 1, 6
ld de,BattleAnimationOptionText ld de, BattleAnimationOptionText
call PlaceString call PlaceString
coord hl, 1, 11 coord hl, 1, 11
ld de,BattleStyleOptionText ld de, BattleStyleOptionText
call PlaceString call PlaceString
coord hl, 2, 16 coord hl, 2, 16
ld de,OptionMenuCancelText ld de, OptionMenuCancelText
call PlaceString call PlaceString
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
inc a inc a
ld [wLetterPrintingDelayFlags],a ld [wLetterPrintingDelayFlags], a
ld [wUnusedCD40],a ld [wUnusedCD40], a
ld a,3 ; text speed cursor Y coordinate ld a, 3 ; text speed cursor Y coordinate
ld [wTopMenuItemY],a ld [wTopMenuItemY], a
call SetCursorPositionsFromOptions call SetCursorPositionsFromOptions
ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld [wTopMenuItemX],a ld [wTopMenuItemX], a
ld a,$01 ld a, $01
ld [H_AUTOBGTRANSFERENABLED],a ; enable auto background transfer ld [H_AUTOBGTRANSFERENABLED], a ; enable auto background transfer
call Delay3 call Delay3
.loop .loop
call PlaceMenuCursor call PlaceMenuCursor
call SetOptionsFromCursorPositions call SetOptionsFromCursorPositions
.getJoypadStateLoop .getJoypadStateLoop
call JoypadLowSensitivity call JoypadLowSensitivity
ld a,[hJoy5] ld a, [hJoy5]
ld b,a ld b, a
and a,A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed? and A_BUTTON | B_BUTTON | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ; any key besides select pressed?
jr z,.getJoypadStateLoop jr z, .getJoypadStateLoop
bit 1,b ; B button pressed? bit 1, b ; B button pressed?
jr nz,.exitMenu jr nz, .exitMenu
bit 3,b ; Start button pressed? bit 3, b ; Start button pressed?
jr nz,.exitMenu jr nz, .exitMenu
bit 0,b ; A button pressed? bit 0, b ; A button pressed?
jr z,.checkDirectionKeys jr z, .checkDirectionKeys
ld a,[wTopMenuItemY] ld a, [wTopMenuItemY]
cp a,16 ; is the cursor on Cancel? cp 16 ; is the cursor on Cancel?
jr nz,.loop jr nz, .loop
.exitMenu .exitMenu
ld a,SFX_PRESS_AB ld a, SFX_PRESS_AB
call PlaySound call PlaySound
ret ret
.eraseOldMenuCursor .eraseOldMenuCursor
ld [wTopMenuItemX],a ld [wTopMenuItemX], a
call EraseMenuCursor call EraseMenuCursor
jp .loop jp .loop
.checkDirectionKeys .checkDirectionKeys
ld a,[wTopMenuItemY] ld a, [wTopMenuItemY]
bit 7,b ; Down pressed? bit 7, b ; Down pressed?
jr nz,.downPressed jr nz, .downPressed
bit 6,b ; Up pressed? bit 6, b ; Up pressed?
jr nz,.upPressed jr nz, .upPressed
cp a,8 ; cursor in Battle Animation section? cp 8 ; cursor in Battle Animation section?
jr z,.cursorInBattleAnimation jr z, .cursorInBattleAnimation
cp a,13 ; cursor in Battle Style section? cp 13 ; cursor in Battle Style section?
jr z,.cursorInBattleStyle jr z, .cursorInBattleStyle
cp a,16 ; cursor on Cancel? cp 16 ; cursor on Cancel?
jr z,.loop jr z, .loop
.cursorInTextSpeed .cursorInTextSpeed
bit 5,b ; Left pressed? bit 5, b ; Left pressed?
jp nz,.pressedLeftInTextSpeed jp nz, .pressedLeftInTextSpeed
jp .pressedRightInTextSpeed jp .pressedRightInTextSpeed
.downPressed .downPressed
cp a,16 cp 16
ld b,-13 ld b, -13
ld hl,wOptionsTextSpeedCursorX ld hl, wOptionsTextSpeedCursorX
jr z,.updateMenuVariables jr z, .updateMenuVariables
ld b,5 ld b, 5
cp a,3 cp 3
inc hl inc hl
jr z,.updateMenuVariables jr z, .updateMenuVariables
cp a,8 cp 8
inc hl inc hl
jr z,.updateMenuVariables jr z, .updateMenuVariables
ld b,3 ld b, 3
inc hl inc hl
jr .updateMenuVariables jr .updateMenuVariables
.upPressed .upPressed
cp a,8 cp 8
ld b,-5 ld b, -5
ld hl,wOptionsTextSpeedCursorX ld hl, wOptionsTextSpeedCursorX
jr z,.updateMenuVariables jr z, .updateMenuVariables
cp a,13 cp 13
inc hl inc hl
jr z,.updateMenuVariables jr z, .updateMenuVariables
cp a,16 cp 16
ld b,-3 ld b, -3
inc hl inc hl
jr z,.updateMenuVariables jr z, .updateMenuVariables
ld b,13 ld b, 13
inc hl inc hl
.updateMenuVariables .updateMenuVariables
add b add b
ld [wTopMenuItemY],a ld [wTopMenuItemY], a
ld a,[hl] ld a, [hl]
ld [wTopMenuItemX],a ld [wTopMenuItemX], a
call PlaceUnfilledArrowMenuCursor call PlaceUnfilledArrowMenuCursor
jp .loop jp .loop
.cursorInBattleAnimation .cursorInBattleAnimation
ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate ld a, [wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
xor a,$0b ; toggle between 1 and 10 xor $0b ; toggle between 1 and 10
ld [wOptionsBattleAnimCursorX],a ld [wOptionsBattleAnimCursorX], a
jp .eraseOldMenuCursor jp .eraseOldMenuCursor
.cursorInBattleStyle .cursorInBattleStyle
ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate ld a, [wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
xor a,$0b ; toggle between 1 and 10 xor $0b ; toggle between 1 and 10
ld [wOptionsBattleStyleCursorX],a ld [wOptionsBattleStyleCursorX], a
jp .eraseOldMenuCursor jp .eraseOldMenuCursor
.pressedLeftInTextSpeed .pressedLeftInTextSpeed
ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
cp a,1 cp 1
jr z,.updateTextSpeedXCoord jr z, .updateTextSpeedXCoord
cp a,7 cp 7
jr nz,.fromSlowToMedium jr nz, .fromSlowToMedium
sub a,6 sub 6
jr .updateTextSpeedXCoord jr .updateTextSpeedXCoord
.fromSlowToMedium .fromSlowToMedium
sub a,7 sub 7
jr .updateTextSpeedXCoord jr .updateTextSpeedXCoord
.pressedRightInTextSpeed .pressedRightInTextSpeed
ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
cp a,14 cp 14
jr z,.updateTextSpeedXCoord jr z, .updateTextSpeedXCoord
cp a,7 cp 7
jr nz,.fromFastToMedium jr nz, .fromFastToMedium
add a,7 add 7
jr .updateTextSpeedXCoord jr .updateTextSpeedXCoord
.fromFastToMedium .fromFastToMedium
add a,6 add 6
.updateTextSpeedXCoord .updateTextSpeedXCoord
ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate ld [wOptionsTextSpeedCursorX], a ; text speed cursor X coordinate
jp .eraseOldMenuCursor jp .eraseOldMenuCursor
TextSpeedOptionText: TextSpeedOptionText:
@ -595,79 +595,79 @@ OptionMenuCancelText:
; sets the options variable according to the current placement of the menu cursors in the options menu ; sets the options variable according to the current placement of the menu cursors in the options menu
SetOptionsFromCursorPositions: SetOptionsFromCursorPositions:
ld hl,TextSpeedOptionData ld hl, TextSpeedOptionData
ld a,[wOptionsTextSpeedCursorX] ; text speed cursor X coordinate ld a, [wOptionsTextSpeedCursorX] ; text speed cursor X coordinate
ld c,a ld c, a
.loop .loop
ld a,[hli] ld a, [hli]
cp c cp c
jr z,.textSpeedMatchFound jr z, .textSpeedMatchFound
inc hl inc hl
jr .loop jr .loop
.textSpeedMatchFound .textSpeedMatchFound
ld a,[hl] ld a, [hl]
ld d,a ld d, a
ld a,[wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate ld a, [wOptionsBattleAnimCursorX] ; battle animation cursor X coordinate
dec a dec a
jr z,.battleAnimationOn jr z, .battleAnimationOn
.battleAnimationOff .battleAnimationOff
set 7,d set 7, d
jr .checkBattleStyle jr .checkBattleStyle
.battleAnimationOn .battleAnimationOn
res 7,d res 7, d
.checkBattleStyle .checkBattleStyle
ld a,[wOptionsBattleStyleCursorX] ; battle style cursor X coordinate ld a, [wOptionsBattleStyleCursorX] ; battle style cursor X coordinate
dec a dec a
jr z,.battleStyleShift jr z, .battleStyleShift
.battleStyleSet .battleStyleSet
set 6,d set 6, d
jr .storeOptions jr .storeOptions
.battleStyleShift .battleStyleShift
res 6,d res 6, d
.storeOptions .storeOptions
ld a,d ld a, d
ld [wOptions],a ld [wOptions], a
ret ret
; reads the options variable and places menu cursors in the correct positions within the options menu ; reads the options variable and places menu cursors in the correct positions within the options menu
SetCursorPositionsFromOptions: SetCursorPositionsFromOptions:
ld hl,TextSpeedOptionData + 1 ld hl, TextSpeedOptionData + 1
ld a,[wOptions] ld a, [wOptions]
ld c,a ld c, a
and a,$3f and $3f
push bc push bc
ld de,2 ld de, 2
call IsInArray call IsInArray
pop bc pop bc
dec hl dec hl
ld a,[hl] ld a, [hl]
ld [wOptionsTextSpeedCursorX],a ; text speed cursor X coordinate ld [wOptionsTextSpeedCursorX], a ; text speed cursor X coordinate
coord hl, 0, 3 coord hl, 0, 3
call .placeUnfilledRightArrow call .placeUnfilledRightArrow
sla c sla c
ld a,1 ; On ld a, 1 ; On
jr nc,.storeBattleAnimationCursorX jr nc, .storeBattleAnimationCursorX
ld a,10 ; Off ld a, 10 ; Off
.storeBattleAnimationCursorX .storeBattleAnimationCursorX
ld [wOptionsBattleAnimCursorX],a ; battle animation cursor X coordinate ld [wOptionsBattleAnimCursorX], a ; battle animation cursor X coordinate
coord hl, 0, 8 coord hl, 0, 8
call .placeUnfilledRightArrow call .placeUnfilledRightArrow
sla c sla c
ld a,1 ld a, 1
jr nc,.storeBattleStyleCursorX jr nc, .storeBattleStyleCursorX
ld a,10 ld a, 10
.storeBattleStyleCursorX .storeBattleStyleCursorX
ld [wOptionsBattleStyleCursorX],a ; battle style cursor X coordinate ld [wOptionsBattleStyleCursorX], a ; battle style cursor X coordinate
coord hl, 0, 13 coord hl, 0, 13
call .placeUnfilledRightArrow call .placeUnfilledRightArrow
; cursor in front of Cancel ; cursor in front of Cancel
coord hl, 0, 16 coord hl, 0, 16
ld a,1 ld a, 1
.placeUnfilledRightArrow .placeUnfilledRightArrow
ld e,a ld e, a
ld d,0 ld d, 0
add hl,de add hl, de
ld [hl],$ec ; unfilled right arrow menu cursor ld [hl], $ec ; unfilled right arrow menu cursor
ret ret
; table that indicates how the 3 text speed options affect frame delays ; table that indicates how the 3 text speed options affect frame delays

View file

@ -19,83 +19,83 @@
; f8: leveled up ; f8: leveled up
DrawPartyMenu_: DrawPartyMenu_:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_: RedrawPartyMenu_:
ld a,[wPartyMenuTypeOrMessageID] ld a, [wPartyMenuTypeOrMessageID]
cp a,SWAP_MONS_PARTY_MENU cp SWAP_MONS_PARTY_MENU
jp z,.printMessage jp z, .printMessage
call ErasePartyMenuCursors call ErasePartyMenuCursors
callba InitPartyMenuBlkPacket callba InitPartyMenuBlkPacket
coord hl, 3, 0 coord hl, 3, 0
ld de,wPartySpecies ld de, wPartySpecies
xor a xor a
ld c,a ld c, a
ld [hPartyMonIndex],a ld [hPartyMonIndex], a
ld [wWhichPartyMenuHPBar],a ld [wWhichPartyMenuHPBar], a
.loop .loop
ld a,[de] ld a, [de]
cp a,$FF ; reached the terminator? cp $FF ; reached the terminator?
jp z,.afterDrawingMonEntries jp z, .afterDrawingMonEntries
push bc push bc
push de push de
push hl push hl
ld a,c ld a, c
push hl push hl
ld hl,wPartyMonNicks ld hl, wPartyMonNicks
call GetPartyMonName call GetPartyMonName
pop hl pop hl
call PlaceString ; print the pokemon's name call PlaceString ; print the pokemon's name
callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ld a,[hPartyMonIndex] ld a, [hPartyMonIndex]
ld [wWhichPokemon],a ld [wWhichPokemon], a
inc a inc a
ld [hPartyMonIndex],a ld [hPartyMonIndex], a
call LoadMonData call LoadMonData
pop hl pop hl
push hl push hl
ld a,[wMenuItemToSwap] ld a, [wMenuItemToSwap]
and a ; is the player swapping pokemon positions? and a ; is the player swapping pokemon positions?
jr z,.skipUnfilledRightArrow jr z, .skipUnfilledRightArrow
; if the player is swapping pokemon positions ; if the player is swapping pokemon positions
dec a dec a
ld b,a ld b, a
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
cp b ; is the player swapping the current pokemon in the list? cp b ; is the player swapping the current pokemon in the list?
jr nz,.skipUnfilledRightArrow jr nz, .skipUnfilledRightArrow
; the player is swapping the current pokemon in the list ; the player is swapping the current pokemon in the list
dec hl dec hl
dec hl dec hl
dec hl dec hl
ld a,"▷" ; unfilled right arrow menu cursor ld a, "▷" ; unfilled right arrow menu cursor
ld [hli],a ; place the cursor ld [hli], a ; place the cursor
inc hl inc hl
inc hl inc hl
.skipUnfilledRightArrow .skipUnfilledRightArrow
ld a,[wPartyMenuTypeOrMessageID] ; menu type ld a, [wPartyMenuTypeOrMessageID] ; menu type
cp a,TMHM_PARTY_MENU cp TMHM_PARTY_MENU
jr z,.teachMoveMenu jr z, .teachMoveMenu
cp a,EVO_STONE_PARTY_MENU cp EVO_STONE_PARTY_MENU
jr z,.evolutionStoneMenu jr z, .evolutionStoneMenu
push hl push hl
ld bc,14 ; 14 columns to the right ld bc, 14 ; 14 columns to the right
add hl,bc add hl, bc
ld de,wLoadedMonStatus ld de, wLoadedMonStatus
call PrintStatusCondition call PrintStatusCondition
pop hl pop hl
push hl push hl
ld bc,SCREEN_WIDTH + 1 ; down 1 row and right 1 column ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
ld a,[hFlags_0xFFF6] ld a, [hFlags_0xFFF6]
set 0,a set 0, a
ld [hFlags_0xFFF6],a ld [hFlags_0xFFF6], a
add hl,bc add hl, bc
predef DrawHP2 ; draw HP bar and prints current / max HP predef DrawHP2 ; draw HP bar and prints current / max HP
ld a,[hFlags_0xFFF6] ld a, [hFlags_0xFFF6]
res 0,a res 0, a
ld [hFlags_0xFFF6],a ld [hFlags_0xFFF6], a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB) call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl pop hl
jr .printLevel jr .printLevel
@ -103,26 +103,26 @@ RedrawPartyMenu_:
push hl push hl
predef CanLearnTM ; check if the pokemon can learn the move predef CanLearnTM ; check if the pokemon can learn the move
pop hl pop hl
ld de,.ableToLearnMoveText ld de, .ableToLearnMoveText
ld a,c ld a, c
and a and a
jr nz,.placeMoveLearnabilityString jr nz, .placeMoveLearnabilityString
ld de,.notAbleToLearnMoveText ld de, .notAbleToLearnMoveText
.placeMoveLearnabilityString .placeMoveLearnabilityString
ld bc,20 + 9 ; down 1 row and right 9 columns ld bc, 20 + 9 ; down 1 row and right 9 columns
push hl push hl
add hl,bc add hl, bc
call PlaceString call PlaceString
pop hl pop hl
.printLevel .printLevel
ld bc,10 ; move 10 columns to the right ld bc, 10 ; move 10 columns to the right
add hl,bc add hl, bc
call PrintLevel call PrintLevel
pop hl pop hl
pop de pop de
inc de inc de
ld bc,2 * 20 ld bc, 2 * 20
add hl,bc add hl, bc
pop bc pop bc
inc c inc c
jp .loop jp .loop
@ -132,54 +132,54 @@ RedrawPartyMenu_:
db "NOT ABLE@" db "NOT ABLE@"
.evolutionStoneMenu .evolutionStoneMenu
push hl push hl
ld hl,EvosMovesPointerTable ld hl, EvosMovesPointerTable
ld b,0 ld b, 0
ld a,[wLoadedMonSpecies] ld a, [wLoadedMonSpecies]
dec a dec a
add a add a
rl b rl b
ld c,a ld c, a
add hl,bc add hl, bc
ld de,wcd6d ld de, wcd6d
ld a,BANK(EvosMovesPointerTable) ld a, BANK(EvosMovesPointerTable)
ld bc,2 ld bc, 2
call FarCopyData call FarCopyData
ld hl,wcd6d ld hl, wcd6d
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld de,wcd6d ld de, wcd6d
ld a,BANK(EvosMovesPointerTable) ld a, BANK(EvosMovesPointerTable)
ld bc,Mon133_EvosEnd - Mon133_EvosMoves ld bc, Mon133_EvosEnd - Mon133_EvosMoves
call FarCopyData call FarCopyData
ld hl,wcd6d ld hl, wcd6d
ld de,.notAbleToEvolveText ld de, .notAbleToEvolveText
; loop through the pokemon's evolution entries ; loop through the pokemon's evolution entries
.checkEvolutionsLoop .checkEvolutionsLoop
ld a,[hli] ld a, [hli]
and a ; reached terminator? and a ; reached terminator?
jr z,.placeEvolutionStoneString ; if so, place the "NOT ABLE" string jr z, .placeEvolutionStoneString ; if so, place the "NOT ABLE" string
inc hl inc hl
inc hl inc hl
cp a,EV_ITEM cp EV_ITEM
jr nz,.checkEvolutionsLoop jr nz, .checkEvolutionsLoop
; if it's a stone evolution entry ; if it's a stone evolution entry
dec hl dec hl
dec hl dec hl
ld b,[hl] ld b, [hl]
ld a,[wEvoStoneItemID] ; the stone the player used ld a, [wEvoStoneItemID] ; the stone the player used
inc hl inc hl
inc hl inc hl
inc hl inc hl
cp b ; does the player's stone match this evolution entry's stone? cp b ; does the player's stone match this evolution entry's stone?
jr nz,.checkEvolutionsLoop jr nz, .checkEvolutionsLoop
; if it does match ; if it does match
ld de,.ableToEvolveText ld de, .ableToEvolveText
.placeEvolutionStoneString .placeEvolutionStoneString
ld bc,20 + 9 ; down 1 row and right 9 columns ld bc, 20 + 9 ; down 1 row and right 9 columns
pop hl pop hl
push hl push hl
add hl,bc add hl, bc
call PlaceString call PlaceString
pop hl pop hl
jr .printLevel jr .printLevel
@ -191,44 +191,44 @@ RedrawPartyMenu_:
ld b, SET_PAL_PARTY_MENU ld b, SET_PAL_PARTY_MENU
call RunPaletteCommand call RunPaletteCommand
.printMessage .printMessage
ld hl,wd730 ld hl, wd730
ld a,[hl] ld a, [hl]
push af push af
push hl push hl
set 6,[hl] ; turn off letter printing delay set 6, [hl] ; turn off letter printing delay
ld a,[wPartyMenuTypeOrMessageID] ; message ID ld a, [wPartyMenuTypeOrMessageID] ; message ID
cp a,$F0 cp $F0
jr nc,.printItemUseMessage jr nc, .printItemUseMessage
add a add a
ld hl,PartyMenuMessagePointers ld hl, PartyMenuMessagePointers
ld b,0 ld b, 0
ld c,a ld c, a
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
call PrintText call PrintText
.done .done
pop hl pop hl
pop af pop af
ld [hl],a ld [hl], a
ld a,1 ld a, 1
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call Delay3 call Delay3
jp GBPalNormal jp GBPalNormal
.printItemUseMessage .printItemUseMessage
and a,$0F and $0F
ld hl,PartyMenuItemUseMessagePointers ld hl, PartyMenuItemUseMessagePointers
add a add a
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
push hl push hl
ld a,[wUsedItemOnWhichPokemon] ld a, [wUsedItemOnWhichPokemon]
ld hl,wPartyMonNicks ld hl, wPartyMonNicks
call GetPartyMonName call GetPartyMonName
pop hl pop hl
call PrintText call PrintText

View file

@ -17,34 +17,34 @@ PCMainMenu:
bit 1, a ;if player pressed B bit 1, a ;if player pressed B
jp nz, LogOff jp nz, LogOff
ld a, [wMaxMenuItem] ld a, [wMaxMenuItem]
cp a, 2 cp 2
jr nz, .next ;if not 2 menu items (not counting log off) (2 occurs before you get the pokedex) jr nz, .next ;if not 2 menu items (not counting log off) (2 occurs before you get the pokedex)
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp a, 1 cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc jr z, .playersPC ;if current menu item id is 1, it's players pc
jp LogOff ;otherwise, it's 2, and you're logging off jp LogOff ;otherwise, it's 2, and you're logging off
.next .next
cp a, 3 cp 3
jr nz, .next2 ;if not 3 menu items (not counting log off) (3 occurs after you get the pokedex, before you beat the pokemon league) jr nz, .next2 ;if not 3 menu items (not counting log off) (3 occurs after you get the pokedex, before you beat the pokemon league)
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp a, 1 cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc jr z, .playersPC ;if current menu item id is 1, it's players pc
cp a, 2 cp 2
jp z, OaksPC ;if current menu item id is 2, it's oaks pc jp z, OaksPC ;if current menu item id is 2, it's oaks pc
jp LogOff ;otherwise, it's 3, and you're logging off jp LogOff ;otherwise, it's 3, and you're logging off
.next2 .next2
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jp z, BillsPC ;if current menu item id is 0, it's bills pc jp z, BillsPC ;if current menu item id is 0, it's bills pc
cp a, 1 cp 1
jr z, .playersPC ;if current menu item id is 1, it's players pc jr z, .playersPC ;if current menu item id is 1, it's players pc
cp a, 2 cp 2
jp z, OaksPC ;if current menu item id is 2, it's oaks pc jp z, OaksPC ;if current menu item id is 2, it's oaks pc
cp a, 3 cp 3
jp z, PKMNLeague ;if current menu item id is 3, it's pkmnleague jp z, PKMNLeague ;if current menu item id is 3, it's pkmnleague
jp LogOff ;otherwise, it's 4, and you're logging off jp LogOff ;otherwise, it's 4, and you're logging off
.playersPC .playersPC

View file

@ -2,53 +2,53 @@ ShowPokedexMenu:
call GBPalWhiteOut call GBPalWhiteOut
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
push af push af
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wListScrollOffset],a ld [wListScrollOffset], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
inc a inc a
ld [wd11e],a ld [wd11e], a
ld [hJoy7],a ld [hJoy7], a
.setUpGraphics .setUpGraphics
ld b, SET_PAL_GENERIC ld b, SET_PAL_GENERIC
call RunPaletteCommand call RunPaletteCommand
callab LoadPokedexTilePatterns callab LoadPokedexTilePatterns
.doPokemonListMenu .doPokemonListMenu
ld hl,wTopMenuItemY ld hl, wTopMenuItemY
ld a,3 ld a, 3
ld [hli],a ; top menu item Y ld [hli], a ; top menu item Y
xor a xor a
ld [hli],a ; top menu item X ld [hli], a ; top menu item X
inc a inc a
ld [wMenuWatchMovingOutOfBounds],a ld [wMenuWatchMovingOutOfBounds], a
inc hl inc hl
inc hl inc hl
ld a,6 ld a, 6
ld [hli],a ; max menu item ID ld [hli], a ; max menu item ID
ld [hl],D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON ld [hl], D_LEFT | D_RIGHT | B_BUTTON | A_BUTTON
call HandlePokedexListMenu call HandlePokedexListMenu
jr c,.goToSideMenu ; if the player chose a pokemon from the list jr c, .goToSideMenu ; if the player chose a pokemon from the list
.exitPokedex .exitPokedex
xor a xor a
ld [wMenuWatchMovingOutOfBounds],a ld [wMenuWatchMovingOutOfBounds], a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
ld [hJoy7],a ld [hJoy7], a
ld [wWastedByteCD3A],a ld [wWastedByteCD3A], a
ld [wOverrideSimulatedJoypadStatesMask],a ld [wOverrideSimulatedJoypadStatesMask], a
pop af pop af
ld [wListScrollOffset],a ld [wListScrollOffset], a
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
jp ReloadMapData jp ReloadMapData
.goToSideMenu .goToSideMenu
call HandlePokedexSideMenu call HandlePokedexSideMenu
dec b dec b
jr z,.exitPokedex ; if the player chose Quit jr z, .exitPokedex ; if the player chose Quit
dec b dec b
jr z,.doPokemonListMenu ; if pokemon not seen or player pressed B button jr z, .doPokemonListMenu ; if pokemon not seen or player pressed B button
jp .setUpGraphics ; if pokemon data or area was shown jp .setUpGraphics ; if pokemon data or area was shown
; handles the menu on the lower right in the pokedex screen ; handles the menu on the lower right in the pokedex screen
@ -59,68 +59,68 @@ ShowPokedexMenu:
; 02: the pokemon has not been seen yet or the player pressed the B button ; 02: the pokemon has not been seen yet or the player pressed the B button
HandlePokedexSideMenu: HandlePokedexSideMenu:
call PlaceUnfilledArrowMenuCursor call PlaceUnfilledArrowMenuCursor
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
push af push af
ld b,a ld b, a
ld a,[wLastMenuItem] ld a, [wLastMenuItem]
push af push af
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
push af push af
add b add b
inc a inc a
ld [wd11e],a ld [wd11e], a
ld a,[wd11e] ld a, [wd11e]
push af push af
ld a,[wDexMaxSeenMon] ld a, [wDexMaxSeenMon]
push af ; this doesn't need to be preserved push af ; this doesn't need to be preserved
ld hl,wPokedexSeen ld hl, wPokedexSeen
call IsPokemonBitSet call IsPokemonBitSet
ld b,2 ld b, 2
jr z,.exitSideMenu jr z, .exitSideMenu
call PokedexToIndex call PokedexToIndex
ld hl,wTopMenuItemY ld hl, wTopMenuItemY
ld a,10 ld a, 10
ld [hli],a ; top menu item Y ld [hli], a ; top menu item Y
ld a,15 ld a, 15
ld [hli],a ; top menu item X ld [hli], a ; top menu item X
xor a xor a
ld [hli],a ; current menu item ID ld [hli], a ; current menu item ID
inc hl inc hl
ld a,3 ld a, 3
ld [hli],a ; max menu item ID ld [hli], a ; max menu item ID
;ld a, A_BUTTON | B_BUTTON ;ld a, A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys (A button and B button) ld [hli], a ; menu watched keys (A button and B button)
xor a xor a
ld [hli],a ; old menu item ID ld [hli], a ; old menu item ID
ld [wMenuWatchMovingOutOfBounds],a ld [wMenuWatchMovingOutOfBounds], a
.handleMenuInput .handleMenuInput
call HandleMenuInput call HandleMenuInput
bit 1,a ; was the B button pressed? bit 1, a ; was the B button pressed?
ld b,2 ld b, 2
jr nz,.buttonBPressed jr nz, .buttonBPressed
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jr z,.choseData jr z, .choseData
dec a dec a
jr z,.choseCry jr z, .choseCry
dec a dec a
jr z,.choseArea jr z, .choseArea
.choseQuit .choseQuit
ld b,1 ld b, 1
.exitSideMenu .exitSideMenu
pop af pop af
ld [wDexMaxSeenMon],a ld [wDexMaxSeenMon], a
pop af pop af
ld [wd11e],a ld [wd11e], a
pop af pop af
ld [wListScrollOffset],a ld [wListScrollOffset], a
pop af pop af
ld [wLastMenuItem],a ld [wLastMenuItem], a
pop af pop af
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
push bc push bc
coord hl, 0, 3 coord hl, 0, 3
ld de,20 ld de, 20
lb bc, " ", 13 lb bc, " ", 13
call DrawTileLine ; cover up the menu cursor in the pokemon list call DrawTileLine ; cover up the menu cursor in the pokemon list
pop bc pop bc
@ -129,7 +129,7 @@ HandlePokedexSideMenu:
.buttonBPressed .buttonBPressed
push bc push bc
coord hl, 15, 10 coord hl, 15, 10
ld de,20 ld de, 20
lb bc, " ", 7 lb bc, " ", 7
call DrawTileLine ; cover up the menu cursor in the side menu call DrawTileLine ; cover up the menu cursor in the side menu
pop bc pop bc
@ -137,130 +137,130 @@ HandlePokedexSideMenu:
.choseData .choseData
call ShowPokedexDataInternal call ShowPokedexDataInternal
ld b,0 ld b, 0
jr .exitSideMenu jr .exitSideMenu
; play pokemon cry ; play pokemon cry
.choseCry .choseCry
ld a,[wd11e] ld a, [wd11e]
call GetCryData call GetCryData
call PlaySound call PlaySound
jr .handleMenuInput jr .handleMenuInput
.choseArea .choseArea
predef LoadTownMap_Nest ; display pokemon areas predef LoadTownMap_Nest ; display pokemon areas
ld b,0 ld b, 0
jr .exitSideMenu jr .exitSideMenu
; handles the list of pokemon on the left of the pokedex screen ; handles the list of pokemon on the left of the pokedex screen
; sets carry flag if player presses A, unsets carry flag if player presses B ; sets carry flag if player presses A, unsets carry flag if player presses B
HandlePokedexListMenu: HandlePokedexListMenu:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
; draw the horizontal line separating the seen and owned amounts from the menu ; draw the horizontal line separating the seen and owned amounts from the menu
coord hl, 15, 8 coord hl, 15, 8
ld a,"─" ld a, "─"
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
ld [hli],a ld [hli], a
coord hl, 14, 0 coord hl, 14, 0
ld [hl],$71 ; vertical line tile ld [hl], $71 ; vertical line tile
coord hl, 14, 1 coord hl, 14, 1
call DrawPokedexVerticalLine call DrawPokedexVerticalLine
coord hl, 14, 9 coord hl, 14, 9
call DrawPokedexVerticalLine call DrawPokedexVerticalLine
ld hl,wPokedexSeen ld hl, wPokedexSeen
ld b,wPokedexSeenEnd - wPokedexSeen ld b, wPokedexSeenEnd - wPokedexSeen
call CountSetBits call CountSetBits
ld de, wNumSetBits ld de, wNumSetBits
coord hl, 16, 3 coord hl, 16, 3
lb bc, 1, 3 lb bc, 1, 3
call PrintNumber ; print number of seen pokemon call PrintNumber ; print number of seen pokemon
ld hl,wPokedexOwned ld hl, wPokedexOwned
ld b,wPokedexOwnedEnd - wPokedexOwned ld b, wPokedexOwnedEnd - wPokedexOwned
call CountSetBits call CountSetBits
ld de, wNumSetBits ld de, wNumSetBits
coord hl, 16, 6 coord hl, 16, 6
lb bc, 1, 3 lb bc, 1, 3
call PrintNumber ; print number of owned pokemon call PrintNumber ; print number of owned pokemon
coord hl, 16, 2 coord hl, 16, 2
ld de,PokedexSeenText ld de, PokedexSeenText
call PlaceString call PlaceString
coord hl, 16, 5 coord hl, 16, 5
ld de,PokedexOwnText ld de, PokedexOwnText
call PlaceString call PlaceString
coord hl, 1, 1 coord hl, 1, 1
ld de,PokedexContentsText ld de, PokedexContentsText
call PlaceString call PlaceString
coord hl, 16, 10 coord hl, 16, 10
ld de,PokedexMenuItemsText ld de, PokedexMenuItemsText
call PlaceString call PlaceString
; find the highest pokedex number among the pokemon the player has seen ; find the highest pokedex number among the pokemon the player has seen
ld hl,wPokedexSeenEnd - 1 ld hl, wPokedexSeenEnd - 1
ld b,(wPokedexSeenEnd - wPokedexSeen) * 8 + 1 ld b, (wPokedexSeenEnd - wPokedexSeen) * 8 + 1
.maxSeenPokemonLoop .maxSeenPokemonLoop
ld a,[hld] ld a, [hld]
ld c,8 ld c, 8
.maxSeenPokemonInnerLoop .maxSeenPokemonInnerLoop
dec b dec b
sla a sla a
jr c,.storeMaxSeenPokemon jr c, .storeMaxSeenPokemon
dec c dec c
jr nz,.maxSeenPokemonInnerLoop jr nz, .maxSeenPokemonInnerLoop
jr .maxSeenPokemonLoop jr .maxSeenPokemonLoop
.storeMaxSeenPokemon .storeMaxSeenPokemon
ld a,b ld a, b
ld [wDexMaxSeenMon],a ld [wDexMaxSeenMon], a
.loop .loop
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 2 coord hl, 4, 2
lb bc, 14, 10 lb bc, 14, 10
call ClearScreenArea call ClearScreenArea
coord hl, 1, 3 coord hl, 1, 3
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
ld [wd11e],a ld [wd11e], a
ld d,7 ld d, 7
ld a,[wDexMaxSeenMon] ld a, [wDexMaxSeenMon]
cp a,7 cp 7
jr nc,.printPokemonLoop jr nc, .printPokemonLoop
ld d,a ld d, a
dec a dec a
ld [wMaxMenuItem],a ld [wMaxMenuItem], a
; loop to print pokemon pokedex numbers and names ; loop to print pokemon pokedex numbers and names
; if the player has owned the pokemon, it puts a pokeball beside the name ; if the player has owned the pokemon, it puts a pokeball beside the name
.printPokemonLoop .printPokemonLoop
ld a,[wd11e] ld a, [wd11e]
inc a inc a
ld [wd11e],a ld [wd11e], a
push af push af
push de push de
push hl push hl
ld de,-SCREEN_WIDTH ld de, -SCREEN_WIDTH
add hl,de add hl, de
ld de,wd11e ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3 lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print the pokedex number call PrintNumber ; print the pokedex number
ld de,SCREEN_WIDTH ld de, SCREEN_WIDTH
add hl,de add hl, de
dec hl dec hl
push hl push hl
ld hl,wPokedexOwned ld hl, wPokedexOwned
call IsPokemonBitSet call IsPokemonBitSet
pop hl pop hl
ld a," " ld a, " "
jr z,.writeTile jr z, .writeTile
ld a,$72 ; pokeball tile ld a, $72 ; pokeball tile
.writeTile .writeTile
ld [hl],a ; put a pokeball next to pokemon that the player has owned ld [hl], a ; put a pokeball next to pokemon that the player has owned
push hl push hl
ld hl,wPokedexSeen ld hl, wPokedexSeen
call IsPokemonBitSet call IsPokemonBitSet
jr nz,.getPokemonName ; if the player has seen the pokemon jr nz, .getPokemonName ; if the player has seen the pokemon
ld de,.dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon ld de, .dashedLine ; print a dashed line in place of the name if the player hasn't seen the pokemon
jr .skipGettingName jr .skipGettingName
.dashedLine ; for unseen pokemon in the list .dashedLine ; for unseen pokemon in the list
db "----------@" db "----------@"
@ -272,73 +272,73 @@ HandlePokedexListMenu:
inc hl inc hl
call PlaceString call PlaceString
pop hl pop hl
ld bc,2 * SCREEN_WIDTH ld bc, 2 * SCREEN_WIDTH
add hl,bc add hl, bc
pop de pop de
pop af pop af
ld [wd11e],a ld [wd11e], a
dec d dec d
jr nz,.printPokemonLoop jr nz, .printPokemonLoop
ld a,01 ld a, 01
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call Delay3 call Delay3
call GBPalNormal call GBPalNormal
call HandleMenuInput call HandleMenuInput
bit 1,a ; was the B button pressed? bit 1, a ; was the B button pressed?
jp nz,.buttonBPressed jp nz, .buttonBPressed
.checkIfUpPressed .checkIfUpPressed
bit 6,a ; was Up pressed? bit 6, a ; was Up pressed?
jr z,.checkIfDownPressed jr z, .checkIfDownPressed
.upPressed ; scroll up one row .upPressed ; scroll up one row
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
and a and a
jp z,.loop jp z, .loop
dec a dec a
ld [wListScrollOffset],a ld [wListScrollOffset], a
jp .loop jp .loop
.checkIfDownPressed .checkIfDownPressed
bit 7,a ; was Down pressed? bit 7, a ; was Down pressed?
jr z,.checkIfRightPressed jr z, .checkIfRightPressed
.downPressed ; scroll down one row .downPressed ; scroll down one row
ld a,[wDexMaxSeenMon] ld a, [wDexMaxSeenMon]
cp a,7 cp 7
jp c,.loop ; can't if the list is shorter than 7 jp c, .loop ; can't if the list is shorter than 7
sub a,7 sub 7
ld b,a ld b, a
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
cp b cp b
jp z,.loop jp z, .loop
inc a inc a
ld [wListScrollOffset],a ld [wListScrollOffset], a
jp .loop jp .loop
.checkIfRightPressed .checkIfRightPressed
bit 4,a ; was Right pressed? bit 4, a ; was Right pressed?
jr z,.checkIfLeftPressed jr z, .checkIfLeftPressed
.rightPressed ; scroll down 7 rows .rightPressed ; scroll down 7 rows
ld a,[wDexMaxSeenMon] ld a, [wDexMaxSeenMon]
cp a,7 cp 7
jp c,.loop ; can't if the list is shorter than 7 jp c, .loop ; can't if the list is shorter than 7
sub a,6 sub 6
ld b,a ld b, a
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
add a,7 add 7
ld [wListScrollOffset],a ld [wListScrollOffset], a
cp b cp b
jp c,.loop jp c, .loop
dec b dec b
ld a,b ld a, b
ld [wListScrollOffset],a ld [wListScrollOffset], a
jp .loop jp .loop
.checkIfLeftPressed ; scroll up 7 rows .checkIfLeftPressed ; scroll up 7 rows
bit 5,a ; was Left pressed? bit 5, a ; was Left pressed?
jr z,.buttonAPressed jr z, .buttonAPressed
.leftPressed .leftPressed
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
sub a,7 sub 7
ld [wListScrollOffset],a ld [wListScrollOffset], a
jp nc,.loop jp nc, .loop
xor a xor a
ld [wListScrollOffset],a ld [wListScrollOffset], a
jp .loop jp .loop
.buttonAPressed .buttonAPressed
scf scf
@ -348,15 +348,15 @@ HandlePokedexListMenu:
ret ret
DrawPokedexVerticalLine: DrawPokedexVerticalLine:
ld c,9 ; height of line ld c, 9 ; height of line
ld de,SCREEN_WIDTH ld de, SCREEN_WIDTH
ld a,$71 ; vertical line tile ld a, $71 ; vertical line tile
.loop .loop
ld [hl],a ld [hl], a
add hl,de add hl, de
xor a,1 ; toggle between vertical line tile and box tile xor 1 ; toggle between vertical line tile and box tile
dec c dec c
jr nz,.loop jr nz, .loop
ret ret
PokedexSeenText: PokedexSeenText:
@ -379,12 +379,12 @@ PokedexMenuItemsText:
; [wd11e] = pokedex number ; [wd11e] = pokedex number
; hl = address of bit field ; hl = address of bit field
IsPokemonBitSet: IsPokemonBitSet:
ld a,[wd11e] ld a, [wd11e]
dec a dec a
ld c,a ld c, a
ld b,FLAG_TEST ld b, FLAG_TEST
predef FlagActionPredef predef FlagActionPredef
ld a,c ld a, c
and a and a
ret ret
@ -397,26 +397,26 @@ ShowPokedexData:
; function to display pokedex data from inside the pokedex ; function to display pokedex data from inside the pokedex
ShowPokedexDataInternal: ShowPokedexDataInternal:
ld hl,wd72c ld hl, wd72c
set 1,[hl] set 1, [hl]
ld a,$33 ; 3/7 volume ld a, $33 ; 3/7 volume
ld [rNR50],a ld [rNR50], a
call GBPalWhiteOut ; zero all palettes call GBPalWhiteOut ; zero all palettes
call ClearScreen call ClearScreen
ld a,[wd11e] ; pokemon ID ld a, [wd11e] ; pokemon ID
ld [wcf91],a ld [wcf91], a
push af push af
ld b, SET_PAL_POKEDEX ld b, SET_PAL_POKEDEX
call RunPaletteCommand call RunPaletteCommand
pop af pop af
ld [wd11e],a ld [wd11e], a
ld a,[hTilesetType] ld a, [hTilesetType]
push af push af
xor a xor a
ld [hTilesetType],a ld [hTilesetType], a
coord hl, 0, 0 coord hl, 0, 0
ld de,1 ld de, 1
lb bc, $64, SCREEN_WIDTH lb bc, $64, SCREEN_WIDTH
call DrawTileLine ; draw top border call DrawTileLine ; draw top border
@ -425,71 +425,71 @@ ShowPokedexDataInternal:
call DrawTileLine ; draw bottom border call DrawTileLine ; draw bottom border
coord hl, 0, 1 coord hl, 0, 1
ld de,20 ld de, 20
lb bc, $66, $10 lb bc, $66, $10
call DrawTileLine ; draw left border call DrawTileLine ; draw left border
coord hl, 19, 1 coord hl, 19, 1
ld b,$67 ld b, $67
call DrawTileLine ; draw right border call DrawTileLine ; draw right border
ld a,$63 ; upper left corner tile ld a, $63 ; upper left corner tile
Coorda 0, 0 Coorda 0, 0
ld a,$65 ; upper right corner tile ld a, $65 ; upper right corner tile
Coorda 19, 0 Coorda 19, 0
ld a,$6c ; lower left corner tile ld a, $6c ; lower left corner tile
Coorda 0, 17 Coorda 0, 17
ld a,$6e ; lower right corner tile ld a, $6e ; lower right corner tile
Coorda 19, 17 Coorda 19, 17
coord hl, 0, 9 coord hl, 0, 9
ld de,PokedexDataDividerLine ld de, PokedexDataDividerLine
call PlaceString ; draw horizontal divider line call PlaceString ; draw horizontal divider line
coord hl, 9, 6 coord hl, 9, 6
ld de,HeightWeightText ld de, HeightWeightText
call PlaceString call PlaceString
call GetMonName call GetMonName
coord hl, 9, 2 coord hl, 9, 2
call PlaceString call PlaceString
ld hl,PokedexEntryPointers ld hl, PokedexEntryPointers
ld a,[wd11e] ld a, [wd11e]
dec a dec a
ld e,a ld e, a
ld d,0 ld d, 0
add hl,de add hl, de
add hl,de add hl, de
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld d,[hl] ; de = address of pokedex entry ld d, [hl] ; de = address of pokedex entry
coord hl, 9, 4 coord hl, 9, 4
call PlaceString ; print species name call PlaceString ; print species name
ld h,b ld h, b
ld l,c ld l, c
push de push de
ld a,[wd11e] ld a, [wd11e]
push af push af
call IndexToPokedex call IndexToPokedex
coord hl, 2, 8 coord hl, 2, 8
ld a, "№" ld a, "№"
ld [hli],a ld [hli], a
ld a,"⠄" ld a, "⠄"
ld [hli],a ld [hli], a
ld de,wd11e ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3 lb bc, LEADING_ZEROES | 1, 3
call PrintNumber ; print pokedex number call PrintNumber ; print pokedex number
ld hl,wPokedexOwned ld hl, wPokedexOwned
call IsPokemonBitSet call IsPokemonBitSet
pop af pop af
ld [wd11e],a ld [wd11e], a
ld a,[wcf91] ld a, [wcf91]
ld [wd0b5],a ld [wd0b5], a
pop de pop de
push af push af
@ -502,7 +502,7 @@ ShowPokedexDataInternal:
call GetMonHeader ; load pokemon picture location call GetMonHeader ; load pokemon picture location
coord hl, 1, 1 coord hl, 1, 1
call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture call LoadFlippedFrontSpriteByMonIndex ; draw pokemon picture
ld a,[wcf91] ld a, [wcf91]
call PlayCry ; play pokemon cry call PlayCry ; play pokemon cry
pop hl pop hl
@ -510,83 +510,83 @@ ShowPokedexDataInternal:
pop bc pop bc
pop af pop af
ld a,c ld a, c
and a and a
jp z,.waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description jp z, .waitForButtonPress ; if the pokemon has not been owned, don't print the height, weight, or description
inc de ; de = address of feet (height) inc de ; de = address of feet (height)
ld a,[de] ; reads feet, but a is overwritten without being used ld a, [de] ; reads feet, but a is overwritten without being used
coord hl, 12, 6 coord hl, 12, 6
lb bc, 1, 2 lb bc, 1, 2
call PrintNumber ; print feet (height) call PrintNumber ; print feet (height)
ld a,$60 ; feet symbol tile (one tick) ld a, $60 ; feet symbol tile (one tick)
ld [hl],a ld [hl], a
inc de inc de
inc de ; de = address of inches (height) inc de ; de = address of inches (height)
coord hl, 15, 6 coord hl, 15, 6
lb bc, LEADING_ZEROES | 1, 2 lb bc, LEADING_ZEROES | 1, 2
call PrintNumber ; print inches (height) call PrintNumber ; print inches (height)
ld a,$61 ; inches symbol tile (two ticks) ld a, $61 ; inches symbol tile (two ticks)
ld [hl],a ld [hl], a
; now print the weight (note that weight is stored in tenths of pounds internally) ; now print the weight (note that weight is stored in tenths of pounds internally)
inc de inc de
inc de inc de
inc de ; de = address of upper byte of weight inc de ; de = address of upper byte of weight
push de push de
; put weight in big-endian order at hDexWeight ; put weight in big-endian order at hDexWeight
ld hl,hDexWeight ld hl, hDexWeight
ld a,[hl] ; save existing value of [hDexWeight] ld a, [hl] ; save existing value of [hDexWeight]
push af push af
ld a,[de] ; a = upper byte of weight ld a, [de] ; a = upper byte of weight
ld [hli],a ; store upper byte of weight in [hDexWeight] ld [hli], a ; store upper byte of weight in [hDexWeight]
ld a,[hl] ; save existing value of [hDexWeight + 1] ld a, [hl] ; save existing value of [hDexWeight + 1]
push af push af
dec de dec de
ld a,[de] ; a = lower byte of weight ld a, [de] ; a = lower byte of weight
ld [hl],a ; store lower byte of weight in [hDexWeight + 1] ld [hl], a ; store lower byte of weight in [hDexWeight + 1]
ld de,hDexWeight ld de, hDexWeight
coord hl, 11, 8 coord hl, 11, 8
lb bc, 2, 5 ; 2 bytes, 5 digits lb bc, 2, 5 ; 2 bytes, 5 digits
call PrintNumber ; print weight call PrintNumber ; print weight
coord hl, 14, 8 coord hl, 14, 8
ld a,[hDexWeight + 1] ld a, [hDexWeight + 1]
sub a,10 sub 10
ld a,[hDexWeight] ld a, [hDexWeight]
sbc a,0 sbc 0
jr nc,.next jr nc, .next
ld [hl],"0" ; if the weight is less than 10, put a 0 before the decimal point ld [hl], "0" ; if the weight is less than 10, put a 0 before the decimal point
.next .next
inc hl inc hl
ld a,[hli] ld a, [hli]
ld [hld],a ; make space for the decimal point by moving the last digit forward one tile ld [hld], a ; make space for the decimal point by moving the last digit forward one tile
ld [hl],"⠄" ; decimal point tile ld [hl], "⠄" ; decimal point tile
pop af pop af
ld [hDexWeight + 1],a ; restore original value of [hDexWeight + 1] ld [hDexWeight + 1], a ; restore original value of [hDexWeight + 1]
pop af pop af
ld [hDexWeight],a ; restore original value of [hDexWeight] ld [hDexWeight], a ; restore original value of [hDexWeight]
pop hl pop hl
inc hl ; hl = address of pokedex description text inc hl ; hl = address of pokedex description text
coord bc, 1, 11 coord bc, 1, 11
ld a,2 ld a, 2
ld [$fff4],a ld [$fff4], a
call TextCommandProcessor ; print pokedex description text call TextCommandProcessor ; print pokedex description text
xor a xor a
ld [$fff4],a ld [$fff4], a
.waitForButtonPress .waitForButtonPress
call JoypadLowSensitivity call JoypadLowSensitivity
ld a,[hJoy5] ld a, [hJoy5]
and a,A_BUTTON | B_BUTTON and A_BUTTON | B_BUTTON
jr z,.waitForButtonPress jr z, .waitForButtonPress
pop af pop af
ld [hTilesetType],a ld [hTilesetType], a
call GBPalWhiteOut call GBPalWhiteOut
call ClearScreen call ClearScreen
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
call GBPalNormal call GBPalNormal
ld hl,wd72c ld hl, wd72c
res 1,[hl] res 1, [hl]
ld a,$77 ; max volume ld a, $77 ; max volume
ld [rNR50],a ld [rNR50], a
ret ret
HeightWeightText: HeightWeightText:
@ -615,10 +615,10 @@ DrawTileLine:
push bc push bc
push de push de
.loop .loop
ld [hl],b ld [hl], b
add hl,de add hl, de
dec c dec c
jr nz,.loop jr nz, .loop
pop de pop de
pop bc pop bc
ret ret
@ -629,19 +629,19 @@ PokedexToIndex:
; converts the Pokédex number at wd11e to an index ; converts the Pokédex number at wd11e to an index
push bc push bc
push hl push hl
ld a,[wd11e] ld a, [wd11e]
ld b,a ld b, a
ld c,0 ld c, 0
ld hl,PokedexOrder ld hl, PokedexOrder
.loop ; go through the list until we find an entry with a matching dex number .loop ; go through the list until we find an entry with a matching dex number
inc c inc c
ld a,[hli] ld a, [hli]
cp b cp b
jr nz,.loop jr nz, .loop
ld a,c ld a, c
ld [wd11e],a ld [wd11e], a
pop hl pop hl
pop bc pop bc
ret ret
@ -650,14 +650,14 @@ IndexToPokedex:
; converts the index number at wd11e to a Pokédex number ; converts the index number at wd11e to a Pokédex number
push bc push bc
push hl push hl
ld a,[wd11e] ld a, [wd11e]
dec a dec a
ld hl,PokedexOrder ld hl, PokedexOrder
ld b,0 ld b, 0
ld c,a ld c, a
add hl,bc add hl, bc
ld a,[hl] ld a, [hl]
ld [wd11e],a ld [wd11e], a
pop hl pop hl
pop bc pop bc
ret ret

View file

@ -1,26 +1,26 @@
CeladonPrizeMenu: CeladonPrizeMenu:
ld b,COIN_CASE ld b, COIN_CASE
call IsItemInBag call IsItemInBag
jr nz,.havingCoinCase jr nz, .havingCoinCase
ld hl,RequireCoinCaseTextPtr ld hl, RequireCoinCaseTextPtr
jp PrintText jp PrintText
.havingCoinCase .havingCoinCase
ld hl,wd730 ld hl, wd730
set 6,[hl] ; disable letter-printing delay set 6, [hl] ; disable letter-printing delay
ld hl,ExchangeCoinsForPrizesTextPtr ld hl, ExchangeCoinsForPrizesTextPtr
call PrintText call PrintText
; the following are the menu settings ; the following are the menu settings
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wLastMenuItem],a ld [wLastMenuItem], a
ld a,A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys],a ld [wMenuWatchedKeys], a
ld a,$03 ld a, $03
ld [wMaxMenuItem],a ld [wMaxMenuItem], a
ld a,$04 ld a, $04
ld [wTopMenuItemY],a ld [wTopMenuItemY], a
ld a,$01 ld a, $01
ld [wTopMenuItemX],a ld [wTopMenuItemX], a
call PrintPrizePrice call PrintPrizePrice
coord hl, 0, 2 coord hl, 0, 2
ld b, 8 ld b, 8
@ -28,18 +28,18 @@ CeladonPrizeMenu:
call TextBoxBorder call TextBoxBorder
call GetPrizeMenuId call GetPrizeMenuId
call UpdateSprites call UpdateSprites
ld hl,WhichPrizeTextPtr ld hl, WhichPrizeTextPtr
call PrintText call PrintText
call HandleMenuInput ; menu choice handler call HandleMenuInput ; menu choice handler
bit 1,a ; keypress = B (Cancel) bit 1, a ; keypress = B (Cancel)
jr nz, .noChoice jr nz, .noChoice
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
cp 3 ; "NO,THANKS" choice cp 3 ; "NO,THANKS" choice
jr z, .noChoice jr z, .noChoice
call HandlePrizeChoice call HandlePrizeChoice
.noChoice .noChoice
ld hl,wd730 ld hl, wd730
res 6,[hl] res 6, [hl]
ret ret
RequireCoinCaseTextPtr: RequireCoinCaseTextPtr:
@ -64,85 +64,85 @@ GetPrizeMenuId:
; display the three prizes' names ; display the three prizes' names
; (distinguishing between Pokemon names ; (distinguishing between Pokemon names
; and Items (specifically TMs) names) ; and Items (specifically TMs) names)
ld a,[hSpriteIndexOrTextID] ld a, [hSpriteIndexOrTextID]
sub 3 ; prize-texts' id are 3, 4 and 5 sub 3 ; prize-texts' id are 3, 4 and 5
ld [wWhichPrizeWindow],a ; prize-texts' id (relative, i.e. 0, 1 or 2) ld [wWhichPrizeWindow], a ; prize-texts' id (relative, i.e. 0, 1 or 2)
add a add a
add a add a
ld d,0 ld d, 0
ld e,a ld e, a
ld hl,PrizeDifferentMenuPtrs ld hl, PrizeDifferentMenuPtrs
add hl,de add hl, de
ld a,[hli] ld a, [hli]
ld d,[hl] ld d, [hl]
ld e,a ld e, a
inc hl inc hl
push hl push hl
ld hl,wPrize1 ld hl, wPrize1
call CopyString call CopyString
pop hl pop hl
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld de,wPrize1Price ld de, wPrize1Price
ld bc,6 ld bc, 6
call CopyData call CopyData
ld a,[wWhichPrizeWindow] ld a, [wWhichPrizeWindow]
cp 2 ;is TM_menu? cp 2 ;is TM_menu?
jr nz,.putMonName jr nz, .putMonName
ld a,[wPrize1] ld a, [wPrize1]
ld [wd11e],a ld [wd11e], a
call GetItemName call GetItemName
coord hl, 2, 4 coord hl, 2, 4
call PlaceString call PlaceString
ld a,[wPrize2] ld a, [wPrize2]
ld [wd11e],a ld [wd11e], a
call GetItemName call GetItemName
coord hl, 2, 6 coord hl, 2, 6
call PlaceString call PlaceString
ld a,[wPrize3] ld a, [wPrize3]
ld [wd11e],a ld [wd11e], a
call GetItemName call GetItemName
coord hl, 2, 8 coord hl, 2, 8
call PlaceString call PlaceString
jr .putNoThanksText jr .putNoThanksText
.putMonName .putMonName
ld a,[wPrize1] ld a, [wPrize1]
ld [wd11e],a ld [wd11e], a
call GetMonName call GetMonName
coord hl, 2, 4 coord hl, 2, 4
call PlaceString call PlaceString
ld a,[wPrize2] ld a, [wPrize2]
ld [wd11e],a ld [wd11e], a
call GetMonName call GetMonName
coord hl, 2, 6 coord hl, 2, 6
call PlaceString call PlaceString
ld a,[wPrize3] ld a, [wPrize3]
ld [wd11e],a ld [wd11e], a
call GetMonName call GetMonName
coord hl, 2, 8 coord hl, 2, 8
call PlaceString call PlaceString
.putNoThanksText .putNoThanksText
coord hl, 2, 10 coord hl, 2, 10
ld de,NoThanksText ld de, NoThanksText
call PlaceString call PlaceString
; put prices on the right side of the textbox ; put prices on the right side of the textbox
ld de,wPrize1Price ld de, wPrize1Price
coord hl, 13, 5 coord hl, 13, 5
; reg. c: ; reg. c:
; [low nybble] number of bytes ; [low nybble] number of bytes
; [bit 765 = %100] space-padding (not zero-padding) ; [bit 765 = %100] space-padding (not zero-padding)
ld c,(1 << 7 | 2) ld c, (1 << 7 | 2)
; Function $15CD displays BCD value (same routine ; Function $15CD displays BCD value (same routine
; used by text-command $02) ; used by text-command $02)
call PrintBCDNumber call PrintBCDNumber
ld de,wPrize2Price ld de, wPrize2Price
coord hl, 13, 7 coord hl, 13, 7
ld c,(1 << 7 | 2) ld c, (1 << 7 | 2)
call PrintBCDNumber call PrintBCDNumber
ld de,wPrize3Price ld de, wPrize3Price
coord hl, 13, 9 coord hl, 13, 9
ld c,(1 << 7 | 2) ld c, (1 << 7 | 2)
jp PrintBCDNumber jp PrintBCDNumber
INCLUDE "data/prizes.asm" INCLUDE "data/prizes.asm"
@ -160,8 +160,8 @@ PrintPrizePrice:
ld de, .SixSpacesString ld de, .SixSpacesString
call PlaceString call PlaceString
coord hl, 13, 1 coord hl, 13, 1
ld de,wPlayerCoins ld de, wPlayerCoins
ld c,%10000010 ld c, %10000010
call PrintBCDNumber call PrintBCDNumber
ret ret
@ -172,30 +172,30 @@ PrintPrizePrice:
db " @" db " @"
LoadCoinsToSubtract: LoadCoinsToSubtract:
ld a,[wWhichPrize] ld a, [wWhichPrize]
add a add a
ld d,0 ld d, 0
ld e,a ld e, a
ld hl,wPrize1Price ld hl, wPrize1Price
add hl,de ; get selected prize's price add hl, de ; get selected prize's price
xor a xor a
ld [hUnusedCoinsByte],a ld [hUnusedCoinsByte], a
ld a,[hli] ld a, [hli]
ld [hCoins],a ld [hCoins], a
ld a,[hl] ld a, [hl]
ld [hCoins + 1],a ld [hCoins + 1], a
ret ret
HandlePrizeChoice: HandlePrizeChoice:
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld [wWhichPrize],a ld [wWhichPrize], a
ld d,0 ld d, 0
ld e,a ld e, a
ld hl,wPrize1 ld hl, wPrize1
add hl,de add hl, de
ld a,[hl] ld a, [hl]
ld [wd11e],a ld [wd11e], a
ld a,[wWhichPrizeWindow] ld a, [wWhichPrizeWindow]
cp 2 ; is prize a TM? cp 2 ; is prize a TM?
jr nz, .getMonName jr nz, .getMonName
call GetItemName call GetItemName
@ -203,40 +203,40 @@ HandlePrizeChoice:
.getMonName .getMonName
call GetMonName call GetMonName
.givePrize .givePrize
ld hl,SoYouWantPrizeTextPtr ld hl, SoYouWantPrizeTextPtr
call PrintText call PrintText
call YesNoChoice call YesNoChoice
ld a,[wCurrentMenuItem] ; yes/no answer (Y=0, N=1) ld a, [wCurrentMenuItem] ; yes/no answer (Y=0, N=1)
and a and a
jr nz, .printOhFineThen jr nz, .printOhFineThen
call LoadCoinsToSubtract call LoadCoinsToSubtract
call HasEnoughCoins call HasEnoughCoins
jr c, .notEnoughCoins jr c, .notEnoughCoins
ld a,[wWhichPrizeWindow] ld a, [wWhichPrizeWindow]
cp $02 cp $02
jr nz, .giveMon jr nz, .giveMon
ld a,[wd11e] ld a, [wd11e]
ld b,a ld b, a
ld a,1 ld a, 1
ld c,a ld c, a
call GiveItem call GiveItem
jr nc, .bagFull jr nc, .bagFull
jr .subtractCoins jr .subtractCoins
.giveMon .giveMon
ld a,[wd11e] ld a, [wd11e]
ld [wcf91],a ld [wcf91], a
push af push af
call GetPrizeMonLevel call GetPrizeMonLevel
ld c,a ld c, a
pop af pop af
ld b,a ld b, a
call GivePokemon call GivePokemon
; If either the party or box was full, wait after displaying message. ; If either the party or box was full, wait after displaying message.
push af push af
ld a,[wAddedToParty] ld a, [wAddedToParty]
and a and a
call z,WaitForTextScrollButtonPress call z, WaitForTextScrollButtonPress
pop af pop af
; If the mon couldn't be given to the player (because both the party and box ; If the mon couldn't be given to the player (because both the party and box
@ -245,19 +245,19 @@ HandlePrizeChoice:
.subtractCoins .subtractCoins
call LoadCoinsToSubtract call LoadCoinsToSubtract
ld hl,hCoins + 1 ld hl, hCoins + 1
ld de,wPlayerCoins + 1 ld de, wPlayerCoins + 1
ld c,$02 ; how many bytes ld c, $02 ; how many bytes
predef SubBCDPredef predef SubBCDPredef
jp PrintPrizePrice jp PrintPrizePrice
.bagFull .bagFull
ld hl,PrizeRoomBagIsFullTextPtr ld hl, PrizeRoomBagIsFullTextPtr
jp PrintText jp PrintText
.notEnoughCoins .notEnoughCoins
ld hl,SorryNeedMoreCoinsText ld hl, SorryNeedMoreCoinsText
jp PrintText jp PrintText
.printOhFineThen .printOhFineThen
ld hl,OhFineThenTextPtr ld hl, OhFineThenTextPtr
jp PrintText jp PrintText
UnknownPrizeData: UnknownPrizeData:
@ -289,18 +289,18 @@ OhFineThenTextPtr:
db "@" db "@"
GetPrizeMonLevel: GetPrizeMonLevel:
ld a,[wcf91] ld a, [wcf91]
ld b,a ld b, a
ld hl,PrizeMonLevelDictionary ld hl, PrizeMonLevelDictionary
.loop .loop
ld a,[hli] ld a, [hli]
cp b cp b
jr z,.matchFound jr z, .matchFound
inc hl inc hl
jr .loop jr .loop
.matchFound .matchFound
ld a,[hl] ld a, [hl]
ld [wCurEnemyLVL],a ld [wCurEnemyLVL], a
ret ret
INCLUDE "data/prize_mon_levels.asm" INCLUDE "data/prize_mon_levels.asm"

View file

@ -1,9 +1,9 @@
DisplayStartMenu:: DisplayStartMenu::
ld a,BANK(StartMenu_Pokedex) ld a, BANK(StartMenu_Pokedex)
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ld a,[wWalkBikeSurfState] ; walking/biking/surfing ld a, [wWalkBikeSurfState] ; walking/biking/surfing
ld [wWalkBikeSurfStateCopy],a ld [wWalkBikeSurfStateCopy], a
ld a, SFX_START_MENU ld a, SFX_START_MENU
call PlaySound call PlaySound
@ -13,73 +13,73 @@ RedisplayStartMenu::
call UpdateSprites call UpdateSprites
.loop .loop
call HandleMenuInput call HandleMenuInput
ld b,a ld b, a
.checkIfUpPressed .checkIfUpPressed
bit 6,a ; was Up pressed? bit 6, a ; was Up pressed?
jr z,.checkIfDownPressed jr z, .checkIfDownPressed
ld a,[wCurrentMenuItem] ; menu selection ld a, [wCurrentMenuItem] ; menu selection
and a and a
jr nz,.loop jr nz, .loop
ld a,[wLastMenuItem] ld a, [wLastMenuItem]
and a and a
jr nz,.loop jr nz, .loop
; if the player pressed tried to go past the top item, wrap around to the bottom ; if the player pressed tried to go past the top item, wrap around to the bottom
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
ld a,6 ; there are 7 menu items with the pokedex, so the max index is 6 ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6
jr nz,.wrapMenuItemId jr nz, .wrapMenuItemId
dec a ; there are only 6 menu items without the pokedex dec a ; there are only 6 menu items without the pokedex
.wrapMenuItemId .wrapMenuItemId
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
call EraseMenuCursor call EraseMenuCursor
jr .loop jr .loop
.checkIfDownPressed .checkIfDownPressed
bit 7,a bit 7, a
jr z,.buttonPressed jr z, .buttonPressed
; if the player pressed tried to go past the bottom item, wrap around to the top ; if the player pressed tried to go past the bottom item, wrap around to the top
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld c,7 ; there are 7 menu items with the pokedex ld c, 7 ; there are 7 menu items with the pokedex
jr nz,.checkIfPastBottom jr nz, .checkIfPastBottom
dec c ; there are only 6 menu items without the pokedex dec c ; there are only 6 menu items without the pokedex
.checkIfPastBottom .checkIfPastBottom
cp c cp c
jr nz,.loop jr nz, .loop
; the player went past the bottom, so wrap to the top ; the player went past the bottom, so wrap to the top
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
call EraseMenuCursor call EraseMenuCursor
jr .loop jr .loop
.buttonPressed ; A, B, or Start button pressed .buttonPressed ; A, B, or Start button pressed
call PlaceUnfilledArrowMenuCursor call PlaceUnfilledArrowMenuCursor
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld [wBattleAndStartSavedMenuItem],a ; save current menu selection ld [wBattleAndStartSavedMenuItem], a ; save current menu selection
ld a,b ld a, b
and a,%00001010 ; was the Start button or B button pressed? and %00001010 ; was the Start button or B button pressed?
jp nz,CloseStartMenu jp nz, CloseStartMenu
call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2 call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2
CheckEvent EVENT_GOT_POKEDEX CheckEvent EVENT_GOT_POKEDEX
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
jr nz,.displayMenuItem jr nz, .displayMenuItem
inc a ; adjust position to account for missing pokedex menu item inc a ; adjust position to account for missing pokedex menu item
.displayMenuItem .displayMenuItem
cp a,0 cp 0
jp z,StartMenu_Pokedex jp z, StartMenu_Pokedex
cp a,1 cp 1
jp z,StartMenu_Pokemon jp z, StartMenu_Pokemon
cp a,2 cp 2
jp z,StartMenu_Item jp z, StartMenu_Item
cp a,3 cp 3
jp z,StartMenu_TrainerInfo jp z, StartMenu_TrainerInfo
cp a,4 cp 4
jp z,StartMenu_SaveReset jp z, StartMenu_SaveReset
cp a,5 cp 5
jp z,StartMenu_Option jp z, StartMenu_Option
; EXIT falls through to here ; EXIT falls through to here
CloseStartMenu:: CloseStartMenu::
call Joypad call Joypad
ld a,[hJoyPressed] ld a, [hJoyPressed]
bit 0,a ; was A button newly pressed? bit 0, a ; was A button newly pressed?
jr nz,CloseStartMenu jr nz, CloseStartMenu
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
jp CloseTextDisplay jp CloseTextDisplay

View file

@ -7,22 +7,22 @@ StartMenu_Pokedex:
jp RedisplayStartMenu jp RedisplayStartMenu
StartMenu_Pokemon: StartMenu_Pokemon:
ld a,[wPartyCount] ld a, [wPartyCount]
and a and a
jp z,RedisplayStartMenu jp z, RedisplayStartMenu
xor a xor a
ld [wMenuItemToSwap],a ld [wMenuItemToSwap], a
ld [wPartyMenuTypeOrMessageID],a ld [wPartyMenuTypeOrMessageID], a
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
call DisplayPartyMenu call DisplayPartyMenu
jr .checkIfPokemonChosen jr .checkIfPokemonChosen
.loop .loop
xor a xor a
ld [wMenuItemToSwap],a ld [wMenuItemToSwap], a
ld [wPartyMenuTypeOrMessageID],a ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu call GoBackToPartyMenu
.checkIfPokemonChosen .checkIfPokemonChosen
jr nc,.chosePokemon jr nc, .chosePokemon
.exitMenu .exitMenu
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns call RestoreScreenTilesAndReloadTilePatterns
@ -30,94 +30,94 @@ StartMenu_Pokemon:
jp RedisplayStartMenu jp RedisplayStartMenu
.chosePokemon .chosePokemon
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a,FIELD_MOVE_MON_MENU ld a, FIELD_MOVE_MON_MENU
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; display pokemon menu options call DisplayTextBoxID ; display pokemon menu options
ld hl,wFieldMoves ld hl, wFieldMoves
lb bc, 2, 12 ; max menu item ID, top menu item Y lb bc, 2, 12 ; max menu item ID, top menu item Y
ld e,5 ld e, 5
.adjustMenuVariablesLoop .adjustMenuVariablesLoop
dec e dec e
jr z,.storeMenuVariables jr z, .storeMenuVariables
ld a,[hli] ld a, [hli]
and a ; end of field moves? and a ; end of field moves?
jr z,.storeMenuVariables jr z, .storeMenuVariables
inc b inc b
dec c dec c
dec c dec c
jr .adjustMenuVariablesLoop jr .adjustMenuVariablesLoop
.storeMenuVariables .storeMenuVariables
ld hl,wTopMenuItemY ld hl, wTopMenuItemY
ld a,c ld a, c
ld [hli],a ; top menu item Y ld [hli], a ; top menu item Y
ld a,[hFieldMoveMonMenuTopMenuItemX] ld a, [hFieldMoveMonMenuTopMenuItemX]
ld [hli],a ; top menu item X ld [hli], a ; top menu item X
xor a xor a
ld [hli],a ; current menu item ID ld [hli], a ; current menu item ID
inc hl inc hl
ld a,b ld a, b
ld [hli],a ; max menu item ID ld [hli], a ; max menu item ID
ld a,A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys ld [hli], a ; menu watched keys
xor a xor a
ld [hl],a ld [hl], a
call HandleMenuInput call HandleMenuInput
push af push af
call LoadScreenTilesFromBuffer1 ; restore saved screen call LoadScreenTilesFromBuffer1 ; restore saved screen
pop af pop af
bit 1,a ; was the B button pressed? bit 1, a ; was the B button pressed?
jp nz,.loop jp nz, .loop
; if the B button wasn't pressed ; if the B button wasn't pressed
ld a,[wMaxMenuItem] ld a, [wMaxMenuItem]
ld b,a ld b, a
ld a,[wCurrentMenuItem] ; menu selection ld a, [wCurrentMenuItem] ; menu selection
cp b cp b
jp z,.exitMenu ; if the player chose Cancel jp z, .exitMenu ; if the player chose Cancel
dec b dec b
cp b cp b
jr z,.choseSwitch jr z, .choseSwitch
dec b dec b
cp b cp b
jp z,.choseStats jp z, .choseStats
ld c,a ld c, a
ld b,0 ld b, 0
ld hl,wFieldMoves ld hl, wFieldMoves
add hl,bc add hl, bc
jp .choseOutOfBattleMove jp .choseOutOfBattleMove
.choseSwitch .choseSwitch
ld a,[wPartyCount] ld a, [wPartyCount]
cp a,2 ; is there more than one pokemon in the party? cp 2 ; is there more than one pokemon in the party?
jp c,StartMenu_Pokemon ; if not, no switching jp c, StartMenu_Pokemon ; if not, no switching
call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap] call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap]
ld a,SWAP_MONS_PARTY_MENU ld a, SWAP_MONS_PARTY_MENU
ld [wPartyMenuTypeOrMessageID],a ld [wPartyMenuTypeOrMessageID], a
call GoBackToPartyMenu call GoBackToPartyMenu
jp .checkIfPokemonChosen jp .checkIfPokemonChosen
.choseStats .choseStats
call ClearSprites call ClearSprites
xor a ; PLAYER_PARTY_DATA xor a ; PLAYER_PARTY_DATA
ld [wMonDataLocation],a ld [wMonDataLocation], a
predef StatusScreen predef StatusScreen
predef StatusScreen2 predef StatusScreen2
call ReloadMapData call ReloadMapData
jp StartMenu_Pokemon jp StartMenu_Pokemon
.choseOutOfBattleMove .choseOutOfBattleMove
push hl push hl
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
ld hl,wPartyMonNicks ld hl, wPartyMonNicks
call GetPartyMonName call GetPartyMonName
pop hl pop hl
ld a,[hl] ld a, [hl]
dec a dec a
add a add a
ld b,0 ld b, 0
ld c,a ld c, a
ld hl,.outOfBattleMovePointers ld hl, .outOfBattleMovePointers
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld a,[wObtainedBadges] ; badges obtained ld a, [wObtainedBadges] ; badges obtained
jp hl jp hl
.outOfBattleMovePointers .outOfBattleMovePointers
dw .cut dw .cut
@ -130,62 +130,62 @@ StartMenu_Pokemon:
dw .teleport dw .teleport
dw .softboiled dw .softboiled
.fly .fly
bit 2,a ; does the player have the Thunder Badge? bit 2, a ; does the player have the Thunder Badge?
jp z,.newBadgeRequired jp z, .newBadgeRequired
call CheckIfInOutsideMap call CheckIfInOutsideMap
jr z,.canFly jr z, .canFly
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
ld hl,wPartyMonNicks ld hl, wPartyMonNicks
call GetPartyMonName call GetPartyMonName
ld hl,.cannotFlyHereText ld hl, .cannotFlyHereText
call PrintText call PrintText
jp .loop jp .loop
.canFly .canFly
call ChooseFlyDestination call ChooseFlyDestination
ld a,[wd732] ld a, [wd732]
bit 3,a ; did the player decide to fly? bit 3, a ; did the player decide to fly?
jp nz,.goBackToMap jp nz, .goBackToMap
call LoadFontTilePatterns call LoadFontTilePatterns
ld hl,wd72e ld hl, wd72e
set 1,[hl] set 1, [hl]
jp StartMenu_Pokemon jp StartMenu_Pokemon
.cut .cut
bit 1,a ; does the player have the Cascade Badge? bit 1, a ; does the player have the Cascade Badge?
jp z,.newBadgeRequired jp z, .newBadgeRequired
predef UsedCut predef UsedCut
ld a,[wActionResultOrTookBattleTurn] ld a, [wActionResultOrTookBattleTurn]
and a and a
jp z,.loop jp z, .loop
jp CloseTextDisplay jp CloseTextDisplay
.surf .surf
bit 4,a ; does the player have the Soul Badge? bit 4, a ; does the player have the Soul Badge?
jp z,.newBadgeRequired jp z, .newBadgeRequired
callba IsSurfingAllowed callba IsSurfingAllowed
ld hl,wd728 ld hl, wd728
bit 1,[hl] bit 1, [hl]
res 1,[hl] res 1, [hl]
jp z,.loop jp z, .loop
ld a,SURFBOARD ld a, SURFBOARD
ld [wcf91],a ld [wcf91], a
ld [wPseudoItemID],a ld [wPseudoItemID], a
call UseItem call UseItem
ld a,[wActionResultOrTookBattleTurn] ld a, [wActionResultOrTookBattleTurn]
and a and a
jp z,.loop jp z, .loop
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
jp .goBackToMap jp .goBackToMap
.strength .strength
bit 3,a ; does the player have the Rainbow Badge? bit 3, a ; does the player have the Rainbow Badge?
jp z,.newBadgeRequired jp z, .newBadgeRequired
predef PrintStrengthTxt predef PrintStrengthTxt
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
jp .goBackToMap jp .goBackToMap
.flash .flash
bit 0,a ; does the player have the Boulder Badge? bit 0, a ; does the player have the Boulder Badge?
jp z,.newBadgeRequired jp z, .newBadgeRequired
xor a xor a
ld [wMapPalOffset],a ld [wMapPalOffset], a
ld hl,.flashLightsAreaText ld hl, .flashLightsAreaText
call PrintText call PrintText
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
jp .goBackToMap jp .goBackToMap
@ -193,34 +193,34 @@ StartMenu_Pokemon:
TX_FAR _FlashLightsAreaText TX_FAR _FlashLightsAreaText
db "@" db "@"
.dig .dig
ld a,ESCAPE_ROPE ld a, ESCAPE_ROPE
ld [wcf91],a ld [wcf91], a
ld [wPseudoItemID],a ld [wPseudoItemID], a
call UseItem call UseItem
ld a,[wActionResultOrTookBattleTurn] ld a, [wActionResultOrTookBattleTurn]
and a and a
jp z,.loop jp z, .loop
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
jp .goBackToMap jp .goBackToMap
.teleport .teleport
call CheckIfInOutsideMap call CheckIfInOutsideMap
jr z,.canTeleport jr z, .canTeleport
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
ld hl,wPartyMonNicks ld hl, wPartyMonNicks
call GetPartyMonName call GetPartyMonName
ld hl,.cannotUseTeleportNowText ld hl, .cannotUseTeleportNowText
call PrintText call PrintText
jp .loop jp .loop
.canTeleport .canTeleport
ld hl,.warpToLastPokemonCenterText ld hl, .warpToLastPokemonCenterText
call PrintText call PrintText
ld hl,wd732 ld hl, wd732
set 3,[hl] set 3, [hl]
set 6,[hl] set 6, [hl]
ld hl,wd72e ld hl, wd72e
set 1,[hl] set 1, [hl]
res 4,[hl] res 4, [hl]
ld c,60 ld c, 60
call DelayFrames call DelayFrames
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
jp .goBackToMap jp .goBackToMap
@ -234,39 +234,39 @@ StartMenu_Pokemon:
TX_FAR _CannotFlyHereText TX_FAR _CannotFlyHereText
db "@" db "@"
.softboiled .softboiled
ld hl,wPartyMon1MaxHP ld hl, wPartyMon1MaxHP
ld a,[wWhichPokemon] ld a, [wWhichPokemon]
ld bc,wPartyMon2 - wPartyMon1 ld bc, wPartyMon2 - wPartyMon1
call AddNTimes call AddNTimes
ld a,[hli] ld a, [hli]
ld [H_DIVIDEND],a ld [H_DIVIDEND], a
ld a,[hl] ld a, [hl]
ld [H_DIVIDEND + 1],a ld [H_DIVIDEND + 1], a
ld a,5 ld a, 5
ld [H_DIVISOR],a ld [H_DIVISOR], a
ld b,2 ; number of bytes ld b, 2 ; number of bytes
call Divide call Divide
ld bc,wPartyMon1HP - wPartyMon1MaxHP ld bc, wPartyMon1HP - wPartyMon1MaxHP
add hl,bc add hl, bc
ld a,[hld] ld a, [hld]
ld b,a ld b, a
ld a,[H_QUOTIENT + 3] ld a, [H_QUOTIENT + 3]
sub b sub b
ld b,[hl] ld b, [hl]
ld a,[H_QUOTIENT + 2] ld a, [H_QUOTIENT + 2]
sbc b sbc b
jp nc,.notHealthyEnough jp nc, .notHealthyEnough
ld a,[wPartyAndBillsPCSavedMenuItem] ld a, [wPartyAndBillsPCSavedMenuItem]
push af push af
ld a,POTION ld a, POTION
ld [wcf91],a ld [wcf91], a
ld [wPseudoItemID],a ld [wPseudoItemID], a
call UseItem call UseItem
pop af pop af
ld [wPartyAndBillsPCSavedMenuItem],a ld [wPartyAndBillsPCSavedMenuItem], a
jp .loop jp .loop
.notHealthyEnough ; if current HP is less than 1/5 of max HP .notHealthyEnough ; if current HP is less than 1/5 of max HP
ld hl,.notHealthyEnoughText ld hl, .notHealthyEnoughText
call PrintText call PrintText
jp .loop jp .loop
.notHealthyEnoughText .notHealthyEnoughText
@ -276,7 +276,7 @@ StartMenu_Pokemon:
call RestoreScreenTilesAndReloadTilePatterns call RestoreScreenTilesAndReloadTilePatterns
jp CloseTextDisplay jp CloseTextDisplay
.newBadgeRequired .newBadgeRequired
ld hl,.newBadgeRequiredText ld hl, .newBadgeRequiredText
call PrintText call PrintText
jp .loop jp .loop
.newBadgeRequiredText .newBadgeRequiredText
@ -286,13 +286,13 @@ StartMenu_Pokemon:
; writes a blank tile to all possible menu cursor positions on the party menu ; writes a blank tile to all possible menu cursor positions on the party menu
ErasePartyMenuCursors: ErasePartyMenuCursors:
coord hl, 0, 1 coord hl, 0, 1
ld bc,2 * 20 ; menu cursor positions are 2 rows apart ld bc, 2 * 20 ; menu cursor positions are 2 rows apart
ld a,6 ; 6 menu cursor positions ld a, 6 ; 6 menu cursor positions
.loop .loop
ld [hl]," " ld [hl], " "
add hl,bc add hl, bc
dec a dec a
jr nz,.loop jr nz, .loop
ret ret
ItemMenuLoop: ItemMenuLoop:
@ -300,28 +300,28 @@ ItemMenuLoop:
call RunDefaultPaletteCommand call RunDefaultPaletteCommand
StartMenu_Item: StartMenu_Item:
ld a,[wLinkState] ld a, [wLinkState]
dec a ; is the player in the Colosseum or Trade Centre? dec a ; is the player in the Colosseum or Trade Centre?
jr nz,.notInCableClubRoom jr nz, .notInCableClubRoom
ld hl,CannotUseItemsHereText ld hl, CannotUseItemsHereText
call PrintText call PrintText
jr .exitMenu jr .exitMenu
.notInCableClubRoom .notInCableClubRoom
ld bc,wNumBagItems ld bc, wNumBagItems
ld hl,wListPointer ld hl, wListPointer
ld a,c ld a, c
ld [hli],a ld [hli], a
ld [hl],b ; store item bag pointer in wListPointer (for DisplayListMenuID) ld [hl], b ; store item bag pointer in wListPointer (for DisplayListMenuID)
xor a xor a
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
ld a,ITEMLISTMENU ld a, ITEMLISTMENU
ld [wListMenuID],a ld [wListMenuID], a
ld a,[wBagSavedMenuItem] ld a, [wBagSavedMenuItem]
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
call DisplayListMenuID call DisplayListMenuID
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld [wBagSavedMenuItem],a ld [wBagSavedMenuItem], a
jr nc,.choseItem jr nc, .choseItem
.exitMenu .exitMenu
call LoadScreenTilesFromBuffer2 ; restore saved screen call LoadScreenTilesFromBuffer2 ; restore saved screen
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
@ -329,111 +329,111 @@ StartMenu_Item:
jp RedisplayStartMenu jp RedisplayStartMenu
.choseItem .choseItem
; erase menu cursor (blank each tile in front of an item name) ; erase menu cursor (blank each tile in front of an item name)
ld a," " ld a, " "
Coorda 5, 4 Coorda 5, 4
Coorda 5, 6 Coorda 5, 6
Coorda 5, 8 Coorda 5, 8
Coorda 5, 10 Coorda 5, 10
call PlaceUnfilledArrowMenuCursor call PlaceUnfilledArrowMenuCursor
xor a xor a
ld [wMenuItemToSwap],a ld [wMenuItemToSwap], a
ld a,[wcf91] ld a, [wcf91]
cp a,BICYCLE cp BICYCLE
jp z,.useOrTossItem jp z, .useOrTossItem
.notBicycle1 .notBicycle1
ld a,USE_TOSS_MENU_TEMPLATE ld a, USE_TOSS_MENU_TEMPLATE
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
ld hl,wTopMenuItemY ld hl, wTopMenuItemY
ld a,11 ld a, 11
ld [hli],a ; top menu item Y ld [hli], a ; top menu item Y
ld a,14 ld a, 14
ld [hli],a ; top menu item X ld [hli], a ; top menu item X
xor a xor a
ld [hli],a ; current menu item ID ld [hli], a ; current menu item ID
inc hl inc hl
inc a ; a = 1 inc a ; a = 1
ld [hli],a ; max menu item ID ld [hli], a ; max menu item ID
ld a,A_BUTTON | B_BUTTON ld a, A_BUTTON | B_BUTTON
ld [hli],a ; menu watched keys ld [hli], a ; menu watched keys
xor a xor a
ld [hl],a ; old menu item id ld [hl], a ; old menu item id
call HandleMenuInput call HandleMenuInput
call PlaceUnfilledArrowMenuCursor call PlaceUnfilledArrowMenuCursor
bit 1,a ; was the B button pressed? bit 1, a ; was the B button pressed?
jr z,.useOrTossItem jr z, .useOrTossItem
jp ItemMenuLoop jp ItemMenuLoop
.useOrTossItem ; if the player made the choice to use or toss the item .useOrTossItem ; if the player made the choice to use or toss the item
ld a,[wcf91] ld a, [wcf91]
ld [wd11e],a ld [wd11e], a
call GetItemName call GetItemName
call CopyStringToCF4B ; copy name to wcf4b call CopyStringToCF4B ; copy name to wcf4b
ld a,[wcf91] ld a, [wcf91]
cp a,BICYCLE cp BICYCLE
jr nz,.notBicycle2 jr nz, .notBicycle2
ld a,[wd732] ld a, [wd732]
bit 5,a bit 5, a
jr z,.useItem_closeMenu jr z, .useItem_closeMenu
ld hl,CannotGetOffHereText ld hl, CannotGetOffHereText
call PrintText call PrintText
jp ItemMenuLoop jp ItemMenuLoop
.notBicycle2 .notBicycle2
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jr nz,.tossItem jr nz, .tossItem
; use item ; use item
ld [wPseudoItemID],a ; a must be 0 due to above conditional jump ld [wPseudoItemID], a ; a must be 0 due to above conditional jump
ld a,[wcf91] ld a, [wcf91]
cp a,HM_01 cp HM_01
jr nc,.useItem_partyMenu jr nc, .useItem_partyMenu
ld hl,UsableItems_CloseMenu ld hl, UsableItems_CloseMenu
ld de,1 ld de, 1
call IsInArray call IsInArray
jr c,.useItem_closeMenu jr c, .useItem_closeMenu
ld a,[wcf91] ld a, [wcf91]
ld hl,UsableItems_PartyMenu ld hl, UsableItems_PartyMenu
ld de,1 ld de, 1
call IsInArray call IsInArray
jr c,.useItem_partyMenu jr c, .useItem_partyMenu
call UseItem call UseItem
jp ItemMenuLoop jp ItemMenuLoop
.useItem_closeMenu .useItem_closeMenu
xor a xor a
ld [wPseudoItemID],a ld [wPseudoItemID], a
call UseItem call UseItem
ld a,[wActionResultOrTookBattleTurn] ld a, [wActionResultOrTookBattleTurn]
and a and a
jp z,ItemMenuLoop jp z, ItemMenuLoop
jp CloseStartMenu jp CloseStartMenu
.useItem_partyMenu .useItem_partyMenu
ld a,[wUpdateSpritesEnabled] ld a, [wUpdateSpritesEnabled]
push af push af
call UseItem call UseItem
ld a,[wActionResultOrTookBattleTurn] ld a, [wActionResultOrTookBattleTurn]
cp a,$02 cp $02
jp z,.partyMenuNotDisplayed jp z, .partyMenuNotDisplayed
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns call RestoreScreenTilesAndReloadTilePatterns
pop af pop af
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
jp StartMenu_Item jp StartMenu_Item
.partyMenuNotDisplayed .partyMenuNotDisplayed
pop af pop af
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
jp ItemMenuLoop jp ItemMenuLoop
.tossItem .tossItem
call IsKeyItem call IsKeyItem
ld a,[wIsKeyItem] ld a, [wIsKeyItem]
and a and a
jr nz,.skipAskingQuantity jr nz, .skipAskingQuantity
ld a,[wcf91] ld a, [wcf91]
call IsItemHM call IsItemHM
jr c,.skipAskingQuantity jr c, .skipAskingQuantity
call DisplayChooseQuantityMenu call DisplayChooseQuantityMenu
inc a inc a
jr z,.tossZeroItems jr z, .tossZeroItems
.skipAskingQuantity .skipAskingQuantity
ld hl,wNumBagItems ld hl, wNumBagItems
call TossItem call TossItem
.tossZeroItems .tossZeroItems
jp ItemMenuLoop jp ItemMenuLoop
@ -500,10 +500,10 @@ StartMenu_TrainerInfo:
call GBPalWhiteOut call GBPalWhiteOut
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
ld a,[hTilesetType] ld a, [hTilesetType]
push af push af
xor a xor a
ld [hTilesetType],a ld [hTilesetType], a
call DrawTrainerInfo call DrawTrainerInfo
predef DrawBadges ; draw badges predef DrawBadges ; draw badges
ld b, SET_PAL_TRAINER_CARD ld b, SET_PAL_TRAINER_CARD
@ -517,101 +517,101 @@ StartMenu_TrainerInfo:
call ReloadMapData call ReloadMapData
call LoadGBPal call LoadGBPal
pop af pop af
ld [hTilesetType],a ld [hTilesetType], a
jp RedisplayStartMenu jp RedisplayStartMenu
; loads tile patterns and draws everything except for gym leader faces / badges ; loads tile patterns and draws everything except for gym leader faces / badges
DrawTrainerInfo: DrawTrainerInfo:
ld de,RedPicFront ld de, RedPicFront
lb bc, BANK(RedPicFront), $01 lb bc, BANK(RedPicFront), $01
predef DisplayPicCenteredOrUpperRight predef DisplayPicCenteredOrUpperRight
call DisableLCD call DisableLCD
coord hl, 0, 2 coord hl, 0, 2
ld a," " ld a, " "
call TrainerInfo_DrawVerticalLine call TrainerInfo_DrawVerticalLine
coord hl, 1, 2 coord hl, 1, 2
call TrainerInfo_DrawVerticalLine call TrainerInfo_DrawVerticalLine
ld hl,vChars2 + $70 ld hl, vChars2 + $70
ld de,vChars2 ld de, vChars2
ld bc,$70 * 4 ld bc, $70 * 4
call CopyData call CopyData
ld hl,TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns ld hl, TrainerInfoTextBoxTileGraphics ; trainer info text box tile patterns
ld de,vChars2 + $770 ld de, vChars2 + $770
ld bc,$0080 ld bc, $0080
push bc push bc
call TrainerInfo_FarCopyData call TrainerInfo_FarCopyData
ld hl,BlankLeaderNames ld hl, BlankLeaderNames
ld de,vChars2 + $600 ld de, vChars2 + $600
ld bc,$0170 ld bc, $0170
call TrainerInfo_FarCopyData call TrainerInfo_FarCopyData
pop bc pop bc
ld hl,BadgeNumbersTileGraphics ; badge number tile patterns ld hl, BadgeNumbersTileGraphics ; badge number tile patterns
ld de,vChars1 + $580 ld de, vChars1 + $580
call TrainerInfo_FarCopyData call TrainerInfo_FarCopyData
ld hl,GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns ld hl, GymLeaderFaceAndBadgeTileGraphics ; gym leader face and badge tile patterns
ld de,vChars2 + $200 ld de, vChars2 + $200
ld bc,$0400 ld bc, $0400
ld a,$03 ld a, $03
call FarCopyData2 call FarCopyData2
ld hl,TextBoxGraphics ld hl, TextBoxGraphics
ld de,$00d0 ld de, $00d0
add hl,de ; hl = colon tile pattern add hl, de ; hl = colon tile pattern
ld de,vChars1 + $560 ld de, vChars1 + $560
ld bc,$0010 ld bc, $0010
ld a,$04 ld a, $04
push bc push bc
call FarCopyData2 call FarCopyData2
pop bc pop bc
ld hl,TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern ld hl, TrainerInfoTextBoxTileGraphics + $80 ; background tile pattern
ld de,vChars1 + $570 ld de, vChars1 + $570
call TrainerInfo_FarCopyData call TrainerInfo_FarCopyData
call EnableLCD call EnableLCD
ld hl,wTrainerInfoTextBoxWidthPlus1 ld hl, wTrainerInfoTextBoxWidthPlus1
ld a,18 + 1 ld a, 18 + 1
ld [hli],a ld [hli], a
dec a dec a
ld [hli],a ld [hli], a
ld [hl],1 ld [hl], 1
coord hl, 0, 0 coord hl, 0, 0
call TrainerInfo_DrawTextBox call TrainerInfo_DrawTextBox
ld hl,wTrainerInfoTextBoxWidthPlus1 ld hl, wTrainerInfoTextBoxWidthPlus1
ld a,16 + 1 ld a, 16 + 1
ld [hli],a ld [hli], a
dec a dec a
ld [hli],a ld [hli], a
ld [hl],3 ld [hl], 3
coord hl, 1, 10 coord hl, 1, 10
call TrainerInfo_DrawTextBox call TrainerInfo_DrawTextBox
coord hl, 0, 10 coord hl, 0, 10
ld a,$d7 ld a, $d7
call TrainerInfo_DrawVerticalLine call TrainerInfo_DrawVerticalLine
coord hl, 19, 10 coord hl, 19, 10
call TrainerInfo_DrawVerticalLine call TrainerInfo_DrawVerticalLine
coord hl, 6, 9 coord hl, 6, 9
ld de,TrainerInfo_BadgesText ld de, TrainerInfo_BadgesText
call PlaceString call PlaceString
coord hl, 2, 2 coord hl, 2, 2
ld de,TrainerInfo_NameMoneyTimeText ld de, TrainerInfo_NameMoneyTimeText
call PlaceString call PlaceString
coord hl, 7, 2 coord hl, 7, 2
ld de,wPlayerName ld de, wPlayerName
call PlaceString call PlaceString
coord hl, 8, 4 coord hl, 8, 4
ld de,wPlayerMoney ld de, wPlayerMoney
ld c,$e3 ld c, $e3
call PrintBCDNumber call PrintBCDNumber
coord hl, 9, 6 coord hl, 9, 6
ld de,wPlayTimeHours ; hours ld de, wPlayTimeHours ; hours
lb bc, LEFT_ALIGN | 1, 3 lb bc, LEFT_ALIGN | 1, 3
call PrintNumber call PrintNumber
ld [hl],$d6 ; colon tile ID ld [hl], $d6 ; colon tile ID
inc hl inc hl
ld de,wPlayTimeMinutes ; minutes ld de, wPlayTimeMinutes ; minutes
lb bc, LEADING_ZEROES | 1, 2 lb bc, LEADING_ZEROES | 1, 2
jp PrintNumber jp PrintNumber
TrainerInfo_FarCopyData: TrainerInfo_FarCopyData:
ld a,BANK(TrainerInfoTextBoxTileGraphics) ld a, BANK(TrainerInfoTextBoxTileGraphics)
jp FarCopyData2 jp FarCopyData2
TrainerInfo_NameMoneyTimeText: TrainerInfo_NameMoneyTimeText:
@ -631,43 +631,43 @@ TrainerInfo_BadgesText:
; [wTrainerInfoTextBoxWidth] = width - 1 ; [wTrainerInfoTextBoxWidth] = width - 1
; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next ; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next
TrainerInfo_DrawTextBox: TrainerInfo_DrawTextBox:
ld a,$79 ; upper left corner tile ID ld a, $79 ; upper left corner tile ID
lb de, $7a, $7b ; top edge and upper right corner tile ID's lb de, $7a, $7b ; top edge and upper right corner tile ID's
call TrainerInfo_DrawHorizontalEdge ; draw top edge call TrainerInfo_DrawHorizontalEdge ; draw top edge
call TrainerInfo_NextTextBoxRow call TrainerInfo_NextTextBoxRow
ld a,[wTrainerInfoTextBoxWidthPlus1] ld a, [wTrainerInfoTextBoxWidthPlus1]
ld e,a ld e, a
ld d,0 ld d, 0
ld c,6 ; height of the text box ld c, 6 ; height of the text box
.loop .loop
ld [hl],$7c ; left edge tile ID ld [hl], $7c ; left edge tile ID
add hl,de add hl, de
ld [hl],$78 ; right edge tile ID ld [hl], $78 ; right edge tile ID
call TrainerInfo_NextTextBoxRow call TrainerInfo_NextTextBoxRow
dec c dec c
jr nz,.loop jr nz, .loop
ld a,$7d ; lower left corner tile ID ld a, $7d ; lower left corner tile ID
lb de,$77, $7e ; bottom edge and lower right corner tile ID's lb de, $77, $7e ; bottom edge and lower right corner tile ID's
TrainerInfo_DrawHorizontalEdge: TrainerInfo_DrawHorizontalEdge:
ld [hli],a ; place left corner tile ld [hli], a ; place left corner tile
ld a,[wTrainerInfoTextBoxWidth] ld a, [wTrainerInfoTextBoxWidth]
ld c,a ld c, a
ld a,d ld a, d
.loop .loop
ld [hli],a ; place edge tile ld [hli], a ; place edge tile
dec c dec c
jr nz,.loop jr nz, .loop
ld a,e ld a, e
ld [hl],a ; place right corner tile ld [hl], a ; place right corner tile
ret ret
TrainerInfo_NextTextBoxRow: TrainerInfo_NextTextBoxRow:
ld a,[wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row ld a, [wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row
.loop .loop
inc hl inc hl
dec a dec a
jr nz,.loop jr nz, .loop
ret ret
; draws a vertical line ; draws a vertical line
@ -675,26 +675,26 @@ TrainerInfo_NextTextBoxRow:
; hl = address of top tile in the line ; hl = address of top tile in the line
; a = tile ID ; a = tile ID
TrainerInfo_DrawVerticalLine: TrainerInfo_DrawVerticalLine:
ld de,SCREEN_WIDTH ld de, SCREEN_WIDTH
ld c,8 ld c, 8
.loop .loop
ld [hl],a ld [hl], a
add hl,de add hl, de
dec c dec c
jr nz,.loop jr nz, .loop
ret ret
StartMenu_SaveReset: StartMenu_SaveReset:
ld a,[wd72e] ld a, [wd72e]
bit 6,a ; is the player using the link feature? bit 6, a ; is the player using the link feature?
jp nz,Init jp nz, Init
predef SaveSAV ; save the game predef SaveSAV ; save the game
call LoadScreenTilesFromBuffer2 ; restore saved screen call LoadScreenTilesFromBuffer2 ; restore saved screen
jp HoldTextDisplayOpen jp HoldTextDisplayOpen
StartMenu_Option: StartMenu_Option:
xor a xor a
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED], a
call ClearScreen call ClearScreen
call UpdateSprites call UpdateSprites
callab DisplayOptionMenu callab DisplayOptionMenu

View file

@ -1,149 +1,149 @@
HandleItemListSwapping: HandleItemListSwapping:
ld a,[wListMenuID] ld a, [wListMenuID]
cp a,ITEMLISTMENU cp ITEMLISTMENU
jp nz,DisplayListMenuIDLoop ; only rearrange item list menus jp nz, DisplayListMenuIDLoop ; only rearrange item list menus
push hl push hl
ld hl,wListPointer ld hl, wListPointer
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
inc hl ; hl = beginning of list entries inc hl ; hl = beginning of list entries
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld b,a ld b, a
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
add b add b
add a add a
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc ; hl = address of currently selected item entry add hl, bc ; hl = address of currently selected item entry
ld a,[hl] ld a, [hl]
pop hl pop hl
inc a inc a
jp z,DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item jp z, DisplayListMenuIDLoop ; ignore attempts to swap the Cancel menu item
ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
and a ; has the first item to swap already been chosen? and a ; has the first item to swap already been chosen?
jr nz,.swapItems jr nz, .swapItems
; if not, set the currently selected item as the first item ; if not, set the currently selected item as the first item
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
inc a inc a
ld b,a ld b, a
ld a,[wListScrollOffset] ; index of top (visible) menu item within the list ld a, [wListScrollOffset] ; index of top (visible) menu item within the list
add b add b
ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1) ld [wMenuItemToSwap], a ; ID of item chosen for swapping (counts from 1)
ld c,20 ld c, 20
call DelayFrames call DelayFrames
jp DisplayListMenuIDLoop jp DisplayListMenuIDLoop
.swapItems .swapItems
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
inc a inc a
ld b,a ld b, a
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
add b add b
ld b,a ld b, a
ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
cp b ; is the currently selected item the same as the first item to swap? cp b ; is the currently selected item the same as the first item to swap?
jp z,DisplayListMenuIDLoop ; ignore attempts to swap an item with itself jp z, DisplayListMenuIDLoop ; ignore attempts to swap an item with itself
dec a dec a
ld [wMenuItemToSwap],a ; ID of item chosen for swapping (counts from 1) ld [wMenuItemToSwap], a ; ID of item chosen for swapping (counts from 1)
ld c,20 ld c, 20
call DelayFrames call DelayFrames
push hl push hl
push de push de
ld hl,wListPointer ld hl, wListPointer
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
inc hl ; hl = beginning of list entries inc hl ; hl = beginning of list entries
ld d,h ld d, h
ld e,l ; de = beginning of list entries ld e, l ; de = beginning of list entries
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ld b,a ld b, a
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
add b add b
add a add a
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc ; hl = address of currently selected item entry add hl, bc ; hl = address of currently selected item entry
ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1)
add a add a
add e add e
ld e,a ld e, a
jr nc,.noCarry jr nc, .noCarry
inc d inc d
.noCarry ; de = address of first item to swap .noCarry ; de = address of first item to swap
ld a,[de] ld a, [de]
ld b,a ld b, a
ld a,[hli] ld a, [hli]
cp b cp b
jr z,.swapSameItemType jr z, .swapSameItemType
.swapDifferentItems .swapDifferentItems
ld [$ff95],a ; [$ff95] = second item ID ld [$ff95], a ; [$ff95] = second item ID
ld a,[hld] ld a, [hld]
ld [$ff96],a ; [$ff96] = second item quantity ld [$ff96], a ; [$ff96] = second item quantity
ld a,[de] ld a, [de]
ld [hli],a ; put first item ID in second item slot ld [hli], a ; put first item ID in second item slot
inc de inc de
ld a,[de] ld a, [de]
ld [hl],a ; put first item quantity in second item slot ld [hl], a ; put first item quantity in second item slot
ld a,[$ff96] ld a, [$ff96]
ld [de],a ; put second item quantity in first item slot ld [de], a ; put second item quantity in first item slot
dec de dec de
ld a,[$ff95] ld a, [$ff95]
ld [de],a ; put second item ID in first item slot ld [de], a ; put second item ID in first item slot
xor a xor a
ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
pop de pop de
pop hl pop hl
jp DisplayListMenuIDLoop jp DisplayListMenuIDLoop
.swapSameItemType .swapSameItemType
inc de inc de
ld a,[hl] ld a, [hl]
ld b,a ld b, a
ld a,[de] ld a, [de]
add b ; a = sum of both item quantities add b ; a = sum of both item quantities
cp a,100 ; is the sum too big for one item slot? cp 100 ; is the sum too big for one item slot?
jr c,.combineItemSlots jr c, .combineItemSlots
; swap enough items from the first slot to max out the second slot if they can't be combined ; swap enough items from the first slot to max out the second slot if they can't be combined
sub a,99 sub 99
ld [de],a ld [de], a
ld a,99 ld a, 99
ld [hl],a ld [hl], a
jr .done jr .done
.combineItemSlots .combineItemSlots
ld [hl],a ; put the sum in the second item slot ld [hl], a ; put the sum in the second item slot
ld hl,wListPointer ld hl, wListPointer
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
dec [hl] ; decrease the number of items dec [hl] ; decrease the number of items
ld a,[hl] ld a, [hl]
ld [wListCount],a ; update number of items variable ld [wListCount], a ; update number of items variable
cp a,1 cp 1
jr nz,.skipSettingMaxMenuItemID jr nz, .skipSettingMaxMenuItemID
ld [wMaxMenuItem],a ; if the number of items is only one now, update the max menu item ID ld [wMaxMenuItem], a ; if the number of items is only one now, update the max menu item ID
.skipSettingMaxMenuItemID .skipSettingMaxMenuItemID
dec de dec de
ld h,d ld h, d
ld l,e ld l, e
inc hl inc hl
inc hl ; hl = address of item after first item to swap inc hl ; hl = address of item after first item to swap
.moveItemsUpLoop ; erase the first item slot and move up all the following item slots to fill the gap .moveItemsUpLoop ; erase the first item slot and move up all the following item slots to fill the gap
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
inc a ; reached the $ff terminator? inc a ; reached the $ff terminator?
jr z,.afterMovingItemsUp jr z, .afterMovingItemsUp
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
jr .moveItemsUpLoop jr .moveItemsUpLoop
.afterMovingItemsUp .afterMovingItemsUp
xor a xor a
ld [wListScrollOffset],a ld [wListScrollOffset], a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
.done .done
xor a xor a
ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped
pop de pop de
pop hl pop hl
jp DisplayListMenuIDLoop jp DisplayListMenuIDLoop

View file

@ -1,28 +1,28 @@
; function to draw various text boxes ; function to draw various text boxes
DisplayTextBoxID_: DisplayTextBoxID_:
ld a,[wTextBoxID] ld a, [wTextBoxID]
cp a,TWO_OPTION_MENU cp TWO_OPTION_MENU
jp z,DisplayTwoOptionMenu jp z, DisplayTwoOptionMenu
ld c,a ld c, a
ld hl,TextBoxFunctionTable ld hl, TextBoxFunctionTable
ld de,3 ld de, 3
call SearchTextBoxTable call SearchTextBoxTable
jr c,.functionTableMatch jr c, .functionTableMatch
ld hl,TextBoxCoordTable ld hl, TextBoxCoordTable
ld de,5 ld de, 5
call SearchTextBoxTable call SearchTextBoxTable
jr c,.coordTableMatch jr c, .coordTableMatch
ld hl,TextBoxTextAndCoordTable ld hl, TextBoxTextAndCoordTable
ld de,9 ld de, 9
call SearchTextBoxTable call SearchTextBoxTable
jr c,.textAndCoordTableMatch jr c, .textAndCoordTableMatch
.done .done
ret ret
.functionTableMatch .functionTableMatch
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ; hl = address of function ld l, a ; hl = address of function
ld de,.done ld de, .done
push de push de
jp hl ; jump to the function jp hl ; jump to the function
.coordTableMatch .coordTableMatch
@ -37,14 +37,14 @@ DisplayTextBoxID_:
call TextBoxBorder call TextBoxBorder
pop hl pop hl
call GetTextBoxIDText call GetTextBoxIDText
ld a,[wd730] ld a, [wd730]
push af push af
ld a,[wd730] ld a, [wd730]
set 6,a ; no pauses between printing each letter set 6, a ; no pauses between printing each letter
ld [wd730],a ld [wd730], a
call PlaceString call PlaceString
pop af pop af
ld [wd730],a ld [wd730], a
call UpdateSprites call UpdateSprites
ret ret
@ -53,12 +53,12 @@ DisplayTextBoxID_:
SearchTextBoxTable: SearchTextBoxTable:
dec de dec de
.loop .loop
ld a,[hli] ld a, [hli]
cp a,$ff cp $ff
jr z,.notFound jr z, .notFound
cp c cp c
jr z,.found jr z, .found
add hl,de add hl, de
jr .loop jr .loop
.found .found
scf scf
@ -74,31 +74,31 @@ SearchTextBoxTable:
; d = row of upper left corner ; d = row of upper left corner
; e = column of upper left corner ; e = column of upper left corner
GetTextBoxIDCoords: GetTextBoxIDCoords:
ld a,[hli] ; column of upper left corner ld a, [hli] ; column of upper left corner
ld e,a ld e, a
ld a,[hli] ; row of upper left corner ld a, [hli] ; row of upper left corner
ld d,a ld d, a
ld a,[hli] ; column of lower right corner ld a, [hli] ; column of lower right corner
sub e sub e
dec a dec a
ld c,a ; c = width ld c, a ; c = width
ld a,[hli] ; row of lower right corner ld a, [hli] ; row of lower right corner
sub d sub d
dec a dec a
ld b,a ; b = height ld b, a ; b = height
ret ret
; function to load a text address and text coordinates from the TextBoxTextAndCoordTable ; function to load a text address and text coordinates from the TextBoxTextAndCoordTable
GetTextBoxIDText: GetTextBoxIDText:
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ; de = address of text ld d, a ; de = address of text
push de ; save text address push de ; save text address
ld a,[hli] ld a, [hli]
ld e,a ; column of upper left corner of text ld e, a ; column of upper left corner of text
ld a,[hl] ld a, [hl]
ld d,a ; row of upper left corner of text ld d, a ; row of upper left corner of text
call GetAddressOfScreenCoords call GetAddressOfScreenCoords
pop de ; restore text address pop de ; restore text address
ret ret
@ -112,17 +112,17 @@ GetTextBoxIDText:
GetAddressOfScreenCoords: GetAddressOfScreenCoords:
push bc push bc
coord hl, 0, 0 coord hl, 0, 0
ld bc,20 ld bc, 20
.loop ; loop to add d rows to the base address .loop ; loop to add d rows to the base address
ld a,d ld a, d
and a and a
jr z,.addedRows jr z, .addedRows
add hl,bc add hl, bc
dec d dec d
jr .loop jr .loop
.addedRows .addedRows
pop bc pop bc
add hl,de add hl, de
ret ret
; Format: ; Format:

View file

@ -32,123 +32,123 @@ SetDefaultNames:
jp CopyData jp CopyData
OakSpeech: OakSpeech:
ld a,$FF ld a, $FF
call PlaySound ; stop music call PlaySound ; stop music
ld a, BANK(Music_Routes2) ld a, BANK(Music_Routes2)
ld c,a ld c, a
ld a, MUSIC_ROUTES2 ld a, MUSIC_ROUTES2
call PlayMusic call PlayMusic
call ClearScreen call ClearScreen
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
call SetDefaultNames call SetDefaultNames
predef InitPlayerData2 predef InitPlayerData2
ld hl,wNumBoxItems ld hl, wNumBoxItems
ld a,POTION ld a, POTION
ld [wcf91],a ld [wcf91], a
ld a,1 ld a, 1
ld [wItemQuantity],a ld [wItemQuantity], a
call AddItemToInventory ; give one potion call AddItemToInventory ; give one potion
ld a,[wDefaultMap] ld a, [wDefaultMap]
ld [wDestinationMap],a ld [wDestinationMap], a
call SpecialWarpIn call SpecialWarpIn
xor a xor a
ld [hTilesetType],a ld [hTilesetType], a
ld a,[wd732] ld a, [wd732]
bit 1,a ; possibly a debug mode bit bit 1, a ; possibly a debug mode bit
jp nz,.skipChoosingNames jp nz, .skipChoosingNames
ld de,ProfOakPic ld de, ProfOakPic
lb bc, Bank(ProfOakPic), $00 lb bc, Bank(ProfOakPic), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call FadeInIntroPic call FadeInIntroPic
ld hl,OakSpeechText1 ld hl, OakSpeechText1
call PrintText call PrintText
call GBFadeOutToWhite call GBFadeOutToWhite
call ClearScreen call ClearScreen
ld a,NIDORINO ld a, NIDORINO
ld [wd0b5],a ld [wd0b5], a
ld [wcf91],a ld [wcf91], a
call GetMonHeader call GetMonHeader
coord hl, 6, 4 coord hl, 6, 4
call LoadFlippedFrontSpriteByMonIndex call LoadFlippedFrontSpriteByMonIndex
call MovePicLeft call MovePicLeft
ld hl,OakSpeechText2 ld hl, OakSpeechText2
call PrintText call PrintText
call GBFadeOutToWhite call GBFadeOutToWhite
call ClearScreen call ClearScreen
ld de,RedPicFront ld de, RedPicFront
lb bc, Bank(RedPicFront), $00 lb bc, Bank(RedPicFront), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call MovePicLeft call MovePicLeft
ld hl,IntroducePlayerText ld hl, IntroducePlayerText
call PrintText call PrintText
call ChoosePlayerName call ChoosePlayerName
call GBFadeOutToWhite call GBFadeOutToWhite
call ClearScreen call ClearScreen
ld de,Rival1Pic ld de, Rival1Pic
lb bc, Bank(Rival1Pic), $00 lb bc, Bank(Rival1Pic), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call FadeInIntroPic call FadeInIntroPic
ld hl,IntroduceRivalText ld hl, IntroduceRivalText
call PrintText call PrintText
call ChooseRivalName call ChooseRivalName
.skipChoosingNames .skipChoosingNames
call GBFadeOutToWhite call GBFadeOutToWhite
call ClearScreen call ClearScreen
ld de,RedPicFront ld de, RedPicFront
lb bc, Bank(RedPicFront), $00 lb bc, Bank(RedPicFront), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call GBFadeInFromWhite call GBFadeInFromWhite
ld a,[wd72d] ld a, [wd72d]
and a and a
jr nz,.next jr nz, .next
ld hl,OakSpeechText3 ld hl, OakSpeechText3
call PrintText call PrintText
.next .next
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a,SFX_SHRINK ld a, SFX_SHRINK
call PlaySound call PlaySound
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ld c,4 ld c, 4
call DelayFrames call DelayFrames
ld de,RedSprite ld de, RedSprite
ld hl,vSprites ld hl, vSprites
lb bc, BANK(RedSprite), $0C lb bc, BANK(RedSprite), $0C
call CopyVideoData call CopyVideoData
ld de,ShrinkPic1 ld de, ShrinkPic1
lb bc, BANK(ShrinkPic1), $00 lb bc, BANK(ShrinkPic1), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
ld c,4 ld c, 4
call DelayFrames call DelayFrames
ld de,ShrinkPic2 ld de, ShrinkPic2
lb bc, BANK(ShrinkPic2), $00 lb bc, BANK(ShrinkPic2), $00
call IntroDisplayPicCenteredOrUpperRight call IntroDisplayPicCenteredOrUpperRight
call ResetPlayerSpriteData call ResetPlayerSpriteData
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a, BANK(Music_PalletTown) ld a, BANK(Music_PalletTown)
ld [wAudioROMBank],a ld [wAudioROMBank], a
ld [wAudioSavedROMBank],a ld [wAudioSavedROMBank], a
ld a, 10 ld a, 10
ld [wAudioFadeOutControl],a ld [wAudioFadeOutControl], a
ld a,$FF ld a, $FF
ld [wNewSoundID],a ld [wNewSoundID], a
call PlaySound ; stop music call PlaySound ; stop music
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ld c,20 ld c, 20
call DelayFrames call DelayFrames
coord hl, 6, 5 coord hl, 6, 5
ld b,7 ld b, 7
ld c,7 ld c, 7
call ClearScreenArea call ClearScreenArea
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
ld a,1 ld a, 1
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
ld c,50 ld c, 50
call DelayFrames call DelayFrames
call GBFadeOutToWhite call GBFadeOutToWhite
jp ClearScreen jp ClearScreen
@ -171,15 +171,15 @@ OakSpeechText3:
db "@" db "@"
FadeInIntroPic: FadeInIntroPic:
ld hl,IntroFadePalettes ld hl, IntroFadePalettes
ld b,6 ld b, 6
.next .next
ld a,[hli] ld a, [hli]
ld [rBGP],a ld [rBGP], a
ld c,10 ld c, 10
call DelayFrames call DelayFrames
dec b dec b
jr nz,.next jr nz, .next
ret ret
IntroFadePalettes: IntroFadePalettes:
@ -191,19 +191,19 @@ IntroFadePalettes:
db %11100100 db %11100100
MovePicLeft: MovePicLeft:
ld a,119 ld a, 119
ld [rWX],a ld [rWX], a
call DelayFrame call DelayFrame
ld a,%11100100 ld a, %11100100
ld [rBGP],a ld [rBGP], a
.next .next
call DelayFrame call DelayFrame
ld a,[rWX] ld a, [rWX]
sub 8 sub 8
cp $FF cp $FF
ret z ret z
ld [rWX],a ld [rWX], a
jr .next jr .next
DisplayPicCenteredOrUpperRight: DisplayPicCenteredOrUpperRight:
@ -213,21 +213,21 @@ IntroDisplayPicCenteredOrUpperRight:
; de = address of compressed pic ; de = address of compressed pic
; c: 0 = centred, non-zero = upper-right ; c: 0 = centred, non-zero = upper-right
push bc push bc
ld a,b ld a, b
call UncompressSpriteFromDE call UncompressSpriteFromDE
ld hl,sSpriteBuffer1 ld hl, sSpriteBuffer1
ld de,sSpriteBuffer0 ld de, sSpriteBuffer0
ld bc,$310 ld bc, $310
call CopyData call CopyData
ld de,vFrontPic ld de, vFrontPic
call InterlaceMergeSpriteBuffers call InterlaceMergeSpriteBuffers
pop bc pop bc
ld a,c ld a, c
and a and a
coord hl, 15, 1 coord hl, 15, 1
jr nz,.next jr nz, .next
coord hl, 6, 4 coord hl, 6, 4
.next .next
xor a xor a
ld [hStartTileID],a ld [hStartTileID], a
predef_jump CopyUncompressedPicToTilemap predef_jump CopyUncompressedPicToTilemap

View file

@ -12,113 +12,113 @@ InitMapSprites:
call InitOutsideMapSprites call InitOutsideMapSprites
ret c ; return if the map is an outside map (already handled by above call) ret c ; return if the map is an outside map (already handled by above call)
; if the map is an inside map (i.e. mapID >= $25) ; if the map is an inside map (i.e. mapID >= $25)
ld hl,wSpriteStateData1 ld hl, wSpriteStateData1
ld de,wSpriteStateData2 + $0d ld de, wSpriteStateData2 + $0d
; Loop to copy picture ID's from $C1X0 to $C2XD for LoadMapSpriteTilePatterns. ; Loop to copy picture ID's from $C1X0 to $C2XD for LoadMapSpriteTilePatterns.
.copyPictureIDLoop .copyPictureIDLoop
ld a,[hl] ; $C1X0 (picture ID) ld a, [hl] ; $C1X0 (picture ID)
ld [de],a ; $C2XD ld [de], a ; $C2XD
ld a,$10 ld a, $10
add e add e
ld e,a ld e, a
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
jr nz,.copyPictureIDLoop jr nz, .copyPictureIDLoop
; This is used for both inside and outside maps, since it is called by ; This is used for both inside and outside maps, since it is called by
; InitOutsideMapSprites. ; InitOutsideMapSprites.
; Loads tile pattern data for sprites into VRAM. ; Loads tile pattern data for sprites into VRAM.
LoadMapSpriteTilePatterns: LoadMapSpriteTilePatterns:
ld a,[wNumSprites] ld a, [wNumSprites]
and a ; are there any sprites? and a ; are there any sprites?
jr nz,.spritesExist jr nz, .spritesExist
ret ret
.spritesExist .spritesExist
ld c,a ; c = [wNumSprites] ld c, a ; c = [wNumSprites]
ld b,$10 ; number of sprite slots ld b, $10 ; number of sprite slots
ld hl,wSpriteStateData2 + $0d ld hl, wSpriteStateData2 + $0d
xor a xor a
ld [hFourTileSpriteCount],a ld [hFourTileSpriteCount], a
.copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE .copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE
ld a,[hli] ; $C2XD (sprite picture ID) ld a, [hli] ; $C2XD (sprite picture ID)
ld [hld],a ; $C2XE ld [hld], a ; $C2XE
ld a,l ld a, l
add a,$10 add $10
ld l,a ld l, a
dec b dec b
jr nz,.copyPictureIDLoop jr nz, .copyPictureIDLoop
ld hl,wSpriteStateData2 + $1e ld hl, wSpriteStateData2 + $1e
.loadTilePatternLoop .loadTilePatternLoop
ld de,wSpriteStateData2 + $1d ld de, wSpriteStateData2 + $1d
; Check if the current picture ID has already had its tile patterns loaded. ; Check if the current picture ID has already had its tile patterns loaded.
; This done by looping through the previous sprite slots and seeing if any of ; This done by looping through the previous sprite slots and seeing if any of
; their picture ID's match that of the current sprite slot. ; their picture ID's match that of the current sprite slot.
.checkIfAlreadyLoadedLoop .checkIfAlreadyLoadedLoop
ld a,e ld a, e
and a,$f0 and $f0
ld b,a ; b = offset of the wSpriteStateData2 sprite slot being checked against ld b, a ; b = offset of the wSpriteStateData2 sprite slot being checked against
ld a,l ld a, l
and a,$f0 ; a = offset of current wSpriteStateData2 sprite slot and $f0 ; a = offset of current wSpriteStateData2 sprite slot
cp b ; done checking all previous sprite slots? cp b ; done checking all previous sprite slots?
jr z,.notAlreadyLoaded jr z, .notAlreadyLoaded
ld a,[de] ; picture ID of the wSpriteStateData2 sprite slot being checked against ld a, [de] ; picture ID of the wSpriteStateData2 sprite slot being checked against
cp [hl] ; do the picture ID's match? cp [hl] ; do the picture ID's match?
jp z,.alreadyLoaded jp z, .alreadyLoaded
ld a,e ld a, e
add a,$10 add $10
ld e,a ld e, a
jr .checkIfAlreadyLoadedLoop jr .checkIfAlreadyLoadedLoop
.notAlreadyLoaded .notAlreadyLoaded
ld de,wSpriteStateData2 + $0e ld de, wSpriteStateData2 + $0e
ld b,$01 ld b, $01
; loop to find the highest tile pattern VRAM slot (among the first 10 slots) used by a previous sprite slot ; loop to find the highest tile pattern VRAM slot (among the first 10 slots) used by a previous sprite slot
; this is done in order to find the first free VRAM slot available ; this is done in order to find the first free VRAM slot available
.findNextVRAMSlotLoop .findNextVRAMSlotLoop
ld a,e ld a, e
add a,$10 add $10
ld e,a ld e, a
ld a,l ld a, l
cp e ; reached current slot? cp e ; reached current slot?
jr z,.foundNextVRAMSlot jr z, .foundNextVRAMSlot
ld a,[de] ; $C2YE (VRAM slot) ld a, [de] ; $C2YE (VRAM slot)
cp a,11 ; is it one of the first 10 slots? cp 11 ; is it one of the first 10 slots?
jr nc,.findNextVRAMSlotLoop jr nc, .findNextVRAMSlotLoop
cp b ; compare the slot being checked to the current max cp b ; compare the slot being checked to the current max
jr c,.findNextVRAMSlotLoop ; if the slot being checked is less than the current max jr c, .findNextVRAMSlotLoop ; if the slot being checked is less than the current max
; if the slot being checked is greater than or equal to the current max ; if the slot being checked is greater than or equal to the current max
ld b,a ; store new max VRAM slot ld b, a ; store new max VRAM slot
jr .findNextVRAMSlotLoop jr .findNextVRAMSlotLoop
.foundNextVRAMSlot .foundNextVRAMSlot
inc b ; increment previous max value to get next VRAM tile pattern slot inc b ; increment previous max value to get next VRAM tile pattern slot
ld a,b ; a = next VRAM tile pattern slot ld a, b ; a = next VRAM tile pattern slot
push af push af
ld a,[hl] ; $C2XE (sprite picture ID) ld a, [hl] ; $C2XE (sprite picture ID)
ld b,a ; b = current sprite picture ID ld b, a ; b = current sprite picture ID
cp a,SPRITE_BALL ; is it a 4-tile sprite? cp SPRITE_BALL ; is it a 4-tile sprite?
jr c,.notFourTileSprite jr c, .notFourTileSprite
pop af pop af
ld a,[hFourTileSpriteCount] ld a, [hFourTileSpriteCount]
add a,11 add 11
jr .storeVRAMSlot jr .storeVRAMSlot
.notFourTileSprite .notFourTileSprite
pop af pop af
.storeVRAMSlot .storeVRAMSlot
ld [hl],a ; store VRAM slot at $C2XE ld [hl], a ; store VRAM slot at $C2XE
ld [hVRAMSlot],a ; used to determine if it's 4-tile sprite later ld [hVRAMSlot], a ; used to determine if it's 4-tile sprite later
ld a,b ; a = current sprite picture ID ld a, b ; a = current sprite picture ID
dec a dec a
add a add a
add a add a
push bc push bc
push hl push hl
ld hl,SpriteSheetPointerTable ld hl, SpriteSheetPointerTable
jr nc,.noCarry jr nc, .noCarry
inc h inc h
.noCarry .noCarry
add l add l
ld l,a ld l, a
jr nc,.noCarry2 jr nc, .noCarry2
inc h inc h
.noCarry2 .noCarry2
push hl push hl
@ -126,69 +126,69 @@ LoadMapSpriteTilePatterns:
push af push af
push de push de
push bc push bc
ld hl,vNPCSprites ; VRAM base address ld hl, vNPCSprites ; VRAM base address
ld bc,$c0 ; number of bytes per VRAM slot ld bc, $c0 ; number of bytes per VRAM slot
ld a,[hVRAMSlot] ld a, [hVRAMSlot]
cp a,11 ; is it a 4-tile sprite? cp 11 ; is it a 4-tile sprite?
jr nc,.fourTileSpriteVRAMAddr jr nc, .fourTileSpriteVRAMAddr
ld d,a ld d, a
dec d dec d
; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM ; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM
; slot and adding the result to $8000 (the VRAM base address). ; slot and adding the result to $8000 (the VRAM base address).
.calculateVRAMAddrLoop .calculateVRAMAddrLoop
add hl,bc add hl, bc
dec d dec d
jr nz,.calculateVRAMAddrLoop jr nz, .calculateVRAMAddrLoop
jr .loadStillTilePattern jr .loadStillTilePattern
.fourTileSpriteVRAMAddr .fourTileSpriteVRAMAddr
ld hl,vSprites + $7c0 ; address for second 4-tile sprite ld hl, vSprites + $7c0 ; address for second 4-tile sprite
ld a,[hFourTileSpriteCount] ld a, [hFourTileSpriteCount]
and a and a
jr nz,.loadStillTilePattern jr nz, .loadStillTilePattern
; if it's the first 4-tile sprite ; if it's the first 4-tile sprite
ld hl,vSprites + $780 ; address for first 4-tile sprite ld hl, vSprites + $780 ; address for first 4-tile sprite
inc a inc a
ld [hFourTileSpriteCount],a ld [hFourTileSpriteCount], a
.loadStillTilePattern .loadStillTilePattern
pop bc pop bc
pop de pop de
pop af pop af
push hl push hl
push hl push hl
ld h,d ld h, d
ld l,e ld l, e
pop de pop de
ld b,a ld b, a
ld a,[wFontLoaded] ld a, [wFontLoaded]
bit 0,a ; reloading upper half of tile patterns after displaying text? bit 0, a ; reloading upper half of tile patterns after displaying text?
jr nz,.skipFirstLoad ; if so, skip loading data into the lower half jr nz, .skipFirstLoad ; if so, skip loading data into the lower half
ld a,b ld a, b
ld b,0 ld b, 0
call FarCopyData2 ; load tile pattern data for sprite when standing still call FarCopyData2 ; load tile pattern data for sprite when standing still
.skipFirstLoad .skipFirstLoad
pop de pop de
pop hl pop hl
ld a,[hVRAMSlot] ld a, [hVRAMSlot]
cp a,11 ; is it a 4-tile sprite? cp 11 ; is it a 4-tile sprite?
jr nc,.skipSecondLoad ; if so, there is no second block jr nc, .skipSecondLoad ; if so, there is no second block
push de push de
call ReadSpriteSheetData call ReadSpriteSheetData
push af push af
ld a,$c0 ld a, $c0
add e add e
ld e,a ld e, a
jr nc,.noCarry3 jr nc, .noCarry3
inc d inc d
.noCarry3 .noCarry3
ld a,[wFontLoaded] ld a, [wFontLoaded]
bit 0,a ; reloading upper half of tile patterns after displaying text? bit 0, a ; reloading upper half of tile patterns after displaying text?
jr nz,.loadWhileLCDOn jr nz, .loadWhileLCDOn
pop af pop af
pop hl pop hl
set 3,h ; add $800 to hl set 3, h ; add $800 to hl
push hl push hl
ld h,d ld h, d
ld l,e ld l, e
pop de pop de
call FarCopyData2 ; load tile pattern data for sprite when walking call FarCopyData2 ; load tile pattern data for sprite when walking
jr .skipSecondLoad jr .skipSecondLoad
@ -198,8 +198,8 @@ LoadMapSpriteTilePatterns:
.loadWhileLCDOn .loadWhileLCDOn
pop af pop af
pop hl pop hl
set 3,h ; add $800 to hl set 3, h ; add $800 to hl
ld b,a ld b, a
swap c swap c
call CopyVideoData ; load tile pattern data for sprite when walking call CopyVideoData ; load tile pattern data for sprite when walking
.skipSecondLoad .skipSecondLoad
@ -208,25 +208,25 @@ LoadMapSpriteTilePatterns:
jr .nextSpriteSlot jr .nextSpriteSlot
.alreadyLoaded ; if the current picture ID has already had its tile patterns loaded .alreadyLoaded ; if the current picture ID has already had its tile patterns loaded
inc de inc de
ld a,[de] ; a = VRAM slot for the current picture ID (from $C2YE) ld a, [de] ; a = VRAM slot for the current picture ID (from $C2YE)
ld [hl],a ; store VRAM slot in current wSpriteStateData2 sprite slot (at $C2XE) ld [hl], a ; store VRAM slot in current wSpriteStateData2 sprite slot (at $C2XE)
.nextSpriteSlot .nextSpriteSlot
ld a,l ld a, l
add a,$10 add $10
ld l,a ld l, a
dec c dec c
jp nz,.loadTilePatternLoop jp nz, .loadTilePatternLoop
ld hl,wSpriteStateData2 + $0d ld hl, wSpriteStateData2 + $0d
ld b,$10 ld b, $10
; the pictures ID's stored at $C2XD are no longer needed, so zero them ; the pictures ID's stored at $C2XD are no longer needed, so zero them
.zeroStoredPictureIDLoop .zeroStoredPictureIDLoop
xor a xor a
ld [hl],a ; $C2XD ld [hl], a ; $C2XD
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
dec b dec b
jr nz,.zeroStoredPictureIDLoop jr nz, .zeroStoredPictureIDLoop
ret ret
; reads data from SpriteSheetPointerTable ; reads data from SpriteSheetPointerTable
@ -237,108 +237,108 @@ LoadMapSpriteTilePatterns:
; bc = length in bytes ; bc = length in bytes
; a = ROM bank ; a = ROM bank
ReadSpriteSheetData: ReadSpriteSheetData:
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
ld a,[hli] ld a, [hli]
ld c,a ld c, a
xor a xor a
ld b,a ld b, a
ld a,[hli] ld a, [hli]
ret ret
; Loads sprite set for outside maps (cities and routes) and sets VRAM slots. ; Loads sprite set for outside maps (cities and routes) and sets VRAM slots.
; sets carry if the map is a city or route, unsets carry if not ; sets carry if the map is a city or route, unsets carry if not
InitOutsideMapSprites: InitOutsideMapSprites:
ld a,[wCurMap] ld a, [wCurMap]
cp a,REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)? cp REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)?
ret nc ; if not, return ret nc ; if not, return
ld hl,MapSpriteSets ld hl, MapSpriteSets
add l add l
ld l,a ld l, a
jr nc,.noCarry jr nc, .noCarry
inc h inc h
.noCarry .noCarry
ld a,[hl] ; a = spriteSetID ld a, [hl] ; a = spriteSetID
cp a,$f0 ; does the map have 2 sprite sets? cp $f0 ; does the map have 2 sprite sets?
call nc,GetSplitMapSpriteSetID ; if so, choose the appropriate one call nc, GetSplitMapSpriteSetID ; if so, choose the appropriate one
ld b,a ; b = spriteSetID ld b, a ; b = spriteSetID
ld a,[wFontLoaded] ld a, [wFontLoaded]
bit 0,a ; reloading upper half of tile patterns after displaying text? bit 0, a ; reloading upper half of tile patterns after displaying text?
jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set
ld a,[wSpriteSetID] ld a, [wSpriteSetID]
cp b ; has the sprite set ID changed? cp b ; has the sprite set ID changed?
jr z,.skipLoadingSpriteSet ; if not, don't load it again jr z, .skipLoadingSpriteSet ; if not, don't load it again
.loadSpriteSet .loadSpriteSet
ld a,b ld a, b
ld [wSpriteSetID],a ld [wSpriteSetID], a
dec a dec a
ld b,a ld b, a
sla a sla a
ld c,a ld c, a
sla a sla a
sla a sla a
add c add c
add b ; a = (spriteSetID - 1) * 11 add b ; a = (spriteSetID - 1) * 11
ld de,SpriteSets ld de, SpriteSets
; add a to de to get offset of sprite set ; add a to de to get offset of sprite set
add e add e
ld e,a ld e, a
jr nc,.noCarry2 jr nc, .noCarry2
inc d inc d
.noCarry2 .noCarry2
ld hl,wSpriteStateData2 + $0d ld hl, wSpriteStateData2 + $0d
ld a,SPRITE_RED ld a, SPRITE_RED
ld [hl],a ld [hl], a
ld bc,wSpriteSet ld bc, wSpriteSet
; Load the sprite set into RAM. ; Load the sprite set into RAM.
; This loop also fills $C2XD (sprite picture ID) where X is from $0 to $A ; This loop also fills $C2XD (sprite picture ID) where X is from $0 to $A
; with picture ID's. This is done so that LoadMapSpriteTilePatterns will ; with picture ID's. This is done so that LoadMapSpriteTilePatterns will
; load tile patterns for all sprite pictures in the sprite set. ; load tile patterns for all sprite pictures in the sprite set.
.loadSpriteSetLoop .loadSpriteSetLoop
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
ld a,[de] ; sprite picture ID from sprite set ld a, [de] ; sprite picture ID from sprite set
ld [hl],a ; $C2XD (sprite picture ID) ld [hl], a ; $C2XD (sprite picture ID)
ld [bc],a ld [bc], a
inc de inc de
inc bc inc bc
ld a,l ld a, l
cp a,$bd ; reached 11th sprite slot? cp $bd ; reached 11th sprite slot?
jr nz,.loadSpriteSetLoop jr nz, .loadSpriteSetLoop
ld b,4 ; 4 remaining sprite slots ld b, 4 ; 4 remaining sprite slots
.zeroRemainingSlotsLoop ; loop to zero the picture ID's of the remaining sprite slots .zeroRemainingSlotsLoop ; loop to zero the picture ID's of the remaining sprite slots
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
xor a xor a
ld [hl],a ; $C2XD (sprite picture ID) ld [hl], a ; $C2XD (sprite picture ID)
dec b dec b
jr nz,.zeroRemainingSlotsLoop jr nz, .zeroRemainingSlotsLoop
ld a,[wNumSprites] ld a, [wNumSprites]
push af ; save number of sprites push af ; save number of sprites
ld a,11 ; 11 sprites in sprite set ld a, 11 ; 11 sprites in sprite set
ld [wNumSprites],a ld [wNumSprites], a
call LoadMapSpriteTilePatterns call LoadMapSpriteTilePatterns
pop af pop af
ld [wNumSprites],a ; restore number of sprites ld [wNumSprites], a ; restore number of sprites
ld hl,wSpriteStateData2 + $1e ld hl, wSpriteStateData2 + $1e
ld b,$0f ld b, $0f
; The VRAM tile pattern slots that LoadMapSpriteTilePatterns set are in the ; The VRAM tile pattern slots that LoadMapSpriteTilePatterns set are in the
; order of the map's sprite set, not the order of the actual sprites loaded ; order of the map's sprite set, not the order of the actual sprites loaded
; for the current map. So, they are not needed and are zeroed by this loop. ; for the current map. So, they are not needed and are zeroed by this loop.
.zeroVRAMSlotsLoop .zeroVRAMSlotsLoop
xor a xor a
ld [hl],a ; $C2XE (VRAM slot) ld [hl], a ; $C2XE (VRAM slot)
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
dec b dec b
jr nz,.zeroVRAMSlotsLoop jr nz, .zeroVRAMSlotsLoop
.skipLoadingSpriteSet .skipLoadingSpriteSet
ld hl,wSpriteStateData1 + $10 ld hl, wSpriteStateData1 + $10
; This loop stores the correct VRAM tile pattern slots according the sprite ; This loop stores the correct VRAM tile pattern slots according the sprite
; data from the map's header. Since the VRAM tile pattern slots are filled in ; data from the map's header. Since the VRAM tile pattern slots are filled in
; the order of the sprite set, in order to find the VRAM tile pattern slot ; the order of the sprite set, in order to find the VRAM tile pattern slot
@ -347,94 +347,94 @@ InitOutsideMapSprites:
; (since the Red sprite always has the first VRAM tile pattern slot) is the ; (since the Red sprite always has the first VRAM tile pattern slot) is the
; VRAM tile pattern slot. ; VRAM tile pattern slot.
.storeVRAMSlotsLoop .storeVRAMSlotsLoop
ld c,0 ld c, 0
ld a,[hl] ; $C1X0 (picture ID) (zero if sprite slot is not used) ld a, [hl] ; $C1X0 (picture ID) (zero if sprite slot is not used)
and a ; is the sprite slot used? and a ; is the sprite slot used?
jr z,.skipGettingPictureIndex ; if the sprite slot is not used jr z, .skipGettingPictureIndex ; if the sprite slot is not used
ld b,a ; b = picture ID ld b, a ; b = picture ID
ld de,wSpriteSet ld de, wSpriteSet
; Loop to find the index of the sprite's picture ID within the sprite set. ; Loop to find the index of the sprite's picture ID within the sprite set.
.getPictureIndexLoop .getPictureIndexLoop
inc c inc c
ld a,[de] ld a, [de]
inc de inc de
cp b ; does the picture ID match? cp b ; does the picture ID match?
jr nz,.getPictureIndexLoop jr nz, .getPictureIndexLoop
inc c inc c
.skipGettingPictureIndex .skipGettingPictureIndex
push hl push hl
inc h inc h
ld a,$0e ld a, $0e
add l add l
ld l,a ld l, a
ld a,c ; a = VRAM slot (zero if sprite slot is not used) ld a, c ; a = VRAM slot (zero if sprite slot is not used)
ld [hl],a ; $C2XE (VRAM slot) ld [hl], a ; $C2XE (VRAM slot)
pop hl pop hl
ld a,$10 ld a, $10
add l add l
ld l,a ld l, a
and a and a
jr nz,.storeVRAMSlotsLoop jr nz, .storeVRAMSlotsLoop
scf scf
ret ret
; Chooses the correct sprite set ID depending on the player's position within ; Chooses the correct sprite set ID depending on the player's position within
; the map for maps with two sprite sets. ; the map for maps with two sprite sets.
GetSplitMapSpriteSetID: GetSplitMapSpriteSetID:
cp a,$f8 cp $f8
jr z,.route20 jr z, .route20
ld hl,SplitMapSpriteSets ld hl, SplitMapSpriteSets
and a,$0f and $0f
dec a dec a
sla a sla a
sla a sla a
add l add l
ld l,a ld l, a
jr nc,.noCarry jr nc, .noCarry
inc h inc h
.noCarry .noCarry
ld a,[hli] ; determines whether the map is split East/West or North/South ld a, [hli] ; determines whether the map is split East/West or North/South
cp a,$01 cp $01
ld a,[hli] ; position of dividing line ld a, [hli] ; position of dividing line
ld b,a ld b, a
jr z,.eastWestDivide jr z, .eastWestDivide
.northSouthDivide .northSouthDivide
ld a,[wYCoord] ld a, [wYCoord]
jr .compareCoord jr .compareCoord
.eastWestDivide .eastWestDivide
ld a,[wXCoord] ld a, [wXCoord]
.compareCoord .compareCoord
cp b cp b
jr c,.loadSpriteSetID jr c, .loadSpriteSetID
; if in the East side or South side ; if in the East side or South side
inc hl inc hl
.loadSpriteSetID .loadSpriteSetID
ld a,[hl] ld a, [hl]
ret ret
; Uses sprite set $01 for West side and $0A for East side. ; Uses sprite set $01 for West side and $0A for East side.
; Route 20 is a special case because the two map sections have a more complex ; Route 20 is a special case because the two map sections have a more complex
; shape instead of the map simply being split horizontally or vertically. ; shape instead of the map simply being split horizontally or vertically.
.route20 .route20
ld hl,wXCoord ld hl, wXCoord
ld a,[hl] ld a, [hl]
cp a,$2b cp $2b
ld a,$01 ld a, $01
ret c ret c
ld a,[hl] ld a, [hl]
cp a,$3e cp $3e
ld a,$0a ld a, $0a
ret nc ret nc
ld a,[hl] ld a, [hl]
cp a,$37 cp $37
ld b,$08 ld b, $08
jr nc,.next jr nc, .next
ld b,$0d ld b, $0d
.next .next
ld a,[wYCoord] ld a, [wYCoord]
cp b cp b
ld a,$0a ld a, $0a
ret c ret c
ld a,$01 ld a, $01
ret ret
INCLUDE "data/sprite_sets.asm" INCLUDE "data/sprite_sets.asm"

View file

@ -1,230 +1,230 @@
DisplayPokemartDialogue_: DisplayPokemartDialogue_:
ld a,[wListScrollOffset] ld a, [wListScrollOffset]
ld [wSavedListScrollOffset],a ld [wSavedListScrollOffset], a
call UpdateSprites call UpdateSprites
xor a xor a
ld [wBoughtOrSoldItemInMart],a ld [wBoughtOrSoldItemInMart], a
.loop .loop
xor a xor a
ld [wListScrollOffset],a ld [wListScrollOffset], a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld [wPlayerMonNumber],a ld [wPlayerMonNumber], a
inc a inc a
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
ld a,BUY_SELL_QUIT_MENU ld a, BUY_SELL_QUIT_MENU
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
; This code is useless. It copies the address of the pokemart's inventory to hl, ; This code is useless. It copies the address of the pokemart's inventory to hl,
; but the address is never used. ; but the address is never used.
ld hl,wItemListPointer ld hl, wItemListPointer
ld a,[hli] ld a, [hli]
ld l,[hl] ld l, [hl]
ld h,a ld h, a
ld a,[wMenuExitMethod] ld a, [wMenuExitMethod]
cp a,CANCELLED_MENU cp CANCELLED_MENU
jp z,.done jp z, .done
ld a,[wChosenMenuItem] ld a, [wChosenMenuItem]
and a ; buying? and a ; buying?
jp z,.buyMenu jp z, .buyMenu
dec a ; selling? dec a ; selling?
jp z,.sellMenu jp z, .sellMenu
dec a ; quitting? dec a ; quitting?
jp z,.done jp z, .done
.sellMenu .sellMenu
; the same variables are set again below, so this code has no effect ; the same variables are set again below, so this code has no effect
xor a xor a
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
ld a,INIT_BAG_ITEM_LIST ld a, INIT_BAG_ITEM_LIST
ld [wInitListType],a ld [wInitListType], a
callab InitList callab InitList
ld a,[wNumBagItems] ld a, [wNumBagItems]
and a and a
jp z,.bagEmpty jp z, .bagEmpty
ld hl,PokemonSellingGreetingText ld hl, PokemonSellingGreetingText
call PrintText call PrintText
call SaveScreenTilesToBuffer1 ; save screen call SaveScreenTilesToBuffer1 ; save screen
.sellMenuLoop .sellMenuLoop
call LoadScreenTilesFromBuffer1 ; restore saved screen call LoadScreenTilesFromBuffer1 ; restore saved screen
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; draw money text box call DisplayTextBoxID ; draw money text box
ld hl,wNumBagItems ld hl, wNumBagItems
ld a,l ld a, l
ld [wListPointer],a ld [wListPointer], a
ld a,h ld a, h
ld [wListPointer + 1],a ld [wListPointer + 1], a
xor a xor a
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
ld a,ITEMLISTMENU ld a, ITEMLISTMENU
ld [wListMenuID],a ld [wListMenuID], a
call DisplayListMenuID call DisplayListMenuID
jp c,.returnToMainPokemartMenu ; if the player closed the menu jp c, .returnToMainPokemartMenu ; if the player closed the menu
.confirmItemSale ; if the player is trying to sell a specific item .confirmItemSale ; if the player is trying to sell a specific item
call IsKeyItem call IsKeyItem
ld a,[wIsKeyItem] ld a, [wIsKeyItem]
and a and a
jr nz,.unsellableItem jr nz, .unsellableItem
ld a,[wcf91] ld a, [wcf91]
call IsItemHM call IsItemHM
jr c,.unsellableItem jr c, .unsellableItem
ld a,PRICEDITEMLISTMENU ld a, PRICEDITEMLISTMENU
ld [wListMenuID],a ld [wListMenuID], a
ld [hHalveItemPrices],a ; halve prices when selling ld [hHalveItemPrices], a ; halve prices when selling
call DisplayChooseQuantityMenu call DisplayChooseQuantityMenu
inc a inc a
jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button
ld hl,PokemartTellSellPriceText ld hl, PokemartTellSellPriceText
lb bc, 14, 1 ; location that PrintText always prints to, this is useless lb bc, 14, 1 ; location that PrintText always prints to, this is useless
call PrintText call PrintText
coord hl, 14, 7 coord hl, 14, 7
lb bc, 8, 15 lb bc, 8, 15
ld a,TWO_OPTION_MENU ld a, TWO_OPTION_MENU
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu call DisplayTextBoxID ; yes/no menu
ld a,[wMenuExitMethod] ld a, [wMenuExitMethod]
cp a,CHOSE_SECOND_ITEM cp CHOSE_SECOND_ITEM
jr z,.sellMenuLoop ; if the player chose No or pressed the B button jr z, .sellMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above ; The following code is supposed to check if the player chose No, but the above
; check already catches it. ; check already catches it.
ld a,[wChosenMenuItem] ld a, [wChosenMenuItem]
dec a dec a
jr z,.sellMenuLoop jr z, .sellMenuLoop
.sellItem .sellItem
ld a,[wBoughtOrSoldItemInMart] ld a, [wBoughtOrSoldItemInMart]
and a and a
jr nz,.skipSettingFlag1 jr nz, .skipSettingFlag1
inc a inc a
ld [wBoughtOrSoldItemInMart],a ld [wBoughtOrSoldItemInMart], a
.skipSettingFlag1 .skipSettingFlag1
call AddAmountSoldToMoney call AddAmountSoldToMoney
ld hl,wNumBagItems ld hl, wNumBagItems
call RemoveItemFromInventory call RemoveItemFromInventory
jp .sellMenuLoop jp .sellMenuLoop
.unsellableItem .unsellableItem
ld hl,PokemartUnsellableItemText ld hl, PokemartUnsellableItemText
call PrintText call PrintText
jp .returnToMainPokemartMenu jp .returnToMainPokemartMenu
.bagEmpty .bagEmpty
ld hl,PokemartItemBagEmptyText ld hl, PokemartItemBagEmptyText
call PrintText call PrintText
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
jp .returnToMainPokemartMenu jp .returnToMainPokemartMenu
.buyMenu .buyMenu
; the same variables are set again below, so this code has no effect ; the same variables are set again below, so this code has no effect
ld a,1 ld a, 1
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
ld a,INIT_OTHER_ITEM_LIST ld a, INIT_OTHER_ITEM_LIST
ld [wInitListType],a ld [wInitListType], a
callab InitList callab InitList
ld hl,PokemartBuyingGreetingText ld hl, PokemartBuyingGreetingText
call PrintText call PrintText
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
.buyMenuLoop .buyMenuLoop
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
ld hl,wItemList ld hl, wItemList
ld a,l ld a, l
ld [wListPointer],a ld [wListPointer], a
ld a,h ld a, h
ld [wListPointer + 1],a ld [wListPointer + 1], a
xor a xor a
ld [wCurrentMenuItem],a ld [wCurrentMenuItem], a
inc a inc a
ld [wPrintItemPrices],a ld [wPrintItemPrices], a
inc a ; a = 2 (PRICEDITEMLISTMENU) inc a ; a = 2 (PRICEDITEMLISTMENU)
ld [wListMenuID],a ld [wListMenuID], a
call DisplayListMenuID call DisplayListMenuID
jr c,.returnToMainPokemartMenu ; if the player closed the menu jr c, .returnToMainPokemartMenu ; if the player closed the menu
ld a,99 ld a, 99
ld [wMaxItemQuantity],a ld [wMaxItemQuantity], a
xor a xor a
ld [hHalveItemPrices],a ; don't halve item prices when buying ld [hHalveItemPrices], a ; don't halve item prices when buying
call DisplayChooseQuantityMenu call DisplayChooseQuantityMenu
inc a inc a
jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button
ld a,[wcf91] ; item ID ld a, [wcf91] ; item ID
ld [wd11e],a ; store item ID for GetItemName ld [wd11e], a ; store item ID for GetItemName
call GetItemName call GetItemName
call CopyStringToCF4B ; copy name to wcf4b call CopyStringToCF4B ; copy name to wcf4b
ld hl,PokemartTellBuyPriceText ld hl, PokemartTellBuyPriceText
call PrintText call PrintText
coord hl, 14, 7 coord hl, 14, 7
lb bc, 8, 15 lb bc, 8, 15
ld a,TWO_OPTION_MENU ld a, TWO_OPTION_MENU
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu call DisplayTextBoxID ; yes/no menu
ld a,[wMenuExitMethod] ld a, [wMenuExitMethod]
cp a,CHOSE_SECOND_ITEM cp CHOSE_SECOND_ITEM
jp z,.buyMenuLoop ; if the player chose No or pressed the B button jp z, .buyMenuLoop ; if the player chose No or pressed the B button
; The following code is supposed to check if the player chose No, but the above ; The following code is supposed to check if the player chose No, but the above
; check already catches it. ; check already catches it.
ld a,[wChosenMenuItem] ld a, [wChosenMenuItem]
dec a dec a
jr z,.buyMenuLoop jr z, .buyMenuLoop
.buyItem .buyItem
call .isThereEnoughMoney call .isThereEnoughMoney
jr c,.notEnoughMoney jr c, .notEnoughMoney
ld hl,wNumBagItems ld hl, wNumBagItems
call AddItemToInventory call AddItemToInventory
jr nc,.bagFull jr nc, .bagFull
call SubtractAmountPaidFromMoney call SubtractAmountPaidFromMoney
ld a,[wBoughtOrSoldItemInMart] ld a, [wBoughtOrSoldItemInMart]
and a and a
jr nz,.skipSettingFlag2 jr nz, .skipSettingFlag2
ld a,1 ld a, 1
ld [wBoughtOrSoldItemInMart],a ld [wBoughtOrSoldItemInMart], a
.skipSettingFlag2 .skipSettingFlag2
ld a,SFX_PURCHASE ld a, SFX_PURCHASE
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
call WaitForSoundToFinish call WaitForSoundToFinish
ld hl,PokemartBoughtItemText ld hl, PokemartBoughtItemText
call PrintText call PrintText
jp .buyMenuLoop jp .buyMenuLoop
.returnToMainPokemartMenu .returnToMainPokemartMenu
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
ld hl,PokemartAnythingElseText ld hl, PokemartAnythingElseText
call PrintText call PrintText
jp .loop jp .loop
.isThereEnoughMoney .isThereEnoughMoney
ld de,wPlayerMoney ld de, wPlayerMoney
ld hl,hMoney ld hl, hMoney
ld c,3 ; length of money in bytes ld c, 3 ; length of money in bytes
jp StringCmp jp StringCmp
.notEnoughMoney .notEnoughMoney
ld hl,PokemartNotEnoughMoneyText ld hl, PokemartNotEnoughMoneyText
call PrintText call PrintText
jr .returnToMainPokemartMenu jr .returnToMainPokemartMenu
.bagFull .bagFull
ld hl,PokemartItemBagFullText ld hl, PokemartItemBagFullText
call PrintText call PrintText
jr .returnToMainPokemartMenu jr .returnToMainPokemartMenu
.done .done
ld hl,PokemartThankYouText ld hl, PokemartThankYouText
call PrintText call PrintText
ld a,1 ld a, 1
ld [wUpdateSpritesEnabled],a ld [wUpdateSpritesEnabled], a
call UpdateSprites call UpdateSprites
ld a,[wSavedListScrollOffset] ld a, [wSavedListScrollOffset]
ld [wListScrollOffset],a ld [wListScrollOffset], a
ret ret
PokemartBuyingGreetingText: PokemartBuyingGreetingText:

View file

@ -1,33 +1,33 @@
LoadWildData: LoadWildData:
ld hl,WildDataPointers ld hl, WildDataPointers
ld a,[wCurMap] ld a, [wCurMap]
; get wild data for current map ; get wild data for current map
ld c,a ld c, a
ld b,0 ld b, 0
add hl,bc add hl, bc
add hl,bc add hl, bc
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ; hl now points to wild data for current map ld l, a ; hl now points to wild data for current map
ld a,[hli] ld a, [hli]
ld [wGrassRate],a ld [wGrassRate], a
and a and a
jr z,.NoGrassData ; if no grass data, skip to surfing data jr z, .NoGrassData ; if no grass data, skip to surfing data
push hl push hl
ld de,wGrassMons ; otherwise, load grass data ld de, wGrassMons ; otherwise, load grass data
ld bc,$0014 ld bc, $0014
call CopyData call CopyData
pop hl pop hl
ld bc,$0014 ld bc, $0014
add hl,bc add hl, bc
.NoGrassData .NoGrassData
ld a,[hli] ld a, [hli]
ld [wWaterRate],a ld [wWaterRate], a
and a and a
ret z ; if no water data, we're done ret z ; if no water data, we're done
ld de,wWaterMons ; otherwise, load surfing data ld de, wWaterMons ; otherwise, load surfing data
ld bc,$0014 ld bc, $0014
jp CopyData jp CopyData
INCLUDE "data/wild_mons.asm" INCLUDE "data/wild_mons.asm"

View file

@ -325,11 +325,11 @@ UpdatePartyMenuBlkPacket:
SendSGBPacket: SendSGBPacket:
;check number of packets ;check number of packets
ld a,[hl] ld a, [hl]
and a,$07 and $07
ret z ret z
; store number of packets in B ; store number of packets in B
ld b,a ld b, a
.loop2 .loop2
; save B for later use ; save B for later use
push bc push bc
@ -338,46 +338,46 @@ SendSGBPacket:
ld [hDisableJoypadPolling], a ld [hDisableJoypadPolling], a
; send RESET signal (P14=LOW, P15=LOW) ; send RESET signal (P14=LOW, P15=LOW)
xor a xor a
ld [rJOYP],a ld [rJOYP], a
; set P14=HIGH, P15=HIGH ; set P14=HIGH, P15=HIGH
ld a,$30 ld a, $30
ld [rJOYP],a ld [rJOYP], a
;load length of packets (16 bytes) ;load length of packets (16 bytes)
ld b,$10 ld b, $10
.nextByte .nextByte
;set bit counter (8 bits per byte) ;set bit counter (8 bits per byte)
ld e,$08 ld e, $08
; get next byte in the packet ; get next byte in the packet
ld a,[hli] ld a, [hli]
ld d,a ld d, a
.nextBit0 .nextBit0
bit 0,d bit 0, d
; if 0th bit is not zero set P14=HIGH,P15=LOW (send bit 1) ; if 0th bit is not zero set P14=HIGH,P15=LOW (send bit 1)
ld a,$10 ld a, $10
jr nz,.next0 jr nz, .next0
; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0) ; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0)
ld a,$20 ld a, $20
.next0 .next0
ld [rJOYP],a ld [rJOYP], a
; must set P14=HIGH,P15=HIGH between each "pulse" ; must set P14=HIGH,P15=HIGH between each "pulse"
ld a,$30 ld a, $30
ld [rJOYP],a ld [rJOYP], a
; rotation will put next bit in 0th position (so we can always use command ; rotation will put next bit in 0th position (so we can always use command
; "bit 0,d" to fetch the bit that has to be sent) ; "bit 0,d" to fetch the bit that has to be sent)
rr d rr d
; decrease bit counter so we know when we have sent all 8 bits of current byte ; decrease bit counter so we know when we have sent all 8 bits of current byte
dec e dec e
jr nz,.nextBit0 jr nz, .nextBit0
dec b dec b
jr nz,.nextByte jr nz, .nextByte
; send bit 1 as a "stop bit" (end of parameter data) ; send bit 1 as a "stop bit" (end of parameter data)
ld a,$20 ld a, $20
ld [rJOYP],a ld [rJOYP], a
; set P14=HIGH,P15=HIGH ; set P14=HIGH,P15=HIGH
ld a,$30 ld a, $30
ld [rJOYP],a ld [rJOYP], a
xor a xor a
ld [hDisableJoypadPolling],a ld [hDisableJoypadPolling], a
; wait for about 70000 cycles ; wait for about 70000 cycles
call Wait7000 call Wait7000
; restore (previously pushed) number of packets ; restore (previously pushed) number of packets

View file

@ -42,7 +42,7 @@ DisplayDexRating:
inc de inc de
.copyRatingTextLoop .copyRatingTextLoop
ld a, [hli] ld a, [hli]
cp a, "@" cp "@"
jr z, .doneCopying jr z, .doneCopying
ld [de], a ld [de], a
inc de inc de

View file

@ -4,48 +4,48 @@ GetPredefPointer:
; Then put the bank and address of predef ; Then put the bank and address of predef
; wPredefID in [wPredefBank] and hl. ; wPredefID in [wPredefBank] and hl.
ld a,h ld a, h
ld [wPredefRegisters],a ld [wPredefRegisters], a
ld a,l ld a, l
ld [wPredefRegisters + 1],a ld [wPredefRegisters + 1], a
ld hl,wPredefRegisters + 2 ld hl, wPredefRegisters + 2
ld a,d ld a, d
ld [hli],a ld [hli], a
ld a,e ld a, e
ld [hli],a ld [hli], a
ld a,b ld a, b
ld [hli],a ld [hli], a
ld [hl],c ld [hl], c
ld hl,PredefPointers ld hl, PredefPointers
ld de,0 ld de, 0
ld a,[wPredefID] ld a, [wPredefID]
ld e,a ld e, a
add a add a
add e add e
ld e,a ld e, a
jr nc, .nocarry jr nc, .nocarry
inc d inc d
.nocarry .nocarry
add hl,de add hl, de
ld d,h ld d, h
ld e,l ld e, l
; get bank of predef routine ; get bank of predef routine
ld a,[de] ld a, [de]
ld [wPredefBank],a ld [wPredefBank], a
; get pointer ; get pointer
inc de inc de
ld a,[de] ld a, [de]
ld l,a ld l, a
inc de inc de
ld a,[de] ld a, [de]
ld h,a ld h, a
ret ret

View file

@ -139,16 +139,16 @@ LoadSAVIgnoreBadCheckSum:
SaveSAV: SaveSAV:
callba PrintSaveScreenText callba PrintSaveScreenText
ld hl,WouldYouLikeToSaveText ld hl, WouldYouLikeToSaveText
call SaveSAVConfirm call SaveSAVConfirm
and a ;|0 = Yes|1 = No| and a ;|0 = Yes|1 = No|
ret nz ret nz
ld a,[wSaveFileStatus] ld a, [wSaveFileStatus]
dec a dec a
jr z,.save jr z, .save
call SAVCheckRandomID call SAVCheckRandomID
jr z,.save jr z, .save
ld hl,OlderFileWillBeErasedText ld hl, OlderFileWillBeErasedText
call SaveSAVConfirm call SaveSAVConfirm
and a and a
ret nz ret nz
@ -158,16 +158,16 @@ SaveSAV:
lb bc, 4, 18 lb bc, 4, 18
call ClearScreenArea call ClearScreenArea
coord hl, 1, 14 coord hl, 1, 14
ld de,NowSavingString ld de, NowSavingString
call PlaceString call PlaceString
ld c,120 ld c, 120
call DelayFrames call DelayFrames
ld hl,GameSavedText ld hl, GameSavedText
call PrintText call PrintText
ld a, SFX_SAVE ld a, SFX_SAVE
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
call WaitForSoundToFinish call WaitForSoundToFinish
ld c,30 ld c, 30
jp DelayFrames jp DelayFrames
NowSavingString: NowSavingString:
@ -177,10 +177,10 @@ SaveSAVConfirm:
call PrintText call PrintText
coord hl, 0, 7 coord hl, 0, 7
lb bc, 8, 1 lb bc, 8, 1
ld a,TWO_OPTION_MENU ld a, TWO_OPTION_MENU
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu call DisplayTextBoxID ; yes/no menu
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
ret ret
WouldYouLikeToSaveText: WouldYouLikeToSaveText:
@ -604,34 +604,34 @@ SAVCheckRandomID:
;checks if Sav file is the same by checking player's name 1st letter ($a598) ;checks if Sav file is the same by checking player's name 1st letter ($a598)
; and the two random numbers generated at game beginning ; and the two random numbers generated at game beginning
;(which are stored at wPlayerID)s ;(which are stored at wPlayerID)s
ld a,$0a ld a, $0a
ld [MBC1SRamEnable],a ld [MBC1SRamEnable], a
ld a,$01 ld a, $01
ld [MBC1SRamBankingMode],a ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank],a ld [MBC1SRamBank], a
ld a,[sPlayerName] ld a, [sPlayerName]
and a and a
jr z,.next jr z, .next
ld hl,sPlayerName ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName ld bc, sMainDataCheckSum - sPlayerName
call SAVCheckSum call SAVCheckSum
ld c,a ld c, a
ld a,[sMainDataCheckSum] ld a, [sMainDataCheckSum]
cp c cp c
jr nz,.next jr nz, .next
ld hl,sMainData + (wPlayerID - wMainDataStart) ; player ID ld hl, sMainData + (wPlayerID - wMainDataStart) ; player ID
ld a,[hli] ld a, [hli]
ld h,[hl] ld h, [hl]
ld l,a ld l, a
ld a,[wPlayerID] ld a, [wPlayerID]
cp l cp l
jr nz,.next jr nz, .next
ld a,[wPlayerID + 1] ld a, [wPlayerID + 1]
cp h cp h
.next .next
ld a,$00 ld a, $00
ld [MBC1SRamBankingMode],a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable],a ld [MBC1SRamEnable], a
ret ret
SaveHallOfFameTeams: SaveHallOfFameTeams:

View file

@ -1,31 +1,31 @@
SpecialWarpIn: SpecialWarpIn:
call LoadSpecialWarpData call LoadSpecialWarpData
predef LoadTilesetHeader predef LoadTilesetHeader
ld hl,wd732 ld hl, wd732
bit 2,[hl] ; dungeon warp or fly warp? bit 2, [hl] ; dungeon warp or fly warp?
res 2,[hl] res 2, [hl]
jr z,.next jr z, .next
; if dungeon warp or fly warp ; if dungeon warp or fly warp
ld a,[wDestinationMap] ld a, [wDestinationMap]
jr .next2 jr .next2
.next .next
bit 1,[hl] bit 1, [hl]
jr z,.next3 jr z, .next3
call EmptyFunc call EmptyFunc
.next3 .next3
ld a,0 ld a, 0
.next2 .next2
ld b,a ld b, a
ld a,[wd72d] ld a, [wd72d]
and a and a
jr nz,.next4 jr nz, .next4
ld a,b ld a, b
.next4 .next4
ld hl,wd732 ld hl, wd732
bit 4,[hl] ; dungeon warp? bit 4, [hl] ; dungeon warp?
ret nz ret nz
; if not dungeon warp ; if not dungeon warp
ld [wLastMap],a ld [wLastMap], a
ret ret
; gets the map ID, tile block map view pointer, tileset, and coordinates ; gets the map ID, tile block map view pointer, tileset, and coordinates

View file

@ -1,17 +1,17 @@
; subtracts the amount the player paid from their money ; subtracts the amount the player paid from their money
; sets carry flag if there is enough money and unsets carry flag if not ; sets carry flag if there is enough money and unsets carry flag if not
SubtractAmountPaidFromMoney_: SubtractAmountPaidFromMoney_:
ld de,wPlayerMoney ld de, wPlayerMoney
ld hl,hMoney ; total price of items ld hl, hMoney ; total price of items
ld c,3 ; length of money in bytes ld c, 3 ; length of money in bytes
call StringCmp call StringCmp
ret c ret c
ld de,wPlayerMoney + 2 ld de, wPlayerMoney + 2
ld hl,hMoney + 2 ; total price of items ld hl, hMoney + 2 ; total price of items
ld c,3 ; length of money in bytes ld c, 3 ; length of money in bytes
predef SubBCDPredef ; subtract total price from money predef SubBCDPredef ; subtract total price from money
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID ; redraw money text box call DisplayTextBoxID ; redraw money text box
and a and a
ret ret

View file

@ -56,7 +56,7 @@ DisplayTitleScreen:
ld a, BANK(PokemonLogoGraphics) ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk call FarCopyData2 ; second chunk
ld hl, Version_GFX ld hl, Version_GFX
ld de,vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50) ld de, vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
ld bc, Version_GFXEnd - Version_GFX ld bc, Version_GFXEnd - Version_GFX
ld a, BANK(Version_GFX) ld a, BANK(Version_GFX)
call FarCopyDataDouble call FarCopyDataDouble
@ -118,10 +118,10 @@ DisplayTitleScreen:
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
call EnableLCD call EnableLCD
IF DEF(_RED) IF DEF(_RED)
ld a,CHARMANDER ; which Pokemon to show first on the title screen ld a, CHARMANDER ; which Pokemon to show first on the title screen
ENDC ENDC
IF DEF(_BLUE) IF DEF(_BLUE)
ld a,SQUIRTLE ; which Pokemon to show first on the title screen ld a, SQUIRTLE ; which Pokemon to show first on the title screen
ENDC ENDC
ld [wTitleMonSpecies], a ld [wTitleMonSpecies], a

View file

@ -1,44 +1,44 @@
Trade_PrintPlayerMonInfoText: Trade_PrintPlayerMonInfoText:
coord hl, 5, 0 coord hl, 5, 0
ld de,Trade_MonInfoText ld de, Trade_MonInfoText
call PlaceString call PlaceString
ld a,[wTradedPlayerMonSpecies] ld a, [wTradedPlayerMonSpecies]
ld [wd11e],a ld [wd11e], a
predef IndexToPokedex predef IndexToPokedex
coord hl, 9, 0 coord hl, 9, 0
ld de,wd11e ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3 lb bc, LEADING_ZEROES | 1, 3
call PrintNumber call PrintNumber
coord hl, 5, 2 coord hl, 5, 2
ld de,wcf4b ld de, wcf4b
call PlaceString call PlaceString
coord hl, 8, 4 coord hl, 8, 4
ld de,wTradedPlayerMonOT ld de, wTradedPlayerMonOT
call PlaceString call PlaceString
coord hl, 8, 6 coord hl, 8, 6
ld de,wTradedPlayerMonOTID ld de, wTradedPlayerMonOTID
lb bc, LEADING_ZEROES | 2, 5 lb bc, LEADING_ZEROES | 2, 5
jp PrintNumber jp PrintNumber
Trade_PrintEnemyMonInfoText: Trade_PrintEnemyMonInfoText:
coord hl, 5, 10 coord hl, 5, 10
ld de,Trade_MonInfoText ld de, Trade_MonInfoText
call PlaceString call PlaceString
ld a,[wTradedEnemyMonSpecies] ld a, [wTradedEnemyMonSpecies]
ld [wd11e],a ld [wd11e], a
predef IndexToPokedex predef IndexToPokedex
coord hl, 9, 10 coord hl, 9, 10
ld de,wd11e ld de, wd11e
lb bc, LEADING_ZEROES | 1, 3 lb bc, LEADING_ZEROES | 1, 3
call PrintNumber call PrintNumber
coord hl, 5, 12 coord hl, 5, 12
ld de,wcd6d ld de, wcd6d
call PlaceString call PlaceString
coord hl, 8, 14 coord hl, 8, 14
ld de,wTradedEnemyMonOT ld de, wTradedEnemyMonOT
call PlaceString call PlaceString
coord hl, 8, 16 coord hl, 8, 16
ld de,wTradedEnemyMonOTID ld de, wTradedEnemyMonOTID
lb bc, LEADING_ZEROES | 2, 5 lb bc, LEADING_ZEROES | 2, 5
jp PrintNumber jp PrintNumber

1928
home.asm

File diff suppressed because it is too large Load diff

View file

@ -1,62 +1,62 @@
FarCopyData2:: FarCopyData2::
; Identical to FarCopyData, but uses hROMBankTemp ; Identical to FarCopyData, but uses hROMBankTemp
; as temp space instead of wBuffer. ; as temp space instead of wBuffer.
ld [hROMBankTemp],a ld [hROMBankTemp], a
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a,[hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
call CopyData call CopyData
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ret ret
FarCopyData3:: FarCopyData3::
; Copy bc bytes from a:de to hl. ; Copy bc bytes from a:de to hl.
ld [hROMBankTemp],a ld [hROMBankTemp], a
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a,[hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
push hl push hl
push de push de
push de push de
ld d,h ld d, h
ld e,l ld e, l
pop hl pop hl
call CopyData call CopyData
pop de pop de
pop hl pop hl
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ret ret
FarCopyDataDouble:: FarCopyDataDouble::
; Expand bc bytes of 1bpp image data ; Expand bc bytes of 1bpp image data
; from a:hl to 2bpp data at de. ; from a:hl to 2bpp data at de.
ld [hROMBankTemp],a ld [hROMBankTemp], a
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a,[hROMBankTemp] ld a, [hROMBankTemp]
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
.loop .loop
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
ld [de],a ld [de], a
inc de inc de
dec bc dec bc
ld a,c ld a, c
or b or b
jr nz,.loop jr nz, .loop
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
ret ret
CopyVideoData:: CopyVideoData::

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ TextBoxBorder::
.next .next
push hl push hl
ld a, "│" ld a, "│"
ld [hli],a ld [hli], a
ld a, " " ld a, " "
call NPlaceChar call NPlaceChar
ld [hl], "│" ld [hl], "│"
@ -49,12 +49,12 @@ NPlaceChar::
PlaceString:: PlaceString::
push hl push hl
PlaceNextChar:: PlaceNextChar::
ld a,[de] ld a, [de]
cp "@" cp "@"
jr nz, Char4ETest jr nz, Char4ETest
ld b,h ld b, h
ld c,l ld c, l
pop hl pop hl
ret ret
@ -62,19 +62,19 @@ Char4ETest::
cp $4E ; next cp $4E ; next
jr nz, .char4FTest jr nz, .char4FTest
ld bc, 2 * SCREEN_WIDTH ld bc, 2 * SCREEN_WIDTH
ld a,[hFlags_0xFFF6] ld a, [hFlags_0xFFF6]
bit 2,a bit 2, a
jr z,.ok jr z, .ok
ld bc,SCREEN_WIDTH ld bc, SCREEN_WIDTH
.ok .ok
pop hl pop hl
add hl,bc add hl, bc
push hl push hl
jp PlaceNextChar_inc jp PlaceNextChar_inc
.char4FTest .char4FTest
cp $4F ; line cp $4F ; line
jr nz,.next3 jr nz, .next3
pop hl pop hl
coord hl, 1, 16 coord hl, 1, 16
push hl push hl
@ -111,17 +111,17 @@ endm
dict $59, Char59 ; TARGET dict $59, Char59 ; TARGET
dict $5A, Char5A ; USER dict $5A, Char5A ; USER
ld [hli],a ld [hli], a
call PrintLetterDelay call PrintLetterDelay
PlaceNextChar_inc:: PlaceNextChar_inc::
inc de inc de
jp PlaceNextChar jp PlaceNextChar
Char00:: Char00::
ld b,h ld b, h
ld c,l ld c, l
pop hl pop hl
ld de,Char00Text ld de, Char00Text
dec de dec de
ret ret
@ -131,47 +131,47 @@ Char00Text:: ; “%d ERROR.”
Char52:: ; players name Char52:: ; players name
push de push de
ld de,wPlayerName ld de, wPlayerName
jr FinishDTE jr FinishDTE
Char53:: ; rivals name Char53:: ; rivals name
push de push de
ld de,wRivalName ld de, wRivalName
jr FinishDTE jr FinishDTE
Char5D:: ; TRAINER Char5D:: ; TRAINER
push de push de
ld de,Char5DText ld de, Char5DText
jr FinishDTE jr FinishDTE
Char5C:: ; TM Char5C:: ; TM
push de push de
ld de,Char5CText ld de, Char5CText
jr FinishDTE jr FinishDTE
Char5B:: ; PC Char5B:: ; PC
push de push de
ld de,Char5BText ld de, Char5BText
jr FinishDTE jr FinishDTE
Char5E:: ; ROCKET Char5E:: ; ROCKET
push de push de
ld de,Char5EText ld de, Char5EText
jr FinishDTE jr FinishDTE
Char54:: ; POKé Char54:: ; POKé
push de push de
ld de,Char54Text ld de, Char54Text
jr FinishDTE jr FinishDTE
Char56:: ; …… Char56:: ; ……
push de push de
ld de,Char56Text ld de, Char56Text
jr FinishDTE jr FinishDTE
Char4A:: ; PKMN Char4A:: ; PKMN
push de push de
ld de,Char4AText ld de, Char4AText
jr FinishDTE jr FinishDTE
Char59:: Char59::
@ -180,7 +180,7 @@ Char59::
; or ; or
; player active monsters name ; player active monsters name
; (like Char5A but flipped) ; (like Char5A but flipped)
ld a,[H_WHOSETURN] ld a, [H_WHOSETURN]
xor 1 xor 1
jr MonsterNameCharsCommon jr MonsterNameCharsCommon
@ -189,26 +189,26 @@ Char5A::
; player active monsters name ; player active monsters name
; or ; or
; enemy active monsters name, prefixed with “Enemy ” ; enemy active monsters name, prefixed with “Enemy ”
ld a,[H_WHOSETURN] ld a, [H_WHOSETURN]
MonsterNameCharsCommon:: MonsterNameCharsCommon::
push de push de
and a and a
jr nz,.Enemy jr nz, .Enemy
ld de,wBattleMonNick ; player active monster name ld de, wBattleMonNick ; player active monster name
jr FinishDTE jr FinishDTE
.Enemy .Enemy
; print “Enemy ” ; print “Enemy ”
ld de,Char5AText ld de, Char5AText
call PlaceString call PlaceString
ld h,b ld h, b
ld l,c ld l, c
ld de,wEnemyMonNick ; enemy active monster name ld de, wEnemyMonNick ; enemy active monster name
FinishDTE:: FinishDTE::
call PlaceString call PlaceString
ld h,b ld h, b
ld l,c ld l, c
pop de pop de
inc de inc de
jp PlaceNextChar jp PlaceNextChar
@ -232,12 +232,12 @@ Char4AText::
Char55:: Char55::
push de push de
ld b,h ld b, h
ld c,l ld c, l
ld hl,Char55Text ld hl, Char55Text
call TextCommandProcessor call TextCommandProcessor
ld h,b ld h, b
ld l,c ld l, c
pop de pop de
inc de inc de
jp PlaceNextChar jp PlaceNextChar
@ -249,12 +249,12 @@ Char55Text::
Char5F:: Char5F::
; ends a Pokédex entry ; ends a Pokédex entry
ld [hl],"." ld [hl], "."
pop hl pop hl
ret ret
Char58:: ; prompt Char58:: ; prompt
ld a,[wLinkState] ld a, [wLinkState]
cp LINK_STATE_BATTLING cp LINK_STATE_BATTLING
jp z, .ok jp z, .ok
ld a, "▼" ld a, "▼"
@ -290,14 +290,14 @@ Char51:: ; para
Char49:: Char49::
push de push de
ld a,"▼" ld a, "▼"
Coorda 18, 16 Coorda 18, 16
call ProtectedDelay3 call ProtectedDelay3
call ManualTextScroll call ManualTextScroll
coord hl, 1, 10 coord hl, 1, 10
lb bc, 7, 18 lb bc, 7, 18
call ClearScreenArea call ClearScreenArea
ld c,20 ld c, 20
call DelayFrames call DelayFrames
pop de pop de
pop hl pop hl
@ -306,7 +306,7 @@ Char49::
jp PlaceNextChar_inc jp PlaceNextChar_inc
Char4B:: Char4B::
ld a,"▼" ld a, "▼"
Coorda 18, 16 Coorda 18, 16
call ProtectedDelay3 call ProtectedDelay3
push de push de
@ -332,25 +332,25 @@ ScrollTextUpOneLine::
coord de, 0, 13 ; empty line above text coord de, 0, 13 ; empty line above text
ld b, SCREEN_WIDTH * 3 ld b, SCREEN_WIDTH * 3
.copyText .copyText
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
dec b dec b
jr nz,.copyText jr nz, .copyText
coord hl, 1, 16 coord hl, 1, 16
ld a, " " ld a, " "
ld b,SCREEN_WIDTH - 2 ld b, SCREEN_WIDTH - 2
.clearText .clearText
ld [hli],a ld [hli], a
dec b dec b
jr nz,.clearText jr nz, .clearText
; wait five frames ; wait five frames
ld b,5 ld b, 5
.WaitFrame .WaitFrame
call DelayFrame call DelayFrame
dec b dec b
jr nz,.WaitFrame jr nz, .WaitFrame
ret ret
@ -361,33 +361,33 @@ ProtectedDelay3::
ret ret
TextCommandProcessor:: TextCommandProcessor::
ld a,[wLetterPrintingDelayFlags] ld a, [wLetterPrintingDelayFlags]
push af push af
set 1,a set 1, a
ld e,a ld e, a
ld a, [$fff4] ld a, [$fff4]
xor e xor e
ld [wLetterPrintingDelayFlags],a ld [wLetterPrintingDelayFlags], a
ld a,c ld a, c
ld [wTextDest],a ld [wTextDest], a
ld a,b ld a, b
ld [wTextDest + 1],a ld [wTextDest + 1], a
NextTextCommand:: NextTextCommand::
ld a,[hli] ld a, [hli]
cp a, "@" ; terminator cp "@" ; terminator
jr nz,.doTextCommand jr nz, .doTextCommand
pop af pop af
ld [wLetterPrintingDelayFlags],a ld [wLetterPrintingDelayFlags], a
ret ret
.doTextCommand .doTextCommand
push hl push hl
cp a, $17 cp $17
jp z, TextCommand17 jp z, TextCommand17
cp a, $0e cp $0e
jp nc,TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB jp nc, TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB
; if a < 0xE, use a jump table ; if a < 0xE, use a jump table
ld hl,TextCommandJumpTable ld hl, TextCommandJumpTable
push bc push bc
add a add a
ld b, 0 ld b, 0
@ -406,17 +406,17 @@ NextTextCommand::
; CC = width ; CC = width
TextCommand04:: TextCommand04::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
ld a,[hli] ld a, [hli]
ld b,a ld b, a
ld a,[hli] ld a, [hli]
ld c,a ld c, a
push hl push hl
ld h,d ld h, d
ld l,e ld l, e
call TextBoxBorder call TextBoxBorder
pop hl pop hl
jr NextTextCommand jr NextTextCommand
@ -425,13 +425,13 @@ TextCommand04::
; 00{string} ; 00{string}
TextCommand00:: TextCommand00::
pop hl pop hl
ld d,h ld d, h
ld e,l ld e, l
ld h,b ld h, b
ld l,c ld l, c
call PlaceString call PlaceString
ld h,d ld h, d
ld l,e ld l, e
inc hl inc hl
jr NextTextCommand jr NextTextCommand
@ -440,13 +440,13 @@ TextCommand00::
; AAAA = address of string ; AAAA = address of string
TextCommand01:: TextCommand01::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
push hl push hl
ld h,b ld h, b
ld l,c ld l, c
call PlaceString call PlaceString
pop hl pop hl
jr NextTextCommand jr NextTextCommand
@ -459,18 +459,18 @@ TextCommand01::
; bits 5-7 = unknown flags ; bits 5-7 = unknown flags
TextCommand02:: TextCommand02::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
ld a,[hli] ld a, [hli]
push hl push hl
ld h,b ld h, b
ld l,c ld l, c
ld c,a ld c, a
call PrintBCDNumber call PrintBCDNumber
ld b,h ld b, h
ld c,l ld c, l
pop hl pop hl
jr NextTextCommand jr NextTextCommand
@ -479,12 +479,12 @@ TextCommand02::
; AAAA = new destination address ; AAAA = new destination address
TextCommand03:: TextCommand03::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld [wTextDest],a ld [wTextDest], a
ld c,a ld c, a
ld a,[hli] ld a, [hli]
ld [wTextDest + 1],a ld [wTextDest + 1], a
ld b,a ld b, a
jp NextTextCommand jp NextTextCommand
; repoint destination to second line of dialogue text box ; repoint destination to second line of dialogue text box
@ -499,15 +499,15 @@ TextCommand05::
; 06 ; 06
; (no arguments) ; (no arguments)
TextCommand06:: TextCommand06::
ld a,[wLinkState] ld a, [wLinkState]
cp a,LINK_STATE_BATTLING cp LINK_STATE_BATTLING
jp z,TextCommand0D jp z, TextCommand0D
ld a,"▼" ld a, "▼"
Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box
push bc push bc
call ManualTextScroll ; blink arrow and wait for A or B to be pressed call ManualTextScroll ; blink arrow and wait for A or B to be pressed
pop bc pop bc
ld a," " ld a, " "
Coorda 18, 16 ; overwrite down arrow with blank space Coorda 18, 16 ; overwrite down arrow with blank space
pop hl pop hl
jp NextTextCommand jp NextTextCommand
@ -528,7 +528,7 @@ TextCommand07::
; 08{code} ; 08{code}
TextCommand08:: TextCommand08::
pop hl pop hl
ld de,NextTextCommand ld de, NextTextCommand
push de ; return address push de ; return address
jp hl jp hl
@ -540,25 +540,25 @@ TextCommand08::
; bits 4-7 = how long the number is in bytes ; bits 4-7 = how long the number is in bytes
TextCommand09:: TextCommand09::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
ld a,[hli] ld a, [hli]
push hl push hl
ld h,b ld h, b
ld l,c ld l, c
ld b,a ld b, a
and a,$0f and $0f
ld c,a ld c, a
ld a,b ld a, b
and a,$f0 and $f0
swap a swap a
set BIT_LEFT_ALIGN,a set BIT_LEFT_ALIGN,a
ld b,a ld b, a
call PrintNumber call PrintNumber
ld b,h ld b, h
ld c,l ld c, l
pop hl pop hl
jp NextTextCommand jp NextTextCommand
@ -568,10 +568,10 @@ TextCommand09::
TextCommand0A:: TextCommand0A::
push bc push bc
call Joypad call Joypad
ld a,[hJoyHeld] ld a, [hJoyHeld]
and a,A_BUTTON | B_BUTTON and A_BUTTON | B_BUTTON
jr nz,.skipDelay jr nz, .skipDelay
ld c,30 ld c, 30
call DelayFrames call DelayFrames
.skipDelay .skipDelay
pop bc pop bc
@ -585,24 +585,24 @@ TextCommand0B::
pop hl pop hl
push bc push bc
dec hl dec hl
ld a,[hli] ld a, [hli]
ld b,a ; b = command number that got us here ld b, a ; b = command number that got us here
push hl push hl
ld hl,TextCommandSounds ld hl, TextCommandSounds
.loop .loop
ld a,[hli] ld a, [hli]
cp b cp b
jr z,.matchFound jr z, .matchFound
inc hl inc hl
jr .loop jr .loop
.matchFound .matchFound
cp a,$14 cp $14
jr z,.pokemonCry jr z, .pokemonCry
cp a,$15 cp $15
jr z,.pokemonCry jr z, .pokemonCry
cp a,$16 cp $16
jr z,.pokemonCry jr z, .pokemonCry
ld a,[hl] ld a, [hl]
call PlaySound call PlaySound
call WaitForSoundToFinish call WaitForSoundToFinish
pop hl pop hl
@ -610,7 +610,7 @@ TextCommand0B::
jp NextTextCommand jp NextTextCommand
.pokemonCry .pokemonCry
push de push de
ld a,[hl] ld a, [hl]
call PlayCry call PlayCry
pop de pop de
pop hl pop hl
@ -635,27 +635,27 @@ TextCommandSounds::
; AA = number of ellipses to draw ; AA = number of ellipses to draw
TextCommand0C:: TextCommand0C::
pop hl pop hl
ld a,[hli] ld a, [hli]
ld d,a ld d, a
push hl push hl
ld h,b ld h, b
ld l,c ld l, c
.loop .loop
ld a,"…" ld a, "…"
ld [hli],a ld [hli], a
push de push de
call Joypad call Joypad
pop de pop de
ld a,[hJoyHeld] ; joypad state ld a, [hJoyHeld] ; joypad state
and a,A_BUTTON | B_BUTTON and A_BUTTON | B_BUTTON
jr nz,.skipDelay ; if so, skip the delay jr nz, .skipDelay ; if so, skip the delay
ld c,10 ld c, 10
call DelayFrames call DelayFrames
.skipDelay .skipDelay
dec d dec d
jr nz,.loop jr nz, .loop
ld b,h ld b, h
ld c,l ld c, l
pop hl pop hl
jp NextTextCommand jp NextTextCommand
@ -675,23 +675,23 @@ TextCommand0D::
; BB = bank ; BB = bank
TextCommand17:: TextCommand17::
pop hl pop hl
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
push af push af
ld a,[hli] ld a, [hli]
ld e,a ld e, a
ld a,[hli] ld a, [hli]
ld d,a ld d, a
ld a,[hli] ld a, [hli]
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
push hl push hl
ld l,e ld l, e
ld h,d ld h, d
call TextCommandProcessor call TextCommandProcessor
pop hl pop hl
pop af pop af
ld [H_LOADEDROMBANK],a ld [H_LOADEDROMBANK], a
ld [MBC1RomBank],a ld [MBC1RomBank], a
jp NextTextCommand jp NextTextCommand
TextCommandJumpTable:: TextCommandJumpTable::

View file

@ -10,27 +10,27 @@ GetRowColAddressBgMap::
srl h srl h
rr a rr a
or l or l
ld l,a ld l, a
ld a,b ld a, b
or h or h
ld h,a ld h, a
ret ret
; clears a VRAM background map with blank space tiles ; clears a VRAM background map with blank space tiles
; INPUT: h - high byte of background tile map address in VRAM ; INPUT: h - high byte of background tile map address in VRAM
ClearBgMap:: ClearBgMap::
ld a," " ld a, " "
jr .next jr .next
ld a,l ld a, l
.next .next
ld de,$400 ; size of VRAM background map ld de, $400 ; size of VRAM background map
ld l,e ld l, e
.loop .loop
ld [hli],a ld [hli], a
dec e dec e
jr nz,.loop jr nz, .loop
dec d dec d
jr nz,.loop jr nz, .loop
ret ret
; This function redraws a BG row of height 2 or a BG column of width 2. ; This function redraws a BG row of height 2 or a BG column of width 2.
@ -40,76 +40,76 @@ ClearBgMap::
; However, this function is also called repeatedly to redraw the whole screen ; However, this function is also called repeatedly to redraw the whole screen
; when necessary. It is also used in trade animation and elevator code. ; when necessary. It is also used in trade animation and elevator code.
RedrawRowOrColumn:: RedrawRowOrColumn::
ld a,[hRedrawRowOrColumnMode] ld a, [hRedrawRowOrColumnMode]
and a and a
ret z ret z
ld b,a ld b, a
xor a xor a
ld [hRedrawRowOrColumnMode],a ld [hRedrawRowOrColumnMode], a
dec b dec b
jr nz,.redrawRow jr nz, .redrawRow
.redrawColumn .redrawColumn
ld hl,wRedrawRowOrColumnSrcTiles ld hl, wRedrawRowOrColumnSrcTiles
ld a,[hRedrawRowOrColumnDest] ld a, [hRedrawRowOrColumnDest]
ld e,a ld e, a
ld a,[hRedrawRowOrColumnDest + 1] ld a, [hRedrawRowOrColumnDest + 1]
ld d,a ld d, a
ld c,SCREEN_HEIGHT ld c, SCREEN_HEIGHT
.loop1 .loop1
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
ld a,BG_MAP_WIDTH - 1 ld a, BG_MAP_WIDTH - 1
add e add e
ld e,a ld e, a
jr nc,.noCarry jr nc, .noCarry
inc d inc d
.noCarry .noCarry
; the following 4 lines wrap us from bottom to top if necessary ; the following 4 lines wrap us from bottom to top if necessary
ld a,d ld a, d
and a,$03 and $03
or a,$98 or $98
ld d,a ld d, a
dec c dec c
jr nz,.loop1 jr nz, .loop1
xor a xor a
ld [hRedrawRowOrColumnMode],a ld [hRedrawRowOrColumnMode], a
ret ret
.redrawRow .redrawRow
ld hl,wRedrawRowOrColumnSrcTiles ld hl, wRedrawRowOrColumnSrcTiles
ld a,[hRedrawRowOrColumnDest] ld a, [hRedrawRowOrColumnDest]
ld e,a ld e, a
ld a,[hRedrawRowOrColumnDest + 1] ld a, [hRedrawRowOrColumnDest + 1]
ld d,a ld d, a
push de push de
call .DrawHalf ; draw upper half call .DrawHalf ; draw upper half
pop de pop de
ld a,BG_MAP_WIDTH ; width of VRAM background map ld a, BG_MAP_WIDTH ; width of VRAM background map
add e add e
ld e,a ld e, a
; fall through and draw lower half ; fall through and draw lower half
.DrawHalf .DrawHalf
ld c,SCREEN_WIDTH / 2 ld c, SCREEN_WIDTH / 2
.loop2 .loop2
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
inc de inc de
ld a,[hli] ld a, [hli]
ld [de],a ld [de], a
ld a,e ld a, e
inc a inc a
; the following 6 lines wrap us from the right edge to the left edge if necessary ; the following 6 lines wrap us from the right edge to the left edge if necessary
and a,$1f and $1f
ld b,a ld b, a
ld a,e ld a, e
and a,$e0 and $e0
or b or b
ld e,a ld e, a
dec c dec c
jr nz,.loop2 jr nz, .loop2
ret ret
; This function automatically transfers tile number data from the tile map at ; This function automatically transfers tile number data from the tile map at
@ -120,52 +120,52 @@ RedrawRowOrColumn::
; the above function, RedrawRowOrColumn, is used when walking to ; the above function, RedrawRowOrColumn, is used when walking to
; improve efficiency. ; improve efficiency.
AutoBgMapTransfer:: AutoBgMapTransfer::
ld a,[H_AUTOBGTRANSFERENABLED] ld a, [H_AUTOBGTRANSFERENABLED]
and a and a
ret z ret z
ld hl,sp + 0 ld hl, sp + 0
ld a,h ld a, h
ld [H_SPTEMP],a ld [H_SPTEMP], a
ld a,l ld a, l
ld [H_SPTEMP + 1],a ; save stack pinter ld [H_SPTEMP + 1], a ; save stack pinter
ld a,[H_AUTOBGTRANSFERPORTION] ld a, [H_AUTOBGTRANSFERPORTION]
and a and a
jr z,.transferTopThird jr z, .transferTopThird
dec a dec a
jr z,.transferMiddleThird jr z, .transferMiddleThird
.transferBottomThird .transferBottomThird
coord hl, 0, 12 coord hl, 0, 12
ld sp,hl ld sp, hl
ld a,[H_AUTOBGTRANSFERDEST + 1] ld a, [H_AUTOBGTRANSFERDEST + 1]
ld h,a ld h, a
ld a,[H_AUTOBGTRANSFERDEST] ld a, [H_AUTOBGTRANSFERDEST]
ld l,a ld l, a
ld de,(12 * 32) ld de, (12 * 32)
add hl,de add hl, de
xor a ; TRANSFERTOP xor a ; TRANSFERTOP
jr .doTransfer jr .doTransfer
.transferTopThird .transferTopThird
coord hl, 0, 0 coord hl, 0, 0
ld sp,hl ld sp, hl
ld a,[H_AUTOBGTRANSFERDEST + 1] ld a, [H_AUTOBGTRANSFERDEST + 1]
ld h,a ld h, a
ld a,[H_AUTOBGTRANSFERDEST] ld a, [H_AUTOBGTRANSFERDEST]
ld l,a ld l, a
ld a,TRANSFERMIDDLE ld a, TRANSFERMIDDLE
jr .doTransfer jr .doTransfer
.transferMiddleThird .transferMiddleThird
coord hl, 0, 6 coord hl, 0, 6
ld sp,hl ld sp, hl
ld a,[H_AUTOBGTRANSFERDEST + 1] ld a, [H_AUTOBGTRANSFERDEST + 1]
ld h,a ld h, a
ld a,[H_AUTOBGTRANSFERDEST] ld a, [H_AUTOBGTRANSFERDEST]
ld l,a ld l, a
ld de,(6 * 32) ld de, (6 * 32)
add hl,de add hl, de
ld a,TRANSFERBOTTOM ld a, TRANSFERBOTTOM
.doTransfer .doTransfer
ld [H_AUTOBGTRANSFERPORTION],a ; store next portion ld [H_AUTOBGTRANSFERPORTION], a ; store next portion
ld b,6 ld b, 6
TransferBgRows:: TransferBgRows::
; unrolled loop and using pop for speed ; unrolled loop and using pop for speed
@ -202,27 +202,27 @@ TransferBgRows::
; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST. ; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST.
; If H_VBCOPYBGSRC is XX00, the transfer is disabled. ; If H_VBCOPYBGSRC is XX00, the transfer is disabled.
VBlankCopyBgMap:: VBlankCopyBgMap::
ld a,[H_VBCOPYBGSRC] ; doubles as enabling byte ld a, [H_VBCOPYBGSRC] ; doubles as enabling byte
and a and a
ret z ret z
ld hl,sp + 0 ld hl, sp + 0
ld a,h ld a, h
ld [H_SPTEMP],a ld [H_SPTEMP], a
ld a,l ld a, l
ld [H_SPTEMP + 1],a ; save stack pointer ld [H_SPTEMP + 1], a ; save stack pointer
ld a,[H_VBCOPYBGSRC] ld a, [H_VBCOPYBGSRC]
ld l,a ld l, a
ld a,[H_VBCOPYBGSRC + 1] ld a, [H_VBCOPYBGSRC + 1]
ld h,a ld h, a
ld sp,hl ld sp, hl
ld a,[H_VBCOPYBGDEST] ld a, [H_VBCOPYBGDEST]
ld l,a ld l, a
ld a,[H_VBCOPYBGDEST + 1] ld a, [H_VBCOPYBGDEST + 1]
ld h,a ld h, a
ld a,[H_VBCOPYBGNUMROWS] ld a, [H_VBCOPYBGNUMROWS]
ld b,a ld b, a
xor a xor a
ld [H_VBCOPYBGSRC],a ; disable transfer so it doesn't continue next V-blank ld [H_VBCOPYBGSRC], a ; disable transfer so it doesn't continue next V-blank
jr TransferBgRows jr TransferBgRows

View file

@ -144,7 +144,7 @@ CeladonGameCornerText2:
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jr nz, .asm_48d0f jr nz, .asm_48d0f
ld b,COIN_CASE ld b, COIN_CASE
call IsItemInBag call IsItemInBag
jr z, .asm_48d19 jr z, .asm_48d19
call Has9990Coins call Has9990Coins
@ -362,7 +362,7 @@ CeladonGameCornerText10:
jr nz, .asm_48e75 jr nz, .asm_48e75
ld hl, CeladonGameCornerText_48e88 ld hl, CeladonGameCornerText_48e88
call PrintText call PrintText
ld b,COIN_CASE ld b, COIN_CASE
call IsItemInBag call IsItemInBag
jr z, .asm_48e7f jr z, .asm_48e7f
call Has9990Coins call Has9990Coins

View file

@ -113,10 +113,10 @@ CeruleanCityMovement1:
db $FF db $FF
CeruleanCityScript_1955d: CeruleanCityScript_1955d:
ld a,1 ld a, 1
ld [H_SPRITEINDEX],a ld [H_SPRITEINDEX], a
xor a ; SPRITE_FACING_DOWN xor a ; SPRITE_FACING_DOWN
ld [hSpriteFacingDirection],a ld [hSpriteFacingDirection], a
jp SetSpriteFacingDirectionAndDelay ; face object jp SetSpriteFacingDirectionAndDelay ; face object
CeruleanCityScript1: CeruleanCityScript1:

View file

@ -302,7 +302,7 @@ FightingDojoText7:
jr nz, .done jr nz, .done
ld a, [wcf91] ld a, [wcf91]
ld b, a ld b, a
ld c,30 ld c, 30
call GivePokemon call GivePokemon
jr nc, .done jr nc, .done
SetEvents EVENT_GOT_HITMONCHAN, EVENT_DEFEATED_FIGHTING_DOJO SetEvents EVENT_GOT_HITMONCHAN, EVENT_DEFEATED_FIGHTING_DOJO

View file

@ -12,7 +12,7 @@ FuchsiaHouse2Text1:
TX_ASM TX_ASM
CheckEvent EVENT_GOT_HM04 CheckEvent EVENT_GOT_HM04
jr nz, .subtract jr nz, .subtract
ld b,GOLD_TEETH ld b, GOLD_TEETH
call IsItemInBag call IsItemInBag
jr nz, .asm_3f30f jr nz, .asm_3f30f
CheckEvent EVENT_GAVE_GOLD_TEETH CheckEvent EVENT_GAVE_GOLD_TEETH

View file

@ -981,7 +981,7 @@ OaksLabText5:
predef DisplayDexRating predef DisplayDexRating
jp .asm_1d2ed jp .asm_1d2ed
.asm_1d279 .asm_1d279
ld b,POKE_BALL ld b, POKE_BALL
call IsItemInBag call IsItemInBag
jr nz, .asm_1d2e7 jr nz, .asm_1d2e7
CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE CheckEvent EVENT_BEAT_ROUTE22_RIVAL_1ST_BATTLE

View file

@ -1,11 +1,11 @@
PalletTownScript: PalletTownScript:
CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
jr z,.next jr z, .next
SetEvent EVENT_PALLET_AFTER_GETTING_POKEBALLS SetEvent EVENT_PALLET_AFTER_GETTING_POKEBALLS
.next .next
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
ld hl,PalletTownScriptPointers ld hl, PalletTownScriptPointers
ld a,[wPalletTownCurScript] ld a, [wPalletTownCurScript]
jp CallFunctionInTable jp CallFunctionInTable
PalletTownScriptPointers: PalletTownScriptPointers:
@ -20,126 +20,126 @@ PalletTownScriptPointers:
PalletTownScript0: PalletTownScript0:
CheckEvent EVENT_FOLLOWED_OAK_INTO_LAB CheckEvent EVENT_FOLLOWED_OAK_INTO_LAB
ret nz ret nz
ld a,[wYCoord] ld a, [wYCoord]
cp 1 ; is player near north exit? cp 1 ; is player near north exit?
ret nz ret nz
xor a xor a
ld [hJoyHeld],a ld [hJoyHeld], a
ld a,PLAYER_DIR_DOWN ld a, PLAYER_DIR_DOWN
ld [wPlayerMovingDirection],a ld [wPlayerMovingDirection], a
ld a,$FF ld a, $FF
call PlaySound ; stop music call PlaySound ; stop music
ld a, BANK(Music_MeetProfOak) ld a, BANK(Music_MeetProfOak)
ld c,a ld c, a
ld a, MUSIC_MEET_PROF_OAK ; “oak appears” music ld a, MUSIC_MEET_PROF_OAK ; “oak appears” music
call PlayMusic call PlayMusic
ld a,$FC ld a, $FC
ld [wJoyIgnore],a ld [wJoyIgnore], a
SetEvent EVENT_OAK_APPEARED_IN_PALLET SetEvent EVENT_OAK_APPEARED_IN_PALLET
; trigger the next script ; trigger the next script
ld a,1 ld a, 1
ld [wPalletTownCurScript],a ld [wPalletTownCurScript], a
ret ret
PalletTownScript1: PalletTownScript1:
xor a xor a
ld [wcf0d],a ld [wcf0d], a
ld a,1 ld a, 1
ld [hSpriteIndexOrTextID],a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
ld a,$FF ld a, $FF
ld [wJoyIgnore],a ld [wJoyIgnore], a
ld a,HS_PALLET_TOWN_OAK ld a, HS_PALLET_TOWN_OAK
ld [wMissableObjectIndex],a ld [wMissableObjectIndex], a
predef ShowObject predef ShowObject
; trigger the next script ; trigger the next script
ld a,2 ld a, 2
ld [wPalletTownCurScript],a ld [wPalletTownCurScript], a
ret ret
PalletTownScript2: PalletTownScript2:
ld a,1 ld a, 1
ld [H_SPRITEINDEX],a ld [H_SPRITEINDEX], a
ld a,SPRITE_FACING_UP ld a, SPRITE_FACING_UP
ld [hSpriteFacingDirection],a ld [hSpriteFacingDirection], a
call SetSpriteFacingDirectionAndDelay call SetSpriteFacingDirectionAndDelay
call Delay3 call Delay3
ld a,1 ld a, 1
ld [wYCoord],a ld [wYCoord], a
ld a,1 ld a, 1
ld [hNPCPlayerRelativePosPerspective],a ld [hNPCPlayerRelativePosPerspective], a
ld a,1 ld a, 1
swap a swap a
ld [hNPCSpriteOffset],a ld [hNPCSpriteOffset], a
predef CalcPositionOfPlayerRelativeToNPC predef CalcPositionOfPlayerRelativeToNPC
ld hl,hNPCPlayerYDistance ld hl, hNPCPlayerYDistance
dec [hl] dec [hl]
predef FindPathToPlayer ; load Oaks movement into wNPCMovementDirections2 predef FindPathToPlayer ; load Oaks movement into wNPCMovementDirections2
ld de,wNPCMovementDirections2 ld de, wNPCMovementDirections2
ld a,1 ; oak ld a, 1 ; oak
ld [H_SPRITEINDEX],a ld [H_SPRITEINDEX], a
call MoveSprite call MoveSprite
ld a,$FF ld a, $FF
ld [wJoyIgnore],a ld [wJoyIgnore], a
; trigger the next script ; trigger the next script
ld a,3 ld a, 3
ld [wPalletTownCurScript],a ld [wPalletTownCurScript], a
ret ret
PalletTownScript3: PalletTownScript3:
ld a,[wd730] ld a, [wd730]
bit 0,a bit 0, a
ret nz ret nz
xor a ; ld a, SPRITE_FACING_DOWN xor a ; ld a, SPRITE_FACING_DOWN
ld [wSpriteStateData1 + 9],a ld [wSpriteStateData1 + 9], a
ld a,1 ld a, 1
ld [wcf0d],a ld [wcf0d], a
ld a,$FC ld a, $FC
ld [wJoyIgnore],a ld [wJoyIgnore], a
ld a,1 ld a, 1
ld [hSpriteIndexOrTextID],a ld [hSpriteIndexOrTextID], a
call DisplayTextID call DisplayTextID
; set up movement script that causes the player to follow Oak to his lab ; set up movement script that causes the player to follow Oak to his lab
ld a,$FF ld a, $FF
ld [wJoyIgnore],a ld [wJoyIgnore], a
ld a,1 ld a, 1
ld [wSpriteIndex],a ld [wSpriteIndex], a
xor a xor a
ld [wNPCMovementScriptFunctionNum],a ld [wNPCMovementScriptFunctionNum], a
ld a,1 ld a, 1
ld [wNPCMovementScriptPointerTableNum],a ld [wNPCMovementScriptPointerTableNum], a
ld a,[H_LOADEDROMBANK] ld a, [H_LOADEDROMBANK]
ld [wNPCMovementScriptBank],a ld [wNPCMovementScriptBank], a
; trigger the next script ; trigger the next script
ld a,4 ld a, 4
ld [wPalletTownCurScript],a ld [wPalletTownCurScript], a
ret ret
PalletTownScript4: PalletTownScript4:
ld a,[wNPCMovementScriptPointerTableNum] ld a, [wNPCMovementScriptPointerTableNum]
and a ; is the movement script over? and a ; is the movement script over?
ret nz ret nz
; trigger the next script ; trigger the next script
ld a,5 ld a, 5
ld [wPalletTownCurScript],a ld [wPalletTownCurScript], a
ret ret
PalletTownScript5: PalletTownScript5:
CheckEvent EVENT_DAISY_WALKING CheckEvent EVENT_DAISY_WALKING
jr nz,.next jr nz, .next
CheckBothEventsSet EVENT_GOT_TOWN_MAP, EVENT_ENTERED_BLUES_HOUSE, 1 CheckBothEventsSet EVENT_GOT_TOWN_MAP, EVENT_ENTERED_BLUES_HOUSE, 1
jr nz,.next jr nz, .next
SetEvent EVENT_DAISY_WALKING SetEvent EVENT_DAISY_WALKING
ld a,HS_DAISY_SITTING ld a, HS_DAISY_SITTING
ld [wMissableObjectIndex],a ld [wMissableObjectIndex], a
predef HideObject predef HideObject
ld a,HS_DAISY_WALKING ld a, HS_DAISY_WALKING
ld [wMissableObjectIndex],a ld [wMissableObjectIndex], a
predef_jump ShowObject predef_jump ShowObject
.next .next
CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK CheckEvent EVENT_GOT_POKEBALLS_FROM_OAK
@ -159,15 +159,15 @@ PalletTownTextPointers:
PalletTownText1: PalletTownText1:
TX_ASM TX_ASM
ld a,[wcf0d] ld a, [wcf0d]
and a and a
jr nz,.next jr nz, .next
ld a,1 ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText],a ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld hl,OakAppearsText ld hl, OakAppearsText
jr .done jr .done
.next .next
ld hl,OakWalksUpText ld hl, OakWalksUpText
.done .done
call PrintText call PrintText
jp TextScriptEnd jp TextScriptEnd
@ -175,14 +175,14 @@ PalletTownText1:
OakAppearsText: OakAppearsText:
TX_FAR _OakAppearsText TX_FAR _OakAppearsText
TX_ASM TX_ASM
ld c,10 ld c, 10
call DelayFrames call DelayFrames
xor a xor a
ld [wEmotionBubbleSpriteIndex],a ; player's sprite ld [wEmotionBubbleSpriteIndex], a ; player's sprite
ld [wWhichEmotionBubble],a ; EXCLAMATION_BUBBLE ld [wWhichEmotionBubble], a ; EXCLAMATION_BUBBLE
predef EmotionBubble predef EmotionBubble
ld a,PLAYER_DIR_DOWN ld a, PLAYER_DIR_DOWN
ld [wPlayerMovingDirection],a ld [wPlayerMovingDirection], a
jp TextScriptEnd jp TextScriptEnd
OakWalksUpText: OakWalksUpText:

View file

@ -51,11 +51,11 @@ MomHealText2:
RedsHouse1FText2: ; TV RedsHouse1FText2: ; TV
TX_ASM TX_ASM
ld a,[wSpriteStateData1 + 9] ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP cp SPRITE_FACING_UP
ld hl,TVWrongSideText ld hl, TVWrongSideText
jr nz,.notUp jr nz, .notUp
ld hl,StandByMeText ld hl, StandByMeText
.notUp .notUp
call PrintText call PrintText
jp TextScriptEnd jp TextScriptEnd

View file

@ -1,7 +1,7 @@
RedsHouse2FScript: RedsHouse2FScript:
call EnableAutoTextBoxDrawing call EnableAutoTextBoxDrawing
ld hl,RedsHouse2FScriptPointers ld hl, RedsHouse2FScriptPointers
ld a,[wRedsHouse2CurScript] ld a, [wRedsHouse2CurScript]
jp CallFunctionInTable jp CallFunctionInTable
RedsHouse2FScriptPointers: RedsHouse2FScriptPointers:
@ -10,11 +10,11 @@ RedsHouse2FScriptPointers:
RedsHouse2FScript0: RedsHouse2FScript0:
xor a xor a
ld [hJoyHeld],a ld [hJoyHeld], a
ld a,PLAYER_DIR_UP ld a, PLAYER_DIR_UP
ld [wPlayerMovingDirection],a ld [wPlayerMovingDirection], a
ld a,1 ld a, 1
ld [wRedsHouse2CurScript],a ld [wRedsHouse2CurScript], a
ret ret
RedsHouse2FScript1: RedsHouse2FScript1:

View file

@ -117,10 +117,10 @@ SafariZoneEntranceScriptPointers:
SafariZoneEntranceAutoWalk: SafariZoneEntranceAutoWalk:
push af push af
ld b,0 ld b, 0
ld a,c ld a, c
ld [wSimulatedJoypadStatesIndex],a ld [wSimulatedJoypadStatesIndex], a
ld hl,wSimulatedJoypadStatesEnd ld hl, wSimulatedJoypadStatesEnd
pop af pop af
call FillMemory call FillMemory
jp StartSimulatingJoypadStates jp StartSimulatingJoypadStates
@ -146,64 +146,64 @@ SafariZoneEntranceTextPointers:
TX_FAR SafariZoneEntranceText_9e6e4 TX_FAR SafariZoneEntranceText_9e6e4
TX_ASM TX_ASM
ld a, MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
call YesNoChoice call YesNoChoice
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jp nz,.PleaseComeAgain jp nz, .PleaseComeAgain
xor a xor a
ld [hMoney],a ld [hMoney], a
ld a,$05 ld a, $05
ld [hMoney + 1],a ld [hMoney + 1], a
ld a,$00 ld a, $00
ld [hMoney + 2],a ld [hMoney + 2], a
call HasEnoughMoney call HasEnoughMoney
jr nc,.success jr nc, .success
ld hl,.NotEnoughMoneyText ld hl, .NotEnoughMoneyText
call PrintText call PrintText
jr .CantPayWalkDown jr .CantPayWalkDown
.success .success
xor a xor a
ld [wPriceTemp],a ld [wPriceTemp], a
ld a,$05 ld a, $05
ld [wPriceTemp + 1],a ld [wPriceTemp + 1], a
ld a,$00 ld a, $00
ld [wPriceTemp + 2],a ld [wPriceTemp + 2], a
ld hl,wPriceTemp + 2 ld hl, wPriceTemp + 2
ld de,wPlayerMoney + 2 ld de, wPlayerMoney + 2
ld c,3 ld c, 3
predef SubBCDPredef predef SubBCDPredef
ld a,MONEY_BOX ld a, MONEY_BOX
ld [wTextBoxID],a ld [wTextBoxID], a
call DisplayTextBoxID call DisplayTextBoxID
ld hl,.MakePaymentText ld hl, .MakePaymentText
call PrintText call PrintText
ld a,30 ld a, 30
ld [wNumSafariBalls],a ld [wNumSafariBalls], a
ld a,502 / $100 ld a, 502 / $100
ld [wSafariSteps],a ld [wSafariSteps], a
ld a, 502 % $100 ld a, 502 % $100
ld [wSafariSteps + 1],a ld [wSafariSteps + 1], a
ld a,D_UP ld a, D_UP
ld c,3 ld c, 3
call SafariZoneEntranceAutoWalk call SafariZoneEntranceAutoWalk
SetEvent EVENT_IN_SAFARI_ZONE SetEvent EVENT_IN_SAFARI_ZONE
ResetEventReuseHL EVENT_SAFARI_GAME_OVER ResetEventReuseHL EVENT_SAFARI_GAME_OVER
ld a,3 ld a, 3
ld [wSafariZoneEntranceCurScript],a ld [wSafariZoneEntranceCurScript], a
jr .done jr .done
.PleaseComeAgain .PleaseComeAgain
ld hl,.PleaseComeAgainText ld hl, .PleaseComeAgainText
call PrintText call PrintText
.CantPayWalkDown .CantPayWalkDown
ld a,D_DOWN ld a, D_DOWN
ld c,1 ld c, 1
call SafariZoneEntranceAutoWalk call SafariZoneEntranceAutoWalk
ld a,4 ld a, 4
ld [wSafariZoneEntranceCurScript],a ld [wSafariZoneEntranceCurScript], a
.done .done
jp TextScriptEnd jp TextScriptEnd
@ -225,7 +225,7 @@ SafariZoneEntranceTextPointers:
TX_FAR SafariZoneEntranceText_9e814 TX_FAR SafariZoneEntranceText_9e814
TX_ASM TX_ASM
call YesNoChoice call YesNoChoice
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
jr nz, .asm_7539c jr nz, .asm_7539c
ld hl, .SafariZoneEntranceText_753bb ld hl, .SafariZoneEntranceText_753bb
@ -268,14 +268,14 @@ SafariZoneEntranceTextPointers:
.SafariZoneEntranceText2 .SafariZoneEntranceText2
TX_ASM TX_ASM
ld hl,.FirstTimeQuestionText ld hl, .FirstTimeQuestionText
call PrintText call PrintText
call YesNoChoice call YesNoChoice
ld a,[wCurrentMenuItem] ld a, [wCurrentMenuItem]
and a and a
ld hl,.RegularText ld hl, .RegularText
jr nz,.Explanation jr nz, .Explanation
ld hl,.ExplanationText ld hl, .ExplanationText
.Explanation .Explanation
call PrintText call PrintText
jp TextScriptEnd jp TextScriptEnd