Use maskbits some more

This commit is contained in:
Remy Oukaour
2018-01-11 12:00:01 -05:00
parent a436bbc23b
commit 94d6a32721
50 changed files with 576 additions and 452 deletions

View File

@ -408,7 +408,7 @@ UpdateChannels: ; e8125
ret ret
.asm_e824d .asm_e824d
ld a, $3f ld a, $3f ; sound length
ld [rNR31], a ld [rNR31], a
xor a xor a
ld [rNR30], a ld [rNR30], a
@ -1304,8 +1304,8 @@ ParseSFXOrRest: ; e8698
ld [hl], a ld [hl], a
; are we on the last channel? (noise sampling) ; are we on the last channel? (noise sampling)
ld a, [CurChannel] ld a, [CurChannel]
and $3 maskbits NUM_MUSIC_CHANS +- 1
cp $3 cp CHAN4
ret z ret z
; update hi frequency from next param ; update hi frequency from next param
call GetMusicByte call GetMusicByte
@ -1320,8 +1320,8 @@ GetNoiseSample: ; e86c5
; load ptr to sample header in NoiseSampleAddress ; load ptr to sample header in NoiseSampleAddress
; are we on the last channel? ; are we on the last channel?
ld a, [CurChannel] ld a, [CurChannel]
and $3 and NUM_MUSIC_CHANS +- 1
cp $3 cp CHAN4
; ret if not ; ret if not
ret nz ret nz
; update note duration ; update note duration
@ -1668,7 +1668,7 @@ MusicEE; e883e
; if ????, jump ; if ????, jump
; get channel ; get channel
ld a, [CurChannel] ld a, [CurChannel]
and $3 ; ch0-3 maskbits NUM_MUSIC_CHANS +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
; hl = Channel1JumpCondition + channel id ; hl = Channel1JumpCondition + channel id
@ -1966,8 +1966,8 @@ Music_NoteType: ; e8963
add hl, bc add hl, bc
ld [hl], a ld [hl], a
ld a, [CurChannel] ld a, [CurChannel]
and $3 maskbits NUM_MUSIC_CHANS +- 1
cp CHAN8 & $3 cp CHAN4
ret z ret z
; intensity ; intensity
call Music_Intensity call Music_Intensity
@ -2414,7 +2414,7 @@ SetLRTracks: ; e8b1b
push de push de
; store current channel in de ; store current channel in de
ld a, [CurChannel] ld a, [CurChannel]
and $3 maskbits NUM_MUSIC_CHANS +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
; get this channel's lr tracks ; get this channel's lr tracks
@ -2449,7 +2449,7 @@ _PlayMusic:: ; e8b30
call LoadMusicByte ; store first byte of music header in a call LoadMusicByte ; store first byte of music header in a
rlca rlca
rlca rlca
and $3 ; get number of channels maskbits NUM_MUSIC_CHANS +- 1
inc a inc a
.loop .loop
; start playing channels ; start playing channels
@ -2505,7 +2505,7 @@ _PlayCryHeader:: ; e8b79
; Top 2 bits contain the number of channels ; Top 2 bits contain the number of channels
rlca rlca
rlca rlca
and 3 maskbits NUM_MUSIC_CHANS +- 1
; For each channel: ; For each channel:
inc a inc a
@ -2530,8 +2530,8 @@ _PlayCryHeader:: ; e8b79
; No tempo for channel 4 ; No tempo for channel 4
ld a, [CurChannel] ld a, [CurChannel]
and 3 maskbits NUM_MUSIC_CHANS +- 1
cp 3 cp CHAN4
jr nc, .start jr nc, .start
; Tempo is effectively length ; Tempo is effectively length
@ -2669,7 +2669,7 @@ _PlaySFX:: ; e8c04
call LoadMusicByte call LoadMusicByte
rlca ; top 2 rlca ; top 2
rlca ; bits rlca ; bits
and $3 maskbits NUM_MUSIC_CHANS +- 1
inc a ; # channels -> # loops inc a ; # channels -> # loops
.startchannels .startchannels
push af push af
@ -2722,7 +2722,7 @@ PlayStereoSFX:: ; e8ca6
call LoadMusicByte call LoadMusicByte
rlca rlca
rlca rlca
and 3 ; ch1-4 maskbits NUM_MUSIC_CHANS +- 1
inc a inc a
.loop .loop
@ -2736,7 +2736,7 @@ PlayStereoSFX:: ; e8ca6
push de push de
; get tracks for this channel ; get tracks for this channel
ld a, [CurChannel] ld a, [CurChannel]
and 3 ; ch1-4 maskbits NUM_MUSIC_CHANS +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
call GetLRTracks call GetLRTracks

