Do a little cleanup towards issue #465

This commit is contained in:
Remy Oukaour 2018-01-09 17:20:47 -05:00
parent ce50d1b2cb
commit a8cf8979d9
10 changed files with 52 additions and 46 deletions

View File

@ -123,6 +123,12 @@ const_value set 1
const ATK_EQ_DEF const ATK_EQ_DEF
; PP
PP_UP_MASK EQU %11000000
PP_UP_ONE EQU %01000000
PP_MASK EQU %00111111
; significant happiness values ; significant happiness values
BASE_HAPPINESS EQU 70 BASE_HAPPINESS EQU 70
FRIEND_BALL_HAPPINESS EQU 200 FRIEND_BALL_HAPPINESS EQU 200

View File

@ -16,12 +16,12 @@ HiddenPowerDamage: ; fbced
; Attack ; Attack
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and %1000
; Defense ; Defense
ld b, a ld b, a
ld a, [hli] ld a, [hli]
and 8 and %1000
srl a srl a
or b or b
@ -29,7 +29,7 @@ HiddenPowerDamage: ; fbced
ld b, a ld b, a
ld a, [hl] ld a, [hl]
swap a swap a
and 8 and %1000
srl a srl a
srl a srl a
or b or b
@ -37,7 +37,7 @@ HiddenPowerDamage: ; fbced
; Special ; Special
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and 8 and %1000
srl a srl a
srl a srl a
srl a srl a
@ -52,7 +52,7 @@ HiddenPowerDamage: ; fbced
; Add Special & 3 ; Add Special & 3
ld b, a ld b, a
ld a, [hld] ld a, [hld]
and 3 and %0011
add b add b
; Divide by 2 and add 30 + 1 ; Divide by 2 and add 30 + 1
@ -67,12 +67,12 @@ HiddenPowerDamage: ; fbced
; Def & 3 ; Def & 3
ld a, [hl] ld a, [hl]
and 3 and %0011
ld b, a ld b, a
; + (Atk & 3) << 2 ; + (Atk & 3) << 2
ld a, [hl] ld a, [hl]
and 3 << 4 and %0011 << 4
swap a swap a
add a add a
add a add a

View File

@ -853,7 +853,7 @@ ShrinkPlayer: ; 610f
ld a, [hROMBank] ld a, [hROMBank]
push af push af
ld a, 0 << 7 | 32 ; fade out ld a, 32 ; fade time
ld [MusicFade], a ld [MusicFade], a
ld de, MUSIC_NONE ld de, MUSIC_NONE
ld a, e ld a, e

View File

@ -2291,7 +2291,7 @@ PokeDoll: ; f48f
inc a inc a
ld [wForcedSwitch], a ld [wForcedSwitch], a
ld a, [wBattleResult] ld a, [wBattleResult]
and 3 << 6 and $c0
or $2 or $2
ld [wBattleResult], a ld [wBattleResult], a
jp UseItemText jp UseItemText
@ -2575,7 +2575,7 @@ Mysteryberry: ; f5bf
ld bc, MON_PP - MON_MOVES ld bc, MON_PP - MON_MOVES
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp 3 << 6 ; have 3 PP Ups already been used? cp PP_UP_MASK
jr c, .do_ppup jr c, .do_ppup
.CantUsePPUpOnSketch: .CantUsePPUpOnSketch:
@ -2586,7 +2586,7 @@ Mysteryberry: ; f5bf
.do_ppup .do_ppup
ld a, [hl] ld a, [hl]
add 1 << 6 ; increase PP Up count by 1 add PP_UP_ONE
ld [hl], a ld [hl], a
ld a, $1 ld a, $1
ld [wd265], a ld [wd265], a
@ -2714,7 +2714,7 @@ RestorePP: ; f6e8
ld a, [wd265] ld a, [wd265]
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and (1 << 6) - 1 and PP_MASK
cp b cp b
jr nc, .dont_restore jr nc, .dont_restore
@ -2732,7 +2732,7 @@ RestorePP: ; f6e8
.restore_some .restore_some
ld a, [hl] ld a, [hl]
and (1 << 6) - 1 and PP_MASK
add c add c
cp b cp b
jr nc, .restore_all jr nc, .restore_all
@ -2740,7 +2740,7 @@ RestorePP: ; f6e8
.restore_all .restore_all
ld a, [hl] ld a, [hl]
and 3 << 6 and PP_UP_MASK
or b or b
ld [hl], a ld [hl], a
ret ret
@ -3125,7 +3125,7 @@ ApplyPPUp: ; f84c
.use .use
ld a, [hl] ld a, [hl]
and 3 << 6 and PP_UP_MASK
ld a, [de] ; wasted cycle ld a, [de] ; wasted cycle
call nz, ComputeMaxPP call nz, ComputeMaxPP
@ -3209,7 +3209,7 @@ RestoreAllPP: ; f8b9
pop bc pop bc
pop de pop de
ld a, [de] ld a, [de]
and 3 << 6 and PP_UP_MASK
ld b, a ld b, a
ld a, [wd265] ld a, [wd265]
add b add b
@ -3282,7 +3282,7 @@ GetMaxPPOfMove: ; f8ec
.notwild .notwild
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and 3 << 6 and PP_UP_MASK
pop bc pop bc
or b or b
@ -3293,7 +3293,7 @@ GetMaxPPOfMove: ; f8ec
ld a, b ; this gets lost anyway ld a, b ; this gets lost anyway
call ComputeMaxPP call ComputeMaxPP
ld a, [hl] ld a, [hl]
and (1 << 6) - 1 and PP_MASK
ld [wd265], a ld [wd265], a
pop af pop af

