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

View File

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

View File

@ -100,3 +100,13 @@ KANTO_LANDMARK EQU const_value
const TOHJO_FALLS ; 5d
const ROUTE_28 ; 5e
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
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)
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
RADIO_TOWER_MUSIC_F EQU 7
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_KIM ; 5
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
; pokedex entries (see data/pokemon/dex_entries.asm)
NUM_DEX_ENTRY_BANKS EQU 4
; party_struct members (see macros/wram.asm)
MON_SPECIES EQUS "(PartyMon1Species - PartyMon1)"
MON_ITEM EQUS "(PartyMon1Item - PartyMon1)"
@ -98,6 +102,21 @@ PARTYMON_STRUCT_LENGTH EQUS "(PartyMon1StatsEnd - PartyMon1)"
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
PARTY_LENGTH EQU 6

View File

@ -52,6 +52,7 @@ const_value set -1
const UP ; 1
const LEFT ; 2
const RIGHT ; 3
NUM_DIRECTIONS EQU const_value
DOWN_MASK EQU 1 << DOWN
UP_MASK EQU 1 << UP
@ -71,6 +72,7 @@ FACE_RIGHT EQU 1
const DAY_F ; 1
const NITE_F ; 2
const DARKNESS_F ; 3
NUM_DAYTIMES EQU const_value
MORN EQU 1 << MORN_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
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_BugCatcherEd
dw BugContestant_CooltrainerMNick
@ -12,6 +13,12 @@ BugContestantPointers: ; 13783
dw BugContestant_SchoolboyKipp
; 13799
; contestant format:
; db class, id
; dbw 1st-place mon, score
; dbw 2nd-place mon, score
; dbw 3rd-place mon, score
BugContestant_BugCatcherDon:
db BUG_CATCHER, DON
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
; dialog set, requested mon, offered mon, nickname, dvs, item, OT ID, OT name, gender requested
db \1, \2, \3, \4, \5, \6, \7
@ -12,11 +8,11 @@ ENDM
NPCTrades: ; fce58
; entries correspond to NPCTRADE_* constants
npctrade 0, 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 1, 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 2, 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 0, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, 50082, "FOREST@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_COLLECTOR, ABRA, MACHOP, "MUSCLE@@@@@", $37, $66, GOLD_BERRY, 37460, "MIKE@@@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_COLLECTOR, BELLSPROUT, ONIX, "ROCKY@@@@@@", $96, $66, BITTER_BERRY, 48926, "KYLE@@@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_HAPPY, KRABBY, VOLTORB, "VOLTY@@@@@@", $98, $88, PRZCUREBERRY, 29189, "TIM@@@@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_GIRL, DRAGONAIR, DODRIO, "DORIS@@@@@@", $77, $66, SMOKE_BALL, 00283, "EMY@@@@@@@@", TRADE_FEMALE_ONLY
npctrade TRADE_DIALOG_NEWBIE, HAUNTER, XATU, "PAUL@@@@@@@", $96, $86, MYSTERYBERRY, 15616, "CHRIS@@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_GIRL, CHANSEY, AERODACTYL, "AEROY@@@@@@", $96, $66, GOLD_BERRY, 26491, "KIM@@@@@@@@", TRADE_EITHER_GENDER
npctrade TRADE_DIALOG_COLLECTOR, DUGTRIO, MAGNETON, "MAGGIE@@@@@", $96, $66, METAL_COAT, 50082, "FOREST@@@@@", TRADE_EITHER_GENDER
; fcf38

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -247,10 +247,10 @@ GameFreakLogoScene2: ; e470d (39:470d)
ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
and $3f
cp $20
and %111111
cp %100000
jr nc, .asm_e4723
add $20
add %100000
.asm_e4723
ld e, a
farcall BattleAnim_Sine_e
@ -1604,12 +1604,12 @@ CrystalIntro_UnownFade: ; e5223 (39:5223)
inc hl
inc hl
ld a, [wcf65]
and $3f
cp $1f
and %111111
cp %011111
jr z, .okay
jr c, .okay
ld c, a
ld a, $3f
ld a, %111111
sub c
.okay

View File

@ -17,7 +17,7 @@ SpecialBuenasPassword: ; 8af6b
ld a, [MenuSelection]
ld c, a
ld a, [wBuenasPassword]
and $3
maskbits NUM_PASSWORDS_PER_CATEGORY +- 1
cp c
jr nz, .wrong
ld b, $1
@ -46,7 +46,7 @@ SpecialBuenasPassword: ; 8af6b
; 0x8afb4
.PasswordIndices: ; 8afb8
db 3
db NUM_PASSWORDS_PER_CATEGORY
db 0, 1, 2
db -1

View File

@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
; Select five random people to participate in the current contest.
; First we have to make sure that any old data is cleared away.
ld c, 10 ; Number of people to choose from.
ld c, NUM_BUG_CONTESTANTS
ld hl, BugCatchingContestantEventFlagTable
.loop1
push bc
@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8
.next
; Choose a flag at uniform random to be set.
call Random
cp 250
cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS
jr nc, .next
ld c, 25
ld c, $ff / NUM_BUG_CONTESTANTS
call SimpleDivide
ld e, b
ld d, 0
@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
Special_CheckBugContestContestantFlag: ; 139ed
; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
; Bug: If a >= 10 when this is called, it will read beyond the table.
; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table.
ld hl, BugCatchingContestantEventFlagTable
ld e, a
@ -74,18 +74,7 @@ Special_CheckBugContestContestantFlag: ; 139ed
ret
; 139fe
BugCatchingContestantEventFlagTable: ; 139fe
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
INCLUDE "data/bug_contest_flags.asm"
ContestDropOffMons: ; 13a12
ld hl, PartyMon1HP
@ -101,7 +90,7 @@ ContestDropOffMons: ; 13a12
ld a, [hl]
ld [wBugContestSecondPartySpecies], a
; ... and replacing it with the terminator byte
ld [hl], $ff
ld [hl], -1
xor a
ld [ScriptVar], a
ret
@ -118,7 +107,7 @@ ContestReturnMons: ; 13a31
ld a, [wBugContestSecondPartySpecies]
ld [hl], a
; Restore the party count, which must be recomputed.
ld b, $1
ld b, 1
.loop
ld a, [hli]
cp -1

View File

@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b
; 0x13730
LoadContestantName: ; 13730
; If a = 0, get your name.
dec a
; If a = 1, get your name.
dec a ; BUG_CONTEST_PLAYER
jr z, .player
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a
@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm"
BugContest_GetPlayersResult: ; 13807
ld hl, wBugContestThirdPlaceWinnerID
ld de, -4
ld b, 3
ld de, - BUG_CONTESTANT_SIZE
ld b, 3 ; 3rd, 2nd, or 1st
.loop
ld a, [hl]
cp 1 ; Player
cp BUG_CONTEST_PLAYER
jr z, .done
add hl, de
dec b
@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819
call ClearContestResults
call ComputeAIContestantScores
ld hl, wBugContestTempWinnerID
ld a, 1 ; Player
ld a, BUG_CONTEST_PLAYER
ld [hli], a
ld a, [wContestMon]
ld [hli], a
@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e
jr c, .not_first_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
ld bc, 4
ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
ld de, wBugContestSecondPlaceWinnerID
ld bc, 4
ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
call CopyTempContestant
@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e
jr c, .not_second_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
ld bc, 4
ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestSecondPlaceWinnerID
call CopyTempContestant
@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e
CopyTempContestant: ; 138a0
; Could've just called CopyBytes.
ld de, wBugContestTempWinnerID
rept 3
rept BUG_CONTESTANT_SIZE +- 1
ld a, [de]
inc de
ld [hli], a
@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0
inc hl
inc hl
.loop2
; 0, 1, or 2 for 1st, 2nd, or 3rd
call Random
and 3
cp 3
@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0
ld a, [hli]
ld h, [hl]
ld l, a
; randomly perturb score
call Random
and 7
and %111
ld c, a
ld b, 0
add hl, bc
@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0
.done
inc e
ld a, e
cp 10
cp NUM_BUG_CONTESTANTS
jr nz, .loop
ret
; 13900
@ -337,26 +338,26 @@ ContestScore: ; 13900
; DVs
ld a, [wContestMonDVs + 0]
ld b, a
and 2
and %0010
add a
add a
ld c, a
swap b
ld a, b
and 2
and %0010
add a
add c
ld d, a
ld a, [wContestMonDVs + 1]
ld b, a
and 2
and %0010
ld c, a
swap b
ld a, b
and 2
and %0010
srl a
add c
add c

