Renaming sections, further dissolving main.asm

This commit is contained in:
PikalaxALT 2015-11-28 15:13:40 -05:00
parent 43903f543b
commit 8612a4a531
44 changed files with 1622 additions and 1594 deletions

View File

@ -20,7 +20,7 @@ AI_SwitchOrTryItem: ; 38000
and a and a
jr nz, DontSwitch jr nz, DontSwitch
ld hl, TrainerClassAttributes + 5 ld hl, TrainerClassAttributes + TRNATTR_AI_ITEM_SWITCH
ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers ld a, [InBattleTowerBattle] ; Load always the first TrainerClass for BattleTower-Trainers
and a and a
jr nz, .ok jr nz, .ok

222
battle/ai/move.asm Executable file
View File

@ -0,0 +1,222 @@
AIChooseMove: ; 440ce
; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
; Pick the move with the lowest score.
; Wildmons attack at random.
ld a, [wBattleMode]
dec a
ret z
ld a, [wLinkMode]
and a
ret nz
; No use picking a move if there's no choice.
callba CheckSubstatus_RechargeChargedRampageBideRollout
ret nz
; The default score is 20. Unusable moves are given a score of 80.
ld a, 20
ld hl, Buffer1
rept 3
ld [hli], a
endr
ld [hl], a
; Don't pick disabled moves.
ld a, [EnemyDisabledMove]
and a
jr z, .CheckPP
ld hl, EnemyMonMoves
ld c, 0
.CheckDisabledMove
cp [hl]
jr z, .ScoreDisabledMove
inc c
inc hl
jr .CheckDisabledMove
.ScoreDisabledMove
ld hl, Buffer1
ld b, 0
add hl, bc
ld [hl], 80
; Don't pick moves with 0 PP.
.CheckPP
ld hl, Buffer1 - 1
ld de, EnemyMonPP
ld b, 0
.CheckMovePP
inc b
ld a, b
cp EnemyMonMovesEnd - EnemyMonMoves + 1
jr z, .ApplyLayers
inc hl
ld a, [de]
inc de
and $3f
jr nz, .CheckMovePP
ld [hl], 80
jr .CheckMovePP
; Apply AI scoring layers depending on the trainer class.
.ApplyLayers
ld hl, TrainerClassAttributes + TRNATTR_AI_MOVE_WEIGHTS
; If we have a battle in BattleTower just load the Attributes of the first TrainerClass (Falkner)
; so we have always the same AI, regardless of the loaded class of trainer
ld a, [InBattleTowerBattle]
bit 0, a
jr nz, .battle_tower_skip
ld a, [TrainerClass]
dec a
ld bc, 7 ; Trainer2AI - Trainer1AI
call AddNTimes
.battle_tower_skip
lb bc, CHECK_FLAG, 0
push bc
push hl
.CheckLayer
pop hl
pop bc
ld a, c
cp 16 ; up to 16 scoring layers
jr z, .DecrementScores
push bc
ld d, BANK(TrainerClassAttributes)
predef FlagPredef
ld d, c
pop bc
inc c
push bc
push hl
ld a, d
and a
jr z, .CheckLayer
ld hl, AIScoringPointers
dec c
ld b, 0
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, BANK(AIScoring)
call FarCall_hl
jr .CheckLayer
; Decrement the scores of all moves one by one until one reaches 0.
.DecrementScores
ld hl, Buffer1
ld de, EnemyMonMoves
ld c, EnemyMonMovesEnd - EnemyMonMoves
.DecrementNextScore
; If the enemy has no moves, this will infinite.
ld a, [de]
inc de
and a
jr z, .DecrementScores
; We are done whenever a score reaches 0
dec [hl]
jr z, .PickLowestScoreMoves
; If we just decremented the fourth move's score, go back to the first move
inc hl
dec c
jr z, .DecrementScores
jr .DecrementNextScore
; In order to avoid bias towards the moves located first in memory, increment the scores
; that were decremented one more time than the rest (in case there was a tie).
; This means that the minimum score will be 1.
.PickLowestScoreMoves
ld a, c
.move_loop
inc [hl]
dec hl
inc a
cp NUM_MOVES + 1
jr nz, .move_loop
ld hl, Buffer1
ld de, EnemyMonMoves
ld c, NUM_MOVES
; Give a score of 0 to a blank move
.loop2
ld a, [de]
and a
jr nz, .skip_load
ld [hl], a
; Disregard the move if its score is not 1
.skip_load
ld a, [hl]
dec a
jr z, .keep
xor a
ld [hli], a
jr .after_toss
.keep
ld a, [de]
ld [hli], a
.after_toss
inc de
dec c
jr nz, .loop2
; Randomly choose one of the moves with a score of 1
.ChooseMove
ld hl, Buffer1
call Random
and 3
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
and a
jr z, .ChooseMove
ld [CurEnemyMove], a
ld a, c
ld [CurEnemyMoveNum], a
ret
; 441af
AIScoringPointers: ; 441af
dw AI_Basic
dw AI_Setup
dw AI_Types
dw AI_Offensive
dw AI_Smart
dw AI_Opportunist
dw AI_Aggressive
dw AI_Cautious
dw AI_Status
dw AI_Risky
dw AI_None
dw AI_None
dw AI_None
dw AI_None
dw AI_None
dw AI_None
; 441cf

View File