View File

@ -2422,7 +2422,7 @@ Pokedex_LoadCurrentFootprint: ; 41478 (10:5478)
Pokedex_LoadAnyFootprint: ; 4147b Pokedex_LoadAnyFootprint: ; 4147b
ld a, [wd265] ld a, [wd265]
dec a dec a
and ($ff ^ $07) ; $f8 ; $1f << 3 and %11111000
srl a srl a
srl a srl a
srl a srl a
@ -2430,7 +2430,7 @@ Pokedex_LoadAnyFootprint: ; 4147b
ld d, a ld d, a
ld a, [wd265] ld a, [wd265]
dec a dec a
and 7 and %111
swap a ; * $10 swap a ; * $10
ld l, a ld l, a
ld h, 0 ld h, 0

View File

@ -898,7 +898,7 @@ Script_musicfadeout:
call GetScriptByte call GetScriptByte
ld [MusicFadeID + 1], a ld [MusicFadeID + 1], a
call GetScriptByte call GetScriptByte
and $7f and $ff ^ (1 << MUSIC_FADE_IN_F)
ld [MusicFade], a ld [MusicFade], a
ret ret

View File

@ -1157,7 +1157,7 @@ CheckFaintedFrzSlp: ; 4e53f
ld hl, MON_STATUS ld hl, MON_STATUS
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and (1 << FRZ) | SLP and 1 << FRZ | SLP
jr nz, .fainted_frz_slp jr nz, .fainted_frz_slp
and a and a
ret ret

View File

@ -237,11 +237,11 @@ SuicuneFrameIterator: ; 10eea7
inc [hl] inc [hl]
; Only do this once every eight frames ; Only do this once every eight frames
and (1 << 3) - 1 and %111
ret nz ret nz
ld a, c ld a, c
and 3 << 3 and %11000
sla a sla a
swap a swap a
ld e, a ld e, a

View File

@ -319,7 +319,7 @@ Unused_FadeOutMusic:: ; 3ca8
; 3cae ; 3cae
FadeInMusic:: ; 3cae FadeInMusic:: ; 3cae
ld a, 4 | 1 << 7 ld a, 4 | (1 << MUSIC_FADE_IN_F)
ld [MusicFade], a ld [MusicFade], a
ret ret
; 3cb4 ; 3cb4

View File