View File

@ -9,21 +9,15 @@
const ITEMATTR_HELP const ITEMATTR_HELP
ITEMATTR_STRUCT_LENGTH EQU const_value ITEMATTR_STRUCT_LENGTH EQU const_value
; item types
; pack pockets const_value set 1
ITEM EQU 1 const ITEM ; 1
KEY_ITEM EQU 2 const KEY_ITEM ; 2
BALL EQU 3 const BALL ; 3
TM_HM EQU 4 const TM_HM ; 4
; pack pocket sizes
MAX_ITEMS EQU 20
MAX_KEY_ITEMS EQU 25
MAX_BALLS EQU 12
MAX_PC_ITEMS EQU 50
; item menu types ; item menu types
; UseItem.dw indexes (see engine/pack.asm)
ITEMMENU_NOUSE EQU 0 ITEMMENU_NOUSE EQU 0
ITEMMENU_CURRENT EQU 4 ITEMMENU_CURRENT EQU 4
ITEMMENU_PARTY EQU 5 ITEMMENU_PARTY EQU 5
@ -34,6 +28,20 @@ CANT_SELECT EQU 1 << 6
CANT_TOSS EQU 1 << 7 CANT_TOSS EQU 1 << 7
; pack pockets
const_def
const ITEM_POCKET ; 0
const BALL_POCKET ; 1
const KEY_ITEM_POCKET ; 2
const TM_HM_POCKET ; 3
NUM_POCKETS EQU const_value +- 1
MAX_ITEMS EQU 20
MAX_BALLS EQU 12
MAX_KEY_ITEMS EQU 25
MAX_PC_ITEMS EQU 50
; mail ; mail
MAIL_MSG_LENGTH EQU $20 MAIL_MSG_LENGTH EQU $20
MAILBOX_CAPACITY EQU 10 MAILBOX_CAPACITY EQU 10

View File

@ -100,3 +100,13 @@ KANTO_LANDMARK EQU const_value
const TOHJO_FALLS ; 5d const TOHJO_FALLS ; 5d
const ROUTE_28 ; 5e const ROUTE_28 ; 5e
const FAST_SHIP ; 5f const FAST_SHIP ; 5f
; used in CaughtData
GIFT_LOCATION EQU $7e
EVENT_LOCATION EQU $7f
; Regions
const_def
const JOHTO_REGION ; 0
const KANTO_REGION ; 1

View File

@ -86,3 +86,10 @@ const_value = 1
; day-care ; day-care
MAX_DAY_CARE_EXP EQU $500000 MAX_DAY_CARE_EXP EQU $500000
; bug-catching contest
BUG_CONTEST_MINUTES EQU 20
BUG_CONTEST_SECONDS EQU 0
BUG_CONTEST_PLAYER EQU 1
NUM_BUG_CONTESTANTS EQU 10 ; not counting the player
BUG_CONTESTANT_SIZE EQU 4

View File

@ -111,6 +111,10 @@
; GetMapHeaderMusic picks music for this value (see home/map.asm) ; GetMapHeaderMusic picks music for this value (see home/map.asm)
MUSIC_MAHOGANY_MART EQU $64 MUSIC_MAHOGANY_MART EQU $64
; ExitPokegearRadio_HandleMusic uses these values
RESTART_MAP_MUSIC EQU $fe
ENTER_MAP_MUSIC EQU $ff
; GetMapHeaderMusic picks music for this bit flag ; GetMapHeaderMusic picks music for this bit flag
RADIO_TOWER_MUSIC_F EQU 7 RADIO_TOWER_MUSIC_F EQU 7
RADIO_TOWER_MUSIC EQU 1 << RADIO_TOWER_MUSIC_F RADIO_TOWER_MUSIC EQU 1 << RADIO_TOWER_MUSIC_F