@ -1,9 +1,6 @@
BattleCore:
; Core components of the battle engine. ; Core components of the battle engine.
BattleCore:
DoBattle: ; 3c000
SendOutFirstMons: ; 3c000
xor a xor a
ld [wBattleParticipantsNotFainted], a ld [wBattleParticipantsNotFainted], a
ld [wc6fc], a ld [wc6fc], a
@ -83,8 +80,8 @@ SendOutFirstMons: ; 3c000
ld [CurPartySpecies], a ld [CurPartySpecies], a
ld [TempBattleMonSpecies], a ld [TempBattleMonSpecies], a
hlcoord 1, 5 hlcoord 1, 5
ld a, $9 ld a, 9
call Function3d490 call SlideBattlePicOut
call LoadTileMapToTempTileMap call LoadTileMapToTempTileMap
call ResetBattleParticipants call ResetBattleParticipants
call InitBattleMon call InitBattleMon
@ -113,7 +110,7 @@ SendOutFirstMons: ; 3c000
call SpikesDamage call SpikesDamage
.not_linked_2 .not_linked_2
jp Function3c12f jp BattleTurn
.tutorial_debug .tutorial_debug
jp BattleMenu jp BattleMenu
@ -130,33 +127,33 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
ld a, [wLinkMode] ld a, [wLinkMode]
and a and a
ld hl, BattleText_WildFled ld hl, BattleText_WildFled
jr z, .asm_3c115 jr z, .print_text
ld a, [wBattleResult] ld a, [wBattleResult]
and $c0 and $c0
ld [wBattleResult], a ld [wBattleResult], a
ld hl, BattleText_EnemyFled ld hl, BattleText_EnemyFled
call CheckMobileBattleError call CheckMobileBattleError
jr nc, .asm_3c115 jr nc, .print_text
ld hl, wcd2a ld hl, wcd2a
bit 4, [hl] bit 4, [hl]
jr nz, .asm_3c118 jr nz, .skip_text
ld hl, BattleText_LinkErrorBattleCanceled ld hl, BattleText_LinkErrorBattleCanceled
.asm_3c115 .print_text
call StdBattleTextBox call StdBattleTextBox
.asm_3c118 .skip_text
call StopDangerSound call StopDangerSound
call CheckMobileBattleError call CheckMobileBattleError
jr c, .asm_3c126 jr c, .skip_sfx
ld de, SFX_RUN ld de, SFX_RUN
call PlaySFX call PlaySFX
.asm_3c126 .skip_sfx
call SetPlayerTurn call SetPlayerTurn
ld a, 1 ld a, 1
ld [BattleEnded], a ld [BattleEnded], a
@ -164,7 +161,7 @@ WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
; 3c12f ; 3c12f
Function3c12f: ; 3c12f BattleTurn: ; 3c12f
.loop .loop
call MobileFn_3c1bf call MobileFn_3c1bf
call CheckContestBattleOver call CheckContestBattleOver
@ -2489,8 +2486,8 @@ WinTrainerBattle: ; 3cfa4
bit 0, a bit 0, a
jr nz, .battle_tower jr nz, .battle_tower
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, $28 ld c, 40
call DelayFrames call DelayFrames
ld a, [BattleType] ld a, [BattleType]
cp BATTLETYPE_CANLOSE cp BATTLETYPE_CANLOSE
@ -2506,7 +2503,7 @@ WinTrainerBattle: ; 3cfa4
jp Function3d02b jp Function3d02b
.mobile .mobile
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40 ld c, 40
call DelayFrames call DelayFrames
ld c, $4 ld c, $4
@ -2514,7 +2511,7 @@ WinTrainerBattle: ; 3cfa4
ret ret
.battle_tower .battle_tower
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40 ld c, 40
call DelayFrames call DelayFrames
call EmptyBattleTextBox call EmptyBattleTextBox
@ -3111,7 +3108,7 @@ LostBattle: ; 3d38e
hlcoord 0, 0 hlcoord 0, 0
lb bc, 8, 21 lb bc, 8, 21
call ClearBox call ClearBox
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40 ld c, 40
call DelayFrames call DelayFrames
@ -3128,7 +3125,7 @@ LostBattle: ; 3d38e
hlcoord 0, 0 hlcoord 0, 0
lb bc, 8, 21 lb bc, 8, 21
call ClearBox call ClearBox
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40 ld c, 40
call DelayFrames call DelayFrames
@ -3180,7 +3177,7 @@ LostBattle: ; 3d38e
hlcoord 0, 0 hlcoord 0, 0
lb bc, 8, 21 lb bc, 8, 21
call ClearBox call ClearBox
call Function3ebd8 call BattleWinSlideInEnemyTrainerFrontpic
ld c, 40 ld c, 40
call DelayFrames call DelayFrames
@ -3260,31 +3257,31 @@ MonFaintedAnimation: ; 3d444
; 3d490 ; 3d490
Function3d490: ; 3d490 SlideBattlePicOut: ; 3d490
ld [hMapObjectIndexBuffer], a ld [hMapObjectIndexBuffer], a
ld c, a ld c, a
.asm_3d493 .loop
push bc push bc
push hl push hl
ld b, $7 ld b, $7
.asm_3d497 .loop2
push hl push hl
call Function3d4ae call .DoFrame
pop hl pop hl
ld de, SCREEN_WIDTH ld de, SCREEN_WIDTH
add hl, de add hl, de
dec b dec b
jr nz, .asm_3d497 jr nz, .loop2
ld c, 2 ld c, 2
call DelayFrames call DelayFrames
pop hl pop hl
pop bc pop bc
dec c dec c
jr nz, .asm_3d493 jr nz, .loop
ret ret
; 3d4ae ; 3d4ae
Function3d4ae: ; 3d4ae .DoFrame: ; 3d4ae
ld a, [hMapObjectIndexBuffer] ld a, [hMapObjectIndexBuffer]
ld c, a ld c, a
cp $8 cp $8
@ -3413,8 +3410,8 @@ ResetEnemyBattleVars: ; 3d557
xor a xor a
ld [wPlayerWrapCount], a ld [wPlayerWrapCount], a
hlcoord 18, 0 hlcoord 18, 0
ld a, $8 ld a, 8
call Function3d490 call SlideBattlePicOut
call EmptyBattleTextBox call EmptyBattleTextBox
jp LoadStandardMenuDataHeader jp LoadStandardMenuDataHeader
; 3d57a ; 3d57a
@ -4478,21 +4475,21 @@ HandleHealingItems: ; 3dcf9
call SetPlayerTurn call SetPlayerTurn
call HandleHPHealingItem call HandleHPHealingItem
call UseHeldStatusHealingItem call UseHeldStatusHealingItem
call HandleStatusHealingItem call UseConfusionHealingItem
call SetEnemyTurn call SetEnemyTurn
call HandleHPHealingItem call HandleHPHealingItem
call UseHeldStatusHealingItem call UseHeldStatusHealingItem
jp HandleStatusHealingItem jp UseConfusionHealingItem
.player_1 .player_1
call SetEnemyTurn call SetEnemyTurn
call HandleHPHealingItem call HandleHPHealingItem
call UseHeldStatusHealingItem call UseHeldStatusHealingItem
call HandleStatusHealingItem call UseConfusionHealingItem
call SetPlayerTurn call SetPlayerTurn
call HandleHPHealingItem call HandleHPHealingItem
call UseHeldStatusHealingItem call UseHeldStatusHealingItem
jp HandleStatusHealingItem jp UseConfusionHealingItem
; 3dd2f ; 3dd2f
HandleHPHealingItem: ; 3dd2f HandleHPHealingItem: ; 3dd2f
@ -4672,7 +4669,7 @@ UseHeldStatusHealingItem: ; 3dde9
; 3de51 ; 3de51
HandleStatusHealingItem: ; 3de51 UseConfusionHealingItem: ; 3de51
ld a, BATTLE_VARS_SUBSTATUS3_OPP ld a, BATTLE_VARS_SUBSTATUS3_OPP
call GetBattleVar call GetBattleVar
bit SUBSTATUS_CONFUSED, a bit SUBSTATUS_CONFUSED, a
@ -4692,7 +4689,7 @@ HandleStatusHealingItem: ; 3de51
res SUBSTATUS_CONFUSED, [hl] res SUBSTATUS_CONFUSED, [hl]
call GetItemName call GetItemName
call ItemRecoveryAnim call ItemRecoveryAnim
ld hl, BattleText_0x80dab ld hl, BattleText_ItemHealedConfusion
call StdBattleTextBox call StdBattleTextBox
ld a, [hBattleTurn] ld a, [hBattleTurn]
and a and a
@ -6874,7 +6871,7 @@ Function3ebc7: ; 3ebc7
ret ret
; 3ebd8 ; 3ebd8
Function3ebd8: ; 3ebd8 BattleWinSlideInEnemyTrainerFrontpic: ; 3ebd8
xor a xor a
ld [TempEnemyMonSpecies], a ld [TempEnemyMonSpecies], a
call FinishBattleAnim call FinishBattleAnim
@ -6883,12 +6880,12 @@ Function3ebd8: ; 3ebd8
ld de, VTiles2 ld de, VTiles2
callab GetTrainerPic callab GetTrainerPic
hlcoord 19, 0 hlcoord 19, 0
ld c, $0 ld c, 0
.outer_loop .outer_loop
inc c inc c
ld a, c ld a, c
cp $7 cp 7
ret z ret z
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
@ -6898,9 +6895,9 @@ Function3ebd8: ; 3ebd8
push hl push hl
.inner_loop .inner_loop
call Function3ec1a call .CopyColumn
inc hl inc hl
ld a, $7 ld a, 7
add d add d
ld d, a ld d, a
dec c dec c
@ -6908,7 +6905,7 @@ Function3ebd8: ; 3ebd8
ld a, $1 ld a, $1
ld [hBGMapMode], a ld [hBGMapMode], a
ld c, $4 ld c, 4
call DelayFrames call DelayFrames
pop hl pop hl
pop bc pop bc
@ -6916,11 +6913,11 @@ Function3ebd8: ; 3ebd8
jr .outer_loop jr .outer_loop
; 3ec1a ; 3ec1a
Function3ec1a: ; 3ec1a .CopyColumn: ; 3ec1a
push hl push hl
push de push de
push bc push bc
ld e, $7 ld e, 7
.loop .loop
ld [hl], d ld [hl], d
@ -6970,7 +6967,7 @@ ApplyPrzEffectOnSpeed: ; 3ec39
ld [hli], a ld [hli], a
or b or b
jr nz, .player_ok jr nz, .player_ok
ld b, $1 ld b, $1 ; min speed
.player_ok .player_ok
ld [hl], b ld [hl], b
@ -6991,7 +6988,7 @@ ApplyPrzEffectOnSpeed: ; 3ec39
ld [hli], a ld [hli], a
or b or b
jr nz, .enemy_ok jr nz, .enemy_ok
ld b, $1 ld b, $1 ; min speed
.enemy_ok .enemy_ok
ld [hl], b ld [hl], b
@ -7014,7 +7011,7 @@ ApplyBrnEffectOnAttack: ; 3ec76
ld [hli], a ld [hli], a
or b or b
jr nz, .player_ok jr nz, .player_ok
ld b, $1 ld b, $1 ; min attack
.player_ok .player_ok
ld [hl], b ld [hl], b
@ -7033,7 +7030,7 @@ ApplyBrnEffectOnAttack: ; 3ec76
ld [hli], a ld [hli], a
or b or b
jr nz, .enemy_ok jr nz, .enemy_ok
ld b, $1 ld b, $1 ; min attack
.enemy_ok .enemy_ok
ld [hl], b ld [hl], b
@ -7423,6 +7420,7 @@ GiveExperiencePoints: ; 3ee3b
and a and a
pop bc pop bc
jp z, .skip_stats jp z, .skip_stats
ld hl, MON_STAT_EXP + 1 ld hl, MON_STAT_EXP + 1
add hl, bc add hl, bc
ld d, h ld d, h
@ -7767,35 +7765,37 @@ endr
; 3f0d4 ; 3f0d4
Function3f0d4: ; 3f0d4 Function3f0d4: ; 3f0d4
; count number of battle participants
ld a, [wBattleParticipantsNotFainted] ld a, [wBattleParticipantsNotFainted]
ld b, a ld b, a
ld c, $6 ld c, PARTY_LENGTH
ld d, $0 ld d, 0
.asm_3f0dc .loop
xor a xor a
srl b srl b
adc d adc d
ld d, a ld d, a
dec c dec c
jr nz, .asm_3f0dc jr nz, .loop
cp $2 cp 2
ret c ret c
ld [wd265], a ld [wd265], a
ld hl, EnemyMonBaseStats ld hl, EnemyMonBaseStats
ld c, $7 ld c, EnemyMonEnd - EnemyMonBaseStats
.asm_3f0ef .loop2
xor a xor a
ld [hDividend + 0], a ld [hDividend + 0], a
ld a, [hl] ld a, [hl]
ld [hDividend + 1], a ld [hDividend + 1], a
ld a, [wd265] ld a, [wd265]
ld [hDivisor], a ld [hDivisor], a
ld b, $2 ld b, 2
call Divide call Divide
ld a, [hQuotient + 2] ld a, [hQuotient + 2]
ld [hli], a ld [hli], a
dec c dec c
jr nz, .asm_3f0ef jr nz, .loop2
ret ret
; 3f106 ; 3f106
@ -7941,12 +7941,12 @@ endr
call PrintPlayerHUD call PrintPlayerHUD
ld hl, BattleMonNick ld hl, BattleMonNick
ld de, StringBuffer1 ld de, StringBuffer1
ld bc, $000b ld bc, PKMN_NAME_LENGTH
call CopyBytes call CopyBytes
call Function3dfe call Function3dfe
ld de, SFX_HIT_END_OF_EXP_BAR ld de, SFX_HIT_END_OF_EXP_BAR
call PlaySFX call PlaySFX
callba Function8e79d callba AnimateEndOfExpBar
call WaitSFX call WaitSFX
ld hl, BattleText_StringBuffer1GrewToLevel ld hl, BattleText_StringBuffer1GrewToLevel
call StdBattleTextBox call StdBattleTextBox
@ -8481,7 +8481,7 @@ StartBattle: ; 3f4c1
ld a, [TimeOfDayPal] ld a, [TimeOfDayPal]
push af push af
call BattleIntro call BattleIntro
call SendOutFirstMons call DoBattle
call ExitBattle call ExitBattle
pop af pop af
ld [TimeOfDayPal], a ld [TimeOfDayPal], a
@ -8490,9 +8490,9 @@ StartBattle: ; 3f4c1
; 3f4d9 ; 3f4d9
_SendOutFirstMons: ; 3f4d9 _DoBattle: ; 3f4d9
; unreferenced ; unreferenced
call SendOutFirstMons call DoBattle
ret ret
; 3f4dd ; 3f4dd
@ -8586,7 +8586,7 @@ InitEnemyTrainer: ; 3f594
callba MobileFn_10606a callba MobileFn_10606a
xor a xor a
ld [TempEnemyMonSpecies], a ld [TempEnemyMonSpecies], a
callab Function3957b callab GetTrainerAttributes
callab ReadTrainerParty callab ReadTrainerParty
ld a, [TrainerClass] ld a, [TrainerClass]
@ -8746,7 +8746,7 @@ Function3f6a5: ; 3f6a5
ret nz ret nz
call CheckPayDay call CheckPayDay
xor a xor a
ld [wd1e9], a ld [wForceEvolution], a
predef EvolveAfterBattle predef EvolveAfterBattle
callba Function2ed44 callba Function2ed44
ret ret
@ -9427,7 +9427,7 @@ InitBattleDisplay: ; 3fb6c
call WaitBGMap call WaitBGMap
xor a xor a
ld [hBGMapMode], a ld [hBGMapMode], a
callba SlideBattlePics callba BattleIntroSlidingPics
ld a, $1 ld a, $1
ld [hBGMapMode], a ld [hBGMapMode], a
ld a, $31 ld a, $31

View File

@ -7496,14 +7496,14 @@ endr
ld a, BATTLE_VARS_MOVE_EFFECT ld a, BATTLE_VARS_MOVE_EFFECT
call GetBattleVar call GetBattleVar
cp EFFECT_CONFUSE_HIT cp EFFECT_CONFUSE_HIT
jr z, .asm_36d99 jr z, .got_effect
cp EFFECT_SNORE cp EFFECT_SNORE
jr z, .asm_36d99 jr z, .got_effect
cp EFFECT_SWAGGER cp EFFECT_SWAGGER
jr z, .asm_36d99 jr z, .got_effect
call AnimateCurrentMove call AnimateCurrentMove
.asm_36d99 .got_effect
ld de, ANIM_CONFUSED ld de, ANIM_CONFUSED
call PlayOpponentBattleAnim call PlayOpponentBattleAnim
@ -7513,11 +7513,11 @@ endr
call GetOpponentItem call GetOpponentItem
ld a, b ld a, b
cp HELD_HEAL_STATUS cp HELD_HEAL_STATUS
jr z, .asm_36db0 jr z, .heal_confusion
cp HELD_HEAL_CONFUSION cp HELD_HEAL_CONFUSION
ret nz ret nz
.asm_36db0 .heal_confusion
ld hl, HandleStatusHealingItem ld hl, UseConfusionHealingItem
jp CallBattleCore jp CallBattleCore
; 36db6 ; 36db6

