This commit is contained in:
PikalaxALT 2015-12-13 14:15:16 -05:00
parent ecd277204a
commit acd92eee94
20 changed files with 1956 additions and 2168 deletions

View File

@ -206,8 +206,8 @@ Sfx_Unknown61: ; f0a1f
musicheader 1, 8, Sfx_Unknown61_Ch8
; f0a22
Sfx_Unknown62: ; f0a22
musicheader 1, 8, Sfx_Unknown62_Ch8
Sfx_SwitchPockets: ; f0a22
musicheader 1, 8, Sfx_SwitchPockets_Ch8
; f0a25
Sfx_Unknown63: ; f0a25
@ -5226,7 +5226,7 @@ Sfx_Unknown61_Ch8: ; f2588
endchannel
; f258c
Sfx_Unknown62_Ch8: ; f258c
Sfx_SwitchPockets_Ch8: ; f258c
noise __, 5, $c1, $42
endchannel
; f2590

View File

@ -97,7 +97,7 @@
dba Sfx_Unknown5F
dba Sfx_Unknown60
dba Sfx_Unknown61
dba Sfx_Unknown62
dba Sfx_SwitchPockets
dba Sfx_Unknown63
dba Sfx_Burn
dba Sfx_TitleScreenEntrance

198
battle/ai/redundant.asm Executable file
View File

