Avoid "+- 1" at every maskbits

This commit is contained in:
Remy Oukaour
2018-01-16 17:27:50 -05:00
parent 8048082114
commit 7b3de85a06
32 changed files with 79 additions and 76 deletions

View File

@@ -186,7 +186,7 @@ AIChooseMove: ; 440ce
.ChooseMove:
ld hl, Buffer1
call Random
maskbits NUM_MOVES +- 1
maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc

View File

@@ -640,7 +640,7 @@ StartTrainerBattle_LoadPokeBallGraphics: ; 8c5dc (23:45dc)
.cgb
ld hl, .daypals
ld a, [TimeOfDayPal]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
cp DARKNESS_F
jr nz, .daytime
ld hl, .nightpals

View File

@@ -6031,7 +6031,7 @@ ParseEnemyAction: ; 3e7c1
.loop2
ld hl, EnemyMonMoves
call BattleRandom
maskbits NUM_MOVES +- 1
maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc

View File

@@ -932,7 +932,7 @@ BattleCommand_CheckObedience: ; 343db
.RandomMove:
call BattleRandom
maskbits NUM_MOVES +- 1
maskbits NUM_MOVES
cp b
jr nc, .RandomMove
@@ -4387,7 +4387,7 @@ BattleCommand_SleepTalk: ; 35b33
.sample_move
push hl
call BattleRandom
maskbits NUM_MOVES +- 1
maskbits NUM_MOVES
ld c, a
ld b, 0
add hl, bc
@@ -8204,7 +8204,7 @@ BattleCommand_Conversion: ; 3707f
.done
.loop3
call BattleRandom
maskbits NUM_MOVES +- 1
maskbits NUM_MOVES
ld c, a
ld b, 0
ld hl, StringBuffer1

View File

@@ -1206,7 +1206,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd)
srl a
ld [wSFXDuration], a
call .GetCryTrack
maskbits NUM_NOISE_CHANS +- 1
maskbits NUM_NOISE_CHANS
ld [CryTracks], a ; CryTracks
ld e, a
@@ -1243,7 +1243,7 @@ BattleAnimCmd_Sound: ; cc7cd (33:47cd)
BattleAnimCmd_Cry: ; cc807 (33:4807)
call GetBattleAnimByte
maskbits NUM_NOISE_CHANS +- 1
maskbits NUM_NOISE_CHANS
ld e, a
ld d, 0
ld hl, .CryData

View File

@@ -1230,7 +1230,7 @@ LoadMapPals:
ld l, a
; Futher refine by time of day
ld a, [TimeOfDayPal]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
add a
add a
add a
@@ -1276,7 +1276,7 @@ LoadMapPals:
.got_pals
ld a, [TimeOfDayPal]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
ld bc, 8 palettes
ld hl, MapObjectPals
call AddNTimes
@@ -1300,7 +1300,7 @@ LoadMapPals:
ld de, RoofPals
add hl, de
ld a, [TimeOfDayPal]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
cp NITE_F
jr c, .morn_day
rept 4

View File

@@ -27,12 +27,12 @@ Function_LoadOpponentTrainerAndPokemons: ; 1f8000
add b
ld b, a ; b contains the nr of the trainer
if DEF(_CRYSTAL11)
maskbits BATTLETOWER_NUM_UNIQUE_TRAINERS +- 1
maskbits BATTLETOWER_NUM_UNIQUE_TRAINERS
cp BATTLETOWER_NUM_UNIQUE_TRAINERS
else
; Crystal 1.0 used the wrong constant here, so only the first 21
; trainers in BattleTowerTrainers can be sampled.
maskbits BATTLETOWER_NUM_UNIQUE_PKMN +- 1
maskbits BATTLETOWER_NUM_UNIQUE_PKMN
cp BATTLETOWER_NUM_UNIQUE_PKMN
endc
jr nc, .resample
@@ -115,7 +115,7 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld a, [hRandomAdd]
add b
ld b, a
maskbits BATTLETOWER_NUM_UNIQUE_PKMN +- 1
maskbits BATTLETOWER_NUM_UNIQUE_PKMN
cp BATTLETOWER_NUM_UNIQUE_PKMN
jr nc, .resample
; in register 'a' is the chosen Pkmn of the LevelGroup

View File

@@ -17,7 +17,7 @@ Special_BuenasPassword: ; 8af6b
ld a, [MenuSelection]
ld c, a
ld a, [wBuenasPassword]
maskbits NUM_PASSWORDS_PER_CATEGORY +- 1
maskbits NUM_PASSWORDS_PER_CATEGORY
cp c
jr nz, .wrong
ld b, $1