View File

@ -1,4 +1,4 @@
SlideBattlePics: ; 4e980 BattleIntroSlidingPics: ; 4e980
ld a, [rSVBK] ld a, [rSVBK]
push af push af
ld a, $5 ld a, $5

View File

@ -639,8 +639,8 @@ const_value = 0
const TRNATTR_ITEM1 const TRNATTR_ITEM1
const TRNATTR_ITEM2 const TRNATTR_ITEM2
const TRNATTR_BASEMONEY const TRNATTR_BASEMONEY
const TRNATTR_AI1 const TRNATTR_AI_MOVE_WEIGHTS
const TRNATTR_AI2 const TRNATTR_AI2
const TRNATTR_AI3 const TRNATTR_AI_ITEM_SWITCH
const TRNATTR_AI4 const TRNATTR_AI4
NUM_TRAINER_ATTRIBUTES EQU const_value NUM_TRAINER_ATTRIBUTES EQU const_value

View File

@ -678,7 +678,7 @@ Function1727f: ; 1727f (5:727f)
push hl push hl
push de push de
push bc push bc
callab Function8cf69 callab PlaySpriteAnimations
call DelayFrame call DelayFrame
pop bc pop bc
pop de pop de
@ -789,9 +789,9 @@ Function1736d: ; 1736d (5:736d)
ret nc ret nc
swap a swap a
srl a srl a
add $4c add 9 * 8 + 4
ld d, a ld d, a
ld e, $58 ld e, 11 * 8
ld a, SPRITE_ANIM_INDEX_19 ld a, SPRITE_ANIM_INDEX_19
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, $3 ld hl, $3
@ -807,10 +807,10 @@ INCBIN "gfx/unknown/017393.2bpp"
Function173b3: ; 173b3 (5:73b3) Function173b3: ; 173b3 (5:73b3)
callba Function8cf53 callba Function8cf53
ld hl, Unknown_173ef ld hl, .SpriteData
.loop .loop
ld a, [hli] ld a, [hli]
cp $ff cp -1
jr z, .done jr z, .done
ld e, a ld e, a
ld a, [hli] ld a, [hli]
@ -823,16 +823,16 @@ Function173b3: ; 173b3 (5:73b3)
push bc push bc
ld a, SPRITE_ANIM_INDEX_1C ld a, SPRITE_ANIM_INDEX_1C
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, $3 ld hl, SpriteAnim1TileID - SpriteAnim1
add hl, bc add hl, bc
ld [hl], $0 ld [hl], $0
pop de pop de
ld a, e ld a, e
ld hl, $1 ld hl, SpriteAnim1Sprite01 - SpriteAnim1
add hl, bc add hl, bc
add [hl] add [hl]
ld [hl], a ld [hl], a
ld hl, $b ld hl, SpriteAnim1Sprite0b - SpriteAnim1
add hl, bc add hl, bc
ld [hl], d ld [hl], d
pop hl pop hl
@ -844,19 +844,19 @@ Function173b3: ; 173b3 (5:73b3)
ret ret
; 173ef (5:73ef) ; 173ef (5:73ef)
Unknown_173ef: ; 173ef .SpriteData: ; 173ef
; Probably OAM. ; Probably OAM.
db $54, $48, $00, $3c dsprite 10, 4, 9, 0, $00, $3c
db $5c, $48, $01, $04 dsprite 11, 4, 9, 0, $01, $04
db $54, $50, $00, $30 dsprite 10, 4, 10, 0, $00, $30
db $5c, $50, $01, $10 dsprite 11, 4, 10, 0, $01, $10
db $54, $58, $02, $24 dsprite 10, 4, 11, 0, $02, $24
db $5c, $58, $03, $1c dsprite 11, 4, 11, 0, $03, $1c
db $50, $4c, $00, $36 dsprite 10, 0, 9, 4, $00, $36
db $60, $4c, $01, $0a dsprite 12, 0, 9, 4, $01, $0a
db $50, $54, $02, $2a dsprite 10, 0, 10, 4, $02, $2a
db $60, $54, $03, $16 dsprite 12, 0, 10, 4, $03, $16
db $ff db -1
; 17418 ; 17418
Function17418: ; 17418 (5:7418) Function17418: ; 17418 (5:7418)

View File

@ -52,7 +52,7 @@ Functione4579: ; e4579
bit 7, a bit 7, a
jr nz, .finish jr nz, .finish
call PlaceGameFreakPresents call PlaceGameFreakPresents
callba Function8cf69 callba PlaySpriteAnimations
call DelayFrame call DelayFrame
jr .joy_loop jr .joy_loop
@ -406,7 +406,7 @@ CrystalIntro: ; e48ac
bit 7, a bit 7, a
jr nz, .done jr nz, .done
call IntroSceneJumper call IntroSceneJumper
callba Function8cf69 callba PlaySpriteAnimations
call DelayFrame call DelayFrame
jp .loop jp .loop

View File

@ -425,7 +425,7 @@ Function81adb: ; 81adb
.asm_81b7a .asm_81b7a
ld a, [wd265] ld a, [wd265]
ld [TrainerClass], a ld [TrainerClass], a
callab Function3957b callab GetTrainerAttributes
ld de, StringBuffer1 ld de, StringBuffer1
hlcoord 4, 1 hlcoord 4, 1
call PlaceString call PlaceString

View File

@ -47,7 +47,7 @@ Functione1ebb: ; e1ebb (38:5ebb)
bit 7, a bit 7, a
jr nz, .asm_e1ed0 jr nz, .asm_e1ed0
call Functione1ed2 call Functione1ed2
callab Function8cf69 callab PlaySpriteAnimations
call DelayFrame call DelayFrame
and a and a
ret ret
@ -89,7 +89,7 @@ Functione1ef3: ; e1ef3
; e1efb ; e1efb
Functione1efb: ; e1efb Functione1efb: ; e1efb
call Functione00ed call ret_e00ed
jr nc, .asm_e1f06 jr nc, .asm_e1f06
ld hl, wJumptableIndex ld hl, wJumptableIndex
set 7, [hl] set 7, [hl]
@ -251,7 +251,7 @@ Functione1fcc: ; e1fcc
inc [hl] inc [hl]
Functione2000: ; e2000 Functione2000: ; e2000
call Functione00ed call ret_e00ed
jr nc, .asm_e200b jr nc, .asm_e200b
ld hl, wJumptableIndex ld hl, wJumptableIndex
set 7, [hl] set 7, [hl]

View File

@ -491,11 +491,11 @@ endr
bit 3, [hl] bit 3, [hl]
jr z, .nope jr z, .nope
ld hl, ScriptDelay + 2 ld hl, wPriorityScriptAddr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld a, [ScriptDelay + 1] ld a, [wPriorityScriptBank]
call CallScript call CallScript
scf scf
ret ret

View File

@ -21,7 +21,7 @@ EvolutionAnimation: ; 4e5e1
pop de pop de
pop hl pop hl
ld a, [wd1ed] ld a, [Buffer4]
and a and a
ret z ret z
@ -99,7 +99,7 @@ _EvolutionAnimation: ; 4e607
call .ReplaceFrontpic call .ReplaceFrontpic
xor a xor a
ld [wd1ed], a ld [Buffer4], a
ld a, [Buffer2] ld a, [Buffer2]
ld [PlayerHPPal], a ld [PlayerHPPal], a
@ -136,7 +136,7 @@ _EvolutionAnimation: ; 4e607
.cancel_evo .cancel_evo
ld a, $1 ld a, $1
ld [wd1ed], a ld [Buffer4], a
ld a, [Buffer1] ld a, [Buffer1]
ld [PlayerHPPal], a ld [PlayerHPPal], a
@ -252,7 +252,7 @@ endr
ret ret
.pressed_b .pressed_b
ld a, [wd1e9] ld a, [wForceEvolution]
and a and a
jr nz, .loop3 jr nz, .loop3
scf scf
@ -270,7 +270,7 @@ Function4e794: ; 4e794
; 4e7a6 ; 4e7a6
Function4e7a6: ; 4e7a6 Function4e7a6: ; 4e7a6
ld a, [wd1ed] ld a, [Buffer4]
and a and a
ret nz ret nz
ld de, SFX_EVOLVED ld de, SFX_EVOLVED
@ -286,7 +286,7 @@ Function4e7a6: ; 4e7a6
jr .loop jr .loop
.done .done
ld c, $20 ld c, 32
.loop2 .loop2
call Function4e80c call Function4e80c
dec c dec c
@ -299,7 +299,7 @@ Function4e7a6: ; 4e7a6
Function4e7cf: ; 4e7cf Function4e7cf: ; 4e7cf
ld hl, wJumptableIndex ld hl, wJumptableIndex
ld a, [hl] ld a, [hl]
cp $20 cp 32
ret nc ret nc
ld d, a ld d, a
inc [hl] inc [hl]
@ -317,8 +317,8 @@ Function4e7cf: ; 4e7cf
Function4e7e8: ; 4e7e8 Function4e7e8: ; 4e7e8
push de push de
lb de, $48, $58 depixel 9, 11
ld a, $13 ld a, SPRITE_ANIM_INDEX_13
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, $b ld hl, $b
add hl, bc add hl, bc
@ -339,7 +339,7 @@ Function4e7e8: ; 4e7e8
Function4e80c: ; 4e80c Function4e80c: ; 4e80c
push bc push bc
callab Function8cf69 callab PlaySpriteAnimations
; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES ; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
ld a, [hVBlankCounter] ld a, [hVBlankCounter]
and $e and $e
@ -369,88 +369,3 @@ endr
EvolutionGFX: EvolutionGFX:
INCBIN "gfx/evo/bubble_large.2bpp" INCBIN "gfx/evo/bubble_large.2bpp"
INCBIN "gfx/evo/bubble.2bpp" INCBIN "gfx/evo/bubble.2bpp"
Function4e881: ; 4e881
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call DisableLCD
call LoadStandardFont
call LoadFontsBattleExtra
hlbgcoord 0, 0
ld bc, VBGMap1 - VBGMap0
ld a, " "
call ByteFill
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
xor a
ld [hSCY], a
ld [hSCX], a
call EnableLCD
ld hl, .SavingRecordDontTurnOff
call PrintText
call Function3200
call SetPalettes
ret
; 4e8bd
.SavingRecordDontTurnOff: ; 0x4e8bd
; SAVING RECORD… DON'T TURN OFF!
text_jump UnknownText_0x1bd39e
db "@"
; 0x4e8c2
Function4e8c2: ; 4e8c2
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call DisableLCD
call LoadStandardFont
call LoadFontsBattleExtra
hlbgcoord 0, 0
ld bc, VBGMap1 - VBGMap0
ld a, " "
call ByteFill
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
ld hl, wd000 ; UnknBGPals
ld c, 4 * $10
.load_white_palettes
ld a, (palred 31 + palgreen 31 + palblue 31) % $100
ld [hli], a
ld a, (palred 31 + palgreen 31 + palblue 31) / $100
ld [hli], a
dec c
jr nz, .load_white_palettes
xor a
ld [hSCY], a
ld [hSCX], a
call EnableLCD
call Function3200
call SetPalettes
ret
; 4e906
Function4e906: ; 4e906
ld a, [rSVBK]
push af
ld a, $6
ld [rSVBK], a
ld hl, w6_d000
ld bc, w6_d400 - w6_d000
ld a, " "
call ByteFill
hlbgcoord 0, 0
ld de, w6_d000
ld b, $0
ld c, $40
call Request2bpp
pop af
ld [rSVBK], a
ret
; 4e929

