This commit is contained in:
YamaArashi 2015-07-18 20:49:52 -07:00
parent b96ef8d2d4
commit c169073eed
61 changed files with 743 additions and 612 deletions

View file

@ -29,7 +29,7 @@ HallOfFamePC: ; 7405c (1d:405c)
ld c, 128
call DelayFrames
xor a
ld [wWhichTrade], a
ld [wNumCreditsMonsDisplayed - 1], a ; not read
ld [wNumCreditsMonsDisplayed], a
jp Credits

View file

@ -796,9 +796,9 @@ DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
dec a
ret nz
; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation
ld a,[wWhichTrade] ; number of shakes
ld a,[wNumShakes] ; number of shakes
dec a ; decrement number of shakes
ld [wWhichTrade],a
ld [wNumShakes],a
ret z
; if there are shakes left, restart the subanimation
ld a,[W_SUBANIMSUBENTRYADDR]
@ -1998,11 +1998,11 @@ AnimationWavyScreen: ; 79666 (1e:5666)
ret
Func_796ae: ; 796ae (1e:56ae)
ld a, [$ff41]
ld a, [rSTAT]
and $3
jr nz, Func_796ae
ld a, [hl]
ld [$ff43], a
ld [rSCX], a
inc hl
ld a, [hl]
cp d
@ -2895,7 +2895,7 @@ TossBallAnimation: ; 79e16 (1e:5e16)
; store these for later
ld a,b
and a,$F
ld [wWhichTrade],a
ld [wNumShakes],a
ld hl,.PokeBallAnimations
; choose which toss animation to use

View file

@ -6298,7 +6298,7 @@ LoadEnemyMonData: ; 3eb01 (f:6b01)
dec de
dec de
xor a
ld [wHPBarMaxHP], a
ld [wLearningMovesFromDayCare], a
predef WriteMonMoves ; get moves based on current level
.loadMovePPs
ld hl, wEnemyMonMoves

View file

@ -254,7 +254,7 @@ GainExperience: ; 5524f (15:524f)
ld a, [wd0b5]
ld [wd11e], a
predef LearnMoveFromLevelUp
ld hl, wccd3
ld hl, wCanEvolveFlags
ld a, [wWhichPokemon]
ld c, a
ld b, $1

View file

@ -19,7 +19,7 @@ InitBattleVariables: ; 525af (14:65af)
ld hl, wcf1d
ld [hli], a
ld [hl], a
ld hl, wccd3
ld hl, wCanEvolveFlags
ld b, $3c
.loop
ld [hli], a

View file

@ -297,7 +297,7 @@ CallCurrentTradeCenterFunction:
ld b, 0
ld a, [wTradeCenterPointerTableIndex]
cp $ff
jp z, LoadTitlescreenGraphics
jp z, DisplayTitleScreen
add a
ld c, a
add hl, bc

View file

@ -20,11 +20,11 @@ EvolveMon: ; 7bde9 (1e:7de9)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld [hTilesetType], a
ld a, [wHPBarMaxHP]
ld a, [wEvoOldSpecies]
ld [wcf1d], a
ld c, $0
call EvolutionSetWholeScreenPalette
ld a, [wHPBarMaxHP + 1]
ld a, [wEvoNewSpecies]
ld [wcf91], a
ld [wd0b5], a
call Evolution_LoadPic
@ -32,13 +32,13 @@ EvolveMon: ; 7bde9 (1e:7de9)
ld hl, vBackPic
ld bc, 7 * 7
call CopyVideoData
ld a, [wHPBarMaxHP]
ld a, [wEvoOldSpecies]
ld [wcf91], a
ld [wd0b5], a
call Evolution_LoadPic
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld a, [wHPBarMaxHP]
ld a, [wEvoOldSpecies]
call PlayCry
call WaitForSoundToFinish
ld c, BANK(Music_SafariZone)
@ -49,23 +49,23 @@ EvolveMon: ; 7bde9 (1e:7de9)
ld c, $1
call EvolutionSetWholeScreenPalette
ld bc, $110
.asm_7be63
.animLoop
push bc
call Evolution_CheckForCancel
jr c, .evolutionCancelled
call Func_7bec2
call Evolution_BackAndForthAnim
pop bc
inc b
dec c
dec c
jr nz, .asm_7be63
jr nz, .animLoop
xor a
ld [wHPBarOldHP + 1], a
ld [wEvoCancelled], a
ld a, $31
ld [wHPBarOldHP], a
call Func_7bed6
ld a, [wHPBarMaxHP + 1]
.afterCancellation
ld [wEvoMonTileOffset], a
call Evolution_ChangeMonPic ; show the new species pic
ld a, [wEvoNewSpecies]
.done
ld [wcf1d], a
ld a, $ff
ld [wc0ee], a
@ -81,17 +81,17 @@ EvolveMon: ; 7bde9 (1e:7de9)
pop bc
pop de
pop hl
ld a, [wHPBarOldHP + 1]
ld a, [wEvoCancelled]
and a
ret z
scf
ret
.evolutionCancelled
pop bc
ld a, $1
ld [wHPBarOldHP + 1], a
ld a, [wHPBarMaxHP]
jr .afterCancellation
ld a, 1
ld [wEvoCancelled], a
ld a, [wEvoOldSpecies]
jr .done
EvolutionSetWholeScreenPalette: ; 7beb4 (1e:7eb4)
ld b, $b
@ -102,37 +102,38 @@ Evolution_LoadPic: ; 7beb9 (1e:7eb9)
coord hl, 7, 2
jp LoadFlippedFrontSpriteByMonIndex
Func_7bec2: ; 7bec2 (1e:7ec2)
Evolution_BackAndForthAnim: ; 7bec2 (1e:7ec2)
; show the mon change back and forth between the new and old species b times
ld a, $31
ld [wHPBarOldHP], a
call Func_7bed6
ld a, $cf
ld [wHPBarOldHP], a
call Func_7bed6
ld [wEvoMonTileOffset], a
call Evolution_ChangeMonPic
ld a, -$31
ld [wEvoMonTileOffset], a
call Evolution_ChangeMonPic
dec b
jr nz, Func_7bec2
jr nz, Evolution_BackAndForthAnim
ret
Func_7bed6: ; 7bed6 (1e:7ed6)
Evolution_ChangeMonPic: ; 7bed6 (1e:7ed6)
push bc
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 7, 2
ld bc, $707
ld de, $d
.asm_7bee3
lb bc, 7, 7
ld de, SCREEN_WIDTH - 7
.loop
push bc
.asm_7bee4
ld a, [wHPBarOldHP]
.innerLoop
ld a, [wEvoMonTileOffset]
add [hl]
ld [hli], a
dec c
jr nz, .asm_7bee4
jr nz, .innerLoop
pop bc
add hl, de
dec b
jr nz, .asm_7bee3
ld a, $1
jr nz, .loop
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
pop bc

View file