View File

@ -80,7 +80,7 @@ rept 4
endr
ld a, [TimeOfDay]
and 3
maskbits NUM_DAYTIMES +- 1
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]
and $3
maskbits NUM_DAYTIMES +- 1
ld [TimeOfDayPal], a
ld a, $1
ld [wEnvironment], a

View File

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

View File

@ -20,7 +20,7 @@ SpecialPokeSeer: ; 4f0bc
call PrintSeerText
call JoyWaitAorB
ld b, $6
ld b, PARTY_LENGTH
farcall SelectMonFromParty
jr c, .cancel
@ -163,11 +163,11 @@ GetCaughtLevel: ; 4f18c
call ByteFill
; caught level
; Limited to between 1 and 63 for some reason.
; Limited to between 1 and 63 since it's a 6-bit quantity.
ld a, [wSeerCaughtData]
and $3f
and CAUGHT_LEVEL_MASK
jr z, .unknown
cp 1 ; hatched from an egg
cp CAUGHT_EGG_LEVEL ; egg marker value
jr nz, .print
ld a, EGG_LEVEL ; egg hatch level
@ -193,7 +193,7 @@ GetCaughtLevel: ; 4f18c
GetCaughtTime: ; 4f1c5
ld a, [wSeerCaughtData]
and $c0
and CAUGHT_TIME_MASK
jr z, .none
rlca
@ -233,11 +233,11 @@ UnknownCaughtData: ; 4f1f8
GetCaughtLocation: ; 4f20a
ld a, [wSeerCaughtGender]
and $7f
and CAUGHT_LOCATION_MASK
jr z, .Unknown
cp $7f
cp EVENT_LOCATION
jr z, .event
cp $7e
cp GIFT_LOCATION
jr z, .fail
ld e, a
farcall GetLandmarkName
@ -440,22 +440,22 @@ GetCaughtGender: ; 4f301
add hl, bc
ld a, [hl]
and $7f
and CAUGHT_LOCATION_MASK
jr z, .genderless
cp $7f
cp EVENT_LOCATION
jr z, .genderless
ld a, [hl]
and $80
and CAUGHT_GENDER_MASK
jr nz, .male
ld c, 1
ld c, CAUGHT_BY_GIRL
ret
.male
ld c, 2
ld c, CAUGHT_BY_BOY
ret
.genderless
ld c, 0
ld c, CAUGHT_BY_UNKNOWN
ret
; 4f31c

View File

@ -1333,7 +1333,7 @@ ResetClock: ; 6392
Function639b: ; unreferenced
; If bit 0 or 1 of [wTitleScreenTimer] is set, we don't need to be here.
ld a, [wTitleScreenTimer]
and $3
and %00000011
ret nz
ld bc, SpriteAnim10
ld hl, SPRITEANIMSTRUCT_FRAME

View File

@ -775,7 +775,7 @@ GetPokedexEntryBank:
ld a, [EnemyMonSpecies]
rlca
rlca
and 3
maskbits NUM_DEX_ENTRY_BANKS +- 1
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
@ -786,12 +786,6 @@ GetPokedexEntryBank:
ret
.PokedexEntryBanks:
GLOBAL PokedexEntries1
GLOBAL PokedexEntries2
GLOBAL PokedexEntries3
GLOBAL PokedexEntries4
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)

View File

@ -80,8 +80,8 @@ RegionCheck: ; 0x1caea1
jr c, .kanto
.johto
ld e, 0
ld e, JOHTO_REGION
ret
.kanto
ld e, 1
ld e, KANTO_REGION
ret

View File

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

View File

@ -29,7 +29,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
inc de ; wc80f
call CloseSRAM
call Random
and $1
and 1
ld [de], a
inc de ; wc810
call .RandomSample
@ -59,10 +59,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.RandomSample: ; 2c6ac (b:46ac)
push de
call Random
cp $19 ; 10 percent
cp 10 percent
jr c, .tenpercent
call Random
and $7
and %111
ld d, a
rl d
ld e, $80
@ -80,10 +80,10 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.tenpercent
call Random
cp $32 ; 20 percent
cp 20 percent - 1
jr c, .twopercent
call Random
and $3
and %011
ld d, a
rl d
ld e, $80
@ -102,7 +102,7 @@ PrepMysteryGiftDataToSend: ; 2c642 (b:4642)
.twopercent
call Random
cp $32 ; 50 ; 20 percent
cp 20 percent - 1
jr c, .pointfourpercent
ld a, b
swap a

View File

@ -70,14 +70,14 @@ Function6f07: ; 6f07
ld e, [hl]
ld hl, OBJECT_PALETTE
add hl, bc
bit 7, [hl]
bit OAM_PRIORITY, [hl]
jp nz, Function6fa1
ld hl, OBJECT_NEXT_TILE
add hl, bc
ld a, [hl]
ld d, a
call GetTileCollision
and a ; land
and a ; LANDTILE
jr z, Function6f3e
scf
ret
@ -106,7 +106,7 @@ Function6f3e: ; 6f3e
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
and 3
maskbits NUM_DIRECTIONS +- 1
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
and 3
maskbits NUM_DIRECTIONS +- 1
ld e, a
ld d, 0
ld hl, .data_6f7b
@ -178,49 +178,49 @@ Function6fa1: ; 6fa1
ld hl, OBJECT_DIRECTION_WALKING
add hl, bc
ld a, [hl]
and 3
jr z, .asm_6fb2
maskbits NUM_DIRECTIONS +- 1
jr z, .down
dec a
jr z, .asm_6fb7
jr z, .up
dec a
jr z, .asm_6fbb
jr .asm_6fbf
jr z, .left
jr .right
.asm_6fb2
.down
inc e
push de
inc d
jr .asm_6fc2
jr .continue
.asm_6fb7
.up
push de
inc d
jr .asm_6fc2
jr .continue
.asm_6fbb
.left
push de
inc e
jr .asm_6fc2
jr .continue
.asm_6fbf
.right
inc d
push de
inc e
.asm_6fc2
.continue
call GetCoordTile
call GetTileCollision
pop de
and a ; land
jr nz, .asm_6fd7
and a ; LANDTILE
jr nz, .not_land
call GetCoordTile
call GetTileCollision
and a ; land
jr nz, .asm_6fd7
and a ; LANDTILE
jr nz, .not_land
xor a
ret
.asm_6fd7
.not_land
scf
ret
; 6fd9

View File