@ -303,7 +303,7 @@ WaitTileAnimation: ; fc2fe
StandingTileFrame8: ; fc2ff StandingTileFrame8: ; fc2ff
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
inc a inc a
and 7 and %111
ld [TileAnimationTimer], a ld [TileAnimationTimer], a
ret ret
; fc309 ; fc309
@ -313,9 +313,9 @@ ScrollTileRightLeft: ; fc309
; Scroll right for 4 ticks, then left for 4 ticks. ; Scroll right for 4 ticks, then left for 4 ticks.
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
inc a inc a
and 7 and %111
ld [TileAnimationTimer], a ld [TileAnimationTimer], a
and 4 and %100
jr nz, ScrollTileLeft jr nz, ScrollTileLeft
jr ScrollTileRight jr ScrollTileRight
; fc318 ; fc318
@ -324,9 +324,9 @@ ScrollTileUpDown: ; fc318
; Scroll up for 4 ticks, then down for 4 ticks. ; Scroll up for 4 ticks, then down for 4 ticks.
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
inc a inc a
and 7 and %111
ld [TileAnimationTimer], a ld [TileAnimationTimer], a
and 4 and %100
jr nz, ScrollTileDown jr nz, ScrollTileDown
jr ScrollTileUp jr ScrollTileUp
; fc327 ; fc327
@ -336,11 +336,11 @@ ScrollTileLeft: ; fc327
ld l, e ld l, e
ld c, 4 ld c, 4
.loop .loop
rept 4 rept 4
ld a, [hl] ld a, [hl]
rlca rlca
ld [hli], a ld [hli], a
endr endr
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
@ -351,11 +351,11 @@ ScrollTileRight: ; fc33b
ld l, e ld l, e
ld c, 4 ld c, 4
.loop .loop
rept 4 rept 4
ld a, [hl] ld a, [hl]
rrca rrca
ld [hli], a ld [hli], a
endr endr
dec c dec c
jr nz, .loop jr nz, .loop
ret ret
@ -424,7 +424,7 @@ AnimateFountain: ; fc387
ld c, l ld c, l
ld hl, .frames ld hl, .frames
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
and 7 and %111
add a add a
add l add l
ld l, a ld l, a
@ -468,7 +468,7 @@ AnimateWaterTile: ; fc402
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
; 4 tile graphics, updated every other frame. ; 4 tile graphics, updated every other frame.
and 3 << 1 and %110
; 2 x 8 = 16 bytes per tile ; 2 x 8 = 16 bytes per tile
add a add a
@ -676,7 +676,7 @@ AnimateFlowerTile: ; fc56d
; Alternate tile graphic every other frame ; Alternate tile graphic every other frame
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
and 1 << 1 and %10
ld e, a ld e, a
; CGB has different color mappings for flowers. ; CGB has different color mappings for flowers.
@ -684,14 +684,14 @@ AnimateFlowerTile: ; fc56d
and 1 and 1
add e add e
swap a ; << 4 (16 bytes) swap a
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, FlowerTileFrames ld hl, FlowerTileFrames
add hl, de add hl, de
ld sp, hl ld sp, hl
ld hl, vTiles2 + $30 ; tile 4 ld hl, vTiles2 tile $03
jp WriteTile jp WriteTile
; fc58c ; fc58c
@ -710,11 +710,11 @@ LavaBubbleAnim1: ; fc5cc
ld b, h ld b, h
ld c, l ld c, l
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
and 6 and %110
srl a srl a
inc a inc a
inc a inc a
and 3 and %011
swap a swap a
ld e, a ld e, a
ld d, 0 ld d, 0
@ -732,7 +732,7 @@ LavaBubbleAnim2: ; fc5eb
ld b, h ld b, h
ld c, l ld c, l
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
and 6 and %110
add a add a
add a add a
add a add a
@ -764,7 +764,7 @@ AnimateSproutPillarTile: ; fc645
ld c, l ld c, l
ld a, [TileAnimationTimer] ld a, [TileAnimationTimer]
and 7 and %111
; Get frame index a ; Get frame index a
ld hl, .frames ld hl, .frames
@ -948,7 +948,7 @@ TileAnimationPalette: ; fc6d7
ld a, l ld a, l
and %110 ; frames 0 2 4 6 and %110 ; frames 0 2 4 6
jr z, .color0 jr z, .color0
cp 4 cp %100 ; frame 4
jr z, .color2 jr z, .color2
.color1 .color1
@ -992,7 +992,7 @@ FlickeringCaveEntrancePalette: ; fc71e
ret nz ret nz
; We only want to be here if we're in a dark cave. ; We only want to be here if we're in a dark cave.
ld a, [wTimeOfDayPalset] ld a, [wTimeOfDayPalset]
cp $ff ; 3,3,3,3 cp %11111111 ; 3,3,3,3
ret nz ret nz
ld a, [rSVBK] ld a, [rSVBK]
@ -1003,7 +1003,7 @@ FlickeringCaveEntrancePalette: ; fc71e
ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_YELLOW ld a, (1 << rBGPI_AUTO_INCREMENT) palette PAL_BG_YELLOW
ld [rBGPI], a ld [rBGPI], a
ld a, [hVBlankCounter] ld a, [hVBlankCounter]
and 1 << 1 and %10
jr nz, .bit1set jr nz, .bit1set
ld hl, wBGPals1 palette PAL_BG_YELLOW ld hl, wBGPals1 palette PAL_BG_YELLOW
jr .okay jr .okay