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:
xor a
ld [H_AUTOBGTRANSFERENABLED],a
ld [H_AUTOBGTRANSFERENABLED], a
call SaveScreenTilesToBuffer1
call FillMiddleOfScreenWithWhite
; display the next monster from CreditsMons
ld hl,wNumCreditsMonsDisplayed
ld c,[hl] ; how many monsters have we displayed so far?
ld hl, wNumCreditsMonsDisplayed
ld c, [hl] ; how many monsters have we displayed so far?
inc [hl]
ld b,0
ld hl,CreditsMons
add hl,bc ; go that far in the list of monsters and get the next one
ld a,[hl]
ld [wcf91],a
ld [wd0b5],a
ld b, 0
ld hl, CreditsMons
add hl, bc ; go that far in the list of monsters and get the next one
ld a, [hl]
ld [wcf91], a
ld [wd0b5], a
coord hl, 8, 6
call GetMonHeader
call LoadFrontSpriteByMonIndex
ld hl,vBGMap0 + $c
ld hl, vBGMap0 + $c
call CreditsCopyTileMapToVRAM
xor a
ld [H_AUTOBGTRANSFERENABLED],a
ld [H_AUTOBGTRANSFERENABLED], a
call LoadScreenTilesFromBuffer1
ld hl,vBGMap0
ld hl, vBGMap0
call CreditsCopyTileMapToVRAM
ld a,$A7
ld [rWX],a
ld hl,vBGMap1
ld a, $A7
ld [rWX], a
ld hl, vBGMap1
call CreditsCopyTileMapToVRAM
call FillMiddleOfScreenWithWhite
ld a,%11111100 ; make the mon a black silhouette
ld [rBGP],a
ld a, %11111100 ; make the mon a black silhouette
ld [rBGP], a
; scroll the mon left by one tile 7 times
ld bc,7
ld bc, 7
.scrollLoop1
call ScrollCreditsMonLeft
dec c
jr nz,.scrollLoop1
jr nz, .scrollLoop1
; 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
; is wrapping around to the right side of the screen.
ld c,20
ld c, 20
.scrollLoop2
call ScrollCreditsMonLeft
ld a,[rWX]
ld a, [rWX]
sub 8
ld [rWX],a
ld [rWX], a
dec c
jr nz,.scrollLoop2
jr nz, .scrollLoop2
xor a
ld [hWY],a
ld a,%11000000
ld [rBGP],a
ld [hWY], a
ld a, %11000000
ld [rBGP], a
ret
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:
; after using a move, decrement pp in battle and (if not transformed?) in party
ld a, [de]
cp a, STRUGGLE
cp STRUGGLE
ret z ; if the pokemon is using "struggle", there's nothing to do
; we don't decrement PP for "struggle"
ld hl, wPlayerBattleStatus1
ld a, [hli] ; load the wPlayerBattleStatus1 pokemon status flags and increment hl to load the
; 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
bit USING_RAGE, [hl]
ret nz ; don't decrement PP either if Pokemon is using Rage

View File

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

View File

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

View File

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

View File

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

View File

@ -1,78 +1,78 @@
; function that performs initialization for DisplayTextID
DisplayTextIDInit:
xor a
ld [wListMenuID],a
ld a,[wAutoTextBoxDrawingControl]
bit 0,a
jr nz,.skipDrawingTextBoxBorder
ld a,[hSpriteIndexOrTextID] ; text ID (or sprite ID)
ld [wListMenuID], a
ld a, [wAutoTextBoxDrawingControl]
bit 0, a
jr nz, .skipDrawingTextBoxBorder
ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID)
and a
jr nz,.notStartMenu
jr nz, .notStartMenu
; if text ID is 0 (i.e. the start menu)
; Note that the start menu text border is also drawn in the function directly
; below this, so this seems unnecessary.
CheckEvent EVENT_GOT_POKEDEX
; start menu with pokedex
coord hl, 10, 0
ld b,$0e
ld c,$08
jr nz,.drawTextBoxBorder
ld b, $0e
ld c, $08
jr nz, .drawTextBoxBorder
; start menu without pokedex
coord hl, 10, 0
ld b,$0c
ld c,$08
ld b, $0c
ld c, $08
jr .drawTextBoxBorder
; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
.notStartMenu
coord hl, 0, 12
ld b,$04
ld c,$12
ld b, $04
ld c, $12
.drawTextBoxBorder
call TextBoxBorder
.skipDrawingTextBoxBorder
ld hl,wFontLoaded
set 0,[hl]
ld hl,wFlags_0xcd60
bit 4,[hl]
res 4,[hl]
jr nz,.skipMovingSprites
ld hl, wFontLoaded
set 0, [hl]
ld hl, wFlags_0xcd60
bit 4, [hl]
res 4, [hl]
jr nz, .skipMovingSprites
call UpdateSprites
.skipMovingSprites
; 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
; the original direction they were facing must be restored after the dialogue is over
ld hl,wSpriteStateData1 + $19
ld c,$0f
ld de,$0010
ld hl, wSpriteStateData1 + $19
ld c, $0f
ld de, $0010
.spriteFacingDirectionCopyLoop
ld a,[hl]
ld a, [hl]
inc h
ld [hl],a
ld [hl], a
dec h
add hl,de
add hl, de
dec c
jr nz,.spriteFacingDirectionCopyLoop
jr nz, .spriteFacingDirectionCopyLoop
; 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)
ld hl,wSpriteStateData1 + 2
ld de,$0010
ld c,e
ld hl, wSpriteStateData1 + 2
ld de, $0010
ld c, e
.spriteStandStillLoop
ld a,[hl]
cp a,$ff ; is the sprite visible?
jr z,.nextSprite
ld a, [hl]
cp $ff ; is the sprite visible?
jr z, .nextSprite
; if it is visible
and a,$fc
ld [hl],a
and $fc
ld [hl], a
.nextSprite
add hl,de
add hl, de
dec c
jr nz,.spriteStandStillLoop
ld b,$9c ; window background address
jr nz, .spriteStandStillLoop
ld b, $9c ; window background address
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
xor a
ld [hWY],a ; put the window on the screen
ld [hWY], a ; put the window on the screen
call LoadFontTilePatterns
ld a,$01
ld [H_AUTOBGTRANSFERENABLED],a ; enable continuous WRAM to VRAM transfer each V-blank
ld a, $01
ld [H_AUTOBGTRANSFERENABLED], a ; enable continuous WRAM to VRAM transfer each V-blank
ret