View File

@ -19,3 +19,25 @@ TRADE_PADDING EQU 31
const NPCTRADE_CHRIS ; 4 const NPCTRADE_CHRIS ; 4
const NPCTRADE_KIM ; 5 const NPCTRADE_KIM ; 5
const NPCTRADE_FOREST ; 6 const NPCTRADE_FOREST ; 6
; trade gender limits
TRADE_EITHER_GENDER EQU 0
TRADE_MALE_ONLY EQU 1
TRADE_FEMALE_ONLY EQU 2
; TradeTexts indexes (see engine/npctrade.asm)
; trade dialogs
const_def
const TRADE_INTRO
const TRADE_CANCEL
const TRADE_WRONG
const TRADE_COMPLETE
const TRADE_AFTER
; trade dialog sets
const_def
const TRADE_DIALOG_COLLECTOR
const TRADE_DIALOG_HAPPY
const TRADE_DIALOG_NEWBIE
const TRADE_DIALOG_GIRL

View File

@ -63,6 +63,10 @@ const_value set 1
const NO_EGGS ; f const NO_EGGS ; f
; pokedex entries (see data/pokemon/dex_entries.asm)
NUM_DEX_ENTRY_BANKS EQU 4
; party_struct members (see macros/wram.asm) ; party_struct members (see macros/wram.asm)
MON_SPECIES EQUS "(PartyMon1Species - PartyMon1)" MON_SPECIES EQUS "(PartyMon1Species - PartyMon1)"
MON_ITEM EQUS "(PartyMon1Item - PartyMon1)" MON_ITEM EQUS "(PartyMon1Item - PartyMon1)"
@ -98,6 +102,21 @@ PARTYMON_STRUCT_LENGTH EQUS "(PartyMon1StatsEnd - PartyMon1)"
REDMON_STRUCT_LENGTH EQU 44 REDMON_STRUCT_LENGTH EQU 44
; caught data
CAUGHT_TIME_MASK EQU %11000000
CAUGHT_LEVEL_MASK EQU %00111111
CAUGHT_GENDER_MASK EQU %10000000
CAUGHT_LOCATION_MASK EQU %01111111
CAUGHT_BY_UNKNOWN EQU 0
CAUGHT_BY_GIRL EQU 1
CAUGHT_BY_BOY EQU 2
CAUGHT_EGG_LEVEL EQU 1
; maximum number of party pokemon ; maximum number of party pokemon
PARTY_LENGTH EQU 6 PARTY_LENGTH EQU 6

View File

@ -52,6 +52,7 @@ const_value set -1
const UP ; 1 const UP ; 1
const LEFT ; 2 const LEFT ; 2
const RIGHT ; 3 const RIGHT ; 3
NUM_DIRECTIONS EQU const_value
DOWN_MASK EQU 1 << DOWN DOWN_MASK EQU 1 << DOWN
UP_MASK EQU 1 << UP UP_MASK EQU 1 << UP
@ -71,6 +72,7 @@ FACE_RIGHT EQU 1
const DAY_F ; 1 const DAY_F ; 1
const NITE_F ; 2 const NITE_F ; 2
const DARKNESS_F ; 3 const DARKNESS_F ; 3
NUM_DAYTIMES EQU const_value
MORN EQU 1 << MORN_F MORN EQU 1 << MORN_F
DAY EQU 1 << DAY_F DAY EQU 1 << DAY_F

View File