View File

@@ -80,7 +80,7 @@ rept 4
endr
ld a, [TimeOfDay]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
cp NITE_F
jr c, .time_species
inc hl

View File

@@ -435,7 +435,7 @@ MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
ld a, [wEnvironment]
push af
ld a, [TimeOfDay]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
ld [TimeOfDayPal], a
ld a, $1
ld [wEnvironment], a

View File

@@ -10,7 +10,7 @@ LoadPoisonBGPals: ; cbcdd
and a
jr nz, .cgb
ld a, [TimeOfDayPal]
maskbits NUM_DAYTIMES +- 1
maskbits NUM_DAYTIMES
cp DARKNESS_F
ld a, %00000000
jr z, .convert_pals

View File

@@ -775,7 +775,7 @@ GetPokedexEntryBank:
ld a, [EnemyMonSpecies]
rlca
rlca
maskbits NUM_DEX_ENTRY_BANKS +- 1
maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a

View File

@@ -82,7 +82,7 @@ _LoadFontsBattleExtra:: ; fb4be
LoadFrame: ; fb4cc
ld a, [TextBoxFrame]
maskbits NUM_FRAMES +- 1
maskbits NUM_FRAMES
ld bc, 6 * LEN_1BPP_TILE
ld hl, Frames
call AddNTimes

View File

@@ -893,7 +893,7 @@ MapObjectMovementPattern: ; 47dd
ld hl, OBJECT_DIRECTION_WALKING
add hl, de
ld a, [hl]
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld d, 1 * 8 + 6
cp DOWN
jr z, .ok_13

View File

@@ -106,7 +106,7 @@ Function6f3e: ; 6f3e
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .data_6f5b
@@ -131,7 +131,7 @@ Function6f5f: ; 6f5f
push af
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .data_6f7b
@@ -178,7 +178,7 @@ Function6fa1: ; 6fa1
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
jr z, .down
dec a
jr z, .up

View File

@@ -954,7 +954,7 @@ InitPackBuffers: ; 1068a
ld [wJumptableIndex], a
; pocket id -> jumptable index
ld a, [wLastPocket]
maskbits NUM_POCKETS +- 1
maskbits NUM_POCKETS
ld [wCurrPocket], a
inc a
add a
@@ -1099,7 +1099,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_left
ld a, [wJumptableIndex]
dec a
maskbits NUM_POCKETS +- 1
maskbits NUM_POCKETS
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@@ -1111,7 +1111,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_right
ld a, [wJumptableIndex]
inc a
maskbits NUM_POCKETS +- 1
maskbits NUM_POCKETS
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@@ -1281,7 +1281,7 @@ WaitBGMap_DrawPackGFX: ; 1089a (4:489a)
call WaitBGMap
DrawPackGFX: ; 1089d
ld a, [wCurrPocket]
maskbits NUM_POCKETS +- 1
maskbits NUM_POCKETS
ld e, a
ld d, $0
ld a, [BattleType]

View File

@@ -140,7 +140,7 @@ DoPlayerMovement:: ; 80000
.water
ld a, c
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld c, a
ld b, 0
ld hl, .water_table
@@ -244,7 +244,7 @@ DoPlayerMovement:: ; 80000
ld a, [PlayerDirection]
rrca
rrca
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
cp e
jr z, .not_turning
@@ -430,7 +430,7 @@ DoPlayerMovement:: ; 80000
ld a, [PlayerDirection]
rrca
rrca
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
cp e
jr nz, .not_warp
call WarpCheck
@@ -559,7 +559,7 @@ DoPlayerMovement:: ; 80000
cp 0
ret z
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .forced_dpad

View File

@@ -589,7 +589,7 @@ Special_SurfStartStep: ; 8379
ld a, [PlayerDirection]
srl a
srl a
maskbits NUM_DIRECTIONS +- 1
maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .movement_data

View File

@@ -230,7 +230,7 @@ GetDexEntryPointer: ; 44333
push de
rlca
rlca
maskbits NUM_DEX_ENTRY_BANKS +- 1
maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a

View File

@@ -251,7 +251,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld a, $4f
call ByteFill
ld a, [wPokegearCard]
maskbits NUM_POKEGEAR_CARDS +- 1
maskbits NUM_POKEGEAR_CARDS
add a
ld e, a
ld d, 0
@@ -289,7 +289,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld [hWY], a
; swap region maps
ld a, [wPokegearMapRegion]
maskbits NUM_REGIONS +- 1
maskbits NUM_REGIONS
xor 1
ld [wPokegearMapRegion], a
ret

Some files were not shown because too many files have changed in this diff Show More