@ -1,11 +1,3 @@
; Trade dialogs
const_def
const TRADE_INTRO
const TRADE_CANCEL
const TRADE_WRONG
const TRADE_COMPLETE
const TRADE_AFTER
NPCTrade:: ; fcba8
ld a, e
ld [wJumptableIndex], a
@ -83,9 +75,9 @@ CheckTradeGender: ; fcc23
ld e, TRADE_GENDER
call GetTradeAttribute
ld a, [hl]
and a
and a ; TRADE_EITHER_GENDER
jr z, .matching
cp 1
cp TRADE_MALE_ONLY
jr z, .check_male
farcall GetGender
@ -178,10 +170,10 @@ DoNPCTrade: ; fcc63
ld e, TRADE_DIALOG
call GetTradeAttribute
ld a, [hl]
cp 3
ld a, 1
cp TRADE_DIALOG_GIRL
ld a, CAUGHT_BY_GIRL
jr c, .okay
ld a, 2
ld a, CAUGHT_BY_BOY
.okay
ld [wOTTrademonCaughtData], a
@ -400,7 +392,7 @@ GetTradeMonNames: ; fce1b
and a
ret z
cp 1
cp TRADE_MALE_ONLY
ld a, "♂"
jr z, .done
ld a, "♀"
@ -433,31 +425,28 @@ PrintTradeText: ; fcf38
; fcf53
TradeTexts: ; fcf53
; intro
; entries correspond to TRADE_* × TRADE_DIALOG_* constants
; TRADE_INTRO
dw TradeIntroText1
dw TradeIntroText2
dw TradeIntroText3
dw TradeIntroText4
; cancel
; TRADE_CANCEL
dw TradeCancelText1
dw TradeCancelText2
dw TradeCancelText3
dw TradeCancelText4
; wrong mon
; TRADE_WRONG
dw TradeWrongText1
dw TradeWrongText2
dw TradeWrongText3
dw TradeWrongText4
; completed
; TRADE_COMPLETE
dw TradeCompleteText1
dw TradeCompleteText2
dw TradeCompleteText3
dw TradeCompleteText4
; after
; TRADE_AFTER
dw TradeAfterText1
dw TradeAfterText2
dw TradeAfterText3

View File

@ -1,3 +1,17 @@
; Pack.Jumptable and BattlePack.Jumptable indexes
const_def
const PACKSTATE_INITGFX ; 0
const PACKSTATE_INITITEMSPOCKET ; 1
const PACKSTATE_ITEMSPOCKETMENU ; 2
const PACKSTATE_INITBALLSPOCKET ; 3
const PACKSTATE_BALLSPOCKETMENU ; 4
const PACKSTATE_INITKEYITEMSPOCKET ; 5
const PACKSTATE_KEYITEMSPOCKETMENU ; 6
const PACKSTATE_INITTMHMPOCKET ; 7
const PACKSTATE_TMHMPOCKETMENU ; 8
const PACKSTATE_QUITNOSCRIPT ; 9
const PACKSTATE_QUITRUNSCRIPT ; 10
Pack: ; 10000
ld hl, Options
set NO_TEXT_SCROLL, [hl]
@ -28,6 +42,7 @@ Pack: ; 10000
; 10030
.Jumptable: ; 10030 (4:4030)
; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0
dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2
@ -50,7 +65,7 @@ Pack: ; 10000
ret
.InitItemsPocket: ; 10056 (4:4056)
xor a
xor a ; ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -70,15 +85,15 @@ Pack: ; 10000
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
ld b, $7
ld c, $3
ld b, PACKSTATE_INITTMHMPOCKET ; left
ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
ret
.InitKeyItemsPocket: ; 10094 (4:4094)
ld a, $2
ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -98,15 +113,15 @@ Pack: ; 10000
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
ld b, $3
ld c, $7
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
ret
.InitTMHMPocket: ; 100d3 (4:40d3)
ld a, $3
ld a, TM_HM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -118,8 +133,8 @@ Pack: ; 10000
.TMHMPocketMenu: ; 100e8 (4:40e8)
farcall TMHMPocket
ld b, $5
ld c, $1
ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
farcall _CheckTossableItem
@ -162,7 +177,6 @@ Pack: ; 10000
; 0x10137
.Jumptable1: ; 10137
dw .UseItem
dw QuitItemSubmenu
@ -211,7 +225,7 @@ Pack: ; 10000
ret
.InitBallsPocket: ; 10186 (4:4186)
ld a, $1
ld a, BALL_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -231,8 +245,8 @@ Pack: ; 10000
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
ld b, $1
ld c, $5
ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
call .ItemBallsKey_LoadSubmenu
@ -327,7 +341,6 @@ MenuDataHeader_UsableKeyItem: ; 0x10249
; 0x1026a
Jumptable_UseGiveTossRegisterQuit: ; 1026a
dw UseItem
dw GiveItem
dw TossMenu
@ -353,7 +366,6 @@ MenuDataHeader_UsableItem: ; 0x10274
; 0x10291
Jumptable_UseGiveTossQuit: ; 10291
dw UseItem
dw GiveItem
dw TossMenu
@ -376,7 +388,6 @@ MenuDataHeader_UnusableItem: ; 0x10299
; 0x102ac
Jumptable_UseQuit: ; 102ac
dw UseItem
dw QuitItemSubmenu
; 102b0
@ -398,7 +409,6 @@ MenuDataHeader_UnusableKeyItem: ; 0x102b0
; 0x102c7
Jumptable_UseRegisterQuit: ; 102c7
dw UseItem
dw RegisterItem
dw QuitItemSubmenu
@ -422,7 +432,6 @@ MenuDataHeader_HoldableKeyItem: ; 0x102cd
; 0x102ea
Jumptable_GiveTossRegisterQuit: ; 102ea
dw GiveItem
dw TossMenu
dw RegisterItem
@ -446,7 +455,6 @@ MenuDataHeader_HoldableItem: ; 0x102f2
; 0x1030b
Jumptable_GiveTossQuit: ; 1030b
dw GiveItem
dw TossMenu
dw QuitItemSubmenu
@ -462,14 +470,14 @@ UseItem: ; 10311
; 1031f
.dw ; 1031f (4:431f)
; entries correspond to ITEMMENU_* constants
dw .Oak ; ITEMMENU_NOUSE
dw .Oak
dw .Oak
dw .Oak
dw .Oak
dw .Current
dw .Party
dw .Field
dw .Current ; ITEMMENU_CURRENT
dw .Party ; ITEMMENU_PARTY
dw .Field ; ITEMMENU_CLOSE
; 1035c
.Oak: ; 1032d (4:432d)
@ -503,7 +511,7 @@ UseItem: ; 10311
ld a, [wItemEffectSucceeded]
and a
jr z, .Oak
ld a, $a
ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a
ret
; 10364 (4:4364)
@ -537,11 +545,11 @@ TossMenu: ; 10364
ResetPocketCursorPositions: ; 1039d
; unreferenced
ld a, [wCurrPocket]
and a
and a ; ITEM_POCKET
jr z, .items
dec a
dec a ; BALL_POCKET
jr z, .balls
dec a
dec a ; KEY_ITEM_POCKET
jr z, .key
ret
@ -693,6 +701,7 @@ BattlePack: ; 10493
; 104c3
.Jumptable: ; 104c3 (4:44c3)
; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0
dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2
@ -715,7 +724,7 @@ BattlePack: ; 10493
ret
.InitItemsPocket: ; 104e9 (4:44e9)
xor a
xor a ; ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -735,15 +744,15 @@ BattlePack: ; 10493
ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a
ld b, $7
ld c, $3
ld b, PACKSTATE_INITTMHMPOCKET ; left
ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
ret
.InitKeyItemsPocket: ; 10527 (4:4527)
ld a, $2
ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -763,15 +772,15 @@ BattlePack: ; 10493
ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a
ld b, $3
ld c, $7
ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
ret
.InitTMHMPocket: ; 10566 (4:4566)
ld a, $3
ld a, TM_HM_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -785,8 +794,8 @@ BattlePack: ; 10493
.TMHMPocketMenu: ; 10581 (4:4581)
farcall TMHMPocket
ld b, $5
ld c, $1
ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
xor a
@ -794,7 +803,7 @@ BattlePack: ; 10493
ret
.InitBallsPocket: ; 10594 (4:4594)
ld a, $1
ld a, BALL_POCKET
ld [wCurrPocket], a
call ClearPocketList
call DrawPocketName
@ -814,8 +823,8 @@ BattlePack: ; 10493
ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a
ld b, $1
ld c, $5
ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad
ret c
call ItemSubmenu
@ -893,13 +902,14 @@ TMHMSubmenu: ; 105dc (4:45dc)
ret
.ItemFunctionJumptable: ; 10637 (4:4637)
; entries correspond to ITEMMENU_* constants
dw .Oak ; ITEMMENU_NOUSE
dw .Oak
dw .Oak
dw .Oak
dw .Oak
dw .Unused
dw .BattleField
dw .BattleOnly
dw .Unused ; ITEMMENU_CURRENT
dw .BattleField ; ITEMMENU_PARTY
dw .BattleOnly ; ITEMMENU_CLOSE
.Oak: ; 10645 (4:4645)
ld hl, Text_ThisIsntTheTime
@ -937,7 +947,7 @@ TMHMSubmenu: ; 105dc (4:45dc)
cp $2
jr z, .didnt_use_item
.quit_run_script ; 1067e (4:467e)
ld a, 10
ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a
ret
@ -954,7 +964,7 @@ InitPackBuffers: ; 1068a
xor a
ld [wJumptableIndex], a
ld a, [wLastPocket]
and $3
maskbits NUM_POCKETS +- 1
ld [wCurrPocket], a
inc a
add a
@ -997,13 +1007,14 @@ DepositSellPack: ; 106be
; 106d1
.Jumptable: ; 106d1 (4:46d1)
; entries correspond to *_POCKET constants
dw .ItemsPocket
dw .BallsPocket
dw .KeyItemsPocket
dw .TMHMPocket
.ItemsPocket: ; 106d9 (4:46d9)
xor a
xor a ; ITEM_POCKET
call InitPocket
ld hl, PC_Mart_ItemsPocketMenuDataHeader
call CopyMenuDataHeader
@ -1019,7 +1030,7 @@ DepositSellPack: ; 106be
ret
.KeyItemsPocket: ; 106ff (4:46ff)
ld a, 2
ld a, KEY_ITEM_POCKET
call InitPocket
ld hl, PC_Mart_KeyItemsPocketMenuDataHeader
call CopyMenuDataHeader
@ -1035,7 +1046,7 @@ DepositSellPack: ; 106be
ret
.TMHMPocket: ; 10726 (4:4726)
ld a, 3
ld a, TM_HM_POCKET
call InitPocket
call WaitBGMap_DrawPackGFX
farcall TMHMPocket
@ -1044,7 +1055,7 @@ DepositSellPack: ; 106be
ret
.BallsPocket: ; 1073b (4:473b)
ld a, 1
ld a, BALL_POCKET
call InitPocket
ld hl, PC_Mart_BallsPocketMenuDataHeader
call CopyMenuDataHeader
@ -1098,7 +1109,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_left
ld a, [wJumptableIndex]
dec a
and $3
maskbits NUM_POCKETS +- 1
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@ -1110,7 +1121,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_right
ld a, [wJumptableIndex]
inc a
and $3
maskbits NUM_POCKETS +- 1
ld [wJumptableIndex], a
push de
ld de, SFX_SWITCH_POCKETS
@ -1144,14 +1155,14 @@ TutorialPack: ; 107bb
; 107e1
.dw ; 107e1 (4:47e1)
; entries correspond to *_POCKET constants
dw .Items
dw .Balls
dw .KeyItems
dw .TMHM
.Items: ; 107e9 (4:47e9)
xor a
xor a ; ITEM_POCKET
ld hl, .ItemsMenuDataHeader
jr .DisplayPocket
@ -1175,7 +1186,7 @@ TutorialPack: ; 107bb
; 10807
.KeyItems: ; 10807 (4:4807)
ld a, 2
ld a, KEY_ITEM_POCKET
ld hl, .KeyItemsMenuDataHeader
jr .DisplayPocket
@ -1199,7 +1210,7 @@ TutorialPack: ; 107bb
; 10826
.TMHM: ; 10826 (4:4826)
ld a, 3
ld a, TM_HM_POCKET
call InitPocket
call WaitBGMap_DrawPackGFX
farcall TMHMPocket
@ -1208,7 +1219,7 @@ TutorialPack: ; 107bb
ret
.Balls: ; 1083b (4:483b)
ld a, 1
ld a, BALL_POCKET
ld hl, .BallsMenuDataHeader
jr .DisplayPocket
@ -1283,7 +1294,7 @@ WaitBGMap_DrawPackGFX: ; 1089a (4:489a)
call WaitBGMap
DrawPackGFX: ; 1089d
ld a, [wCurrPocket]
and $3
maskbits NUM_POCKETS +- 1
ld e, a
ld d, $0
ld a, [BattleType]
@ -1310,10 +1321,10 @@ DrawPackGFX: ; 1089d
; 108cc
PackGFXPointers: ; 108cc
dw PackGFX + (15 tiles) * 1
dw PackGFX + (15 tiles) * 3
dw PackGFX + (15 tiles) * 0
dw PackGFX + (15 tiles) * 2
dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET
dw PackGFX + (15 tiles) * 3 ; BALL_POCKET
dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET
; 108d4
Pack_InterpretJoypad: ; 108d4 (4:48d4)
@ -1344,7 +1355,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4)
ret
.b_button
ld a, 9
ld a, PACKSTATE_QUITNOSCRIPT
ld [wJumptableIndex], a
scf
ret
@ -1489,15 +1500,19 @@ DrawPocketName: ; 109bb
; 109e1
.tilemap ; 109e1
; ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $06, $07, $08, $09, $0a ; Items
db $02, $05, $05, $05, $03 ; bottom border
; BALL_POCKET
db $00, $04, $04, $04, $01 ; top border
db $15, $16, $17, $18, $19 ; Balls
db $02, $05, $05, $05, $03 ; bottom border
; KEY_ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $0b, $0c, $0d, $0e, $0f ; Key Items
db $02, $05, $05, $05, $03 ; bottom border
; TM_HM_POCKET
db $00, $04, $04, $04, $01 ; top border
db $10, $11, $12, $13, $14 ; TM/HM
db $02, $05, $05, $05, $03 ; bottom border