@ -0,0 +1,13 @@
BugCatchingContestantEventFlagTable: ; 139fe
; there are NUM_BUG_CONTESTANTS entries
dw EVENT_BUG_CATCHING_CONTESTANT_1A
dw EVENT_BUG_CATCHING_CONTESTANT_2A
dw EVENT_BUG_CATCHING_CONTESTANT_3A
dw EVENT_BUG_CATCHING_CONTESTANT_4A
dw EVENT_BUG_CATCHING_CONTESTANT_5A
dw EVENT_BUG_CATCHING_CONTESTANT_6A
dw EVENT_BUG_CATCHING_CONTESTANT_7A
dw EVENT_BUG_CATCHING_CONTESTANT_8A
dw EVENT_BUG_CATCHING_CONTESTANT_9A
dw EVENT_BUG_CATCHING_CONTESTANT_10A
; 13a12

View File

@ -1,5 +1,6 @@
BugContestantPointers: ; 13783 BugContestantPointers: ; 13783
dw BugContestant_BugCatcherDon ; This reverts back to the player ; there are NUM_BUG_CONTESTANTS + 1 entries
dw BugContestant_BugCatcherDon ; this reverts back to the player
dw BugContestant_BugCatcherDon dw BugContestant_BugCatcherDon
dw BugContestant_BugCatcherEd dw BugContestant_BugCatcherEd
dw BugContestant_CooltrainerMNick dw BugContestant_CooltrainerMNick
@ -12,6 +13,12 @@ BugContestantPointers: ; 13783
dw BugContestant_SchoolboyKipp dw BugContestant_SchoolboyKipp
; 13799 ; 13799
; contestant format:
; db class, id
; dbw 1st-place mon, score
; dbw 2nd-place mon, score
; dbw 3rd-place mon, score
BugContestant_BugCatcherDon: BugContestant_BugCatcherDon:
db BUG_CATCHER, DON db BUG_CATCHER, DON
dbw KAKUNA, 300 dbw KAKUNA, 300

View File

@ -1,7 +1,3 @@
TRADE_EITHER_GENDER EQU 0
TRADE_MALE_ONLY EQU 1
TRADE_FEMALE_ONLY EQU 2
npctrade: MACRO npctrade: MACRO
; dialog set, requested mon, offered mon, nickname, dvs, item, OT ID, OT name, gender requested ; dialog set, requested mon, offered mon, nickname, dvs, item, OT ID, OT name, gender requested
db \1, \2, \3, \4, \5, \6, \7 db \1, \2, \3, \4, \5, \6, \7
@ -12,11 +8,11 @@ ENDM
NPCTrades: ; fce58 NPCTrades: ; fce58
; entries correspond to NPCTRADE_* constants ; entries correspond to NPCTRADE_* constants
npctrade 0, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, 37460, "MIKE@@@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_COLLECTOR, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, 37460, "MIKE@@@@@@@", TRADE_EITHER_GENDER
npctrade 0, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, 48926, "KYLE@@@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_COLLECTOR, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, 48926, "KYLE@@@@@@@", TRADE_EITHER_GENDER
npctrade 1, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, 29189, "TIM@@@@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_HAPPY, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, 29189, "TIM@@@@@@@@", TRADE_EITHER_GENDER
npctrade 3, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, 00283, "EMY@@@@@@@@", TRADE_FEMALE_ONLY npctrade TRADE_DIALOG_GIRL, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, 00283, "EMY@@@@@@@@", TRADE_FEMALE_ONLY
npctrade 2, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, 15616, "CHRIS@@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_NEWBIE, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, 15616, "CHRIS@@@@@@", TRADE_EITHER_GENDER
npctrade 3, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, 26491, "KIM@@@@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_GIRL, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, 26491, "KIM@@@@@@@@", TRADE_EITHER_GENDER
npctrade 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, 50082, "FOREST@@@@@", TRADE_EITHER_GENDER npctrade TRADE_DIALOG_COLLECTOR, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, 50082, "FOREST@@@@@", TRADE_EITHER_GENDER
; fcf38 ; fcf38

View File

@ -56,7 +56,7 @@ AIChooseMove: ; 440ce
inc hl inc hl
ld a, [de] ld a, [de]
inc de inc de
and $3f and PP_MASK
jr nz, .CheckMovePP jr nz, .CheckMovePP
ld [hl], 80 ld [hl], 80
jr .CheckMovePP jr .CheckMovePP
@ -186,7 +186,7 @@ AIChooseMove: ; 440ce
.ChooseMove: .ChooseMove:
ld hl, Buffer1 ld hl, Buffer1
call Random call Random
and 3 maskbits NUM_MOVES +- 1
ld c, a ld c, a
ld b, 0 ld b, 0
add hl, bc add hl, bc

