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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -70,14 +70,14 @@ Function6f07: ; 6f07
ld e, [hl] ld e, [hl]
ld hl, OBJECT_PALETTE ld hl, OBJECT_PALETTE
add hl, bc add hl, bc
bit 7, [hl] bit OAM_PRIORITY, [hl]
jp nz, Function6fa1 jp nz, Function6fa1
ld hl, OBJECT_NEXT_TILE ld hl, OBJECT_NEXT_TILE
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld d, a ld d, a
call GetTileCollision call GetTileCollision
and a ; land and a ; LANDTILE
jr z, Function6f3e jr z, Function6f3e
scf scf
ret ret
@ -106,7 +106,7 @@ Function6f3e: ; 6f3e
ld hl, OBJECT_DIRECTION_WALKING ld hl, OBJECT_DIRECTION_WALKING
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and 3 maskbits NUM_DIRECTIONS +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .data_6f5b ld hl, .data_6f5b
@ -131,7 +131,7 @@ Function6f5f: ; 6f5f
push af push af
ld hl, OBJECT_DIRECTION_WALKING ld hl, OBJECT_DIRECTION_WALKING
add hl, bc add hl, bc
and 3 maskbits NUM_DIRECTIONS +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .data_6f7b ld hl, .data_6f7b
@ -178,49 +178,49 @@ Function6fa1: ; 6fa1
ld hl, OBJECT_DIRECTION_WALKING ld hl, OBJECT_DIRECTION_WALKING
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
and 3 maskbits NUM_DIRECTIONS +- 1
jr z, .asm_6fb2 jr z, .down
dec a dec a
jr z, .asm_6fb7 jr z, .up
dec a dec a
jr z, .asm_6fbb jr z, .left
jr .asm_6fbf jr .right
.asm_6fb2 .down
inc e inc e
push de push de
inc d inc d
jr .asm_6fc2 jr .continue
.asm_6fb7 .up
push de push de
inc d inc d
jr .asm_6fc2 jr .continue
.asm_6fbb .left
push de push de
inc e inc e
jr .asm_6fc2 jr .continue
.asm_6fbf .right
inc d inc d
push de push de
inc e inc e
.asm_6fc2 .continue
call GetCoordTile call GetCoordTile
call GetTileCollision call GetTileCollision
pop de pop de
and a ; land and a ; LANDTILE
jr nz, .asm_6fd7 jr nz, .not_land
call GetCoordTile call GetCoordTile
call GetTileCollision call GetTileCollision
and a ; land and a ; LANDTILE
jr nz, .asm_6fd7 jr nz, .not_land
xor a xor a
ret ret
.asm_6fd7 .not_land
scf scf
ret ret
; 6fd9 ; 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 NPCTrade:: ; fcba8
ld a, e ld a, e
ld [wJumptableIndex], a ld [wJumptableIndex], a
@ -83,9 +75,9 @@ CheckTradeGender: ; fcc23
ld e, TRADE_GENDER ld e, TRADE_GENDER
call GetTradeAttribute call GetTradeAttribute
ld a, [hl] ld a, [hl]
and a and a ; TRADE_EITHER_GENDER
jr z, .matching jr z, .matching
cp 1 cp TRADE_MALE_ONLY
jr z, .check_male jr z, .check_male
farcall GetGender farcall GetGender
@ -178,10 +170,10 @@ DoNPCTrade: ; fcc63
ld e, TRADE_DIALOG ld e, TRADE_DIALOG
call GetTradeAttribute call GetTradeAttribute
ld a, [hl] ld a, [hl]
cp 3 cp TRADE_DIALOG_GIRL
ld a, 1 ld a, CAUGHT_BY_GIRL
jr c, .okay jr c, .okay
ld a, 2 ld a, CAUGHT_BY_BOY
.okay .okay
ld [wOTTrademonCaughtData], a ld [wOTTrademonCaughtData], a
@ -400,7 +392,7 @@ GetTradeMonNames: ; fce1b
and a and a
ret z ret z
cp 1 cp TRADE_MALE_ONLY
ld a, "♂" ld a, "♂"
jr z, .done jr z, .done
ld a, "♀" ld a, "♀"
@ -433,31 +425,28 @@ PrintTradeText: ; fcf38
; fcf53 ; fcf53
TradeTexts: ; fcf53 TradeTexts: ; fcf53
; intro ; entries correspond to TRADE_* × TRADE_DIALOG_* constants
; TRADE_INTRO
dw TradeIntroText1 dw TradeIntroText1
dw TradeIntroText2 dw TradeIntroText2
dw TradeIntroText3 dw TradeIntroText3
dw TradeIntroText4 dw TradeIntroText4
; TRADE_CANCEL
; cancel
dw TradeCancelText1 dw TradeCancelText1
dw TradeCancelText2 dw TradeCancelText2
dw TradeCancelText3 dw TradeCancelText3
dw TradeCancelText4 dw TradeCancelText4
; TRADE_WRONG
; wrong mon
dw TradeWrongText1 dw TradeWrongText1
dw TradeWrongText2 dw TradeWrongText2
dw TradeWrongText3 dw TradeWrongText3
dw TradeWrongText4 dw TradeWrongText4
; TRADE_COMPLETE
; completed
dw TradeCompleteText1 dw TradeCompleteText1
dw TradeCompleteText2 dw TradeCompleteText2
dw TradeCompleteText3 dw TradeCompleteText3
dw TradeCompleteText4 dw TradeCompleteText4
; TRADE_AFTER
; after
dw TradeAfterText1 dw TradeAfterText1
dw TradeAfterText2 dw TradeAfterText2
dw TradeAfterText3 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 Pack: ; 10000
ld hl, Options ld hl, Options
set NO_TEXT_SCROLL, [hl] set NO_TEXT_SCROLL, [hl]
@ -28,6 +42,7 @@ Pack: ; 10000
; 10030 ; 10030
.Jumptable: ; 10030 (4:4030) .Jumptable: ; 10030 (4:4030)
; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0 dw .InitGFX ; 0
dw .InitItemsPocket ; 1 dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2 dw .ItemsPocketMenu ; 2
@ -50,7 +65,7 @@ Pack: ; 10000
ret ret
.InitItemsPocket: ; 10056 (4:4056) .InitItemsPocket: ; 10056 (4:4056)
xor a xor a ; ITEM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -70,15 +85,15 @@ Pack: ; 10000
ld [wItemsPocketScrollPosition], a ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a ld [wItemsPocketCursor], a
ld b, $7 ld b, PACKSTATE_INITTMHMPOCKET ; left
ld c, $3 ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call .ItemBallsKey_LoadSubmenu call .ItemBallsKey_LoadSubmenu
ret ret
.InitKeyItemsPocket: ; 10094 (4:4094) .InitKeyItemsPocket: ; 10094 (4:4094)
ld a, $2 ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -98,15 +113,15 @@ Pack: ; 10000
ld [wKeyItemsPocketScrollPosition], a ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a ld [wKeyItemsPocketCursor], a
ld b, $3 ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, $7 ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call .ItemBallsKey_LoadSubmenu call .ItemBallsKey_LoadSubmenu
ret ret
.InitTMHMPocket: ; 100d3 (4:40d3) .InitTMHMPocket: ; 100d3 (4:40d3)
ld a, $3 ld a, TM_HM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -118,8 +133,8 @@ Pack: ; 10000
.TMHMPocketMenu: ; 100e8 (4:40e8) .TMHMPocketMenu: ; 100e8 (4:40e8)
farcall TMHMPocket farcall TMHMPocket
ld b, $5 ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
ld c, $1 ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
farcall _CheckTossableItem farcall _CheckTossableItem
@ -162,7 +177,6 @@ Pack: ; 10000
; 0x10137 ; 0x10137
.Jumptable1: ; 10137 .Jumptable1: ; 10137
dw .UseItem dw .UseItem
dw QuitItemSubmenu dw QuitItemSubmenu
@ -211,7 +225,7 @@ Pack: ; 10000
ret ret
.InitBallsPocket: ; 10186 (4:4186) .InitBallsPocket: ; 10186 (4:4186)
ld a, $1 ld a, BALL_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -231,8 +245,8 @@ Pack: ; 10000
ld [wBallsPocketScrollPosition], a ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a ld [wBallsPocketCursor], a
ld b, $1 ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, $5 ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call .ItemBallsKey_LoadSubmenu call .ItemBallsKey_LoadSubmenu
@ -327,7 +341,6 @@ MenuDataHeader_UsableKeyItem: ; 0x10249
; 0x1026a ; 0x1026a
Jumptable_UseGiveTossRegisterQuit: ; 1026a Jumptable_UseGiveTossRegisterQuit: ; 1026a
dw UseItem dw UseItem
dw GiveItem dw GiveItem
dw TossMenu dw TossMenu
@ -353,7 +366,6 @@ MenuDataHeader_UsableItem: ; 0x10274
; 0x10291 ; 0x10291
Jumptable_UseGiveTossQuit: ; 10291 Jumptable_UseGiveTossQuit: ; 10291
dw UseItem dw UseItem
dw GiveItem dw GiveItem
dw TossMenu dw TossMenu
@ -376,7 +388,6 @@ MenuDataHeader_UnusableItem: ; 0x10299
; 0x102ac ; 0x102ac
Jumptable_UseQuit: ; 102ac Jumptable_UseQuit: ; 102ac
dw UseItem dw UseItem
dw QuitItemSubmenu dw QuitItemSubmenu
; 102b0 ; 102b0
@ -398,7 +409,6 @@ MenuDataHeader_UnusableKeyItem: ; 0x102b0
; 0x102c7 ; 0x102c7
Jumptable_UseRegisterQuit: ; 102c7 Jumptable_UseRegisterQuit: ; 102c7
dw UseItem dw UseItem
dw RegisterItem dw RegisterItem
dw QuitItemSubmenu dw QuitItemSubmenu
@ -422,7 +432,6 @@ MenuDataHeader_HoldableKeyItem: ; 0x102cd
; 0x102ea ; 0x102ea
Jumptable_GiveTossRegisterQuit: ; 102ea Jumptable_GiveTossRegisterQuit: ; 102ea
dw GiveItem dw GiveItem
dw TossMenu dw TossMenu
dw RegisterItem dw RegisterItem
@ -446,7 +455,6 @@ MenuDataHeader_HoldableItem: ; 0x102f2
; 0x1030b ; 0x1030b
Jumptable_GiveTossQuit: ; 1030b Jumptable_GiveTossQuit: ; 1030b
dw GiveItem dw GiveItem
dw TossMenu dw TossMenu
dw QuitItemSubmenu dw QuitItemSubmenu
@ -462,14 +470,14 @@ UseItem: ; 10311
; 1031f ; 1031f
.dw ; 1031f (4:431f) .dw ; 1031f (4:431f)
; entries correspond to ITEMMENU_* constants
dw .Oak ; ITEMMENU_NOUSE
dw .Oak dw .Oak
dw .Oak dw .Oak
dw .Oak dw .Oak
dw .Oak dw .Current ; ITEMMENU_CURRENT
dw .Current dw .Party ; ITEMMENU_PARTY
dw .Party dw .Field ; ITEMMENU_CLOSE
dw .Field
; 1035c ; 1035c
.Oak: ; 1032d (4:432d) .Oak: ; 1032d (4:432d)
@ -503,7 +511,7 @@ UseItem: ; 10311
ld a, [wItemEffectSucceeded] ld a, [wItemEffectSucceeded]
and a and a
jr z, .Oak jr z, .Oak
ld a, $a ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
; 10364 (4:4364) ; 10364 (4:4364)
@ -537,11 +545,11 @@ TossMenu: ; 10364
ResetPocketCursorPositions: ; 1039d ResetPocketCursorPositions: ; 1039d
; unreferenced ; unreferenced
ld a, [wCurrPocket] ld a, [wCurrPocket]
and a and a ; ITEM_POCKET
jr z, .items jr z, .items
dec a dec a ; BALL_POCKET
jr z, .balls jr z, .balls
dec a dec a ; KEY_ITEM_POCKET
jr z, .key jr z, .key
ret ret
@ -693,6 +701,7 @@ BattlePack: ; 10493
; 104c3 ; 104c3
.Jumptable: ; 104c3 (4:44c3) .Jumptable: ; 104c3 (4:44c3)
; entries correspond to PACKSTATE_* constants
dw .InitGFX ; 0 dw .InitGFX ; 0
dw .InitItemsPocket ; 1 dw .InitItemsPocket ; 1
dw .ItemsPocketMenu ; 2 dw .ItemsPocketMenu ; 2
@ -715,7 +724,7 @@ BattlePack: ; 10493
ret ret
.InitItemsPocket: ; 104e9 (4:44e9) .InitItemsPocket: ; 104e9 (4:44e9)
xor a xor a ; ITEM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -735,15 +744,15 @@ BattlePack: ; 10493
ld [wItemsPocketScrollPosition], a ld [wItemsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wItemsPocketCursor], a ld [wItemsPocketCursor], a
ld b, $7 ld b, PACKSTATE_INITTMHMPOCKET ; left
ld c, $3 ld c, PACKSTATE_INITBALLSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call ItemSubmenu call ItemSubmenu
ret ret
.InitKeyItemsPocket: ; 10527 (4:4527) .InitKeyItemsPocket: ; 10527 (4:4527)
ld a, $2 ld a, KEY_ITEM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -763,15 +772,15 @@ BattlePack: ; 10493
ld [wKeyItemsPocketScrollPosition], a ld [wKeyItemsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wKeyItemsPocketCursor], a ld [wKeyItemsPocketCursor], a
ld b, $3 ld b, PACKSTATE_INITBALLSPOCKET ; left
ld c, $7 ld c, PACKSTATE_INITTMHMPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call ItemSubmenu call ItemSubmenu
ret ret
.InitTMHMPocket: ; 10566 (4:4566) .InitTMHMPocket: ; 10566 (4:4566)
ld a, $3 ld a, TM_HM_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -785,8 +794,8 @@ BattlePack: ; 10493
.TMHMPocketMenu: ; 10581 (4:4581) .TMHMPocketMenu: ; 10581 (4:4581)
farcall TMHMPocket farcall TMHMPocket
ld b, $5 ld b, PACKSTATE_INITKEYITEMSPOCKET ; left
ld c, $1 ld c, PACKSTATE_INITITEMSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
xor a xor a
@ -794,7 +803,7 @@ BattlePack: ; 10493
ret ret
.InitBallsPocket: ; 10594 (4:4594) .InitBallsPocket: ; 10594 (4:4594)
ld a, $1 ld a, BALL_POCKET
ld [wCurrPocket], a ld [wCurrPocket], a
call ClearPocketList call ClearPocketList
call DrawPocketName call DrawPocketName
@ -814,8 +823,8 @@ BattlePack: ; 10493
ld [wBallsPocketScrollPosition], a ld [wBallsPocketScrollPosition], a
ld a, [wMenuCursorY] ld a, [wMenuCursorY]
ld [wBallsPocketCursor], a ld [wBallsPocketCursor], a
ld b, $1 ld b, PACKSTATE_INITITEMSPOCKET ; left
ld c, $5 ld c, PACKSTATE_INITKEYITEMSPOCKET ; right
call Pack_InterpretJoypad call Pack_InterpretJoypad
ret c ret c
call ItemSubmenu call ItemSubmenu
@ -893,13 +902,14 @@ TMHMSubmenu: ; 105dc (4:45dc)
ret ret
.ItemFunctionJumptable: ; 10637 (4:4637) .ItemFunctionJumptable: ; 10637 (4:4637)
; entries correspond to ITEMMENU_* constants
dw .Oak ; ITEMMENU_NOUSE
dw .Oak dw .Oak
dw .Oak dw .Oak
dw .Oak dw .Oak
dw .Oak dw .Unused ; ITEMMENU_CURRENT
dw .Unused dw .BattleField ; ITEMMENU_PARTY
dw .BattleField dw .BattleOnly ; ITEMMENU_CLOSE
dw .BattleOnly
.Oak: ; 10645 (4:4645) .Oak: ; 10645 (4:4645)
ld hl, Text_ThisIsntTheTime ld hl, Text_ThisIsntTheTime
@ -937,7 +947,7 @@ TMHMSubmenu: ; 105dc (4:45dc)
cp $2 cp $2
jr z, .didnt_use_item jr z, .didnt_use_item
.quit_run_script ; 1067e (4:467e) .quit_run_script ; 1067e (4:467e)
ld a, 10 ld a, PACKSTATE_QUITRUNSCRIPT
ld [wJumptableIndex], a ld [wJumptableIndex], a
ret ret
@ -954,7 +964,7 @@ InitPackBuffers: ; 1068a
xor a xor a
ld [wJumptableIndex], a ld [wJumptableIndex], a
ld a, [wLastPocket] ld a, [wLastPocket]
and $3 maskbits NUM_POCKETS +- 1
ld [wCurrPocket], a ld [wCurrPocket], a
inc a inc a
add a add a
@ -997,13 +1007,14 @@ DepositSellPack: ; 106be
; 106d1 ; 106d1
.Jumptable: ; 106d1 (4:46d1) .Jumptable: ; 106d1 (4:46d1)
; entries correspond to *_POCKET constants
dw .ItemsPocket dw .ItemsPocket
dw .BallsPocket dw .BallsPocket
dw .KeyItemsPocket dw .KeyItemsPocket
dw .TMHMPocket dw .TMHMPocket
.ItemsPocket: ; 106d9 (4:46d9) .ItemsPocket: ; 106d9 (4:46d9)
xor a xor a ; ITEM_POCKET
call InitPocket call InitPocket
ld hl, PC_Mart_ItemsPocketMenuDataHeader ld hl, PC_Mart_ItemsPocketMenuDataHeader
call CopyMenuDataHeader call CopyMenuDataHeader
@ -1019,7 +1030,7 @@ DepositSellPack: ; 106be
ret ret
.KeyItemsPocket: ; 106ff (4:46ff) .KeyItemsPocket: ; 106ff (4:46ff)
ld a, 2 ld a, KEY_ITEM_POCKET
call InitPocket call InitPocket
ld hl, PC_Mart_KeyItemsPocketMenuDataHeader ld hl, PC_Mart_KeyItemsPocketMenuDataHeader
call CopyMenuDataHeader call CopyMenuDataHeader
@ -1035,7 +1046,7 @@ DepositSellPack: ; 106be
ret ret
.TMHMPocket: ; 10726 (4:4726) .TMHMPocket: ; 10726 (4:4726)
ld a, 3 ld a, TM_HM_POCKET
call InitPocket call InitPocket
call WaitBGMap_DrawPackGFX call WaitBGMap_DrawPackGFX
farcall TMHMPocket farcall TMHMPocket
@ -1044,7 +1055,7 @@ DepositSellPack: ; 106be
ret ret
.BallsPocket: ; 1073b (4:473b) .BallsPocket: ; 1073b (4:473b)
ld a, 1 ld a, BALL_POCKET
call InitPocket call InitPocket
ld hl, PC_Mart_BallsPocketMenuDataHeader ld hl, PC_Mart_BallsPocketMenuDataHeader
call CopyMenuDataHeader call CopyMenuDataHeader
@ -1098,7 +1109,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_left .d_left
ld a, [wJumptableIndex] ld a, [wJumptableIndex]
dec a dec a
and $3 maskbits NUM_POCKETS +- 1
ld [wJumptableIndex], a ld [wJumptableIndex], a
push de push de
ld de, SFX_SWITCH_POCKETS ld de, SFX_SWITCH_POCKETS
@ -1110,7 +1121,7 @@ DepositSellTutorial_InterpretJoypad: ; 1076f
.d_right .d_right
ld a, [wJumptableIndex] ld a, [wJumptableIndex]
inc a inc a
and $3 maskbits NUM_POCKETS +- 1
ld [wJumptableIndex], a ld [wJumptableIndex], a
push de push de
ld de, SFX_SWITCH_POCKETS ld de, SFX_SWITCH_POCKETS
@ -1144,14 +1155,14 @@ TutorialPack: ; 107bb
; 107e1 ; 107e1
.dw ; 107e1 (4:47e1) .dw ; 107e1 (4:47e1)
; entries correspond to *_POCKET constants
dw .Items dw .Items
dw .Balls dw .Balls
dw .KeyItems dw .KeyItems
dw .TMHM dw .TMHM
.Items: ; 107e9 (4:47e9) .Items: ; 107e9 (4:47e9)
xor a xor a ; ITEM_POCKET
ld hl, .ItemsMenuDataHeader ld hl, .ItemsMenuDataHeader
jr .DisplayPocket jr .DisplayPocket
@ -1175,7 +1186,7 @@ TutorialPack: ; 107bb
; 10807 ; 10807
.KeyItems: ; 10807 (4:4807) .KeyItems: ; 10807 (4:4807)
ld a, 2 ld a, KEY_ITEM_POCKET
ld hl, .KeyItemsMenuDataHeader ld hl, .KeyItemsMenuDataHeader
jr .DisplayPocket jr .DisplayPocket
@ -1199,7 +1210,7 @@ TutorialPack: ; 107bb
; 10826 ; 10826
.TMHM: ; 10826 (4:4826) .TMHM: ; 10826 (4:4826)
ld a, 3 ld a, TM_HM_POCKET
call InitPocket call InitPocket
call WaitBGMap_DrawPackGFX call WaitBGMap_DrawPackGFX
farcall TMHMPocket farcall TMHMPocket
@ -1208,7 +1219,7 @@ TutorialPack: ; 107bb
ret ret
.Balls: ; 1083b (4:483b) .Balls: ; 1083b (4:483b)
ld a, 1 ld a, BALL_POCKET
ld hl, .BallsMenuDataHeader ld hl, .BallsMenuDataHeader
jr .DisplayPocket jr .DisplayPocket
@ -1283,7 +1294,7 @@ WaitBGMap_DrawPackGFX: ; 1089a (4:489a)
call WaitBGMap call WaitBGMap
DrawPackGFX: ; 1089d DrawPackGFX: ; 1089d
ld a, [wCurrPocket] ld a, [wCurrPocket]
and $3 maskbits NUM_POCKETS +- 1
ld e, a ld e, a
ld d, $0 ld d, $0
ld a, [BattleType] ld a, [BattleType]
@ -1310,10 +1321,10 @@ DrawPackGFX: ; 1089d
; 108cc ; 108cc
PackGFXPointers: ; 108cc PackGFXPointers: ; 108cc
dw PackGFX + (15 tiles) * 1 dw PackGFX + (15 tiles) * 1 ; ITEM_POCKET
dw PackGFX + (15 tiles) * 3 dw PackGFX + (15 tiles) * 3 ; BALL_POCKET
dw PackGFX + (15 tiles) * 0 dw PackGFX + (15 tiles) * 0 ; KEY_ITEM_POCKET
dw PackGFX + (15 tiles) * 2 dw PackGFX + (15 tiles) * 2 ; TM_HM_POCKET
; 108d4 ; 108d4
Pack_InterpretJoypad: ; 108d4 (4:48d4) Pack_InterpretJoypad: ; 108d4 (4:48d4)
@ -1344,7 +1355,7 @@ Pack_InterpretJoypad: ; 108d4 (4:48d4)
ret ret
.b_button .b_button
ld a, 9 ld a, PACKSTATE_QUITNOSCRIPT
ld [wJumptableIndex], a ld [wJumptableIndex], a
scf scf
ret ret
@ -1489,15 +1500,19 @@ DrawPocketName: ; 109bb
; 109e1 ; 109e1
.tilemap ; 109e1 .tilemap ; 109e1
; ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border db $00, $04, $04, $04, $01 ; top border
db $06, $07, $08, $09, $0a ; Items db $06, $07, $08, $09, $0a ; Items
db $02, $05, $05, $05, $03 ; bottom border db $02, $05, $05, $05, $03 ; bottom border
; BALL_POCKET
db $00, $04, $04, $04, $01 ; top border db $00, $04, $04, $04, $01 ; top border
db $15, $16, $17, $18, $19 ; Balls db $15, $16, $17, $18, $19 ; Balls
db $02, $05, $05, $05, $03 ; bottom border db $02, $05, $05, $05, $03 ; bottom border
; KEY_ITEM_POCKET
db $00, $04, $04, $04, $01 ; top border db $00, $04, $04, $04, $01 ; top border
db $0b, $0c, $0d, $0e, $0f ; Key Items db $0b, $0c, $0d, $0e, $0f ; Key Items
db $02, $05, $05, $05, $03 ; bottom border db $02, $05, $05, $05, $03 ; bottom border
; TM_HM_POCKET
db $00, $04, $04, $04, $01 ; top border db $00, $04, $04, $04, $01 ; top border
db $10, $11, $12, $13, $14 ; TM/HM db $10, $11, $12, $13, $14 ; TM/HM
db $02, $05, $05, $05, $03 ; bottom border db $02, $05, $05, $05, $03 ; bottom border

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,16 +133,16 @@ endr
Special_SampleKenjiBreakCountdown: ; 11485 Special_SampleKenjiBreakCountdown: ; 11485
; Generate a random number between 3 and 6 ; Generate a random number between 3 and 6
call Random call Random
and 3 and %11
add 3 add 3
ld [wKenjiBreakTimer], a ld [wKenjiBreakTimer], a
ret ret
; 11490 ; 11490
StartBugContestTimer: ; 11490 StartBugContestTimer: ; 11490
ld a, 20 ld a, BUG_CONTEST_MINUTES
ld [wBugContestMinsRemaining], a ld [wBugContestMinsRemaining], a
ld a, 0 ld a, BUG_CONTEST_SECONDS
ld [wBugContestSecsRemaining], a ld [wBugContestSecsRemaining], a
call UpdateTime call UpdateTime
ld hl, wBugContestStartTime ld hl, wBugContestStartTime
@ -252,7 +252,7 @@ RestartLuckyNumberCountdown: ; 1152b
ld a, FRIDAY ld a, FRIDAY
sub c sub c
jr z, .friday_saturday jr z, .friday_saturday
jr nc, .earlier ; should've done "ret nc" jr nc, .earlier ; could have done "ret nc"
.friday_saturday .friday_saturday
add 7 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 TradeAnimation: ; 28f24
xor a xor a
ld [wcf66], a ld [wcf66], a
@ -165,13 +176,13 @@ RunTradeAnimScript: ; 28fa1
ld de, vTiles2 tile $31 ld de, vTiles2 tile $31
call Decompress call Decompress
ld hl, TradeArrowGFX ld hl, TradeArrowGFX
ld de, vTiles1 tile $6d ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW
ld bc, $10 ld bc, 1 tiles
ld a, BANK(TradeArrowGFX) ld a, BANK(TradeArrowGFX)
call FarCopyBytes call FarCopyBytes
ld hl, TradeArrowGFX + $10 ld hl, TradeArrowGFX + 1 tiles
ld de, vTiles1 tile $6e ld de, vTiles0 tile TRADEANIM_LEFT_ARROW
ld bc, $10 ld bc, 1 tiles
ld a, BANK(TradeArrowGFX) ld a, BANK(TradeArrowGFX)
call FarCopyBytes call FarCopyBytes
xor a xor a
@ -317,7 +328,7 @@ TradeAnim_End: ; 29123
; 29129 ; 29129
TradeAnim_TubeToOT1: ; 29129 TradeAnim_TubeToOT1: ; 29129
ld a, $ed ; >>>>>>>> ld a, TRADEANIM_RIGHT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeSendmonSpecies] ld a, [wLinkTradeSendmonSpecies]
ld [wd265], a ld [wd265], a
@ -327,11 +338,11 @@ TradeAnim_TubeToOT1: ; 29129
jr TradeAnim_InitTubeAnim jr TradeAnim_InitTubeAnim
TradeAnim_TubeToPlayer1: ; 2913c TradeAnim_TubeToPlayer1: ; 2913c
ld a, $ee ; <<<<<<<< ld a, TRADEANIM_LEFT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeGetmonSpecies] ld a, [wLinkTradeGetmonSpecies]
ld [wd265], a ld [wd265], a
ld a, $2 ld a, TRADEANIMSTATE_2
depixel 9, 18, 4, 4 depixel 9, 18, 4, 4
ld b, $4 ld b, $4
TradeAnim_InitTubeAnim: ; 2914e TradeAnim_InitTubeAnim: ; 2914e
@ -400,7 +411,7 @@ TradeAnim_TubeToOT2: ; 291af
ld [hSCX], a ld [hSCX], a
cp $50 cp $50
ret nz ret nz
ld a, $1 ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex call TradeAnim_IncrementJumptableIndex
ret ret
@ -414,7 +425,7 @@ TradeAnim_TubeToOT3: ; 291c4
ld [hSCX], a ld [hSCX], a
cp $a0 cp $a0
ret nz ret nz
ld a, $2 ld a, TRADEANIMSTATE_2
call TradeAnim_TubeAnimJumptable call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex call TradeAnim_IncrementJumptableIndex
ret ret
@ -440,7 +451,7 @@ TradeAnim_TubeToPlayer3: ; 291e8
ld [hSCX], a ld [hSCX], a
cp $b0 cp $b0
ret nz ret nz
ld a, $1 ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex call TradeAnim_IncrementJumptableIndex
ret ret
@ -454,7 +465,7 @@ TradeAnim_TubeToPlayer4: ; 291fd
ld [hSCX], a ld [hSCX], a
cp $60 cp $60
ret nz ret nz
xor a xor a ; TRADEANIMSTATE_0
call TradeAnim_TubeAnimJumptable call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex call TradeAnim_IncrementJumptableIndex
ret ret
@ -541,7 +552,7 @@ TradeAnim_GetTrademonSFX: ; 29277
; 29281 ; 29281
TradeAnim_TubeAnimJumptable: ; 29281 TradeAnim_TubeAnimJumptable: ; 29281
and 3 maskbits TRADEANIMJUMPTABLE_LENGTH +- 1
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .Jumptable ld hl, .Jumptable
@ -554,6 +565,7 @@ TradeAnim_TubeAnimJumptable: ; 29281
; 2928f ; 2928f
.Jumptable: ; 2928f .Jumptable: ; 2928f
; entries correspond to TRADEANIMSTATE_* constants
dw .Zero dw .Zero
dw .One dw .One
dw .Two dw .Two

View File

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

View File

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