diff options
| author | xCrystal <rgr.crystal@gmail.com> | 2017-12-30 01:54:27 +0100 | 
|---|---|---|
| committer | xCrystal <rgr.crystal@gmail.com> | 2017-12-30 01:54:27 +0100 | 
| commit | 237aeb8fbdb204948d611830565d4a00c6b0ab70 (patch) | |
| tree | 94dea41b4af4a3374a1a1e2f56665cff2ea5baa9 /engine | |
| parent | 94b9a86c8b9b6ea29653e98921205056790d6617 (diff) | |
Add space between arguments in assembly instructions and remove redundant a in instructions like add a, x
Diffstat (limited to 'engine')
36 files changed, 4675 insertions, 4675 deletions
| diff --git a/engine/HoF_room_pc.asm b/engine/HoF_room_pc.asm index 82aa6d52..fb196486 100755 --- a/engine/HoF_room_pc.asm +++ b/engine/HoF_room_pc.asm @@ -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" diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index e17a651a..76d4f464 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -1,202 +1,202 @@  ; Draws a "frame block". Frame blocks are blocks of tiles that are put  ; together to form frames in battle animations.  DrawFrameBlock: -	ld l,c -	ld h,b -	ld a,[hli] -	ld [wNumFBTiles],a -	ld a,[wFBDestAddr + 1] -	ld e,a -	ld a,[wFBDestAddr] -	ld d,a +	ld l, c +	ld h, b +	ld a, [hli] +	ld [wNumFBTiles], a +	ld a, [wFBDestAddr + 1] +	ld e, a +	ld a, [wFBDestAddr] +	ld d, a  	xor a -	ld [wFBTileCounter],a ; loop counter +	ld [wFBTileCounter], a ; loop counter  .loop -	ld a,[wFBTileCounter] +	ld a, [wFBTileCounter]  	inc a -	ld [wFBTileCounter],a -	ld a,[wSubAnimTransform] +	ld [wFBTileCounter], a +	ld a, [wSubAnimTransform]  	dec a -	jr z,.flipHorizontalAndVertical   ; 1 +	jr z, .flipHorizontalAndVertical   ; 1  	dec a -	jp z,.flipHorizontalTranslateDown ; 2 +	jp z, .flipHorizontalTranslateDown ; 2  	dec a -	jr z,.flipBaseCoords              ; 3 +	jr z, .flipBaseCoords              ; 3  .noTransformation -	ld a,[wBaseCoordY] +	ld a, [wBaseCoordY]  	add [hl] -	ld [de],a ; store Y +	ld [de], a ; store Y  	inc hl  	inc de -	ld a,[wBaseCoordX] +	ld a, [wBaseCoordX]  	jr .finishCopying  .flipBaseCoords -	ld a,[wBaseCoordY] -	ld b,a -	ld a,136 +	ld a, [wBaseCoordY] +	ld b, a +	ld a, 136  	sub b ; flip Y base coordinate  	add [hl] ; Y offset -	ld [de],a ; store Y +	ld [de], a ; store Y  	inc hl  	inc de -	ld a,[wBaseCoordX] -	ld b,a -	ld a,168 +	ld a, [wBaseCoordX] +	ld b, a +	ld a, 168  	sub b ; flip X base coordinate  .finishCopying ; finish copying values to OAM (when [wSubAnimTransform] not 1 or 2)  	add [hl] ; X offset -	ld [de],a ; store X +	ld [de], a ; store X  	inc hl  	inc de -	ld a,[hli] -	add a,$31 ; base tile ID for battle animations -	ld [de],a ; store tile ID +	ld a, [hli] +	add $31 ; base tile ID for battle animations +	ld [de], a ; store tile ID  	inc de -	ld a,[hli] -	ld [de],a ; store flags +	ld a, [hli] +	ld [de], a ; store flags  	inc de  	jp .nextTile  .flipHorizontalAndVertical -	ld a,[wBaseCoordY] +	ld a, [wBaseCoordY]  	add [hl] ; Y offset -	ld b,a -	ld a,136 +	ld b, a +	ld a, 136  	sub b ; flip Y coordinate -	ld [de],a ; store Y +	ld [de], a ; store Y  	inc hl  	inc de -	ld a,[wBaseCoordX] +	ld a, [wBaseCoordX]  	add [hl] ; X offset -	ld b,a -	ld a,168 +	ld b, a +	ld a, 168  	sub b ; flip X coordinate -	ld [de],a ; store X +	ld [de], a ; store X  	inc hl  	inc de -	ld a,[hli] -	add a,$31 ; base tile ID for battle animations -	ld [de],a ; store tile ID +	ld a, [hli] +	add $31 ; base tile ID for battle animations +	ld [de], a ; store tile ID  	inc de  ; toggle horizontal and vertical flip -	ld a,[hli] ; flags +	ld a, [hli] ; flags  	and a -	ld b,OAM_VFLIP | OAM_HFLIP -	jr z,.storeFlags1 -	cp a,OAM_HFLIP -	ld b,OAM_VFLIP -	jr z,.storeFlags1 -	cp a,OAM_VFLIP -	ld b,OAM_HFLIP -	jr z,.storeFlags1 -	ld b,0 +	ld b, OAM_VFLIP | OAM_HFLIP +	jr z, .storeFlags1 +	cp OAM_HFLIP +	ld b, OAM_VFLIP +	jr z, .storeFlags1 +	cp OAM_VFLIP +	ld b, OAM_HFLIP +	jr z, .storeFlags1 +	ld b, 0  .storeFlags1 -	ld a,b -	ld [de],a +	ld a, b +	ld [de], a  	inc de  	jp .nextTile  .flipHorizontalTranslateDown -	ld a,[wBaseCoordY] +	ld a, [wBaseCoordY]  	add [hl] -	add a,40 ; translate Y coordinate downwards -	ld [de],a ; store Y +	add 40 ; translate Y coordinate downwards +	ld [de], a ; store Y  	inc hl  	inc de -	ld a,[wBaseCoordX] +	ld a, [wBaseCoordX]  	add [hl] -	ld b,a -	ld a,168 +	ld b, a +	ld a, 168  	sub b ; flip X coordinate -	ld [de],a ; store X +	ld [de], a ; store X  	inc hl  	inc de -	ld a,[hli] -	add a,$31 ; base tile ID for battle animations -	ld [de],a ; store tile ID +	ld a, [hli] +	add $31 ; base tile ID for battle animations +	ld [de], a ; store tile ID  	inc de -	ld a,[hli] -	bit 5,a ; is horizontal flip enabled? -	jr nz,.disableHorizontalFlip +	ld a, [hli] +	bit 5, a ; is horizontal flip enabled? +	jr nz, .disableHorizontalFlip  .enableHorizontalFlip -	set 5,a +	set 5, a  	jr .storeFlags2  .disableHorizontalFlip -	res 5,a +	res 5, a  .storeFlags2 -	ld [de],a +	ld [de], a  	inc de  .nextTile -	ld a,[wFBTileCounter] -	ld c,a -	ld a,[wNumFBTiles] +	ld a, [wFBTileCounter] +	ld c, a +	ld a, [wNumFBTiles]  	cp c -	jp nz,.loop ; go back up if there are more tiles to draw +	jp nz, .loop ; go back up if there are more tiles to draw  .afterDrawingTiles -	ld a,[wFBMode] -	cp a,2 -	jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer -	ld a,[wSubAnimFrameDelay] -	ld c,a +	ld a, [wFBMode] +	cp 2 +	jr z, .advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer +	ld a, [wSubAnimFrameDelay] +	ld c, a  	call DelayFrames -	ld a,[wFBMode] -	cp a,3 -	jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer -	cp a,4 -	jr z,.done ; skip cleaning OAM buffer and don't advance the frame block destination address -	ld a,[wAnimationID] -	cp a,GROWL -	jr z,.resetFrameBlockDestAddr +	ld a, [wFBMode] +	cp 3 +	jr z, .advanceFrameBlockDestAddr ; skip cleaning OAM buffer +	cp 4 +	jr z, .done ; skip cleaning OAM buffer and don't advance the frame block destination address +	ld a, [wAnimationID] +	cp GROWL +	jr z, .resetFrameBlockDestAddr  	call AnimationCleanOAM  .resetFrameBlockDestAddr -	ld hl,wOAMBuffer ; OAM buffer -	ld a,l -	ld [wFBDestAddr + 1],a -	ld a,h -	ld [wFBDestAddr],a ; set destination address to beginning of OAM buffer +	ld hl, wOAMBuffer ; OAM buffer +	ld a, l +	ld [wFBDestAddr + 1], a +	ld a, h +	ld [wFBDestAddr], a ; set destination address to beginning of OAM buffer  	ret  .advanceFrameBlockDestAddr -	ld a,e -	ld [wFBDestAddr + 1],a -	ld a,d -	ld [wFBDestAddr],a +	ld a, e +	ld [wFBDestAddr + 1], a +	ld a, d +	ld [wFBDestAddr], a  .done  	ret  PlayAnimation:  	xor a -	ld [$FF8B],a ; it looks like nothing reads this -	ld [wSubAnimTransform],a -	ld a,[wAnimationID] ; get animation number +	ld [$FF8B], a ; it looks like nothing reads this +	ld [wSubAnimTransform], a +	ld a, [wAnimationID] ; get animation number  	dec a -	ld l,a -	ld h,0 -	add hl,hl -	ld de,AttackAnimationPointers  ; animation command stream pointers -	add hl,de -	ld a,[hli] -	ld h,[hl] -	ld l,a +	ld l, a +	ld h, 0 +	add hl, hl +	ld de, AttackAnimationPointers  ; animation command stream pointers +	add hl, de +	ld a, [hli] +	ld h, [hl] +	ld l, a  .animationLoop -	ld a,[hli] -	cp a,$FF -	jr z,.AnimationOver -	cp a,$C0 ; is this subanimation or a special effect? -	jr c,.playSubanimation +	ld a, [hli] +	cp $FF +	jr z, .AnimationOver +	cp $C0 ; is this subanimation or a special effect? +	jr c, .playSubanimation  .doSpecialEffect -	ld c,a -	ld de,SpecialEffectPointers +	ld c, a +	ld de, SpecialEffectPointers  .searchSpecialEffectTableLoop -	ld a,[de] +	ld a, [de]  	cp c -	jr z,.foundMatch +	jr z, .foundMatch  	inc de  	inc de  	inc de  	jr .searchSpecialEffectTableLoop  .foundMatch -	ld a,[hli] -	cp a,$FF ; is there a sound to play? -	jr z,.skipPlayingSound -	ld [wAnimSoundID],a ; store sound +	ld a, [hli] +	cp $FF ; is there a sound to play? +	jr z, .skipPlayingSound +	ld [wAnimSoundID], a ; store sound  	push hl  	push de  	call GetMoveSound @@ -206,50 +206,50 @@ PlayAnimation:  .skipPlayingSound  	push hl  	inc de -	ld a,[de] -	ld l,a +	ld a, [de] +	ld l, a  	inc de -	ld a,[de] -	ld h,a -	ld de,.nextAnimationCommand +	ld a, [de] +	ld h, a +	ld de, .nextAnimationCommand  	push de  	jp hl ; jump to special effect function  .playSubanimation -	ld c,a -	and a,%00111111 -	ld [wSubAnimFrameDelay],a +	ld c, a +	and %00111111 +	ld [wSubAnimFrameDelay], a  	xor a  	sla c  	rla  	sla c  	rla -	ld [wWhichBattleAnimTileset],a -	ld a,[hli] ; sound -	ld [wAnimSoundID],a ; store sound -	ld a,[hli] ; subanimation ID -	ld c,l -	ld b,h -	ld l,a -	ld h,0 -	add hl,hl -	ld de,SubanimationPointers -	add hl,de -	ld a,l -	ld [wSubAnimAddrPtr],a -	ld a,h -	ld [wSubAnimAddrPtr + 1],a -	ld l,c -	ld h,b +	ld [wWhichBattleAnimTileset], a +	ld a, [hli] ; sound +	ld [wAnimSoundID], a ; store sound +	ld a, [hli] ; subanimation ID +	ld c, l +	ld b, h +	ld l, a +	ld h, 0 +	add hl, hl +	ld de, SubanimationPointers +	add hl, de +	ld a, l +	ld [wSubAnimAddrPtr], a +	ld a, h +	ld [wSubAnimAddrPtr + 1], a +	ld l, c +	ld h, b  	push hl -	ld a,[rOBP0] +	ld a, [rOBP0]  	push af -	ld a,[wAnimPalette] -	ld [rOBP0],a +	ld a, [wAnimPalette] +	ld [rOBP0], a  	call LoadAnimationTileset  	call LoadSubanimation  	call PlaySubanimation  	pop af -	ld [rOBP0],a +	ld [rOBP0], a  .nextAnimationCommand  	pop hl  	jr .animationLoop @@ -257,22 +257,22 @@ PlayAnimation:  	ret  LoadSubanimation: -	ld a,[wSubAnimAddrPtr + 1] -	ld h,a -	ld a,[wSubAnimAddrPtr] -	ld l,a -	ld a,[hli] -	ld e,a -	ld a,[hl] -	ld d,a ; de = address of subanimation -	ld a,[de] -	ld b,a -	and a,31 -	ld [wSubAnimCounter],a ; number of frame blocks -	ld a,b -	and a,%11100000 -	cp a,5 << 5 ; is subanimation type 5? -	jr nz,.isNotType5 +	ld a, [wSubAnimAddrPtr + 1] +	ld h, a +	ld a, [wSubAnimAddrPtr] +	ld l, a +	ld a, [hli] +	ld e, a +	ld a, [hl] +	ld d, a ; de = address of subanimation +	ld a, [de] +	ld b, a +	and 31 +	ld [wSubAnimCounter], a ; number of frame blocks +	ld a, b +	and %11100000 +	cp 5 << 5 ; is subanimation type 5? +	jr nz, .isNotType5  .isType5  	call GetSubanimationTransform2  	jr .saveTransformation @@ -282,35 +282,35 @@ LoadSubanimation:  ; place the upper 3 bits of a into bits 0-2 of a before storing  	srl a  	swap a -	ld [wSubAnimTransform],a -	cp a,4 ; is the animation reversed? -	ld hl,0 -	jr nz,.storeSubentryAddr +	ld [wSubAnimTransform], a +	cp 4 ; is the animation reversed? +	ld hl, 0 +	jr nz, .storeSubentryAddr  ; if the animation is reversed, then place the initial subentry address at the end of the list of subentries -	ld a,[wSubAnimCounter] +	ld a, [wSubAnimCounter]  	dec a -	ld bc,3 +	ld bc, 3  .loop -	add hl,bc +	add hl, bc  	dec a -	jr nz,.loop +	jr nz, .loop  .storeSubentryAddr  	inc de -	add hl,de -	ld a,l -	ld [wSubAnimSubEntryAddr],a -	ld a,h -	ld [wSubAnimSubEntryAddr + 1],a +	add hl, de +	ld a, l +	ld [wSubAnimSubEntryAddr], a +	ld a, h +	ld [wSubAnimSubEntryAddr + 1], a  	ret  ; called if the subanimation type is not 5  ; sets the transform to 0 (i.e. no transform) if it's the player's turn  ; sets the transform to the subanimation type if it's the enemy's turn  GetSubanimationTransform1: -	ld b,a -	ld a,[H_WHOSETURN] +	ld b, a +	ld a, [H_WHOSETURN]  	and a -	ld a,b +	ld a, b  	ret nz  	xor a  	ret @@ -319,32 +319,32 @@ GetSubanimationTransform1:  ; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn  ; sets the transform to 0 (i.e. no transform) if it's the enemy's turn  GetSubanimationTransform2: -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	and a -	ld a,2 << 5 +	ld a, 2 << 5  	ret z  	xor a  	ret  ; loads tile patterns for battle animations  LoadAnimationTileset: -	ld a,[wWhichBattleAnimTileset] +	ld a, [wWhichBattleAnimTileset]  	add a  	add a -	ld hl,AnimationTilesetPointers -	ld e,a -	ld d,0 -	add hl,de -	ld a,[hli] -	ld [wTempTilesetNumTiles],a ; number of tiles -	ld a,[hli] -	ld e,a -	ld a,[hl] -	ld d,a ; de = address of tileset -	ld hl,vSprites + $310 +	ld hl, AnimationTilesetPointers +	ld e, a +	ld d, 0 +	add hl, de +	ld a, [hli] +	ld [wTempTilesetNumTiles], a ; number of tiles +	ld a, [hli] +	ld e, a +	ld a, [hl] +	ld d, a ; de = address of tileset +	ld hl, vSprites + $310  	ld b, BANK(AnimationTileset1) ; ROM bank -	ld a,[wTempTilesetNumTiles] -	ld c,a ; number of tiles +	ld a, [wTempTilesetNumTiles] +	ld c, a ; number of tiles  	jp CopyVideoData ; load tileset  AnimationTilesetPointers: @@ -381,12 +381,12 @@ MoveAnimation:  	push af  	call WaitForSoundToFinish  	call SetAnimationPalette -	ld a,[wAnimationID] +	ld a, [wAnimationID]  	and a  	jr z, .animationFinished  	; if throwing a Poké Ball, skip the regular animation code -	cp a,TOSS_ANIM +	cp TOSS_ANIM  	jr nz, .moveAnimation  	ld de, .animationFinished  	push de @@ -394,25 +394,25 @@ MoveAnimation:  .moveAnimation  	; check if battle animations are disabled in the options -	ld a,[wOptions] -	bit 7,a +	ld a, [wOptions] +	bit 7, a  	jr nz, .animationsDisabled  	call ShareMoveAnimations  	call PlayAnimation  	jr .next4  .animationsDisabled -	ld c,30 +	ld c, 30  	call DelayFrames  .next4  	call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)  .animationFinished  	call WaitForSoundToFinish  	xor a -	ld [wSubAnimSubEntryAddr],a -	ld [wUnusedD09B],a -	ld [wSubAnimTransform],a +	ld [wSubAnimSubEntryAddr], a +	ld [wUnusedD09B], a +	ld [wSubAnimTransform], a  	dec a -	ld [wAnimSoundID],a +	ld [wAnimSoundID], a  	pop af  	pop bc  	pop de @@ -421,42 +421,42 @@ MoveAnimation:  ShareMoveAnimations:  ; some moves just reuse animations from status conditions -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	and a  	ret z  	; opponent’s turn -	ld a,[wAnimationID] +	ld a, [wAnimationID] -	cp a,AMNESIA -	ld b,CONF_ANIM +	cp AMNESIA +	ld b, CONF_ANIM  	jr z, .replaceAnim -	cp a,REST -	ld b,SLP_ANIM +	cp REST +	ld b, SLP_ANIM  	ret nz  .replaceAnim -	ld a,b -	ld [wAnimationID],a +	ld a, b +	ld [wAnimationID], a  	ret  PlayApplyingAttackAnimation:  ; Generic animation that shows after the move's individual animation  ; Different animation depending on whether the move has an additional effect and on whose turn it is -	ld a,[wAnimationType] +	ld a, [wAnimationType]  	and a  	ret z  	dec a  	add a -	ld c,a -	ld b,0 -	ld hl,AnimationTypePointerTable -	add hl,bc -	ld a,[hli] -	ld h,[hl] -	ld l,a +	ld c, a +	ld b, 0 +	ld hl, AnimationTypePointerTable +	add hl, bc +	ld a, [hli] +	ld h, [hl] +	ld l, a  	jp hl  AnimationTypePointerTable: @@ -547,69 +547,69 @@ SetAnimationPalette:  	ret  PlaySubanimation: -	ld a,[wAnimSoundID] -	cp a,$FF -	jr z,.skipPlayingSound +	ld a, [wAnimSoundID] +	cp $FF +	jr z, .skipPlayingSound  	call GetMoveSound  	call PlaySound  .skipPlayingSound -	ld hl,wOAMBuffer ; base address of OAM buffer -	ld a,l -	ld [wFBDestAddr + 1],a -	ld a,h -	ld [wFBDestAddr],a -	ld a,[wSubAnimSubEntryAddr + 1] -	ld h,a -	ld a,[wSubAnimSubEntryAddr] -	ld l,a +	ld hl, wOAMBuffer ; base address of OAM buffer +	ld a, l +	ld [wFBDestAddr + 1], a +	ld a, h +	ld [wFBDestAddr], a +	ld a, [wSubAnimSubEntryAddr + 1] +	ld h, a +	ld a, [wSubAnimSubEntryAddr] +	ld l, a  .loop  	push hl -	ld c,[hl] ; frame block ID -	ld b,0 -	ld hl,FrameBlockPointers -	add hl,bc -	add hl,bc -	ld a,[hli] -	ld c,a -	ld a,[hli] -	ld b,a +	ld c, [hl] ; frame block ID +	ld b, 0 +	ld hl, FrameBlockPointers +	add hl, bc +	add hl, bc +	ld a, [hli] +	ld c, a +	ld a, [hli] +	ld b, a  	pop hl  	inc hl  	push hl -	ld e,[hl] ; base coordinate ID -	ld d,0 -	ld hl,FrameBlockBaseCoords  ; base coordinate table -	add hl,de -	add hl,de -	ld a,[hli] -	ld [wBaseCoordY],a -	ld a,[hl] -	ld [wBaseCoordX],a +	ld e, [hl] ; base coordinate ID +	ld d, 0 +	ld hl, FrameBlockBaseCoords  ; base coordinate table +	add hl, de +	add hl, de +	ld a, [hli] +	ld [wBaseCoordY], a +	ld a, [hl] +	ld [wBaseCoordX], a  	pop hl  	inc hl -	ld a,[hl] ; frame block mode -	ld [wFBMode],a +	ld a, [hl] ; frame block mode +	ld [wFBMode], a  	call DrawFrameBlock  	call DoSpecialEffectByAnimationId ; run animation-specific function (if there is one) -	ld a,[wSubAnimCounter] +	ld a, [wSubAnimCounter]  	dec a -	ld [wSubAnimCounter],a +	ld [wSubAnimCounter], a  	ret z -	ld a,[wSubAnimSubEntryAddr + 1] -	ld h,a -	ld a,[wSubAnimSubEntryAddr] -	ld l,a -	ld a,[wSubAnimTransform] -	cp a,4 ; is the animation reversed? -	ld bc,3 -	jr nz,.nextSubanimationSubentry -	ld bc,-3 +	ld a, [wSubAnimSubEntryAddr + 1] +	ld h, a +	ld a, [wSubAnimSubEntryAddr] +	ld l, a +	ld a, [wSubAnimTransform] +	cp 4 ; is the animation reversed? +	ld bc, 3 +	jr nz, .nextSubanimationSubentry +	ld bc, -3  .nextSubanimationSubentry -	add hl,bc -	ld a,h -	ld [wSubAnimSubEntryAddr + 1],a -	ld a,l -	ld [wSubAnimSubEntryAddr],a +	add hl, bc +	ld a, h +	ld [wSubAnimSubEntryAddr + 1], a +	ld a, l +	ld [wSubAnimSubEntryAddr], a  	jp .loop  AnimationCleanOAM: @@ -631,16 +631,16 @@ DoSpecialEffectByAnimationId:  	push hl  	push de  	push bc -	ld a,[wAnimationID] -	ld hl,AnimationIdSpecialEffects -	ld de,3 +	ld a, [wAnimationID] +	ld hl, AnimationIdSpecialEffects +	ld de, 3  	call IsInArray -	jr nc,.done +	jr nc, .done  	inc hl -	ld a,[hli] -	ld h,[hl] -	ld l,a -	ld de,.done +	ld a, [hli] +	ld h, [hl] +	ld l, a +	ld de, .done  	push de  	jp hl  .done @@ -726,38 +726,38 @@ AnimationIdSpecialEffects:  	db $FF ; terminator  DoBallTossSpecialEffects: -	ld a,[wcf91] -	cp a,3 ; is it a Master Ball or Ultra Ball? -	jr nc,.skipFlashingEffect +	ld a, [wcf91] +	cp 3 ; is it a Master Ball or Ultra Ball? +	jr nc, .skipFlashingEffect  .flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball -	ld a,[rOBP0] -	xor a,%00111100 ; complement colors 1 and 2 -	ld [rOBP0],a +	ld a, [rOBP0] +	xor %00111100 ; complement colors 1 and 2 +	ld [rOBP0], a  .skipFlashingEffect -	ld a,[wSubAnimCounter] -	cp a,11 ; is it the beginning of the subanimation? -	jr nz,.skipPlayingSound +	ld a, [wSubAnimCounter] +	cp 11 ; is it the beginning of the subanimation? +	jr nz, .skipPlayingSound  ; if it is the beginning of the subanimation, play a sound -	ld a,SFX_BALL_TOSS +	ld a, SFX_BALL_TOSS  	call PlaySound  .skipPlayingSound -	ld a,[wIsInBattle] -	cp a,02 ; is it a trainer battle? -	jr z,.isTrainerBattle -	ld a,[wd11e] -	cp a,$10 ; is the enemy pokemon the Ghost Marowak? +	ld a, [wIsInBattle] +	cp 02 ; is it a trainer battle? +	jr z, .isTrainerBattle +	ld a, [wd11e] +	cp $10 ; is the enemy pokemon the Ghost Marowak?  	ret nz  ; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames -	ld a,[wSubAnimCounter] -	cp a,3 -	jr z,.moveGhostMarowakLeft -	cp a,2 -	jr z,.moveGhostMarowakLeft -	cp a,1 +	ld a, [wSubAnimCounter] +	cp 3 +	jr z, .moveGhostMarowakLeft +	cp 2 +	jr z, .moveGhostMarowakLeft +	cp 1  	ret nz  .moveGhostMarowakLeft  	coord hl, 17, 0 -	ld de,20 +	ld de, 20  	lb bc, 7, 7  .loop  	push hl @@ -765,152 +765,152 @@ DoBallTossSpecialEffects:  	call AnimCopyRowRight ; move row of tiles left  	pop bc  	pop hl -	add hl,de +	add hl, de  	dec b -	jr nz,.loop -	ld a,%00001000 -	ld [rNR10],a ; Channel 1 sweep register +	jr nz, .loop +	ld a, %00001000 +	ld [rNR10], a ; Channel 1 sweep register  	ret  .isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame -	ld a,[wSubAnimCounter] -	cp a,3 +	ld a, [wSubAnimCounter] +	cp 3  	ret nz  	dec a -	ld [wSubAnimCounter],a +	ld [wSubAnimCounter], a  	ret  DoBallShakeSpecialEffects: -	ld a,[wSubAnimCounter] -	cp a,4 ; is it the beginning of a shake? -	jr nz,.skipPlayingSound +	ld a, [wSubAnimCounter] +	cp 4 ; is it the beginning of a shake? +	jr nz, .skipPlayingSound  ; if it is the beginning of a shake, play a sound and wait 2/3 of a second -	ld a,SFX_TINK +	ld a, SFX_TINK  	call PlaySound -	ld c,40 +	ld c, 40  	call DelayFrames  .skipPlayingSound -	ld a,[wSubAnimCounter] +	ld a, [wSubAnimCounter]  	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,[wNumShakes] ; number of shakes +	ld a, [wNumShakes] ; number of shakes  	dec a ; decrement number of shakes -	ld [wNumShakes],a +	ld [wNumShakes], a  	ret z  ; if there are shakes left, restart the subanimation -	ld a,[wSubAnimSubEntryAddr] -	ld l,a -	ld a,[wSubAnimSubEntryAddr + 1] -	ld h,a -	ld de,-(4 * 3) ; 4 subentries and 3 bytes per subentry -	add hl,de -	ld a,l -	ld [wSubAnimSubEntryAddr],a -	ld a,h -	ld [wSubAnimSubEntryAddr + 1],a -	ld a,5 ; number of subentries in the ball shaking subanimation plus one -	ld [wSubAnimCounter],a +	ld a, [wSubAnimSubEntryAddr] +	ld l, a +	ld a, [wSubAnimSubEntryAddr + 1] +	ld h, a +	ld de, -(4 * 3) ; 4 subentries and 3 bytes per subentry +	add hl, de +	ld a, l +	ld [wSubAnimSubEntryAddr], a +	ld a, h +	ld [wSubAnimSubEntryAddr + 1], a +	ld a, 5 ; number of subentries in the ball shaking subanimation plus one +	ld [wSubAnimCounter], a  	ret  ; plays a sound after the second frame of the poof animation  DoPoofSpecialEffects: -	ld a,[wSubAnimCounter] -	cp a,5 +	ld a, [wSubAnimCounter] +	cp 5  	ret nz -	ld a,SFX_BALL_POOF +	ld a, SFX_BALL_POOF  	jp PlaySound  DoRockSlideSpecialEffects: -	ld a,[wSubAnimCounter] -	cp a,12 +	ld a, [wSubAnimCounter] +	cp 12  	ret nc -	cp a,8 -	jr nc,.shakeScreen -	cp a,1 -	jp z,AnimationFlashScreen ; if it's the end of the subanimation, flash the screen +	cp 8 +	jr nc, .shakeScreen +	cp 1 +	jp z, AnimationFlashScreen ; if it's the end of the subanimation, flash the screen  	ret  ; if the subanimation counter is between 8 and 11, shake the screen horizontally and vertically  .shakeScreen -	ld b,1 +	ld b, 1  	predef PredefShakeScreenHorizontally ; shake horizontally -	ld b,1 +	ld b, 1  	predef_jump PredefShakeScreenVertically ; shake vertically  FlashScreenEveryEightFrameBlocks: -	ld a,[wSubAnimCounter] -	and a,7 ; is the subanimation counter exactly 8? -	call z,AnimationFlashScreen ; if so, flash the screen +	ld a, [wSubAnimCounter] +	and 7 ; is the subanimation counter exactly 8? +	call z, AnimationFlashScreen ; if so, flash the screen  	ret  ; flashes the screen if the subanimation counter is divisible by 4  FlashScreenEveryFourFrameBlocks: -	ld a,[wSubAnimCounter] -	and a,3 -	call z,AnimationFlashScreen +	ld a, [wSubAnimCounter] +	and 3 +	call z, AnimationFlashScreen  	ret  ; used for Explosion and Selfdestruct  DoExplodeSpecialEffects: -	ld a,[wSubAnimCounter] -	cp a,1 ; is it the end of the subanimation? -	jr nz,FlashScreenEveryFourFrameBlocks +	ld a, [wSubAnimCounter] +	cp 1 ; is it the end of the subanimation? +	jr nz, FlashScreenEveryFourFrameBlocks  ; if it's the end of the subanimation, make the attacking pokemon disappear  	coord hl, 1, 5  	jp AnimationHideMonPic ; make pokemon disappear  ; flashes the screen when subanimation counter is 1 modulo 4  DoBlizzardSpecialEffects: -	ld a,[wSubAnimCounter] -	cp a,13 -	jp z,AnimationFlashScreen -	cp a,9 -	jp z,AnimationFlashScreen -	cp a,5 -	jp z,AnimationFlashScreen -	cp a,1 -	jp z,AnimationFlashScreen +	ld a, [wSubAnimCounter] +	cp 13 +	jp z, AnimationFlashScreen +	cp 9 +	jp z, AnimationFlashScreen +	cp 5 +	jp z, AnimationFlashScreen +	cp 1 +	jp z, AnimationFlashScreen  	ret  ; flashes the screen at 3 points in the subanimation  ; unused  FlashScreenUnused: -	ld a,[wSubAnimCounter] -	cp a,14 -	jp z,AnimationFlashScreen -	cp a,9 -	jp z,AnimationFlashScreen -	cp a,2 -	jp z,AnimationFlashScreen +	ld a, [wSubAnimCounter] +	cp 14 +	jp z, AnimationFlashScreen +	cp 9 +	jp z, AnimationFlashScreen +	cp 2 +	jp z, AnimationFlashScreen  	ret  ; function to make the pokemon disappear at the beginning of the animation  TradeHidePokemon: -	ld a,[wSubAnimCounter] -	cp a,6 +	ld a, [wSubAnimCounter] +	cp 6  	ret nz -	ld a,2 * SCREEN_WIDTH + 7 +	ld a, 2 * SCREEN_WIDTH + 7  	jp ClearMonPicFromTileMap ; make pokemon disappear  ; function to make a shaking pokeball jump up at the end of the animation  TradeShakePokeball: -	ld a,[wSubAnimCounter] -	cp a,1 +	ld a, [wSubAnimCounter] +	cp 1  	ret nz  ; if it's the end of the animation, make the ball jump up -	ld de,BallMoveDistances1 +	ld de, BallMoveDistances1  .loop -	ld hl,wOAMBuffer ; OAM buffer -	ld bc,4 +	ld hl, wOAMBuffer ; OAM buffer +	ld bc, 4  .innerLoop -	ld a,[de] -	cp a,$ff -	jr z,.done +	ld a, [de] +	cp $ff +	jr z, .done  	add [hl] ; add to Y value of OAM entry -	ld [hl],a -	add hl,bc -	ld a,l -	cp a,4 * 4 ; there are 4 entries, each 4 bytes -	jr nz,.innerLoop +	ld [hl], a +	add hl, bc +	ld a, l +	cp 4 * 4 ; there are 4 entries, each 4 bytes +	jr nz, .innerLoop  	inc de  	push bc  	call Delay3 @@ -918,7 +918,7 @@ TradeShakePokeball:  	jr .loop  .done  	call AnimationCleanOAM -	ld a,SFX_TRADE_MACHINE +	ld a, SFX_TRADE_MACHINE  	jp PlaySound  BallMoveDistances1: @@ -927,38 +927,38 @@ BallMoveDistances1:  ; function to make the pokeball jump up  TradeJumpPokeball: -	ld de,BallMoveDistances2 +	ld de, BallMoveDistances2  .loop -	ld hl,wOAMBuffer ; OAM buffer -	ld bc,4 +	ld hl, wOAMBuffer ; OAM buffer +	ld bc, 4  .innerLoop -	ld a,[de] -	cp a,$ff -	jp z,ClearScreen +	ld a, [de] +	cp $ff +	jp z, ClearScreen  	add [hl] -	ld [hl],a -	add hl,bc -	ld a,l -	cp a,4 * 4 ; there are 4 entries, each 4 bytes -	jr nz,.innerLoop +	ld [hl], a +	add hl, bc +	ld a, l +	cp 4 * 4 ; there are 4 entries, each 4 bytes +	jr nz, .innerLoop  	inc de  	push de -	ld a,[de] -	cp a,12 -	jr z,.playSound -	cp a,$ff -	jr nz,.skipPlayingSound +	ld a, [de] +	cp 12 +	jr z, .playSound +	cp $ff +	jr nz, .skipPlayingSound  .playSound ; play sound if next move distance is 12 or this is the last one -	ld a,SFX_BATTLE_18 +	ld a, SFX_BATTLE_18  	call PlaySound  .skipPlayingSound  	push bc -	ld c,5 +	ld c, 5  	call DelayFrames  	pop bc -	ld a,[hSCX] ; background scroll X -	sub a,8 ; scroll to the left -	ld [hSCX],a +	ld a, [hSCX] ; background scroll X +	sub 8 ; scroll to the left +	ld [hSCX], a  	pop de  	jr .loop @@ -969,20 +969,20 @@ BallMoveDistances2:  ; this function copies the current musical note graphic  ; so that there are two musical notes flying towards the defending pokemon  DoGrowlSpecialEffects: -	ld hl,wOAMBuffer ; OAM buffer -	ld de,wOAMBuffer + $10 -	ld bc,$10 +	ld hl, wOAMBuffer ; OAM buffer +	ld de, wOAMBuffer + $10 +	ld bc, $10  	call CopyData ; copy the musical note graphic -	ld a,[wSubAnimCounter] +	ld a, [wSubAnimCounter]  	dec a -	call z,AnimationCleanOAM ; clean up at the end of the subanimation +	call z, AnimationCleanOAM ; clean up at the end of the subanimation  	ret  ; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations  TailWhipAnimationUnused: -	ld a,1 -	ld [wSubAnimCounter],a -	ld c,20 +	ld a, 1 +	ld [wSubAnimCounter], a +	ld c, 20  	jp DelayFrames  ; Format: Special Effect ID (1 byte), Address (2 bytes) @@ -1068,48 +1068,48 @@ SpecialEffectPointers:  	db $FF  AnimationDelay10: -	ld c,10 +	ld c, 10  	jp DelayFrames  ; calls a function with the turn flipped from player to enemy or vice versa  ; input - hl - address of function to call  CallWithTurnFlipped: -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	push af -	xor a,1 -	ld [H_WHOSETURN],a -	ld de,.returnAddress +	xor 1 +	ld [H_WHOSETURN], a +	ld de, .returnAddress  	push de  	jp hl  .returnAddress  	pop af -	ld [H_WHOSETURN],a +	ld [H_WHOSETURN], a  	ret  ; flashes the screen for an extended period (48 frames)  AnimationFlashScreenLong: -	ld a,3 ; cycle through the palettes 3 times -	ld [wFlashScreenLongCounter],a -	ld a,[wOnSGB] ; running on SGB? +	ld a, 3 ; cycle through the palettes 3 times +	ld [wFlashScreenLongCounter], a +	ld a, [wOnSGB] ; running on SGB?  	and a -	ld hl,FlashScreenLongMonochrome -	jr z,.loop -	ld hl,FlashScreenLongSGB +	ld hl, FlashScreenLongMonochrome +	jr z, .loop +	ld hl, FlashScreenLongSGB  .loop  	push hl  .innerLoop -	ld a,[hli] -	cp a,$01 ; is it the end of the palettes? -	jr z,.endOfPalettes -	ld [rBGP],a +	ld a, [hli] +	cp $01 ; is it the end of the palettes? +	jr z, .endOfPalettes +	ld [rBGP], a  	call FlashScreenLongDelay  	jr .innerLoop  .endOfPalettes -	ld a,[wFlashScreenLongCounter] +	ld a, [wFlashScreenLongCounter]  	dec a -	ld [wFlashScreenLongCounter],a +	ld [wFlashScreenLongCounter], a  	pop hl -	jr nz,.loop +	jr nz, .loop  	ret  ; BG palettes @@ -1147,31 +1147,31 @@ FlashScreenLongSGB:  ; causes a delay of 2 frames for the first cycle  ; causes a delay of 1 frame for the second and third cycles  FlashScreenLongDelay: -	ld a,[wFlashScreenLongCounter] -	cp a,4 ; never true since [wFlashScreenLongCounter] starts at 3 -	ld c,4 -	jr z,.delayFrames -	cp a,3 -	ld c,2 -	jr z,.delayFrames -	cp a,2 ; nothing is done with this -	ld c,1 +	ld a, [wFlashScreenLongCounter] +	cp 4 ; never true since [wFlashScreenLongCounter] starts at 3 +	ld c, 4 +	jr z, .delayFrames +	cp 3 +	ld c, 2 +	jr z, .delayFrames +	cp 2 ; nothing is done with this +	ld c, 1  .delayFrames  	jp DelayFrames  AnimationFlashScreen: -	ld a,[rBGP] +	ld a, [rBGP]  	push af ; save initial palette -	ld a,%00011011 ; 0, 1, 2, 3 (inverted colors) -	ld [rBGP],a -	ld c,2 +	ld a, %00011011 ; 0, 1, 2, 3 (inverted colors) +	ld [rBGP], a +	ld c, 2  	call DelayFrames  	xor a ; white out background -	ld [rBGP],a -	ld c,2 +	ld [rBGP], a +	ld c, 2  	call DelayFrames  	pop af -	ld [rBGP],a ; restore initial palette +	ld [rBGP], a ; restore initial palette  	ret  AnimationDarkScreenPalette: @@ -2310,52 +2310,52 @@ GetMoveSoundB:  	ret  GetMoveSound: -	ld hl,MoveSoundTable -	ld e,a -	ld d,0 -	add hl,de -	add hl,de -	add hl,de -	ld a,[hli] -	ld b,a +	ld hl, MoveSoundTable +	ld e, a +	ld d, 0 +	add hl, de +	add hl, de +	add hl, de +	ld a, [hli] +	ld b, a  	call IsCryMove -	jr nc,.NotCryMove -	ld a,[H_WHOSETURN] +	jr nc, .NotCryMove +	ld a, [H_WHOSETURN]  	and a -	jr nz,.next -	ld a,[wBattleMonSpecies] ; get number of current monster +	jr nz, .next +	ld a, [wBattleMonSpecies] ; get number of current monster  	jr .Continue  .next -	ld a,[wEnemyMonSpecies] +	ld a, [wEnemyMonSpecies]  .Continue  	push hl  	call GetCryData -	ld b,a +	ld b, a  	pop hl -	ld a,[wFrequencyModifier] +	ld a, [wFrequencyModifier]  	add [hl] -	ld [wFrequencyModifier],a +	ld [wFrequencyModifier], a  	inc hl -	ld a,[wTempoModifier] +	ld a, [wTempoModifier]  	add [hl] -	ld [wTempoModifier],a +	ld [wTempoModifier], a  	jr .done  .NotCryMove -	ld a,[hli] -	ld [wFrequencyModifier],a -	ld a,[hli] -	ld [wTempoModifier],a +	ld a, [hli] +	ld [wFrequencyModifier], a +	ld a, [hli] +	ld [wTempoModifier], a  .done -	ld a,b +	ld a, b  	ret  IsCryMove:  ; set carry if the move animation involves playing a monster cry -	ld a,[wAnimationID] -	cp a,GROWL -	jr z,.CryMove -	cp a,ROAR -	jr z,.CryMove +	ld a, [wAnimationID] +	cp GROWL +	jr z, .CryMove +	cp ROAR +	jr z, .CryMove  	and a ; clear carry  	ret  .CryMove @@ -2951,46 +2951,46 @@ BattleAnimCopyTileMapToVRAM:  	jp Delay3  TossBallAnimation: -	ld a,[wIsInBattle] -	cp a,2 -	jr z,.BlockBall ; if in trainer battle, play different animation -	ld a,[wPokeBallAnimData] -	ld b,a +	ld a, [wIsInBattle] +	cp 2 +	jr z, .BlockBall ; if in trainer battle, play different animation +	ld a, [wPokeBallAnimData] +	ld b, a  	; upper nybble: how many animations (from PokeBallAnimations) to play  	; this will be 4 for successful capture, 6 for breakout -	and a,$F0 +	and $F0  	swap a -	ld c,a +	ld c, a  	; lower nybble: number of shakes  	; store these for later -	ld a,b -	and a,$F -	ld [wNumShakes],a +	ld a, b +	and $F +	ld [wNumShakes], a -	ld hl,.PokeBallAnimations +	ld hl, .PokeBallAnimations  	; choose which toss animation to use -	ld a,[wcf91] -	cp a,POKE_BALL -	ld b,TOSS_ANIM -	jr z,.done -	cp a,GREAT_BALL -	ld b,GREATTOSS_ANIM -	jr z,.done -	ld b,ULTRATOSS_ANIM +	ld a, [wcf91] +	cp POKE_BALL +	ld b, TOSS_ANIM +	jr z, .done +	cp GREAT_BALL +	ld b, GREATTOSS_ANIM +	jr z, .done +	ld b, ULTRATOSS_ANIM  .done -	ld a,b +	ld a, b  .PlayNextAnimation -	ld [wAnimationID],a +	ld [wAnimationID], a  	push bc  	push hl  	call PlayAnimation  	pop hl -	ld a,[hli] +	ld a, [hli]  	pop bc  	dec c -	jr nz,.PlayNextAnimation +	jr nz, .PlayNextAnimation  	ret  .PokeBallAnimations: @@ -2998,13 +2998,13 @@ TossBallAnimation:  	db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM  .BlockBall -	ld a,TOSS_ANIM -	ld [wAnimationID],a +	ld a, TOSS_ANIM +	ld [wAnimationID], a  	call PlayAnimation -	ld a,SFX_FAINT_THUD +	ld a, SFX_FAINT_THUD  	call PlaySound -	ld a,BLOCKBALL_ANIM -	ld [wAnimationID],a +	ld a, BLOCKBALL_ANIM +	ld [wAnimationID], a  	jp PlayAnimation  PlayApplyingAttackSound: diff --git a/engine/battle/core.asm b/engine/battle/core.asm index a2b18389..9265503d 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -579,7 +579,7 @@ HandlePoisonBurnLeechSeed:  	call PrintText  	xor a  	ld [wAnimationType], a -	ld a,BURN_PSN_ANIM +	ld a, BURN_PSN_ANIM  	call PlayMoveAnimation   ; play burn/poison animation  	pop hl  	call HandlePoisonBurnLeechSeed_DecreaseOwnHP @@ -600,7 +600,7 @@ HandlePoisonBurnLeechSeed:  	ld [H_WHOSETURN], a  	xor a  	ld [wAnimationType], a -	ld a,ABSORB +	ld a, ABSORB  	call PlayMoveAnimation ; play leech seed animation (from opposing mon)  	pop af  	ld [H_WHOSETURN], a @@ -1363,138 +1363,138 @@ SlideTrainerPicOffScreen:  ; send out a trainer's mon  EnemySendOut: -	ld hl,wPartyGainExpFlags +	ld hl, wPartyGainExpFlags  	xor a -	ld [hl],a -	ld a,[wPlayerMonNumber] -	ld c,a -	ld b,FLAG_SET +	ld [hl], a +	ld a, [wPlayerMonNumber] +	ld c, a +	ld b, FLAG_SET  	push bc  	predef FlagActionPredef -	ld hl,wPartyFoughtCurrentEnemyFlags +	ld hl, wPartyFoughtCurrentEnemyFlags  	xor a -	ld [hl],a +	ld [hl], a  	pop bc  	predef FlagActionPredef  ; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags  EnemySendOutFirstMon:  	xor a -	ld hl,wEnemyStatsToDouble ; clear enemy statuses -	ld [hli],a -	ld [hli],a -	ld [hli],a -	ld [hli],a -	ld [hl],a -	ld [wEnemyDisabledMove],a -	ld [wEnemyDisabledMoveNumber],a -	ld [wEnemyMonMinimized],a -	ld hl,wPlayerUsedMove -	ld [hli],a -	ld [hl],a +	ld hl, wEnemyStatsToDouble ; clear enemy statuses +	ld [hli], a +	ld [hli], a +	ld [hli], a +	ld [hli], a +	ld [hl], a +	ld [wEnemyDisabledMove], a +	ld [wEnemyDisabledMoveNumber], a +	ld [wEnemyMonMinimized], a +	ld hl, wPlayerUsedMove +	ld [hli], a +	ld [hl], a  	dec a -	ld [wAICount],a -	ld hl,wPlayerBattleStatus1 -	res 5,[hl] +	ld [wAICount], a +	ld hl, wPlayerBattleStatus1 +	res 5, [hl]  	coord hl, 18, 0 -	ld a,8 +	ld a, 8  	call SlideTrainerPicOffScreen  	call PrintEmptyString  	call SaveScreenTilesToBuffer1 -	ld a,[wLinkState] +	ld a, [wLinkState]  	cp LINK_STATE_BATTLING -	jr nz,.next -	ld a,[wSerialExchangeNybbleReceiveData] +	jr nz, .next +	ld a, [wSerialExchangeNybbleReceiveData]  	sub 4 -	ld [wWhichPokemon],a +	ld [wWhichPokemon], a  	jr .next3  .next -	ld b,$FF +	ld b, $FF  .next2  	inc b -	ld a,[wEnemyMonPartyPos] +	ld a, [wEnemyMonPartyPos]  	cp b -	jr z,.next2 -	ld hl,wEnemyMon1 -	ld a,b -	ld [wWhichPokemon],a +	jr z, .next2 +	ld hl, wEnemyMon1 +	ld a, b +	ld [wWhichPokemon], a  	push bc -	ld bc,wEnemyMon2 - wEnemyMon1 +	ld bc, wEnemyMon2 - wEnemyMon1  	call AddNTimes  	pop bc  	inc hl -	ld a,[hli] -	ld c,a -	ld a,[hl] +	ld a, [hli] +	ld c, a +	ld a, [hl]  	or c -	jr z,.next2 +	jr z, .next2  .next3 -	ld a,[wWhichPokemon] -	ld hl,wEnemyMon1Level -	ld bc,wEnemyMon2 - wEnemyMon1 +	ld a, [wWhichPokemon] +	ld hl, wEnemyMon1Level +	ld bc, wEnemyMon2 - wEnemyMon1  	call AddNTimes -	ld a,[hl] -	ld [wCurEnemyLVL],a -	ld a,[wWhichPokemon] +	ld a, [hl] +	ld [wCurEnemyLVL], a +	ld a, [wWhichPokemon]  	inc a -	ld hl,wEnemyPartyCount -	ld c,a -	ld b,0 -	add hl,bc -	ld a,[hl] -	ld [wEnemyMonSpecies2],a -	ld [wcf91],a +	ld hl, wEnemyPartyCount +	ld c, a +	ld b, 0 +	add hl, bc +	ld a, [hl] +	ld [wEnemyMonSpecies2], a +	ld [wcf91], a  	call LoadEnemyMonData -	ld hl,wEnemyMonHP -	ld a,[hli] -	ld [wLastSwitchInEnemyMonHP],a -	ld a,[hl] -	ld [wLastSwitchInEnemyMonHP + 1],a -	ld a,1 -	ld [wCurrentMenuItem],a -	ld a,[wFirstMonsNotOutYet] +	ld hl, wEnemyMonHP +	ld a, [hli] +	ld [wLastSwitchInEnemyMonHP], a +	ld a, [hl] +	ld [wLastSwitchInEnemyMonHP + 1], a +	ld a, 1 +	ld [wCurrentMenuItem], a +	ld a, [wFirstMonsNotOutYet]  	dec a -	jr z,.next4 -	ld a,[wPartyCount] +	jr z, .next4 +	ld a, [wPartyCount]  	dec a -	jr z,.next4 -	ld a,[wLinkState] +	jr z, .next4 +	ld a, [wLinkState]  	cp LINK_STATE_BATTLING -	jr z,.next4 -	ld a,[wOptions] -	bit 6,a -	jr nz,.next4 +	jr z, .next4 +	ld a, [wOptions] +	bit 6, a +	jr nz, .next4  	ld hl, TrainerAboutToUseText  	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 -	ld a,[wCurrentMenuItem] +	ld a, [wCurrentMenuItem]  	and a -	jr nz,.next4 -	ld a,BATTLE_PARTY_MENU -	ld [wPartyMenuTypeOrMessageID],a +	jr nz, .next4 +	ld a, BATTLE_PARTY_MENU +	ld [wPartyMenuTypeOrMessageID], a  	call DisplayPartyMenu  .next9 -	ld a,1 -	ld [wCurrentMenuItem],a -	jr c,.next7 -	ld hl,wPlayerMonNumber -	ld a,[wWhichPokemon] +	ld a, 1 +	ld [wCurrentMenuItem], a +	jr c, .next7 +	ld hl, wPlayerMonNumber +	ld a, [wWhichPokemon]  	cp [hl] -	jr nz,.next6 -	ld hl,AlreadyOutText +	jr nz, .next6 +	ld hl, AlreadyOutText  	call PrintText  .next8  	call GoBackToPartyMenu  	jr .next9  .next6  	call HasMonFainted -	jr z,.next8 +	jr z, .next8  	xor a -	ld [wCurrentMenuItem],a +	ld [wCurrentMenuItem], a  .next7  	call GBPalWhiteOut  	call LoadHudTilePatterns @@ -1507,27 +1507,27 @@ EnemySendOutFirstMon:  	ld b, SET_PAL_BATTLE  	call RunPaletteCommand  	call GBPalNormal -	ld hl,TrainerSentOutText +	ld hl, TrainerSentOutText  	call PrintText -	ld a,[wEnemyMonSpecies2] -	ld [wcf91],a -	ld [wd0b5],a +	ld a, [wEnemyMonSpecies2] +	ld [wcf91], a +	ld [wd0b5], a  	call GetMonHeader -	ld de,vFrontPic +	ld de, vFrontPic  	call LoadMonFrontSprite -	ld a,-$31 -	ld [hStartTileID],a +	ld a, -$31 +	ld [hStartTileID], a  	coord hl, 15, 6  	predef AnimateSendingOutMon -	ld a,[wEnemyMonSpecies2] +	ld a, [wEnemyMonSpecies2]  	call PlayCry  	call DrawEnemyHUDAndHPBar -	ld a,[wCurrentMenuItem] +	ld a, [wCurrentMenuItem]  	and a  	ret nz  	xor a -	ld [wPartyGainExpFlags],a -	ld [wPartyFoughtCurrentEnemyFlags],a +	ld [wPartyGainExpFlags], a +	ld [wPartyFoughtCurrentEnemyFlags], a  	call SaveScreenTilesToBuffer1  	jp SwitchPlayerMon @@ -3169,160 +3169,160 @@ CheckIfPlayerNeedsToChargeUp:  ; in-battle stuff  PlayerCanExecuteChargingMove: -	ld hl,wPlayerBattleStatus1 -	res CHARGING_UP,[hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack +	ld hl, wPlayerBattleStatus1 +	res CHARGING_UP, [hl] ; reset charging up and invulnerability statuses if mon was charging up for an attack  	                    ; being fully paralyzed or hurting oneself in confusion removes charging up status  	                    ; resulting in the Pokemon being invulnerable for the whole battle -	res INVULNERABLE,[hl] +	res INVULNERABLE, [hl]  PlayerCanExecuteMove:  	call PrintMonName1Text -	ld hl,DecrementPP -	ld de,wPlayerSelectedMove ; pointer to the move just used -	ld b,BANK(DecrementPP) +	ld hl, DecrementPP +	ld de, wPlayerSelectedMove ; pointer to the move just used +	ld b, BANK(DecrementPP)  	call Bankswitch -	ld a,[wPlayerMoveEffect] ; effect of the move just used -	ld hl,ResidualEffects1 -	ld de,1 +	ld a, [wPlayerMoveEffect] ; effect of the move just used +	ld hl, ResidualEffects1 +	ld de, 1  	call IsInArray -	jp c,JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests +	jp c, JumpMoveEffect ; ResidualEffects1 moves skip damage calculation and accuracy tests  	                    ; unless executed as part of their exclusive effect functions -	ld a,[wPlayerMoveEffect] -	ld hl,SpecialEffectsCont -	ld de,1 +	ld a, [wPlayerMoveEffect] +	ld hl, SpecialEffectsCont +	ld de, 1  	call IsInArray -	call c,JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything +	call c, JumpMoveEffect ; execute the effects of SpecialEffectsCont moves (e.g. Wrap, Thrash) but don't skip anything  PlayerCalcMoveDamage: -	ld a,[wPlayerMoveEffect] -	ld hl,SetDamageEffects -	ld de,1 +	ld a, [wPlayerMoveEffect] +	ld hl, SetDamageEffects +	ld de, 1  	call IsInArray -	jp c,.moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation +	jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation  	call CriticalHitTest  	call HandleCounterMove -	jr z,handleIfPlayerMoveMissed +	jr z, handleIfPlayerMoveMissed  	call GetDamageVarsForPlayerAttack  	call CalculateDamage -	jp z,playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest +	jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest  	               ; for these moves, accuracy tests will only occur if they are called as part of the effect itself  	call AdjustDamageForMoveType  	call RandomizeDamage  .moveHitTest  	call MoveHitTest  handleIfPlayerMoveMissed: -	ld a,[wMoveMissed] +	ld a, [wMoveMissed]  	and a -	jr z,getPlayerAnimationType -	ld a,[wPlayerMoveEffect] -	sub a,EXPLODE_EFFECT -	jr z,playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT +	jr z, getPlayerAnimationType +	ld a, [wPlayerMoveEffect] +	sub EXPLODE_EFFECT +	jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT  	jr playerCheckIfFlyOrChargeEffect  getPlayerAnimationType: -	ld a,[wPlayerMoveEffect] +	ld a, [wPlayerMoveEffect]  	and a -	ld a,4 ; move has no effect other than dealing damage -	jr z,playPlayerMoveAnimation -	ld a,5 ; move has effect +	ld a, 4 ; move has no effect other than dealing damage +	jr z, playPlayerMoveAnimation +	ld a, 5 ; move has effect  playPlayerMoveAnimation:  	push af -	ld a,[wPlayerBattleStatus2] -	bit HAS_SUBSTITUTE_UP,a -	ld hl,HideSubstituteShowMonAnim -	ld b,BANK(HideSubstituteShowMonAnim) -	call nz,Bankswitch +	ld a, [wPlayerBattleStatus2] +	bit HAS_SUBSTITUTE_UP, a +	ld hl, HideSubstituteShowMonAnim +	ld b, BANK(HideSubstituteShowMonAnim) +	call nz, Bankswitch  	pop af -	ld [wAnimationType],a -	ld a,[wPlayerMoveNum] +	ld [wAnimationType], a +	ld a, [wPlayerMoveNum]  	call PlayMoveAnimation  	call HandleExplodingAnimation  	call DrawPlayerHUDAndHPBar -	ld a,[wPlayerBattleStatus2] -	bit HAS_SUBSTITUTE_UP,a -	ld hl,ReshowSubstituteAnim -	ld b,BANK(ReshowSubstituteAnim) -	call nz,Bankswitch +	ld a, [wPlayerBattleStatus2] +	bit HAS_SUBSTITUTE_UP, a +	ld hl, ReshowSubstituteAnim +	ld b, BANK(ReshowSubstituteAnim) +	call nz, Bankswitch  	jr MirrorMoveCheck  playerCheckIfFlyOrChargeEffect: -	ld c,30 +	ld c, 30  	call DelayFrames -	ld a,[wPlayerMoveEffect] -	cp a,FLY_EFFECT -	jr z,.playAnim -	cp a,CHARGE_EFFECT -	jr z,.playAnim +	ld a, [wPlayerMoveEffect] +	cp FLY_EFFECT +	jr z, .playAnim +	cp CHARGE_EFFECT +	jr z, .playAnim  	jr MirrorMoveCheck  .playAnim  	xor a -	ld [wAnimationType],a -	ld a,STATUS_AFFECTED_ANIM +	ld [wAnimationType], a +	ld a, STATUS_AFFECTED_ANIM  	call PlayMoveAnimation  MirrorMoveCheck: -	ld a,[wPlayerMoveEffect] -	cp a,MIRROR_MOVE_EFFECT -	jr nz,.metronomeCheck +	ld a, [wPlayerMoveEffect] +	cp MIRROR_MOVE_EFFECT +	jr nz, .metronomeCheck  	call MirrorMoveCopyMove -	jp z,ExecutePlayerMoveDone +	jp z, ExecutePlayerMoveDone  	xor a -	ld [wMonIsDisobedient],a +	ld [wMonIsDisobedient], a  	jp CheckIfPlayerNeedsToChargeUp ; if Mirror Move was successful go back to damage calculation for copied move  .metronomeCheck -	cp a,METRONOME_EFFECT -	jr nz,.next +	cp METRONOME_EFFECT +	jr nz, .next  	call MetronomePickMove  	jp CheckIfPlayerNeedsToChargeUp ; Go back to damage calculation for the move picked by Metronome  .next -	ld a,[wPlayerMoveEffect] -	ld hl,ResidualEffects2 -	ld de,1 +	ld a, [wPlayerMoveEffect] +	ld hl, ResidualEffects2 +	ld de, 1  	call IsInArray -	jp c,JumpMoveEffect ; done here after executing effects of ResidualEffects2 -	ld a,[wMoveMissed] +	jp c, JumpMoveEffect ; done here after executing effects of ResidualEffects2 +	ld a, [wMoveMissed]  	and a -	jr z,.moveDidNotMiss +	jr z, .moveDidNotMiss  	call PrintMoveFailureText -	ld a,[wPlayerMoveEffect] -	cp a,EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated -	jr z,.notDone +	ld a, [wPlayerMoveEffect] +	cp EXPLODE_EFFECT ; even if Explosion or Selfdestruct missed, its effect still needs to be activated +	jr z, .notDone  	jp ExecutePlayerMoveDone ; otherwise, we're done if the move missed  .moveDidNotMiss  	call ApplyAttackToEnemyPokemon  	call PrintCriticalOHKOText  	callab DisplayEffectiveness -	ld a,1 -	ld [wMoveDidntMiss],a +	ld a, 1 +	ld [wMoveDidntMiss], a  .notDone -	ld a,[wPlayerMoveEffect] -	ld hl,AlwaysHappenSideEffects -	ld de,1 +	ld a, [wPlayerMoveEffect] +	ld hl, AlwaysHappenSideEffects +	ld de, 1  	call IsInArray -	call c,JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects -	ld hl,wEnemyMonHP -	ld a,[hli] -	ld b,[hl] +	call c, JumpMoveEffect ; not done after executing effects of AlwaysHappenSideEffects +	ld hl, wEnemyMonHP +	ld a, [hli] +	ld b, [hl]  	or b  	ret z ; don't do anything else if the enemy fainted  	call HandleBuildingRage -	ld hl,wPlayerBattleStatus1 -	bit ATTACKING_MULTIPLE_TIMES,[hl] -	jr z,.executeOtherEffects -	ld a,[wPlayerNumAttacksLeft] +	ld hl, wPlayerBattleStatus1 +	bit ATTACKING_MULTIPLE_TIMES, [hl] +	jr z, .executeOtherEffects +	ld a, [wPlayerNumAttacksLeft]  	dec a -	ld [wPlayerNumAttacksLeft],a -	jp nz,getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints. +	ld [wPlayerNumAttacksLeft], a +	jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.  	                             ; damage calculation and accuracy tests only happen for the first hit -	res ATTACKING_MULTIPLE_TIMES,[hl] ; clear attacking multiple times status when all attacks are over -	ld hl,MultiHitText +	res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over +	ld hl, MultiHitText  	call PrintText  	xor a -	ld [wPlayerNumHits],a +	ld [wPlayerNumHits], a  .executeOtherEffects -	ld a,[wPlayerMoveEffect] +	ld a, [wPlayerMoveEffect]  	and a -	jp z,ExecutePlayerMoveDone -	ld hl,SpecialEffects -	ld de,1 +	jp z, ExecutePlayerMoveDone +	ld hl, SpecialEffects +	ld de, 1  	call IsInArray -	call nc,JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays, +	call nc, JumpMoveEffect ; move effects not included in SpecialEffects or in either of the ResidualEffect arrays,  	; which are the effects not covered yet. Rage effect will be executed for a second time (though it's irrelevant).  	; Includes side effects that only need to be called if the target didn't faint.  	; Responsible for executing Twineedle's second side effect (poison). @@ -3334,26 +3334,26 @@ MultiHitText:  ExecutePlayerMoveDone:  	xor a -	ld [wActionResultOrTookBattleTurn],a -	ld b,1 +	ld [wActionResultOrTookBattleTurn], a +	ld b, 1  	ret  PrintGhostText:  ; print the ghost battle messages  	call IsGhostBattle  	ret nz -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	and a -	jr nz,.Ghost -	ld a,[wBattleMonStatus] ; player’s turn -	and a,SLP | (1 << FRZ) +	jr nz, .Ghost +	ld a, [wBattleMonStatus] ; player’s turn +	and SLP | (1 << FRZ)  	ret nz -	ld hl,ScaredText +	ld hl, ScaredText  	call PrintText  	xor a  	ret  .Ghost ; ghost’s turn -	ld hl,GetOutText +	ld hl, GetOutText  	call PrintText  	xor a  	ret @@ -3367,261 +3367,261 @@ GetOutText:  	db "@"  IsGhostBattle: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	dec a  	ret nz -	ld a,[wCurMap] -	cp a,POKEMONTOWER_1 -	jr c,.next -	cp a,LAVENDER_HOUSE_1 -	jr nc,.next -	ld b,SILPH_SCOPE +	ld a, [wCurMap] +	cp POKEMONTOWER_1 +	jr c, .next +	cp LAVENDER_HOUSE_1 +	jr nc, .next +	ld b, SILPH_SCOPE  	call IsItemInBag  	ret z  .next -	ld a,1 +	ld a, 1  	and a  	ret  ; checks for various status conditions affecting the player mon  ; stores whether the mon cannot use a move this turn in Z flag  CheckPlayerStatusConditions: -	ld hl,wBattleMonStatus -	ld a,[hl] -	and a,SLP ; sleep mask -	jr z,.FrozenCheck +	ld hl, wBattleMonStatus +	ld a, [hl] +	and SLP ; sleep mask +	jr z, .FrozenCheck  ; sleeping  	dec a -	ld [wBattleMonStatus],a ; decrement number of turns left +	ld [wBattleMonStatus], a ; decrement number of turns left  	and a -	jr z,.WakeUp ; if the number of turns hit 0, wake up +	jr z, .WakeUp ; if the number of turns hit 0, wake up  ; fast asleep  	xor a -	ld [wAnimationType],a -	ld a,SLP_ANIM - 1 +	ld [wAnimationType], a +	ld a, SLP_ANIM - 1  	call PlayMoveAnimation -	ld hl,FastAsleepText +	ld hl, FastAsleepText  	call PrintText  	jr .sleepDone  .WakeUp -	ld hl,WokeUpText +	ld hl, WokeUpText  	call PrintText  .sleepDone  	xor a -	ld [wPlayerUsedMove],a -	ld hl,ExecutePlayerMoveDone ; player can't move this turn +	ld [wPlayerUsedMove], a +	ld hl, ExecutePlayerMoveDone ; player can't move this turn  	jp .returnToHL  .FrozenCheck -	bit FRZ,[hl] ; frozen? -	jr z,.HeldInPlaceCheck -	ld hl,IsFrozenText +	bit FRZ, [hl] ; frozen? +	jr z, .HeldInPlaceCheck +	ld hl, IsFrozenText  	call PrintText  	xor a -	ld [wPlayerUsedMove],a -	ld hl,ExecutePlayerMoveDone ; player can't move this turn +	ld [wPlayerUsedMove], a +	ld hl, ExecutePlayerMoveDone ; player can't move this turn  	jp .returnToHL  .HeldInPlaceCheck -	ld a,[wEnemyBattleStatus1] -	bit USING_TRAPPING_MOVE,a ; is enemy using a mult-turn move like wrap? -	jp z,.FlinchedCheck -	ld hl,CantMoveText +	ld a, [wEnemyBattleStatus1] +	bit USING_TRAPPING_MOVE, a ; is enemy using a mult-turn move like wrap? +	jp z, .FlinchedCheck +	ld hl, CantMoveText  	call PrintText -	ld hl,ExecutePlayerMoveDone ; player can't move this turn +	ld hl, ExecutePlayerMoveDone ; player can't move this turn  	jp .returnToHL  .FlinchedCheck -	ld hl,wPlayerBattleStatus1 -	bit FLINCHED,[hl] -	jp z,.HyperBeamCheck -	res FLINCHED,[hl] ; reset player's flinch status -	ld hl,FlinchedText +	ld hl, wPlayerBattleStatus1 +	bit FLINCHED, [hl] +	jp z, .HyperBeamCheck +	res FLINCHED, [hl] ; reset player's flinch status +	ld hl, FlinchedText  	call PrintText -	ld hl,ExecutePlayerMoveDone ; player can't move this turn +	ld hl, ExecutePlayerMoveDone ; player can't move this turn  	jp .returnToHL  .HyperBeamCheck -	ld hl,wPlayerBattleStatus2 -	bit NEEDS_TO_RECHARGE,[hl] -	jr z,.AnyMoveDisabledCheck -	res NEEDS_TO_RECHARGE,[hl] ; reset player's recharge status -	ld hl,MustRechargeText +	ld hl, wPlayerBattleStatus2 +	bit NEEDS_TO_RECHARGE, [hl] +	jr z, .AnyMoveDisabledCheck +	res NEEDS_TO_RECHARGE, [hl] ; reset player's recharge status +	ld hl, MustRechargeText  	call PrintText -	ld hl,ExecutePlayerMoveDone ; player can't move this turn +	ld hl, ExecutePlayerMoveDone ; player can't move this turn  	jp .returnToHL  .AnyMoveDisabledCheck -	ld hl,wPlayerDisabledMove -	ld a,[hl] +	ld hl, wPlayerDisabledMove +	ld a, [hl]  	and a -	jr z,.ConfusedCheck +	jr z, .ConfusedCheck  	dec a -	ld [hl],a +	ld [hl], a  	and $f ; did Disable counter hit 0? -	jr nz,.ConfusedCheck -	ld [hl],a -	ld [wPlayerDisabledMoveNumber],a -	ld hl,DisabledNoMoreText +	jr nz, .ConfusedCheck +	ld [hl], a +	ld [wPlayerDisabledMoveNumber], a +	ld hl, DisabledNoMoreText  	call PrintText  .ConfusedCheck -	ld a,[wPlayerBattleStatus1] +	ld a, [wPlayerBattleStatus1]  	add a ; is player confused? -	jr nc,.TriedToUseDisabledMoveCheck -	ld hl,wPlayerConfusedCounter +	jr nc, .TriedToUseDisabledMoveCheck +	ld hl, wPlayerConfusedCounter  	dec [hl] -	jr nz,.IsConfused -	ld hl,wPlayerBattleStatus1 -	res CONFUSED,[hl] ; if confused counter hit 0, reset confusion status -	ld hl,ConfusedNoMoreText +	jr nz, .IsConfused +	ld hl, wPlayerBattleStatus1 +	res CONFUSED, [hl] ; if confused counter hit 0, reset confusion status +	ld hl, ConfusedNoMoreText  	call PrintText  	jr .TriedToUseDisabledMoveCheck  .IsConfused -	ld hl,IsConfusedText +	ld hl, IsConfusedText  	call PrintText  	xor a -	ld [wAnimationType],a -	ld a,CONF_ANIM - 1 +	ld [wAnimationType], a +	ld a, CONF_ANIM - 1  	call PlayMoveAnimation  	call BattleRandom -	cp a,$80 ; 50% chance to hurt itself -	jr c,.TriedToUseDisabledMoveCheck -	ld hl,wPlayerBattleStatus1 -	ld a,[hl] -	and a, 1 << CONFUSED ; if mon hurts itself, clear every other status from wPlayerBattleStatus1 -	ld [hl],a +	cp $80 ; 50% chance to hurt itself +	jr c, .TriedToUseDisabledMoveCheck +	ld hl, wPlayerBattleStatus1 +	ld a, [hl] +	and 1 << CONFUSED ; if mon hurts itself, clear every other status from wPlayerBattleStatus1 +	ld [hl], a  	call HandleSelfConfusionDamage  	jr .MonHurtItselfOrFullyParalysed  .TriedToUseDisabledMoveCheck  ; prevents a disabled move that was selected before being disabled from being used -	ld a,[wPlayerDisabledMoveNumber] +	ld a, [wPlayerDisabledMoveNumber]  	and a -	jr z,.ParalysisCheck -	ld hl,wPlayerSelectedMove +	jr z, .ParalysisCheck +	ld hl, wPlayerSelectedMove  	cp [hl] -	jr nz,.ParalysisCheck +	jr nz, .ParalysisCheck  	call PrintMoveIsDisabledText -	ld hl,ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn +	ld hl, ExecutePlayerMoveDone ; if a disabled move was somehow selected, player can't move this turn  	jp .returnToHL  .ParalysisCheck -	ld hl,wBattleMonStatus -	bit PAR,[hl] -	jr z,.BideCheck +	ld hl, wBattleMonStatus +	bit PAR, [hl] +	jr z, .BideCheck  	call BattleRandom -	cp a,$3F ; 25% to be fully paralyzed -	jr nc,.BideCheck -	ld hl,FullyParalyzedText +	cp $3F ; 25% to be fully paralyzed +	jr nc, .BideCheck +	ld hl, FullyParalyzedText  	call PrintText  .MonHurtItselfOrFullyParalysed -	ld hl,wPlayerBattleStatus1 -	ld a,[hl] +	ld hl, wPlayerBattleStatus1 +	ld a, [hl]  	; clear bide, thrashing, charging up, and trapping moves such as warp (already cleared for confusion damage)  	and $ff ^ ((1 << STORING_ENERGY) | (1 << THRASHING_ABOUT) | (1 << CHARGING_UP) | (1 << USING_TRAPPING_MOVE)) -	ld [hl],a -	ld a,[wPlayerMoveEffect] -	cp a,FLY_EFFECT -	jr z,.FlyOrChargeEffect -	cp a,CHARGE_EFFECT -	jr z,.FlyOrChargeEffect +	ld [hl], a +	ld a, [wPlayerMoveEffect] +	cp FLY_EFFECT +	jr z, .FlyOrChargeEffect +	cp CHARGE_EFFECT +	jr z, .FlyOrChargeEffect  	jr .NotFlyOrChargeEffect  .FlyOrChargeEffect  	xor a -	ld [wAnimationType],a -	ld a,STATUS_AFFECTED_ANIM +	ld [wAnimationType], a +	ld a, STATUS_AFFECTED_ANIM  	call PlayMoveAnimation  .NotFlyOrChargeEffect -	ld hl,ExecutePlayerMoveDone +	ld hl, ExecutePlayerMoveDone  	jp .returnToHL ; if using a two-turn move, we need to recharge the first turn  .BideCheck -	ld hl,wPlayerBattleStatus1 -	bit STORING_ENERGY,[hl] ; is mon using bide? -	jr z,.ThrashingAboutCheck -	xor a -	ld [wPlayerMoveNum],a -	ld hl,wDamage -	ld a,[hli] -	ld b,a -	ld c,[hl] -	ld hl,wPlayerBideAccumulatedDamage + 1 -	ld a,[hl] +	ld hl, wPlayerBattleStatus1 +	bit STORING_ENERGY, [hl] ; is mon using bide? +	jr z, .ThrashingAboutCheck +	xor a +	ld [wPlayerMoveNum], a +	ld hl, wDamage +	ld a, [hli] +	ld b, a +	ld c, [hl] +	ld hl, wPlayerBideAccumulatedDamage + 1 +	ld a, [hl]  	add c ; accumulate damage taken -	ld [hld],a -	ld a,[hl] +	ld [hld], a +	ld a, [hl]  	adc b -	ld [hl],a -	ld hl,wPlayerNumAttacksLeft +	ld [hl], a +	ld hl, wPlayerNumAttacksLeft  	dec [hl] ; did Bide counter hit 0? -	jr z,.UnleashEnergy -	ld hl,ExecutePlayerMoveDone +	jr z, .UnleashEnergy +	ld hl, ExecutePlayerMoveDone  	jp .returnToHL ; unless mon unleashes energy, can't move this turn  .UnleashEnergy -	ld hl,wPlayerBattleStatus1 -	res STORING_ENERGY,[hl] ; not using bide any more -	ld hl,UnleashedEnergyText +	ld hl, wPlayerBattleStatus1 +	res STORING_ENERGY, [hl] ; not using bide any more +	ld hl, UnleashedEnergyText  	call PrintText -	ld a,1 -	ld [wPlayerMovePower],a -	ld hl,wPlayerBideAccumulatedDamage + 1 -	ld a,[hld] +	ld a, 1 +	ld [wPlayerMovePower], a +	ld hl, wPlayerBideAccumulatedDamage + 1 +	ld a, [hld]  	add a -	ld b,a -	ld [wDamage + 1],a -	ld a,[hl] +	ld b, a +	ld [wDamage + 1], a +	ld a, [hl]  	rl a ; double the damage -	ld [wDamage],a +	ld [wDamage], a  	or b -	jr nz,.next -	ld a,1 -	ld [wMoveMissed],a +	jr nz, .next +	ld a, 1 +	ld [wMoveMissed], a  .next  	xor a -	ld [hli],a -	ld [hl],a -	ld a,BIDE -	ld [wPlayerMoveNum],a -	ld hl,handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest +	ld [hli], a +	ld [hl], a +	ld a, BIDE +	ld [wPlayerMoveNum], a +	ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest  	jp .returnToHL  .ThrashingAboutCheck -	bit THRASHING_ABOUT,[hl] ; is mon using thrash or petal dance? -	jr z,.MultiturnMoveCheck -	ld a,THRASH -	ld [wPlayerMoveNum],a -	ld hl,ThrashingAboutText +	bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance? +	jr z, .MultiturnMoveCheck +	ld a, THRASH +	ld [wPlayerMoveNum], a +	ld hl, ThrashingAboutText  	call PrintText -	ld hl,wPlayerNumAttacksLeft +	ld hl, wPlayerNumAttacksLeft  	dec [hl] ; did Thrashing About counter hit 0? -	ld hl,PlayerCalcMoveDamage ; skip DecrementPP -	jp nz,.returnToHL +	ld hl, PlayerCalcMoveDamage ; skip DecrementPP +	jp nz, .returnToHL  	push hl -	ld hl,wPlayerBattleStatus1 -	res THRASHING_ABOUT,[hl] ; no longer thrashing about -	set CONFUSED,[hl] ; confused +	ld hl, wPlayerBattleStatus1 +	res THRASHING_ABOUT, [hl] ; no longer thrashing about +	set CONFUSED, [hl] ; confused  	call BattleRandom -	and a,3 +	and 3  	inc a  	inc a ; confused for 2-5 turns -	ld [wPlayerConfusedCounter],a +	ld [wPlayerConfusedCounter], a  	pop hl ; skip DecrementPP  	jp .returnToHL  .MultiturnMoveCheck -	bit USING_TRAPPING_MOVE,[hl] ; is mon using multi-turn move? -	jp z,.RageCheck -	ld hl,AttackContinuesText +	bit USING_TRAPPING_MOVE, [hl] ; is mon using multi-turn move? +	jp z, .RageCheck +	ld hl, AttackContinuesText  	call PrintText -	ld a,[wPlayerNumAttacksLeft] +	ld a, [wPlayerNumAttacksLeft]  	dec a ; did multi-turn move end? -	ld [wPlayerNumAttacksLeft],a -	ld hl,getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit), +	ld [wPlayerNumAttacksLeft], a +	ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),  	                ; DecrementPP and MoveHitTest -	jp nz,.returnToHL +	jp nz, .returnToHL  	jp .returnToHL  .RageCheck @@ -4515,7 +4515,7 @@ CalculateDamage:  .effect  ; EXPLODE_EFFECT halves defense. -	cp a, EXPLODE_EFFECT +	cp EXPLODE_EFFECT  	jr nz, .ok  	srl c  	jr nz, .ok @@ -4523,13 +4523,13 @@ CalculateDamage:  .ok  ; Multi-hit attacks may or may not have 0 bp. -	cp a, TWO_TO_FIVE_ATTACKS_EFFECT +	cp TWO_TO_FIVE_ATTACKS_EFFECT  	jr z, .skipbp -	cp a, $1e +	cp $1e  	jr z, .skipbp  ; Calculate OHKO damage based on remaining HP. -	cp a, OHKO_EFFECT +	cp OHKO_EFFECT  	jp z, JumpToOHKOMoveEffect  ; Don't calculate damage for moves that don't do any. @@ -4762,297 +4762,297 @@ HandleCounterMove:  ; the outcome may be affected by the player's actions in the move selection menu prior to switching the Pokemon.  ; This might also lead to desync glitches in link battles. -	ld a,[H_WHOSETURN] ; whose turn +	ld a, [H_WHOSETURN] ; whose turn  	and a  ; player's turn -	ld hl,wEnemySelectedMove -	ld de,wEnemyMovePower -	ld a,[wPlayerSelectedMove] -	jr z,.next +	ld hl, wEnemySelectedMove +	ld de, wEnemyMovePower +	ld a, [wPlayerSelectedMove] +	jr z, .next  ; enemy's turn -	ld hl,wPlayerSelectedMove -	ld de,wPlayerMovePower -	ld a,[wEnemySelectedMove] +	ld hl, wPlayerSelectedMove +	ld de, wPlayerMovePower +	ld a, [wEnemySelectedMove]  .next -	cp a,COUNTER +	cp COUNTER  	ret nz ; return if not using Counter -	ld a,$01 -	ld [wMoveMissed],a ; initialize the move missed variable to true (it is set to false below if the move hits) -	ld a,[hl] -	cp a,COUNTER +	ld a, $01 +	ld [wMoveMissed], a ; initialize the move missed variable to true (it is set to false below if the move hits) +	ld a, [hl] +	cp COUNTER  	ret z ; miss if the opponent's last selected move is Counter. -	ld a,[de] +	ld a, [de]  	and a  	ret z ; miss if the opponent's last selected move's Base Power is 0.  ; check if the move the target last selected was Normal or Fighting type  	inc de -	ld a,[de] +	ld a, [de]  	and a ; normal type -	jr z,.counterableType -	cp a,FIGHTING -	jr z,.counterableType +	jr z, .counterableType +	cp FIGHTING +	jr z, .counterableType  ; if the move wasn't Normal or Fighting type, miss  	xor a  	ret  .counterableType -	ld hl,wDamage -	ld a,[hli] +	ld hl, wDamage +	ld a, [hli]  	or [hl]  	ret z ; If we made it here, Counter still misses if the last move used in battle did no damage to its target.  	      ; wDamage is shared by both players, so Counter may strike back damage dealt by the Counter user itself  	      ; if the conditions meet, even though 99% of the times damage will come from the target.  ; if it did damage, double it -	ld a,[hl] +	ld a, [hl]  	add a -	ldd [hl],a -	ld a,[hl] +	ldd [hl], a +	ld a, [hl]  	adc a -	ld [hl],a -	jr nc,.noCarry +	ld [hl], a +	jr nc, .noCarry  ; damage is capped at 0xFFFF -	ld a,$ff -	ld [hli],a -	ld [hl],a +	ld a, $ff +	ld [hli], a +	ld [hl], a  .noCarry  	xor a -	ld [wMoveMissed],a +	ld [wMoveMissed], a  	call MoveHitTest ; do the normal move hit test in addition to Counter's special rules  	xor a  	ret  ApplyAttackToEnemyPokemon: -	ld a,[wPlayerMoveEffect] -	cp a,OHKO_EFFECT -	jr z,ApplyDamageToEnemyPokemon -	cp a,SUPER_FANG_EFFECT -	jr z,.superFangEffect -	cp a,SPECIAL_DAMAGE_EFFECT -	jr z,.specialDamage -	ld a,[wPlayerMovePower] -	and a -	jp z,ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0 +	ld a, [wPlayerMoveEffect] +	cp OHKO_EFFECT +	jr z, ApplyDamageToEnemyPokemon +	cp SUPER_FANG_EFFECT +	jr z, .superFangEffect +	cp SPECIAL_DAMAGE_EFFECT +	jr z, .specialDamage +	ld a, [wPlayerMovePower] +	and a +	jp z, ApplyAttackToEnemyPokemonDone ; no attack to apply if base power is 0  	jr ApplyDamageToEnemyPokemon  .superFangEffect  ; set the damage to half the target's HP -	ld hl,wEnemyMonHP -	ld de,wDamage -	ld a,[hli] +	ld hl, wEnemyMonHP +	ld de, wDamage +	ld a, [hli]  	srl a -	ld [de],a +	ld [de], a  	inc de -	ld b,a -	ld a,[hl] +	ld b, a +	ld a, [hl]  	rr a -	ld [de],a +	ld [de], a  	or b -	jr nz,ApplyDamageToEnemyPokemon +	jr nz, ApplyDamageToEnemyPokemon  ; make sure Super Fang's damage is always at least 1 -	ld a,$01 -	ld [de],a +	ld a, $01 +	ld [de], a  	jr ApplyDamageToEnemyPokemon  .specialDamage -	ld hl,wBattleMonLevel -	ld a,[hl] -	ld b,a ; Seismic Toss deals damage equal to the user's level -	ld a,[wPlayerMoveNum] -	cp a,SEISMIC_TOSS -	jr z,.storeDamage -	cp a,NIGHT_SHADE -	jr z,.storeDamage -	ld b,SONICBOOM_DAMAGE ; 20 -	cp a,SONICBOOM -	jr z,.storeDamage -	ld b,DRAGON_RAGE_DAMAGE ; 40 -	cp a,DRAGON_RAGE -	jr z,.storeDamage +	ld hl, wBattleMonLevel +	ld a, [hl] +	ld b, a ; Seismic Toss deals damage equal to the user's level +	ld a, [wPlayerMoveNum] +	cp SEISMIC_TOSS +	jr z, .storeDamage +	cp NIGHT_SHADE +	jr z, .storeDamage +	ld b, SONICBOOM_DAMAGE ; 20 +	cp SONICBOOM +	jr z, .storeDamage +	ld b, DRAGON_RAGE_DAMAGE ; 40 +	cp DRAGON_RAGE +	jr z, .storeDamage  ; Psywave -	ld a,[hl] -	ld b,a +	ld a, [hl] +	ld b, a  	srl a  	add b -	ld b,a ; b = level * 1.5 +	ld b, a ; b = level * 1.5  ; loop until a random number in the range [1, b) is found  .loop  	call BattleRandom  	and a -	jr z,.loop +	jr z, .loop  	cp b -	jr nc,.loop -	ld b,a +	jr nc, .loop +	ld b, a  .storeDamage ; store damage value at b -	ld hl,wDamage +	ld hl, wDamage  	xor a -	ld [hli],a -	ld a,b -	ld [hl],a +	ld [hli], a +	ld a, b +	ld [hl], a  ApplyDamageToEnemyPokemon: -	ld hl,wDamage -	ld a,[hli] -	ld b,a -	ld a,[hl] +	ld hl, wDamage +	ld a, [hli] +	ld b, a +	ld a, [hl]  	or b -	jr z,ApplyAttackToEnemyPokemonDone ; we're done if damage is 0 -	ld a,[wEnemyBattleStatus2] -	bit HAS_SUBSTITUTE_UP,a ; does the enemy have a substitute? -	jp nz,AttackSubstitute +	jr z, ApplyAttackToEnemyPokemonDone ; we're done if damage is 0 +	ld a, [wEnemyBattleStatus2] +	bit HAS_SUBSTITUTE_UP, a ; does the enemy have a substitute? +	jp nz, AttackSubstitute  ; subtract the damage from the pokemon's current HP  ; also, save the current HP at wHPBarOldHP -	ld a,[hld] -	ld b,a -	ld a,[wEnemyMonHP + 1] -	ld [wHPBarOldHP],a +	ld a, [hld] +	ld b, a +	ld a, [wEnemyMonHP + 1] +	ld [wHPBarOldHP], a  	sub b -	ld [wEnemyMonHP + 1],a -	ld a,[hl] -	ld b,a -	ld a,[wEnemyMonHP] -	ld [wHPBarOldHP+1],a +	ld [wEnemyMonHP + 1], a +	ld a, [hl] +	ld b, a +	ld a, [wEnemyMonHP] +	ld [wHPBarOldHP+1], a  	sbc b -	ld [wEnemyMonHP],a -	jr nc,.animateHpBar +	ld [wEnemyMonHP], a +	jr nc, .animateHpBar  ; if more damage was done than the current HP, zero the HP and set the damage (wDamage)  ; equal to how much HP the pokemon had before the attack -	ld a,[wHPBarOldHP+1] -	ld [hli],a -	ld a,[wHPBarOldHP] -	ld [hl],a -	xor a -	ld hl,wEnemyMonHP -	ld [hli],a -	ld [hl],a +	ld a, [wHPBarOldHP+1] +	ld [hli], a +	ld a, [wHPBarOldHP] +	ld [hl], a +	xor a +	ld hl, wEnemyMonHP +	ld [hli], a +	ld [hl], a  .animateHpBar -	ld hl,wEnemyMonMaxHP -	ld a,[hli] -	ld [wHPBarMaxHP+1],a -	ld a,[hl] -	ld [wHPBarMaxHP],a -	ld hl,wEnemyMonHP -	ld a,[hli] -	ld [wHPBarNewHP+1],a -	ld a,[hl] -	ld [wHPBarNewHP],a +	ld hl, wEnemyMonMaxHP +	ld a, [hli] +	ld [wHPBarMaxHP+1], a +	ld a, [hl] +	ld [wHPBarMaxHP], a +	ld hl, wEnemyMonHP +	ld a, [hli] +	ld [wHPBarNewHP+1], a +	ld a, [hl] +	ld [wHPBarNewHP], a  	coord hl, 2, 2  	xor a -	ld [wHPBarType],a +	ld [wHPBarType], a  	predef UpdateHPBar2 ; animate the HP bar shortening  ApplyAttackToEnemyPokemonDone:  	jp DrawHUDsAndHPBars  ApplyAttackToPlayerPokemon: -	ld a,[wEnemyMoveEffect] -	cp a,OHKO_EFFECT -	jr z,ApplyDamageToPlayerPokemon -	cp a,SUPER_FANG_EFFECT -	jr z,.superFangEffect -	cp a,SPECIAL_DAMAGE_EFFECT -	jr z,.specialDamage -	ld a,[wEnemyMovePower] -	and a -	jp z,ApplyAttackToPlayerPokemonDone +	ld a, [wEnemyMoveEffect] +	cp OHKO_EFFECT +	jr z, ApplyDamageToPlayerPokemon +	cp SUPER_FANG_EFFECT +	jr z, .superFangEffect +	cp SPECIAL_DAMAGE_EFFECT +	jr z, .specialDamage +	ld a, [wEnemyMovePower] +	and a +	jp z, ApplyAttackToPlayerPokemonDone  	jr ApplyDamageToPlayerPokemon  .superFangEffect  ; set the damage to half the target's HP -	ld hl,wBattleMonHP -	ld de,wDamage -	ld a,[hli] +	ld hl, wBattleMonHP +	ld de, wDamage +	ld a, [hli]  	srl a -	ld [de],a +	ld [de], a  	inc de -	ld b,a -	ld a,[hl] +	ld b, a +	ld a, [hl]  	rr a -	ld [de],a +	ld [de], a  	or b -	jr nz,ApplyDamageToPlayerPokemon +	jr nz, ApplyDamageToPlayerPokemon  ; make sure Super Fang's damage is always at least 1 -	ld a,$01 -	ld [de],a +	ld a, $01 +	ld [de], a  	jr ApplyDamageToPlayerPokemon  .specialDamage -	ld hl,wEnemyMonLevel -	ld a,[hl] -	ld b,a -	ld a,[wEnemyMoveNum] -	cp a,SEISMIC_TOSS -	jr z,.storeDamage -	cp a,NIGHT_SHADE -	jr z,.storeDamage -	ld b,SONICBOOM_DAMAGE -	cp a,SONICBOOM -	jr z,.storeDamage -	ld b,DRAGON_RAGE_DAMAGE -	cp a,DRAGON_RAGE -	jr z,.storeDamage +	ld hl, wEnemyMonLevel +	ld a, [hl] +	ld b, a +	ld a, [wEnemyMoveNum] +	cp SEISMIC_TOSS +	jr z, .storeDamage +	cp NIGHT_SHADE +	jr z, .storeDamage +	ld b, SONICBOOM_DAMAGE +	cp SONICBOOM +	jr z, .storeDamage +	ld b, DRAGON_RAGE_DAMAGE +	cp DRAGON_RAGE +	jr z, .storeDamage  ; Psywave -	ld a,[hl] -	ld b,a +	ld a, [hl] +	ld b, a  	srl a  	add b -	ld b,a ; b = attacker's level * 1.5 +	ld b, a ; b = attacker's level * 1.5  ; loop until a random number in the range [0, b) is found  ; this differs from the range when the player attacks, which is [1, b)  ; it's possible for the enemy to do 0 damage with Psywave, but the player always does at least 1 damage  .loop  	call BattleRandom  	cp b -	jr nc,.loop -	ld b,a +	jr nc, .loop +	ld b, a  .storeDamage -	ld hl,wDamage +	ld hl, wDamage  	xor a -	ld [hli],a -	ld a,b -	ld [hl],a +	ld [hli], a +	ld a, b +	ld [hl], a  ApplyDamageToPlayerPokemon: -	ld hl,wDamage -	ld a,[hli] -	ld b,a -	ld a,[hl] +	ld hl, wDamage +	ld a, [hli] +	ld b, a +	ld a, [hl]  	or b -	jr z,ApplyAttackToPlayerPokemonDone ; we're done if damage is 0 -	ld a,[wPlayerBattleStatus2] -	bit HAS_SUBSTITUTE_UP,a ; does the player have a substitute? -	jp nz,AttackSubstitute +	jr z, ApplyAttackToPlayerPokemonDone ; we're done if damage is 0 +	ld a, [wPlayerBattleStatus2] +	bit HAS_SUBSTITUTE_UP, a ; does the player have a substitute? +	jp nz, AttackSubstitute  ; subtract the damage from the pokemon's current HP  ; also, save the current HP at wHPBarOldHP and the new HP at wHPBarNewHP -	ld a,[hld] -	ld b,a -	ld a,[wBattleMonHP + 1] -	ld [wHPBarOldHP],a +	ld a, [hld] +	ld b, a +	ld a, [wBattleMonHP + 1] +	ld [wHPBarOldHP], a  	sub b -	ld [wBattleMonHP + 1],a -	ld [wHPBarNewHP],a -	ld b,[hl] -	ld a,[wBattleMonHP] -	ld [wHPBarOldHP+1],a +	ld [wBattleMonHP + 1], a +	ld [wHPBarNewHP], a +	ld b, [hl] +	ld a, [wBattleMonHP] +	ld [wHPBarOldHP+1], a  	sbc b -	ld [wBattleMonHP],a -	ld [wHPBarNewHP+1],a -	jr nc,.animateHpBar +	ld [wBattleMonHP], a +	ld [wHPBarNewHP+1], a +	jr nc, .animateHpBar  ; if more damage was done than the current HP, zero the HP and set the damage (wDamage)  ; equal to how much HP the pokemon had before the attack -	ld a,[wHPBarOldHP+1] -	ld [hli],a -	ld a,[wHPBarOldHP] -	ld [hl],a -	xor a -	ld hl,wBattleMonHP -	ld [hli],a -	ld [hl],a -	ld hl,wHPBarNewHP -	ld [hli],a -	ld [hl],a +	ld a, [wHPBarOldHP+1] +	ld [hli], a +	ld a, [wHPBarOldHP] +	ld [hl], a +	xor a +	ld hl, wBattleMonHP +	ld [hli], a +	ld [hl], a +	ld hl, wHPBarNewHP +	ld [hli], a +	ld [hl], a  .animateHpBar -	ld hl,wBattleMonMaxHP -	ld a,[hli] -	ld [wHPBarMaxHP+1],a -	ld a,[hl] -	ld [wHPBarMaxHP],a +	ld hl, wBattleMonMaxHP +	ld a, [hli] +	ld [wHPBarMaxHP+1], a +	ld a, [hl] +	ld [wHPBarMaxHP], a  	coord hl, 10, 9 -	ld a,$01 -	ld [wHPBarType],a +	ld a, $01 +	ld [wHPBarType], a  	predef UpdateHPBar2 ; animate the HP bar shortening  ApplyAttackToPlayerPokemonDone:  	jp DrawHUDsAndHPBars @@ -5065,51 +5065,51 @@ AttackSubstitute:  ; Normal recoil such as from Double-Edge isn't affected by this glitch,  ; because this function is never called in that case. -	ld hl,SubstituteTookDamageText +	ld hl, SubstituteTookDamageText  	call PrintText  ; values for player turn -	ld de,wEnemySubstituteHP -	ld bc,wEnemyBattleStatus2 -	ld a,[H_WHOSETURN] +	ld de, wEnemySubstituteHP +	ld bc, wEnemyBattleStatus2 +	ld a, [H_WHOSETURN]  	and a -	jr z,.applyDamageToSubstitute +	jr z, .applyDamageToSubstitute  ; values for enemy turn -	ld de,wPlayerSubstituteHP -	ld bc,wPlayerBattleStatus2 +	ld de, wPlayerSubstituteHP +	ld bc, wPlayerBattleStatus2  .applyDamageToSubstitute -	ld hl,wDamage -	ld a,[hli] +	ld hl, wDamage +	ld a, [hli]  	and a -	jr nz,.substituteBroke ; damage > 0xFF always breaks substitutes +	jr nz, .substituteBroke ; damage > 0xFF always breaks substitutes  ; subtract damage from HP of substitute -	ld a,[de] +	ld a, [de]  	sub [hl] -	ld [de],a +	ld [de], a  	ret nc  .substituteBroke  ; If the target's Substitute breaks, wDamage isn't updated with the amount of HP  ; the Substitute had before being attacked. -	ld h,b -	ld l,c -	res HAS_SUBSTITUTE_UP,[hl] ; unset the substitute bit -	ld hl,SubstituteBrokeText +	ld h, b +	ld l, c +	res HAS_SUBSTITUTE_UP, [hl] ; unset the substitute bit +	ld hl, SubstituteBrokeText  	call PrintText  ; flip whose turn it is for the next function call -	ld a,[H_WHOSETURN] -	xor a,$01 -	ld [H_WHOSETURN],a +	ld a, [H_WHOSETURN] +	xor $01 +	ld [H_WHOSETURN], a  	callab HideSubstituteShowMonAnim ; animate the substitute breaking  ; flip the turn back to the way it was -	ld a,[H_WHOSETURN] -	xor a,$01 -	ld [H_WHOSETURN],a -	ld hl,wPlayerMoveEffect ; value for player's turn +	ld a, [H_WHOSETURN] +	xor $01 +	ld [H_WHOSETURN], a +	ld hl, wPlayerMoveEffect ; value for player's turn  	and a -	jr z,.nullifyEffect -	ld hl,wEnemyMoveEffect ; value for enemy's turn +	jr z, .nullifyEffect +	ld hl, wEnemyMoveEffect ; value for enemy's turn  .nullifyEffect  	xor a -	ld [hl],a ; zero the effect of the attacker's move +	ld [hl], a ; zero the effect of the attacker's move  	jp DrawHUDsAndHPBars  SubstituteTookDamageText: @@ -5123,44 +5123,44 @@ SubstituteBrokeText:  ; this function raises the attack modifier of a pokemon using Rage when that pokemon is attacked  HandleBuildingRage:  ; values for the player turn -	ld hl,wEnemyBattleStatus2 -	ld de,wEnemyMonStatMods -	ld bc,wEnemyMoveNum -	ld a,[H_WHOSETURN] +	ld hl, wEnemyBattleStatus2 +	ld de, wEnemyMonStatMods +	ld bc, wEnemyMoveNum +	ld a, [H_WHOSETURN]  	and a -	jr z,.next +	jr z, .next  ; values for the enemy turn -	ld hl,wPlayerBattleStatus2 -	ld de,wPlayerMonStatMods -	ld bc,wPlayerMoveNum +	ld hl, wPlayerBattleStatus2 +	ld de, wPlayerMonStatMods +	ld bc, wPlayerMoveNum  .next -	bit USING_RAGE,[hl] ; is the pokemon being attacked under the effect of Rage? +	bit USING_RAGE, [hl] ; is the pokemon being attacked under the effect of Rage?  	ret z ; return if not -	ld a,[de] -	cp a,$0d ; maximum stat modifier value +	ld a, [de] +	cp $0d ; maximum stat modifier value  	ret z ; return if attack modifier is already maxed -	ld a,[H_WHOSETURN] -	xor a,$01 ; flip turn for the stat modifier raising function -	ld [H_WHOSETURN],a +	ld a, [H_WHOSETURN] +	xor $01 ; flip turn for the stat modifier raising function +	ld [H_WHOSETURN], a  ; temporarily change the target pokemon's move to $00 and the effect to the one  ; that causes the attack modifier to go up one stage -	ld h,b -	ld l,c -	ld [hl],$00 ; null move number +	ld h, b +	ld l, c +	ld [hl], $00 ; null move number  	inc hl -	ld [hl],ATTACK_UP1_EFFECT +	ld [hl], ATTACK_UP1_EFFECT  	push hl -	ld hl,BuildingRageText +	ld hl, BuildingRageText  	call PrintText  	call StatModifierUpEffect ; stat modifier raising function  	pop hl  	xor a -	ldd [hl],a ; null move effect -	ld a,RAGE -	ld [hl],a ; restore the target pokemon's move number to Rage -	ld a,[H_WHOSETURN] -	xor a,$01 ; flip turn back to the way it was -	ld [H_WHOSETURN],a +	ldd [hl], a ; null move effect +	ld a, RAGE +	ld [hl], a ; restore the target pokemon's move number to Rage +	ld a, [H_WHOSETURN] +	xor $01 ; flip turn back to the way it was +	ld [H_WHOSETURN], a  	ret  BuildingRageText: @@ -5176,25 +5176,25 @@ MirrorMoveCopyMove:  ; ccf1 is also set to 0 whenever the player is fast asleep or frozen solid.  ; ccf2 is also set to 0 whenever the enemy is fast asleep or frozen solid. -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	and a  ; values for player turn -	ld a,[wEnemyUsedMove] -	ld hl,wPlayerSelectedMove -	ld de,wPlayerMoveNum -	jr z,.next +	ld a, [wEnemyUsedMove] +	ld hl, wPlayerSelectedMove +	ld de, wPlayerMoveNum +	jr z, .next  ; values for enemy turn -	ld a,[wPlayerUsedMove] -	ld de,wEnemyMoveNum -	ld hl,wEnemySelectedMove +	ld a, [wPlayerUsedMove] +	ld de, wEnemyMoveNum +	ld hl, wEnemySelectedMove  .next -	ld [hl],a -	cp a,MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss? -	jr z,.mirrorMoveFailed +	ld [hl], a +	cp MIRROR_MOVE ; did the target Pokemon last use Mirror Move, and miss? +	jr z, .mirrorMoveFailed  	and a ; has the target selected any move yet? -	jr nz,ReloadMoveData +	jr nz, ReloadMoveData  .mirrorMoveFailed -	ld hl,MirrorMoveFailedText +	ld hl, MirrorMoveFailedText  	call PrintText  	xor a  	ret @@ -5205,78 +5205,78 @@ MirrorMoveFailedText:  ; function used to reload move data for moves like Mirror Move and Metronome  ReloadMoveData: -	ld [wd11e],a +	ld [wd11e], a  	dec a -	ld hl,Moves -	ld bc,MoveEnd - Moves +	ld hl, Moves +	ld bc, MoveEnd - Moves  	call AddNTimes -	ld a,BANK(Moves) +	ld a, BANK(Moves)  	call FarCopyData ; copy the move's stats  	call IncrementMovePP  ; the follow two function calls are used to reload the move name  	call GetMoveName  	call CopyStringToCF4B -	ld a,$01 +	ld a, $01  	and a  	ret  ; function that picks a random move for metronome  MetronomePickMove:  	xor a -	ld [wAnimationType],a -	ld a,METRONOME +	ld [wAnimationType], a +	ld a, METRONOME  	call PlayMoveAnimation ; play Metronome's animation  ; values for player turn -	ld de,wPlayerMoveNum -	ld hl,wPlayerSelectedMove -	ld a,[H_WHOSETURN] +	ld de, wPlayerMoveNum +	ld hl, wPlayerSelectedMove +	ld a, [H_WHOSETURN]  	and a -	jr z,.pickMoveLoop +	jr z, .pickMoveLoop  ; values for enemy turn -	ld de,wEnemyMoveNum -	ld hl,wEnemySelectedMove +	ld de, wEnemyMoveNum +	ld hl, wEnemySelectedMove  ; loop to pick a random number in the range [1, $a5) to be the move used by Metronome  .pickMoveLoop  	call BattleRandom  	and a -	jr z,.pickMoveLoop -	cp a,NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number) -	jr nc,.pickMoveLoop -	cp a,METRONOME -	jr z,.pickMoveLoop -	ld [hl],a +	jr z, .pickMoveLoop +	cp NUM_ATTACKS + 1 ; max normal move number + 1 (this is Struggle's move number) +	jr nc, .pickMoveLoop +	cp METRONOME +	jr z, .pickMoveLoop +	ld [hl], a  	jr ReloadMoveData  ; this function increments the current move's PP  ; it's used to prevent moves that run another move within the same turn  ; (like Mirror Move and Metronome) from losing 2 PP  IncrementMovePP: -	ld a,[H_WHOSETURN] +	ld a, [H_WHOSETURN]  	and a  ; values for player turn -	ld hl,wBattleMonPP -	ld de,wPartyMon1PP -	ld a,[wPlayerMoveListIndex] -	jr z,.next +	ld hl, wBattleMonPP +	ld de, wPartyMon1PP +	ld a, [wPlayerMoveListIndex] +	jr z, .next  ; values for enemy turn -	ld hl,wEnemyMonPP -	ld de,wEnemyMon1PP -	ld a,[wEnemyMoveListIndex] +	ld hl, wEnemyMonPP +	ld de, wEnemyMon1PP +	ld a, [wEnemyMoveListIndex]  .next -	ld b,$00 -	ld c,a -	add hl,bc +	ld b, $00 +	ld c, a +	add hl, bc  	inc [hl] ; increment PP in the currently battling pokemon memory location -	ld h,d -	ld l,e -	add hl,bc -	ld a,[H_WHOSETURN] -	and a -	ld a,[wPlayerMonNumber] ; value for player turn -	jr z,.updatePP -	ld a,[wEnemyMonPartyPos] ; value for enemy turn +	ld h, d +	ld l, e +	add hl, bc +	ld a, [H_WHOSETURN] +	and a +	ld a, [wPlayerMonNumber] ; value for player turn +	jr z, .updatePP +	ld a, [wEnemyMonPartyPos] ; value for enemy turn  .updatePP -	ld bc,wEnemyMon2 - wEnemyMon1 +	ld bc, wEnemyMon2 - wEnemyMon1  	call AddNTimes  	inc [hl] ; increment PP in the party memory location  	ret @@ -5284,107 +5284,107 @@ IncrementMovePP:  ; function to adjust the base damage of an attack to account for type effectiveness  AdjustDamageForMoveType:  ; values for player turn -	ld hl,wBattleMonType -	ld a,[hli] -	ld b,a    ; b = type 1 of attacker -	ld c,[hl] ; c = type 2 of attacker -	ld hl,wEnemyMonType -	ld a,[hli] -	ld d,a    ; d = type 1 of defender -	ld e,[hl] ; e = type 2 of defender -	ld a,[wPlayerMoveType] -	ld [wMoveType],a -	ld a,[H_WHOSETURN] -	and a -	jr z,.next +	ld hl, wBattleMonType +	ld a, [hli] +	ld b, a    ; b = type 1 of attacker +	ld c, [hl] ; c = type 2 of attacker +	ld hl, wEnemyMonType +	ld a, [hli] +	ld d, a    ; d = type 1 of defender +	ld e, [hl] ; e = type 2 of defender +	ld a, [wPlayerMoveType] +	ld [wMoveType], a +	ld a, [H_WHOSETURN] +	and a +	jr z, .next  ; values for enemy turn -	ld hl,wEnemyMonType -	ld a,[hli] -	ld b,a    ; b = type 1 of attacker -	ld c,[hl] ; c = type 2 of attacker -	ld hl,wBattleMonType -	ld a,[hli] -	ld d,a    ; d = type 1 of defender -	ld e,[hl] ; e = type 2 of defender -	ld a,[wEnemyMoveType] -	ld [wMoveType],a +	ld hl, wEnemyMonType +	ld a, [hli] +	ld b, a    ; b = type 1 of attacker +	ld c, [hl] ; c = type 2 of attacker +	ld hl, wBattleMonType +	ld a, [hli] +	ld d, a    ; d = type 1 of defender +	ld e, [hl] ; e = type 2 of defender +	ld a, [wEnemyMoveType] +	ld [wMoveType], a  .next -	ld a,[wMoveType] +	ld a, [wMoveType]  	cp b ; does the move type match type 1 of the attacker? -	jr z,.sameTypeAttackBonus +	jr z, .sameTypeAttackBonus  	cp c ; does the move type match type 2 of the attacker? -	jr z,.sameTypeAttackBonus +	jr z, .sameTypeAttackBonus  	jr .skipSameTypeAttackBonus  .sameTypeAttackBonus  ; if the move type matches one of the attacker's types -	ld hl,wDamage + 1 -	ld a,[hld] -	ld h,[hl] -	ld l,a    ; hl = damage -	ld b,h -	ld c,l    ; bc = damage +	ld hl, wDamage + 1 +	ld a, [hld] +	ld h, [hl] +	ld l, a    ; hl = damage +	ld b, h +	ld c, l    ; bc = damage  	srl b  	rr c      ; bc = floor(0.5 * damage) -	add hl,bc ; hl = floor(1.5 * damage) +	add hl, bc ; hl = floor(1.5 * damage)  ; store damage -	ld a,h -	ld [wDamage],a -	ld a,l -	ld [wDamage + 1],a -	ld hl,wDamageMultipliers -	set 7,[hl] +	ld a, h +	ld [wDamage], a +	ld a, l +	ld [wDamage + 1], a +	ld hl, wDamageMultipliers +	set 7, [hl]  .skipSameTypeAttackBonus -	ld a,[wMoveType] -	ld b,a -	ld hl,TypeEffects +	ld a, [wMoveType] +	ld b, a +	ld hl, TypeEffects  .loop -	ld a,[hli] ; a = "attacking type" of the current type pair -	cp a,$ff -	jr z,.done +	ld a, [hli] ; a = "attacking type" of the current type pair +	cp $ff +	jr z, .done  	cp b ; does move type match "attacking type"? -	jr nz,.nextTypePair -	ld a,[hl] ; a = "defending type" of the current type pair +	jr nz, .nextTypePair +	ld a, [hl] ; a = "defending type" of the current type pair  	cp d ; does type 1 of defender match "defending type"? -	jr z,.matchingPairFound +	jr z, .matchingPairFound  	cp e ; does type 2 of defender match "defending type"? -	jr z,.matchingPairFound +	jr z, .matchingPairFound  	jr .nextTypePair  .matchingPairFound  ; if the move type matches the "attacking type" and one of the defender's types matches the "defending type"  	push hl  	push bc  	inc hl -	ld a,[wDamageMultipliers] -	and a,$80 -	ld b,a -	ld a,[hl] ; a = damage multiplier -	ld [H_MULTIPLIER],a +	ld a, [wDamageMultipliers] +	and $80 +	ld b, a +	ld a, [hl] ; a = damage multiplier +	ld [H_MULTIPLIER], a  	add b -	ld [wDamageMultipliers],a -	xor a -	ld [H_MULTIPLICAND],a -	ld hl,wDamage -	ld a,[hli] -	ld [H_MULTIPLICAND + 1],a -	ld a,[hld] -	ld [H_MULTIPLICAND + 2],a +	ld [wDamageMultipliers], a +	xor a +	ld [H_MULTIPLICAND], a +	ld hl, wDamage +	ld a, [hli] +	ld [H_MULTIPLICAND + 1], a +	ld a, [hld] +	ld [H_MULTIPLICAND + 2], a  	call Multiply -	ld a,10 -	ld [H_DIVISOR],a -	ld b,$04 +	ld a, 10 +	ld [H_DIVISOR], a +	ld b, $04  	call Divide -	ld a,[H_QUOTIENT + 2] -	ld [hli],a -	ld b,a -	ld a,[H_QUOTIENT + 3] -	ld [hl],a +	ld a, [H_QUOTIENT + 2] +	ld [hli], a +	ld b, a +	ld a, [H_QUOTIENT + 3] +	ld [hl], a  	or b ; is damage 0? -	jr nz,.skipTypeImmunity +	jr nz, .skipTypeImmunity  .typeImmunity  ; if damage is 0, make the move miss  ; this only occurs if a move that would do 2 or 3 damage is 0.25x effective against the target  	inc a -	ld [wMoveMissed],a +	ld [wMoveMissed], a  .skipTypeImmunity  	pop bc  	pop hl @@ -5402,26 +5402,26 @@ AdjustDamageForMoveType:  ; ($05 is not very effective, $10 is neutral, $14 is super effective)  ; as far is can tell, this is only used once in some AI code to help decide which move to use  AIGetTypeEffectiveness: -	ld a,[wEnemyMoveType] -	ld d,a                    ; d = type of enemy move -	ld hl,wBattleMonType -	ld b,[hl]                 ; b = type 1 of player's pokemon +	ld a, [wEnemyMoveType] +	ld d, a                    ; d = type of enemy move +	ld hl, wBattleMonType +	ld b, [hl]                 ; b = type 1 of player's pokemon  	inc hl -	ld c,[hl]                 ; c = type 2 of player's pokemon -	ld a,$10 -	ld [wTypeEffectiveness],a ; initialize to neutral effectiveness -	ld hl,TypeEffects +	ld c, [hl]                 ; c = type 2 of player's pokemon +	ld a, $10 +	ld [wTypeEffectiveness], a ; initialize to neutral effectiveness +	ld hl, TypeEffects  .loop -	ld a,[hli] -	cp a,$ff +	ld a, [hli] +	cp $ff  	ret z  	cp d                      ; match the type of the move -	jr nz,.nextTypePair1 -	ld a,[hli] +	jr nz, .nextTypePair1 +	ld a, [hli]  	cp b                      ; match with type 1 of pokemon -	jr z,.done +	jr z, .done  	cp c                      ; or match with type 2 of pokemon -	jr z,.done +	jr z, .done  	jr .nextTypePair2  .nextTypePair1  	inc hl @@ -5429,8 +5429,8 @@ AIGetTypeEffectiveness:  	inc hl  	jr .loop  .done -	ld a,[hl] -	ld [wTypeEffectiveness],a ; store damage multiplier +	ld a, [hl] +	ld [wTypeEffectiveness], a ; store damage multiplier  	ret  INCLUDE "data/type_effects.asm" @@ -5438,52 +5438,52 @@ INCLUDE "data/type_effects.asm"  ; some tests that need to pass for a move to hit  MoveHitTest:  ; player's turn -	ld hl,wEnemyBattleStatus1 -	ld de,wPlayerMoveEffect -	ld bc,wEnemyMonStatus -	ld a,[H_WHOSETURN] +	ld hl, wEnemyBattleStatus1 +	ld de, wPlayerMoveEffect +	ld bc, wEnemyMonStatus +	ld a, [H_WHOSETURN]  	and a -	jr z,.dreamEaterCheck +	jr z, .dreamEaterCheck  ; enemy's turn -	ld hl,wPlayerBattleStatus1 -	ld de,wEnemyMoveEffect -	ld bc,wBattleMonStatus +	ld hl, wPlayerBattleStatus1 +	ld de, wEnemyMoveEffect +	ld bc, wBattleMonStatus  .dreamEaterCheck -	ld a,[de] -	cp a,DREAM_EATER_EFFECT -	jr nz,.swiftCheck -	ld a,[bc] -	and a,SLP ; is the target pokemon sleeping? -	jp z,.moveMissed +	ld a, [de] +	cp DREAM_EATER_EFFECT +	jr nz, .swiftCheck +	ld a, [bc] +	and SLP ; is the target pokemon sleeping? +	jp z, .moveMissed  .swiftCheck -	ld a,[de] -	cp a,SWIFT_EFFECT +	ld a, [de] +	cp SWIFT_EFFECT  	ret z ; Swift never misses (interestingly, Azure Heights lists this is a myth, but it appears to be true)  	call CheckTargetSubstitute ; substitute check (note that this overwrites a) -	jr z,.checkForDigOrFlyStatus +	jr z, .checkForDigOrFlyStatus  ; this code is buggy. it's supposed to prevent HP draining moves from working on substitutes.  ; since $7b79 overwrites a with either $00 or $01, it never works. -	cp a,DRAIN_HP_EFFECT -	jp z,.moveMissed -	cp a,DREAM_EATER_EFFECT -	jp z,.moveMissed +	cp DRAIN_HP_EFFECT +	jp z, .moveMissed +	cp DREAM_EATER_EFFECT +	jp z, .moveMissed  .checkForDigOrFlyStatus -	bit INVULNERABLE,[hl] -	jp nz,.moveMissed -	ld a,[H_WHOSETURN] +	bit INVULNERABLE, [hl] +	jp nz, .moveMissed +	ld a, [H_WHOSETURN]  	and a -	jr nz,.enemyTurn +	jr nz, .enemyTurn  .playerTurn  ; this checks if the move effect is disallowed by mist -	ld a,[wPlayerMoveEffect] -	cp a,ATTACK_DOWN1_EFFECT -	jr c,.skipEnemyMistCheck -	cp a,HAZE_EFFECT + 1 -	jr c,.enemyMistCheck -	cp a,ATTACK_DOWN2_EFFECT -	jr c,.skipEnemyMistCheck -	cp a,REFLECT_EFFECT + 1 -	jr c,.enemyMistCheck +	ld a, [wPlayerMoveEffect] +	cp ATTACK_DOWN1_EFFECT +	jr c, .skipEnemyMistCheck +	cp HAZE_EFFECT + 1 +	jr c, .enemyMistCheck +	cp ATTACK_DOWN2_EFFECT +	jr c, .skipEnemyMistCheck +	cp REFLECT_EFFECT + 1 +	jr c, .enemyMistCheck  	jr .skipEnemyMistCheck  .enemyMistCheck  ; if move effect is from $12 to $19 inclusive or $3a to $41 inclusive @@ -5492,98 +5492,98 @@ MoveHitTest:  ; FLASH, CONVERSION*, HAZE*, SCREECH, LIGHT SCREEN*, REFLECT*  ; the moves that are marked with an asterisk are not affected since this  ; function is not called when those moves are used -	ld a,[wEnemyBattleStatus2] -	bit PROTECTED_BY_MIST,a ; is mon protected by mist? -	jp nz,.moveMissed +	ld a, [wEnemyBattleStatus2] +	bit PROTECTED_BY_MIST, a ; is mon protected by mist? +	jp nz, .moveMissed  .skipEnemyMistCheck -	ld a,[wPlayerBattleStatus2] -	bit USING_X_ACCURACY,a ; is the player using X Accuracy? +	ld a, [wPlayerBattleStatus2] +	bit USING_X_ACCURACY, a ; is the player using X Accuracy?  	ret nz ; if so, always hit regardless of accuracy/evasion  	jr .calcHitChance  .enemyTurn -	ld a,[wEnemyMoveEffect] -	cp a,ATTACK_DOWN1_EFFECT -	jr c,.skipPlayerMistCheck -	cp a,HAZE_EFFECT + 1 -	jr c,.playerMistCheck -	cp a,ATTACK_DOWN2_EFFECT -	jr c,.skipPlayerMistCheck -	cp a,REFLECT_EFFECT + 1 -	jr c,.playerMistCheck +	ld a, [wEnemyMoveEffect] +	cp ATTACK_DOWN1_EFFECT +	jr c, .skipPlayerMistCheck +	cp HAZE_EFFECT + 1 +	jr c, .playerMistCheck +	cp ATTACK_DOWN2_EFFECT +	jr c, .skipPlayerMistCheck +	cp REFLECT_EFFECT + 1 +	jr c, .playerMistCheck  	jr .skipPlayerMistCheck  .playerMistCheck  ; similar to enemy mist check -	ld a,[wPlayerBattleStatus2] -	bit PROTECTED_BY_MIST,a ; is mon protected by mist? -	jp nz,.moveMissed +	ld a, [wPlayerBattleStatus2] +	bit PROTECTED_BY_MIST, a ; is mon protected by mist? +	jp nz, .moveMissed  .skipPlayerMistCheck -	ld a,[wEnemyBattleStatus2] -	bit USING_X_ACCURACY,a ; is the enemy using X Accuracy? +	ld a, [wEnemyBattleStatus2] +	bit USING_X_ACCURACY, a ; is the enemy using X Accuracy?  	ret nz ; if so, always hit regardless of accuracy/evasion  .calcHitChance  	call CalcHitChance ; scale the move accuracy according to attacker's accuracy and target's evasion -	ld a,[wPlayerMoveAccuracy] -	ld b,a -	ld a,[H_WHOSETURN] +	ld a, [wPlayerMoveAccuracy] +	ld b, a +	ld a, [H_WHOSETURN]  	and a -	jr z,.doAccuracyCheck -	ld a,[wEnemyMoveAccuracy] -	ld b,a +	jr z, .doAccuracyCheck +	ld a, [wEnemyMoveAccuracy] +	ld b, a  .doAccuracyCheck  ; if the random number generated is greater than or equal to the scaled accuracy, the move misses  ; note that this means that even the highest accuracy is still just a 255/256 chance, not 100%  	call BattleRandom  	cp b -	jr nc,.moveMissed +	jr nc, .moveMissed  	ret  .moveMissed  	xor a -	ld hl,wDamage ; zero the damage -	ld [hli],a -	ld [hl],a +	ld hl, wDamage ; zero the damage +	ld [hli], a +	ld [hl], a  	inc a -	ld [wMoveMissed],a -	ld a,[H_WHOSETURN] +	ld [wMoveMissed], a +	ld a, [H_WHOSETURN]  	and a -	jr z,.playerTurn2 +	jr z, .playerTurn2  .enemyTurn2 -	ld hl,wEnemyBattleStatus1 -	res USING_TRAPPING_MOVE,[hl] ; end multi-turn attack e.g. wrap +	ld hl, wEnemyBattleStatus1 +	res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap  	ret  .playerTurn2 -	ld hl,wPlayerBattleStatus1 -	res USING_TRAPPING_MOVE,[hl] ; end multi-turn attack e.g. wrap +	ld hl, wPlayerBattleStatus1 +	res USING_TRAPPING_MOVE, [hl] ; end multi-turn attack e.g. wrap  	ret  ; values for player turn  CalcHitChance: -	ld hl,wPlayerMoveAccuracy -	ld a,[H_WHOSETURN] -	and a -	ld a,[wPlayerMonAccuracyMod] -	ld b,a -	ld a,[wEnemyMonEvasionMod] -	ld c,a -	jr z,.next +	ld hl, wPlayerMoveAccuracy +	ld a, [H_WHOSETURN] +	and a +	ld a, [wPlayerMonAccuracyMod] +	ld b, a +	ld a, [wEnemyMonEvasionMod] +	ld c, a +	jr z, .next  ; values for enemy turn -	ld hl,wEnemyMoveAccuracy -	ld a,[wEnemyMonAccuracyMod] -	ld b,a -	ld a,[wPlayerMonEvasionMod] -	ld c,a +	ld hl, wEnemyMoveAccuracy +	ld a, [wEnemyMonAccuracyMod] +	ld b, a +	ld a, [wPlayerMonEvasionMod] +	ld c, a  .next -	ld a,$0e +	ld a, $0e  	sub c -	ld c,a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion +	ld c, a ; c = 14 - EVASIONMOD (this "reflects" the value over 7, so that an increase in the target's evasion  	       ; decreases the hit chance instead of increasing the hit chance)  ; zero the high bytes of the multiplicand  	xor a -	ld [H_MULTIPLICAND],a -	ld [H_MULTIPLICAND + 1],a -	ld a,[hl] -	ld [H_MULTIPLICAND + 2],a ; set multiplicand to move accuracy +	ld [H_MULTIPLICAND], a +	ld [H_MULTIPLICAND + 1], a +	ld a, [hl] +	ld [H_MULTIPLICAND + 2], a ; set multiplicand to move accuracy  	push hl -	ld d,$02 ; loop has two iterations +	ld d, $02 ; loop has two iterations  ; loop to do the calculations, the first iteration multiplies by the accuracy ratio and  ; the second iteration multiplies by the evasion ratio  .loop @@ -5591,40 +5591,40 @@ CalcHitChance:  	ld hl, StatModifierRatios  ; stat modifier ratios  	dec b  	sla b -	ld c,b -	ld b,$00 -	add hl,bc ; hl = address of stat modifier ratio +	ld c, b +	ld b, $00 +	add hl, bc ; hl = address of stat modifier ratio  	pop bc -	ld a,[hli] -	ld [H_MULTIPLIER],a ; set multiplier to the numerator of the ratio +	ld a, [hli] +	ld [H_MULTIPLIER], a ; set multiplier to the numerator of the ratio  	call Multiply -	ld a,[hl] -	ld [H_DIVISOR],a ; set divisor to the the denominator of the ratio +	ld a, [hl] +	ld [H_DIVISOR], a ; set divisor to the the denominator of the ratio  	                 ; (the dividend is the product of the previous multiplication) -	ld b,$04 ; number of bytes in the dividend +	ld b, $04 ; number of bytes in the dividend  	call Divide -	ld a,[H_QUOTIENT + 3] -	ld b,a -	ld a,[H_QUOTIENT + 2] +	ld a, [H_QUOTIENT + 3] +	ld b, a +	ld a, [H_QUOTIENT + 2]  	or b -	jp nz,.nextCalculation +	jp nz, .nextCalculation  ; make sure the result is always at least one -	ld [H_QUOTIENT + 2],a -	ld a,$01 -	ld [H_QUOTIENT + 3],a +	ld [H_QUOTIENT + 2], a +	ld a, $01 +	ld [H_QUOTIENT + 3], a  .nextCalculation -	ld b,c +	ld b, c  	dec d -	jr nz,.loop -	ld a,[H_QUOTIENT + 2] +	jr nz, .loop +	ld a, [H_QUOTIENT + 2]  	and a ; is the calculated hit chance over 0xFF? -	ld a,[H_QUOTIENT + 3] -	jr z,.storeAccuracy +	ld a, [H_QUOTIENT + 3] +	jr z, .storeAccuracy  ; if calculated hit chance over 0xFF -	ld a,$ff ; set the hit chance to 0xFF +	ld a, $ff ; set the hit chance to 0xFF  .storeAccuracy  	pop hl -	ld [hl],a ; store the hit chance in the move accuracy variable +	ld [hl], a ; store the hit chance in the move accuracy variable  	ret  ; multiplies damage by a random percentage from ~85% to 100% @@ -5805,7 +5805,7 @@ EnemyCheckIfFlyOrChargeEffect:  .playAnim  	xor a  	ld [wAnimationType], a -	ld a,STATUS_AFFECTED_ANIM +	ld a, STATUS_AFFECTED_ANIM  	call PlayMoveAnimation  EnemyCheckIfMirrorMoveEffect:  	ld a, [wEnemyMoveEffect] @@ -5897,7 +5897,7 @@ CheckEnemyStatusConditions:  	call PrintText  	xor a  	ld [wAnimationType], a -	ld a,SLP_ANIM +	ld a, SLP_ANIM  	call PlayMoveAnimation  	jr .sleepDone  .wokeUp @@ -5973,7 +5973,7 @@ CheckEnemyStatusConditions:  	call PrintText  	xor a  	ld [wAnimationType], a -	ld a,CONF_ANIM +	ld a, CONF_ANIM  	call PlayMoveAnimation  	call BattleRandom  	cp $80 @@ -6830,7 +6830,7 @@ HandleExplodingAnimation:  	ld [wAnimationType], a  PlayMoveAnimation: -	ld [wAnimationID],a +	ld [wAnimationID], a  	call Delay3  	predef_jump MoveAnimation @@ -7417,11 +7417,11 @@ FreezeBurnParalyzeEffect:  	cp b ; do target type 2 and move type match?  	ret z  ; return if they match  	ld a, [wPlayerMoveEffect] -	cp a, PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those +	cp PARALYZE_SIDE_EFFECT1 + 1 ; 10% status effects are 04, 05, 06 so 07 will set carry for those  	ld b, $1a ; 0x1A/0x100 or 26/256 = 10.2%~ chance  	jr c, .next1 ; branch ahead if this is a 10% chance effect..  	ld b, $4d ; else use 0x4D/0x100 or 77/256 = 30.1%~ chance -	sub a, $1e ; subtract $1E to map to equivalent 10% chance effects +	sub $1e ; subtract $1E to map to equivalent 10% chance effects  .next1  	push af  	call BattleRandom ; get random 8bit value for probability test @@ -7429,9 +7429,9 @@ FreezeBurnParalyzeEffect:  	pop bc  	ret nc ; do nothing if random value is >= 1A or 4D [no status applied]  	ld a, b ; what type of effect is this? -	cp a, BURN_SIDE_EFFECT1 +	cp BURN_SIDE_EFFECT1  	jr z, .burn -	cp a, FREEZE_SIDE_EFFECT +	cp FREEZE_SIDE_EFFECT  	jr z, .freeze  ; .paralyze  	ld a, 1 << PAR @@ -7469,11 +7469,11 @@ opponentAttacker:  	cp b  	ret z  	ld a, [wEnemyMoveEffect] -	cp a, PARALYZE_SIDE_EFFECT1 + 1 +	cp PARALYZE_SIDE_EFFECT1 + 1  	ld b, $1a  	jr c, .next1  	ld b, $4d -	sub a, $1e +	sub $1e  .next1  	push af  	call BattleRandom @@ -7481,9 +7481,9 @@ opponentAttacker:  	pop bc  	ret nc  	ld a, b -	cp a, BURN_SIDE_EFFECT1 +	cp BURN_SIDE_EFFECT1  	jr z, .burn -	cp a, FREEZE_SIDE_EFFECT +	cp FREEZE_SIDE_EFFECT  	jr z, .freeze  	ld a, 1 << PAR  	ld [wBattleMonStatus], a @@ -7512,14 +7512,14 @@ FrozenText:  CheckDefrost:  ; any fire-type move that has a chance inflict burn (all but Fire Spin) will defrost a frozen target -	and a, 1 << FRZ ; are they frozen? +	and 1 << FRZ ; are they frozen?  	ret z ; return if so  	ld a, [H_WHOSETURN]  	and a  	jr nz, .opponent  	;player [attacker]  	ld a, [wPlayerMoveType] -	sub a, FIRE +	sub FIRE  	ret nz ; return if type of move used isn't fire  	ld [wEnemyMonStatus], a ; set opponent status to 00 ["defrost" a frozen monster]  	ld hl, wEnemyMon1Status @@ -7532,7 +7532,7 @@ CheckDefrost:  	jr .common  .opponent  	ld a, [wEnemyMoveType] ; same as above with addresses swapped -	sub a, FIRE +	sub FIRE  	ret nz  	ld [wBattleMonStatus], a  	ld hl, wPartyMon1Status diff --git a/engine/battle/decrement_pp.asm b/engine/battle/decrement_pp.asm index 39cd0809..b7c428f7 100644 --- a/engine/battle/decrement_pp.asm +++ b/engine/battle/decrement_pp.asm @@ -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 diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm index 85f2bc3e..1bf14460 100644 --- a/engine/battle/display_effectiveness.asm +++ b/engine/battle/display_effectiveness.asm @@ -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 diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm index 3672d8dc..ba00083b 100755 --- a/engine/battle/read_trainer_party.asm +++ b/engine/battle/read_trainer_party.asm @@ -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 diff --git a/engine/battle/save_trainer_name.asm b/engine/battle/save_trainer_name.asm index 7e2c911c..49d0429f 100644 --- a/engine/battle/save_trainer_name.asm +++ b/engine/battle/save_trainer_name.asm @@ -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: diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index fff064fa..6f699b9c 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -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 diff --git a/engine/display_text_id_init.asm b/engine/display_text_id_init.asm index 312d6329..59b3a5f8 100644 --- a/engine/display_text_id_init.asm +++ b/engine/display_text_id_init.asm @@ -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 diff --git a/engine/hall_of_fame.asm b/engine/hall_of_fame.asm index 9eb4edc5..3c9b1723 100755 --- a/engine/hall_of_fame.asm +++ b/engine/hall_of_fame.asm @@ -6,7 +6,7 @@ AnimateHallOfFame:  	call LoadFontTilePatterns  	call LoadTextBoxTilePatterns  	call DisableLCD -	ld hl,vBGMap0 +	ld hl, vBGMap0  	ld bc, $800  	ld a, " "  	call FillMemory diff --git a/engine/in_game_trades.asm b/engine/in_game_trades.asm index a1fe85bc..c01bc3c3 100755 --- a/engine/in_game_trades.asm +++ b/engine/in_game_trades.asm @@ -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: diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index 1294ed8d..d07f64eb 100644 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -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 diff --git a/engine/items/items.asm b/engine/items/items.asm index 81c4c615..ada4d7db 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1,18 +1,18 @@  UseItem_: -	ld a,1 -	ld [wActionResultOrTookBattleTurn],a ; initialise to success value -	ld a,[wcf91] ;contains item_ID -	cp a,HM_01 -	jp nc,ItemUseTMHM -	ld hl,ItemUsePtrTable +	ld a, 1 +	ld [wActionResultOrTookBattleTurn], a ; initialise to success value +	ld a, [wcf91] ;contains item_ID +	cp HM_01 +	jp nc, ItemUseTMHM +	ld hl, ItemUsePtrTable  	dec a  	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  	jp hl  ItemUsePtrTable: @@ -103,75 +103,75 @@ ItemUsePtrTable:  ItemUseBall:  ; Balls can't be used out of battle. -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp z,ItemUseNotTime +	jp z, ItemUseNotTime  ; Balls can't catch trainers' Pokémon.  	dec a -	jp nz,ThrowBallAtTrainerMon +	jp nz, ThrowBallAtTrainerMon  ; If this is for the old man battle, skip checking if the party & box are full. -	ld a,[wBattleType] +	ld a, [wBattleType]  	dec a -	jr z,.canUseBall +	jr z, .canUseBall -	ld a,[wPartyCount] ; is party full? -	cp a,PARTY_LENGTH -	jr nz,.canUseBall -	ld a,[wNumInBox] ; is box full? -	cp a,MONS_PER_BOX -	jp z,BoxFullCannotThrowBall +	ld a, [wPartyCount] ; is party full? +	cp PARTY_LENGTH +	jr nz, .canUseBall +	ld a, [wNumInBox] ; is box full? +	cp MONS_PER_BOX +	jp z, BoxFullCannotThrowBall  .canUseBall  	xor a -	ld [wCapturedMonSpecies],a +	ld [wCapturedMonSpecies], a -	ld a,[wBattleType] -	cp a,BATTLE_TYPE_SAFARI -	jr nz,.skipSafariZoneCode +	ld a, [wBattleType] +	cp BATTLE_TYPE_SAFARI +	jr nz, .skipSafariZoneCode  .safariZone -	ld hl,wNumSafariBalls +	ld hl, wNumSafariBalls  	dec [hl] ; remove a Safari Ball  .skipSafariZoneCode  	call RunDefaultPaletteCommand -	ld a,$43 ; successful capture value -	ld [wPokeBallAnimData],a +	ld a, $43 ; successful capture value +	ld [wPokeBallAnimData], a  	call LoadScreenTilesFromBuffer1 -	ld hl,ItemUseText00 +	ld hl, ItemUseText00  	call PrintText  ; If the player is fighting an unidentified ghost, set the value that indicates  ; the Pokémon can't be caught and skip the capture calculations.  	callab IsGhostBattle -	ld b,$10 ; can't be caught value -	jp z,.setAnimData +	ld b, $10 ; can't be caught value +	jp z, .setAnimData -	ld a,[wBattleType] +	ld a, [wBattleType]  	dec a -	jr nz,.notOldManBattle +	jr nz, .notOldManBattle  .oldManBattle -	ld hl,wGrassRate -	ld de,wPlayerName -	ld bc,NAME_LENGTH +	ld hl, wGrassRate +	ld de, wPlayerName +	ld bc, NAME_LENGTH  	call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno. glitch)  	jp .captured  .notOldManBattle  ; If the player is fighting the ghost Marowak, set the value that indicates the  ; Pokémon can't be caught and skip the capture calculations. -	ld a,[wCurMap] -	cp a,POKEMONTOWER_6 -	jr nz,.loop -	ld a,[wEnemyMonSpecies2] -	cp a,MAROWAK -	ld b,$10 ; can't be caught value -	jp z,.setAnimData +	ld a, [wCurMap] +	cp POKEMONTOWER_6 +	jr nz, .loop +	ld a, [wEnemyMonSpecies2] +	cp MAROWAK +	ld b, $10 ; can't be caught value +	jp z, .setAnimData  ; Get the first random number. Let it be called Rand1.  ; Rand1 must be within a certain range according the kind of ball being thrown. @@ -183,34 +183,34 @@ ItemUseBall:  .loop  	call Random -	ld b,a +	ld b, a  ; Get the item ID. -	ld hl,wcf91 -	ld a,[hl] +	ld hl, wcf91 +	ld a, [hl]  ; The Master Ball always succeeds. -	cp a,MASTER_BALL -	jp z,.captured +	cp MASTER_BALL +	jp z, .captured  ; Anything will do for the basic Poké Ball. -	cp a,POKE_BALL -	jr z,.checkForAilments +	cp POKE_BALL +	jr z, .checkForAilments  ; If it's a Great/Ultra/Safari Ball and Rand1 is greater than 200, try again. -	ld a,200 +	ld a, 200  	cp b -	jr c,.loop +	jr c, .loop  ; Less than or equal to 200 is good enough for a Great Ball. -	ld a,[hl] -	cp a,GREAT_BALL -	jr z,.checkForAilments +	ld a, [hl] +	cp GREAT_BALL +	jr z, .checkForAilments  ; If it's an Ultra/Safari Ball and Rand1 is greater than 150, try again. -	ld a,150 +	ld a, 150  	cp b -	jr c,.loop +	jr c, .loop  .checkForAilments  ; Pokémon can be caught more easily with a status ailment. @@ -221,174 +221,174 @@ ItemUseBall:  ; Burn/Paralysis/Poison: Status = 12  ; Freeze/Sleep:          Status = 25  ; If Status is greater than Rand1, the Pokémon will be caught for sure. -	ld a,[wEnemyMonStatus] +	ld a, [wEnemyMonStatus]  	and a -	jr z,.skipAilmentValueSubtraction ; no ailments -	and a, 1 << FRZ | SLP -	ld c,12 -	jr z,.notFrozenOrAsleep -	ld c,25 +	jr z, .skipAilmentValueSubtraction ; no ailments +	and 1 << FRZ | SLP +	ld c, 12 +	jr z, .notFrozenOrAsleep +	ld c, 25  .notFrozenOrAsleep -	ld a,b +	ld a, b  	sub c -	jp c,.captured -	ld b,a +	jp c, .captured +	ld b, a  .skipAilmentValueSubtraction  	push bc ; save (Rand1 - Status)  ; Calculate MaxHP * 255.  	xor a -	ld [H_MULTIPLICAND],a -	ld hl,wEnemyMonMaxHP -	ld a,[hli] -	ld [H_MULTIPLICAND + 1],a -	ld a,[hl] -	ld [H_MULTIPLICAND + 2],a -	ld a,255 -	ld [H_MULTIPLIER],a +	ld [H_MULTIPLICAND], a +	ld hl, wEnemyMonMaxHP +	ld a, [hli] +	ld [H_MULTIPLICAND + 1], a +	ld a, [hl] +	ld [H_MULTIPLICAND + 2], a +	ld a, 255 +	ld [H_MULTIPLIER], a  	call Multiply  ; Determine BallFactor. It's 8 for Great Balls and 12 for the others. -	ld a,[wcf91] -	cp a,GREAT_BALL -	ld a,12 -	jr nz,.skip1 -	ld a,8 +	ld a, [wcf91] +	cp GREAT_BALL +	ld a, 12 +	jr nz, .skip1 +	ld a, 8  .skip1  ; Note that the results of all division operations are floored.  ; Calculate (MaxHP * 255) / BallFactor. -	ld [H_DIVISOR],a -	ld b,4 ; number of bytes in dividend +	ld [H_DIVISOR], a +	ld b, 4 ; number of bytes in dividend  	call Divide  ; Divide the enemy's current HP by 4. HP is not supposed to exceed 999 so  ; the result should fit in a. If the division results in a quotient of 0,  ; change it to 1. -	ld hl,wEnemyMonHP -	ld a,[hli] -	ld b,a -	ld a,[hl] +	ld hl, wEnemyMonHP +	ld a, [hli] +	ld b, a +	ld a, [hl]  	srl b  	rr a  	srl b  	rr a  	and a -	jr nz,.skip2 +	jr nz, .skip2  	inc a  .skip2  ; Let W = ((MaxHP * 255) / BallFactor) / max(HP / 4, 1). Calculate W. -	ld [H_DIVISOR],a -	ld b,4 +	ld [H_DIVISOR], a +	ld b, 4  	call Divide  ; If W > 255, store 255 in [H_QUOTIENT + 3].  ; Let X = min(W, 255) = [H_QUOTIENT + 3]. -	ld a,[H_QUOTIENT + 2] +	ld a, [H_QUOTIENT + 2]  	and a -	jr z,.skip3 -	ld a,255 -	ld [H_QUOTIENT + 3],a +	jr z, .skip3 +	ld a, 255 +	ld [H_QUOTIENT + 3], a  .skip3  	pop bc ; b = Rand1 - Status  ; If Rand1 - Status > CatchRate, the ball fails to capture the Pokémon. -	ld a,[wEnemyMonCatchRate] +	ld a, [wEnemyMonCatchRate]  	cp b -	jr c,.failedToCapture +	jr c, .failedToCapture  ; If W > 255, the ball captures the Pokémon. -	ld a,[H_QUOTIENT + 2] +	ld a, [H_QUOTIENT + 2]  	and a -	jr nz,.captured +	jr nz, .captured  	call Random ; Let this random number be called Rand2.  ; If Rand2 > X, the ball fails to capture the Pokémon. -	ld b,a -	ld a,[H_QUOTIENT + 3] +	ld b, a +	ld a, [H_QUOTIENT + 3]  	cp b -	jr c,.failedToCapture +	jr c, .failedToCapture  .captured  	jr .skipShakeCalculations  .failedToCapture -	ld a,[H_QUOTIENT + 3] -	ld [wPokeBallCaptureCalcTemp],a ; Save X. +	ld a, [H_QUOTIENT + 3] +	ld [wPokeBallCaptureCalcTemp], a ; Save X.  ; Calculate CatchRate * 100.  	xor a -	ld [H_MULTIPLICAND],a -	ld [H_MULTIPLICAND + 1],a -	ld a,[wEnemyMonCatchRate] -	ld [H_MULTIPLICAND + 2],a -	ld a,100 -	ld [H_MULTIPLIER],a +	ld [H_MULTIPLICAND], a +	ld [H_MULTIPLICAND + 1], a +	ld a, [wEnemyMonCatchRate] +	ld [H_MULTIPLICAND + 2], a +	ld a, 100 +	ld [H_MULTIPLIER], a  	call Multiply  ; Determine BallFactor2.  ; Poké Ball:         BallFactor2 = 255  ; Great Ball:        BallFactor2 = 200  ; Ultra/Safari Ball: BallFactor2 = 150 -	ld a,[wcf91] -	ld b,255 -	cp a,POKE_BALL -	jr z,.skip4 -	ld b,200 -	cp a,GREAT_BALL -	jr z,.skip4 -	ld b,150 -	cp a,ULTRA_BALL -	jr z,.skip4 +	ld a, [wcf91] +	ld b, 255 +	cp POKE_BALL +	jr z, .skip4 +	ld b, 200 +	cp GREAT_BALL +	jr z, .skip4 +	ld b, 150 +	cp ULTRA_BALL +	jr z, .skip4  .skip4  ; Let Y = (CatchRate * 100) / BallFactor2. Calculate Y. -	ld a,b -	ld [H_DIVISOR],a -	ld b,4 +	ld a, b +	ld [H_DIVISOR], a +	ld b, 4  	call Divide  ; If Y > 255, there are 3 shakes.  ; Note that this shouldn't be possible.  ; The maximum value of Y is (255 * 100) / 150 = 170. -	ld a,[H_QUOTIENT + 2] +	ld a, [H_QUOTIENT + 2]  	and a -	ld b,$63 ; 3 shakes -	jr nz,.setAnimData +	ld b, $63 ; 3 shakes +	jr nz, .setAnimData  ; Calculate X * Y. -	ld a,[wPokeBallCaptureCalcTemp] -	ld [H_MULTIPLIER],a +	ld a, [wPokeBallCaptureCalcTemp] +	ld [H_MULTIPLIER], a  	call Multiply  ; Calculate (X * Y) / 255. -	ld a,255 -	ld [H_DIVISOR],a -	ld b,4 +	ld a, 255 +	ld [H_DIVISOR], a +	ld b, 4  	call Divide  ; Determine Status2.  ; no status ailment:     Status2 = 0  ; Burn/Paralysis/Poison: Status2 = 5  ; Freeze/Sleep:          Status2 = 10 -	ld a,[wEnemyMonStatus] +	ld a, [wEnemyMonStatus]  	and a -	jr z,.skip5 -	and a, 1 << FRZ | SLP -	ld b,5 -	jr z,.addAilmentValue -	ld b,10 +	jr z, .skip5 +	and 1 << FRZ | SLP +	ld b, 5 +	jr z, .addAilmentValue +	ld b, 10  .addAilmentValue  ; If the Pokémon has a status ailment, add Status2. -	ld a,[H_QUOTIENT + 3] +	ld a, [H_QUOTIENT + 3]  	add b -	ld [H_QUOTIENT + 3],a +	ld [H_QUOTIENT + 3], a  .skip5  ; Finally determine the number of shakes. @@ -398,71 +398,71 @@ ItemUseBall:  ; 10 ≤ Z < 30: 1 shake  ; 30 ≤ Z < 70: 2 shakes  ; 70 ≤ Z:      3 shakes -	ld a,[H_QUOTIENT + 3] -	cp a,10 -	ld b,$20 -	jr c,.setAnimData -	cp a,30 -	ld b,$61 -	jr c,.setAnimData -	cp a,70 -	ld b,$62 -	jr c,.setAnimData -	ld b,$63 +	ld a, [H_QUOTIENT + 3] +	cp 10 +	ld b, $20 +	jr c, .setAnimData +	cp 30 +	ld b, $61 +	jr c, .setAnimData +	cp 70 +	ld b, $62 +	jr c, .setAnimData +	ld b, $63  .setAnimData -	ld a,b -	ld [wPokeBallAnimData],a +	ld a, b +	ld [wPokeBallAnimData], a  .skipShakeCalculations -	ld c,20 +	ld c, 20  	call DelayFrames  ; Do the animation. -	ld a,TOSS_ANIM -	ld [wAnimationID],a +	ld a, TOSS_ANIM +	ld [wAnimationID], a  	xor a -	ld [H_WHOSETURN],a -	ld [wAnimationType],a -	ld [wDamageMultipliers],a -	ld a,[wWhichPokemon] +	ld [H_WHOSETURN], a +	ld [wAnimationType], a +	ld [wDamageMultipliers], a +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] +	ld a, [wcf91]  	push af  	predef MoveAnimation  	pop af -	ld [wcf91],a +	ld [wcf91], a  	pop af -	ld [wWhichPokemon],a +	ld [wWhichPokemon], a  ; Determine the message to display from the animation. -	ld a,[wPokeBallAnimData] -	cp a,$10 -	ld hl,ItemUseBallText00 -	jp z,.printMessage -	cp a,$20 -	ld hl,ItemUseBallText01 -	jp z,.printMessage -	cp a,$61 -	ld hl,ItemUseBallText02 -	jp z,.printMessage -	cp a,$62 -	ld hl,ItemUseBallText03 -	jp z,.printMessage -	cp a,$63 -	ld hl,ItemUseBallText04 -	jp z,.printMessage +	ld a, [wPokeBallAnimData] +	cp $10 +	ld hl, ItemUseBallText00 +	jp z, .printMessage +	cp $20 +	ld hl, ItemUseBallText01 +	jp z, .printMessage +	cp $61 +	ld hl, ItemUseBallText02 +	jp z, .printMessage +	cp $62 +	ld hl, ItemUseBallText03 +	jp z, .printMessage +	cp $63 +	ld hl, ItemUseBallText04 +	jp z, .printMessage  ; Save current HP. -	ld hl,wEnemyMonHP -	ld a,[hli] +	ld hl, wEnemyMonHP +	ld a, [hli]  	push af -	ld a,[hli] +	ld a, [hli]  	push af  ; Save status ailment.  	inc hl -	ld a,[hl] +	ld a, [hl]  	push af  	push hl @@ -470,86 +470,86 @@ ItemUseBall:  ; If the Pokémon is transformed, the Pokémon is assumed to be a Ditto.  ; This is a bug because a wild Pokémon could have used Transform via  ; Mirror Move even though the only wild Pokémon that knows Transform is Ditto. -	ld hl,wEnemyBattleStatus3 -	bit TRANSFORMED,[hl] -	jr z,.notTransformed -	ld a,DITTO -	ld [wEnemyMonSpecies2],a +	ld hl, wEnemyBattleStatus3 +	bit TRANSFORMED, [hl] +	jr z, .notTransformed +	ld a, DITTO +	ld [wEnemyMonSpecies2], a  	jr .skip6  .notTransformed  ; If the Pokémon is not transformed, set the transformed bit and copy the  ; DVs to wTransformedEnemyMonOriginalDVs so that LoadEnemyMonData won't generate  ; new DVs. -	set TRANSFORMED,[hl] -	ld hl,wTransformedEnemyMonOriginalDVs -	ld a,[wEnemyMonDVs] -	ld [hli],a -	ld a,[wEnemyMonDVs + 1] -	ld [hl],a +	set TRANSFORMED, [hl] +	ld hl, wTransformedEnemyMonOriginalDVs +	ld a, [wEnemyMonDVs] +	ld [hli], a +	ld a, [wEnemyMonDVs + 1] +	ld [hl], a  .skip6 -	ld a,[wcf91] +	ld a, [wcf91]  	push af -	ld a,[wEnemyMonSpecies2] -	ld [wcf91],a -	ld a,[wEnemyMonLevel] -	ld [wCurEnemyLVL],a +	ld a, [wEnemyMonSpecies2] +	ld [wcf91], a +	ld a, [wEnemyMonLevel] +	ld [wCurEnemyLVL], a  	callab LoadEnemyMonData  	pop af -	ld [wcf91],a +	ld [wcf91], a  	pop hl  	pop af -	ld [hld],a +	ld [hld], a  	dec hl  	pop af -	ld [hld],a +	ld [hld], a  	pop af -	ld [hl],a -	ld a,[wEnemyMonSpecies] -	ld [wCapturedMonSpecies],a -	ld [wcf91],a -	ld [wd11e],a -	ld a,[wBattleType] +	ld [hl], a +	ld a, [wEnemyMonSpecies] +	ld [wCapturedMonSpecies], a +	ld [wcf91], a +	ld [wd11e], a +	ld a, [wBattleType]  	dec a ; is this the old man battle? -	jr z,.oldManCaughtMon ; if so, don't give the player the caught Pokémon +	jr z, .oldManCaughtMon ; if so, don't give the player the caught Pokémon -	ld hl,ItemUseBallText05 +	ld hl, ItemUseBallText05  	call PrintText  ; Add the caught Pokémon to the Pokédex.  	predef IndexToPokedex -	ld a,[wd11e] +	ld a, [wd11e]  	dec a -	ld c,a -	ld b,FLAG_TEST -	ld hl,wPokedexOwned +	ld c, a +	ld b, FLAG_TEST +	ld hl, wPokedexOwned  	predef FlagActionPredef -	ld a,c +	ld a, c  	push af -	ld a,[wd11e] +	ld a, [wd11e]  	dec a -	ld c,a -	ld b,FLAG_SET +	ld c, a +	ld b, FLAG_SET  	predef FlagActionPredef  	pop af  	and a ; was the Pokémon already in the Pokédex? -	jr nz,.skipShowingPokedexData ; if so, don't show the Pokédex data +	jr nz, .skipShowingPokedexData ; if so, don't show the Pokédex data -	ld hl,ItemUseBallText06 +	ld hl, ItemUseBallText06  	call PrintText  	call ClearSprites -	ld a,[wEnemyMonSpecies] -	ld [wd11e],a +	ld a, [wEnemyMonSpecies] +	ld [wd11e], a  	predef ShowPokedexData  .skipShowingPokedexData -	ld a,[wPartyCount] -	cp a,PARTY_LENGTH ; is party full? -	jr z,.sendToBox +	ld a, [wPartyCount] +	cp PARTY_LENGTH ; is party full? +	jr z, .sendToBox  	xor a ; PLAYER_PARTY_DATA -	ld [wMonDataLocation],a +	ld [wMonDataLocation], a  	call ClearSprites  	call AddPartyMon  	jr .done @@ -557,30 +557,30 @@ ItemUseBall:  .sendToBox  	call ClearSprites  	call SendNewMonToBox -	ld hl,ItemUseBallText07 +	ld hl, ItemUseBallText07  	CheckEvent EVENT_MET_BILL -	jr nz,.printTransferredToPCText -	ld hl,ItemUseBallText08 +	jr nz, .printTransferredToPCText +	ld hl, ItemUseBallText08  .printTransferredToPCText  	call PrintText  	jr .done  .oldManCaughtMon -	ld hl,ItemUseBallText05 +	ld hl, ItemUseBallText05  .printMessage  	call PrintText  	call ClearSprites  .done -	ld a,[wBattleType] +	ld a, [wBattleType]  	and a ; is this the old man battle?  	ret nz ; if so, don't remove a ball from the bag  ; Remove a ball from the bag. -	ld hl,wNumBagItems +	ld hl, wNumBagItems  	inc a -	ld [wItemQuantity],a +	ld [wItemQuantity], a  	jp RemoveItemFromInventory  ItemUseBallText00: @@ -629,119 +629,119 @@ ItemUseBallText06:  	db "@"  ItemUseTownMap: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime +	jp nz, ItemUseNotTime  	jpba DisplayTownMap  ItemUseBicycle: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime -	ld a,[wWalkBikeSurfState] -	ld [wWalkBikeSurfStateCopy],a -	cp a,2 ; is the player surfing? -	jp z,ItemUseNotTime +	jp nz, ItemUseNotTime +	ld a, [wWalkBikeSurfState] +	ld [wWalkBikeSurfStateCopy], a +	cp 2 ; is the player surfing? +	jp z, ItemUseNotTime  	dec a ; is player already bicycling? -	jr nz,.tryToGetOnBike +	jr nz, .tryToGetOnBike  .getOffBike  	call ItemUseReloadOverworldData  	xor a -	ld [wWalkBikeSurfState],a ; change player state to walking +	ld [wWalkBikeSurfState], a ; change player state to walking  	call PlayDefaultMusic ; play walking music -	ld hl,GotOffBicycleText +	ld hl, GotOffBicycleText  	jr .printText  .tryToGetOnBike  	call IsBikeRidingAllowed -	jp nc,NoCyclingAllowedHere +	jp nc, NoCyclingAllowedHere  	call ItemUseReloadOverworldData  	xor a ; no keys pressed -	ld [hJoyHeld],a ; current joypad state +	ld [hJoyHeld], a ; current joypad state  	inc a -	ld [wWalkBikeSurfState],a ; change player state to bicycling -	ld hl,GotOnBicycleText +	ld [wWalkBikeSurfState], a ; change player state to bicycling +	ld hl, GotOnBicycleText  	call PlayDefaultMusic ; play bike riding music  .printText  	jp PrintText  ; used for Surf out-of-battle effect  ItemUseSurfboard: -	ld a,[wWalkBikeSurfState] -	ld [wWalkBikeSurfStateCopy],a -	cp a,2 ; is the player already surfing? -	jr z,.tryToStopSurfing +	ld a, [wWalkBikeSurfState] +	ld [wWalkBikeSurfStateCopy], a +	cp 2 ; is the player already surfing? +	jr z, .tryToStopSurfing  .tryToSurf  	call IsNextTileShoreOrWater -	jp c,SurfingAttemptFailed -	ld hl,TilePairCollisionsWater +	jp c, SurfingAttemptFailed +	ld hl, TilePairCollisionsWater  	call CheckForTilePairCollisions -	jp c,SurfingAttemptFailed +	jp c, SurfingAttemptFailed  .surf  	call .makePlayerMoveForward -	ld hl,wd730 -	set 7,[hl] -	ld a,2 -	ld [wWalkBikeSurfState],a ; change player state to surfing +	ld hl, wd730 +	set 7, [hl] +	ld a, 2 +	ld [wWalkBikeSurfState], a ; change player state to surfing  	call PlayDefaultMusic ; play surfing music -	ld hl,SurfingGotOnText +	ld hl, SurfingGotOnText  	jp PrintText  .tryToStopSurfing  	xor a -	ld [hSpriteIndexOrTextID],a -	ld d,16 ; talking range in pixels (normal range) +	ld [hSpriteIndexOrTextID], a +	ld d, 16 ; talking range in pixels (normal range)  	call IsSpriteInFrontOfPlayer2 -	res 7,[hl] -	ld a,[hSpriteIndexOrTextID] +	res 7, [hl] +	ld a, [hSpriteIndexOrTextID]  	and a ; is there a sprite in the way? -	jr nz,.cannotStopSurfing -	ld hl,TilePairCollisionsWater +	jr nz, .cannotStopSurfing +	ld hl, TilePairCollisionsWater  	call CheckForTilePairCollisions -	jr c,.cannotStopSurfing -	ld hl,wTilesetCollisionPtr ; pointer to list of passable tiles -	ld a,[hli] -	ld h,[hl] -	ld l,a ; hl now points to passable tiles -	ld a,[wTileInFrontOfPlayer] ; tile in front of the player -	ld b,a +	jr c, .cannotStopSurfing +	ld hl, wTilesetCollisionPtr ; pointer to list of passable tiles +	ld a, [hli] +	ld h, [hl] +	ld l, a ; hl now points to passable tiles +	ld a, [wTileInFrontOfPlayer] ; tile in front of the player +	ld b, a  .passableTileLoop -	ld a,[hli] +	ld a, [hli]  	cp b -	jr z,.stopSurfing -	cp a,$ff -	jr nz,.passableTileLoop +	jr z, .stopSurfing +	cp $ff +	jr nz, .passableTileLoop  .cannotStopSurfing -	ld hl,SurfingNoPlaceToGetOffText +	ld hl, SurfingNoPlaceToGetOffText  	jp PrintText  .stopSurfing  	call .makePlayerMoveForward -	ld hl,wd730 -	set 7,[hl] +	ld hl, wd730 +	set 7, [hl]  	xor a -	ld [wWalkBikeSurfState],a ; change player state to walking +	ld [wWalkBikeSurfState], a ; change player state to walking  	dec a -	ld [wJoyIgnore],a +	ld [wJoyIgnore], a  	call PlayDefaultMusic ; play walking music  	jp LoadWalkingPlayerSpriteGraphics  ; uses a simulated button press to make the player move forward  .makePlayerMoveForward -	ld a,[wPlayerDirection] ; direction the player is going -	bit PLAYER_DIR_BIT_UP,a -	ld b,D_UP -	jr nz,.storeSimulatedButtonPress -	bit PLAYER_DIR_BIT_DOWN,a -	ld b,D_DOWN -	jr nz,.storeSimulatedButtonPress -	bit PLAYER_DIR_BIT_LEFT,a -	ld b,D_LEFT -	jr nz,.storeSimulatedButtonPress -	ld b,D_RIGHT +	ld a, [wPlayerDirection] ; direction the player is going +	bit PLAYER_DIR_BIT_UP, a +	ld b, D_UP +	jr nz, .storeSimulatedButtonPress +	bit PLAYER_DIR_BIT_DOWN, a +	ld b, D_DOWN +	jr nz, .storeSimulatedButtonPress +	bit PLAYER_DIR_BIT_LEFT, a +	ld b, D_LEFT +	jr nz, .storeSimulatedButtonPress +	ld b, D_RIGHT  .storeSimulatedButtonPress -	ld a,b -	ld [wSimulatedJoypadStatesEnd],a +	ld a, b +	ld [wSimulatedJoypadStatesEnd], a  	xor a -	ld [wWastedByteCD39],a +	ld [wWastedByteCD39], a  	inc a -	ld [wSimulatedJoypadStatesIndex],a +	ld [wSimulatedJoypadStatesIndex], a  	ret  SurfingGotOnText: @@ -756,73 +756,73 @@ ItemUsePokedex:  	predef_jump ShowPokedexMenu  ItemUseEvoStone: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime -	ld a,[wWhichPokemon] +	jp nz, ItemUseNotTime +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] -	ld [wEvoStoneItemID],a +	ld a, [wcf91] +	ld [wEvoStoneItemID], a  	push af -	ld a,EVO_STONE_PARTY_MENU -	ld [wPartyMenuTypeOrMessageID],a -	ld a,$ff -	ld [wUpdateSpritesEnabled],a +	ld a, EVO_STONE_PARTY_MENU +	ld [wPartyMenuTypeOrMessageID], a +	ld a, $ff +	ld [wUpdateSpritesEnabled], a  	call DisplayPartyMenu  	pop bc -	jr c,.canceledItemUse -	ld a,b -	ld [wcf91],a -	ld a,$01 -	ld [wForceEvolution],a -	ld a,SFX_HEAL_AILMENT +	jr c, .canceledItemUse +	ld a, b +	ld [wcf91], a +	ld a, $01 +	ld [wForceEvolution], a +	ld a, SFX_HEAL_AILMENT  	call PlaySoundWaitForCurrent  	call WaitForSoundToFinish  	callab TryEvolvingMon ; try to evolve pokemon -	ld a,[wEvolutionOccurred] +	ld a, [wEvolutionOccurred]  	and a -	jr z,.noEffect +	jr z, .noEffect  	pop af -	ld [wWhichPokemon],a -	ld hl,wNumBagItems -	ld a,1 ; remove 1 stone -	ld [wItemQuantity],a +	ld [wWhichPokemon], a +	ld hl, wNumBagItems +	ld a, 1 ; remove 1 stone +	ld [wItemQuantity], a  	jp RemoveItemFromInventory  .noEffect  	call ItemUseNoEffect  .canceledItemUse  	xor a -	ld [wActionResultOrTookBattleTurn],a ; item not used +	ld [wActionResultOrTookBattleTurn], a ; item not used  	pop af  	ret  ItemUseVitamin: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime +	jp nz, ItemUseNotTime  ItemUseMedicine: -	ld a,[wPartyCount] +	ld a, [wPartyCount]  	and a -	jp z,.emptyParty -	ld a,[wWhichPokemon] +	jp z, .emptyParty +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] +	ld a, [wcf91]  	push af -	ld a,USE_ITEM_PARTY_MENU -	ld [wPartyMenuTypeOrMessageID],a -	ld a,$ff -	ld [wUpdateSpritesEnabled],a -	ld a,[wPseudoItemID] +	ld a, USE_ITEM_PARTY_MENU +	ld [wPartyMenuTypeOrMessageID], a +	ld a, $ff +	ld [wUpdateSpritesEnabled], a +	ld a, [wPseudoItemID]  	and a ; using Softboiled? -	jr z,.notUsingSoftboiled +	jr z, .notUsingSoftboiled  ; if using softboiled  	call GoBackToPartyMenu  	jr .getPartyMonDataAddress  .emptyParty -	ld hl,.emptyPartyText +	ld hl, .emptyPartyText  	xor a -	ld [wActionResultOrTookBattleTurn],a ; item use failed +	ld [wActionResultOrTookBattleTurn], a ; item use failed  	jp PrintText  .emptyPartyText  	text "You don't have" @@ -831,121 +831,121 @@ ItemUseMedicine:  .notUsingSoftboiled  	call DisplayPartyMenu  .getPartyMonDataAddress -	jp c,.canceledItemUse -	ld hl,wPartyMons -	ld bc,wPartyMon2 - wPartyMon1 -	ld a,[wWhichPokemon] +	jp c, .canceledItemUse +	ld hl, wPartyMons +	ld bc, wPartyMon2 - wPartyMon1 +	ld a, [wWhichPokemon]  	call AddNTimes -	ld a,[wWhichPokemon] -	ld [wUsedItemOnWhichPokemon],a -	ld d,a -	ld a,[wcf91] -	ld e,a -	ld [wd0b5],a +	ld a, [wWhichPokemon] +	ld [wUsedItemOnWhichPokemon], a +	ld d, a +	ld a, [wcf91] +	ld e, a +	ld [wd0b5], a  	pop af -	ld [wcf91],a +	ld [wcf91], a  	pop af -	ld [wWhichPokemon],a -	ld a,[wPseudoItemID] +	ld [wWhichPokemon], a +	ld a, [wPseudoItemID]  	and a ; using Softboiled? -	jr z,.checkItemType +	jr z, .checkItemType  ; if using softboiled -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	cp d ; is the pokemon trying to use softboiled on itself? -	jr z,ItemUseMedicine ; if so, force another choice +	jr z, ItemUseMedicine ; if so, force another choice  .checkItemType -	ld a,[wcf91] -	cp a,REVIVE -	jr nc,.healHP ; if it's a Revive or Max Revive -	cp a,FULL_HEAL -	jr z,.cureStatusAilment ; if it's a Full Heal -	cp a,HP_UP -	jp nc,.useVitamin ; if it's a vitamin or Rare Candy -	cp a,FULL_RESTORE -	jr nc,.healHP ; if it's a Full Restore or one of the potions +	ld a, [wcf91] +	cp REVIVE +	jr nc, .healHP ; if it's a Revive or Max Revive +	cp FULL_HEAL +	jr z, .cureStatusAilment ; if it's a Full Heal +	cp HP_UP +	jp nc, .useVitamin ; if it's a vitamin or Rare Candy +	cp FULL_RESTORE +	jr nc, .healHP ; if it's a Full Restore or one of the potions  ; fall through if it's one of the status-specific healing items  .cureStatusAilment -	ld bc,wPartyMon1Status - wPartyMon1 -	add hl,bc ; hl now points to status -	ld a,[wcf91] +	ld bc, wPartyMon1Status - wPartyMon1 +	add hl, bc ; hl now points to status +	ld a, [wcf91]  	lb bc, ANTIDOTE_MSG, 1 << PSN -	cp a,ANTIDOTE -	jr z,.checkMonStatus +	cp ANTIDOTE +	jr z, .checkMonStatus  	lb bc, BURN_HEAL_MSG, 1 << BRN -	cp a,BURN_HEAL -	jr z,.checkMonStatus +	cp BURN_HEAL +	jr z, .checkMonStatus  	lb bc, ICE_HEAL_MSG, 1 << FRZ -	cp a,ICE_HEAL -	jr z,.checkMonStatus +	cp ICE_HEAL +	jr z, .checkMonStatus  	lb bc, AWAKENING_MSG, SLP -	cp a,AWAKENING -	jr z,.checkMonStatus +	cp AWAKENING +	jr z, .checkMonStatus  	lb bc, PARALYZ_HEAL_MSG, 1 << PAR -	cp a,PARLYZ_HEAL -	jr z,.checkMonStatus +	cp PARLYZ_HEAL +	jr z, .checkMonStatus  	lb bc, FULL_HEAL_MSG, $ff ; Full Heal  .checkMonStatus -	ld a,[hl] ; pokemon's status +	ld a, [hl] ; pokemon's status  	and c ; does the pokemon have a status ailment the item can cure? -	jp z,.healingItemNoEffect +	jp z, .healingItemNoEffect  ; if the pokemon has a status the item can heal  	xor a -	ld [hl],a ; remove the status ailment in the party data -	ld a,b -	ld [wPartyMenuTypeOrMessageID],a ; the message to display for the item used -	ld a,[wPlayerMonNumber] +	ld [hl], a ; remove the status ailment in the party data +	ld a, b +	ld [wPartyMenuTypeOrMessageID], a ; the message to display for the item used +	ld a, [wPlayerMonNumber]  	cp d ; is pokemon the item was used on active in battle? -	jp nz,.doneHealing +	jp nz, .doneHealing  ; if it is active in battle  	xor a -	ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data +	ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data  	push hl -	ld hl,wPlayerBattleStatus3 -	res BADLY_POISONED,[hl] ; heal Toxic status +	ld hl, wPlayerBattleStatus3 +	res BADLY_POISONED, [hl] ; heal Toxic status  	pop hl -	ld bc,wPartyMon1Stats - wPartyMon1Status -	add hl,bc ; hl now points to party stats -	ld de,wBattleMonStats -	ld bc,NUM_STATS * 2 +	ld bc, wPartyMon1Stats - wPartyMon1Status +	add hl, bc ; hl now points to party stats +	ld de, wBattleMonStats +	ld bc, NUM_STATS * 2  	call CopyData ; copy party stats to in-battle stat data  	predef DoubleOrHalveSelectedStats  	jp .doneHealing  .healHP  	inc hl ; hl = address of current HP -	ld a,[hli] -	ld b,a -	ld [wHPBarOldHP+1],a -	ld a,[hl] -	ld c,a -	ld [wHPBarOldHP],a ; current HP stored at wHPBarOldHP (2 bytes, big-endian) +	ld a, [hli] +	ld b, a +	ld [wHPBarOldHP+1], a +	ld a, [hl] +	ld c, a +	ld [wHPBarOldHP], a ; current HP stored at wHPBarOldHP (2 bytes, big-endian)  	or b -	jr nz,.notFainted +	jr nz, .notFainted  .fainted -	ld a,[wcf91] -	cp a,REVIVE -	jr z,.updateInBattleFaintedData -	cp a,MAX_REVIVE -	jr z,.updateInBattleFaintedData +	ld a, [wcf91] +	cp REVIVE +	jr z, .updateInBattleFaintedData +	cp MAX_REVIVE +	jr z, .updateInBattleFaintedData  	jp .healingItemNoEffect  .updateInBattleFaintedData -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr z,.compareCurrentHPToMaxHP +	jr z, .compareCurrentHPToMaxHP  	push hl  	push de  	push bc -	ld a,[wUsedItemOnWhichPokemon] -	ld c,a -	ld hl,wPartyFoughtCurrentEnemyFlags -	ld b,FLAG_TEST +	ld a, [wUsedItemOnWhichPokemon] +	ld c, a +	ld hl, wPartyFoughtCurrentEnemyFlags +	ld b, FLAG_TEST  	predef FlagActionPredef -	ld a,c +	ld a, c  	and a -	jr z,.next -	ld a,[wUsedItemOnWhichPokemon] -	ld c,a -	ld hl,wPartyGainExpFlags -	ld b,FLAG_SET +	jr z, .next +	ld a, [wUsedItemOnWhichPokemon] +	ld c, a +	ld hl, wPartyGainExpFlags +	ld b, FLAG_SET  	predef FlagActionPredef  .next  	pop bc @@ -953,467 +953,467 @@ ItemUseMedicine:  	pop hl  	jr .compareCurrentHPToMaxHP  .notFainted -	ld a,[wcf91] -	cp a,REVIVE -	jp z,.healingItemNoEffect -	cp a,MAX_REVIVE -	jp z,.healingItemNoEffect +	ld a, [wcf91] +	cp REVIVE +	jp z, .healingItemNoEffect +	cp MAX_REVIVE +	jp z, .healingItemNoEffect  .compareCurrentHPToMaxHP  	push hl  	push bc -	ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1) -	add hl,bc ; hl now points to max HP +	ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) +	add hl, bc ; hl now points to max HP  	pop bc -	ld a,[hli] +	ld a, [hli]  	cp b -	jr nz,.skipComparingLSB ; no need to compare the LSB's if the MSB's don't match -	ld a,[hl] +	jr nz, .skipComparingLSB ; no need to compare the LSB's if the MSB's don't match +	ld a, [hl]  	cp c  .skipComparingLSB  	pop hl -	jr nz,.notFullHP +	jr nz, .notFullHP  .fullHP ; if the pokemon's current HP equals its max HP -	ld a,[wcf91] -	cp a,FULL_RESTORE -	jp nz,.healingItemNoEffect +	ld a, [wcf91] +	cp FULL_RESTORE +	jp nz, .healingItemNoEffect  	inc hl  	inc hl -	ld a,[hld] ; status ailment +	ld a, [hld] ; status ailment  	and a ; does the pokemon have a status ailment? -	jp z,.healingItemNoEffect -	ld a,FULL_HEAL -	ld [wcf91],a +	jp z, .healingItemNoEffect +	ld a, FULL_HEAL +	ld [wcf91], a  	dec hl  	dec hl  	dec hl  	jp .cureStatusAilment  .notFullHP ; if the pokemon's current HP doesn't equal its max HP  	xor a -	ld [wLowHealthAlarm],a ;disable low health alarm -	ld [wChannelSoundIDs + Ch4],a +	ld [wLowHealthAlarm], a ;disable low health alarm +	ld [wChannelSoundIDs + Ch4], a  	push hl  	push de -	ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1) -	add hl,bc ; hl now points to max HP -	ld a,[hli] -	ld [wHPBarMaxHP+1],a -	ld a,[hl] -	ld [wHPBarMaxHP],a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian) -	ld a,[wPseudoItemID] +	ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) +	add hl, bc ; hl now points to max HP +	ld a, [hli] +	ld [wHPBarMaxHP+1], a +	ld a, [hl] +	ld [wHPBarMaxHP], a ; max HP stored at wHPBarMaxHP (2 bytes, big-endian) +	ld a, [wPseudoItemID]  	and a ; using Softboiled? -	jp z,.notUsingSoftboiled2 +	jp z, .notUsingSoftboiled2  ; if using softboiled -	ld hl,wHPBarMaxHP -	ld a,[hli] +	ld hl, wHPBarMaxHP +	ld a, [hli]  	push af -	ld a,[hli] +	ld a, [hli]  	push af -	ld a,[hli] +	ld a, [hli]  	push af -	ld a,[hl] +	ld a, [hl]  	push af -	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 [wHPBarMaxHP + 1],a -	ld [H_DIVIDEND],a -	ld a,[hl] -	ld [wHPBarMaxHP],a -	ld [H_DIVIDEND + 1],a -	ld a,5 -	ld [H_DIVISOR],a -	ld b,2 ; number of bytes +	ld a, [hli] +	ld [wHPBarMaxHP + 1], a +	ld [H_DIVIDEND], a +	ld a, [hl] +	ld [wHPBarMaxHP], a +	ld [H_DIVIDEND + 1], a +	ld a, 5 +	ld [H_DIVISOR], a +	ld b, 2 ; number of bytes  	call Divide ; get 1/5 of max HP of pokemon that used Softboiled -	ld bc,(wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) -	add hl,bc ; hl now points to LSB of current HP of pokemon that used Softboiled +	ld bc, (wPartyMon1HP + 1) - (wPartyMon1MaxHP + 1) +	add hl, bc ; hl now points to LSB of current HP of pokemon that used Softboiled  ; subtract 1/5 of max HP from current HP of pokemon that used Softboiled -	ld a,[H_QUOTIENT + 3] +	ld a, [H_QUOTIENT + 3]  	push af -	ld b,a -	ld a,[hl] -	ld [wHPBarOldHP],a +	ld b, a +	ld a, [hl] +	ld [wHPBarOldHP], a  	sub b -	ld [hld],a -	ld [wHPBarNewHP],a -	ld a,[H_QUOTIENT + 2] -	ld b,a -	ld a,[hl] -	ld [wHPBarOldHP+1],a +	ld [hld], a +	ld [wHPBarNewHP], a +	ld a, [H_QUOTIENT + 2] +	ld b, a +	ld a, [hl] +	ld [wHPBarOldHP+1], a  	sbc b -	ld [hl],a -	ld [wHPBarNewHP+1],a +	ld [hl], a +	ld [wHPBarNewHP+1], a  	coord hl, 4, 1 -	ld a,[wWhichPokemon] -	ld bc,2 * SCREEN_WIDTH +	ld a, [wWhichPokemon] +	ld bc, 2 * SCREEN_WIDTH  	call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled -	ld a,SFX_HEAL_HP +	ld a, SFX_HEAL_HP  	call PlaySoundWaitForCurrent -	ld a,[hFlags_0xFFF6] -	set 0,a -	ld [hFlags_0xFFF6],a -	ld a,$02 -	ld [wHPBarType],a +	ld a, [hFlags_0xFFF6] +	set 0, a +	ld [hFlags_0xFFF6], a +	ld a, $02 +	ld [wHPBarType], a  	predef UpdateHPBar2 ; animate HP bar decrease of pokemon that used Softboiled -	ld a,[hFlags_0xFFF6] -	res 0,a -	ld [hFlags_0xFFF6],a +	ld a, [hFlags_0xFFF6] +	res 0, a +	ld [hFlags_0xFFF6], a  	pop af -	ld b,a ; store heal amount (1/5 of max HP) -	ld hl,wHPBarOldHP + 1 +	ld b, a ; store heal amount (1/5 of max HP) +	ld hl, wHPBarOldHP + 1  	pop af -	ld [hld],a +	ld [hld], a  	pop af -	ld [hld],a +	ld [hld], a  	pop af -	ld [hld],a +	ld [hld], a  	pop af -	ld [hl],a +	ld [hl], a  	jr .addHealAmount  .notUsingSoftboiled2 -	ld a,[wcf91] -	cp a,SODA_POP -	ld b,60 ; Soda Pop heal amount -	jr z,.addHealAmount -	ld b,80 ; Lemonade heal amount -	jr nc,.addHealAmount -	cp a,FRESH_WATER -	ld b,50 ; Fresh Water heal amount -	jr z,.addHealAmount -	cp a,SUPER_POTION -	ld b,200 ; Hyper Potion heal amount -	jr c,.addHealAmount -	ld b,50 ; Super Potion heal amount -	jr z,.addHealAmount -	ld b,20 ; Potion heal amount +	ld a, [wcf91] +	cp SODA_POP +	ld b, 60 ; Soda Pop heal amount +	jr z, .addHealAmount +	ld b, 80 ; Lemonade heal amount +	jr nc, .addHealAmount +	cp FRESH_WATER +	ld b, 50 ; Fresh Water heal amount +	jr z, .addHealAmount +	cp SUPER_POTION +	ld b, 200 ; Hyper Potion heal amount +	jr c, .addHealAmount +	ld b, 50 ; Super Potion heal amount +	jr z, .addHealAmount +	ld b, 20 ; Potion heal amount  .addHealAmount  	pop de  	pop hl -	ld a,[hl] +	ld a, [hl]  	add b -	ld [hld],a -	ld [wHPBarNewHP],a -	ld a,[hl] -	ld [wHPBarNewHP+1],a -	jr nc,.noCarry +	ld [hld], a +	ld [wHPBarNewHP], a +	ld a, [hl] +	ld [wHPBarNewHP+1], a +	jr nc, .noCarry  	inc [hl] -	ld a,[hl] -	ld [wHPBarNewHP + 1],a +	ld a, [hl] +	ld [wHPBarNewHP + 1], a  .noCarry  	push de  	inc hl -	ld d,h -	ld e,l ; de now points to current HP -	ld hl,(wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1) -	add hl,de ; hl now points to max HP -	ld a,[wcf91] -	cp a,REVIVE -	jr z,.setCurrentHPToHalfMaxHP -	ld a,[hld] -	ld b,a -	ld a,[de] +	ld d, h +	ld e, l ; de now points to current HP +	ld hl, (wPartyMon1MaxHP + 1) - (wPartyMon1HP + 1) +	add hl, de ; hl now points to max HP +	ld a, [wcf91] +	cp REVIVE +	jr z, .setCurrentHPToHalfMaxHP +	ld a, [hld] +	ld b, a +	ld a, [de]  	sub b  	dec de -	ld b,[hl] -	ld a,[de] +	ld b, [hl] +	ld a, [de]  	sbc b -	jr nc,.setCurrentHPToMaxHp ; if current HP exceeds max HP after healing -	ld a,[wcf91] -	cp a,HYPER_POTION -	jr c,.setCurrentHPToMaxHp ; if using a Full Restore or Max Potion -	cp a,MAX_REVIVE -	jr z,.setCurrentHPToMaxHp ; if using a Max Revive +	jr nc, .setCurrentHPToMaxHp ; if current HP exceeds max HP after healing +	ld a, [wcf91] +	cp HYPER_POTION +	jr c, .setCurrentHPToMaxHp ; if using a Full Restore or Max Potion +	cp MAX_REVIVE +	jr z, .setCurrentHPToMaxHp ; if using a Max Revive  	jr .updateInBattleData  .setCurrentHPToHalfMaxHP  	dec hl  	dec de -	ld a,[hli] +	ld a, [hli]  	srl a -	ld [de],a -	ld [wHPBarNewHP+1],a -	ld a,[hl] +	ld [de], a +	ld [wHPBarNewHP+1], a +	ld a, [hl]  	rr a  	inc de -	ld [de],a -	ld [wHPBarNewHP],a +	ld [de], a +	ld [wHPBarNewHP], a  	dec de  	jr .doneHealingPartyHP  .setCurrentHPToMaxHp -	ld a,[hli] -	ld [de],a -	ld [wHPBarNewHP+1],a +	ld a, [hli] +	ld [de], a +	ld [wHPBarNewHP+1], a  	inc de -	ld a,[hl] -	ld [de],a -	ld [wHPBarNewHP],a +	ld a, [hl] +	ld [de], a +	ld [wHPBarNewHP], a  	dec de  .doneHealingPartyHP ; done updating the pokemon's current HP in the party data structure -	ld a,[wcf91] -	cp a,FULL_RESTORE -	jr nz,.updateInBattleData -	ld bc,wPartyMon1Status - (wPartyMon1MaxHP + 1) -	add hl,bc +	ld a, [wcf91] +	cp FULL_RESTORE +	jr nz, .updateInBattleData +	ld bc, wPartyMon1Status - (wPartyMon1MaxHP + 1) +	add hl, bc  	xor a -	ld [hl],a ; remove the status ailment in the party data +	ld [hl], a ; remove the status ailment in the party data  .updateInBattleData -	ld h,d -	ld l,e +	ld h, d +	ld l, e  	pop de -	ld a,[wPlayerMonNumber] +	ld a, [wPlayerMonNumber]  	cp d ; is pokemon the item was used on active in battle? -	jr nz,.calculateHPBarCoords +	jr nz, .calculateHPBarCoords  ; copy party HP to in-battle HP -	ld a,[hli] -	ld [wBattleMonHP],a -	ld a,[hld] -	ld [wBattleMonHP + 1],a -	ld a,[wcf91] -	cp a,FULL_RESTORE -	jr nz,.calculateHPBarCoords +	ld a, [hli] +	ld [wBattleMonHP], a +	ld a, [hld] +	ld [wBattleMonHP + 1], a +	ld a, [wcf91] +	cp FULL_RESTORE +	jr nz, .calculateHPBarCoords  	xor a -	ld [wBattleMonStatus],a ; remove the status ailment in the in-battle pokemon data +	ld [wBattleMonStatus], a ; remove the status ailment in the in-battle pokemon data  .calculateHPBarCoords -	ld hl,wOAMBuffer + $90 -	ld bc,2 * SCREEN_WIDTH +	ld hl, wOAMBuffer + $90 +	ld bc, 2 * SCREEN_WIDTH  	inc d  .calculateHPBarCoordsLoop -	add hl,bc +	add hl, bc  	dec d -	jr nz,.calculateHPBarCoordsLoop +	jr nz, .calculateHPBarCoordsLoop  	jr .doneHealing  .healingItemNoEffect  	call ItemUseNoEffect  	jp .done  .doneHealing -	ld a,[wPseudoItemID] +	ld a, [wPseudoItemID]  	and a ; using Softboiled? -	jr nz,.skipRemovingItem ; no item to remove if using Softboiled +	jr nz, .skipRemovingItem ; no item to remove if using Softboiled  	push hl  	call RemoveUsedItem  	pop hl  .skipRemovingItem -	ld a,[wcf91] -	cp a,FULL_RESTORE -	jr c,.playStatusAilmentCuringSound -	cp a,FULL_HEAL -	jr z,.playStatusAilmentCuringSound -	ld a,SFX_HEAL_HP +	ld a, [wcf91] +	cp FULL_RESTORE +	jr c, .playStatusAilmentCuringSound +	cp FULL_HEAL +	jr z, .playStatusAilmentCuringSound +	ld a, SFX_HEAL_HP  	call PlaySoundWaitForCurrent -	ld a,[hFlags_0xFFF6] -	set 0,a -	ld [hFlags_0xFFF6],a -	ld a,$02 -	ld [wHPBarType],a +	ld a, [hFlags_0xFFF6] +	set 0, a +	ld [hFlags_0xFFF6], a +	ld a, $02 +	ld [wHPBarType], a  	predef UpdateHPBar2 ; animate the HP bar lengthening -	ld a,[hFlags_0xFFF6] -	res 0,a -	ld [hFlags_0xFFF6],a -	ld a,REVIVE_MSG -	ld [wPartyMenuTypeOrMessageID],a -	ld a,[wcf91] -	cp a,REVIVE -	jr z,.showHealingItemMessage -	cp a,MAX_REVIVE -	jr z,.showHealingItemMessage -	ld a,POTION_MSG -	ld [wPartyMenuTypeOrMessageID],a +	ld a, [hFlags_0xFFF6] +	res 0, a +	ld [hFlags_0xFFF6], a +	ld a, REVIVE_MSG +	ld [wPartyMenuTypeOrMessageID], a +	ld a, [wcf91] +	cp REVIVE +	jr z, .showHealingItemMessage +	cp MAX_REVIVE +	jr z, .showHealingItemMessage +	ld a, POTION_MSG +	ld [wPartyMenuTypeOrMessageID], a  	jr .showHealingItemMessage  .playStatusAilmentCuringSound -	ld a,SFX_HEAL_AILMENT +	ld a, SFX_HEAL_AILMENT  	call PlaySoundWaitForCurrent  .showHealingItemMessage  	xor a -	ld [H_AUTOBGTRANSFERENABLED],a +	ld [H_AUTOBGTRANSFERENABLED], a  	call ClearScreen  	dec a -	ld [wUpdateSpritesEnabled],a +	ld [wUpdateSpritesEnabled], a  	call RedrawPartyMenu ; redraws the party menu and displays the message -	ld a,1 -	ld [H_AUTOBGTRANSFERENABLED],a -	ld c,50 +	ld a, 1 +	ld [H_AUTOBGTRANSFERENABLED], a +	ld c, 50  	call DelayFrames  	call WaitForTextScrollButtonPress  	jr .done  .canceledItemUse  	xor a -	ld [wActionResultOrTookBattleTurn],a ; item use failed +	ld [wActionResultOrTookBattleTurn], a ; item use failed  	pop af  	pop af  .done -	ld a,[wPseudoItemID] +	ld a, [wPseudoItemID]  	and a ; using Softboiled?  	ret nz ; if so, return  	call GBPalWhiteOut -	call z,RunDefaultPaletteCommand -	ld a,[wIsInBattle] +	call z, RunDefaultPaletteCommand +	ld a, [wIsInBattle]  	and a  	ret nz  	jp ReloadMapData  .useVitamin  	push hl -	ld a,[hl] -	ld [wd0b5],a -	ld [wd11e],a -	ld bc,wPartyMon1Level - wPartyMon1 -	add hl,bc ; hl now points to level -	ld a,[hl] ; a = level -	ld [wCurEnemyLVL],a ; store level +	ld a, [hl] +	ld [wd0b5], a +	ld [wd11e], a +	ld bc, wPartyMon1Level - wPartyMon1 +	add hl, bc ; hl now points to level +	ld a, [hl] ; a = level +	ld [wCurEnemyLVL], a ; store level  	call GetMonHeader  	push de -	ld a,d -	ld hl,wPartyMonNicks +	ld a, d +	ld hl, wPartyMonNicks  	call GetPartyMonName  	pop de  	pop hl -	ld a,[wcf91] -	cp a,RARE_CANDY -	jp z,.useRareCandy +	ld a, [wcf91] +	cp RARE_CANDY +	jp z, .useRareCandy  	push hl -	sub a,HP_UP +	sub HP_UP  	add a -	ld bc,wPartyMon1HPExp - wPartyMon1 -	add hl,bc +	ld bc, wPartyMon1HPExp - wPartyMon1 +	add hl, bc  	add l -	ld l,a -	jr nc,.noCarry2 +	ld l, a +	jr nc, .noCarry2  	inc h  .noCarry2 -	ld a,10 -	ld b,a -	ld a,[hl] ; a = MSB of stat experience of the appropriate stat -	cp a,100 ; is there already at least 25600 (256 * 100) stat experience? -	jr nc,.vitaminNoEffect ; if so, vitamins can't add any more +	ld a, 10 +	ld b, a +	ld a, [hl] ; a = MSB of stat experience of the appropriate stat +	cp 100 ; is there already at least 25600 (256 * 100) stat experience? +	jr nc, .vitaminNoEffect ; if so, vitamins can't add any more  	add b ; add 2560 (256 * 10) stat experience -	jr nc,.noCarry3 ; a carry should be impossible here, so this will always jump -	ld a,255 +	jr nc, .noCarry3 ; a carry should be impossible here, so this will always jump +	ld a, 255  .noCarry3 -	ld [hl],a +	ld [hl], a  	pop hl  	call .recalculateStats -	ld hl,VitaminText -	ld a,[wcf91] -	sub a,HP_UP - 1 -	ld c,a +	ld hl, VitaminText +	ld a, [wcf91] +	sub HP_UP - 1 +	ld c, a  .statNameLoop ; loop to get the address of the name of the stat the vitamin increases  	dec c -	jr z,.gotStatName +	jr z, .gotStatName  .statNameInnerLoop -	ld a,[hli] -	ld b,a -	ld a,$50 +	ld a, [hli] +	ld b, a +	ld a, $50  	cp b -	jr nz,.statNameInnerLoop +	jr nz, .statNameInnerLoop  	jr .statNameLoop  .gotStatName -	ld de,wcf4b -	ld bc,10 +	ld de, wcf4b +	ld bc, 10  	call CopyData ; copy the stat's name to wcf4b -	ld a,SFX_HEAL_AILMENT +	ld a, SFX_HEAL_AILMENT  	call PlaySound -	ld hl,VitaminStatRoseText +	ld hl, VitaminStatRoseText  	call PrintText  	jp RemoveUsedItem  .vitaminNoEffect  	pop hl -	ld hl,VitaminNoEffectText +	ld hl, VitaminNoEffectText  	call PrintText  	jp GBPalWhiteOut  .recalculateStats -	ld bc,wPartyMon1Stats - wPartyMon1 -	add hl,bc -	ld d,h -	ld e,l ; de now points to stats -	ld bc,(wPartyMon1Exp + 2) - wPartyMon1Stats -	add hl,bc ; hl now points to LSB of experience -	ld b,1 +	ld bc, wPartyMon1Stats - wPartyMon1 +	add hl, bc +	ld d, h +	ld e, l ; de now points to stats +	ld bc, (wPartyMon1Exp + 2) - wPartyMon1Stats +	add hl, bc ; hl now points to LSB of experience +	ld b, 1  	jp CalcStats ; recalculate stats  .useRareCandy  	push hl -	ld bc,wPartyMon1Level - wPartyMon1 -	add hl,bc ; hl now points to level -	ld a,[hl] ; a = level -	cp a, MAX_LEVEL -	jr z,.vitaminNoEffect ; can't raise level above 100 +	ld bc, wPartyMon1Level - wPartyMon1 +	add hl, bc ; hl now points to level +	ld a, [hl] ; a = level +	cp MAX_LEVEL +	jr z, .vitaminNoEffect ; can't raise level above 100  	inc a -	ld [hl],a ; store incremented level -	ld [wCurEnemyLVL],a +	ld [hl], a ; store incremented level +	ld [wCurEnemyLVL], a  	push hl  	push de -	ld d,a +	ld d, a  	callab CalcExperience ; calculate experience for next level and store it at $ff96  	pop de  	pop hl -	ld bc,wPartyMon1Exp - wPartyMon1Level -	add hl,bc ; hl now points to MSB of experience +	ld bc, wPartyMon1Exp - wPartyMon1Level +	add hl, bc ; hl now points to MSB of experience  ; update experience to minimum for new level -	ld a,[hExperience] -	ld [hli],a -	ld a,[hExperience + 1] -	ld [hli],a -	ld a,[hExperience + 2] -	ld [hl],a +	ld a, [hExperience] +	ld [hli], a +	ld a, [hExperience + 1] +	ld [hli], a +	ld a, [hExperience + 2] +	ld [hl], a  	pop hl -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] +	ld a, [wcf91]  	push af  	push de  	push hl -	ld bc,wPartyMon1MaxHP - wPartyMon1 -	add hl,bc ; hl now points to MSB of max HP -	ld a,[hli] -	ld b,a -	ld c,[hl] +	ld bc, wPartyMon1MaxHP - wPartyMon1 +	add hl, bc ; hl now points to MSB of max HP +	ld a, [hli] +	ld b, a +	ld c, [hl]  	pop hl  	push bc  	push hl  	call .recalculateStats  	pop hl -	ld bc,(wPartyMon1MaxHP + 1) - wPartyMon1 -	add hl,bc ; hl now points to LSB of max HP +	ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1 +	add hl, bc ; hl now points to LSB of max HP  	pop bc -	ld a,[hld] +	ld a, [hld]  	sub c -	ld c,a -	ld a,[hl] +	ld c, a +	ld a, [hl]  	sbc b -	ld b,a ; bc = the amount of max HP gained from leveling up +	ld b, a ; bc = the amount of max HP gained from leveling up  ; add the amount gained to the current HP -	ld de,(wPartyMon1HP + 1) - wPartyMon1MaxHP -	add hl,de ; hl now points to LSB of current HP -	ld a,[hl] +	ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP +	add hl, de ; hl now points to LSB of current HP +	ld a, [hl]  	add c -	ld [hld],a -	ld a,[hl] +	ld [hld], a +	ld a, [hl]  	adc b -	ld [hl],a -	ld a,RARE_CANDY_MSG -	ld [wPartyMenuTypeOrMessageID],a +	ld [hl], a +	ld a, RARE_CANDY_MSG +	ld [wPartyMenuTypeOrMessageID], a  	call RedrawPartyMenu  	pop de -	ld a,d -	ld [wWhichPokemon],a -	ld a,e -	ld [wd11e],a +	ld a, d +	ld [wWhichPokemon], a +	ld a, e +	ld [wd11e], a  	xor a ; PLAYER_PARTY_DATA -	ld [wMonDataLocation],a +	ld [wMonDataLocation], a  	call LoadMonData -	ld d,$01 +	ld d, $01  	callab PrintStatsBox ; display new stats text box  	call WaitForTextScrollButtonPress ; wait for button press  	xor a ; PLAYER_PARTY_DATA -	ld [wMonDataLocation],a +	ld [wMonDataLocation], a  	predef LearnMoveFromLevelUp ; learn level up move, if any  	xor a -	ld [wForceEvolution],a +	ld [wForceEvolution], a  	callab TryEvolvingMon ; evolve pokemon, if appropriate -	ld a,$01 -	ld [wUpdateSpritesEnabled],a +	ld a, $01 +	ld [wUpdateSpritesEnabled], a  	pop af -	ld [wcf91],a +	ld [wcf91], a  	pop af -	ld [wWhichPokemon],a +	ld [wWhichPokemon], a  	jp RemoveUsedItem  VitaminStatRoseText: @@ -1432,50 +1432,50 @@ VitaminText:  	db "SPECIAL@"  ItemUseBait: -	ld hl,ThrewBaitText +	ld hl, ThrewBaitText  	call PrintText -	ld hl,wEnemyMonCatchRate ; catch rate +	ld hl, wEnemyMonCatchRate ; catch rate  	srl [hl] ; halve catch rate -	ld a,BAIT_ANIM -	ld hl,wSafariBaitFactor ; bait factor -	ld de,wSafariEscapeFactor ; escape factor +	ld a, BAIT_ANIM +	ld hl, wSafariBaitFactor ; bait factor +	ld de, wSafariEscapeFactor ; escape factor  	jr BaitRockCommon  ItemUseRock: -	ld hl,ThrewRockText +	ld hl, ThrewRockText  	call PrintText -	ld hl,wEnemyMonCatchRate ; catch rate -	ld a,[hl] +	ld hl, wEnemyMonCatchRate ; catch rate +	ld a, [hl]  	add a ; double catch rate -	jr nc,.noCarry -	ld a,$ff +	jr nc, .noCarry +	ld a, $ff  .noCarry -	ld [hl],a -	ld a,ROCK_ANIM -	ld hl,wSafariEscapeFactor ; escape factor -	ld de,wSafariBaitFactor ; bait factor +	ld [hl], a +	ld a, ROCK_ANIM +	ld hl, wSafariEscapeFactor ; escape factor +	ld de, wSafariBaitFactor ; bait factor  BaitRockCommon: -	ld [wAnimationID],a +	ld [wAnimationID], a  	xor a -	ld [wAnimationType],a -	ld [H_WHOSETURN],a -	ld [de],a ; zero escape factor (for bait), zero bait factor (for rock) +	ld [wAnimationType], a +	ld [H_WHOSETURN], a +	ld [de], a ; zero escape factor (for bait), zero bait factor (for rock)  .randomLoop ; loop until a random number less than 5 is generated  	call Random -	and a,7 -	cp a,5 -	jr nc,.randomLoop +	and 7 +	cp 5 +	jr nc, .randomLoop  	inc a ; increment the random number, giving a range from 1 to 5 inclusive -	ld b,a -	ld a,[hl] +	ld b, a +	ld a, [hl]  	add b ; increase bait factor (for bait), increase escape factor (for rock) -	jr nc,.noCarry -	ld a,$ff +	jr nc, .noCarry +	ld a, $ff  .noCarry -	ld [hl],a +	ld [hl], a  	predef MoveAnimation ; do animation -	ld c,70 +	ld c, 70  	jp DelayFrames  ThrewBaitText: @@ -1488,38 +1488,38 @@ ThrewRockText:  ; also used for Dig out-of-battle effect  ItemUseEscapeRope: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr nz,.notUsable -	ld a,[wCurMap] -	cp a,AGATHAS_ROOM -	jr z,.notUsable -	ld a,[wCurMapTileset] -	ld b,a -	ld hl,EscapeRopeTilesets +	jr nz, .notUsable +	ld a, [wCurMap] +	cp AGATHAS_ROOM +	jr z, .notUsable +	ld a, [wCurMapTileset] +	ld b, a +	ld hl, EscapeRopeTilesets  .loop -	ld a,[hli] -	cp a,$ff -	jr z,.notUsable +	ld a, [hli] +	cp $ff +	jr z, .notUsable  	cp b -	jr nz,.loop -	ld hl,wd732 -	set 3,[hl] -	set 6,[hl] -	ld hl,wd72e -	res 4,[hl] +	jr nz, .loop +	ld hl, wd732 +	set 3, [hl] +	set 6, [hl] +	ld hl, wd72e +	res 4, [hl]  	ResetEvent EVENT_IN_SAFARI_ZONE  	xor a -	ld [wNumSafariBalls],a -	ld [wSafariZoneEntranceCurScript],a +	ld [wNumSafariBalls], a +	ld [wSafariZoneEntranceCurScript], a  	inc a -	ld [wEscapedFromBattle],a -	ld [wActionResultOrTookBattleTurn],a ; item used -	ld a,[wPseudoItemID] +	ld [wEscapedFromBattle], a +	ld [wActionResultOrTookBattleTurn], a ; item used +	ld a, [wPseudoItemID]  	and a ; using Dig?  	ret nz ; if so, return  	call ItemUseReloadOverworldData -	ld c,30 +	ld c, 30  	call DelayFrames  	jp RemoveUsedItem  .notUsable @@ -1530,62 +1530,62 @@ EscapeRopeTilesets:  	db $ff ; terminator  ItemUseRepel: -	ld b,100 +	ld b, 100  ItemUseRepelCommon: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime -	ld a,b -	ld [wRepelRemainingSteps],a +	jp nz, ItemUseNotTime +	ld a, b +	ld [wRepelRemainingSteps], a  	jp PrintItemUseTextAndRemoveItem  ; handles X Accuracy item  ItemUseXAccuracy: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp z,ItemUseNotTime -	ld hl,wPlayerBattleStatus2 -	set USING_X_ACCURACY,[hl] ; X Accuracy bit +	jp z, ItemUseNotTime +	ld hl, wPlayerBattleStatus2 +	set USING_X_ACCURACY, [hl] ; X Accuracy bit  	jp PrintItemUseTextAndRemoveItem  ; This function is bugged and never works. It always jumps to ItemUseNotTime.  ; The Card Key is handled in a different way.  ItemUseCardKey:  	xor a -	ld [wUnusedD71F],a +	ld [wUnusedD71F], a  	call GetTileAndCoordsInFrontOfPlayer -	ld a,[GetTileAndCoordsInFrontOfPlayer] -	cp a,$18 -	jr nz,.next0 -	ld hl,CardKeyTable1 +	ld a, [GetTileAndCoordsInFrontOfPlayer] +	cp $18 +	jr nz, .next0 +	ld hl, CardKeyTable1  	jr .next1  .next0 -	cp a,$24 -	jr nz,.next2 -	ld hl,CardKeyTable2 +	cp $24 +	jr nz, .next2 +	ld hl, CardKeyTable2  	jr .next1  .next2 -	cp a,$5e -	jp nz,ItemUseNotTime -	ld hl,CardKeyTable3 +	cp $5e +	jp nz, ItemUseNotTime +	ld hl, CardKeyTable3  .next1 -	ld a,[wCurMap] -	ld b,a +	ld a, [wCurMap] +	ld b, a  .loop -	ld a,[hli] -	cp a,$ff -	jp z,ItemUseNotTime +	ld a, [hli] +	cp $ff +	jp z, ItemUseNotTime  	cp b -	jr nz,.nextEntry1 -	ld a,[hli] +	jr nz, .nextEntry1 +	ld a, [hli]  	cp d -	jr nz,.nextEntry2 -	ld a,[hli] +	jr nz, .nextEntry2 +	ld a, [hli]  	cp e -	jr nz,.nextEntry3 -	ld a,[hl] -	ld [wUnusedD71F],a +	jr nz, .nextEntry3 +	ld a, [hl] +	ld [wUnusedD71F], a  	jr .done  .nextEntry1  	inc hl @@ -1595,10 +1595,10 @@ ItemUseCardKey:  	inc hl  	jr .loop  .done -	ld hl,ItemUseText00 +	ld hl, ItemUseText00  	call PrintText -	ld hl,wd728 -	set 7,[hl] +	ld hl, wd728 +	set 7, [hl]  	ret  ; These tables are probably supposed to be door locations in Silph Co., @@ -1643,145 +1643,145 @@ CardKeyTable3:  	db $ff  ItemUsePokedoll: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	dec a -	jp nz,ItemUseNotTime -	ld a,$01 -	ld [wEscapedFromBattle],a +	jp nz, ItemUseNotTime +	ld a, $01 +	ld [wEscapedFromBattle], a  	jp PrintItemUseTextAndRemoveItem  ItemUseGuardSpec: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp z,ItemUseNotTime -	ld hl,wPlayerBattleStatus2 -	set PROTECTED_BY_MIST,[hl] ; Mist bit +	jp z, ItemUseNotTime +	ld hl, wPlayerBattleStatus2 +	set PROTECTED_BY_MIST, [hl] ; Mist bit  	jp PrintItemUseTextAndRemoveItem  ItemUseSuperRepel: -	ld b,200 +	ld b, 200  	jp ItemUseRepelCommon  ItemUseMaxRepel: -	ld b,250 +	ld b, 250  	jp ItemUseRepelCommon  ItemUseDireHit: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp z,ItemUseNotTime -	ld hl,wPlayerBattleStatus2 -	set GETTING_PUMPED,[hl] ; Focus Energy bit +	jp z, ItemUseNotTime +	ld hl, wPlayerBattleStatus2 +	set GETTING_PUMPED, [hl] ; Focus Energy bit  	jp PrintItemUseTextAndRemoveItem  ItemUseXStat: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr nz,.inBattle +	jr nz, .inBattle  	call ItemUseNotTime -	ld a,2 -	ld [wActionResultOrTookBattleTurn],a ; item not used +	ld a, 2 +	ld [wActionResultOrTookBattleTurn], a ; item not used  	ret  .inBattle -	ld hl,wPlayerMoveNum -	ld a,[hli] +	ld hl, wPlayerMoveNum +	ld a, [hli]  	push af ; save [wPlayerMoveNum] -	ld a,[hl] +	ld a, [hl]  	push af ; save [wPlayerMoveEffect]  	push hl -	ld a,[wcf91] -	sub a,X_ATTACK - ATTACK_UP1_EFFECT -	ld [hl],a ; store player move effect +	ld a, [wcf91] +	sub X_ATTACK - ATTACK_UP1_EFFECT +	ld [hl], a ; store player move effect  	call PrintItemUseTextAndRemoveItem -	ld a,XSTATITEM_ANIM ; X stat item animation ID -	ld [wPlayerMoveNum],a +	ld a, XSTATITEM_ANIM ; X stat item animation ID +	ld [wPlayerMoveNum], a  	call LoadScreenTilesFromBuffer1 ; restore saved screen  	call Delay3  	xor a -	ld [H_WHOSETURN],a ; set turn to player's turn +	ld [H_WHOSETURN], a ; set turn to player's turn  	callba StatModifierUpEffect ; do stat increase move  	pop hl  	pop af -	ld [hld],a ; restore [wPlayerMoveEffect] +	ld [hld], a ; restore [wPlayerMoveEffect]  	pop af -	ld [hl],a ; restore [wPlayerMoveNum] +	ld [hl], a ; restore [wPlayerMoveNum]  	ret  ItemUsePokeflute: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr nz,.inBattle +	jr nz, .inBattle  ; if not in battle  	call ItemUseReloadOverworldData -	ld a,[wCurMap] -	cp a,ROUTE_12 -	jr nz,.notRoute12 +	ld a, [wCurMap] +	cp ROUTE_12 +	jr nz, .notRoute12  	CheckEvent EVENT_BEAT_ROUTE12_SNORLAX -	jr nz,.noSnorlaxToWakeUp +	jr nz, .noSnorlaxToWakeUp  ; if the player hasn't beaten Route 12 Snorlax -	ld hl,Route12SnorlaxFluteCoords +	ld hl, Route12SnorlaxFluteCoords  	call ArePlayerCoordsInArray -	jr nc,.noSnorlaxToWakeUp -	ld hl,PlayedFluteHadEffectText +	jr nc, .noSnorlaxToWakeUp +	ld hl, PlayedFluteHadEffectText  	call PrintText  	SetEvent EVENT_FIGHT_ROUTE12_SNORLAX  	ret  .notRoute12 -	cp a,ROUTE_16 -	jr nz,.noSnorlaxToWakeUp +	cp ROUTE_16 +	jr nz, .noSnorlaxToWakeUp  	CheckEvent EVENT_BEAT_ROUTE16_SNORLAX -	jr nz,.noSnorlaxToWakeUp +	jr nz, .noSnorlaxToWakeUp  ; if the player hasn't beaten Route 16 Snorlax -	ld hl,Route16SnorlaxFluteCoords +	ld hl, Route16SnorlaxFluteCoords  	call ArePlayerCoordsInArray -	jr nc,.noSnorlaxToWakeUp -	ld hl,PlayedFluteHadEffectText +	jr nc, .noSnorlaxToWakeUp +	ld hl, PlayedFluteHadEffectText  	call PrintText  	SetEvent EVENT_FIGHT_ROUTE16_SNORLAX  	ret  .noSnorlaxToWakeUp -	ld hl,PlayedFluteNoEffectText +	ld hl, PlayedFluteNoEffectText  	jp PrintText  .inBattle  	xor a -	ld [wWereAnyMonsAsleep],a -	ld b,~SLP & $ff -	ld hl,wPartyMon1Status +	ld [wWereAnyMonsAsleep], a +	ld b, ~SLP & $ff +	ld hl, wPartyMon1Status  	call WakeUpEntireParty -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	dec a ; is it a trainer battle? -	jr z,.skipWakingUpEnemyParty +	jr z, .skipWakingUpEnemyParty  ; if it's a trainer battle -	ld hl,wEnemyMon1Status +	ld hl, wEnemyMon1Status  	call WakeUpEntireParty  .skipWakingUpEnemyParty -	ld hl,wBattleMonStatus -	ld a,[hl] +	ld hl, wBattleMonStatus +	ld a, [hl]  	and b ; remove Sleep status -	ld [hl],a -	ld hl,wEnemyMonStatus -	ld a,[hl] +	ld [hl], a +	ld hl, wEnemyMonStatus +	ld a, [hl]  	and b ; remove Sleep status -	ld [hl],a +	ld [hl], a  	call LoadScreenTilesFromBuffer2 ; restore saved screen -	ld a,[wWereAnyMonsAsleep] +	ld a, [wWereAnyMonsAsleep]  	and a ; were any pokemon asleep before playing the flute? -	ld hl,PlayedFluteNoEffectText -	jp z,PrintText ; if no pokemon were asleep +	ld hl, PlayedFluteNoEffectText +	jp z, PrintText ; if no pokemon were asleep  ; if some pokemon were asleep -	ld hl,PlayedFluteHadEffectText +	ld hl, PlayedFluteHadEffectText  	call PrintText -	ld a,[wLowHealthAlarm] -	and a,$80 -	jr nz,.skipMusic +	ld a, [wLowHealthAlarm] +	and $80 +	jr nz, .skipMusic  	call WaitForSoundToFinish ; wait for sound to end  	callba Music_PokeFluteInBattle ; play in-battle pokeflute music  .musicWaitLoop ; wait for music to finish playing -	ld a,[wChannelSoundIDs + Ch6] +	ld a, [wChannelSoundIDs + Ch6]  	and a ; music off? -	jr nz,.musicWaitLoop +	jr nz, .musicWaitLoop  .skipMusic -	ld hl,FluteWokeUpText +	ld hl, FluteWokeUpText  	jp PrintText  ; wakes up all party pokemon @@ -1792,22 +1792,22 @@ ItemUsePokeflute:  ; OUTPUT:  ; [wWereAnyMonsAsleep]: set to 1 if any pokemon were asleep  WakeUpEntireParty: -	ld de,44 -	ld c,6 +	ld de, 44 +	ld c, 6  .loop -	ld a,[hl] +	ld a, [hl]  	push af -	and a,SLP ; is pokemon asleep? -	jr z,.notAsleep -	ld a,1 -	ld [wWereAnyMonsAsleep],a ; indicate that a pokemon had to be woken up +	and SLP ; is pokemon asleep? +	jr z, .notAsleep +	ld a, 1 +	ld [wWereAnyMonsAsleep], a ; indicate that a pokemon had to be woken up  .notAsleep  	pop af  	and b ; remove Sleep status -	ld [hl],a -	add hl,de +	ld [hl], a +	add hl, de  	dec c -	jr nz,.loop +	jr nz, .loop  	ret  ; Format: @@ -1840,28 +1840,28 @@ PlayedFluteHadEffectText:  	TX_FAR _PlayedFluteHadEffectText  	TX_BLINK  	TX_ASM -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr nz,.done +	jr nz, .done  ; play out-of-battle pokeflute music -	ld a,$ff +	ld a, $ff  	call PlaySound ; turn off music  	ld a, SFX_POKEFLUTE  	ld c, BANK(SFX_Pokeflute)  	call PlayMusic  .musicWaitLoop ; wait for music to finish playing -	ld a,[wChannelSoundIDs + Ch2] -	cp a, SFX_POKEFLUTE -	jr z,.musicWaitLoop +	ld a, [wChannelSoundIDs + Ch2] +	cp SFX_POKEFLUTE +	jr z, .musicWaitLoop  	call PlayDefaultMusic ; start playing normal music again  .done  	jp TextScriptEnd ; end text  ItemUseCoinCase: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime -	ld hl,CoinCaseNumCoinsText +	jp nz, ItemUseNotTime +	ld hl, CoinCaseNumCoinsText  	jp PrintText  CoinCaseNumCoinsText: @@ -1877,7 +1877,7 @@ ItemUseOldRod:  ItemUseGoodRod:  	call FishingInit -	jp c,ItemUseNotTime +	jp c, ItemUseNotTime  .RandomLoop  	call Random  	srl a @@ -1886,17 +1886,17 @@ ItemUseGoodRod:  	cp 2  	jr nc, .RandomLoop  	; choose which monster appears -	ld hl,GoodRodMons -	add a,a -	ld c,a -	ld b,0 -	add hl,bc -	ld b,[hl] +	ld hl, GoodRodMons +	add a +	ld c, a +	ld b, 0 +	add hl, bc +	ld b, [hl]  	inc hl -	ld c,[hl] +	ld c, [hl]  	and a  .SetBite -	ld a,0 +	ld a, 0  	rla  	xor 1  	jr RodResponse @@ -1936,23 +1936,23 @@ RodResponse:  ; checks if fishing is possible and if so, runs initialization code common to all rods  ; unsets carry if fishing is possible, sets carry if not  FishingInit: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jr z,.notInBattle +	jr z, .notInBattle  	scf ; can't fish during battle  	ret  .notInBattle  	call IsNextTileShoreOrWater  	ret c -	ld a,[wWalkBikeSurfState] -	cp a,2 ; Surfing? -	jr z,.surfing +	ld a, [wWalkBikeSurfState] +	cp 2 ; Surfing? +	jr z, .surfing  	call ItemUseReloadOverworldData -	ld hl,ItemUseText00 +	ld hl, ItemUseText00  	call PrintText -	ld a,SFX_HEAL_AILMENT +	ld a, SFX_HEAL_AILMENT  	call PlaySound -	ld c,80 +	ld c, 80  	call DelayFrames  	and a  	ret @@ -1964,22 +1964,22 @@ ItemUseOaksParcel:  	jp ItemUseNotYoursToUse  ItemUseItemfinder: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime +	jp nz, ItemUseNotTime  	call ItemUseReloadOverworldData  	callba HiddenItemNear ; check for hidden items -	ld hl,ItemfinderFoundNothingText -	jr nc,.printText ; if no hidden items -	ld c,4 +	ld hl, ItemfinderFoundNothingText +	jr nc, .printText ; if no hidden items +	ld c, 4  .loop -	ld a,SFX_HEALING_MACHINE +	ld a, SFX_HEALING_MACHINE  	call PlaySoundWaitForCurrent -	ld a,SFX_PURCHASE +	ld a, SFX_PURCHASE  	call PlaySoundWaitForCurrent  	dec c -	jr nz,.loop -	ld hl,ItemfinderFoundItemText +	jr nz, .loop +	ld hl, ItemfinderFoundItemText  .printText  	jp PrintText @@ -1992,136 +1992,136 @@ ItemfinderFoundNothingText:  	db "@"  ItemUsePPUp: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime +	jp nz, ItemUseNotTime  ItemUsePPRestore: -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] -	ld [wPPRestoreItem],a +	ld a, [wcf91] +	ld [wPPRestoreItem], a  .chooseMon  	xor a -	ld [wUpdateSpritesEnabled],a -	ld a,USE_ITEM_PARTY_MENU -	ld [wPartyMenuTypeOrMessageID],a +	ld [wUpdateSpritesEnabled], a +	ld a, USE_ITEM_PARTY_MENU +	ld [wPartyMenuTypeOrMessageID], a  	call DisplayPartyMenu -	jr nc,.chooseMove +	jr nc, .chooseMove  	jp .itemNotUsed  .chooseMove -	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,[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 +	ld a, [wPPRestoreItem] +	cp ELIXER +	jp nc, .useElixir ; if Elixir or Max Elixir +	ld a, $02 +	ld [wMoveMenuType], a +	ld hl, RaisePPWhichTechniqueText +	ld a, [wPPRestoreItem] +	cp 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  .printWhichTechniqueMessage  	call PrintText  	xor a -	ld [wPlayerMoveListIndex],a +	ld [wPlayerMoveListIndex], a  	callab MoveSelectionMenu ; move selection menu -	ld a,0 -	ld [wPlayerMoveListIndex],a -	jr nz,.chooseMon -	ld hl,wPartyMon1Moves +	ld a, 0 +	ld [wPlayerMoveListIndex], a +	jr nz, .chooseMon +	ld hl, wPartyMon1Moves  	ld bc, wPartyMon2 - wPartyMon1  	call GetSelectedMoveOffset  	push hl -	ld a,[hl] -	ld [wd11e],a +	ld a, [hl] +	ld [wd11e], a  	call GetMoveName  	call CopyStringToCF4B ; copy name to wcf4b  	pop hl -	ld a,[wPPRestoreItem] -	cp a,ETHER -	jr nc,.useEther ; if Ether or Max Ether +	ld a, [wPPRestoreItem] +	cp ETHER +	jr nc, .useEther ; if Ether or Max Ether  .usePPUp -	ld bc,wPartyMon1PP - wPartyMon1Moves -	add hl,bc -	ld a,[hl] ; move PP -	cp a,3 << 6 ; have 3 PP Ups already been used? -	jr c,.PPNotMaxedOut -	ld hl,PPMaxedOutText +	ld bc, wPartyMon1PP - wPartyMon1Moves +	add hl, bc +	ld a, [hl] ; move PP +	cp 3 << 6 ; have 3 PP Ups already been used? +	jr c, .PPNotMaxedOut +	ld hl, PPMaxedOutText  	call PrintText  	jr .chooseMove  .PPNotMaxedOut -	ld a,[hl] -	add a,1 << 6 ; increase PP Up count by 1 -	ld [hl],a -	ld a,1 ; 1 PP Up used -	ld [wd11e],a +	ld a, [hl] +	add 1 << 6 ; increase PP Up count by 1 +	ld [hl], a +	ld a, 1 ; 1 PP Up used +	ld [wd11e], a  	call RestoreBonusPP ; add the bonus PP to current PP -	ld hl,PPIncreasedText +	ld hl, PPIncreasedText  	call PrintText  .done  	pop af -	ld [wWhichPokemon],a +	ld [wWhichPokemon], a  	call GBPalWhiteOut  	call RunDefaultPaletteCommand  	jp RemoveUsedItem  .afterRestoringPP ; after using a (Max) Ether/Elixir -	ld a,[wWhichPokemon] -	ld b,a -	ld a,[wPlayerMonNumber] +	ld a, [wWhichPokemon] +	ld b, a +	ld a, [wPlayerMonNumber]  	cp b ; is the pokemon whose PP was restored active in battle? -	jr nz,.skipUpdatingInBattleData -	ld hl,wPartyMon1PP +	jr nz, .skipUpdatingInBattleData +	ld hl, wPartyMon1PP  	ld bc, wPartyMon2 - wPartyMon1  	call AddNTimes -	ld de,wBattleMonPP -	ld bc,4 +	ld de, wBattleMonPP +	ld bc, 4  	call CopyData ; copy party data to in-battle data  .skipUpdatingInBattleData -	ld a,SFX_HEAL_AILMENT +	ld a, SFX_HEAL_AILMENT  	call PlaySound -	ld hl,PPRestoredText +	ld hl, PPRestoredText  	call PrintText  	jr .done  .useEther  	call .restorePP -	jr nz,.afterRestoringPP +	jr nz, .afterRestoringPP  	jp .noEffect  ; unsets zero flag if PP was restored, sets zero flag if not  ; however, this is bugged for Max Ethers and Max Elixirs (see below)  .restorePP  	xor a ; PLAYER_PARTY_DATA -	ld [wMonDataLocation],a +	ld [wMonDataLocation], a  	call GetMaxPP -	ld hl,wPartyMon1Moves +	ld hl, wPartyMon1Moves  	ld bc, wPartyMon2 - wPartyMon1  	call GetSelectedMoveOffset  	ld bc, wPartyMon1PP - wPartyMon1Moves -	add hl,bc ; hl now points to move's PP -	ld a,[wMaxPP] -	ld b,a -	ld a,[wPPRestoreItem] -	cp a,MAX_ETHER -	jr z,.fullyRestorePP -	ld a,[hl] ; move PP -	and a,%00111111 ; lower 6 bit bits store current PP +	add hl, bc ; hl now points to move's PP +	ld a, [wMaxPP] +	ld b, a +	ld a, [wPPRestoreItem] +	cp MAX_ETHER +	jr z, .fullyRestorePP +	ld a, [hl] ; move PP +	and %00111111 ; lower 6 bit bits store current PP  	cp b ; does current PP equal max PP?  	ret z ; if so, return -	add a,10 ; increase current PP by 10 +	add 10 ; increase current PP by 10  ; b holds the max PP amount and b will hold the new PP amount.  ; So, if the new amount meets or exceeds the max amount,  ; cap the amount to the max amount by leaving b unchanged.  ; Otherwise, store the new amount in b.  	cp b ; does the new amount meet or exceed the maximum? -	jr nc,.storeNewAmount -	ld b,a +	jr nc, .storeNewAmount +	ld b, a  .storeNewAmount -	ld a,[hl] ; move PP -	and a,%11000000 ; PP Up counter bits +	ld a, [hl] ; move PP +	and %11000000 ; PP Up counter bits  	add b -	ld [hl],a +	ld [hl], a  	ret  .fullyRestorePP -	ld a,[hl] ; move PP +	ld a, [hl] ; move PP  ; Note that this code has a bug. It doesn't mask out the upper two bits, which  ; are used to count how many PP Ups have been used on the move. So, Max Ethers  ; and Max Elixirs will not be detected as having no effect on a move with full @@ -2131,37 +2131,37 @@ ItemUsePPRestore:  	jr .storeNewAmount  .useElixir  ; decrement the item ID so that ELIXER becomes ETHER and MAX_ELIXER becomes MAX_ETHER -	ld hl,wPPRestoreItem +	ld hl, wPPRestoreItem  	dec [hl]  	dec [hl]  	xor a -	ld hl,wCurrentMenuItem -	ld [hli],a -	ld [hl],a ; zero the counter for number of moves that had their PP restored -	ld b,4 +	ld hl, wCurrentMenuItem +	ld [hli], a +	ld [hl], a ; zero the counter for number of moves that had their PP restored +	ld b, 4  ; loop through each move and restore PP  .elixirLoop  	push bc -	ld hl,wPartyMon1Moves +	ld hl, wPartyMon1Moves  	ld bc, wPartyMon2 - wPartyMon1  	call GetSelectedMoveOffset -	ld a,[hl] +	ld a, [hl]  	and a ; does the current slot have a move? -	jr z,.nextMove +	jr z, .nextMove  	call .restorePP -	jr z,.nextMove +	jr z, .nextMove  ; if some PP was restored -	ld hl,wTileBehindCursor ; counter for number of moves that had their PP restored +	ld hl, wTileBehindCursor ; counter for number of moves that had their PP restored  	inc [hl]  .nextMove -	ld hl,wCurrentMenuItem +	ld hl, wCurrentMenuItem  	inc [hl]  	pop bc  	dec b -	jr nz,.elixirLoop -	ld a,[wTileBehindCursor] +	jr nz, .elixirLoop +	ld a, [wTileBehindCursor]  	and a ; did any moves have their PP restored? -	jp nz,.afterRestoringPP +	jp nz, .afterRestoringPP  .noEffect  	call ItemUseNoEffect  .itemNotUsed @@ -2169,7 +2169,7 @@ ItemUsePPRestore:  	call RunDefaultPaletteCommand  	pop af  	xor a -	ld [wActionResultOrTookBattleTurn],a ; item use failed +	ld [wActionResultOrTookBattleTurn], a ; item use failed  	ret  RaisePPWhichTechniqueText: @@ -2197,63 +2197,63 @@ UnusableItem:  	jp ItemUseNotTime  ItemUseTMHM: -	ld a,[wIsInBattle] +	ld a, [wIsInBattle]  	and a -	jp nz,ItemUseNotTime -	ld a,[wcf91] -	sub a,TM_01 +	jp nz, ItemUseNotTime +	ld a, [wcf91] +	sub TM_01  	push af -	jr nc,.skipAdding -	add a,55 ; if item is an HM, add 55 +	jr nc, .skipAdding +	add 55 ; if item is an HM, add 55  .skipAdding  	inc a -	ld [wd11e],a +	ld [wd11e], a  	predef TMToMove ; get move ID from TM/HM ID -	ld a,[wd11e] -	ld [wMoveNum],a +	ld a, [wd11e] +	ld [wMoveNum], a  	call GetMoveName  	call CopyStringToCF4B ; copy name to wcf4b  	pop af -	ld hl,BootedUpTMText -	jr nc,.printBootedUpMachineText -	ld hl,BootedUpHMText +	ld hl, BootedUpTMText +	jr nc, .printBootedUpMachineText +	ld hl, BootedUpHMText  .printBootedUpMachineText  	call PrintText -	ld hl,TeachMachineMoveText +	ld hl, TeachMachineMoveText  	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,[wCurrentMenuItem] +	ld a, [wCurrentMenuItem]  	and a -	jr z,.useMachine -	ld a,2 -	ld [wActionResultOrTookBattleTurn],a ; item not used +	jr z, .useMachine +	ld a, 2 +	ld [wActionResultOrTookBattleTurn], a ; item not used  	ret  .useMachine -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	push af -	ld a,[wcf91] +	ld a, [wcf91]  	push af  .chooseMon -	ld hl,wcf4b -	ld de,wTempMoveNameBuffer -	ld bc,14 +	ld hl, wcf4b +	ld de, wTempMoveNameBuffer +	ld bc, 14  	call CopyData ; save the move name because DisplayPartyMenu will overwrite it -	ld a,$ff -	ld [wUpdateSpritesEnabled],a -	ld a,TMHM_PARTY_MENU -	ld [wPartyMenuTypeOrMessageID],a +	ld a, $ff +	ld [wUpdateSpritesEnabled], a +	ld a, TMHM_PARTY_MENU +	ld [wPartyMenuTypeOrMessageID], a  	call DisplayPartyMenu  	push af -	ld hl,wTempMoveNameBuffer -	ld de,wcf4b -	ld bc,14 +	ld hl, wTempMoveNameBuffer +	ld de, wcf4b +	ld bc, 14  	call CopyData  	pop af -	jr nc,.checkIfAbleToLearnMove +	jr nc, .checkIfAbleToLearnMove  ; if the player canceled teaching the move  	pop af  	pop af @@ -2264,31 +2264,31 @@ ItemUseTMHM:  .checkIfAbleToLearnMove  	predef CanLearnTM ; check if the pokemon can learn the move  	push bc -	ld a,[wWhichPokemon] -	ld hl,wPartyMonNicks +	ld a, [wWhichPokemon] +	ld hl, wPartyMonNicks  	call GetPartyMonName  	pop bc -	ld a,c +	ld a, c  	and a ; can the pokemon learn the move? -	jr nz,.checkIfAlreadyLearnedMove +	jr nz, .checkIfAlreadyLearnedMove  ; if the pokemon can't learn the move -	ld a,SFX_DENIED +	ld a, SFX_DENIED  	call PlaySoundWaitForCurrent -	ld hl,MonCannotLearnMachineMoveText +	ld hl, MonCannotLearnMachineMoveText  	call PrintText  	jr .chooseMon  .checkIfAlreadyLearnedMove  	callab CheckIfMoveIsKnown ; check if the pokemon already knows the move -	jr c,.chooseMon +	jr c, .chooseMon  	predef LearnMove ; teach move  	pop af -	ld [wcf91],a +	ld [wcf91], a  	pop af -	ld [wWhichPokemon],a -	ld a,b +	ld [wWhichPokemon], a +	ld a, b  	and a  	ret z -	ld a,[wcf91] +	ld a, [wcf91]  	call IsItemHM  	ret c  	jp RemoveUsedItem @@ -2310,57 +2310,57 @@ MonCannotLearnMachineMoveText:  	db "@"  PrintItemUseTextAndRemoveItem: -	ld hl,ItemUseText00 +	ld hl, ItemUseText00  	call PrintText -	ld a,SFX_HEAL_AILMENT +	ld a, SFX_HEAL_AILMENT  	call PlaySound  	call WaitForTextScrollButtonPress ; wait for button press  RemoveUsedItem: -	ld hl,wNumBagItems -	ld a,1 ; one item -	ld [wItemQuantity],a +	ld hl, wNumBagItems +	ld a, 1 ; one item +	ld [wItemQuantity], a  	jp RemoveItemFromInventory  ItemUseNoEffect: -	ld hl,ItemUseNoEffectText +	ld hl, ItemUseNoEffectText  	jr ItemUseFailed  ItemUseNotTime: -	ld hl,ItemUseNotTimeText +	ld hl, ItemUseNotTimeText  	jr ItemUseFailed  ItemUseNotYoursToUse: -	ld hl,ItemUseNotYoursToUseText +	ld hl, ItemUseNotYoursToUseText  	jr ItemUseFailed  ThrowBallAtTrainerMon:  	call RunDefaultPaletteCommand  	call LoadScreenTilesFromBuffer1 ; restore saved screen  	call Delay3 -	ld a,TOSS_ANIM -	ld [wAnimationID],a +	ld a, TOSS_ANIM +	ld [wAnimationID], a  	predef MoveAnimation ; do animation -	ld hl,ThrowBallAtTrainerMonText1 +	ld hl, ThrowBallAtTrainerMonText1  	call PrintText -	ld hl,ThrowBallAtTrainerMonText2 +	ld hl, ThrowBallAtTrainerMonText2  	call PrintText  	jr RemoveUsedItem  NoCyclingAllowedHere: -	ld hl,NoCyclingAllowedHereText +	ld hl, NoCyclingAllowedHereText  	jr ItemUseFailed  BoxFullCannotThrowBall: -	ld hl,BoxFullCannotThrowBallText +	ld hl, BoxFullCannotThrowBallText  	jr ItemUseFailed  SurfingAttemptFailed: -	ld hl,NoSurfingHereText +	ld hl, NoSurfingHereText  ItemUseFailed:  	xor a -	ld [wActionResultOrTookBattleTurn],a ; item use failed +	ld [wActionResultOrTookBattleTurn], a ; item use failed  	jp PrintText  ItemUseNotTimeText: @@ -2419,37 +2419,37 @@ GotOffBicycleText:  ; [wWhichPokemon] = index of pokemon in party  ; [wCurrentMenuItem] = index of move (when using a PP Up)  RestoreBonusPP: -	ld hl,wPartyMon1Moves +	ld hl, wPartyMon1Moves  	ld bc, wPartyMon2 - wPartyMon1 -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	call AddNTimes  	push hl -	ld de,wNormalMaxPPList - 1 +	ld de, wNormalMaxPPList - 1  	predef LoadMovePPs ; loads the normal max PP of each of the pokemon's moves to wNormalMaxPPList  	pop hl  	ld c, wPartyMon1PP - wPartyMon1Moves -	ld b,0 -	add hl,bc ; hl now points to move 1 PP -	ld de,wNormalMaxPPList -	ld b,0 ; initialize move counter to zero +	ld b, 0 +	add hl, bc ; hl now points to move 1 PP +	ld de, wNormalMaxPPList +	ld b, 0 ; initialize move counter to zero  ; loop through the pokemon's moves  .loop  	inc b -	ld a,b -	cp a,5 ; reached the end of the pokemon's moves? +	ld a, b +	cp 5 ; reached the end of the pokemon's moves?  	ret z ; if so, return -	ld a,[wUsingPPUp] +	ld a, [wUsingPPUp]  	dec a ; using a PP Up? -	jr nz,.skipMenuItemIDCheck +	jr nz, .skipMenuItemIDCheck  ; if using a PP Up, check if this is the move it's being used on -	ld a,[wCurrentMenuItem] +	ld a, [wCurrentMenuItem]  	inc a  	cp b -	jr nz,.nextMove +	jr nz, .nextMove  .skipMenuItemIDCheck -	ld a,[hl] -	and a,%11000000 ; have any PP Ups been used? -	call nz,AddBonusPP ; if so, add bonus PP +	ld a, [hl] +	and %11000000 ; have any PP Ups been used? +	call nz, AddBonusPP ; if so, add bonus PP  .nextMove  	inc hl  	inc de @@ -2462,38 +2462,38 @@ RestoreBonusPP:  ; [hl] = move PP  AddBonusPP:  	push bc -	ld a,[de] ; normal max PP of move -	ld [H_DIVIDEND + 3],a +	ld a, [de] ; normal max PP of move +	ld [H_DIVIDEND + 3], a  	xor a -	ld [H_DIVIDEND],a -	ld [H_DIVIDEND + 1],a -	ld [H_DIVIDEND + 2],a -	ld a,5 -	ld [H_DIVISOR],a -	ld b,4 +	ld [H_DIVIDEND], a +	ld [H_DIVIDEND + 1], a +	ld [H_DIVIDEND + 2], a +	ld a, 5 +	ld [H_DIVISOR], a +	ld b, 4  	call Divide -	ld a,[hl] ; move PP -	ld b,a +	ld a, [hl] ; move PP +	ld b, a  	swap a -	and a,%00001111 +	and %00001111  	srl a  	srl a -	ld c,a ; c = number of PP Ups used +	ld c, a ; c = number of PP Ups used  .loop -	ld a,[H_QUOTIENT + 3] -	cp a,8 ; is the amount greater than or equal to 8? -	jr c,.addAmount -	ld a,7 ; cap the amount at 7 +	ld a, [H_QUOTIENT + 3] +	cp 8 ; is the amount greater than or equal to 8? +	jr c, .addAmount +	ld a, 7 ; cap the amount at 7  .addAmount  	add b -	ld b,a -	ld a,[wUsingPPUp] +	ld b, a +	ld a, [wUsingPPUp]  	dec a ; is the player using a PP Up right now? -	jr z,.done ; if so, only add the bonus once +	jr z, .done ; if so, only add the bonus once  	dec c -	jr nz,.loop +	jr nz, .loop  .done -	ld [hl],b +	ld [hl], b  	pop bc  	ret @@ -2510,74 +2510,74 @@ AddBonusPP:  ; OUTPUT:  ; [wMaxPP] = max PP  GetMaxPP: -	ld a,[wMonDataLocation] +	ld a, [wMonDataLocation]  	and a -	ld hl,wPartyMon1Moves -	ld bc,wPartyMon2 - wPartyMon1 -	jr z,.sourceWithMultipleMon -	ld hl,wEnemyMon1Moves +	ld hl, wPartyMon1Moves +	ld bc, wPartyMon2 - wPartyMon1 +	jr z, .sourceWithMultipleMon +	ld hl, wEnemyMon1Moves  	dec a -	jr z,.sourceWithMultipleMon -	ld hl,wBoxMon1Moves -	ld bc,wBoxMon2 - wBoxMon1 +	jr z, .sourceWithMultipleMon +	ld hl, wBoxMon1Moves +	ld bc, wBoxMon2 - wBoxMon1  	dec a -	jr z,.sourceWithMultipleMon -	ld hl,wDayCareMonMoves +	jr z, .sourceWithMultipleMon +	ld hl, wDayCareMonMoves  	dec a -	jr z,.sourceWithOneMon -	ld hl,wBattleMonMoves ; player's in-battle pokemon +	jr z, .sourceWithOneMon +	ld hl, wBattleMonMoves ; player's in-battle pokemon  .sourceWithOneMon  	call GetSelectedMoveOffset2  	jr .next  .sourceWithMultipleMon  	call GetSelectedMoveOffset  .next -	ld a,[hl] +	ld a, [hl]  	dec a  	push hl -	ld hl,Moves -	ld bc,MoveEnd - Moves +	ld hl, Moves +	ld bc, MoveEnd - Moves  	call AddNTimes -	ld de,wcd6d -	ld a,BANK(Moves) +	ld de, wcd6d +	ld a, BANK(Moves)  	call FarCopyData -	ld de,wcd6d + 5 ; PP is byte 5 of move data -	ld a,[de] -	ld b,a ; b = normal max PP +	ld de, wcd6d + 5 ; PP is byte 5 of move data +	ld a, [de] +	ld b, a ; b = normal max PP  	pop hl  	push bc -	ld bc,wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data -	ld a,[wMonDataLocation] -	cp a,4 ; player's in-battle pokemon? -	jr nz,.addPPOffset -	ld bc,wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data +	ld bc, wPartyMon1PP - wPartyMon1Moves ; PP offset if not player's in-battle pokemon data +	ld a, [wMonDataLocation] +	cp 4 ; player's in-battle pokemon? +	jr nz, .addPPOffset +	ld bc, wBattleMonPP - wBattleMonMoves ; PP offset if player's in-battle pokemon data  .addPPOffset -	add hl,bc -	ld a,[hl] ; a = current PP -	and a,%11000000 ; get PP Up count +	add hl, bc +	ld a, [hl] ; a = current PP +	and %11000000 ; get PP Up count  	pop bc  	or b ; place normal max PP in 6 lower bits of a -	ld h,d -	ld l,e +	ld h, d +	ld l, e  	inc hl ; hl = wcd73 -	ld [hl],a +	ld [hl], a  	xor a ; add the bonus for the existing PP Up count -	ld [wUsingPPUp],a +	ld [wUsingPPUp], a  	call AddBonusPP ; add bonus PP from PP Ups -	ld a,[hl] -	and a,%00111111 ; mask out the PP Up count -	ld [wMaxPP],a ; store max PP +	ld a, [hl] +	and %00111111 ; mask out the PP Up count +	ld [wMaxPP], a ; store max PP  	ret  GetSelectedMoveOffset: -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	call AddNTimes  GetSelectedMoveOffset2: -	ld a,[wCurrentMenuItem] -	ld c,a -	ld b,0 -	add hl,bc +	ld a, [wCurrentMenuItem] +	ld c, a +	ld b, 0 +	add hl, bc  	ret  ; confirms the item toss and then tosses the item @@ -2590,49 +2590,49 @@ GetSelectedMoveOffset2:  ; clears carry flag if the item is tossed, sets carry flag if not  TossItem_:  	push hl -	ld a,[wcf91] +	ld a, [wcf91]  	call IsItemHM  	pop hl -	jr c,.tooImportantToToss +	jr c, .tooImportantToToss  	push hl  	call IsKeyItem_ -	ld a,[wIsKeyItem] +	ld a, [wIsKeyItem]  	pop hl  	and a -	jr nz,.tooImportantToToss +	jr nz, .tooImportantToToss  	push hl -	ld a,[wcf91] -	ld [wd11e],a +	ld a, [wcf91] +	ld [wd11e], a  	call GetItemName  	call CopyStringToCF4B ; copy name to wcf4b -	ld hl,IsItOKToTossItemText +	ld hl, IsItOKToTossItemText  	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 +	ld a, [wMenuExitMethod] +	cp CHOSE_SECOND_ITEM  	pop hl  	scf  	ret z ; return if the player chose No  ; if the player chose Yes  	push hl -	ld a,[wWhichPokemon] +	ld a, [wWhichPokemon]  	call RemoveItemFromInventory -	ld a,[wcf91] -	ld [wd11e],a +	ld a, [wcf91] +	ld [wd11e], a  	call GetItemName  	call CopyStringToCF4B ; copy name to wcf4b -	ld hl,ThrewAwayItemText +	ld hl, ThrewAwayItemText  	call PrintText  	pop hl  	and a  	ret  .tooImportantToToss  	push hl -	ld hl,TooImportantToTossText +	ld hl, TooImportantToTossText  	call PrintText  	pop hl  	scf @@ -2658,32 +2658,32 @@ TooImportantToTossText:  ; 00: item is not key item  ; 01: item is key item  IsKeyItem_: -	ld a,$01 -	ld [wIsKeyItem],a -	ld a,[wcf91] -	cp a,HM_01 ; is the item an HM or TM? -	jr nc,.checkIfItemIsHM +	ld a, $01 +	ld [wIsKeyItem], a +	ld a, [wcf91] +	cp HM_01 ; is the item an HM or TM? +	jr nc, .checkIfItemIsHM  ; if the item is not an HM or TM  	push af -	ld hl,KeyItemBitfield -	ld de,wBuffer -	ld bc,15 ; only 11 bytes are actually used +	ld hl, KeyItemBitfield +	ld de, wBuffer +	ld bc, 15 ; only 11 bytes are actually used  	call CopyData  	pop af  	dec a -	ld c,a -	ld hl,wBuffer -	ld b,FLAG_TEST +	ld c, a +	ld hl, wBuffer +	ld b, FLAG_TEST  	predef FlagActionPredef -	ld a,c +	ld a, c  	and a  	ret nz  .checkIfItemIsHM -	ld a,[wcf91] +	ld a, [wcf91]  	call IsItemHM  	ret c  	xor a -	ld [wIsKeyItem],a +	ld [wIsKeyItem], a  	ret  INCLUDE "data/key_items.asm" @@ -2860,7 +2860,7 @@ SendNewMonToBox:  IsNextTileShoreOrWater:  	ld a, [wCurMapTileset]  	ld hl, WaterTilesets -	ld de,1 +	ld de, 1  	call IsInArray  	jr nc, .notShoreOrWater  	ld a, [wCurMapTileset] diff --git a/engine/load_pokedex_tiles.asm b/engine/load_pokedex_tiles.asm index 637b7a24..70bcf04d 100755 --- a/engine/load_pokedex_tiles.asm +++ b/engine/load_pokedex_tiles.asm @@ -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 diff --git a/engine/menu/draw_start_menu.asm b/engine/menu/draw_start_menu.asm index 83a81aac..11777dc6 100644 --- a/engine/menu/draw_start_menu.asm +++ b/engine/menu/draw_start_menu.asm @@ -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 diff --git a/engine/menu/main_menu.asm b/engine/menu/main_menu.asm index cd4198b6..da2e98e4 100755 --- a/engine/menu/main_menu.asm +++ b/engine/menu/main_menu.asm @@ -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 diff --git a/engine/menu/party_menu.asm b/engine/menu/party_menu.asm index a35524ed..5149e5ab 100755 --- a/engine/menu/party_menu.asm +++ b/engine/menu/party_menu.asm @@ -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 diff --git a/engine/menu/pc.asm b/engine/menu/pc.asm index c9e2cf08..5639bd99 100755 --- a/engine/menu/pc.asm +++ b/engine/menu/pc.asm @@ -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 diff --git a/engine/menu/pokedex.asm b/engine/menu/pokedex.asm index bf8afaa9..8e1fd480 100755 --- a/engine/menu/pokedex.asm +++ b/engine/menu/pokedex.asm @@ -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 diff --git a/engine/menu/prize_menu.asm b/engine/menu/prize_menu.asm index f6ca013b..bcd0d4ea 100755 --- a/engine/menu/prize_menu.asm +++ b/engine/menu/prize_menu.asm @@ -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" diff --git a/engine/menu/start_menu.asm b/engine/menu/start_menu.asm index 029d8c01..eb4b4f2d 100755 --- a/engine/menu/start_menu.asm +++ b/engine/menu/start_menu.asm @@ -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 diff --git a/engine/menu/start_sub_menus.asm b/engine/menu/start_sub_menus.asm index 8c10266b..947837e3 100755 --- a/engine/menu/start_sub_menus.asm +++ b/engine/menu/start_sub_menus.asm @@ -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 diff --git a/engine/menu/swap_items.asm b/engine/menu/swap_items.asm index b1fa78be..563fc7d5 100644 --- a/engine/menu/swap_items.asm +++ b/engine/menu/swap_items.asm @@ -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 diff --git a/engine/menu/text_box.asm b/engine/menu/text_box.asm index 90c35d25..b9a36652 100644 --- a/engine/menu/text_box.asm +++ b/engine/menu/text_box.asm @@ -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: diff --git a/engine/oak_speech.asm b/engine/oak_speech.asm index 43efecbc..b1acfb65 100755 --- a/engine/oak_speech.asm +++ b/engine/oak_speech.asm @@ -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 diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 2a221c7e..8a6057a0 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -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" diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 823939b1..dc5b29b5 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -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: diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm index 6444ab7e..dae57f23 100644 --- a/engine/overworld/wild_mons.asm +++ b/engine/overworld/wild_mons.asm @@ -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" diff --git a/engine/palettes.asm b/engine/palettes.asm index 1ac5e56a..4808776e 100755 --- a/engine/palettes.asm +++ b/engine/palettes.asm @@ -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 diff --git a/engine/pokedex_rating.asm b/engine/pokedex_rating.asm index f8e29e5c..aff9769e 100755 --- a/engine/pokedex_rating.asm +++ b/engine/pokedex_rating.asm @@ -42,7 +42,7 @@ DisplayDexRating:  	inc de  .copyRatingTextLoop  	ld a, [hli] -	cp a, "@" +	cp "@"  	jr z, .doneCopying  	ld [de], a  	inc de diff --git a/engine/predefs.asm b/engine/predefs.asm index 605cba3a..6f605043 100755 --- a/engine/predefs.asm +++ b/engine/predefs.asm @@ -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 diff --git a/engine/save.asm b/engine/save.asm index e5f67a62..97935dbb 100755 --- a/engine/save.asm +++ b/engine/save.asm @@ -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: diff --git a/engine/special_warps.asm b/engine/special_warps.asm index de00a817..3a8b8b86 100644 --- a/engine/special_warps.asm +++ b/engine/special_warps.asm @@ -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 diff --git a/engine/subtract_paid_money.asm b/engine/subtract_paid_money.asm index 2888c3fb..a6a6ec2e 100644 --- a/engine/subtract_paid_money.asm +++ b/engine/subtract_paid_money.asm @@ -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 diff --git a/engine/titlescreen.asm b/engine/titlescreen.asm index f4cce5b4..03a5832d 100755 --- a/engine/titlescreen.asm +++ b/engine/titlescreen.asm @@ -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 diff --git a/engine/trade2.asm b/engine/trade2.asm index 062d5285..2c79e077 100755 --- a/engine/trade2.asm +++ b/engine/trade2.asm @@ -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 | 