View File

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

View File

@ -730,7 +730,7 @@ HandleEncore: ; 3c4df
ld b, 0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
ret nz ret nz
.end_player_encore .end_player_encore
@ -754,7 +754,7 @@ HandleEncore: ; 3c4df
ld b, 0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
ret nz ret nz
.end_enemy_encore .end_enemy_encore
@ -1401,7 +1401,7 @@ HandleMysteryberry: ; 3c93c
and a and a
jr z, .quit jr z, .quit
ld a, [de] ld a, [de]
and $3f and PP_MASK
jr z, .restore jr z, .restore
inc hl inc hl
inc de inc de
@ -5650,7 +5650,7 @@ MoveSelectionScreen: ; 3e4bc
ld b, 0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jr z, .no_pp_left jr z, .no_pp_left
ld a, [PlayerDisableCount] ld a, [PlayerDisableCount]
swap a swap a
@ -5849,7 +5849,7 @@ MoveInfoBox: ; 3e6c8
ld hl, BattleMonPP ld hl, BattleMonPP
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
ld [StringBuffer1], a ld [StringBuffer1], a
call .PrintPP call .PrintPP
@ -5912,7 +5912,7 @@ CheckPlayerHasUsableMoves: ; 3e786
or [hl] or [hl]
inc hl inc hl
or [hl] or [hl]
and $3f and PP_MASK
ret nz ret nz
jr .force_struggle jr .force_struggle
@ -5934,8 +5934,7 @@ CheckPlayerHasUsableMoves: ; 3e786
.done .done
; Bug: this will result in a move with PP Up confusing the game. ; Bug: this will result in a move with PP Up confusing the game.
; Replace with "and $3f" to fix. and a ; should be "and PP_MASK"
and a
ret nz ret nz
.force_struggle .force_struggle
@ -6014,7 +6013,7 @@ ParseEnemyAction: ; 3e7c1
cp [hl] cp [hl]
jr z, .disabled jr z, .disabled
ld a, [de] ld a, [de]
and $3f and PP_MASK
jr nz, .enough_pp jr nz, .enough_pp
.disabled .disabled
@ -6032,7 +6031,7 @@ ParseEnemyAction: ; 3e7c1
.loop2 .loop2
ld hl, EnemyMonMoves ld hl, EnemyMonMoves
call BattleRandom call BattleRandom
and 3 ; TODO factor in NUM_MOVES maskbits NUM_MOVES +- 1
ld c, a ld c, a
ld b, 0 ld b, 0
add hl, bc add hl, bc
@ -6049,7 +6048,7 @@ ParseEnemyAction: ; 3e7c1
add hl, bc add hl, bc
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jr z, .loop2 jr z, .loop2
ld a, c ld a, c
ld [CurEnemyMoveNum], a ld [CurEnemyMoveNum], a

View File