@ -1,6 +1,6 @@
; try to evolve the mon in [wWhichPokemon]
TryEvolvingMon: ; 3ad0e (e:6d0e)
ld hl, wccd3
ld hl, wCanEvolveFlags
xor a
ld [hl], a
ld a, [wWhichPokemon]
@ -31,17 +31,17 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [hl]
cp $ff ; have we reached the end of the party?
jp z, .done
ld [wHPBarMaxHP], a
ld [wEvoOldSpecies], a
push hl
ld a, [wWhichPokemon]
ld c, a
ld hl, wccd3
ld hl, wCanEvolveFlags
ld b, $2
call Evolution_FlagAction
ld a, c
and a ; is the mon's bit set?
jp z, Evolution_PartyMonLoop ; if not, go to the next mon
ld a, [wHPBarMaxHP]
ld a, [wEvoOldSpecies]
dec a
ld b, 0
ld hl, EvosMovesPointerTable
@ -110,7 +110,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld [wd121], a
push hl
ld a, [hl]
ld [wHPBarMaxHP + 1], a
ld [wEvoNewSpecies], a
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
call GetPartyMonName
@ -122,7 +122,7 @@ Evolution_PartyMonLoop: ; loop over party mons
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 0, 0
ld bc, $c14
lb bc, 12, 20
call ClearScreenArea
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
@ -137,7 +137,7 @@ Evolution_PartyMonLoop: ; loop over party mons
ld a, [hl]
ld [wd0b5], a
ld [wLoadedMonSpecies], a
ld [wHPBarMaxHP + 1], a
ld [wEvoNewSpecies], a
ld a, MONSTER_NAME
ld [wNameListType], a
ld a, BANK(TrainerNames) ; bank is not used for monster names
@ -357,7 +357,7 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b)
ld bc, wPartyMon2 - wPartyMon1
call AddNTimes
.next
ld b, $4
ld b, NUM_MOVES
.checkCurrentMovesLoop ; check if the move to learn is already known
ld a, [hli]
cp d
@ -377,14 +377,13 @@ LearnMoveFromLevelUp: ; 3af5b (e:6f5b)
; writes the moves a mon has at level [W_CURENEMYLVL] to [de]
; move slots are being filled up sequentially and shifted if all slots are full
; [wHPBarMaxHP]: (?)
WriteMonMoves: ; 3afb8 (e:6fb8)
call GetPredefRegisters
push hl
push de
push bc
ld hl, EvosMovesPointerTable
ld b, $0
ld b, 0
ld a, [wcf91] ; cur mon ID
dec a
add a
@ -411,25 +410,30 @@ WriteMonMoves: ; 3afb8 (e:6fb8)
ld a, [W_CURENEMYLVL]
cp b
jp c, .done ; mon level < move level (assumption: learnset is sorted by level)
ld a, [wHPBarMaxHP]
ld a, [wLearningMovesFromDayCare]
and a
jr z, .skipMinLevelCheck
ld a, [wWhichTrade] ; min move level)
ld a, [wDayCareStartLevel]
cp b
jr nc, .nextMove2 ; min level >= move level
.skipMinLevelCheck
; check if the move is already known
push de
ld c, $4
.moveAlreadyLearnedCheckLoop
ld c, NUM_MOVES
.alreadyKnowsCheckLoop
ld a, [de]
inc de
cp [hl]
jr z, .nextMove
dec c
jr nz, .moveAlreadyLearnedCheckLoop
jr nz, .alreadyKnowsCheckLoop
; try to find an empty move slot
pop de
push de
ld c, $4
ld c, NUM_MOVES
.findEmptySlotLoop
ld a, [de]
and a
@ -437,47 +441,55 @@ WriteMonMoves: ; 3afb8 (e:6fb8)
inc de
dec c
jr nz, .findEmptySlotLoop
pop de ; no empty move slots found
; no empty move slots found
pop de
push de
push hl
ld h, d
ld l, e
call WriteMonMoves_ShiftMoveData ; shift all moves one up (deleting move 1)
ld a, [wHPBarMaxHP]
ld a, [wLearningMovesFromDayCare]
and a
jr z, .writeMoveToSlot
; shift PP as well if learning moves from day care
push de
ld bc, $12
ld bc, wPartyMon1PP - (wPartyMon1Moves + 3)
add hl, bc
ld d, h
ld e, l
call WriteMonMoves_ShiftMoveData ; shift all move PP data one up
pop de
.writeMoveToSlot
pop hl
.writeMoveToSlot2
ld a, [hl]
ld [de], a
ld a, [wHPBarMaxHP]
ld a, [wLearningMovesFromDayCare]
and a
jr z, .nextMove
push hl ; write move PP value
; write move PP value if learning moves from day care
push hl
ld a, [hl]
ld hl, $15
ld hl, wPartyMon1PP - wPartyMon1Moves
add hl, de
push hl
dec a
ld hl, Moves
ld bc, $6
ld bc, 6
call AddNTimes
ld de, wHPBarMaxHP
ld de, wBuffer
ld a, BANK(Moves)
call FarCopyData
ld a, [wHPBarNewHP + 1]
ld a, [wBuffer + 5]
pop hl
ld [hl], a
pop hl
jr .nextMove
.done
pop bc
pop de
@ -486,13 +498,13 @@ WriteMonMoves: ; 3afb8 (e:6fb8)
; shifts all move data one up (freeing 4th move slot)
WriteMonMoves_ShiftMoveData: ; 3b04e (e:704e)
ld c, $3
.asm_3b050
ld c, NUM_MOVES - 1
.loop
inc de
ld a, [de]
ld [hli], a
dec c
jr nz, .asm_3b050
jr nz, .loop
ret
Evolution_FlagAction: ; 3b057 (e:7057)

View file

@ -10,15 +10,15 @@ CalcLevelFromExperience: ; 58f43 (16:4f43)
push hl
ld hl, wLoadedMonExp + 2 ; current exp
; compare exp needed for level d with current exp
ld a, [H_MULTIPLICAND + 2]
ld a, [hExperience + 2]
ld c, a
ld a, [hld]
sub c
ld a, [H_MULTIPLICAND + 1]
ld a, [hExperience + 1]
ld c, a
ld a, [hld]
sbc c
ld a, [H_MULTIPLICAND]
ld a, [hExperience]
ld c, a
ld a, [hl]
sbc c
@ -33,7 +33,7 @@ CalcExperience: ; 58f6a (16:4f6a)
add a
add a
ld c, a
ld b, $0
ld b, 0
ld hl, GrowthRateTable
add hl, bc
call CalcDSquared
@ -50,96 +50,100 @@ CalcExperience: ; 58f6a (16:4f6a)
ld [H_DIVISOR], a
ld b, $4
call Divide
ld a, [H_MULTIPLICAND] ; (aliases: H_NUMTOPRINT)
ld a, [H_QUOTIENT + 1]
push af
ld a, [H_MULTIPLICAND+1]
ld a, [H_QUOTIENT + 2]
push af
ld a, [H_MULTIPLICAND+2]
ld a, [H_QUOTIENT + 3]
push af
call CalcDSquared
ld a, [hl]
and $7f
ld [H_MULTIPLIER], a
call Multiply
ld a, [H_MULTIPLICAND] ; (aliases: H_NUMTOPRINT)
ld a, [H_PRODUCT + 1]
push af
ld a, [H_MULTIPLICAND+1]
ld a, [H_PRODUCT + 2]
push af
ld a, [H_MULTIPLICAND+2]
ld a, [H_PRODUCT + 3]
push af
ld a, [hli]
push af
xor a
ld [H_MULTIPLICAND], a
ld [H_MULTIPLICAND+1], a
ld [H_MULTIPLICAND + 1], a
ld a, d
ld [H_MULTIPLICAND+2], a
ld [H_MULTIPLICAND + 2], a
ld a, [hli]
ld [H_MULTIPLIER], a
call Multiply
ld b, [hl]
ld a, [H_MULTIPLICAND+2]
ld a, [H_PRODUCT + 3]
sub b
ld [H_MULTIPLICAND+2], a
ld [H_PRODUCT + 3], a
ld b, $0
ld a, [H_MULTIPLICAND+1]
ld a, [H_PRODUCT + 2]
sbc b
ld [H_MULTIPLICAND+1], a
ld a, [H_MULTIPLICAND]
ld [H_PRODUCT + 2], a
ld a, [H_PRODUCT + 1]
sbc b
ld [H_MULTIPLICAND], a
ld [H_PRODUCT + 1], a
; The difference of the linear term and the constant term consists of 3 bytes
; starting at H_PRODUCT + 1. Below, hExperience (an alias of that address) will
; be used instead for the further work of adding or subtracting the squared
; term and adding the cubed term.
pop af
and $80
jr nz, .subtractSquaredTerm ; check sign
pop bc
ld a, [H_MULTIPLICAND+2]
ld a, [hExperience + 2]
add b
ld [H_MULTIPLICAND+2], a
ld [hExperience + 2], a
pop bc
ld a, [H_MULTIPLICAND+1]
ld a, [hExperience + 1]
adc b
ld [H_MULTIPLICAND+1], a
ld [hExperience + 1], a
pop bc
ld a, [H_MULTIPLICAND]
ld a, [hExperience]
adc b
ld [H_MULTIPLICAND], a
ld [hExperience], a
jr .addCubedTerm
.subtractSquaredTerm
pop bc
ld a, [H_MULTIPLICAND+2]
ld a, [hExperience + 2]
sub b
ld [H_MULTIPLICAND+2], a
ld [hExperience + 2], a
pop bc
ld a, [H_MULTIPLICAND+1]
ld a, [hExperience + 1]
sbc b
ld [H_MULTIPLICAND+1], a
ld [hExperience + 1], a
pop bc
ld a, [H_MULTIPLICAND]
ld a, [hExperience]
sbc b
ld [H_MULTIPLICAND], a
ld [hExperience], a
.addCubedTerm
pop bc
ld a, [H_MULTIPLICAND+2]
ld a, [hExperience + 2]
add b
ld [H_MULTIPLICAND+2], a
ld [hExperience + 2], a
pop bc
ld a, [H_MULTIPLICAND+1]
ld a, [hExperience + 1]
adc b
ld [H_MULTIPLICAND+1], a
ld [hExperience + 1], a
pop bc
ld a, [H_MULTIPLICAND]
ld a, [hExperience]
adc b
ld [H_MULTIPLICAND], a
ld [hExperience], a
ret
; calculates d*d
CalcDSquared: ; 59010 (16:5010)
xor a
ld [H_MULTIPLICAND], a ; (aliases: H_NUMTOPRINT)
ld [H_MULTIPLICAND+1], a
ld [H_MULTIPLICAND], a
ld [H_MULTIPLICAND + 1], a
ld a, d
ld [H_MULTIPLICAND+2], a
ld [H_MULTIPLIER], a ; (aliases: H_DIVISOR, H_REMAINDER, H_POWEROFTEN)
ld [H_MULTIPLICAND + 2], a
ld [H_MULTIPLIER], a
jp Multiply
; each entry has the following scheme:

View file

@ -7,7 +7,7 @@ StartSlotMachine: ; 37e2d (d:7e2d)
cp $ff
jr z, .printSomeonesKeys
callba AbleToPlaySlotsCheck
ld a, [wHiddenObjectFunctionArgument]
ld a, [wCanPlaySlots]
and a
ret z
ld a, [wLuckySlotHiddenObjectIndex]

View file

@ -1,4 +1,4 @@
AbleToPlaySlotsCheck ; 2ff09 (b:7f09)
AbleToPlaySlotsCheck: ; 2ff09 (b:7f09)
ld a, [wSpriteStateData1 + 2]
and $8
jr z, .done ; not able
@ -19,7 +19,7 @@ AbleToPlaySlotsCheck ; 2ff09 (b:7f09)
call PrintPredefTextID
xor a
.done
ld [wWhichTrade], a
ld [wCanPlaySlots], a
ret
GameCornerCoinCaseText: ; 2ff32 (b:7f32)

View file

@ -1,13 +1,16 @@
_GivePokemon: ; 4fda5 (13:7da5)
; returns success in carry
; and whether the mon was added to the party in [wAddedToParty]
call EnableAutoTextBoxDrawing
xor a
ld [wccd3], a
ld [wAddedToParty], a
ld a, [wPartyCount]
cp PARTY_LENGTH
jr c, .asm_4fe01
jr c, .addToParty
ld a, [W_NUMINBOX]
cp MONS_PER_BOX
jr nc, .asm_4fdf9
jr nc, .boxFull
; add to box
xor a
ld [W_ENEMYBATTSTATUS3], a
ld a, [wcf91]
@ -19,32 +22,32 @@ _GivePokemon: ; 4fda5 (13:7da5)
ld a, [wCurrentBoxNum]
and $7f
cp 9
jr c, .asm_4fdec
jr c, .singleDigitBoxNum
sub 9
ld [hl], "1"
inc hl
add "0"
jr .asm_4fdee
.asm_4fdec
jr .next
.singleDigitBoxNum
add "1"
.asm_4fdee
.next
ld [hli], a
ld [hl], "@"
ld hl, SetToBoxText
call PrintText
scf
ret
.asm_4fdf9
.boxFull
ld hl, BoxIsFullText
call PrintText
and a
ret
.asm_4fe01
.addToParty
call SetPokedexOwnedFlag
call AddPartyMon
ld a, $1
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld [wccd3], a
ld [wAddedToParty], a
scf
ret

View file

@ -55,7 +55,7 @@ KabutopsFossilText: ; 5dbd4 (17:5bd4)
DisplayMonFrontSpriteInBox: ; 5dbd9 (17:5bd9)
; Displays a pokemon's front sprite in a pop-up window.
; [wcf91] = pokemon interal id number
ld a, $1
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
xor a
@ -85,7 +85,7 @@ PrintBlackboardLinkCableText: ; 5dc1a (17:5c1a)
call EnableAutoTextBoxDrawing
ld a, $1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade]
ld a, [wHiddenObjectFunctionArgument]
call PrintPredefTextID
ret
@ -310,7 +310,7 @@ VermilionGymTrashText: ; 5ddf7 (17:5df7)
GymTrashScript: ; 5ddfc (17:5dfc)
call EnableAutoTextBoxDrawing
ld a, [wWhichTrade]
ld a, [wHiddenObjectFunctionArgument]
ld [wcd5b], a
; Don't do the trash can puzzle if it's already been done.

View file

@ -128,7 +128,7 @@ CinnabarGymQuiz: ; 1ea25 (7:6a25)
TX_ASM
xor a
ld [wda38], a
ld a, [wWhichTrade]
ld a, [wHiddenObjectFunctionArgument]
push af
and $f
ld [$ffdb], a

View file

@ -1,14 +1,14 @@
HiddenItemNear: ; 7481f (1d:481f)
ld hl, HiddenItemCoords
ld b, $0
.asm_74824
ld de, $0003
ld b, 0
.loop
ld de, 3
ld a, [W_CURMAP]
call IsInRestOfArray
ret nc ; return if current map has no hidden items
push bc
push hl
ld hl, wd6f0
ld hl, wObtainedHiddenItemsFlags
ld c, b
ld b, $2
predef FlagActionPredef
@ -22,28 +22,30 @@ HiddenItemNear: ; 7481f (1d:481f)
inc hl
ld e, [hl]
inc hl
jr nz, .asm_74824
jr nz, .loop ; if the item has already been obtained
; check if the item is within 4-5 tiles (depending on the direction of item)
ld a, [W_YCOORD]
call Func_7486b
call Sub5ClampTo0
cp d
jr nc, .asm_74824
jr nc, .loop
ld a, [W_YCOORD]
add $4
add 4
cp d
jr c, .asm_74824
jr c, .loop
ld a, [W_XCOORD]
call Func_7486b
call Sub5ClampTo0
cp e
jr nc, .asm_74824
jr nc, .loop
ld a, [W_XCOORD]
add $5
add 5
cp e
jr c, .asm_74824
jr c, .loop
scf
ret
Func_7486b: ; 7486b (1d:486b)
sub $5
Sub5ClampTo0: ; 7486b (1d:486b)
; subtract 5 but clamp to 0
sub 5
cp $f0
ret c
xor a

View file