View File

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

View File

@ -154,7 +154,7 @@ UpdateOverworldMap: ; d536 (3:5536)
jr nc, .not_overflowed
ld a, [wBGMapAnchor + 1]
inc a
and $3
and %11
or HIGH(vBGMap0)
ld [wBGMapAnchor + 1], a
.not_overflowed
@ -185,7 +185,7 @@ UpdateOverworldMap: ; d536 (3:5536)
jr nc, .not_underflowed
ld a, [wBGMapAnchor + 1]
dec a
and $3
and %11
or HIGH(vBGMap0)
ld [wBGMapAnchor + 1], a
.not_underflowed

View File

@ -1,3 +1,4 @@
; Pokedex_RunJumptable.Jumptable indexes
const_def
const DEXSTATE_MAIN_SCR
const DEXSTATE_UPDATE_MAIN_SCR
@ -185,6 +186,7 @@ Pokedex_RunJumptable: ; 4010b
jp hl
.Jumptable: ; 40115 (10:4115)
; entries correspond to DEXSTATE_* constants
dw Pokedex_InitMainScreen
dw Pokedex_UpdateMainScreen
dw Pokedex_InitDexEntryScreen
@ -739,7 +741,7 @@ Pokedex_InitSearchResultsScreen: ; 4050a (10:450a)
farcall DrawPokedexSearchResultsWindow
call Pokedex_PlaceSearchResultsTypeStrings
call Pokedex_UpdateSearchResultsCursorOAM
ld a, $ff
ld a, -1
ld [CurPartySpecies], a
ld a, SCGB_POKEDEX
call Pokedex_GetSGBLayout
@ -1123,13 +1125,14 @@ Pokedex_DrawMainScreenBG: ; 4074c (10:474c)
ret
String_SEEN: ; 407e1
db "SEEN", $ff
db "SEEN", -1
String_OWN: ; 407e6
db "OWN", $ff
db "OWN", -1
String_SELECT_OPTION: ; 407ea
db $3b, $48, $49, $4a, $44, $45, $46, $47 ; SELECT > OPTION
; fallthrough
String_START_SEARCH: ; 407f2
db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, $ff ; START > SEARCH
db $3c, $3b, $41, $42, $43, $4b, $4c, $4d, $4e, $3c, -1 ; START > SEARCH
Pokedex_DrawDexEntryScreenBG: ; 407fd
call Pokedex_FillBackgroundColor2
@ -1164,13 +1167,13 @@ Pokedex_DrawDexEntryScreenBG: ; 407fd
ret
.Unused: ; 4084f
db $5c, $5d, $ff ; No.
db $5c, $5d, -1 ; No.
.Height: ; 40852
db "HT ?", $5e, "??", $5f, $ff ; HT ?'??"
db "HT ?", $5e, "??", $5f, -1 ; HT ?'??"
.Weight: ; 4085c
db "WT ???lb", $ff ; WT ???lb
db "WT ???lb", -1 ; WT ???lb
.MenuItems: ; 40867
db $3b, " PAGE AREA CRY PRNT", $ff
db $3b, " PAGE AREA CRY PRNT", -1
Pokedex_DrawOptionScreenBG: ; 4087c (10:487c)
call Pokedex_FillBackgroundColor2
@ -1195,7 +1198,7 @@ Pokedex_DrawOptionScreenBG: ; 4087c (10:487c)
ret
.Title: ; 408b2
db $3b, " OPTION ", $3c, $ff
db $3b, " OPTION ", $3c, -1
.Modes: ; 408bd
db "NEW #DEX MODE"
@ -1229,10 +1232,10 @@ Pokedex_DrawSearchScreenBG: ; 408f0 (10:48f0)
ret
.Title: ; 4092a
db $3b, " SEARCH ", $3c, $ff
db $3b, " SEARCH ", $3c, -1
.TypeLeftRightArrows: ; 40935
db $3d, " ", $3e, $ff
db $3d, " ", $3e, -1
.Types: ; 40940
db "TYPE1"