@ -846,19 +846,20 @@ BattleCommand_CheckObedience: ; 343db
.DoNothing: .DoNothing:
; 4 random choices
call BattleRandom call BattleRandom
and 3 and %11
ld hl, LoafingAroundText ld hl, LoafingAroundText
and a and a ; 0
jr z, .Print jr z, .Print
ld hl, WontObeyText ld hl, WontObeyText
dec a dec a ; 1
jr z, .Print jr z, .Print
ld hl, TurnedAwayText ld hl, TurnedAwayText
dec a dec a ; 2
jr z, .Print jr z, .Print
ld hl, IgnoredOrdersText ld hl, IgnoredOrdersText
@ -888,7 +889,7 @@ BattleCommand_CheckObedience: ; 343db
.GetTotalPP: .GetTotalPP:
ld a, [hli] ld a, [hli]
and $3f ; exclude pp up and PP_MASK
add b add b
ld b, a ld b, a
@ -911,7 +912,7 @@ BattleCommand_CheckObedience: ; 343db
; Can't use another move if only one move has PP. ; Can't use another move if only one move has PP.
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
cp b cp b
jr z, .DoNothing jr z, .DoNothing
@ -931,7 +932,7 @@ BattleCommand_CheckObedience: ; 343db
.RandomMove: .RandomMove:
call BattleRandom call BattleRandom
and 3 ; TODO NUM_MOVES maskbits NUM_MOVES +- 1
cp b cp b
jr nc, .RandomMove jr nc, .RandomMove
@ -947,7 +948,7 @@ BattleCommand_CheckObedience: ; 343db
ld d, 0 ld d, 0
add hl, de add hl, de
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jr z, .RandomMove jr z, .RandomMove
@ -1118,7 +1119,7 @@ BattleCommand_DoTurn: ; 34555
ld b, 0 ld b, 0
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jr z, .out_of_pp jr z, .out_of_pp
dec [hl] dec [hl]
ld b, 0 ld b, 0
@ -3906,7 +3907,7 @@ BattleCommand_Encore: ; 35864
ld bc, BattleMonPP - BattleMonMoves - 1 ld bc, BattleMonPP - BattleMonMoves - 1
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jp z, .failed jp z, .failed
ld a, [AttackMissed] ld a, [AttackMissed]
and a and a
@ -4386,7 +4387,7 @@ BattleCommand_SleepTalk: ; 35b33
.sample_move .sample_move
push hl push hl
call BattleRandom call BattleRandom
and 3 ; TODO factor in NUM_MOVES maskbits NUM_MOVES +- 1
ld c, a ld c, a
ld b, 0 ld b, 0
add hl, bc add hl, bc
@ -4550,17 +4551,18 @@ BattleCommand_Spite: ; 35c0f
add hl, bc add hl, bc
pop bc pop bc
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
jr z, .failed jr z, .failed
push bc push bc
call GetMoveName call GetMoveName
; lose 2-5 PP
call BattleRandom call BattleRandom
and 3 and %11
inc a inc a
inc a inc a
ld b, a ld b, a
ld a, [hl] ld a, [hl]
and $3f and PP_MASK
cp b cp b
jr nc, .deplete_pp jr nc, .deplete_pp
ld b, a ld b, a
@ -6208,13 +6210,12 @@ BattleCommand_TriStatusChance: ; 3658f
call BattleCommand_EffectChance call BattleCommand_EffectChance
; 1/3 chance of each status
.loop .loop
; 1/3 chance of each status
call BattleRandom call BattleRandom
swap a swap a
and 3 and %11
jr z, .loop jr z, .loop
; jump
dec a dec a
ld hl, .ptrs ld hl, .ptrs
rst JumpTable rst JumpTable
@ -7392,7 +7393,8 @@ BattleCommand_TrapTarget: ; 36c2d
bit SUBSTATUS_SUBSTITUTE, a bit SUBSTATUS_SUBSTITUTE, a
ret nz ret nz
call BattleRandom call BattleRandom
and 3 ; trapped for 2-5 turns
and %11
inc a inc a
inc a inc a
inc a inc a
@ -7590,8 +7592,9 @@ BattleCommand_FinishConfusingTarget: ; 36d70
.got_confuse_count .got_confuse_count
set SUBSTATUS_CONFUSED, [hl] set SUBSTATUS_CONFUSED, [hl]
; confused for 2-5 turns
call BattleRandom call BattleRandom
and 3 and %11
inc a inc a
inc a inc a
ld [bc], a ld [bc], a
@ -8201,7 +8204,7 @@ BattleCommand_Conversion: ; 3707f
.done .done
.loop3 .loop3
call BattleRandom call BattleRandom
and 3 ; TODO factor in NUM_MOVES maskbits NUM_MOVES +- 1
ld c, a ld c, a
ld b, 0 ld b, 0
ld hl, StringBuffer1 ld hl, StringBuffer1

View File

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

View File