@ -1216,11 +1216,11 @@ ItemUseMedicine: ; dabb (3:5abb)
ld bc,-19
add hl,bc ; hl now points to experience
; update experience to minimum for new level
ld a,[$ff96]
ld a,[hExperience]
ld [hli],a
ld a,[$ff97]
ld a,[hExperience + 1]
ld [hli],a
ld a,[$ff98]
ld a,[hExperience + 2]
ld [hl],a
pop hl
ld a,[wWhichPokemon]
@ -1618,8 +1618,8 @@ ItemUsePokeflute: ; e140 (3:6140)
jp PrintText
.inBattle
xor a
ld [wWhichTrade],a ; initialize variable that indicates if any pokemon were woken up to zero
ld b,~SLP & $FF
ld [wWereAnyMonsAsleep],a
ld b,~SLP & $ff
ld hl,wPartyMon1Status
call WakeUpEntireParty
ld a,[W_ISINBATTLE]
@ -1638,7 +1638,7 @@ ItemUsePokeflute: ; e140 (3:6140)
and b ; remove Sleep status
ld [hl],a
call LoadScreenTilesFromBuffer2 ; restore saved screen
ld a,[wWhichTrade]
ld a,[wWereAnyMonsAsleep]
and a ; were any pokemon asleep before playing the flute?
ld hl,PlayedFluteNoEffectText
jp z,PrintText ; if no pokemon were asleep
@ -1662,9 +1662,9 @@ ItemUsePokeflute: ; e140 (3:6140)
; INPUT:
; hl must point to status of first pokemon in party (player's or enemy's)
; b must equal ~SLP
; [wWhichTrade] should be initialized to 0
; [wWereAnyMonsAsleep] should be initialized to 0
; OUTPUT:
; [wWhichTrade]: set to 1 if any pokemon were asleep
; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep
WakeUpEntireParty: ; e1e5 (3:61e5)
ld de,44
ld c,6
@ -1674,7 +1674,7 @@ WakeUpEntireParty: ; e1e5 (3:61e5)
and a,SLP ; is pokemon asleep?
jr z,.notAsleep
ld a,1
ld [wWhichTrade],a ; indicate that a pokemon had to be woken up
ld [wWereAnyMonsAsleep],a ; indicate that a pokemon had to be woken up
.notAsleep
pop af
and b ; remove Sleep status
@ -1874,7 +1874,7 @@ ItemUsePPRestore: ; e31e (3:631e)
ld a,[wWhichPokemon]
push af
ld a,[wcf91]
ld [wWhichTrade],a
ld [wPPRestoreItem],a
.chooseMon
xor a
ld [wUpdateSpritesEnabled],a
@ -1884,13 +1884,13 @@ ItemUsePPRestore: ; e31e (3:631e)
jr nc,.chooseMove
jp .itemNotUsed
.chooseMove
ld a,[wWhichTrade]
ld a,[wPPRestoreItem]
cp a,ELIXER
jp nc,.useElixir ; if Elixir or Max Elixir
ld a,$02
ld [wMoveMenuType],a
ld hl,RaisePPWhichTechniqueText
ld a,[wWhichTrade]
ld a,[wPPRestoreItem]
cp a,ETHER ; is it a PP Up?
jr c,.printWhichTechniqueMessage ; if so, print the raise PP message
ld hl,RestorePPWhichTechniqueText ; otherwise, print the restore PP message
@ -1911,7 +1911,7 @@ ItemUsePPRestore: ; e31e (3:631e)
call GetMoveName
call CopyStringToCF4B ; copy name to wcf4b
pop hl
ld a,[wWhichTrade]
ld a,[wPPRestoreItem]
cp a,ETHER
jr nc,.useEther ; if Ether or Max Ether
.usePPUp
@ -1973,7 +1973,7 @@ ItemUsePPRestore: ; e31e (3:631e)
add hl,bc ; hl now points to move's PP
ld a,[wd11e]
ld b,a ; b = max PP
ld a,[wWhichTrade]
ld a,[wPPRestoreItem]
cp a,MAX_ETHER
jr z,.fullyRestorePP
ld a,[hl] ; move PP
@ -2005,7 +2005,7 @@ ItemUsePPRestore: ; e31e (3:631e)
jr .storeNewAmount
.useElixir
; decrement the item ID so that ELIXER becomes ETHER and MAX_ELIXER becomes MAX_ETHER
ld hl,wWhichTrade
ld hl,wPPRestoreItem
dec [hl]
dec [hl]
xor a
@ -2701,13 +2701,13 @@ SendNewMonToBox: ; e7a4 (3:67a4)
ld d, a
callab CalcExperience
pop de
ld a, [H_NUMTOPRINT] ; (aliases: H_MULTIPLICAND)
ld a, [hExperience]
ld [de], a
inc de
ld a, [$ff97]
ld a, [hExperience + 1]
ld [de], a
inc de
ld a, [$ff98]
ld a, [hExperience + 2]
ld [de], a
inc de
xor a

View file

@ -12,7 +12,7 @@ PKMNLeaguePC: ; 0x7657e
ld [hTilesetType], a
ld [W_SPRITEFLIPPED], a
ld [wUpdateSpritesEnabled], a
ld [wTrainerScreenX], a
ld [wHoFTeamIndex2], a
ld [wHoFTeamNo], a
ld a, [wNumHoFTeams]
ld b, a
@ -27,13 +27,13 @@ PKMNLeaguePC: ; 0x7657e
ld hl, wHoFTeamNo
inc [hl]
push bc
ld a, [wTrainerScreenX]
ld [wHoFMonSpecies], a
ld a, [wHoFTeamIndex2]
ld [wHoFTeamIndex], a
callba LoadHallOfFameTeams
call LeaguePCShowTeam
pop bc
jr c, .doneShowingTeams
ld hl, wTrainerScreenX
ld hl, wHoFTeamIndex2
inc [hl]
ld a, [hl]
cp b

View file

@ -1,17 +1,16 @@
MainMenu: ; 5af2 (1:5af2)
; Check save file
call Func_5bff
call InitOptions
xor a
ld [wd08a],a
ld [wOptionsInitialized],a
inc a
ld [wd088],a
call Func_609e
jr nc,.next0
ld [wSaveFileStatus],a
call CheckForPlayerNameInSRAM
jr nc,.mainMenuLoop
; Predef 52 loads the save from SRAM to RAM
predef LoadSAV
.next0
.mainMenuLoop
ld c,20
call DelayFrames
xor a ; LINK_STATE_NONE
@ -30,9 +29,10 @@ MainMenu: ; 5af2 (1:5af2)
call LoadFontTilePatterns
ld hl,wd730
set 6,[hl]
ld a,[wd088]
ld a,[wSaveFileStatus]
cp a,1
jr z,.next1
jr z,.noSaveFile
; there's a save file
coord hl, 0, 0
ld b,6
ld c,13
@ -41,7 +41,7 @@ MainMenu: ; 5af2 (1:5af2)
ld de,ContinueText
call PlaceString
jr .next2
.next1
.noSaveFile
coord hl, 0, 0
ld b,4
ld c,13
@ -63,31 +63,33 @@ MainMenu: ; 5af2 (1:5af2)
ld [wTopMenuItemY],a
ld a,$B
ld [wMenuWatchedKeys],a
ld a,[wd088]
ld a,[wSaveFileStatus]
ld [wMaxMenuItem],a
call HandleMenuInput
bit 1,a
jp nz,LoadTitlescreenGraphics ; load title screen (gfx and arrangement)
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,[wd088]
ld a,[wSaveFileStatus]
cp a,2
jp z,.next3
inc b ; adjust MenuArrow_Counter
.next3
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
and a
jr z,.next4 ; if press_A on Continue
jr z,.choseContinue
cp a,1
jp z,Func_5d52 ; if press_A on NewGame
call DisplayOptionMenu ; if press_a on Options
jp z,StartNewGame
call DisplayOptionMenu
ld a,1
ld [wd08a],a
jp .next0
.next4
call ContinueGame
ld [wOptionsInitialized],a
jp .mainMenuLoop
.choseContinue
call DisplayContinueGameInfo
ld hl,wd126
set 5,[hl]
.inputLoop
@ -100,7 +102,7 @@ MainMenu: ; 5af2 (1:5af2)
bit 0,a
jr nz,.pressedA
bit 1,a
jp nz,.next0 ; pressedB
jp nz,.mainMenuLoop ; pressed B
jr .inputLoop
.pressedA
call GBPalWhiteOutWithDelay3
@ -122,10 +124,10 @@ MainMenu: ; 5af2 (1:5af2)
call SpecialWarpIn
jp SpecialEnterMap
Func_5bff: ; 5bff (1:5bff)
ld a,1
InitOptions: ; 5bff (1:5bff)
ld a,1 ; no delay
ld [wLetterPrintingDelayFlags],a
ld a,3
ld a,3 ; medium speed
ld [W_OPTIONS],a
ret
@ -301,7 +303,7 @@ LinkCanceledText: ; 5d4d (1:5d4d)
TX_FAR _LinkCanceledText
db "@"
Func_5d52: ; 5d52 (1:5d52)
StartNewGame: ; 5d52 (1:5d52)
ld hl, wd732
res 1, [hl]
call OakSpeech
@ -337,12 +339,12 @@ CableClubOptionsText: ; 5d97 (1:5d97)
db "COLOSSEUM", $4e
db "CANCEL@"
ContinueGame: ; 5db5 (1:5db5)
DisplayContinueGameInfo: ; 5db5 (1:5db5)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
coord hl, 4, 7
ld b, $8
ld c, $e
ld b, 8
ld c, 14
call TextBoxBorder
coord hl, 5, 9
ld de, SaveScreenInfoText
@ -351,12 +353,12 @@ ContinueGame: ; 5db5 (1:5db5)
ld de, wPlayerName
call PlaceString
coord hl, 17, 11
call Func_5e2f
call PrintNumBadges
coord hl, 16, 13
call Func_5e42
call PrintNumOwnedMons
coord hl, 13, 15
call Func_5e55
ld a, $1
call PrintPlayTime
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ld c, 30
jp DelayFrames
@ -377,17 +379,17 @@ PrintSaveScreenText: ; 5def (1:5def)
ld de, wPlayerName
call PlaceString
coord hl, 17, 4
call Func_5e2f
call PrintNumBadges
coord hl, 16, 6
call Func_5e42
call PrintNumOwnedMons
coord hl, 13, 8
call Func_5e55
call PrintPlayTime
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
ld c, 30
jp DelayFrames
Func_5e2f: ; 5e2f (1:5e2f)
PrintNumBadges: ; 5e2f (1:5e2f)
push hl
ld hl, W_OBTAINEDBADGES
ld b, $1
@ -397,7 +399,7 @@ Func_5e2f: ; 5e2f (1:5e2f)
ld bc, $102
jp PrintNumber
Func_5e42: ; 5e42 (1:5e42)
PrintNumOwnedMons: ; 5e42 (1:5e42)
push hl
ld hl, wPokedexOwned
ld b, wPokedexOwnedEnd - wPokedexOwned
@ -407,7 +409,7 @@ Func_5e42: ; 5e42 (1:5e42)
ld bc, $103
jp PrintNumber
Func_5e55: ; 5e55 (1:5e55)
PrintPlayTime: ; 5e55 (1:5e55)
ld de, W_PLAYTIMEHOURS + 1
ld bc, $103
call PrintNumber
@ -678,28 +680,32 @@ TextSpeedOptionData: ; 6096 (1:6096)
db 7 ; default X coordinate (Medium)
db $ff ; terminator
Func_609e: ; 609e (1:609e)
ld a, $a
ld [$0], a
CheckForPlayerNameInSRAM: ; 609e (1:609e)
; Check if the player name data in SRAM has a string terminator character
; (indicating that a name may have been saved there) and return whether it does
; in carry.
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
ld a, $1
ld [$6000], a
ld [$4000], a
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
ld b, $b
ld hl, $a598
.asm_60b0
ld hl, sPlayerName
.loop
ld a, [hli]
cp $50
jr z, .asm_60c1
cp "@"
jr z, .found
dec b
jr nz, .asm_60b0
jr nz, .loop
; not found
xor a
ld [$0], a
ld [$6000], a
ld [MBC1SRamEnable], a
ld [MBC1SRamBankingMode], a
and a
ret
.asm_60c1
.found
xor a
ld [$0], a
ld [$6000], a
ld [MBC1SRamEnable], a
ld [MBC1SRamBankingMode], a
scf
ret