View File

@ -230,7 +230,7 @@ GetDexEntryPointer: ; 44333
push de
rlca
rlca
and $3
maskbits NUM_DEX_ENTRY_BANKS +- 1
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
@ -241,12 +241,6 @@ GetDexEntryPointer: ; 44333
ret
.PokedexEntryBanks: ; 44351
GLOBAL PokedexEntries1
GLOBAL PokedexEntries2
GLOBAL PokedexEntries3
GLOBAL PokedexEntries4
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)

View File

@ -1,3 +1,27 @@
; Pokégear cards
const_def
const POKEGEARCARD_CLOCK ; 0
const POKEGEARCARD_MAP ; 1
const POKEGEARCARD_PHONE ; 2
const POKEGEARCARD_RADIO ; 3
NUM_POKEGEAR_CARDS EQU const_value
; PokegearJumptable.Jumptable indexes
const_def
const POKEGEARSTATE_CLOCKINIT ; 0
const POKEGEARSTATE_CLOCKJOYPAD ; 1
const POKEGEARSTATE_MAPCHECKREGION ; 2
const POKEGEARSTATE_JOHTOMAPINIT ; 3
const POKEGEARSTATE_JOHTOMAPJOYPAD ; 4
const POKEGEARSTATE_KANTOMAPINIT ; 5
const POKEGEARSTATE_KANTOMAPJOYPAD ; 6
const POKEGEARSTATE_PHONEINIT ; 7
const POKEGEARSTATE_PHONEJOYPAD ; 8
const POKEGEARSTATE_MAKEPHONECALL ; 9
const POKEGEARSTATE_FINISHPHONECALL ; a
const POKEGEARSTATE_RADIOINIT ; b
const POKEGEARSTATE_RADIOJOYPAD ; c
PokeGear: ; 90b8d (24:4b8d)
ld hl, Options
ld a, [hl]
@ -163,7 +187,10 @@ AnimatePokegearModeIndicatorArrow: ; 90d41 (24:4d41)
; 90d52 (24:4d52)
.XCoords: ; 90d52
db $00, $10, $20, $30
db $00 ; POKEGEARCARD_CLOCK
db $10 ; POKEGEARCARD_MAP
db $20 ; POKEGEARCARD_PHONE
db $30 ; POKEGEARCARD_RADIO
; 90d56
TownMap_GetCurrentLandmark: ; 90d56
@ -210,7 +237,7 @@ TownMap_InitCursorAndPlayerIconPositions: ; 90d70 (24:4d70)
ret
Pokegear_InitJumptableIndices: ; 90d9e (24:4d9e)
ld a, $0
ld a, POKEGEARSTATE_CLOCKINIT
ld [wJumptableIndex], a
xor a
ld [wcf64], a
@ -224,7 +251,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld a, $4f
call ByteFill
ld a, [wcf64]
and $3
maskbits NUM_POKEGEAR_CARDS +- 1
add a
ld e, a
ld d, 0
@ -260,6 +287,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
xor a
.finish
ld [hWY], a
; swap region maps
ld a, [wcf65]
and 1
xor 1
@ -281,6 +309,7 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
; 90e12 (24:4e12)
.Jumptable: ; 90e12
; entries correspond to POKEGEARCARD_* constants
dw .Clock
dw .Map
dw .Phone
@ -319,12 +348,12 @@ InitPokegearTilemap: ; 90da8 (24:4da8)
ld e, 1
.ok
farcall PokegearMap
ld a, $7
ld a, $07
ld bc, $12
hlcoord 1, 2
call ByteFill
hlcoord 0, 2
ld [hl], $6
ld [hl], $06
hlcoord 19, 2
ld [hl], $17
ld a, [wPokegearMapCursorLandmark]
@ -382,13 +411,13 @@ Pokegear_FinishTilemap: ; 90eb0 (24:4eb0)
call ByteFill
ld de, wPokegearFlags
ld a, [de]
bit 0, a
bit 0, a ; ENGINE_MAP_CARD
call nz, .PlaceMapIcon
ld a, [de]
bit 2, a
bit 2, a ; ENGINE_PHONE_CARD
call nz, .PlacePhoneIcon
ld a, [de]
bit 1, a
bit 1, a ; ENGINE_RADIO_CARD
call nz, .PlaceRadioIcon
hlcoord 0, 0
ld a, $46
@ -433,6 +462,7 @@ PokegearJumptable: ; 90f04 (24:4f04)
jp hl
.Jumptable: ; 90f13 (24:4f13)
; entries correspond to POKEGEARSTATE_* constants
dw PokegearClock_Init
dw PokegearClock_Joypad
dw PokegearMap_CheckRegion
@ -460,32 +490,32 @@ PokegearClock_Joypad: ; 90f3e (24:4f3e)
call .UpdateClock
ld hl, hJoyLast
ld a, [hl]
and A_BUTTON + B_BUTTON + START + SELECT
and A_BUTTON | B_BUTTON | START | SELECT
jr nz, .quit
ld a, [hl]
and D_RIGHT
ret z
ld a, [wPokegearFlags]
bit 0, a
bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map_card
ld c, $2
ld b, $1
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
jr .done
.no_map_card
ld a, [wPokegearFlags]
bit 2, a
bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone_card
ld c, $7
ld b, $2
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
jr .done
.no_phone_card
ld a, [wPokegearFlags]
bit 1, a
bit 1, a ; ENGINE_RADIO_CARD
ret z
ld c, $b
ld b, $3
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
.done
call Pokegear_SwitchPage
ret
@ -535,12 +565,12 @@ PokegearMap_CheckRegion: ; 90fb4 (24:4fb4)
cp KANTO_LANDMARK
jr nc, .kanto
.johto
ld a, 3
ld a, POKEGEARSTATE_JOHTOMAPINIT
jr .done
ret
.kanto
ld a, 5
ld a, POKEGEARSTATE_KANTOMAPINIT
.done
ld [wJumptableIndex], a
call ExitPokegearRadio_HandleMusic
@ -583,23 +613,23 @@ PokegearMap_ContinueMap: ; 90ff2 (24:4ff2)
.right
ld a, [wPokegearFlags]
bit 2, a
bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone
ld c, $7
ld b, $2
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
jr .done
.no_phone
ld a, [wPokegearFlags]
bit 1, a
bit 1, a ; ENGINE_RADIO_CARD
ret z
ld c, $b
ld b, $3
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
jr .done
.left
ld c, $0
ld b, $0
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
.done
call Pokegear_SwitchPage
ret
@ -657,7 +687,7 @@ PokegearMap_InitPlayerIcon: ; 9106a
depixel 0, 0
ld b, SPRITE_ANIM_INDEX_RED_WALK
ld a, [wPlayerGender]
bit 0, a
bit 0, a ; ENGINE_PLAYER_IS_FEMALE
jr z, .got_gender
ld b, SPRITE_ANIM_INDEX_BLUE_WALK
.got_gender
@ -688,7 +718,7 @@ PokegearMap_InitCursor: ; 91098
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $4
ld [hl], $04
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
@ -734,7 +764,7 @@ PokegearMap_UpdateCursorPosition: ; 910d4
TownMap_GetKantoLandmarkLimits: ; 910e8
ld a, [wStatusFlags]
bit 6, a
bit 6, a ; ENGINE_CREDITS_SKIP
jr z, .not_hof
ld d, ROUTE_28
ld e, PALLET_TOWN
@ -754,7 +784,7 @@ PokegearRadio_Init: ; 910f9 (24:50f9)
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $8
ld [hl], $08
call _UpdateRadioStation
ld hl, wJumptableIndex
inc [hl]
@ -780,23 +810,23 @@ PokegearRadio_Joypad: ; 91112 (24:5112)
.left
ld a, [wPokegearFlags]
bit 2, a
bit 2, a ; ENGINE_PHONE_CARD
jr z, .no_phone
ld c, $7
ld b, $2
ld c, POKEGEARSTATE_PHONEINIT
ld b, POKEGEARCARD_PHONE
jr .switch_page
.no_phone
ld a, [wPokegearFlags]
bit 0, a
bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map
ld c, $2
ld b, $1
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
jr .switch_page
.no_map
ld c, $0
ld b, $0
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
.switch_page
call Pokegear_SwitchPage
ret
@ -839,23 +869,23 @@ PokegearPhone_Joypad: ; 91171 (24:5171)
.left
ld a, [wPokegearFlags]
bit 0, a
bit 0, a ; ENGINE_MAP_CARD
jr z, .no_map
ld c, $2
ld b, $1
ld c, POKEGEARSTATE_MAPCHECKREGION
ld b, POKEGEARCARD_MAP
jr .switch_page
.no_map
ld c, $0
ld b, $0
ld c, POKEGEARSTATE_CLOCKINIT
ld b, POKEGEARCARD_CLOCK
jr .switch_page
.right
ld a, [wPokegearFlags]
bit 1, a
bit 1, a ; ENGINE_RADIO_CARD
ret z
ld c, $b
ld b, $3
ld c, POKEGEARSTATE_RADIOINIT
ld b, POKEGEARCARD_RADIO
.switch_page
call Pokegear_SwitchPage
ret
@ -891,7 +921,7 @@ PokegearPhone_Joypad: ; 91171 (24:5171)
ret
.quit_submenu
ld a, $8
ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ret
@ -931,7 +961,7 @@ PokegearPhone_MakePhoneCall: ; 911eb (24:51eb)
farcall Phone_NoSignal
ld hl, .OutOfServiceArea
call PrintText
ld a, $8
ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
@ -958,7 +988,7 @@ PokegearPhone_FinishPhoneCall: ; 91256 (24:5256)
and A_BUTTON | B_BUTTON
ret z
farcall HangUp
ld a, $8
ld a, POKEGEARSTATE_PHONEJOYPAD
ld [wJumptableIndex], a
ld hl, PokegearText_WhomToCall
call PrintText
@ -993,7 +1023,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d)
.down
ld hl, wPokegearPhoneCursorPosition
ld a, [hl]
cp $3
cp 3
jr nc, .scroll_page_down
inc [hl]
jr .done_joypad_same_page
@ -1001,7 +1031,7 @@ PokegearPhone_GetDPad: ; 9126d (24:526d)
.scroll_page_down
ld hl, wPokegearPhoneScrollPosition
ld a, [hl]
cp $6
cp 6
ret nc
inc [hl]
jr .done_joypad_update_page
@ -1075,7 +1105,7 @@ PokegearPhone_UpdateDisplayList: ; 912d8 (24:52d8)
ld a, [wPokegearPhoneLoadNameBuffer]
inc a
ld [wPokegearPhoneLoadNameBuffer], a
cp $4
cp 4
jr c, .loop
call PokegearPhone_UpdateCursor
ret
@ -1337,9 +1367,9 @@ Pokegear_SwitchPage: ; 91480 (24:5480)
ExitPokegearRadio_HandleMusic: ; 91492
ld a, [wPokegearRadioMusicPlaying]
cp $fe
cp RESTART_MAP_MUSIC
jr z, .restart_map_music
cp $ff
cp ENTER_MAP_MUSIC
call z, EnterMapMusic
xor a
ld [wPokegearRadioMusicPlaying], a
@ -1364,11 +1394,11 @@ DeleteSpriteAnimStruct2ToEnd: ; 914ab (24:54ab)
Pokegear_LoadTilemapRLE: ; 914bb (24:54bb)
; Format: repeat count, tile ID
; Terminated with $FF
; Terminated with -1
hlcoord 0, 0
.loop
ld a, [de]
cp $ff
cp -1
ret z
ld b, a
inc de
@ -1560,7 +1590,7 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_PlacesAndPeople
@ -1568,7 +1598,7 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_LetsAllSing
@ -1576,14 +1606,14 @@ RadioChannels:
call .InJohto
jr c, .NoSignal
ld a, [wPokegearFlags]
bit 3, a
bit 3, a ; ENGINE_EXPN_CARD
jr z, .NoSignal
jp LoadStation_PokeFluteRadio
.EvolutionRadio:
; This station airs in the Lake of Rage area when Rocket are still in Mahogany.
ld a, [wStatusFlags]
bit 4, a
bit 4, a ; ENGINE_ROCKET_SIGNAL_ON_CH20
jr z, .NoSignal
ld a, [wPokegearMapPlayerIconLandmark]
cp MAHOGANY_TOWN
@ -1669,7 +1699,7 @@ LoadStation_BuenasPassword: ; 917a5 (24:57a5)
call Radio_BackUpFarCallParams
ld de, NotBuenasPasswordName
ld a, [wStatusFlags2]
bit 0, a
bit 0, a ; ENGINE_ROCKETS_IN_RADIO_TOWER
ret z
ld de, BuenasPasswordName
ret
@ -1768,7 +1798,7 @@ RadioMusicRestartDE: ; 91854 (24:5854)
RadioMusicRestartPokemonChannel: ; 91868 (24:5868)
push de
ld a, $fe
ld a, RESTART_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
ld de, MUSIC_NONE
call PlayMusic
@ -1799,7 +1829,7 @@ NoRadioStation: ; 91888 (24:5888)
NoRadioMusic: ; 9189d (24:589d)
ld de, MUSIC_NONE
call PlayMusic
ld a, $ff
ld a, ENTER_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
ret
@ -1810,7 +1840,7 @@ NoRadioName: ; 918a9 (24:58a9)
lb bc, 3, 18
call ClearBox
hlcoord 0, 12
ld bc, $412
lb bc, 4, 18
call TextBox
ret
@ -1966,26 +1996,26 @@ _TownMap: ; 9191c
ld a, [wTownMapPlayerIconLandmark]
cp KANTO_LANDMARK
jr nc, .kanto2
ld e, $0
ld e, JOHTO_REGION
jr .okay_tilemap
.kanto2
ld e, $1
ld e, KANTO_REGION
.okay_tilemap
farcall PokegearMap
ld a, $7
ld a, $07
ld bc, 6
hlcoord 1, 0
call ByteFill
hlcoord 0, 0
ld [hl], $6
ld [hl], $06
hlcoord 7, 0
ld [hl], $17
hlcoord 7, 1
ld [hl], $16
hlcoord 7, 2
ld [hl], $26
ld a, $7
ld a, $07
ld bc, NAME_LENGTH
hlcoord 8, 2
call ByteFill
@ -2001,7 +2031,7 @@ PlayRadio: ; 91a53
ld hl, Options
ld a, [hl]
push af
set 4, [hl]
set NO_TEXT_SCROLL, [hl]
call .PlayStation
ld c, 100
call DelayFrames
@ -2031,10 +2061,10 @@ PlayRadio: ; 91a53
; 91a87
.PlayStation: ; 91a87
ld a, -1
ld [EnemyTurnsTaken], a
ld a, ENTER_MAP_MUSIC
ld [wPokegearRadioMusicPlaying], a
ld hl, .StationPointers
ld d, $0
ld d, 0
add hl, de
add hl, de
ld a, [hli]
@ -2063,6 +2093,7 @@ PlayRadio: ; 91a53
; 91ab9
.StationPointers: ; 91ab9
; entries correspond to radio station constants
dw .OakOrPnP
dw LoadStation_OaksPokemonTalk
dw LoadStation_PokedexShow
@ -2286,7 +2317,7 @@ TownMapBubble: ; 91bb5
GetMapCursorCoordinates: ; 91c17
ld a, [wTownMapPlayerIconLandmark]
ld l, a
ld h, $0
ld h, 0
add hl, hl
ld de, Flypoints
add hl, de
@ -2296,10 +2327,10 @@ GetMapCursorCoordinates: ; 91c17
ld c, a
ld a, [wTownMapCursorCoordinates + 1]
ld b, a
ld hl, $4
ld hl, 4
add hl, bc
ld [hl], e
ld hl, $5
ld hl, 5
add hl, bc
ld [hl], d
ret
@ -2477,7 +2508,7 @@ _Area: ; 91d11
call SetPalettes
xor a
ld [hBGMapMode], a
xor a ; Johto
xor a ; JOHTO_REGION
call .GetAndPlaceNest
.loop
call JoyTextDelay
@ -2524,13 +2555,13 @@ _Area: ; 91d11
call ClearSprites
ld a, $90
ld [hWY], a
xor a ; Johto
xor a ; JOHTO_REGION
call .GetAndPlaceNest
ret
.right
ld a, [wStatusFlags]
bit 6, a ; hall of fame
bit 6, a ; ENGINE_CREDITS_SKIP
ret z
ld a, [hWY]
and a
@ -2538,7 +2569,7 @@ _Area: ; 91d11
call ClearSprites
xor a
ld [hWY], a
ld a, 1 ; Kanto
ld a, KANTO_REGION
call .GetAndPlaceNest
ret
@ -2791,12 +2822,11 @@ TownMapPals: ; 91f13
; Current tile
ld a, [hli]
push hl
; HP/borders use palette 0
; The palette map covers tiles $00 to $5f; $60 and above use palette 0
cp $60
jr nc, .pal0
; The palette data is condensed to nybbles,
; least-significant first.
; The palette data is condensed to nybbles, least-significant first.
ld hl, .PalMap
srl a
jr c, .odd
@ -2807,7 +2837,7 @@ TownMapPals: ; 91f13
adc 0
ld h, a
ld a, [hl]
and %111
and PALETTE_MASK
jr .update
.odd
@ -2819,7 +2849,7 @@ TownMapPals: ; 91f13
ld h, a
ld a, [hl]
swap a
and %111
and PALETTE_MASK
jr .update
.pal0
@ -2839,7 +2869,7 @@ INCLUDE "gfx/pokegear/town_map_palette_map.asm"
; 91f7b
TownMapMon: ; 91f7b
; Draw the FlyMon icon at town map location in
; Draw the FlyMon icon at town map location
; Get FlyMon species
ld a, [CurPartyMon]
@ -2850,7 +2880,7 @@ TownMapMon: ; 91f7b
ld a, [hl]
ld [wd265], a
; Get FlyMon icon
ld e, 8 ; starting tile in VRAM
ld e, $08 ; starting tile in VRAM
farcall GetSpeciesIcon
; Animation/palette
depixel 0, 0
@ -2858,7 +2888,7 @@ TownMapMon: ; 91f7b
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $8
ld [hl], $08
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL

View File

@ -247,7 +247,7 @@ endr
; Generate a number, either 0, 1, or 2, to choose a time of day.
.loop2
call Random
and $3
maskbits NUM_DAYTIMES +- 1
cp DARKNESS_F
jr z, .loop2
@ -692,8 +692,8 @@ PokedexShow_GetDexEntryBank:
dec a
rlca
rlca
and 3
ld hl, .pokedexbanks
maskbits NUM_DEX_ENTRY_BANKS +- 1
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
@ -702,7 +702,7 @@ PokedexShow_GetDexEntryBank:
pop hl
ret
.pokedexbanks
.PokedexEntryBanks
db BANK(PokedexEntries1)
db BANK(PokedexEntries2)
db BANK(PokedexEntries3)

View File

@ -11,10 +11,10 @@ DrawKrisPackGFX: ; 48e81
ret
PackFGFXPointers: ; 48e93
dw PackFGFX + (15 tiles) * 1
dw PackFGFX + (15 tiles) * 3
dw PackFGFX + (15 tiles) * 0
dw PackFGFX + (15 tiles) * 2
dw PackFGFX + (15 tiles) * 1 ; ITEM_POCKET
dw PackFGFX + (15 tiles) * 3 ; BALL_POCKET
dw PackFGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
dw PackFGFX + (15 tiles) * 2 ; TM_HM_POCKET
PackFGFX: ; 48e9b
INCBIN "gfx/pack/pack_f.2bpp"