View File

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

View File

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

View File

@ -5,81 +5,81 @@
; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
AddItemToInventory_:
ld a,[wItemQuantity] ; a = item quantity
ld a, [wItemQuantity] ; a = item quantity
push af
push bc
push de
push hl
push hl
ld d,PC_ITEM_CAPACITY ; how many items the PC can hold
ld a,wNumBagItems & $FF
ld d, PC_ITEM_CAPACITY ; how many items the PC can hold
ld a, wNumBagItems & $FF
cp l
jr nz,.checkIfInventoryFull
ld a,wNumBagItems >> 8
jr nz, .checkIfInventoryFull
ld a, wNumBagItems >> 8
cp h
jr nz,.checkIfInventoryFull
jr nz, .checkIfInventoryFull
; 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
ld a,[hl]
ld a, [hl]
sub d
ld d,a
ld a,[hli]
ld d, a
ld a, [hli]
and a
jr z,.addNewItem
jr z, .addNewItem
.loop
ld a,[hli]
ld b,a ; b = ID of current item in table
ld a,[wcf91] ; a = ID of item being added
ld a, [hli]
ld b, a ; b = ID of current item in table
ld a, [wcf91] ; a = ID of 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
ld a,[hl]
cp a,$ff ; is it the end of the table?
jr nz,.loop
ld a, [hl]
cp $ff ; is it the end of the table?
jr nz, .loop
.addNewItem ; add an item not yet in the inventory
pop hl
ld a,d
ld a, d
and a ; is there room for a new item slot?
jr z,.done
jr z, .done
; if there is room
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
dec a
ld c,a
ld b,0
add hl,bc ; hl = address to store the item
ld a,[wcf91]
ld [hli],a ; store item ID
ld a,[wItemQuantity]
ld [hli],a ; store item quantity
ld [hl],$ff ; store terminator
ld c, a
ld b, 0
add hl, bc ; hl = address to store the item
ld a, [wcf91]
ld [hli], a ; store item ID
ld a, [wItemQuantity]
ld [hli], a ; store item quantity
ld [hl], $ff ; store terminator
jp .success
.increaseItemQuantity ; increase the quantity of an item already in the inventory
ld a,[wItemQuantity]
ld b,a ; b = quantity to add
ld a,[hl] ; a = existing item quantity
ld a, [wItemQuantity]
ld b, a ; b = quantity to add
ld a, [hl] ; a = existing item quantity
add b ; a = new item quantity
cp a,100
jp c,.storeNewQuantity ; if the new quantity is less than 100, store it
cp 100
jp c, .storeNewQuantity ; if the new quantity is less than 100, store it
; 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
sub a,99
ld [wItemQuantity],a ; a = amount left over (to put in the new slot)
ld a,d
sub 99
ld [wItemQuantity], a ; a = amount left over (to put in the new slot)
ld a, d
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
ld a,99
ld [hli],a
ld a, 99
ld [hli], a
jp .loop
.increaseItemQuantityFailed
pop hl
and a
jr .done
.storeNewQuantity
ld [hl],a
ld [hl], a
pop hl
.success
scf
@ -88,8 +88,8 @@ AddItemToInventory_:
pop de
pop bc
pop bc
ld a,b
ld [wItemQuantity],a ; restore the initial value from when the function was called
ld a, b
ld [wItemQuantity], a ; restore the initial value from when the function was called
ret
; function to remove an item (in varying quantities) from the player's bag or PC box
@ -100,49 +100,49 @@ AddItemToInventory_:
RemoveItemFromInventory_:
push 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
add l
ld l,a
jr nc,.noCarry
ld l, a
jr nc, .noCarry
inc h
.noCarry
inc hl
ld a,[wItemQuantity] ; quantity being removed
ld e,a
ld a,[hl] ; a = current quantity
ld a, [wItemQuantity] ; quantity being removed
ld e, a
ld a, [hl] ; a = current quantity
sub e
ld [hld],a ; store new quantity
ld [wMaxItemQuantity],a
ld [hld], a ; store new quantity
ld [wMaxItemQuantity], a
and a
jr nz,.skipMovingUpSlots
jr nz, .skipMovingUpSlots
; if the remaining quantity is 0,
; remove the emptied item slot and move up all the following item slots
.moveSlotsUp
ld e,l
ld d,h
ld e, l
ld d, h
inc de
inc de ; de = address of the slot following the emptied one
.loop ; loop to move up the following slots
ld a,[de]
ld a, [de]
inc de
ld [hli],a
cp a,$ff
jr nz,.loop
ld [hli], a
cp $ff
jr nz, .loop
; update menu info
xor a
ld [wListScrollOffset],a
ld [wCurrentMenuItem],a
ld [wBagSavedMenuItem],a
ld [wSavedListScrollOffset],a
ld [wListScrollOffset], a
ld [wCurrentMenuItem], a
ld [wBagSavedMenuItem], a
ld [wSavedListScrollOffset], a
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
ld [hl],a ; store new number of items
ld [wListCount],a
cp a,2
jr c,.done
ld [wMaxMenuItem],a
ld [hl], a ; store new number of items
ld [wListCount], a
cp 2
jr c, .done
ld [wMaxMenuItem], a
jr .done
.skipMovingUpSlots
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.
LoadPokedexTilePatterns:
call LoadHpBarAndStatusTilePatterns
ld de,PokedexTileGraphics
ld hl,vChars2 + $600
ld de, PokedexTileGraphics
ld hl, vChars2 + $600
lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
call CopyVideoData
ld de,PokeballTileGraphics
ld hl,vChars2 + $720
ld de, PokeballTileGraphics
ld hl, vChars2 + $720
lb bc, BANK(PokeballTileGraphics), $01
jp CopyVideoData ; load pokeball tile for marking caught mons