View File

@ -78,7 +78,7 @@ endr
cp EVOLVE_ITEM cp EVOLVE_ITEM
jp z, .item jp z, .item
ld a, [wd1e9] ld a, [wForceEvolution]
and a and a
jp nz, .dont_evolve_2 jp nz, .dont_evolve_2
@ -179,7 +179,7 @@ endr
cp b cp b
jp nz, .dont_evolve_3 jp nz, .dont_evolve_3
ld a, [wd1e9] ld a, [wForceEvolution]
and a and a
jp z, .dont_evolve_3 jp z, .dont_evolve_3
ld a, [wLinkMode] ld a, [wLinkMode]

257
engine/learn.asm Executable file
View File

@ -0,0 +1,257 @@
LearnMove: ; 6508
call LoadTileMapToTempTileMap
ld a, [CurPartyMon]
ld hl, PartyMonNicknames
call GetNick
ld hl, StringBuffer1
ld de, wd050_MonNick
ld bc, PKMN_NAME_LENGTH
call CopyBytes
.loop
ld hl, PartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld d, h
ld e, l
ld b, NUM_MOVES
; Get the first empty move slot. This routine also serves to
; determine whether the Pokemon learning the moves already has
; all four slots occupied, in which case one would need to be
; deleted.
.next
ld a, [hl]
and a
jr z, .learn
inc hl
dec b
jr nz, .next
; If we're here, we enter the routine for forgetting a move
; to make room for the new move we're trying to learn.
push de
call ForgetMove
pop de
jp c, .cancel
push hl
push de
ld [wd265], a
ld b, a
ld a, [wBattleMode]
and a
jr z, .not_disabled
ld a, [DisabledMove]
cp b
jr nz, .not_disabled
xor a
ld [DisabledMove], a
ld [PlayerDisableCount], a
.not_disabled
call GetMoveName
ld hl, UnknownText_0x6684 ; 1, 2 and…
call PrintText
pop de
pop hl
.learn
ld a, [wd262]
ld [hl], a
ld bc, MON_PP - MON_MOVES
add hl, bc
push hl
push de
dec a
ld hl, Moves + MOVE_PP
ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
pop de
pop hl
ld [hl], a
ld a, [wBattleMode]
and a
jp z, .learned
ld a, [CurPartyMon]
ld b, a
ld a, [CurBattleMon]
cp b
jp nz, .learned
ld a, [PlayerSubStatus5]
bit SUBSTATUS_TRANSFORMED, a
jp nz, .learned
ld h, d
ld l, e
ld de, BattleMonMoves
ld bc, NUM_MOVES
call CopyBytes
ld bc, PartyMon1PP - (PartyMon1Moves + NUM_MOVES)
add hl, bc
ld de, BattleMonPP
ld bc, NUM_MOVES
call CopyBytes
jp .learned
.cancel
ld hl, UnknownText_0x6675 ; Stop learning <MOVE>?
call PrintText
call YesNoBox
jp c, .loop
ld hl, UnknownText_0x667a ; <MON> did not learn <MOVE>.
call PrintText
ld b, 0
ret
.learned
ld hl, UnknownText_0x666b ; <MON> learned <MOVE>!
call PrintText
ld b, 1
ret
; 65d3
ForgetMove: ; 65d3
push hl
ld hl, UnknownText_0x667f
call PrintText
call YesNoBox
pop hl
ret c
ld bc, -NUM_MOVES
add hl, bc
push hl
ld de, wListMoves_MoveIndicesBuffer
ld bc, NUM_MOVES
call CopyBytes
pop hl
.loop
push hl
ld hl, UnknownText_0x6670
call PrintText
hlcoord 5, 2
ld b, NUM_MOVES * 2
ld c, MOVE_NAME_LENGTH
call TextBox
hlcoord 5 + 2, 2 + 2
ld a, SCREEN_WIDTH * 2
ld [Buffer1], a
predef ListMoves
; wMenuData3
ld a, $4
ld [wcfa1], a
ld a, $6
ld [wcfa2], a
ld a, [wd0eb]
inc a
ld [wcfa3], a
ld a, $1
ld [wcfa4], a
ld [MenuSelection2], a
ld [wcfaa], a
ld a, $3
ld [wcfa8], a
ld a, $20
ld [wcfa5], a
xor a
ld [wcfa6], a
ld a, $20
ld [wcfa7], a
call Function1bc9
push af
call Call_LoadTempTileMapToTileMap
pop af
pop hl
bit 1, a
jr nz, .cancel
push hl
ld a, [MenuSelection2]
dec a
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
push af
push bc
call IsHMMove
pop bc
pop de
ld a, d
jr c, .hmmove
pop hl
add hl, bc
and a
ret
.hmmove
ld hl, UnknownText_0x669a
call PrintText
pop hl
jr .loop
.cancel
scf
ret
; 666b
UnknownText_0x666b: ; 666b
; <MON> learned <MOVE>!
text_jump UnknownText_0x1c5660
db "@"
; 6670
UnknownText_0x6670: ; 6670
; Which move should be forgotten?
text_jump UnknownText_0x1c5678
db "@"
; 6675
UnknownText_0x6675: ; 6675
; Stop learning <MOVE>?
text_jump UnknownText_0x1c5699
db "@"
; 667a
UnknownText_0x667a: ; 667a
; <MON> did not learn <MOVE>.
text_jump UnknownText_0x1c56af
db "@"
; 667f
UnknownText_0x667f: ; 667f
; <MON> is trying to learn <MOVE>. But <MON> can't learn more than
; four moves. Delete an older move to make room for <MOVE>?
text_jump UnknownText_0x1c56c9
db "@"
; 6684
UnknownText_0x6684: ; 6684
text_jump UnknownText_0x1c5740 ; 1, 2 and…
start_asm
push de
ld de, SFX_SWITCH_POKEMON
call PlaySFX
pop de
ld hl, UnknownText_0x6695
ret
; 6695
UnknownText_0x6695: ; 6695
; Poof! <MON> forgot <MOVE>. And…
text_jump UnknownText_0x1c574e
db "@"
; 669a
UnknownText_0x669a: ; 669a
; HM moves can't be forgotten now.
text_jump UnknownText_0x1c5772
db "@"
; 669f

View File

@ -1891,7 +1891,7 @@ Function28b87: ; 28b87
dec a dec a
ld [CurPartyMon], a ld [CurPartyMon], a
ld a, $1 ld a, $1
ld [wd1e9], a ld [wForceEvolution], a
ld a, [wd003] ld a, [wd003]
push af push af
ld hl, OTPartySpecies ld hl, OTPartySpecies

196
engine/math.asm Executable file
View File

@ -0,0 +1,196 @@
_Multiply:: ; 66de
; hMultiplier is one byte.
ld a, 8
ld b, a
xor a
ld [hProduct], a
ld [hMathBuffer + 1], a
ld [hMathBuffer + 2], a
ld [hMathBuffer + 3], a
ld [hMathBuffer + 4], a
.loop
ld a, [hMultiplier]
srl a
ld [hMultiplier], a
jr nc, .next
ld a, [hMathBuffer + 4]
ld c, a
ld a, [hMultiplicand + 2]
add c
ld [hMathBuffer + 4], a
ld a, [hMathBuffer + 3]
ld c, a
ld a, [hMultiplicand + 1]
adc c
ld [hMathBuffer + 3], a
ld a, [hMathBuffer + 2]
ld c, a
ld a, [hMultiplicand + 0]
adc c
ld [hMathBuffer + 2], a
ld a, [hMathBuffer + 1]
ld c, a
ld a, [hProduct]
adc c
ld [hMathBuffer + 1], a
.next
dec b
jr z, .done
; hMultiplicand <<= 1
ld a, [hMultiplicand + 2]
add a
ld [hMultiplicand + 2], a
ld a, [hMultiplicand + 1]
rla
ld [hMultiplicand + 1], a
ld a, [hMultiplicand + 0]
rla
ld [hMultiplicand + 0], a
ld a, [hProduct]
rla
ld [hProduct], a
jr .loop
.done
ld a, [hMathBuffer + 4]
ld [hProduct + 3], a
ld a, [hMathBuffer + 3]
ld [hProduct + 2], a
ld a, [hMathBuffer + 2]
ld [hProduct + 1], a
ld a, [hMathBuffer + 1]
ld [hProduct + 0], a
ret
; 673e
_Divide:: ; 673e
xor a
ld [hMathBuffer + 0], a
ld [hMathBuffer + 1], a
ld [hMathBuffer + 2], a
ld [hMathBuffer + 3], a
ld [hMathBuffer + 4], a
ld a, 9
ld e, a
.loop
ld a, [hMathBuffer + 0]
ld c, a
ld a, [hDividend + 1]
sub c
ld d, a
ld a, [hDivisor]
ld c, a
ld a, [hDividend + 0]
sbc c
jr c, .next
ld [hDividend + 0], a
ld a, d
ld [hDividend + 1], a
ld a, [hMathBuffer + 4]
inc a
ld [hMathBuffer + 4], a
jr .loop
.next
ld a, b
cp 1
jr z, .done
ld a, [hMathBuffer + 4]
add a
ld [hMathBuffer + 4], a
ld a, [hMathBuffer + 3]
rla
ld [hMathBuffer + 3], a
ld a, [hMathBuffer + 2]
rla
ld [hMathBuffer + 2], a
ld a, [hMathBuffer + 1]
rla
ld [hMathBuffer + 1], a
dec e
jr nz, .next2
ld e, 8
ld a, [hMathBuffer + 0]
ld [hDivisor], a
xor a
ld [hMathBuffer + 0], a
ld a, [hDividend + 1]
ld [hDividend + 0], a
ld a, [hDividend + 2]
ld [hDividend + 1], a
ld a, [hDividend + 3]
ld [hDividend + 2], a
.next2
ld a, e
cp 1
jr nz, .okay
dec b
.okay
ld a, [hDivisor]
srl a
ld [hDivisor], a
ld a, [hMathBuffer + 0]
rr a
ld [hMathBuffer + 0], a
jr .loop
.done
ld a, [hDividend + 1]
ld [hDivisor], a
ld a, [hMathBuffer + 4]
ld [hDividend + 3], a
ld a, [hMathBuffer + 3]
ld [hDividend + 2], a
ld a, [hMathBuffer + 2]
ld [hDividend + 1], a
ld a, [hMathBuffer + 1]
ld [hDividend + 0], a
ret
; 67c1