View File

@ -614,7 +614,7 @@ GetPocketName:
ld a, [wItemAttributeParamBuffer]
dec a
ld hl, .Pockets
and 3
maskbits NUM_POCKETS +- 1
add a
ld e, a
ld d, 0
@ -2474,7 +2474,7 @@ Script_warpfacing:
; parameters: facing, map_group, map_id, x, y
call GetScriptByte
and $3
maskbits NUM_DIRECTIONS +- 1
ld c, a
ld a, [wPlayerSpriteSetupFlags]
set 5, a

View File

@ -1,3 +1,9 @@
const_value set 1
const PINK_PAGE ; 1
const GREEN_PAGE ; 2
const BLUE_PAGE ; 3
NUM_STAT_PAGES EQU const_value +- 1
BattleStatsScreenInit: ; 4dc7b (13:5c7b)
ld a, [wLinkMode]
cp LINK_MOBILE
@ -58,12 +64,12 @@ StatsScreenMain: ; 0x4dcd2
; stupid interns
ld [wcf64], a
ld a, [wcf64]
and $fc
or $1
and %11111100
or 1
ld [wcf64], a
.loop ; 4dce3
ld a, [wJumptableIndex]
and $7f
and $ff ^ (1 << 7)
ld hl, StatsScreenPointerTable
rst JumpTable
call StatsScreen_WaitAnim ; check for keys?
@ -79,13 +85,13 @@ StatsScreenMobile: ; 4dcf7
; stupid interns
ld [wcf64], a
ld a, [wcf64]
and $fc
or $1
and %11111100
or 1
ld [wcf64], a
.loop
farcall Mobile_SetOverworldDelay
ld a, [wJumptableIndex]
and $7f
and $ff ^ (1 << 7)
ld hl, StatsScreenPointerTable
rst JumpTable
call StatsScreen_WaitAnim
@ -277,7 +283,7 @@ StatsScreen_GetJoypad: ; 4de2c (13:5e2c)
StatsScreen_JoypadAction: ; 4de54 (13:5e54)
push af
ld a, [wcf64]
and $3
maskbits NUM_STAT_PAGES +- 1
ld c, a
pop af
bit B_BUTTON_F, a
@ -335,20 +341,20 @@ StatsScreen_JoypadAction: ; 4de54 (13:5e54)
.a_button
ld a, c
cp $3
cp BLUE_PAGE ; last page
jr z, .b_button
.d_right
inc c
ld a, $3
ld a, BLUE_PAGE ; last page
cp c
jr nc, .set_page
ld c, $1
ld c, PINK_PAGE ; first page
jr .set_page
.d_left
dec c
jr nz, .set_page
ld c, $3
ld c, BLUE_PAGE ; last page
jr .set_page
.done
@ -507,7 +513,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.ClearBox: ; 4dfda (13:5fda)
ld a, [wcf64]
and $3
maskbits NUM_STAT_PAGES +- 1
ld c, a
call StatsScreen_LoadPageIndicators
hlcoord 0, 8
@ -517,7 +523,7 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.LoadPals: ; 4dfed (13:5fed)
ld a, [wcf64]
and $3
maskbits NUM_STAT_PAGES +- 1
ld c, a
farcall LoadStatsScreenPals
call DelayFrame
@ -527,13 +533,14 @@ StatsScreen_LoadGFX: ; 4dfb6 (13:5fb6)
.PageTilemap: ; 4e002 (13:6002)
ld a, [wcf64]
and $3
maskbits NUM_STAT_PAGES +- 1
dec a
ld hl, .Jumptable
rst JumpTable
ret
.Jumptable: ; 4e00d (13:600d)
; entries correspond to *_PAGE constants
dw .PinkPage
dw .GreenPage
dw .BluePage
@ -1089,13 +1096,13 @@ StatsScreen_LoadPageIndicators: ; 4e4cd (13:64cd)
ld a, $36
call .load_square
ld a, c
cp $2
cp GREEN_PAGE
ld a, $3a
hlcoord 13, 5
hlcoord 13, 5 ; PINK_PAGE (< GREEN_PAGE)
jr c, .load_square
hlcoord 15, 5
hlcoord 15, 5 ; GREEN_PAGE (= GREEN_PAGE)
jr z, .load_square
hlcoord 17, 5
hlcoord 17, 5 ; BLUE_PAGE (> GREEN_PAGE)
.load_square ; 4e4f7 (13:64f7)
push bc
ld [hli], a