@ -136,7 +136,7 @@ _DepositPKMN: ; e2391 (38:6391)
jp c, BillsPCDepositFuncCancel jp c, BillsPCDepositFuncCancel
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
dec a dec a
and $3 and %11
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, BillsPCDepositJumptable ld hl, BillsPCDepositJumptable
@ -401,7 +401,7 @@ BillsPC_Withdraw: ; e2675 (38:6675)
jp c, .cancel jp c, .cancel
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
dec a dec a
and 3 and %11
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .dw ld hl, .dw
@ -663,7 +663,7 @@ _MovePKMNWithoutMail: ; e2759
jp c, .Cancel jp c, .Cancel
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
dec a dec a
and 3 and %11
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .Jumptable2 ld hl, .Jumptable2

View File

@ -7,17 +7,17 @@ CheckPartyFullAfterContest: ; 4d9e5
call GetBaseData call GetBaseData
ld hl, PartyCount ld hl, PartyCount
ld a, [hl] ld a, [hl]
cp 6 cp PARTY_LENGTH
jp nc, .TryAddToBox jp nc, .TryAddToBox
inc a inc a
ld [hl], a ld [hl], a
ld c, a ld c, a
ld b, $0 ld b, 0
add hl, bc add hl, bc
ld a, [wContestMon] ld a, [wContestMon]
ld [hli], a ld [hli], a
ld [CurSpecies], a ld [CurSpecies], a
ld a, $ff ld a, -1
ld [hl], a ld [hl], a
ld hl, PartyMon1Species ld hl, PartyMon1Species
ld a, [PartyCount] ld a, [PartyCount]
@ -75,8 +75,8 @@ CheckPartyFullAfterContest: ; 4d9e5
ld hl, PartyMon1CaughtLocation ld hl, PartyMon1CaughtLocation
call GetPartyLocation call GetPartyLocation
ld a, [hl] ld a, [hl]
and $80 and CAUGHT_GENDER_MASK
ld b, $13 ld b, NATIONAL_PARK
or b or b
ld [hl], a ld [hl], a
xor a xor a
@ -135,8 +135,8 @@ CheckPartyFullAfterContest: ; 4d9e5
call GetSRAMBank call GetSRAMBank
ld hl, sBoxMon1CaughtLocation ld hl, sBoxMon1CaughtLocation
ld a, [hl] ld a, [hl]
and $80 and CAUGHT_GENDER_MASK
ld b, $13 ld b, NATIONAL_PARK
or b or b
ld [hl], a ld [hl], a
call CloseSRAM call CloseSRAM
@ -227,7 +227,7 @@ SetGiftPartyMonCaughtData: ; 4dba3
SetGiftMonCaughtData: ; 4dbaf SetGiftMonCaughtData: ; 4dbaf
xor a xor a
ld [hli], a ld [hli], a
ld a, $7e ld a, GIFT_LOCATION
rrc b rrc b
or b or b
ld [hl], a ld [hl], a
@ -239,7 +239,7 @@ SetEggMonCaughtData: ; 4dbb8 (13:5bb8)
call GetPartyLocation call GetPartyLocation
ld a, [CurPartyLevel] ld a, [CurPartyLevel]
push af push af
ld a, $1 ld a, CAUGHT_EGG_LEVEL
ld [CurPartyLevel], a ld [CurPartyLevel], a
call SetBoxmonOrEggmonCaughtData call SetBoxmonOrEggmonCaughtData
pop af pop af

View File

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

View File

@ -504,7 +504,7 @@ GetCreditsPalette: ; 109b2c
.GetPalAddress: .GetPalAddress:
; Each set of palette data is 24 bytes long. ; Each set of palette data is 24 bytes long.
ld a, [wCreditsBorderMon] ; scene ld a, [wCreditsBorderMon] ; scene
and 3 and %11
add a add a
add a ; * 8 add a ; * 8
add a add a
@ -549,13 +549,13 @@ Credits_LoadBorderGFX: ; 109bca (42:5bca)
cp $ff cp $ff
jr z, .init jr z, .init
and 3 and %11
ld e, a ld e, a
inc a inc a
and 3 and %11
ld [hl], a ld [hl], a
ld a, [wCreditsBorderMon] ld a, [wCreditsBorderMon]
and 3 and %11
add a add a
add a add a
add e add e

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