View File

@ -670,7 +670,7 @@ InitPartyMenuGFX: ; 503e0
pop bc pop bc
dec c dec c
jr nz, .loop jr nz, .loop
callab Function8cf69 callab PlaySpriteAnimations
ret ret
; 50405 ; 50405

View File

@ -323,7 +323,7 @@ Function40217: ; 40217 (10:4217)
call Function4134f call Function4134f
call Function40bb1 call Function40bb1
ld [wc2d6], a ld [wc2d6], a
callba Function4424d callba DisplayDexEntry
call Function40ba0 call Function40ba0
call WaitBGMap call WaitBGMap
ld a, $a7 ld a, $a7
@ -378,7 +378,7 @@ Function40292: ; 40292
ld [wPokedexStatus], a ld [wPokedexStatus], a
call Function40bb1 call Function40bb1
ld [wc2d6], a ld [wc2d6], a
callba Function4424d callba DisplayDexEntry
call WaitBGMap call WaitBGMap
ret ret
; 402aa ; 402aa
@ -394,7 +394,7 @@ Function402aa: ; 402aa (10:42aa)
call Function41478 call Function41478
call Function40bb1 call Function40bb1
ld [wc2d6], a ld [wc2d6], a
callba Function4424d callba DisplayDexEntry
call Function40ba0 call Function40ba0
call Function4143b call Function4143b
call WaitBGMap call WaitBGMap
@ -498,7 +498,7 @@ Function4034f: ; 4034f
Function4038d: ; 4038d Function4038d: ; 4038d
call Function407fd call Function407fd
call Function40bb1 call Function40bb1
callba Function4424d callba DisplayDexEntry
call Function40ba0 call Function40ba0
ret ret
; 4039d ; 4039d
@ -621,8 +621,8 @@ Function40443: ; 40443 (10:4443)
ld [wc7d6], a ld [wc7d6], a
call Function40fa8 call Function40fa8
xor a xor a
ld [wc7db], a ld [wDexSearchSlowpokeFrame], a
callba Function44207 callba DoDexSearchSlowpokeFrame
call WaitBGMap call WaitBGMap
ld a, $10 ld a, $10
call Function41423 call Function41423
@ -679,7 +679,7 @@ Function404b0: ; 404b0
Function404b7: ; 404b7 Function404b7: ; 404b7
call Function41086 call Function41086
callba Function441cf callba AnimateDexSearchSlowpoke
ld a, [wc7d7] ld a, [wc7d7]
and a and a
jr nz, .asm_404dc jr nz, .asm_404dc
@ -2557,7 +2557,6 @@ Function41a2c: ; 41a2c
ret ret
; 41a58 ; 41a58
Function41a58: ; 41a58 (10:5a58) Function41a58: ; 41a58 (10:5a58)
ld a, [UnownLetter] ld a, [UnownLetter]
push af push af
@ -2576,3 +2575,68 @@ Function41a58: ; 41a58 (10:5a58)
pop af pop af
ld [UnownLetter], a ld [UnownLetter], a
ret ret
; 41a7f
Function41a7f: ; 41a7f
xor a
ld [hBGMapMode], a
callba Function1de247
call Function41af7
call DisableLCD
call LoadStandardFont
call LoadFontsExtra
call Function414b7
call Function4147b
ld a, [wd265]
ld [CurPartySpecies], a
call Function407fd
call Function40ba0
hlcoord 0, 17
ld [hl], $3b
inc hl
ld bc, $13
ld a, " "
call ByteFill
callba DisplayDexEntry
call EnableLCD
call WaitBGMap
call GetBaseData
ld de, VTiles2
predef GetFrontpic
ld a, $4
call Function41423
ld a, [CurPartySpecies]
call PlayCry
ret
; 41ad7
Function41ad7: ; 41ad7 (10:5ad7)
ld a, $3
ld [hBGMapMode], a
ld c, 4
call DelayFrames
ret
Function41ae1: ; 41ae1 (10:5ae1)
ld a, $4
ld [hBGMapMode], a
ld c, 4
call DelayFrames
ret
Function41aeb: ; 41aeb (10:5aeb)
ld a, [hCGB]
and a
jr z, .asm_41af3
call Function41ae1
.asm_41af3
call Function41ad7
ret
Function41af7: ; 41af7
xor a
ld [hBGMapMode], a
ret
; 41afb

View File

@ -24,7 +24,7 @@ PokeGear: ; 90b8d (24:4b8d)
bit 7, a bit 7, a
jr nz, .done jr nz, .done
call Function90f04 call Function90f04
callba Function8cf69 callba PlaySpriteAnimations
call DelayFrame call DelayFrame
jr .loop jr .loop
@ -1966,7 +1966,7 @@ _FlyMap: ; 91af3
jr nz, .pressedA jr nz, .pressedA
call FlyMapScroll call FlyMapScroll
call GetMapCursorCoordinates call GetMapCursorCoordinates
callba Function8cf69 callba PlaySpriteAnimations
call DelayFrame call DelayFrame
jr .loop jr .loop
@ -2901,7 +2901,7 @@ Function92311: ; unreferenced
jr nz, .pressedA jr nz, .pressedA
call Function923b8 call Function923b8
call GetMapCursorCoordinates call GetMapCursorCoordinates
callba Function8cf69 callba PlaySpriteAnimations
call DelayFrame call DelayFrame
jr .loop jr .loop

View File

@ -672,7 +672,7 @@ PrintDexEntry: ; 8442c
call Function84000 call Function84000
ld a, $10 ld a, $10
ld [wcbfa], a ld [wcbfa], a
callba Function1dc1b0 callba PrintPage1
call ClearTileMap call ClearTileMap
ld a, $e4 ld a, $e4
call DmgToCgbBGPals call DmgToCgbBGPals
@ -694,7 +694,7 @@ PrintDexEntry: ; 8442c
call Function84000 call Function84000
ld a, $3 ld a, $3
ld [wcbfa], a ld [wcbfa], a
callba Function1dc213 callba PrintPage2
call Function84742 call Function84742
ld a, $4 ld a, $4
ld [wcf65], a ld [wcf65], a

View File

@ -316,11 +316,11 @@ Script_jumptextfaceplayer: ; 96e45
; text_pointer (RawTextPointerLabelParam) ; text_pointer (RawTextPointerLabelParam)
ld a, [ScriptBank] ld a, [ScriptBank]
ld [wd44e], a ld [wScriptTextBank], a
call GetScriptByte call GetScriptByte
ld [wd44f], a ld [wScriptTextAddr], a
call GetScriptByte call GetScriptByte
ld [wd450], a ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextFacePlayerScript) ld b, BANK(JumpTextFacePlayerScript)
ld hl, JumpTextFacePlayerScript ld hl, JumpTextFacePlayerScript
jp ScriptJump jp ScriptJump
@ -332,11 +332,11 @@ Script_jumptext: ; 96e5f
; text_pointer (RawTextPointerLabelParam) ; text_pointer (RawTextPointerLabelParam)
ld a, [ScriptBank] ld a, [ScriptBank]
ld [wd44e], a ld [wScriptTextBank], a
call GetScriptByte call GetScriptByte
ld [wd44f], a ld [wScriptTextAddr], a
call GetScriptByte call GetScriptByte
ld [wd450], a ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextScript) ld b, BANK(JumpTextScript)
ld hl, JumpTextScript ld hl, JumpTextScript
jp ScriptJump jp ScriptJump
@ -361,11 +361,11 @@ Script_farjumptext: ; 96e81
; text_pointer (PointerLabelBeforeBank) ; text_pointer (PointerLabelBeforeBank)
call GetScriptByte call GetScriptByte
ld [wd44e], a ld [wScriptTextBank], a
call GetScriptByte call GetScriptByte
ld [wd44f], a ld [wScriptTextAddr], a
call GetScriptByte call GetScriptByte
ld [wd450], a ld [wScriptTextAddr + 1], a
ld b, BANK(JumpTextScript) ld b, BANK(JumpTextScript)
ld hl, JumpTextScript ld hl, JumpTextScript
jp ScriptJump jp ScriptJump
@ -419,7 +419,7 @@ Script_repeattext: ; 96ebb
ld a, l ld a, l
cp -1 cp -1
jr nz, .done jr nz, .done
ld hl, wd44e ld hl, wScriptTextBank
ld a, [hli] ld a, [hli]
ld b, a ld b, a
ld a, [hli] ld a, [hli]
@ -427,6 +427,7 @@ Script_repeattext: ; 96ebb
ld l, a ld l, a
call MapTextbox call MapTextbox
ret ret
.done .done
ret ret
; 96ed9 ; 96ed9
@ -1862,11 +1863,11 @@ Script_priorityjump: ; 975aa
; pointer (ScriptPointerLabelParam) ; pointer (ScriptPointerLabelParam)
ld a, [ScriptBank] ld a, [ScriptBank]
ld [wd44e], a ld [wPriorityScriptBank], a
call GetScriptByte call GetScriptByte
ld [wd44f], a ld [wPriorityScriptAddr], a
call GetScriptByte call GetScriptByte
ld [wd450], a ld [wPriorityScriptAddr + 1], a
ld hl, ScriptFlags ld hl, ScriptFlags
set 3, [hl] set 3, [hl]
ret ret
@ -3217,8 +3218,6 @@ Script_credits: ; 97bf3
; script command 0xa2 ; script command 0xa2
callba RedCredits callba RedCredits
; fallthrough
DisplayCredits: DisplayCredits:
call Script_resetfuncs call Script_resetfuncs
ld a, $3 ld a, $3

View File