View File

@ -133,16 +133,16 @@ endr
Special_SampleKenjiBreakCountdown: ; 11485
; Generate a random number between 3 and 6
call Random
and 3
and %11
add 3
ld [wKenjiBreakTimer], a
ret
; 11490
StartBugContestTimer: ; 11490
ld a, 20
ld a, BUG_CONTEST_MINUTES
ld [wBugContestMinsRemaining], a
ld a, 0
ld a, BUG_CONTEST_SECONDS
ld [wBugContestSecsRemaining], a
call UpdateTime
ld hl, wBugContestStartTime
@ -252,7 +252,7 @@ RestartLuckyNumberCountdown: ; 1152b
ld a, FRIDAY
sub c
jr z, .friday_saturday
jr nc, .earlier ; should've done "ret nc"
jr nc, .earlier ; could have done "ret nc"
.friday_saturday
add 7

View File

@ -1,3 +1,14 @@
TRADEANIM_RIGHT_ARROW EQU $ed
TRADEANIM_LEFT_ARROW EQU $ee
; TradeAnim_TubeAnimJumptable.Jumptable indexes
const_def
const TRADEANIMSTATE_0 ; 0
const TRADEANIMSTATE_1 ; 1
const TRADEANIMSTATE_2 ; 2
const TRADEANIMSTATE_3 ; 3
TRADEANIMJUMPTABLE_LENGTH EQU const_value
TradeAnimation: ; 28f24
xor a
ld [wcf66], a
@ -165,13 +176,13 @@ RunTradeAnimScript: ; 28fa1
ld de, vTiles2 tile $31
call Decompress
ld hl, TradeArrowGFX
ld de, vTiles1 tile $6d
ld bc, $10
ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW
ld bc, 1 tiles
ld a, BANK(TradeArrowGFX)
call FarCopyBytes
ld hl, TradeArrowGFX + $10
ld de, vTiles1 tile $6e
ld bc, $10
ld hl, TradeArrowGFX + 1 tiles
ld de, vTiles0 tile TRADEANIM_LEFT_ARROW
ld bc, 1 tiles
ld a, BANK(TradeArrowGFX)
call FarCopyBytes
xor a
@ -317,7 +328,7 @@ TradeAnim_End: ; 29123
; 29129
TradeAnim_TubeToOT1: ; 29129
ld a, $ed ; >>>>>>>>
ld a, TRADEANIM_RIGHT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeSendmonSpecies]
ld [wd265], a
@ -327,11 +338,11 @@ TradeAnim_TubeToOT1: ; 29129
jr TradeAnim_InitTubeAnim
TradeAnim_TubeToPlayer1: ; 2913c
ld a, $ee ; <<<<<<<<
ld a, TRADEANIM_LEFT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeGetmonSpecies]
ld [wd265], a
ld a, $2
ld a, TRADEANIMSTATE_2
depixel 9, 18, 4, 4
ld b, $4
TradeAnim_InitTubeAnim: ; 2914e
@ -400,7 +411,7 @@ TradeAnim_TubeToOT2: ; 291af
ld [hSCX], a
cp $50
ret nz
ld a, $1
ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@ -414,7 +425,7 @@ TradeAnim_TubeToOT3: ; 291c4
ld [hSCX], a
cp $a0
ret nz
ld a, $2
ld a, TRADEANIMSTATE_2
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@ -440,7 +451,7 @@ TradeAnim_TubeToPlayer3: ; 291e8
ld [hSCX], a
cp $b0
ret nz
ld a, $1
ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@ -454,7 +465,7 @@ TradeAnim_TubeToPlayer4: ; 291fd
ld [hSCX], a
cp $60
ret nz
xor a
xor a ; TRADEANIMSTATE_0
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
@ -541,7 +552,7 @@ TradeAnim_GetTrademonSFX: ; 29277
; 29281
TradeAnim_TubeAnimJumptable: ; 29281
and 3
maskbits TRADEANIMJUMPTABLE_LENGTH +- 1
ld e, a
ld d, 0
ld hl, .Jumptable
@ -554,6 +565,7 @@ TradeAnim_TubeAnimJumptable: ; 29281
; 2928f
.Jumptable: ; 2928f
; entries correspond to TRADEANIMSTATE_* constants
dw .Zero
dw .One
dw .Two

View File

@ -678,9 +678,9 @@ UpdateRoamMons: ; 2a30d
ld l, e
; Choose which map to warp to.
call Random
and $1f ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map.
and %00011111 ; 1/8n chance it moves to a completely random map, where n is the number of roaming connections from the current map.
jr z, JumpRoamMon
and 3
and %11
cp [hl]
jr nc, .update_loop ; invalid index, try again
inc hl
@ -740,9 +740,9 @@ JumpRoamMon: ; 2a3cd
.loop
ld hl, RoamMaps
.innerloop1 ; This loop is completely unnecessary.
call Random ; Choose a random number
and $f ; Take the lower nybble only. This gives a number between 0 and 15.
cp $10 ; If the number is greater than or equal to 16, loop back and try again.
call Random ; Choose a random number.
maskbits $10 - 1 ; Mask the number to limit it between 0 and 15.
cp $10 ; If the number is not less than 16, try again.
jr nc, .innerloop1 ; I'm sure you can guess why this check is bogus.
inc a
ld b, a
@ -825,7 +825,7 @@ RandomUnseenWildMon: ; 2a4ab
call AddNTimes
.randloop1
call Random
and $3
and %11
jr z, .randloop1
dec a
ld c, a
@ -902,7 +902,7 @@ RandomPhoneWildMon: ; 2a51f
.done
call Random
and $3
and %11
ld c, a
ld b, $0
add hl, bc

View File

@ -1371,7 +1371,7 @@ UpdateBGMapColumn:: ; 27f8
inc d
; cap d at HIGH(vBGMap0)
ld a, d
and $3
and %11
or HIGH(vBGMap0)
ld d, a