View file

@ -71,8 +71,8 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
ld [wd11e],a
ld a,[wd11e]
push af
ld a,[wWhichTrade]
push af
ld a,[wDexMaxSeenMon]
push af ; this doesn't need to be preserved
ld hl,wPokedexSeen
call IsPokemonBitSet
ld b,2
@ -108,7 +108,7 @@ HandlePokedexSideMenu: ; 4006d (10:406d)
ld b,1
.exitSideMenu
pop af
ld [wWhichTrade],a
ld [wDexMaxSeenMon],a
pop af
ld [wd11e],a
pop af
@ -207,7 +207,7 @@ HandlePokedexListMenu: ; 40111 (10:4111)
jr .maxSeenPokemonLoop
.storeMaxSeenPokemon
ld a,b
ld [wWhichTrade],a ; max seen pokemon
ld [wDexMaxSeenMon],a
.loop
xor a
ld [H_AUTOBGTRANSFERENABLED],a
@ -218,7 +218,7 @@ HandlePokedexListMenu: ; 40111 (10:4111)
ld a,[wListScrollOffset]
ld [wd11e],a
ld d,7
ld a,[wWhichTrade]
ld a,[wDexMaxSeenMon]
cp a,7
jr nc,.printPokemonLoop
ld d,a
@ -294,9 +294,9 @@ HandlePokedexListMenu: ; 40111 (10:4111)
bit 7,a ; was Down pressed?
jr z,.checkIfRightPressed
.downPressed ; scroll down one row
ld a,[wWhichTrade]
ld a,[wDexMaxSeenMon]
cp a,7
jp c,.loop
jp c,.loop ; can't if the list is shorter than 7
sub a,7
ld b,a
ld a,[wListScrollOffset]
@ -309,9 +309,9 @@ HandlePokedexListMenu: ; 40111 (10:4111)
bit 4,a ; was Right pressed?
jr z,.checkIfLeftPressed
.rightPressed ; scroll down 7 rows
ld a,[wWhichTrade]
ld a,[wDexMaxSeenMon]
cp a,7
jp c,.loop
jp c,.loop ; can't if the list is shorter than 7
sub a,6
ld b,a
ld a,[wListScrollOffset]

View file

@ -231,18 +231,24 @@ HandlePrizeChoice: ; 528c6 (14:68c6)
pop af
ld b,a
call GivePokemon
; If either the party or box was full, wait after displaying message.
push af
ld a,[wccd3] ; XXX is there room?
ld a,[wAddedToParty]
and a
call z,WaitForTextScrollButtonPress
pop af
; If the mon couldn't be given to the player (because both the party and box
; were full), return without subtracting coins.
ret nc
.SubtractCoins
call LoadCoinsToSubtract
ld hl,hCoins + 1
ld de,wPlayerCoins + 1
ld c,$02 ; how many bytes
predef SubBCDPredef ; subtract coins (BCD daa operations)
predef SubBCDPredef
jp PrintPrizePrice
.BagFull
ld hl,PrizeRoomBagIsFullTextPtr

View file

@ -297,8 +297,8 @@ StatusScreen2: ; 12b57 (4:6b57)
push af
xor a
ld [hTilesetType], a
ld [$ffba], a
ld bc, $0005
ld [H_AUTOBGTRANSFERENABLED], a
ld bc, NUM_MOVES + 1
ld hl, wMoves
call FillMemory
ld hl, wLoadedMonMoves
@ -307,13 +307,13 @@ StatusScreen2: ; 12b57 (4:6b57)
call CopyData
callab FormatMovesString
coord hl, 9, 2
ld bc, $050a
lb bc, 5, 10
call ClearScreenArea ; Clear under name
coord hl, 19, 3
ld [hl], $78
coord hl, 0, 8
ld b, $8
ld c, $12
ld b, 8
ld c, 18
call TextBoxBorder ; Draw move container
coord hl, 2, 9
ld de, wMovesString
@ -387,9 +387,9 @@ StatusScreen2: ; 12b57 (4:6b57)
jr nz, .PrintPP
.PPDone
coord hl, 9, 3
ld de, EXPPointsText
ld de, StatusScreenExpText
call PlaceString
ld a, [wLoadedMonLevel] ; level
ld a, [wLoadedMonLevel]
push af
cp MAX_LEVEL
jr z, .Level100
@ -407,11 +407,11 @@ StatusScreen2: ; 12b57 (4:6b57)
coord hl, 12, 4
ld bc, $0307
call PrintNumber ; exp
call .asm_12c86
call CalcExpToLevelUp
ld de, wLoadedMonExp
coord hl, 7, 6
ld bc, $0307
call PrintNumber
call PrintNumber ; exp needed to level up
coord hl, 9, 0
call StatusScreen_ClearName
coord hl, 9, 1
@ -422,7 +422,7 @@ StatusScreen2: ; 12b57 (4:6b57)
coord hl, 9, 1
call PlaceString
ld a, $1
ld [$ffba], a
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call WaitForTextScrollButtonPress ; wait for button
pop af
@ -433,25 +433,26 @@ StatusScreen2: ; 12b57 (4:6b57)
ld [$ff24], a
call GBPalWhiteOut
jp ClearScreen
.asm_12c86 ; This does some magic with lvl/exp?
ld a, [wLoadedMonLevel] ; Load level
CalcExpToLevelUp: ; 12c86 (4:6c86)
ld a, [wLoadedMonLevel]
cp MAX_LEVEL
jr z, .asm_12ca7 ; If 100
jr z, .atMaxLevel
inc a
ld d, a
callab CalcExperience
ld hl, wLoadedMonExp + 2
ld a, [$ff98]
ld a, [hExperience + 2]
sub [hl]
ld [hld], a
ld a, [$ff97]
ld a, [hExperience + 1]
sbc [hl]
ld [hld], a
ld a, [$ff96]
ld a, [hExperience]
sbc [hl]
ld [hld], a
ret
.asm_12ca7
.atMaxLevel
ld hl, wLoadedMonExp
xor a
ld [hli], a
@ -459,11 +460,9 @@ StatusScreen2: ; 12b57 (4:6b57)
ld [hl], a
ret
EXPPointsText: ; 12caf (4:6caf)
db "EXP POINTS", $4e
LevelUpText: ; 12cba (4:6cba)
db "LEVEL UP@"
StatusScreenExpText: ; 12caf (4:6caf)
db "EXP POINTS"
next "LEVEL UP@"
StatusScreen_ClearName: ; 12cc3 (4:6cc3)
ld bc, 10