@ -12,12 +12,12 @@ Function8cf53: ; 8cf53
; 8cf62 ; 8cf62
Function8cf62: ; 8cf62 Function8cf62: ; 8cf62
call Function8cf69 call PlaySpriteAnimations
call DelayFrame call DelayFrame
ret ret
; 8cf69 ; 8cf69
Function8cf69: ; 8cf69 PlaySpriteAnimations: ; 8cf69
push hl push hl
push de push de
push bc push bc
@ -35,7 +35,7 @@ Function8cf69: ; 8cf69
; 8cf7a ; 8cf7a
Function8cf7a: ; 8cf7a Function8cf7a: ; 8cf7a
ld hl, wc314 ld hl, wSpriteAnimationStructs
ld e, 10 ; There are 10 structs here. ld e, 10 ; There are 10 structs here.
.loop .loop
@ -114,10 +114,10 @@ Function8cfa8: ; 8cfa8 (23:4fa8)
ret ret
InitSpriteAnimStruct:: ; 8cfd6 InitSpriteAnimStruct:: ; 8cfd6
; Find if there's any room in the wc314 array, which is 10x16 ; Find if there's any room in the wSpriteAnimationStructs array, which is 10x16
push de push de
push af push af
ld hl, wc314 ld hl, wSpriteAnimationStructs
ld e, 10 ld e, 10
.loop .loop
ld a, [hl] ld a, [hl]
@ -221,8 +221,8 @@ Function8d036: ; 8d036
Function8d03d: ; 8d03d (23:503d) Function8d03d: ; 8d03d (23:503d)
; Clear the index field of every struct in the wc314 array. ; Clear the index field of every struct in the wSpriteAnimationStructs array.
ld hl, wc314 ld hl, wSpriteAnimationStructs
ld bc, $10 ld bc, $10
ld e, 10 ld e, 10
xor a xor a
@ -622,7 +622,7 @@ endr
dw .sixteen dw .sixteen
dw .seventeen dw .seventeen
dw .eighteen dw .eighteen
dw .nineteen dw .nineteen ; finish egg hatching animation
dw .twenty dw .twenty
dw .twentyone dw .twentyone
dw .twentytwo ; flying sprite dw .twentytwo ; flying sprite
@ -761,7 +761,7 @@ endr
ld a, [hl] ld a, [hl]
add $3 add $3
ld [hl], a ld [hl], a
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -779,7 +779,7 @@ endr
inc a inc a
ld [hl], a ld [hl], a
ld d, $2 ld d, $2
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -818,13 +818,13 @@ endr
ld a, [hl] ld a, [hl]
push af push af
push de push de
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
pop de pop de
pop af pop af
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -856,13 +856,13 @@ endr
ld a, [hl] ld a, [hl]
push af push af
push de push de
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
pop de pop de
pop af pop af
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -947,14 +947,14 @@ endr
.asm_8d462 .asm_8d462
ld a, e ld a, e
ld d, $20 ld d, $20
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
ret ret
.thirteen: ; 8d46e (23:546e) .thirteen: ; 8d46e (23:546e)
callab Functione00ed callab ret_e00ed
ret ret
.fifteen: ; 8d475 (23:5475) .fifteen: ; 8d475 (23:5475)
@ -1014,7 +1014,7 @@ endr
jr c, .asm_8d4cd jr c, .asm_8d4cd
dec [hl] dec [hl]
ld d, $28 ld d, $28
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1049,7 +1049,7 @@ endr
ld hl, $c ld hl, $c
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
call Function8e72c call ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1108,33 +1108,36 @@ endr
ret ret
.nineteen: ; 8d54a (23:554a) .nineteen: ; 8d54a (23:554a)
ld hl, $c ld hl, SpriteAnim1Sprite0c - SpriteAnim1
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp $80 cp $80
jr nc, .asm_8d574 jr nc, .finish_nineteen
ld d, a ld d, a
add $8 add $8
ld [hl], a ld [hl], a
ld hl, $b ld hl, SpriteAnim1Sprite0b - SpriteAnim1
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
xor $20 xor $20
ld [hl], a ld [hl], a
push af push af
push de push de
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, SpriteAnim1YOffset - SpriteAnim1
add hl, bc add hl, bc
ld [hl], a ld [hl], a
pop de pop de
pop af pop af
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, SpriteAnim1XOffset - SpriteAnim1
add hl, bc add hl, bc
ld [hl], a ld [hl], a
ret ret
.asm_8d574
.finish_nineteen
call Function8d036 call Function8d036
ret ret
@ -1165,13 +1168,13 @@ rept 3
endr endr
push af push af
push de push de
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
pop de pop de
pop af pop af
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1207,7 +1210,7 @@ endr
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
inc [hl] inc [hl]
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1230,7 +1233,7 @@ endr
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
inc [hl] inc [hl]
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1263,7 +1266,7 @@ endr
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
inc [hl] inc [hl]
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1294,7 +1297,7 @@ endr
xor $ff xor $ff
inc a inc a
ld d, $20 ld d, $20
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1313,7 +1316,7 @@ endr
xor $ff xor $ff
inc a inc a
ld d, $20 ld d, $20
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1332,13 +1335,13 @@ endr
ld a, [hl] ld a, [hl]
push af push af
push de push de
call .asm_8d6de call .ApplyYOffset
ld hl, $7 ld hl, $7
add hl, bc add hl, bc
ld [hl], a ld [hl], a
pop de pop de
pop af pop af
call .asm_8d6e2 call .ApplyXOffset
ld hl, $6 ld hl, $6
add hl, bc add hl, bc
ld [hl], a ld [hl], a
@ -1393,12 +1396,12 @@ endr
ret ret
; 8d6de ; 8d6de
.asm_8d6de: ; 8d6de (23:56de) .ApplyYOffset: ; 8d6de (23:56de)
call Function8e72c call ApplyYOffset
ret ret
.asm_8d6e2: ; 8d6e2 (23:56e2) .ApplyXOffset: ; 8d6e2 (23:56e2)
call Function8e72a call ApplyXOffset
ret ret
; 8d6e6 (23:56e6) ; 8d6e6 (23:56e6)
@ -2839,17 +2842,17 @@ Unknown_8e706: ; Broken 2bpp pointers
dbbw $10, $24, $672a ; 16-tile 2bpp at 24:672a (inside Function926f7) dbbw $10, $24, $672a ; 16-tile 2bpp at 24:672a (inside Function926f7)
dbbw $10, $21, $672a ; 16-tile 2bpp at 21:672a (inside Function8671c) dbbw $10, $21, $672a ; 16-tile 2bpp at 21:672a (inside Function8671c)
Function8e72a: ; 8e72a ApplyXOffset: ; 8e72a
add $10 add $10
Function8e72c: ; 8e72c ApplyYOffset: ; 8e72c
and $3f and $3f
cp $20 cp $20
jr nc, .asm_8e737 jr nc, .xflip
call Function8e741 call Function8e741
ld a, h ld a, h
ret ret
.asm_8e737 .xflip
and $1f and $1f
call Function8e741 call Function8e741
ld a, h ld a, h
@ -2862,7 +2865,7 @@ Function8e741: ; 8e741
ld e, a ld e, a
ld a, d ld a, d
ld d, 0 ld d, 0
ld hl, Unknown_8e75d ld hl, .sinewave
rept 2 rept 2
add hl, de add hl, de
endr endr
@ -2870,54 +2873,54 @@ endr
inc hl inc hl
ld d, [hl] ld d, [hl]
ld hl, 0 ld hl, 0
.asm_8e750 .loop
srl a srl a
jr nc, .asm_8e755 jr nc, .skip_add
add hl, de add hl, de
.asm_8e755 .skip_add
sla e sla e
rl d rl d
and a and a
jr nz, .asm_8e750 jr nz, .loop
ret ret
; 8e75d ; 8e75d
Unknown_8e75d: ; 8e75d .sinewave: ; 8e75d
sine_wave $100 sine_wave $100
Function8e79d: ; 8e79d AnimateEndOfExpBar: ; 8e79d
ld a, [hSGB] ld a, [hSGB]
ld de, GFX_8e7f4 ld de, EndOfExpBarGFX
and a and a
jr z, .asm_8e7a8 jr z, .load
ld de, GFX_8e804 ld de, SGBEndOfExpBarGFX
.asm_8e7a8 .load
ld hl, VTiles0 ld hl, VTiles0 tile $00
lb bc, BANK(GFX_8e7f4), 1 lb bc, BANK(EndOfExpBarGFX), 1
call Request2bpp call Request2bpp
ld c, $8 ld c, $8
ld d, $0 ld d, $0
.asm_8e7b5 .loop
push bc push bc
call Function8e7c6 call .AnimateFrame
call DelayFrame call DelayFrame
pop bc pop bc
rept 2 rept 2
inc d inc d
endr endr
dec c dec c
jr nz, .asm_8e7b5 jr nz, .loop
call ClearSprites call ClearSprites
ret ret
; 8e7c6 ; 8e7c6
Function8e7c6: ; 8e7c6 .AnimateFrame: ; 8e7c6
ld hl, Sprites ld hl, Sprites
ld c, $8 ld c, $8
.asm_8e7cb .anim_loop
ld a, c ld a, c
and a and a
ret z ret z
@ -2927,32 +2930,35 @@ Function8e7c6: ; 8e7c6
sla a sla a
sla a sla a
push af push af
push de push de
push hl push hl
call Function8e72c call ApplyYOffset
pop hl pop hl
pop de pop de
add $68 add 13 * 8
ld [hli], a ld [hli], a
pop af pop af
push de push de
push hl push hl
call Function8e72a call ApplyXOffset
pop hl pop hl
pop de pop de
add $54 add 10 * 8 + 4
ld [hli], a ld [hli], a
ld a, $0 ld a, $0
ld [hli], a ld [hli], a
ld a, $6 ld a, $6 ; OBJ 6
ld [hli], a ld [hli], a
jr .asm_8e7cb jr .anim_loop
; 8e7f4 ; 8e7f4
GFX_8e7f4: ; 8e7f4 EndOfExpBarGFX: ; 8e7f4
INCBIN "gfx/unknown/08e7f4.2bpp" INCBIN "gfx/battle/expbarend.2bpp"
GFX_8e804: ; 8e804 SGBEndOfExpBarGFX: ; 8e804
INCBIN "gfx/unknown/08e804.2bpp" INCBIN "gfx/battle/expbarend_sgb.2bpp"
ClearSpriteAnims: ; 8e814 ClearSpriteAnims: ; 8e814
push hl push hl

View File

@ -359,7 +359,7 @@ NewPokedexEntry: ; fb877
call WaitPressAorB_BlinkCursor call WaitPressAorB_BlinkCursor
ld a, $1 ld a, $1
ld [wPokedexStatus], a ld [wPokedexStatus], a
callba Function4424d callba DisplayDexEntry
call WaitPressAorB_BlinkCursor call WaitPressAorB_BlinkCursor
pop af pop af
ld [wPokedexStatus], a ld [wPokedexStatus], a

View File

@ -92,7 +92,7 @@ Function919b0: ; 919b0
jr nz, .pressed_down jr nz, .pressed_down
.loop2 .loop2
push de push de
callba Function8cf69 callba PlaySpriteAnimations
pop de pop de
call DelayFrame call DelayFrame
jr .loop jr .loop

View File

@ -206,7 +206,7 @@ DoTradeAnimation: ; 29082
bit 7, a bit 7, a
jr nz, .finished jr nz, .finished
call .DoTradeAnimCommand call .DoTradeAnimCommand
callab Function8cf69 callab PlaySpriteAnimations
ld hl, wcf65 ld hl, wcf65
inc [hl] inc [hl]
call DelayFrame call DelayFrame

View File

@ -43,7 +43,7 @@ Special_MagnetTrain: ; 8cc04
jr z, .initialize jr z, .initialize
bit 7, a bit 7, a
jr nz, .done jr nz, .done
callab Function8cf69 callab PlaySpriteAnimations
call Function8cdf7 call Function8cdf7
call Function8cc99 call Function8cc99
call Function3b0c call Function3b0c
@ -426,7 +426,7 @@ Function8cea2: ; 8cea2
; 8ceae ; 8ceae
Function8ceae: ; 8ceae Function8ceae: ; 8ceae
callba Function8cf69 callba PlaySpriteAnimations
call Function8cdf7 call Function8cdf7
call Function8cc99 call Function8cc99
call Function3b0c call Function3b0c

View File

