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

@ -1304,7 +1304,7 @@ ParseSFXOrRest: ; e8698
ld [hl], a
; are we on the last channel? (noise sampling)
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
cp CHAN4
ret z
; update hi frequency from next param
@ -1668,7 +1668,7 @@ MusicEE; e883e
; if ????, jump
; get channel
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
; hl = Channel1JumpCondition + channel id
@ -1966,7 +1966,7 @@ Music_NoteType: ; e8963
add hl, bc
ld [hl], a
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
cp CHAN4
ret z
; intensity
@ -2414,7 +2414,7 @@ SetLRTracks: ; e8b1b
push de
; store current channel in de
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
; get this channel's lr tracks
@ -2449,7 +2449,7 @@ _PlayMusic:: ; e8b30
call LoadMusicByte ; store first byte of music header in a
rlca
rlca
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
inc a
.loop
; start playing channels
@ -2505,7 +2505,7 @@ _PlayCryHeader:: ; e8b79
; Top 2 bits contain the number of channels
rlca
rlca
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
; For each channel:
inc a
@ -2530,7 +2530,7 @@ _PlayCryHeader:: ; e8b79
; No tempo for channel 4
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
cp CHAN4
jr nc, .start
@ -2669,7 +2669,7 @@ _PlaySFX:: ; e8c04
call LoadMusicByte
rlca ; top 2
rlca ; bits
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
inc a ; # channels -> # loops
.startchannels
push af
@ -2722,7 +2722,7 @@ PlayStereoSFX:: ; e8ca6
call LoadMusicByte
rlca
rlca
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
inc a
.loop
@ -2736,7 +2736,7 @@ PlayStereoSFX:: ; e8ca6
push de
; get tracks for this channel
ld a, [CurChannel]
maskbits NUM_MUSIC_CHANS +- 1
maskbits NUM_MUSIC_CHANS
ld e, a
ld d, 0
call GetLRTracks

View File

@ -216,6 +216,8 @@ NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size
GRASS_WILDDATA_LENGTH EQU (NUM_GRASSMON * 2 + 1) * 3 + 2
WATER_WILDDATA_LENGTH EQU (NUM_WATERMON * 2 + 1) * 1 + 2
NUM_ROAMMON_MAPS EQU 16 ; RoamMaps table size (see data/wild/roammon_maps.asm)
; swarms

View File

@ -13,6 +13,7 @@ endr
ENDM
RoamMaps: ; 2a40f
; there are NUM_ROAMMON_MAPS entries
roam_map ROUTE_29, 2, ROUTE_30, ROUTE_46
roam_map ROUTE_30, 2, ROUTE_29, ROUTE_31
roam_map ROUTE_31, 3, ROUTE_30, ROUTE_32, ROUTE_36

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

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