@ -0,0 +1,198 @@
AI_Redundant: ; 2c41a
; Check if move effect c will fail because it's already been used.
; Return z if the move is a good choice.
; Return nz if the move is a bad choice.
ld a, c
ld de, 3
ld hl, .Moves
call IsInArray
jp nc, .NotRedundant
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
.Moves: ; 2c42c
dbw EFFECT_DREAM_EATER, .DreamEater
dbw EFFECT_HEAL, .Heal
dbw EFFECT_LIGHT_SCREEN, .LightScreen
dbw EFFECT_MIST, .Mist
dbw EFFECT_FOCUS_ENERGY, .FocusEnergy
dbw EFFECT_CONFUSE, .Confuse
dbw EFFECT_TRANSFORM, .Transform
dbw EFFECT_REFLECT, .Reflect
dbw EFFECT_SUBSTITUTE, .Substitute
dbw EFFECT_LEECH_SEED, .LeechSeed
dbw EFFECT_DISABLE, .Disable
dbw EFFECT_ENCORE, .Encore
dbw EFFECT_SNORE, .Snore
dbw EFFECT_SLEEP_TALK, .SleepTalk
dbw EFFECT_MEAN_LOOK, .MeanLook
dbw EFFECT_NIGHTMARE, .Nightmare
dbw EFFECT_SPIKES, .Spikes
dbw EFFECT_FORESIGHT, .Foresight
dbw EFFECT_PERISH_SONG, .PerishSong
dbw EFFECT_SANDSTORM, .Sandstorm
dbw EFFECT_ATTRACT, .Attract
dbw EFFECT_SAFEGUARD, .Safeguard
dbw EFFECT_RAIN_DANCE, .RainDance
dbw EFFECT_SUNNY_DAY, .SunnyDay
dbw EFFECT_TELEPORT, .Teleport
dbw EFFECT_MORNING_SUN, .MorningSun
dbw EFFECT_SYNTHESIS, .Synthesis
dbw EFFECT_MOONLIGHT, .Moonlight
dbw EFFECT_SWAGGER, .Swagger
dbw EFFECT_FUTURE_SIGHT, .FutureSight
db -1
.LightScreen: ; 2c487
ld a, [EnemyScreens]
bit SCREENS_LIGHT_SCREEN, a
ret
.Mist: ; 2c48d
ld a, [EnemySubStatus4]
bit SUBSTATUS_MIST, a
ret
.FocusEnergy: ; 2c493
ld a, [EnemySubStatus4]
bit SUBSTATUS_FOCUS_ENERGY, a
ret
.Confuse: ; 2c499
ld a, [PlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret nz
ld a, [PlayerScreens]
bit SCREENS_SAFEGUARD, a
ret
.Transform: ; 2c4a5
ld a, [EnemySubStatus5]
bit SUBSTATUS_TRANSFORMED, a
ret
.Reflect: ; 2c4ab
ld a, [EnemyScreens]
bit SCREENS_REFLECT, a
ret
.Substitute: ; 2c4b1
ld a, [EnemySubStatus4]
bit SUBSTATUS_SUBSTITUTE, a
ret
.LeechSeed: ; 2c4b7
ld a, [PlayerSubStatus4]
bit SUBSTATUS_LEECH_SEED, a
ret
.Disable: ; 2c4bd
ld a, [PlayerDisableCount]
and a
ret
.Encore: ; 2c4c2
ld a, [PlayerSubStatus5]
bit SUBSTATUS_ENCORED, a
ret
.Snore:
.SleepTalk: ; 2c4c8
ld a, [EnemyMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
.MeanLook: ; 2c4d1
ld a, [EnemySubStatus5]
bit SUBSTATUS_CANT_RUN, a
ret
.Nightmare: ; 2c4d7
ld a, [BattleMonStatus]
and a
jr z, .Redundant
ld a, [PlayerSubStatus1]
bit SUBSTATUS_NIGHTMARE, a
ret
.Spikes: ; 2c4e3
ld a, [PlayerScreens]
bit SCREENS_SPIKES, a
ret
.Foresight: ; 2c4e9
ld a, [PlayerSubStatus1]
bit SUBSTATUS_IDENTIFIED, a
ret
.PerishSong: ; 2c4ef
ld a, [PlayerSubStatus1]
bit SUBSTATUS_PERISH, a
ret
.Sandstorm: ; 2c4f5
ld a, [Weather]
cp WEATHER_SANDSTORM
jr z, .Redundant
jr .NotRedundant
.Attract: ; 2c4fe
callba CheckOppositeGender
jr c, .Redundant
ld a, [PlayerSubStatus1]
bit SUBSTATUS_IN_LOVE, a
ret
.Safeguard: ; 2c50c
ld a, [EnemyScreens]
bit SCREENS_SAFEGUARD, a
ret
.RainDance: ; 2c512
ld a, [Weather]
cp WEATHER_RAIN
jr z, .Redundant
jr .NotRedundant
.SunnyDay: ; 2c51b
ld a, [Weather]
cp WEATHER_SUN
jr z, .Redundant
jr .NotRedundant
.DreamEater: ; 2c524
ld a, [BattleMonStatus]
and SLP
jr z, .Redundant
jr .NotRedundant
.Swagger: ; 2c52d
ld a, [PlayerSubStatus3]
bit SUBSTATUS_CONFUSED, a
ret
.FutureSight: ; 2c533
ld a, [EnemyScreens]
bit 5, a
ret
.Heal:
.MorningSun:
.Synthesis:
.Moonlight: ; 2c539
callba AICheckEnemyMaxHP
jr nc, .NotRedundant
.Teleport:
.Redundant: ; 2c541
ld a, 1
and a
ret
.NotRedundant: ; 2c545
xor a
ret

View File

@ -2412,7 +2412,7 @@ Function3cf4a: ; 3cf4a
ld e, HP_BAR_LENGTH_PX
call UpdateHPPal
call WaitBGMap
callba Function2c012
callba EnemySwitch_TrainerHud
ld a, [wLinkMode]
and a
jr z, .not_linked
@ -4853,7 +4853,7 @@ DrawPlayerHUD: ; 3df58
lb bc, 5, 11
call ClearBox
callba DrawPlayerExpBar
callba DrawPlayerHUDBorder
hlcoord 18, 9
ld [hl], $73 ; vertical bar
@ -4995,7 +4995,7 @@ DrawEnemyHUD: ; 3e043
lb bc, 4, 11
call ClearBox
callba Function2c0c5
callba DrawEnemyHUDBorder
ld a, [TempEnemyMonSpecies]
ld [CurSpecies], a
@ -9610,7 +9610,7 @@ BattleStartMessage: ; 3fc8b
ld d, $0
ld e, ANIM_MON_NORMAL
predef AnimateFrontpic
jr .skip_cry
jr .skip_cry ; cry is played during the animation
.cry_no_anim
ld a, $0f
@ -9623,7 +9623,7 @@ BattleStartMessage: ; 3fc8b
cp BATTLETYPE_FISH
jr nz, .NotFishing
callba MobileFn_106086
callba MobileFn_106086 ; update fishing records?
ld hl, HookedPokemonAttackedText
jr .PlaceBattleStartText
@ -9639,7 +9639,7 @@ BattleStartMessage: ; 3fc8b
.PlaceBattleStartText
push hl
callba Function2c000
callba BattleStart_TrainerHuds
pop hl
call StdBattleTextBox

View File

@ -62,7 +62,7 @@ endr
; 4e9d6
.subfunction3: ; 4e9d6
ld hl, Sprites + 1
ld hl, Sprites + 1 ; x pixel
ld c, $12 ; 18
ld de, $4
.loop3

275
battle/trainer_huds.asm Executable file
View File

@ -0,0 +1,275 @@
wPlaceBallsDirection EQU $d003
wTrainerHUDTiles EQU $d004
wPlaceBallsX EQU $cfc4
wPlaceBallsY EQU $cfc5
GLOBAL wPlaceBallsDirection, wTrainerHUDTiles, wPlaceBallsX, wPlaceBallsY
BattleStart_TrainerHuds: ; 2c000
ld a, $e4
ld [rOBP0], a
call LoadBallIconGFX
call ShowPlayerMonsRemaining
ld a, [wBattleMode]
dec a
ret z
jp ShowOTTrainerMonsRemaining
; 2c012
EnemySwitch_TrainerHud: ; 2c012
ld a, $e4
ld [rOBP0], a
call LoadBallIconGFX
jp ShowOTTrainerMonsRemaining
; 2c01c
ShowPlayerMonsRemaining: ; 2c01c
call DrawPlayerPartyIconHUDBorder
ld hl, PartyMon1HP
ld de, PartyCount
call StageBallTilesData
; ldpixel wPlaceBallsX, 12, 12
ld a, 12 * 8
ld hl, wPlaceBallsX
ld [hli], a
ld [hl], a
ld a, 8
ld [wPlaceBallsDirection], a
ld hl, Sprites
jp LoadTrainerHudOAM
; 2c03a
ShowOTTrainerMonsRemaining: ; 2c03a
call DrawEnemyHUDBorder
ld hl, OTPartyMon1HP
ld de, OTPartyCount
call StageBallTilesData
; ldpixel wPlaceBallsX, 9, 4
ld hl, wPlaceBallsX
ld a, 9 * 8
ld [hli], a
ld [hl], 4 * 8
ld a, -8
ld [wPlaceBallsDirection], a
ld hl, Sprites + PARTY_LENGTH * 4
jp LoadTrainerHudOAM
; 2c059
StageBallTilesData: ; 2c059
ld a, [de]
push af
ld de, Buffer1
ld c, PARTY_LENGTH
ld a, $34 ; empty slot
.loop1
ld [de], a
inc de
dec c
jr nz, .loop1
pop af
ld de, Buffer1
.loop2
push af
call .GetHUDTile
inc de
pop af
dec a
jr nz, .loop2
ret
; 2c075
.GetHUDTile: ; 2c075
ld a, [hli]
and a
jr nz, .got_hp
ld a, [hl]
and a
ld b, $33 ; fainted
jr z, .fainted
.got_hp
rept 3
dec hl
endr
ld a, [hl]
and a
ld b, $32 ; statused
jr nz, .load
dec b ; normal
jr .load
.fainted
rept 3
dec hl
endr
.load
ld a, b
ld [de], a
ld bc, PARTYMON_STRUCT_LENGTH + MON_HP - MON_STATUS
add hl, bc
ret
; 2c095
DrawPlayerHUDBorder: ; 2c095
ld hl, .tiles
ld de, wTrainerHUDTiles
ld bc, 4
call CopyBytes
hlcoord 18, 10
ld de, -1 ; start on right
jr PlaceHUDBorderTiles
.tiles
db $73 ; right side
db $77 ; bottom right
db $6f ; bottom left
db $76 ; bottom side
; 2c0ad
DrawPlayerPartyIconHUDBorder: ; 2c0ad
ld hl, .tiles
ld de, wTrainerHUDTiles
ld bc, 4
call CopyBytes
hlcoord 18, 10
ld de, -1 ; start on right
jr PlaceHUDBorderTiles
.tiles
db $73 ; right side
db $5c ; bottom right
db $6f ; bottom left
db $76 ; bottom side
; 2c0c5
DrawEnemyHUDBorder: ; 2c0c5
ld hl, .tiles
ld de, wTrainerHUDTiles
ld bc, 4
call CopyBytes
hlcoord 1, 2
ld de, 1 ; start on left
call PlaceHUDBorderTiles
ld a, [wBattleMode]
dec a
ret nz
ld a, [TempEnemyMonSpecies]
dec a
call CheckCaughtMon
ret z
hlcoord 1, 1
ld [hl], $5d
ret
.tiles
db $6d ; left side
db $74 ; bottom left
db $78 ; bottom right
db $76 ; bottom side
; 2c0f1
PlaceHUDBorderTiles: ; 2c0f1
ld a, [wTrainerHUDTiles]
ld [hl], a
ld bc, SCREEN_WIDTH
add hl, bc
ld a, [StartFlypoint]
ld [hl], a
ld b, $8
.loop
add hl, de
ld a, [MovementBuffer]
ld [hl], a
dec b
jr nz, .loop
add hl, de
ld a, [EndFlypoint]
ld [hl], a
ret
; 2c10d
LinkBattle_TrainerHuds: ; 2c10d
call LoadBallIconGFX
ld hl, PartyMon1HP
ld de, PartyCount
call StageBallTilesData
ld hl, wPlaceBallsX
ld a, 10 * 8
ld [hli], a
ld [hl], 8 * 8
ld a, $8
ld [wPlaceBallsDirection], a
ld hl, Sprites
call LoadTrainerHudOAM
ld hl, OTPartyMon1HP
ld de, OTPartyCount
call StageBallTilesData
ld hl, wPlaceBallsX
ld a, 10 * 8
ld [hli], a
ld [hl], 13 * 8
ld hl, Sprites + PARTY_LENGTH * 4
jp LoadTrainerHudOAM
; 2c143
LoadTrainerHudOAM: ; 2c143
ld de, Buffer1
ld c, PARTY_LENGTH
.loop
ld a, [wPlaceBallsY]
ld [hli], a
ld a, [wPlaceBallsX]
ld [hli], a
ld a, [de]
ld [hli], a
ld a, $3
ld [hli], a
ld a, [wPlaceBallsX]
ld b, a
ld a, [wPlaceBallsDirection]
add b
ld [wPlaceBallsX], a
inc de
dec c
jr nz, .loop
ret
; 2c165
LoadBallIconGFX: ; 2c165
ld de, .gfx
ld hl, VTiles0 tile $31
lb bc, BANK(LoadBallIconGFX), 4
call Get2bpp_2
ret
; 2c172
.gfx: ; 2c172
INCBIN "gfx/battle/balls.2bpp"
; 2c1b2
_ShowLinkBattleParticipants: ; 2c1b2
call ClearBGPalettes
call LoadFontsExtra
hlcoord 2, 3
ld b, 9
ld c, 14
call TextBox
hlcoord 4, 5
ld de, PlayerName
call PlaceString
hlcoord 4, 10
ld de, OTPlayerName
call PlaceString
hlcoord 9, 8
ld a, $69 ; "V"
ld [hli], a
ld [hl], $6a ; "S"
callba LinkBattle_TrainerHuds ; no need to callba
ld b, SCGB_08
call GetSGBLayout
call SetPalettes
ld a, $e4
ld [rOBP0], a
ret
; 2c1ef

View File

@ -98,7 +98,7 @@
const SFX_UNKNOWN_5F
const SFX_UNKNOWN_60
const SFX_UNKNOWN_61
const SFX_UNKNOWN_62
const SFX_SWITCH_POCKETS
const SFX_UNKNOWN_63
const SFX_BURN
const SFX_TITLE_SCREEN_ENTRANCE

View File

@ -41,7 +41,7 @@ MenuData2_0x49d1c: ; 49d1c
db $80 ; flags
db 0 ; items
dw MainMenuItems
dw Function1f79
dw PlaceMenuStrings
dw MainMenuText
; 49d20

View File

@ -809,9 +809,9 @@ UnknownText_0x15eae: ; 0x15eae
SellMenu: ; 15eb3
call DisableSpriteUpdates
callba Function106a5
callba DepositSellInitPackBuffers
.asm_15ebc
callba Function106be
callba DepositSellPack
ld a, [wcf66]
and a
jp z, Function15ece

File diff suppressed because it is too large Load Diff

View File

@ -431,9 +431,9 @@ KrisDepositItemMenu: ; 0x1588b
jr c, .asm_158b6
call DisableSpriteUpdates
call LoadStandardMenuDataHeader
callba Function106a5
callba DepositSellInitPackBuffers
.asm_1589c
callba Function106be
callba DepositSellPack
ld a, [wcf66]
and a
jr z, .asm_158b3
@ -629,7 +629,7 @@ Function15985: ; 0x15985
call Function156c7
.asm_159f2
callba Function2490c
callba SwitchItemsInBag
.asm_159f8
jp .asm_15989

View File

@ -795,49 +795,49 @@ GiveTakePartyMonItem: ; 12b60
; Eggs can't hold items!
ld a, [CurPartySpecies]
cp EGG
jr z, .asm_12ba6
jr z, .cancel
ld hl, GiveTakeItemMenuData
call LoadMenuDataHeader
call InterpretMenu2
call ExitMenu
jr c, .asm_12ba6
jr c, .cancel
call GetCurNick
ld hl, StringBuffer1
ld de, wd050
ld bc, $b
ld de, wd050_MonNick
ld bc, PKMN_NAME_LENGTH
call CopyBytes
ld a, [MenuSelection2]
cp 1
jr nz, .asm_12ba0
jr nz, .take
call LoadStandardMenuDataHeader
call ClearPalettes
call Function12ba9
call .GiveItem
call ClearPalettes
call LoadFontsBattleExtra
call ExitMenu
ld a, 0
ret
.asm_12ba0
.take
call TakePartyItem
ld a, 3
ret
.asm_12ba6
.cancel
ld a, 3
ret
; 12ba9
Function12ba9: ; 12ba9
.GiveItem: ; 12ba9
callba Function106a5
callba DepositSellInitPackBuffers
.loop
callba Function106be
callba DepositSellPack
ld a, [wcf66]
and a
@ -852,7 +852,7 @@ Function12ba9: ; 12ba9
and a
jr nz, .next
call Function12bd9
call TryGiveItemToPartymon
jr .quit
.next
@ -865,41 +865,41 @@ Function12ba9: ; 12ba9
; 12bd9
Function12bd9: ; 12bd9
TryGiveItemToPartymon: ; 12bd9
call SpeechTextBox
call PartyMonItemName
call GetPartyItemLocation
ld a, [hl]
and a
jr z, .asm_12bf4
jr z, .give_item_to_mon
push hl
ld d, a
callba ItemIsMail
pop hl
jr c, .asm_12c01
jr c, .please_remove_mail
ld a, [hl]
jr .asm_12c08
jr .already_holding_item
.asm_12bf4
.give_item_to_mon
call GiveItemToPokemon
ld hl, MadeHoldText
call MenuTextBoxBackup
call GivePartyItem
ret
.asm_12c01
.please_remove_mail
ld hl, PleaseRemoveMailText
call MenuTextBoxBackup
ret
.asm_12c08
.already_holding_item
ld [wd265], a
call GetItemName
ld hl, SwitchAlreadyHoldingText
call StartMenuYesNo
jr c, .asm_12c4b
jr c, .abort
call GiveItemToPokemon
ld a, [wd265]
@ -909,7 +909,7 @@ Function12bd9: ; 12bd9
pop af
ld [CurItem], a
call ReceiveItemFromPokemon
jr nc, .asm_12c3c
jr nc, .bag_full
ld hl, TookAndMadeHoldText
call MenuTextBoxBackup
@ -918,14 +918,14 @@ Function12bd9: ; 12bd9
call GivePartyItem
ret
.asm_12c3c
.bag_full
ld a, [wd265]
ld [CurItem], a
call ReceiveItemFromPokemon
ld hl, ItemStorageIsFullText
call MenuTextBoxBackup
.asm_12c4b
.abort
ret
; 12c4c

274
engine/switch_items.asm Executable file
View File

@ -0,0 +1,274 @@
SwitchItemsInBag: ; 2490c (9:490c)
ld a, [wSwitchItem]
and a
jr z, .init
ld b, a
ld a, [wCurrPocketCursorPosition]
inc a
cp b
jr z, .trivial
ld a, [wCurrPocketCursorPosition]
call Function24a5c
ld a, [hl]
cp $ff
ret z
ld a, [wSwitchItem]
dec a
ld [wSwitchItem], a
call Function249a7
jp c, Function249d1
ld a, [wCurrPocketCursorPosition]
ld c, a
ld a, [wSwitchItem]
cp c
jr c, .asm_2497a
jr .asm_2494a
.init
ld a, [wCurrPocketCursorPosition]
inc a
ld [wSwitchItem], a
ret
.trivial
xor a
ld [wSwitchItem], a
ret
.asm_2494a
ld a, [wSwitchItem]
call Function24a40
ld a, [wCurrPocketCursorPosition]
ld d, a
ld a, [wSwitchItem]
ld e, a
call Function24a6c
push bc
ld a, [wSwitchItem]
call Function24a5c
dec hl
push hl
call Function24a80
add hl, bc
ld d, h
ld e, l
pop hl
pop bc
call Function24aab
ld a, [wCurrPocketCursorPosition]
call Function24a4d
xor a
ld [wSwitchItem], a
ret
.asm_2497a
ld a, [wSwitchItem]
call Function24a40
ld a, [wCurrPocketCursorPosition]
ld d, a
ld a, [wSwitchItem]
ld e, a
call Function24a6c
push bc
ld a, [wSwitchItem]
call Function24a5c
ld d, h
ld e, l
call Function24a80
add hl, bc
pop bc
call CopyBytes
ld a, [wCurrPocketCursorPosition]
call Function24a4d
xor a
ld [wSwitchItem], a
ret
Function249a7: ; 249a7 (9:49a7)
ld a, [wSwitchItem]
call Function24a5c
ld d, h
ld e, l
ld a, [wCurrPocketCursorPosition]
call Function24a5c
ld a, [de]
cp [hl]
jr nz, .asm_249cd
ld a, [wCurrPocketCursorPosition]
call Function24a97
cp 99
jr z, .asm_249cd
ld a, [wSwitchItem]
call Function24a97
cp 99
jr nz, .asm_249cf
.asm_249cd
and a
ret
.asm_249cf
scf
ret
Function249d1: ; 249d1 (9:49d1)
ld a, [wSwitchItem]
call Function24a5c
inc hl
push hl
ld a, [wCurrPocketCursorPosition]
call Function24a5c
inc hl
ld a, [hl]
pop hl
add [hl]
cp 100
jr c, .asm_24a01
sub 99
push af
ld a, [wCurrPocketCursorPosition]
call Function24a5c
inc hl
ld [hl], 99
ld a, [wSwitchItem]
call Function24a5c
inc hl
pop af
ld [hl], a
xor a
ld [wSwitchItem], a
ret
.asm_24a01
push af
ld a, [wCurrPocketCursorPosition]
call Function24a5c
inc hl
pop af
ld [hl], a
ld hl, wMenuData2Addr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wSwitchItem]
cp [hl]
jr nz, .asm_24a25
dec [hl]
ld a, [wSwitchItem]
call Function24a5c
ld [hl], $ff
xor a
ld [wSwitchItem], a
ret
.asm_24a25
dec [hl]
call Function24a80
push bc
ld a, [wSwitchItem]
call Function24a5c
pop bc
push hl
add hl, bc
pop de
.asm_24a34
ld a, [hli]
ld [de], a
inc de
cp $ff
jr nz, .asm_24a34
xor a
ld [wSwitchItem], a
ret
Function24a40: ; 24a40 (9:4a40)
call Function24a5c
ld de, wd002
call Function24a80
call CopyBytes
ret
Function24a4d: ; 24a4d (9:4a4d)
call Function24a5c
ld d, h
ld e, l
ld hl, wd002
call Function24a80
call CopyBytes
ret
Function24a5c: ; 24a5c (9:4a5c)
push af
call Function24a80
ld hl, wMenuData2Addr
ld a, [hli]
ld h, [hl]
ld l, a
inc hl
pop af
call AddNTimes
ret
Function24a6c: ; 24a6c (9:4a6c)
push hl
call Function24a80
ld a, d
sub e
jr nc, .asm_24a76
dec a
cpl
.asm_24a76
ld hl, 0
call AddNTimes
ld b, h
ld c, l
pop hl
ret
Function24a80: ; 24a80 (9:4a80)
push hl
ld a, [wcf94]
ld c, a
ld b, 0
ld hl, Unknown_24a91
rept 2
add hl, bc
endr
ld c, [hl]
inc hl
ld b, [hl]
pop hl
ret
; 24a91 (9:4a91)
Unknown_24a91: ; 24a91
dw 0, 1, 2
; 24a97
Function24a97: ; 24a97 (9:4a97)
push af
call Function24a80
ld a, c
cp $2
jr nz, .asm_24aa7
pop af
call Function24a5c
inc hl
ld a, [hl]
ret
.asm_24aa7
pop af
ld a, $1
ret
Function24aab: ; 24aab (9:4aab)
.loop
ld a, [hld]
ld [de], a
dec de
dec bc
ld a, b
or c
jr nz, .loop
ret

592
engine/tmhm2.asm Executable file
View File

@ -0,0 +1,592 @@
TMHMPocket: ; 2c76f (b:476f)
ld a, $1
ld [hInMenu], a
call TMHM_PocketLoop
ld a, $0
ld [hInMenu], a
ret nc
call Function1bee
call WaitBGMap
ld a, [CurItem]
dec a
ld [ItemCountBuffer], a
ld hl, TMsHMs
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
ld [wItemQuantityBuffer], a
call .ConvertItemToTMHMNumber
scf
ret
.ConvertItemToTMHMNumber: ; 2c798 (b:4798)
ld a, [CurItem]
ld c, a
callab GetNumberedTMHM
ld a, c
ld [CurItem], a
ret
ConvertCurItemIntoCurTMHM: ; 2c7a7 (b:47a7)
ld a, [CurItem]
ld c, a
callab GetTMHMNumber
ld a, c
ld [wCurTMHM], a
ret
GetTMHMItemMove: ; 2c7b6 (b:47b6)
call ConvertCurItemIntoCurTMHM
predef GetTMHMMove
ret
AskTeachTMHM: ; 2c7bf (b:47bf)
ld hl, Options
ld a, [hl]
push af
res NO_TEXT_SCROLL, [hl]
ld a, [CurItem]
cp TM01
jr c, .NotTMHM
call GetTMHMItemMove
ld a, [wCurTMHM]
ld [wPutativeTMHMMove], a
call GetMoveName
call CopyName1
ld hl, Text_BootedTM ; Booted up a TM
ld a, [CurItem]
cp HM01
jr c, .TM
ld hl, Text_BootedHM ; Booted up an HM
.TM
call PrintText
ld hl, Text_ItContained
call PrintText
call YesNoBox
.NotTMHM
pop bc
ld a, b
ld [Options], a
ret
ChooseMonToLearnTMHM: ; 2c7fb
ld hl, StringBuffer2
ld de, wd066
ld bc, 12
call CopyBytes
call ClearBGPalettes
ChooseMonToLearnTMHM_NoRefresh: ; 2c80a
callba LoadPartyMenuGFX
callba InitPartyMenuWithCancel
callba InitPartyMenuGFX
ld a, $3
ld [PartyMenuActionText], a
.loopback
callba WritePartyMenuTilemap
callba PrintPartyMenuText
call WaitBGMap
call SetPalettes
call DelayFrame
callba PartyMenuSelect
push af
ld a, [CurPartySpecies]
cp EGG
pop bc ; now contains the former contents of af
jr z, .egg
push bc
ld hl, wd066
ld de, StringBuffer2
ld bc, 12
call CopyBytes
pop af ; now contains the original contents of af
ret
.egg
push hl
push de
push bc
push af
ld de, SFX_WRONG
call PlaySFX
call WaitSFX
pop af
pop bc
pop de
pop hl
jr .loopback
; 2c867
TeachTMHM: ; 2c867
predef CanLearnTMHMMove
push bc
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
call GetNick
pop bc
ld a, c
and a
jr nz, .compatible
push de
ld de, SFX_WRONG
call PlaySFX
pop de
ld hl, Text_TMHMNotCompatible
call PrintText
jr .nope
.compatible
callab KnowsMove
jr c, .nope
predef LearnMove
ld a, b
and a
jr z, .nope
callba MobileFn_106049
ld a, [CurItem]
call IsHM
ret c
ld c, HAPPINESS_LEARNMOVE
callab ChangeHappiness
call ConsumeTM
jr .learned_move
.nope
and a
ret
.unused
ld a, 2
ld [wItemEffectSucceeded], a
.learned_move
scf
ret
; 2c8bf (b:48bf)
Text_BootedTM: ; 0x2c8bf
; Booted up a TM.
text_jump UnknownText_0x1c0373
db "@"
; 0x2c8c4
Text_BootedHM: ; 0x2c8c4
; Booted up an HM.
text_jump UnknownText_0x1c0384
db "@"
; 0x2c8c9
Text_ItContained: ; 0x2c8c9
; It contained @ . Teach @ to a #MON?
text_jump UnknownText_0x1c0396
db "@"
; 0x2c8ce
Text_TMHMNotCompatible: ; 0x2c8ce
; is not compatible with @ . It can't learn @ .
text_jump UnknownText_0x1c03c2
db "@"
; 0x2c8d3
TMHM_PocketLoop: ; 2c8d3 (b:48d3)
xor a
ld [hBGMapMode], a
call TMHM_DisplayPocketItems
ld a, $2
ld [wcfa1], a
ld a, $7
ld [wcfa2], a
ld a, $1
ld [wcfa4], a
ld a, $5
sub d
inc a
cp $6
jr nz, .okay
dec a
.okay
ld [wcfa3], a
ld a, $c
ld [wcfa5], a
xor a
ld [wcfa6], a
ld a, $20
ld [wcfa7], a
ld a, $f3
ld [wcfa8], a
ld a, [wTMHMPocketCursor]
inc a
ld [MenuSelection2], a
ld a, $1
ld [wcfaa], a
jr TMHM_ShowTMMoveDescription
TMHM_JoypadLoop: ; 2c915 (b:4915)
call TMHM_DisplayPocketItems
call Function1bc9
ld b, a
ld a, [MenuSelection2]
dec a
ld [wTMHMPocketCursor], a
xor a
ld [hBGMapMode], a
ld a, [wcfa6]
bit 7, a
jp nz, TMHM_ScrollPocket
ld a, b
ld [wMenuJoypad], a
bit A_BUTTON_F, a
jp nz, TMHM_ChooseTMorHM
bit B_BUTTON_F, a
jp nz, TMHM_ExitPack
bit D_RIGHT_F, a
jp nz, TMHM_ExitPocket
bit D_LEFT_F, a
jp nz, TMHM_ExitPocket
TMHM_ShowTMMoveDescription: ; 2c946 (b:4946)
call TMHM_CheckHoveringOverCancel
jp nc, TMHM_ExitPocket
hlcoord 0, 12
ld b, 4
ld c, SCREEN_WIDTH - 2
call TextBox
ld a, [CurItem]
cp NUM_TMS + NUM_HMS + 1
jr nc, TMHM_JoypadLoop
ld [wd265], a
predef GetTMHMMove
ld a, [wd265]
ld [CurSpecies], a
hlcoord 1, 14
call PrintMoveDesc
jp TMHM_JoypadLoop
TMHM_ChooseTMorHM: ; 2c974 (b:4974)
call TMHM_PlaySFX_ReadText2
call CountTMsHMs ; This stores the count to wd265.
ld a, [MenuSelection2]
dec a
ld b, a
ld a, [wTMHMPocketScrollPosition]
add b
ld b, a
ld a, [wd265]
cp b
jr z, _TMHM_ExitPack ; our cursor was hovering over CANCEL
TMHM_CheckHoveringOverCancel: ; 2c98a (b:498a)
call TMHM_GetCurrentPocketPosition
ld a, [MenuSelection2]
ld b, a
.loop
inc c
ld a, c
cp NUM_TMS + NUM_HMS + 1
jr nc, .okay
ld a, [hli]
and a
jr z, .loop
dec b
jr nz, .loop
ld a, c
.okay
ld [CurItem], a
cp -1
ret
TMHM_ExitPack: ; 2c9a5 (b:49a5)
call TMHM_PlaySFX_ReadText2
_TMHM_ExitPack: ; 2c9a8 (b:49a8)
ld a, $2
ld [wMenuJoypad], a
and a
ret
TMHM_ExitPocket: ; 2c9af (b:49af)
and a
ret
TMHM_ScrollPocket: ; 2c9b1 (b:49b1)
ld a, b
bit 7, a
jr nz, .skip
ld hl, wTMHMPocketScrollPosition
ld a, [hl]
and a
jp z, TMHM_JoypadLoop
dec [hl]
call TMHM_DisplayPocketItems
jp TMHM_ShowTMMoveDescription
.skip
call TMHM_GetCurrentPocketPosition
ld b, 5
.loop
inc c
ld a, c
cp NUM_TMS + NUM_HMS + 1
jp nc, TMHM_JoypadLoop
ld a, [hli]
and a
jr z, .loop
dec b
jr nz, .loop
ld hl, wTMHMPocketScrollPosition
inc [hl]
call TMHM_DisplayPocketItems
jp TMHM_ShowTMMoveDescription
TMHM_DisplayPocketItems: ; 2c9e2 (b:49e2)
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
jp z, Tutorial_TMHMPocket
hlcoord 5, 2
lb bc, 10, 15
ld a, " "
call ClearBox
call TMHM_GetCurrentPocketPosition
ld d, $5
.loop2
inc c
ld a, c
cp NUM_TMS + NUM_HMS + 1
jr nc, .NotTMHM
ld a, [hli]
and a
jr z, .loop2
ld b, a
ld a, c
ld [wd265], a
push hl
push de
push bc
call TMHMPocket_GetCurrentLineCoord
push hl
ld a, [wd265]
cp NUM_TMS + 1
jr nc, .HM
ld de, wd265
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
jr .okay
.HM
push af
sub NUM_TMS
ld [wd265], a
ld [hl], "H"
inc hl
ld de, wd265
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
call PrintNum
pop af
ld [wd265], a
.okay
predef GetTMHMMove
ld a, [wd265]
ld [wPutativeTMHMMove], a
call GetMoveName
pop hl
ld bc, 3
add hl, bc
push hl
call PlaceString
pop hl
pop bc
ld a, c
push bc
cp NUM_TMS + 1
jr nc, .hm2
ld bc, SCREEN_WIDTH + 9
add hl, bc
ld [hl], "×"
inc hl
ld a, "0" ; why are we doing this?
pop bc
push bc
ld a, b
ld [wd265], a
ld de, wd265
lb bc, 1, 2
call PrintNum
.hm2
pop bc
pop de
pop hl
dec d
jr nz, .loop2
jr .done
.NotTMHM
call TMHMPocket_GetCurrentLineCoord
rept 3
inc hl
endr
push de
ld de, TMHM_String_Cancel
call PlaceString
pop de
.done
ret
TMHMPocket_GetCurrentLineCoord: ; 2ca86 (b:4a86)
hlcoord 5, 0
ld bc, 2 * SCREEN_WIDTH
ld a, 6
sub d
ld e, a
; AddNTimes
.loop
add hl, bc
dec e
jr nz, .loop
ret
; 2ca95 (b:4a95)
Function2ca95: ; 2ca95
; unreferenced
pop hl
ld bc, 3
add hl, bc
predef GetTMHMMove
ld a, [wd265]
ld [wPutativeTMHMMove], a
call GetMoveName
push hl
call PlaceString
pop hl
ret
; 2caae
TMHM_String_Cancel: ; 2caae
db "CANCEL@"
; 2cab5
TMHM_GetCurrentPocketPosition: ; 2cab5 (b:4ab5)
ld hl, TMsHMs
ld a, [wTMHMPocketScrollPosition]
ld b, a
inc b
ld c, 0
.loop
inc c
ld a, [hli]
and a
jr z, .loop
dec b
jr nz, .loop
dec hl
dec c
ret
Tutorial_TMHMPocket: ; 2caca (b:4aca)
hlcoord 9, 3
push de
ld de, TMHM_String_Cancel
call PlaceString
pop de
ret
TMHM_PlaySFX_ReadText2: ; 2cad6 (b:4ad6)
push de
ld de, SFX_READ_TEXT_2
call PlaySFX
pop de
ret
; 2cadf (b:4adf)
Function2cadf: ; 2cadf
; unreferenced
call ConvertCurItemIntoCurTMHM
call .CheckHaveRoomForTMHM
ld hl, .NoRoomText
jr nc, .print
ld hl, .ReceivedText
.print
jp PrintText
; 2caf0
.NoRoomText: ; 0x2caf0
; You have no room for any more @ S.
text_jump UnknownText_0x1c03fa
db "@"
; 0x2caf5
.ReceivedText: ; 0x2caf5
; You received @ !
text_jump UnknownText_0x1c0421
db "@"
; 0x2cafa
.CheckHaveRoomForTMHM: ; 2cafa
ld a, [wd265]
dec a
ld hl, TMsHMs
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
inc a
cp NUM_TMS * 2
ret nc
ld [hl], a
ret
; 2cb0c
ConsumeTM: ; 2cb0c (b:4b0c)
call ConvertCurItemIntoCurTMHM
ld a, [wd265]
dec a
ld hl, TMsHMs
ld b, 0
ld c, a
add hl, bc
ld a, [hl]
and a
ret z
dec a
ld [hl], a
ret nz
ld a, [wTMHMPocketScrollPosition]
and a
ret z
dec a
ld [wTMHMPocketScrollPosition], a
ret
CountTMsHMs: ; 2cb2a (b:4b2a)
ld b, 0
ld c, NUM_TMS + NUM_HMS
ld hl, TMsHMs
.loop
ld a, [hli]
and a
jr z, .skip
inc b
.skip
dec c
jr nz, .loop
ld a, b
ld [wd265], a
ret
PrintMoveDesc: ; 2cb3e
push hl
ld hl, MoveDescriptions
ld a, [CurSpecies]
dec a
ld c, a
ld b, 0
rept 2
add hl, bc
endr
ld a, [hli]
ld e, a
ld d, [hl]
pop hl
jp PlaceString
; 2cb52

View File

@ -28,7 +28,8 @@ MenuTextBox:: ; 1d4f
jp PrintText
; 1d57
Function1d57:: ; 1d57
ret_1d57:: ; 1d57
; unreferenced
ret
; 1d58
@ -423,9 +424,9 @@ Function1f2a:: ; 1f2a
ret
; 1f79
Function1f79:: ; 1f79
PlaceMenuStrings:: ; 1f79
push de
ld hl, wcf97
ld hl, wMenuData2PointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a
@ -441,7 +442,7 @@ Function1f79:: ; 1f79
PlaceNthMenuStrings:: ; 1f8d
push de
ld a, [MenuSelection]
call Function1fb1
call GetMenuDataPointerTableEntry
rept 2
inc hl
endr
@ -454,7 +455,8 @@ endr
; 1f9e
Function1f9e:: ; 1f9e
call Function1fb1
; unreferenced
call GetMenuDataPointerTableEntry
rept 2
inc hl
endr
@ -466,17 +468,17 @@ endr
MenuJumptable:: ; 1fa7
ld a, [MenuSelection]
call Function1fb1
call GetMenuDataPointerTableEntry
ld a, [hli]
ld h, [hl]
ld l, a
jp [hl]
; 1fb1
Function1fb1:: ; 1fb1
GetMenuDataPointerTableEntry:: ; 1fb1
ld e, a
ld d, $0
ld hl, wcf97
ld hl, wMenuData2PointerTableAddr
ld a, [hli]
ld h, [hl]
ld l, a

View File

@ -4,7 +4,7 @@ _DoItemEffect:: ; e722
call GetItemName
call CopyName1
ld a, 1
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ld a, [CurItem]
dec a
ld hl, ItemEffects
@ -1220,7 +1220,7 @@ SunStone: ; ee0f
.DecidedNotToUse
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ret
; ee3d
@ -1293,7 +1293,7 @@ UpdateStatsAfterItem: ; ee8c
RareCandy_StatBooster_ExitMenu: ; ee9f
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
jp ClearPalettes
; eea6
@ -1930,7 +1930,7 @@ StatusHealer_NoEffect: ; f299 (3:7299)
StatusHealer_ExitMenu: ; f29e (3:729e)
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
StatusHealer_ClearPalettes: ; f2a2 (3:72a2)
call ClearPalettes
ret
@ -2233,10 +2233,10 @@ Softboiled_MilkDrinkFunction: ; f3df (3:73df)
EscapeRope: ; f44f
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
callba EscapeRopeFunction
ld a, [wPlayerAction]
ld a, [wItemEffectSucceeded]
cp 1
call z, UseDisposableItem
ret
@ -2298,7 +2298,7 @@ PokeDoll: ; f48f
.asm_f4a6
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ret
; f4ab
@ -2701,7 +2701,7 @@ PPRestoreItem_NoEffect: ; f6dd
PPRestoreItem_Cancel: ; f6e0
call ClearPalettes
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ret
; f6e8
@ -2802,7 +2802,7 @@ BasementKey: ; f74c
SacredAsh: ; f753
callba _SacredAsh
ld a, [wPlayerAction]
ld a, [wItemEffectSucceeded]
cp $1
ret nz
call UseDisposableItem
@ -2973,7 +2973,7 @@ WontHaveAnyEffect_NotUsedMessage: ; f7ca
; Item wasn't used.
ld a, $2
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ret
; f7d6
@ -2988,7 +2988,7 @@ Ball_BoxIsFullMessage: ; f7dc
; Item wasn't used.
ld a, $2
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
ret
; f7e8
@ -3018,7 +3018,7 @@ CantGetOnYourBikeMessage: ; f801
CantUseItemMessage: ; f804
; Item couldn't be used.
xor a
ld [wPlayerAction], a
ld [wItemEffectSucceeded], a
jp PrintText
; f80b

1737
main.asm

File diff suppressed because it is too large Load Diff

View File

@ -1694,7 +1694,7 @@ Function89a57: ; 89a57
Function89a8a: ; 89a8a
push af
ld de, SFX_UNKNOWN_62
ld de, SFX_SWITCH_POCKETS
call PlaySFX
pop af
ret

67
text/trainer_class_names.asm Executable file
View File

@ -0,0 +1,67 @@
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "RIVAL@"
db "#MON PROF.@"
db "ELITE FOUR@"
db "<PKMN> TRAINER@"
db "ELITE FOUR@"
db "ELITE FOUR@"
db "ELITE FOUR@"
db "CHAMPION@"
db "LEADER@"
db "LEADER@"
db "LEADER@"
db "SCIENTIST@"
db "LEADER@"
db "YOUNGSTER@"
db "SCHOOLBOY@"
db "BIRD KEEPER@"
db "LASS@"
db "LEADER@"
db "COOLTRAINER@"
db "COOLTRAINER@"
db "BEAUTY@"
db "#MANIAC@"
db "ROCKET@"
db "GENTLEMAN@"
db "SKIER@"
db "TEACHER@"
db "LEADER@"
db "BUG CATCHER@"
db "FISHER@"
db "SWIMMER♂@"
db "SWIMMER♀@"
db "SAILOR@"
db "SUPER NERD@"
db "RIVAL@"
db "GUITARIST@"
db "HIKER@"
db "BIKER@"
db "LEADER@"
db "BURGLAR@"
db "FIREBREATHER@"
db "JUGGLER@"
db "BLACKBELT@"
db "ROCKET@"
db "PSYCHIC@"
db "PICNICKER@"
db "CAMPER@"
db "ROCKET@"
db "SAGE@"
db "MEDIUM@"
db "BOARDER@"
db "#FAN@"
db "KIMONO GIRL@"
db "TWINS@"
db "#FAN@"
db "<PKMN> TRAINER@"
db "LEADER@"
db "OFFICER@"
db "ROCKET@"
db "MYSTICALMAN@"

View File

@ -1471,12 +1471,14 @@ Requested1bppDest:: ; cf6f
; something to do with menu
wcf71:: ds 1
wcf72:: ds 1
wMenuJoypad::
wcf73:: ds 1
MenuSelection:: ; cf74
ds 1
wcf75:: ds 1
wcf76:: ds 1
wCurrPocketCursorPosition::
wcf77:: ds 1
wcf78:: ds 9
@ -1506,10 +1508,15 @@ wMenuData2Flags:: ds 1 ; cf91
; bit 0: ????
wMenuData2Items:: ds 1
wMenuData2IndicesPointer::
wcf93:: ds 1
wcf94:: ds 1
wMenuData2DisplayFunctionPointer::
wMenuData2Bank::
wcf95:: ds 1 ; bank
wMenuData2Addr::
wcf96:: ds 1 ; addr lo
wMenuData2PointerTableAddr::
wcf97:: ds 1 ; addr hi
wcf98:: ds 3
wcf9b:: ds 3
@ -1622,7 +1629,7 @@ wMinutesSince:: ds 1
wHoursSince:: ds 1
wDaysSince:: ds 1
ds 40
wRAM0End:: ; cfc0
SECTION "WRAM 1", WRAMX, BANK [1]
@ -1851,6 +1858,7 @@ wBallsPocketScrollPosition:: ds 1
wTMHMPocketScrollPosition:: ds 1
wMoveSwapBuffer::
wSwitchMon::
wSwitchItem::
wd0e3:: ds 1
wMenuScrollPosition:: ds 4
wQueuedScriptBank:: ds 1
@ -1858,6 +1866,7 @@ wQueuedScriptAddr:: ds 2
wNumMoves::
wd0eb:: ds 1
wFieldMoveSucceeded::
wItemEffectSucceeded::
wPlayerAction::
; 0 - use move
; 1 - use item
@ -2285,6 +2294,21 @@ OTPartyCount:: ds 1 ; d280
OTPartySpecies:: ds PARTY_LENGTH ; d281
OTPartyEnd:: ds 1
wDudeBag:: ; d288
wDudeNumItems:: ds 1
wDudeItems:: ds 2 * 4
wDudeItemsEnd:: ds 1
wDudeNumKeyItems:: ds 1 ; d292
wDudeKeyItems:: ds 18
wDudeKeyItemsEnd:: ds 1
wDudeNumBalls:: ds 1 ; d2a6
wDudeBalls:: ds 2 * 4
wDudeBallsEnd:: ds 1
wDudeBagEnd::
ds wDudeBag - @
OTPartyMons::
OTPartyMon1:: party_struct OTPartyMon1 ; d288
OTPartyMon2:: party_struct OTPartyMon2 ; d2b8