@ -317,15 +317,15 @@ PrintLetterDelay:: ; 313d
; mid: 3 frames ; mid: 3 frames
; slow: 5 frames ; slow: 5 frames
; TextBoxFrame + 1[!0] and A or B override text speed with a one-frame delay. ; TextBoxFlags[!0] and A or B override text speed with a one-frame delay.
; Options[4] and TextBoxFrame + 1[!1] disable the delay. ; Options[4] and TextBoxFlags[!1] disable the delay.
ld a, [Options] ld a, [Options]
bit NO_TEXT_SCROLL, a bit NO_TEXT_SCROLL, a
ret nz ret nz
; non-scrolling text? ; non-scrolling text?
ld a, [TextBoxFrame + 1] ld a, [TextBoxFlags]
bit 1, a bit 1, a
ret z ret z
@ -342,7 +342,7 @@ PrintLetterDelay:: ; 313d
ld [hl], a ld [hl], a
; force fast scroll? ; force fast scroll?
ld a, [TextBoxFrame + 1] ld a, [TextBoxFlags]
bit 0, a bit 0, a
jr z, .fast jr z, .fast

View File

@ -723,15 +723,15 @@ PokeFluteTerminatorCharacter:: ; 13e0
PlaceWholeStringInBoxAtOnce:: ; 13e5 PlaceWholeStringInBoxAtOnce:: ; 13e5
ld a, [TextBoxFrame + 1] ld a, [TextBoxFlags]
push af push af
set 1, a set 1, a
ld [TextBoxFrame + 1], a ld [TextBoxFlags], a
call DoTextUntilTerminator call DoTextUntilTerminator
pop af pop af
ld [TextBoxFrame + 1], a ld [TextBoxFlags], a
ret ret
; 13f6 ; 13f6

View File

@ -1206,7 +1206,7 @@ SunStone: ; ee0f
jr z, .NoEffect jr z, .NoEffect
ld a, $1 ld a, $1
ld [wd1e9], a ld [wForceEvolution], a
callba EvolvePokemon callba EvolvePokemon
ld a, [wMonTriedToEvolve] ld a, [wMonTriedToEvolve]
@ -1447,7 +1447,7 @@ RareCandy: ; ef14
predef LearnLevelMoves predef LearnLevelMoves
xor a xor a
ld [wd1e9], a ld [wForceEvolution], a
callba EvolvePokemon callba EvolvePokemon
jp UseDisposableItem jp UseDisposableItem

View File

@ -238,3 +238,7 @@ bgrows EQUS "* $20"
palred EQUS "$0400 *" palred EQUS "$0400 *"
palgreen EQUS "$0020 *" palgreen EQUS "$0020 *"
palblue EQUS "$0001 *" palblue EQUS "$0001 *"
dsprite: MACRO
db \1 * 8 + \2, \3 * 8 + \4, \5, \6
endm

1424
main.asm

File diff suppressed because it is too large Load Diff

View File

@ -12,23 +12,23 @@ VioletPokeCenter1F_MapScriptHeader:
.MapCallbacks: .MapCallbacks:
db 0 db 0
NurseScript_0x694c9: VioletPokeCenterNurse:
jumpstd pokecenternurse jumpstd pokecenternurse
ScientistScript_0x694cc: VioletPokeCenter1F_ElmsAideScript:
faceplayer faceplayer
loadfont loadfont
checkevent EVENT_REFUSED_TO_TAKE_EGG_FROM_ELMS_AIDE checkevent EVENT_REFUSED_TO_TAKE_EGG_FROM_ELMS_AIDE
iftrue UnknownScript_0x6953a iftrue .SecondTimeAsking
writetext UnknownText_0x69555 writetext UnknownText_0x69555
UnknownScript_0x694d7: .AskTakeEgg:
yesorno yesorno
iffalse UnknownScript_0x69531 iffalse .RefusedEgg
checkcode VAR_PARTYCOUNT checkcode VAR_PARTYCOUNT
if_equal $6, UnknownScript_0x6952b if_equal PARTY_LENGTH, .PartyFull
giveegg TOGEPI, 5 giveegg TOGEPI, 5
stringtotext .eggname, $1 stringtotext .eggname, $1
scall UnknownScript_0x69527 scall .AideGivesEgg
setevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE setevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE
clearevent EVENT_ELMS_AIDE_IN_LAB clearevent EVENT_ELMS_AIDE_IN_LAB
clearevent EVENT_TOGEPI_HATCHED clearevent EVENT_TOGEPI_HATCHED
@ -37,18 +37,18 @@ UnknownScript_0x694d7:
waitbutton waitbutton
closetext closetext
checkcode VAR_FACING checkcode VAR_FACING
if_equal UP, .UnknownScript_0x69511 if_equal UP, .AideWalksAroundPlayer
spriteface PLAYER, DOWN spriteface PLAYER, DOWN
applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_0x69549 applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_AideWalksStraightOutOfPokecenter
playsound SFX_EXIT_BUILDING playsound SFX_EXIT_BUILDING
disappear VIOLETPOKECENTER1F_SCIENTIST disappear VIOLETPOKECENTER1F_SCIENTIST
waitsfx waitsfx
end end
.UnknownScript_0x69511 .AideWalksAroundPlayer
applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_0x6954e applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_AideWalksLeftToExitPokecenter
spriteface PLAYER, DOWN spriteface PLAYER, DOWN
applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_0x69551 applymovement VIOLETPOKECENTER1F_SCIENTIST, MovementData_AideFinishesLeavingPokecenter
playsound SFX_EXIT_BUILDING playsound SFX_EXIT_BUILDING
disappear VIOLETPOKECENTER1F_SCIENTIST disappear VIOLETPOKECENTER1F_SCIENTIST
waitsfx waitsfx
@ -57,26 +57,26 @@ UnknownScript_0x694d7:
.eggname .eggname
db "EGG@" db "EGG@"
UnknownScript_0x69527: .AideGivesEgg:
jumpstd receivetogepiegg jumpstd receivetogepiegg
end end
UnknownScript_0x6952b: .PartyFull:
writetext UnknownText_0x69693 writetext UnknownText_0x69693
waitbutton waitbutton
closetext closetext
end end
UnknownScript_0x69531: .RefusedEgg:
writetext UnknownText_0x696f2 writetext UnknownText_0x696f2
waitbutton waitbutton
closetext closetext
setevent EVENT_REFUSED_TO_TAKE_EGG_FROM_ELMS_AIDE setevent EVENT_REFUSED_TO_TAKE_EGG_FROM_ELMS_AIDE
end end
UnknownScript_0x6953a: .SecondTimeAsking:
writetext UnknownText_0x69712 writetext UnknownText_0x69712
jump UnknownScript_0x694d7 jump .AskTakeEgg
GameboyKidScript_0x69540: GameboyKidScript_0x69540:
jumptextfaceplayer UnknownText_0x69809 jumptextfaceplayer UnknownText_0x69809
@ -87,19 +87,19 @@ GentlemanScript_0x69543:
YoungsterScript_0x69546: YoungsterScript_0x69546:
jumptextfaceplayer UnknownText_0x698b8 jumptextfaceplayer UnknownText_0x698b8
MovementData_0x69549: MovementData_AideWalksStraightOutOfPokecenter:
step_down step_down
step_down step_down
step_down step_down
step_down step_down
step_end step_end
MovementData_0x6954e: MovementData_AideWalksLeftToExitPokecenter:
step_left step_left
step_down step_down
step_end step_end
MovementData_0x69551: MovementData_AideFinishesLeavingPokecenter:
step_down step_down
step_down step_down
step_down step_down
@ -233,8 +233,8 @@ VioletPokeCenter1F_MapEventHeader:
.PersonEvents: .PersonEvents:
db 5 db 5
person_event SPRITE_NURSE, 1, 3, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, NurseScript_0x694c9, -1 person_event SPRITE_NURSE, 1, 3, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, VioletPokeCenterNurse, -1
person_event SPRITE_GAMEBOY_KID, 6, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, GameboyKidScript_0x69540, -1 person_event SPRITE_GAMEBOY_KID, 6, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, GameboyKidScript_0x69540, -1
person_event SPRITE_GENTLEMAN, 4, 1, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, GentlemanScript_0x69543, -1 person_event SPRITE_GENTLEMAN, 4, 1, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, GentlemanScript_0x69543, -1
person_event SPRITE_YOUNGSTER, 1, 8, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, YoungsterScript_0x69546, -1 person_event SPRITE_YOUNGSTER, 1, 8, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_SCRIPT, 0, YoungsterScript_0x69546, -1
person_event SPRITE_SCIENTIST, 3, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, ScientistScript_0x694cc, EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER person_event SPRITE_SCIENTIST, 3, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, VioletPokeCenter1F_ElmsAideScript, EVENT_ELMS_AIDE_IN_VIOLET_POKEMON_CENTER

View File

@ -362,7 +362,7 @@ Function11c283: ; 11c283
bit 7, a bit 7, a
jr nz, .exit jr nz, .exit
call .DoJumptableFunction call .DoJumptableFunction
callba Function8cf69 callba PlaySpriteAnimations
callba ReloadMapPart callba ReloadMapPart
jr .loop jr .loop

View File

@ -2011,7 +2011,7 @@ Function100cb5: ; 100cb5
call Function100dd2 call Function100dd2
callba Function241ba callba Function241ba
push bc push bc
callba Function8cf69 callba PlaySpriteAnimations
callba Function10402d callba Function10402d
call Function100dfd call Function100dfd
pop bc pop bc
@ -2065,7 +2065,7 @@ Function100d22: ; 100d22
call Function100dd2 call Function100dd2
callba Function241ba callba Function241ba
push bc push bc
callba Function8cf69 callba PlaySpriteAnimations
callba Function10402d callba Function10402d
call Function100dfd call Function100dfd
pop bc pop bc
@ -4059,7 +4059,7 @@ Function101a21: ; 101a21
ld a, $1 ld a, $1
ld [wc2d7], a ld [wc2d7], a
callba BattleIntro callba BattleIntro
callba SendOutFirstMons callba DoBattle
callba ShowLinkBattleParticipantsAfterEnd callba ShowLinkBattleParticipantsAfterEnd
xor a xor a
ld [wc2d7], a ld [wc2d7], a
@ -6468,7 +6468,7 @@ Function102b32: ; 102b32
dec a dec a
ld [CurPartyMon], a ld [CurPartyMon], a
ld a, $1 ld a, $1
ld [wd1e9], a ld [wForceEvolution], a
callba EvolvePokemon callba EvolvePokemon
call Function102d9a call Function102d9a
call Function102dd3 call Function102dd3

View File

@ -400,7 +400,7 @@ Function1082c6: ; 1082c6
Function1082cc: ; 1082cc Function1082cc: ; 1082cc
.asm_1082cc .asm_1082cc
push bc push bc
callba Function8cf69 callba PlaySpriteAnimations
pop bc pop bc
call DelayFrame call DelayFrame
dec c dec c
@ -410,7 +410,7 @@ Function1082cc: ; 1082cc
Function1082db: ; 1082db Function1082db: ; 1082db
.asm_1082db .asm_1082db
callba Function8cf69 callba PlaySpriteAnimations
callba Functiond00b4 callba Functiond00b4
callba Function10402d callba Function10402d
jr nc, .asm_1082db jr nc, .asm_1082db
@ -431,7 +431,7 @@ Function1082fa: ; 1082fa
call Function108b78 call Function108b78
push hl push hl
push bc push bc
callba Function8cf69 callba PlaySpriteAnimations
pop bc pop bc
pop hl pop hl
call DelayFrame call DelayFrame