View file

@ -19,9 +19,9 @@ SetDefaultNames: ; 60ca (1:60ca)
ld [W_OPTIONS], a
pop af
ld [wLetterPrintingDelayFlags], a
ld a, [wd08a]
ld a, [wOptionsInitialized]
and a
call z, Func_5bff
call z, InitOptions
ld hl, NintenText
ld de, wPlayerName
ld bc, $b

View file

@ -15,7 +15,7 @@ WriteDMACodeToHRAM:
DMARoutine:
; initiate DMA
ld a, wOAMBuffer / $100
ld [$ff46], a
ld [rDMA], a
; wait for DMA to finish
ld a, $28

View file

@ -1,9 +1,9 @@
HiddenItems: ; 76688 (1d:6688)
ld hl, HiddenItemCoords
call Func_76857
ld [wTrainerScreenX], a
ld hl, wd6f0
ld a, [wTrainerScreenX]
call FindHiddenItemOrCoinsIndex
ld [wHiddenItemOrCoinsIndex], a
ld hl, wObtainedHiddenItemsFlags
ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, $2
predef FlagActionPredef
@ -11,9 +11,9 @@ HiddenItems: ; 76688 (1d:6688)
and a
ret nz
call EnableAutoTextBoxDrawing
ld a, $1
ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
ld a, [wWhichTrade] ; item ID
ld a, [wHiddenObjectFunctionArgument] ; item ID
ld [wd11e], a
call GetItemName
tx_pre_jump FoundHiddenItemText
@ -23,12 +23,12 @@ INCLUDE "data/hidden_item_coords.asm"
FoundHiddenItemText: ; 7675b (1d:675b)
TX_FAR _FoundHiddenItemText
TX_ASM
ld a, [wWhichTrade] ; item ID
ld a, [wHiddenObjectFunctionArgument] ; item ID
ld b, a
ld c, 1
call GiveItem
jr nc, .BagFull
ld hl, wd6f0
ld hl, wObtainedHiddenItemsFlags
ld a, [wTrainerScreenX]
ld c, a
ld b, $1
@ -56,10 +56,10 @@ HiddenCoins: ; 76799 (1d:6799)
and a
ret z
ld hl, HiddenCoinCoords
call Func_76857
ld [wTrainerScreenX], a
ld hl, wd6fe
ld a, [wTrainerScreenX]
call FindHiddenItemOrCoinsIndex
ld [wHiddenItemOrCoinsIndex], a
ld hl, wObtainedHiddenCoinsFlags
ld a, [wHiddenItemOrCoinsIndex]
ld c, a
ld b, $2
predef FlagActionPredef
@ -70,7 +70,7 @@ HiddenCoins: ; 76799 (1d:6799)
ld [hCoins - 1], a
ld [hCoins], a
ld [hCoins + 1], a
ld a, [wWhichTrade]
ld a, [wHiddenObjectFunctionArgument]
sub COIN
cp 10
jr z, .bcd10
@ -99,7 +99,7 @@ HiddenCoins: ; 76799 (1d:6799)
ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
ld hl, wd6fe
ld hl, wObtainedHiddenCoinsFlags
ld a, [wTrainerScreenX]
ld c, a
ld b, $1
@ -130,31 +130,31 @@ DroppedHiddenCoinsText: ; 7684d (1d:684d)
TX_FAR _DroppedHiddenCoinsText
db "@"
Func_76857: ; 76857 (1d:6857)
ld a, [wTrainerScreenY]
FindHiddenItemOrCoinsIndex: ; 76857 (1d:6857)
ld a, [wHiddenObjectY]
ld d, a
ld a, [wTrainerScreenX]
ld a, [wHiddenObjectX]
ld e, a
ld a, [W_CURMAP]
ld b, a
ld c, $ff
ld c, -1
.loop
inc c
ld a, [hli]
cp $ff ; end of the list?
ret z ; if so, we're done here
cp b
jr nz, .asm_76877
jr nz, .next1
ld a, [hli]
cp d
jr nz, .asm_76878
jr nz, .next2
ld a, [hli]
cp e
jr nz, .loop
ld a, c
ret
.asm_76877
.next1
inc hl
.asm_76878
.next2
inc hl
jr .loop

View file

@ -1,4 +1,4 @@
Func_46981: ; 46981 (11:6981)
IsPlayerOnDungeonWarp: ; 46981 (11:6981)
xor a
ld [wWhichDungeonWarp], a
ld a, [wd72d]
@ -6,7 +6,7 @@ Func_46981: ; 46981 (11:6981)
ret nz
call ArePlayerCoordsInArray
ret nc
ld a, [wWhichTrade]
ld a, [wCoordIndex]
ld [wWhichDungeonWarp], a
ld hl, wd72d
set 4, [hl]
@ -58,7 +58,7 @@ CheckForHiddenObject: ; 469a0 (11:69a0)
ld [wHiddenObjectX], a
ld c, a
call CheckIfCoordsInFrontOfPlayerMatch
ld a, [$ffea]
ld a, [hCoordsInFrontOfPlayerMatch]
and a
jr z, .foundMatchingObject
inc hl
@ -85,7 +85,7 @@ CheckForHiddenObject: ; 469a0 (11:69a0)
ret
; checks if the coordinates in front of the player's sprite match Y in b and X in c
; [$ffea] = $00 if they match, $ff if they don't match
; [hCoordsInFrontOfPlayerMatch] = $00 if they match, $ff if they don't match
CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01)
ld a, [wSpriteStateData1 + 9] ; player's sprite facing direction
cp SPRITE_FACING_UP
@ -127,7 +127,7 @@ CheckIfCoordsInFrontOfPlayerMatch: ; 46a01 (11:6a01)
.didNotMatch
ld a, $ff
.done
ld [$ffea], a
ld [hCoordsInFrontOfPlayerMatch], a
ret
INCLUDE "data/hidden_objects.asm"

View file

@ -210,9 +210,8 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
.moveDown
ld de, 2*SCREEN_WIDTH
add hl, de ; move tile pointer two rows down
ld de, $100
ld bc, $400
lb de, 1, 0
lb bc, 4, SPRITE_FACING_DOWN
jr TryWalking
.notDown
cp $80 ; $40 <= a < $80: up (or right)
@ -223,8 +222,8 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
.moveUp
ld de, -2*SCREEN_WIDTH
add hl, de ; move tile pointer two rows up
ld de, $ff00
ld bc, $804
lb de, -1, 0
lb bc, 8, SPRITE_FACING_UP
jr TryWalking
.notUp
cp $c0 ; $80 <= a < $c0: left (or up)
@ -235,8 +234,8 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
.moveLeft
dec hl
dec hl ; move tile pointer two columns left
ld de, $ff
ld bc, $208
lb de, 0, -1
lb bc, 2, SPRITE_FACING_LEFT
jr TryWalking
.notLeft ; $c0 <= a: right (or down)
ld a, [wCurSpriteMovement2]
@ -245,8 +244,8 @@ UpdateNPCSprite: ; 4ed1 (1:4ed1)
.moveRight
inc hl
inc hl ; move tile pointer two columns right
ld de, $1
ld bc, $10c
lb de, 0, 1
lb bc, 1, SPRITE_FACING_RIGHT
jr TryWalking
; changes facing direction by zeroing the movement delta and calling TryWalking

View file