View File

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

View File

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

View File

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

View File

@ -17,34 +17,34 @@ PCMainMenu:
bit 1, a ;if player pressed B
jp nz, LogOff
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)
ld a, [wCurrentMenuItem]
and a
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
jp LogOff ;otherwise, it's 2, and you're logging off
.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)
ld a, [wCurrentMenuItem]
and a
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
cp a, 2
cp 2
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
.next2
ld a, [wCurrentMenuItem]
and a
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
cp a, 2
cp 2
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 LogOff ;otherwise, it's 4, and you're logging off
.playersPC

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,31 +1,31 @@
SpecialWarpIn:
call LoadSpecialWarpData
predef LoadTilesetHeader
ld hl,wd732
bit 2,[hl] ; dungeon warp or fly warp?
res 2,[hl]
jr z,.next
ld hl, wd732
bit 2, [hl] ; dungeon warp or fly warp?
res 2, [hl]
jr z, .next
; if dungeon warp or fly warp
ld a,[wDestinationMap]
ld a, [wDestinationMap]
jr .next2
.next
bit 1,[hl]
jr z,.next3
bit 1, [hl]
jr z, .next3
call EmptyFunc
.next3
ld a,0
ld a, 0
.next2
ld b,a
ld a,[wd72d]
ld b, a
ld a, [wd72d]
and a
jr nz,.next4
ld a,b
jr nz, .next4
ld a, b
.next4
ld hl,wd732
bit 4,[hl] ; dungeon warp?
ld hl, wd732
bit 4, [hl] ; dungeon warp?
ret nz
; if not dungeon warp
ld [wLastMap],a
ld [wLastMap], a
ret
; 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
; sets carry flag if there is enough money and unsets carry flag if not
SubtractAmountPaidFromMoney_:
ld de,wPlayerMoney
ld hl,hMoney ; total price of items
ld c,3 ; length of money in bytes
ld de, wPlayerMoney
ld hl, hMoney ; total price of items
ld c, 3 ; length of money in bytes
call StringCmp
ret c
ld de,wPlayerMoney + 2
ld hl,hMoney + 2 ; total price of items
ld c,3 ; length of money in bytes
ld de, wPlayerMoney + 2
ld hl, hMoney + 2 ; total price of items
ld c, 3 ; length of money in bytes
predef SubBCDPredef ; subtract total price from money
ld a,MONEY_BOX
ld [wTextBoxID],a
ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID ; redraw money text box
and a
ret

View File

@ -56,7 +56,7 @@ DisplayTitleScreen:
ld a, BANK(PokemonLogoGraphics)
call FarCopyData2 ; second chunk
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 a, BANK(Version_GFX)
call FarCopyDataDouble
@ -118,10 +118,10 @@ DisplayTitleScreen:
call LoadScreenTilesFromBuffer2
call EnableLCD
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
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
ld [wTitleMonSpecies], a

View File

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

1928
home.asm

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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