View File

@ -7721,7 +7721,7 @@ Function1176ee: ; 1176ee (45:76ee)
bit 7, a bit 7, a
jr nz, .asm_117709 jr nz, .asm_117709
call Function117719 call Function117719
callba Function8cf69 callba PlaySpriteAnimations
callba ReloadMapPart callba ReloadMapPart
jr Function1176ee jr Function1176ee
.asm_117709 .asm_117709

View File

@ -7679,7 +7679,7 @@ Function11b7e5: ; 11b7e5
callba Function108016 callba Function108016
callba Function17d1f1 callba Function17d1f1
ld a, $1 ld a, $1
ld [wd1e9], a ld [wForceEvolution], a
ld a, $2 ld a, $2
ld [wLinkMode], a ld [wLinkMode], a
callba EvolvePokemon callba EvolvePokemon

View File

@ -422,7 +422,7 @@ Function171a11: ; 171a11 (5c:5a11)
bit 7, a bit 7, a
jr nz, .asm_171a2c jr nz, .asm_171a2c
call Function171a36 call Function171a36
callba Function8cf69 callba PlaySpriteAnimations
callba ReloadMapPart callba ReloadMapPart
jr Function171a11 jr Function171a11
.asm_171a2c .asm_171a2c

View File

@ -302,7 +302,7 @@ Function17d0f3: ; 17d0f3
callba Function10804d callba Function10804d
callba Function17d1f1 callba Function17d1f1
ld a, $1 ld a, $1
ld [wd1e9], a ld [wForceEvolution], a
ld a, $2 ld a, $2
ld [wLinkMode], a ld [wLinkMode], a
callba EvolvePokemon callba EvolvePokemon

View File

@ -478,9 +478,9 @@ BecameConfusedText: ; 0x80d97
text "<TARGET>" text "<TARGET>"
line "became confused!" line "became confused!"
prompt prompt
; 0x80dab ; ItemHealedConfusion
BattleText_0x80dab: ; 0x80dab BattleText_ItemHealedConfusion: ; ItemHealedConfusion
text "A @" text "A @"
text_from_ram StringBuffer1 text_from_ram StringBuffer1
text " rid" text " rid"

401
trainers/read_party.asm Executable file
View File

@ -0,0 +1,401 @@
ReadTrainerParty: ; 39771
ld a, [InBattleTowerBattle]
bit 0, a
ret nz
ld a, [wLinkMode]
and a
ret nz
ld hl, OTPartyCount
xor a
ld [hli], a
dec a
ld [hl], a
ld hl, OTPartyMons
ld bc, OTPartyMonsEnd - OTPartyMons
xor a
call ByteFill
ld a, [OtherTrainerClass]
cp CAL
jr nz, .not_cal2
ld a, [OtherTrainerID]
cp CAL2
jr z, .cal2
ld a, [OtherTrainerClass]
.not_cal2
dec a
ld c, a
ld b, 0
ld hl, TrainerGroups
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [OtherTrainerID]
ld b, a
.skip_trainer
dec b
jr z, .got_trainer
.loop
ld a, [hli]
cp $ff
jr nz, .loop
jr .skip_trainer
.got_trainer
.skip_name
ld a, [hli]
cp "@"
jr nz, .skip_name
ld a, [hli]
ld c, a
ld b, 0
ld d, h
ld e, l
ld hl, TrainerTypes
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
ld bc, .done
push bc
jp [hl]
.done
jp ComputeTrainerReward
.cal2
ld a, BANK(sMysteryGiftTrainer)
call GetSRAMBank
ld de, sMysteryGiftTrainer
call TrainerType2
call CloseSRAM
jr .done
; 397e3
TrainerTypes: ; 397e3
dw TrainerType1 ; level, species
dw TrainerType2 ; level, species, moves
dw TrainerType3 ; level, species, item
dw TrainerType4 ; level, species, item, moves
; 397eb
TrainerType1: ; 397eb
; normal (level, species)
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
predef TryAddMonToParty
pop hl
jr .loop
; 39806
TrainerType2: ; 39806
; moves
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
predef TryAddMonToParty
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
ld b, NUM_MOVES
.copy_moves
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .copy_moves
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
ld hl, MON_PP
add hl, de
push hl
ld hl, MON_MOVES
add hl, de
pop de
ld b, NUM_MOVES
.copy_pp
ld a, [hli]
and a
jr z, .copied_pp
push hl
push bc
dec a
ld hl, Moves + MOVE_PP
ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
pop bc
pop hl
ld [de], a
inc de
dec b
jr nz, .copy_pp
.copied_pp
pop hl
jr .loop
; 39871
TrainerType3: ; 39871
; item
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
predef TryAddMonToParty
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
ld a, [hli]
ld [de], a
jr .loop
; 3989d (e:589d)
TrainerType4: ; 3989d
; item + moves
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
predef TryAddMonToParty
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
ld a, [hli]
ld [de], a
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Moves
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
pop hl
ld b, NUM_MOVES
.copy_moves
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .copy_moves
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
ld d, h
ld e, l
ld hl, MON_PP
add hl, de
push hl
ld hl, MON_MOVES
add hl, de
pop de
ld b, NUM_MOVES
.copy_pp
ld a, [hli]
and a
jr z, .copied_pp
push hl
push bc
dec a
ld hl, Moves + MOVE_PP
ld bc, MOVE_LENGTH
call AddNTimes
ld a, BANK(Moves)
call GetFarByte
pop bc
pop hl
ld [de], a
inc de
dec b
jr nz, .copy_pp
.copied_pp
pop hl
jr .loop
; 3991b
ComputeTrainerReward: ; 3991b (e:591b)
ld hl, hProduct
xor a
rept 3
ld [hli], a
endr
ld a, [wEnemyTrainerBaseReward]
ld [hli], a
ld a, [CurPartyLevel]
ld [hl], a
call Multiply
ld hl, wBattleReward
xor a
ld [hli], a
ld a, [hProduct + 2]
ld [hli], a
ld a, [hProduct + 3]
ld [hl], a
ret
Battle_GetTrainerName:: ; 39939
ld a, [InBattleTowerBattle]
bit 0, a
ld hl, wd26b
jp nz, CopyTrainerName
ld a, [OtherTrainerID]
ld b, a
ld a, [OtherTrainerClass]
ld c, a
GetTrainerName:: ; 3994c
ld a, c
cp CAL
jr nz, .not_cal2
ld a, BANK(sMysteryGiftTrainerHouseFlag)
call GetSRAMBank
ld a, [sMysteryGiftTrainerHouseFlag]
and a
call CloseSRAM
jr z, .not_cal2
ld a, BANK(sMysteryGiftPartnerName)
call GetSRAMBank
ld hl, sMysteryGiftPartnerName
call CopyTrainerName
jp CloseSRAM
.not_cal2
dec c
push bc
ld b, 0
ld hl, TrainerGroups
rept 2
add hl, bc
endr
ld a, [hli]
ld h, [hl]
ld l, a
pop bc
.loop
dec b
jr z, CopyTrainerName
.skip
ld a, [hli]
cp $ff
jr nz, .skip
jr .loop
CopyTrainerName: ; 39984
ld de, StringBuffer1
push de
ld bc, NAME_LENGTH
call CopyBytes
pop de
ret
; 39990
Function39990: ; 39990
; This function is useless.
ld de, StringBuffer1
push de
ld bc, NAME_LENGTH
pop de
ret
; 39999

View File

@ -1014,7 +1014,7 @@ wc7d7:: ds 1
wc7d8:: ds 1 wc7d8:: ds 1
wc7d9:: ds 1 wc7d9:: ds 1
wc7da:: ds 1 wc7da:: ds 1
wc7db:: ds 1 wDexSearchSlowpokeFrame:: ds 1
wc7dc:: ds 1 wc7dc:: ds 1
wc7dd:: ds 1 wc7dd:: ds 1
wc7de:: ds 1 wc7de:: ds 1
@ -1493,7 +1493,7 @@ wSaveFileExists:: ds 1
TextBoxFrame:: ; cfce TextBoxFrame:: ; cfce
; bits 0-2: textbox frame 0-7 ; bits 0-2: textbox frame 0-7
ds 1 ds 1
TextBoxFlags::
ds 1 ds 1
GBPrinter:: ; cfd0 GBPrinter:: ; cfd0
@ -2011,7 +2011,7 @@ TilesetPalettes:: ; d1e6
EvolvableFlags:: ; d1e8 EvolvableFlags:: ; d1e8
flag_array PARTY_LENGTH flag_array PARTY_LENGTH
wd1e9:: ds 1 wForceEvolution:: ds 1
MagikarpLength:: MagikarpLength::
Buffer1:: ; d1ea Buffer1:: ; d1ea
ds 1 ds 1
@ -2161,9 +2161,6 @@ TimeOfDay:: ; d269
ds 1 ds 1
ds 1 ds 1
SECTION "Enemy Party", WRAMX, BANK [1]
OTPlayerName:: ds NAME_LENGTH
ds OTPlayerName - @
wPokedexShowPointerAddr:: wPokedexShowPointerAddr::
wd26b:: ds 1 wd26b:: ds 1
wd26c:: ds 1 wd26c:: ds 1
@ -2171,9 +2168,13 @@ wPokedexShowPointerBank::
wd26d:: ds 1 wd26d:: ds 1
ds 3 ds 3
wd271:: ds 5 wd271:: ds 5
OTPlayerID::
wd276:: ds 10 wd276:: ds 10
ds wd26b - @
SECTION "Enemy Party", WRAMX, BANK [1]
OTPlayerName:: ds NAME_LENGTH
OTPlayerID:: ds 2
ds 8
OTPartyCount:: ds 1 ; d280 OTPartyCount:: ds 1 ; d280
OTPartySpecies:: ds PARTY_LENGTH ; d281 OTPartySpecies:: ds PARTY_LENGTH ; d281
OTPartyEnd:: ds 1 OTPartyEnd:: ds 1
@ -2204,6 +2205,7 @@ MapEventStatus:: ; d433
ds 1 ds 1
ScriptFlags:: ; d434 ScriptFlags:: ; d434
; bit 3: priority jump
ds 1 ds 1
ScriptFlags2:: ; d435 ScriptFlags2:: ; d435
ds 1 ds 1
@ -2234,7 +2236,11 @@ wScriptStackBA5:: ds 3
ScriptDelay:: ; d44d ScriptDelay:: ; d44d
ds 1 ds 1
wPriorityScriptBank::
wScriptTextBank::
wd44e:: ds 1 wd44e:: ds 1
wPriorityScriptAddr::
wScriptTextAddr::
wd44f:: ds 1 wd44f:: ds 1
wd450:: ds 1 wd450:: ds 1
wd451:: ds 1 wd451:: ds 1