@ -328,10 +328,10 @@ SendSGBPacket: ; 71feb (1c:5feb)
ld [$fff9],a
; send RESET signal (P14=LOW, P15=LOW)
xor a
ld [$ff00],a
ld [rJOYP],a
; set P14=HIGH, P15=HIGH
ld a,$30
ld [$ff00],a
ld [rJOYP],a
;load length of packets (16 bytes)
ld b,$10
.nextByte
@ -348,10 +348,10 @@ SendSGBPacket: ; 71feb (1c:5feb)
; else (if 0th bit is zero) set P14=LOW,P15=HIGH (send bit 0)
ld a,$20
.next0
ld [$ff00],a
ld [rJOYP],a
; must set P14=HIGH,P15=HIGH between each "pulse"
ld a,$30
ld [$ff00],a
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
@ -362,10 +362,10 @@ SendSGBPacket: ; 71feb (1c:5feb)
jr nz,.nextByte
; send bit 1 as a "stop bit" (end of parameter data)
ld a,$20
ld [$ff00],a
ld [rJOYP],a
; set P14=HIGH,P15=HIGH
ld a,$30
ld [$ff00],a
ld [rJOYP],a
xor a
ld [$fff9],a
; wait for about 70000 cycles
@ -448,38 +448,38 @@ CheckSGB: ; 7209b (1c:609b)
ld [$fff9], a
ei
call Wait7000
ld a, [rJOYP] ; $ff0
ld a, [rJOYP]
and $3
cp $3
jr nz, .asm_720fd
ld a, $20
ld [rJOYP], a ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld [rJOYP], a
ld a, [rJOYP]
ld a, [rJOYP]
call Wait7000
call Wait7000
ld a, $30
ld [rJOYP], a ; $ff0
ld [rJOYP], a
call Wait7000
call Wait7000
ld a, $10
ld [rJOYP], a ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld [rJOYP], a
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
call Wait7000
call Wait7000
ld a, $30
ld [rJOYP], a ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld a, [rJOYP] ; $ff0
ld [rJOYP], a
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
call Wait7000
call Wait7000
ld a, [rJOYP] ; $ff0
ld a, [rJOYP]
and $3
cp $3
jr nz, .asm_720fd

View file

@ -111,7 +111,7 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef InternalClockTradeAnim
add_predef TrainerEngage
add_predef IndexToPokedex
add_predef DisplayPicCenteredOrUpperRight; 3B display pic?
add_predef DisplayPicCenteredOrUpperRight
add_predef UsedCut
add_predef ShowPokedexData
add_predef WriteMonMoves
@ -128,15 +128,15 @@ PredefPointers:: ; 4fe79 (13:7e79)
add_predef DrawEnemyHUDAndHPBar
add_predef LoadTownMap_Nest
add_predef PrintMonType
add_predef EmotionBubble; 4C player exclamation
add_predef EmotionBubble
add_predef EmptyFunc3; return immediately
add_predef AskName
add_predef PewterGuys
add_predef SaveSAVtoSRAM2
add_predef LoadSAVCheckSum2
add_predef LoadSAV2
add_predef LoadSAV
add_predef SaveSAVtoSRAM1
add_predef DoInGameTradeDialogue ; 54 initiate trade
add_predef DoInGameTradeDialogue
add_predef HallOfFamePC
add_predef DisplayDexRating
dbw $1E, _LeaveMapAnim ; wrong bank

View file

@ -4,11 +4,11 @@ LoadSAV: ; 735e8 (1c:75e8)
call ClearScreen
call LoadFontTilePatterns
call LoadTextBoxTilePatterns
call LoadSAVCheckSum
call LoadSAV0
jr c, .badsum
call LoadSAVCheckSum1
call LoadSAV1
jr c, .badsum
call LoadSAVCheckSum2
call LoadSAV2
jr c, .badsum
ld a, $2 ; good checksum
jr .goodsum
@ -24,14 +24,14 @@ LoadSAV: ; 735e8 (1c:75e8)
res 6, [hl]
ld a, $1 ; bad checksum
.goodsum
ld [wd088], a ; checksum flag
ld [wSaveFileStatus], a
ret
FileDataDestroyedText: ; 7361e (1c:761e)
TX_FAR _FileDataDestroyedText
db "@"
LoadSAVCheckSum: ; 73623 (1c:7623)
LoadSAV0: ; 73623 (1c:7623)
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
ld a, $1
@ -43,7 +43,9 @@ LoadSAVCheckSum: ; 73623 (1c:7623)
ld c, a
ld a, [sMainDataCheckSum] ; SAV's checksum
cp c
jp z, .Func_73652
jp z, .checkSumsMatched
; If the computed checksum didn't match the saved on, try again.
ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName
call SAVCheckSum
@ -52,7 +54,7 @@ LoadSAVCheckSum: ; 73623 (1c:7623)
cp c
jp nz, SAVBadCheckSum
.Func_73652 ; 73652 (1c:7652)
.checkSumsMatched
ld hl, sPlayerName
ld de, wPlayerName
ld bc, 11
@ -76,7 +78,7 @@ LoadSAVCheckSum: ; 73623 (1c:7623)
and a
jp SAVGoodChecksum
LoadSAVCheckSum1: ; 73690 (1c:7690)
LoadSAV1: ; 73690 (1c:7690)
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
ld a, $1
@ -96,7 +98,7 @@ LoadSAVCheckSum1: ; 73690 (1c:7690)
and a
jp SAVGoodChecksum
LoadSAVCheckSum2: ; 736bd (1c:76bd)
LoadSAV2: ; 736bd (1c:76bd)
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
ld a, $1
@ -129,10 +131,11 @@ SAVGoodChecksum: ; 736f8 (1c:76f8)
ld [MBC1SRamEnable], a
ret
Func_73701: ; 73701 (1c:7701)
call LoadSAVCheckSum
call LoadSAVCheckSum1
jp LoadSAVCheckSum2
LoadSAVIgnoreBadCheckSum: ; 73701 (1c:7701)
; unused function that loads save data and ignores bad checksums
call LoadSAV0
call LoadSAV1
jp LoadSAV2
SaveSAV: ; 7370a (1c:770a)
callba PrintSaveScreenText
@ -140,7 +143,7 @@ SaveSAV: ; 7370a (1c:770a)
call SaveSAVConfirm
and a ;|0 = Yes|1 = No|
ret nz
ld a,[wd088]
ld a,[wSaveFileStatus]
dec a
jr z,.save
call SAVCheckRandomID
@ -270,14 +273,14 @@ SaveSAVtoSRAM2: ; 7380f (1c:780f)
SaveSAVtoSRAM: ; 73848 (1c:7848)
ld a, $2
ld [wd088], a
ld [wSaveFileStatus], a
call SaveSAVtoSRAM0
call SaveSAVtoSRAM1
jp SaveSAVtoSRAM2
SAVCheckSum: ; 73856 (1c:7856)
;Check Sum (result[1 byte] is complemented)
ld d, $0
ld d, 0
.loop
ld a, [hli]
add d
@ -290,11 +293,11 @@ SAVCheckSum: ; 73856 (1c:7856)
cpl
ret
Func_73863: ; 73863 (1c:7863)
CalcIndividualBoxCheckSums: ; 73863 (1c:7863)
ld hl, sBox1 ; sBox7
ld de, sBoxes1CheckSum2 ; sBoxes2CheckSum2
ld de, sBank2IndividualBoxChecksums ; sBank3IndividualBoxChecksums
ld b, NUM_BOXES / 2
.asm_7386b
.loop
push bc
push de
ld bc, wBoxMonNicksEnd - W_NUMINBOX
@ -304,21 +307,23 @@ Func_73863: ; 73863 (1c:7863)
inc de
pop bc
dec b
jr nz, .asm_7386b
jr nz, .loop
ret
Func_7387b: ; 7387b (1c:787b)
ld hl, PointerTable_73895
GetBoxSRAMLocation: ; 7387b (1c:787b)
; in: a = box num
; out: b = box SRAM bank, hl = pointer to start of box
ld hl, BoxSRAMPointerTable
ld a, [wCurrentBoxNum]
and $7f
cp NUM_BOXES / 2
ld b, $2
jr c, .asm_7388c
ld b, 2
jr c, .next
inc b
sub NUM_BOXES / 2
.asm_7388c
.next
ld e, a
ld d, $0
ld d, 0
add hl, de
add hl, de
ld a, [hli]
@ -326,7 +331,7 @@ Func_7387b: ; 7387b (1c:787b)
ld l, a
ret
PointerTable_73895: ; 73895 (1c:7895)
BoxSRAMPointerTable: ; 73895 (1c:7895)
dw sBox1 ; sBox7
dw sBox2 ; sBox8
dw sBox3 ; sBox9
@ -342,9 +347,9 @@ ChangeBox:: ; 738a1 (1c:78a1)
and a
ret nz ; return if No was chosen
ld hl, wCurrentBoxNum
bit 7, [hl]
call z, Func_73a29
call Func_7393f
bit 7, [hl] ; is it the first time player is changing the box?
call z, EmptyAllSRAMBoxes ; if so, empty all boxes in SRAM
call DisplayChangeBoxMenu
call UpdateSprites
ld hl, hFlags_0xFFF6
set 1, [hl]
@ -353,17 +358,17 @@ ChangeBox:: ; 738a1 (1c:78a1)
res 1, [hl]
bit 1, a
ret nz
call Func_7387b
call GetBoxSRAMLocation
ld e, l
ld d, h
ld hl, W_NUMINBOX
call Func_7390e
call CopyBoxToOrFromSRAM ; copy old box from WRAM to SRAM
ld a, [wCurrentMenuItem]
set 7, a
ld [wCurrentBoxNum], a
call Func_7387b
call GetBoxSRAMLocation
ld de, W_NUMINBOX
call Func_7390e
call CopyBoxToOrFromSRAM ; copy new box from SRAM to WRAM
ld hl, W_MAPTEXTPTR
ld de, wChangeBoxSavedMapTextPointer
ld a, [hli]
@ -384,7 +389,8 @@ WhenYouChangeBoxText: ; 73909 (1c:7909)
TX_FAR _WhenYouChangeBoxText
db "@"
Func_7390e: ; 7390e (1c:790e)
CopyBoxToOrFromSRAM: ; 7390e (1c:790e)
; copy an entire box from hl to de with b as the SRAM bank
push hl
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
@ -395,30 +401,33 @@ Func_7390e: ; 7390e (1c:790e)
ld bc, wBoxMonNicksEnd - W_NUMINBOX
call CopyData
pop hl
; mark the memory that the box was copied from as am empty box
xor a
ld [hli], a
dec a
ld [hl], a
ld hl, sBox1 ; sBox7
ld bc, sBoxes1CheckSum - sBox1
ld bc, sBank2AllBoxesChecksum - sBox1
call SAVCheckSum
ld [sBoxes1CheckSum], a ; sBoxes2CheckSum
call Func_73863
ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum
call CalcIndividualBoxCheckSums
xor a
ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a
ret
Func_7393f: ; 7393f (1c:793f)
DisplayChangeBoxMenu: ; 7393f (1c:793f)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld a, $3
ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a
ld a, $b
ld a, 11
ld [wMaxMenuItem], a
ld a, $1
ld a, 1
ld [wTopMenuItemY], a
ld a, $c
ld a, 12
ld [wTopMenuItemX], a
xor a
ld [wMenuWatchMovingOutOfBounds], a
@ -427,14 +436,14 @@ Func_7393f: ; 7393f (1c:793f)
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
coord hl, 0, 0
ld b, $2
ld c, $9
ld b, 2
ld c, 9
call TextBoxBorder
ld hl, ChooseABoxText
call PrintText
coord hl, 11, 0
ld b, $c
ld c, $7
ld b, 12
ld c, 7
call TextBoxBorder
ld hl, hFlags_0xFFF6
set 2, [hl]
@ -446,37 +455,37 @@ Func_7393f: ; 7393f (1c:793f)
ld a, [wCurrentBoxNum]
and $7f
cp 9
jr c, .asm_739a6
jr c, .singleDigitBoxNum
sub 9
coord hl, 8, 2
ld [hl], "1"
add "0"
jr .asm_739a8
.asm_739a6
jr .next
.singleDigitBoxNum
add "1"
.asm_739a8
.next
Coorda 9, 2
coord hl, 1, 2
ld de, BoxNoText
call PlaceString
call Func_73a84
call GetMonCountsForAllBoxes
coord hl, 18, 1
ld de, wWhichTrade
ld de, wBoxMonCounts
ld bc, SCREEN_WIDTH
ld a, $c
.asm_739c2
.loop
push af
ld a, [de]
and a
jr z, .asm_739c9
ld [hl], $78
.asm_739c9
and a ; is the box empty?
jr z, .skipPlacingPokeball
ld [hl], $78 ; place pokeball tile next to box name if box not empty
.skipPlacingPokeball
add hl, bc
inc de
pop af
dec a
jr nz, .asm_739c2
ld a, $1
jr nz, .loop
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
ret
@ -501,51 +510,54 @@ BoxNames: ; 739d9 (1c:79d9)
BoxNoText: ; 73a21 (1c:7a21)
db "BOX No.@"
Func_73a29: ; 73a29 (1c:7a29)
EmptyAllSRAMBoxes: ; 73a29 (1c:7a29)
; marks all boxes in SRAM as empty (initialisation for the first time the
; player changes the box)
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
ld a, $1
ld [MBC1SRamBankingMode], a
ld a, $2
ld a, 2
ld [MBC1SRamBank], a
call Func_73a4b
ld a, $3
call EmptySRAMBoxesInBank
ld a, 3
ld [MBC1SRamBank], a
call Func_73a4b
call EmptySRAMBoxesInBank
xor a
ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a
ret
Func_73a4b: ; 73a4b (1c:7a4b)
EmptySRAMBoxesInBank: ; 73a4b (1c:7a4b)
; marks every box in the current SRAM bank as empty
ld hl, sBox1 ; sBox7
call Func_73a7f
call EmptySRAMBox
ld hl, sBox2 ; sBox8
call Func_73a7f
call EmptySRAMBox
ld hl, sBox3 ; sBox9
call Func_73a7f
call EmptySRAMBox
ld hl, sBox4 ; sBox10
call Func_73a7f
call EmptySRAMBox
ld hl, sBox5 ; sBox11
call Func_73a7f
call EmptySRAMBox
ld hl, sBox6 ; sBox12
call Func_73a7f
call EmptySRAMBox
ld hl, sBox1 ; sBox7
ld bc, sBoxes1CheckSum - sBox1
ld bc, sBank2AllBoxesChecksum - sBox1
call SAVCheckSum
ld [sBoxes1CheckSum], a ; sBoxes2CheckSum
call Func_73863
ld [sBank2AllBoxesChecksum], a ; sBank3AllBoxesChecksum
call CalcIndividualBoxCheckSums
ret
Func_73a7f: ; 73a7f (1c:7a7f)
EmptySRAMBox: ; 73a7f (1c:7a7f)
xor a
ld [hli], a
dec a
ld [hl], a
ret
Func_73a84: ; 73a84 (1c:7a84)
ld hl, wWhichTrade
GetMonCountsForAllBoxes: ; 73a84 (1c:7a84)
ld hl, wBoxMonCounts
push hl
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
@ -553,24 +565,27 @@ Func_73a84: ; 73a84 (1c:7a84)
ld [MBC1SRamBankingMode], a
ld a, $2
ld [MBC1SRamBank], a
call Func_73ab8
call GetMonCountsForBoxesInBank
ld a, $3
ld [MBC1SRamBank], a
call Func_73ab8
call GetMonCountsForBoxesInBank
xor a
ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a
pop hl
; copy the count for the current box from WRAM
ld a, [wCurrentBoxNum]
and $7f
ld c, a
ld b, $0
ld b, 0
add hl, bc
ld a, [W_NUMINBOX]
ld [hl], a
ret
Func_73ab8: ; 73ab8 (1c:7ab8)
GetMonCountsForBoxesInBank: ; 73ab8 (1c:7ab8)
ld a, [sBox1] ; sBox7
ld [hli], a
ld a, [sBox2] ; sBox8
@ -646,7 +661,7 @@ SaveHallOfFameTeams: ; 73b0d (1c:7b0d)
LoadHallOfFameTeams: ; 73b3f (1c:7b3f)
ld hl, sHallOfFame
ld bc, HOF_TEAM
ld a, [wWhichTrade]
ld a, [wHoFTeamIndex]
call AddNTimes
ld de, wcc5b
ld bc, HOF_TEAM

View file

@ -867,7 +867,7 @@ LoadSlotMachineTiles: ; 378a8 (d:78a8)
ld bc, $00f0
call CopyData
call EnableLCD
ld hl, wTrainerEngageDistance
ld hl, wSlotMachineWheel1Offset
ld a, $1c
ld [hli], a
ld [hli], a

View file

@ -21,7 +21,7 @@ SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
ld [wc0ef], a
ld [wc0f0], a
LoadTitlescreenGraphics: ; 42dd (1:42dd)
DisplayTitleScreen: ; 42dd (1:42dd)
call GBPalWhiteOut
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a