diff options
Diffstat (limited to 'engine/battle')
-rwxr-xr-x | engine/battle/1.asm | 54 | ||||
-rwxr-xr-x | engine/battle/14.asm | 64 | ||||
-rwxr-xr-x | engine/battle/16.asm | 2 | ||||
-rwxr-xr-x | engine/battle/1c.asm | 74 | ||||
-rwxr-xr-x | engine/battle/4.asm | 60 | ||||
-rwxr-xr-x | engine/battle/4_2.asm | 86 | ||||
-rwxr-xr-x | engine/battle/5.asm | 10 | ||||
-rwxr-xr-x | engine/battle/9.asm | 48 | ||||
-rwxr-xr-x | engine/battle/a.asm | 2 | ||||
-rwxr-xr-x | engine/battle/c.asm | 2 | ||||
-rwxr-xr-x | engine/battle/core.asm | 105 | ||||
-rwxr-xr-x | engine/battle/e.asm | 230 | ||||
-rwxr-xr-x | engine/battle/e_2.asm | 107 |
13 files changed, 436 insertions, 408 deletions
diff --git a/engine/battle/1.asm b/engine/battle/1.asm index e28cd056..517d53d1 100755 --- a/engine/battle/1.asm +++ b/engine/battle/1.asm @@ -6,26 +6,28 @@ DrainHPEffect_: ; 783f (1:783f) ld a, [hl] rr a ld [hld], a - or [hl] - jr nz, .asm_784f + or [hl] ; is damage 0? + jr nz, .getAttackerHP +; if damage is 0, increase to 1 so that the attacker gains at least 1 HP inc hl inc [hl] -.asm_784f - ld hl, wBattleMonHP ; wd015 - ld de, wBattleMonMaxHP ; wd023 - ld a, [H_WHOSETURN] ; $fff3 +.getAttackerHP + ld hl, wBattleMonHP + ld de, wBattleMonMaxHP + ld a, [H_WHOSETURN] and a - jp z, Func_7861 + jp z, .addDamageToAttackerHP ld hl, wEnemyMonHP ld de, wEnemyMonMaxHP - -Func_7861: ; 7861 (1:7861) +.addDamageToAttackerHP ld bc, wHPBarOldHP+1 +; copy current HP to wHPBarOldHP ld a, [hli] ld [bc], a ld a, [hl] dec bc ld [bc], a +; copy max HP to wHPBarMaxHP ld a, [de] dec bc ld [bc], a @@ -33,7 +35,8 @@ Func_7861: ; 7861 (1:7861) ld a, [de] dec bc ld [bc], a - ld a, [wd0d8] +; add damage to attacker's HP and copy new HP to wHPBarNewHP + ld a, [W_DAMAGE + 1] ld b, [hl] add b ld [hld], a @@ -43,7 +46,8 @@ Func_7861: ; 7861 (1:7861) adc b ld [hli], a ld [wHPBarNewHP+1], a - jr c, .asm_7890 + jr c, .capToMaxHP ; if HP > 65,535, cap to max HP +; compare HP with max HP ld a, [hld] ld b, a ld a, [de] @@ -54,8 +58,8 @@ Func_7861: ; 7861 (1:7861) ld a, [de] inc de sbc b - jr nc, .asm_789c -.asm_7890 + jr nc, .next +.capToMaxHP ld a, [de] ld [hld], a ld [wHPBarNewHP], a @@ -64,31 +68,31 @@ Func_7861: ; 7861 (1:7861) ld [hli], a ld [wHPBarNewHP+1], a inc de -.asm_789c - ld a, [H_WHOSETURN] ; $fff3 +.next + ld a, [H_WHOSETURN] and a hlCoord 10, 9 ld a, $1 - jr z, .asm_78aa + jr z, .next2 hlCoord 2, 2 xor a -.asm_78aa - ld [wListMenuID], a ; wListMenuID +.next2 + ld [wHPBarType], a predef UpdateHPBar2 predef DrawPlayerHUDAndHPBar predef DrawEnemyHUDAndHPBar callab ReadPlayerMonCurHPAndStatus - ld hl, SuckedHealthText ; $78dc - ld a, [H_WHOSETURN] ; $fff3 + ld hl, SuckedHealthText + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVEEFFECT] ; wcfd3 - jr z, .asm_78d2 + ld a, [W_PLAYERMOVEEFFECT] + jr z, .next3 ld a, [W_ENEMYMOVEEFFECT] -.asm_78d2 +.next3 cp DREAM_EATER_EFFECT - jr nz, .asm_78d9 + jr nz, .printText ld hl, DreamWasEatenText -.asm_78d9 +.printText jp PrintText SuckedHealthText: ; 78dc (1:78dc) diff --git a/engine/battle/14.asm b/engine/battle/14.asm index cabaae07..1b2d7462 100755 --- a/engine/battle/14.asm +++ b/engine/battle/14.asm @@ -1,4 +1,4 @@ -Func_525af: ; 525af (14:65af) +InitBattleVariables: ; 525af (14:65af) ld a, [hTilesetType] ld [wd0d4], a xor a @@ -9,7 +9,7 @@ Func_525af: ; 525af (14:65af) ld [hli], a ld [hli], a ld [hl], a - ld [wListScrollOffset], a ; wcc36 + ld [wListScrollOffset], a ld [wCriticalHitOrOHKO], a ld [wBattleMonSpecies], a ld [wPartyGainExpFlags], a @@ -21,73 +21,73 @@ Func_525af: ; 525af (14:65af) ld [hl], a ld hl, wccd3 ld b, $3c -.asm_525e1 +.loop ld [hli], a dec b - jr nz, .asm_525e1 + jr nz, .loop inc a ld [wccd9], a ld a, [W_CURMAP] cp SAFARI_ZONE_EAST - jr c, .asm_525f9 + jr c, .notSafariBattle cp SAFARI_ZONE_REST_HOUSE_1 - jr nc, .asm_525f9 - ld a, $2 - ld [W_BATTLETYPE], a ; wd05a -.asm_525f9 + jr nc, .notSafariBattle + ld a, $2 ; safari battle + ld [W_BATTLETYPE], a +.notSafariBattle ld hl, PlayBattleMusic ld b, BANK(PlayBattleMusic) jp Bankswitch ParalyzeEffect_: ; 52601 (14:6601) - ld hl, wEnemyMonStatus ; wcfe9 - ld de, W_PLAYERMOVETYPE ; wcfd5 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wEnemyMonStatus + ld de, W_PLAYERMOVETYPE + ld a, [H_WHOSETURN] and a - jp z, .asm_52613 + jp z, .next ld hl, wBattleMonStatus - ld de, W_ENEMYMOVETYPE ; wcfcf - -.asm_52613 + ld de, W_ENEMYMOVETYPE +.next ld a, [hl] - and a - jr nz, .asm_52659 + and a ; does the target already have a status ailment? + jr nz, .didntAffect +; check if the target is immune due to types ld a, [de] - cp EVASION_DOWN1_EFFECT - jr nz, .asm_5262a + cp ELECTRIC + jr nz, .hitTest ld b, h ld c, l inc bc ld a, [bc] - cp $4 - jr z, .asm_52666 + cp GROUND + jr z, .doesntAffect inc bc ld a, [bc] - cp $4 - jr z, .asm_52666 -.asm_5262a + cp GROUND + jr z, .doesntAffect +.hitTest push hl callab MoveHitTest pop hl ld a, [W_MOVEMISSED] and a - jr nz, .asm_52659 + jr nz, .didntAffect set PAR, [hl] callab QuarterSpeedDueToParalysis - ld c, $1e + ld c, 30 call DelayFrames - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, PrintMayNotAttackText ld b, BANK(PrintMayNotAttackText) jp Bankswitch -.asm_52659 - ld c, $32 +.didntAffect + ld c, 50 call DelayFrames ld hl, PrintDidntAffectText ld b, BANK(PrintDidntAffectText) jp Bankswitch -.asm_52666 - ld c, $32 +.doesntAffect + ld c, 50 call DelayFrames ld hl, PrintDoesntAffectText ld b, BANK(PrintDoesntAffectText) diff --git a/engine/battle/16.asm b/engine/battle/16.asm index d1cecbbe..9a00bd98 100755 --- a/engine/battle/16.asm +++ b/engine/battle/16.asm @@ -55,7 +55,7 @@ PrintBeginningBattleText: ; 58d99 (16:4d99) ld hl, UnveiledGhostText call PrintText callab LoadEnemyMonData - callab Func_708ca + callab MarowakAnim ld hl, WildMonAppearedText call PrintText diff --git a/engine/battle/1c.asm b/engine/battle/1c.asm index b905777b..ce0296f7 100755 --- a/engine/battle/1c.asm +++ b/engine/battle/1c.asm @@ -1,85 +1,91 @@ -Func_708ca: ; 708ca (1c:48ca) +MarowakAnim: ; 708ca (1c:48ca) +; animate the ghost being unveiled as a Marowak ld a, $e4 - ld [rOBP1], a ; $ff49 - call Func_7092a + ld [rOBP1], a + call CopyMonPicFromBGToSpriteVRAM ; cover the BG ghost pic with a sprite ghost pic that looks the same +; now that the ghost pic is being displayed using sprites, clear the ghost pic from the BG tilemap hlCoord 12, 0 ld bc, $707 call ClearScreenArea call Delay3 xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba - ld a, $91 + ld [H_AUTOBGTRANSFERENABLED], a ; disable BG transfer so we don't see the Marowak too soon +; replace ghost pic with Marowak in BG + ld a, MAROWAK ld [wHPBarMaxHP], a ld a, $1 - ld [H_WHOSETURN], a ; $fff3 + ld [H_WHOSETURN], a callab Func_79793 + ; alternate between black and light grey 8 times. + ; this makes the ghost's body appear to flash ld d, $80 - call Func_704f3 -.asm_708f6 - ld c, $a + call FlashSprite8Times +.fadeOutGhostLoop + ld c, 10 call DelayFrames - ld a, [rOBP1] ; $ff49 + ld a, [rOBP1] sla a sla a - ld [rOBP1], a ; $ff49 - jr nz, .asm_708f6 + ld [rOBP1], a + jr nz, .fadeOutGhostLoop call ClearSprites - call Func_7092a + call CopyMonPicFromBGToSpriteVRAM ; copy Marowak pic from BG to sprite VRAM ld b, $e4 -.asm_7090d - ld c, $a +.fadeInMarowakLoop + ld c, 10 call DelayFrames - ld a, [rOBP1] ; $ff49 + ld a, [rOBP1] srl b rra srl b rra - ld [rOBP1], a ; $ff49 + ld [rOBP1], a ld a, b and a - jr nz, .asm_7090d + jr nz, .fadeInMarowakLoop ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $ffba + ld [H_AUTOBGTRANSFERENABLED], a ; enable BG transfer so the BG Marowak pic will be visible after the sprite one is cleared call Delay3 jp ClearSprites -Func_7092a: ; 7092a (1c:492a) +; copies a mon pic's from background VRAM to sprite VRAM and sets up OAM +CopyMonPicFromBGToSpriteVRAM: ; 7092a (1c:492a) ld de, vFrontPic ld hl, vSprites ld bc, 7 * 7 call CopyVideoData ld a, $10 - ld [W_BASECOORDY], a ; wd082 + ld [W_BASECOORDY], a ld a, $70 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a ld hl, wOAMBuffer ld bc, $606 ld d, $8 -.asm_70948 +.oamLoop push bc - ld a, [W_BASECOORDY] ; wd082 + ld a, [W_BASECOORDY] ld e, a -.asm_7094d +.oamInnerLoop ld a, e add $8 ld e, a ld [hli], a - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] ld [hli], a ld a, d ld [hli], a - ld a, $10 + ld a, $10 ; use OBP1 ld [hli], a inc d dec c - jr nz, .asm_7094d + jr nz, .oamInnerLoop inc d - ld a, [W_BASECOORDX] ; wd081 + ld a, [W_BASECOORDX] add $8 - ld [W_BASECOORDX], a ; wd081 + ld [W_BASECOORDX], a pop bc dec b - jr nz, .asm_70948 + jr nz, .oamLoop ret BattleTransition: ; 7096d (1c:496d) @@ -270,9 +276,9 @@ BattleTransitionTile: ; 70a59 (1c:4a59) BattleTransition_BlackScreen: ; 70a69 (1c:4a69) ld a, $ff - ld [rBGP], a ; $ff47 - ld [rOBP0], a ; $ff48 - ld [rOBP1], a ; $ff49 + ld [rBGP], a + ld [rOBP0], a + ld [rOBP1], a ret ; for non-dungeon trainer battles diff --git a/engine/battle/4.asm b/engine/battle/4.asm index db6614cc..e96267c4 100755 --- a/engine/battle/4.asm +++ b/engine/battle/4.asm @@ -1,14 +1,14 @@ -Func_128d8: ; 128d8 (4:68d8) - ld a, [W_YCOORD] ; wd361 +; returns whether the player is one tile outside the map in Z +IsPlayerJustOutsideMap: ; 128d8 (4:68d8) + ld a, [W_YCOORD] ld b, a - ld a, [W_CURMAPHEIGHT] ; wd368 - call Func_128ea + ld a, [W_CURMAPHEIGHT] + call .compareCoordWithMapDimension ret z - ld a, [W_XCOORD] ; wd362 + ld a, [W_XCOORD] ld b, a - ld a, [W_CURMAPWIDTH] ; wd369 - -Func_128ea: ; 128ea (4:68ea) + ld a, [W_CURMAPWIDTH] +.compareCoordWithMapDimension add a cp b ret z @@ -18,58 +18,58 @@ Func_128ea: ; 128ea (4:68ea) DrawHP: ; 128ef (4:68ef) call GetPredefRegisters ld a, $1 - jr asm_128fb + jr DrawHP_ -Func_128f6: ; 128f6 (4:68f6) +DrawHP2: ; 128f6 (4:68f6) call GetPredefRegisters ld a, $2 -asm_128fb: ; 128fb (4:68fb) - ld [wListMenuID], a ; wListMenuID + +DrawHP_: ; 128fb (4:68fb) + ld [wHPBarType], a push hl - ld a, [wcf99] + ld a, [wLoadedMonHP] ld b, a - ld a, [wcf9a] + ld a, [wLoadedMonHP + 1] ld c, a or b - jr nz, .asm_12913 + jr nz, .nonzeroHP xor a ld c, a ld e, a ld a, $6 ld d, a - jp Func_12924 -.asm_12913 - ld a, [wcfba] + jp .drawHPBarAndPrintFraction +.nonzeroHP + ld a, [wLoadedMonMaxHP] ld d, a - ld a, [wcfbb] + ld a, [wLoadedMonMaxHP + 1] ld e, a predef HPBarLength ld a, $6 ld d, a ld c, a - -Func_12924: ; 12924 (4:6924) +.drawHPBarAndPrintFraction pop hl push de push hl push hl call DrawHPBar pop hl - ld a, [$fff6] + ld a, [hFlags_0xFFF6] bit 0, a - jr z, .asm_12937 - ld bc, $9 - jr .asm_1293a -.asm_12937 - ld bc, $15 -.asm_1293a + jr z, .printFractionBelowBar + ld bc, $9 ; right of bar + jr .printFraction +.printFractionBelowBar + ld bc, SCREEN_WIDTH + 1 ; below bar +.printFraction add hl, bc - ld de, wcf99 + ld de, wLoadedMonHP ld bc, $203 call PrintNumber ld a, "/" ld [hli], a - ld de, wcfba + ld de, wLoadedMonMaxHP ld bc, $203 call PrintNumber pop hl diff --git a/engine/battle/4_2.asm b/engine/battle/4_2.asm index a3ef1264..bac0a2d1 100755 --- a/engine/battle/4_2.asm +++ b/engine/battle/4_2.asm @@ -60,7 +60,7 @@ EndOfBattle: ; 137aa (4:77aa) ld [hli], a ld [hl], a ld [wListScrollOffset], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld b, $18 .loop ld [hli], a @@ -87,7 +87,9 @@ PickUpPayDayMoneyText: ; 1386b (4:786b) TX_FAR _PickUpPayDayMoneyText db "@" -Func_13870: ; 13870 (4:7870) +; try to initiate a wild pokemon encounter +; returns success in Z +TryDoWildEncounter: ; 13870 (4:7870) ld a, [wNPCMovementScriptPointerTableNum] and a ret nz @@ -95,14 +97,14 @@ Func_13870: ; 13870 (4:7870) and a ret nz callab IsPlayerStandingOnDoorTileOrWarpTile - jr nc, .asm_13888 -.asm_13884 + jr nc, .notStandingOnDoorOrWarpTile +.CantEncounter ld a, $1 and a ret -.asm_13888 - callab Func_128d8 - jr z, .asm_13884 +.notStandingOnDoorOrWarpTile + callab IsPlayerJustOutsideMap + jr z, .CantEncounter ld a, [wRepelRemainingSteps] and a jr z, .asm_1389e @@ -110,8 +112,8 @@ Func_13870: ; 13870 (4:7870) jr z, .lastRepelStep ld [wRepelRemainingSteps], a .asm_1389e -; determine if wild pokémon can appear in the half-block we’re standing -; is the bottom right tile (9,9) of the half-block are we standing a grass/water tile? +; determine if wild pokémon can appear in the half-block we’re standing in +; is the bottom right tile (9,9) of the half-block we're standing in a grass/water tile? hlCoord 9, 9 ld c, [hl] ld a, [W_GRASSTILE] @@ -127,17 +129,17 @@ Func_13870: ; 13870 (4:7870) ; …as long as it’s not Viridian Forest or Safari Zone. ld a, [W_CURMAP] cp REDS_HOUSE_1F ; is this an indoor map? - jr c, .CantEncounter + jr c, .CantEncounter2 ld a, [W_CURMAPTILESET] cp FOREST ; Viridian Forest/Safari Zone - jr z, .CantEncounter + jr z, .CantEncounter2 ld a, [W_GRASSRATE] .CanEncounter -; weigh encounter chance to a random number to determine if there will be an encounter +; compare encounter chance with a random number to determine if there will be an encounter ld b, a ld a, [hRandomAdd] cp b - jr nc, .CantEncounter + jr nc, .CantEncounter2 ld a, [hRandomSub] ld b, a ld hl, WildMonEncounterSlotChances @@ -148,15 +150,15 @@ Func_13870: ; 13870 (4:7870) inc hl jr .determineEncounterSlot .gotEncounterSlot -; determine which wild pokémon (grass or water) can appear in the half-block we’re standing +; determine which wild pokémon (grass or water) can appear in the half-block we’re standing in ld c, [hl] ld hl, W_GRASSMONS aCoord 8, 9 - cp $14 ; is the bottom left tile (8,9) of the half-block are we standing a water tile? + cp $14 ; is the bottom left tile (8,9) of the half-block we're standing in a water tile? jr nz, .gotWildEncounterType ; else, it's treated as a grass tile by default ld hl, W_WATERMONS ; since the bottom right tile of a "left shore" half-block is $14 but the bottom left tile is not, -; "left shore" half-blocks (such as the one in the east coast of Cinnabar), load grass encounters. +; "left shore" half-blocks (such as the one in the east coast of Cinnabar) load grass encounters. .gotWildEncounterType ld b, $0 add hl, bc @@ -172,15 +174,15 @@ Func_13870: ; 13870 (4:7870) ld b, a ld a, [W_CURENEMYLVL] cp b - jr c, .CantEncounter + jr c, .CantEncounter2 ; repel prevents encounters if the leading party mon's level is higher than the wild mon jr .willEncounter .lastRepelStep ld [wRepelRemainingSteps], a ld a, $d2 - ld [H_DOWNARROWBLINKCNT2], a ; $ff8c + ld [H_DOWNARROWBLINKCNT2], a call EnableAutoTextBoxDrawing call DisplayTextID -.CantEncounter +.CantEncounter2 ld a, $1 and a ret @@ -205,16 +207,16 @@ WildMonEncounterSlotChances: ; 13918 (4:7918) db $FF, $12 ; 3/256 = 1.2% chance of slot 9 RecoilEffect_: ; 1392c (4:792c) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld a, [W_PLAYERMOVENUM] ; wcfd2 - ld hl, wBattleMonMaxHP ; wd023 + ld a, [W_PLAYERMOVENUM] + ld hl, wBattleMonMaxHP jr z, .asm_1393d - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP + ld a, [W_ENEMYMOVENUM] + ld hl, wEnemyMonMaxHP .asm_1393d ld d, a - ld a, [W_DAMAGE] ; W_DAMAGE + ld a, [W_DAMAGE] ld b, a ld a, [W_DAMAGE + 1] ld c, a @@ -258,16 +260,16 @@ RecoilEffect_: ; 1392c (4:792c) ld [hl], a .asm_13982 hlCoord 10, 9 - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a ld a, $1 jr z, .asm_13990 hlCoord 2, 2 xor a .asm_13990 - ld [wListMenuID], a ; wListMenuID + ld [wHPBarType], a predef UpdateHPBar2 - ld hl, HitWithRecoilText ; $799e + ld hl, HitWithRecoilText jp PrintText HitWithRecoilText: ; 1399e (4:799e) TX_FAR _HitWithRecoilText @@ -293,8 +295,8 @@ ConversionEffect_: ; 139a3 (4:79a3) inc de ld a, [hl] ld [de], a - ld hl, Func_3fba8 - call Func_139d5 + ld hl, PlayCurrentMoveAnimation + call CallBankF ld hl, ConvertedTypeText jp PrintText @@ -304,22 +306,22 @@ ConvertedTypeText: ; 139cd (4:79cd) PrintButItFailedText: ; 139d2 (4:79d2) ld hl, PrintButItFailedText_ -Func_139d5: ; 139d5 (4:79d5) +CallBankF: ; 139d5 (4:79d5) ld b, BANK(PrintButItFailedText_) jp Bankswitch HazeEffect_: ; 139da (4:79da) ld a, $7 ld hl, wPlayerMonAttackMod - call Func_13a43 + call ResetStatMods ld hl, wEnemyMonAttackMod - call Func_13a43 + call ResetStatMods ld hl, wPlayerMonUnmodifiedAttack ld de, wBattleMonAttack - call Func_13a4a + call ResetStats ld hl, wEnemyMonUnmodifiedAttack ld de, wEnemyMonAttack - call Func_13a4a + call ResetStats ld hl, wEnemyMonStatus ld de, wEnemySelectedMove ld a, [H_WHOSETURN] @@ -347,8 +349,8 @@ HazeEffect_: ; 139da (4:79da) call CureStatuses ld hl, W_ENEMYBATTSTATUS1 call CureStatuses - ld hl, Func_3fba8 - call Func_139d5 + ld hl, PlayCurrentMoveAnimation + call CallBankF ld hl, StatusChangesEliminatedText jp PrintText @@ -363,7 +365,7 @@ CureStatuses: ; 13a37 (4:7a37) ld [hl], a ret -Func_13a43: ; 13a43 (4:7a43) +ResetStatMods: ; 13a43 (4:7a43) ld b, $8 .loop ld [hli], a @@ -371,7 +373,7 @@ Func_13a43: ; 13a43 (4:7a43) jr nz, .loop ret -Func_13a4a: ; 13a4a (4:7a4a) +ResetStats: ; 13a4a (4:7a4a) ld b, $8 .loop ld a, [hli] @@ -390,8 +392,8 @@ GetTrainerName_: ; 13a58 (4:7a58) ld a, [wLinkState] and a jr nz, .rival - ld hl, W_RIVALNAME ; wd34a - ld a, [W_TRAINERCLASS] ; wd031 + ld hl, W_RIVALNAME + ld a, [W_TRAINERCLASS] cp SONY1 jr z, .rival cp SONY2 @@ -400,7 +402,7 @@ GetTrainerName_: ; 13a58 (4:7a58) jr z, .rival ld [wd0b5], a ld a, TRAINER_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, BANK(TrainerNames) ld [wPredefBank], a call GetName diff --git a/engine/battle/5.asm b/engine/battle/5.asm index e534470d..ef3e1362 100755 --- a/engine/battle/5.asm +++ b/engine/battle/5.asm @@ -4,7 +4,7 @@ SubstituteEffectHandler: ; 17dad (5:7dad) ld hl, wBattleMonMaxHP ld de, wPlayerSubstituteHP ld bc, W_PLAYERBATTSTATUS2 - ld a, [$fff3] ;whose turn? + ld a, [H_WHOSETURN] and a jr z, .notEnemy ld hl, wEnemyMonMaxHP @@ -23,8 +23,8 @@ SubstituteEffectHandler: ; 17dad (5:7dad) srl a rr b push de - ld de, $fff2 ;subtract 8 to point to [current hp] instead of [max hp] - add hl, de ;HL -= 8 + ld de, wBattleMonHP - wBattleMonMaxHP + add hl, de ; point hl to current HP pop de ld a, b ld [de], a ;save copy of HP to subtract in ccd7/ccd8 [how much HP substitute has] @@ -44,8 +44,8 @@ SubstituteEffectHandler: ; 17dad (5:7dad) set HasSubstituteUp, [hl] ;set bit 4 of flags, user now has substitute ld a, [W_OPTIONS] ;load options bit 7, a ;battle animation is enabled? - ld hl, Func_3fba8 ;animation enabled: 0F:7BA8 - ld b, BANK(Func_3fba8) + ld hl, PlayCurrentMoveAnimation ;animation enabled: 0F:7BA8 + ld b, BANK(PlayCurrentMoveAnimation) jr z, .animationEnabled ld hl, AnimationSubstitute ;animation disabled: 1E:56E0 ld b, BANK(AnimationSubstitute) diff --git a/engine/battle/9.asm b/engine/battle/9.asm index eb86cce0..e7265f41 100755 --- a/engine/battle/9.asm +++ b/engine/battle/9.asm @@ -1,35 +1,43 @@ -Func_27d6b: ; 27d6b (9:7d6b) +; [wd0b5] = pokemon ID +; hl = dest addr +PrintMonType: ; 27d6b (9:7d6b) call GetPredefRegisters push hl call GetMonHeader pop hl push hl ld a, [W_MONHTYPE1] - call Func_27d89 + call PrintType ld a, [W_MONHTYPE1] ld b, a ld a, [W_MONHTYPE2] cp b pop hl - jr z, asm_27d8c - ld bc, $28 + jr z, EraseType2Text + ld bc, SCREEN_WIDTH * 2 add hl, bc -Func_27d89: ; 27d89 (9:7d89) +; a = type +; hl = dest addr +PrintType: ; 27d89 (9:7d89) push hl - jr asm_27d9f -asm_27d8c: ; 27d8c (9:7d8c) - ld a, $7f + jr PrintType_ + +; erase "TYPE2/" if the mon only has 1 type +EraseType2Text: ; 27d8c (9:7d8c) + ld a, " " ld bc, $13 add hl, bc ld bc, $6 jp FillMemory -Func_27d98: ; 27d98 (9:7d98) +PrintMoveType: ; 27d98 (9:7d98) call GetPredefRegisters push hl - ld a, [W_PLAYERMOVETYPE] ; wcfd5 -asm_27d9f: ; 27d9f (9:7d9f) + ld a, [W_PLAYERMOVETYPE] +; fall through + +PrintType_: ; 27d9f (9:7d9f) add a ld hl, TypeNames ld e, a @@ -157,19 +165,19 @@ CooltrainerFName: ; 27f79 (9:7f79) db "COOLTRAINER♀@" FocusEnergyEffect_: ; 27f86 (9:7f86) - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a - jr z, .asm_27f91 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 -.asm_27f91 + jr z, .notEnemy + ld hl, W_ENEMYBATTSTATUS2 +.notEnemy bit GettingPumped, [hl] ; is mon already using focus energy? - jr nz, .asm_27fa5 + jr nz, .alreadyUsing set GettingPumped, [hl] ; mon is now using focus energy - callab Func_3fba8 - ld hl, GettingPumpedText ; $7fb2 + callab PlayCurrentMoveAnimation + ld hl, GettingPumpedText jp PrintText -.asm_27fa5 +.alreadyUsing ld c, $32 call DelayFrames ld hl, PrintButItFailedText_ diff --git a/engine/battle/a.asm b/engine/battle/a.asm index 917a462b..a257d143 100755 --- a/engine/battle/a.asm +++ b/engine/battle/a.asm @@ -21,7 +21,7 @@ LeechSeedEffect_: ; 2bea9 (a:7ea9) bit Seeded, [hl] jr nz, .asm_2bee7 set Seeded, [hl] - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, WasSeededText ; $7ef2 jp PrintText .asm_2bee7 diff --git a/engine/battle/c.asm b/engine/battle/c.asm index 07369375..b7c20ef6 100755 --- a/engine/battle/c.asm +++ b/engine/battle/c.asm @@ -8,7 +8,7 @@ MistEffect_: ; 33f2b (c:7f2b) bit ProtectedByMist, [hl] ; is mon protected by mist? jr nz, .asm_33f4a set ProtectedByMist, [hl] ; mon is now protected by mist - callab Func_3fba8 + callab PlayCurrentMoveAnimation ld hl, ShroudedInMistText jp PrintText .asm_33f4a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 64a8d44e..63be5676 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -98,7 +98,7 @@ SpecialEffectsCont: ; 3c049 (f:4049) SlidePlayerAndEnemySilhouettesOnScreen: ; 3c04c (f:404c) call LoadPlayerBackPic - ld a, $1 ; the usual text box at the bottom of the screen + ld a, MESSAGE_BOX ; the usual text box at the bottom of the screen ld [wTextBoxID], a call DisplayTextBoxID hlCoord 1, 5 @@ -768,7 +768,7 @@ UpdateCurMonHPBar: ; 3c4f6 (f:44f6) xor a .playersTurn push bc - ld [wListMenuID], a + ld [wHPBarType], a predef UpdateHPBar2 pop bc ret @@ -839,7 +839,7 @@ FaintEnemyPokemon ; 0x3c567 res AttackingMultipleTimes, [hl] xor a ld [wPlayerNumHits], a - ld hl, wd065 ; clear enemy statuses + ld hl, wEnemyStatsToDouble ; clear enemy statuses ld [hli], a ld [hli], a ld [hli], a @@ -1137,7 +1137,7 @@ DoUseNextMonDialogue: ; 3c79b (f:479b) .displayYesNoBox hlCoord 13, 9 ld bc, $a0e - ld a, $14 ; yes/no text box + ld a, TWO_OPTION_MENU ld [wTextBoxID], a call DisplayTextBoxID ld a, [wd12e] @@ -1366,7 +1366,7 @@ EnemySendOut: ; 3c90e (f:490e) ; don't change wPartyGainExpFlags or wPartyFoughtCurrentEnemyFlags EnemySendOutFirstMon: ; 3c92a (f:492a) xor a - ld hl,wd065 ; clear enemy statuses + ld hl,wEnemyStatsToDouble ; clear enemy statuses ld [hli],a ld [hli],a ld [hli],a @@ -1454,7 +1454,7 @@ EnemySendOutFirstMon: ; 3c92a (f:492a) call PrintText hlCoord 0, 7 ld bc,$0801 - ld a,$14 + ld a,TWO_OPTION_MENU ld [wTextBoxID],a call DisplayTextBoxID ld a,[wCurrentMenuItem] @@ -1815,7 +1815,7 @@ SendOutMon: ; 3cc91 (f:4c91) ld hl, wPlayerUsedMove ld [hli], a ld [hl], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a ld [hli], a @@ -1899,23 +1899,23 @@ DrawPlayerHUDAndHPBar: ; 3cd60 (f:4d60) call CenterMonName call PlaceString ld hl, wBattleMonSpecies - ld de, wcf98 + ld de, wLoadedMon ld bc, $c call CopyData ld hl, wBattleMonLevel - ld de, wcfb9 + ld de, wLoadedMonLevel ld bc, $b call CopyData hlCoord 14, 8 push hl inc hl - ld de, wcf9c + ld de, wLoadedMonStatus call PrintStatusConditionNotFainted pop hl jr nz, .asm_3cdae call PrintLevel .asm_3cdae - ld a, [wcf98] + ld a, [wLoadedMonSpecies] ld [wcf91], a hlCoord 10, 9 predef DrawHP @@ -1965,7 +1965,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) pop hl jr nz, .skipPrintLevel ; if the mon has a status condition, skip printing the level ld a, [wEnemyMonLevel] - ld [wcfb9], a + ld [wLoadedMonLevel], a call PrintLevel .skipPrintLevel ld hl, wEnemyMonHP @@ -2029,7 +2029,7 @@ DrawEnemyHUDAndHPBar: ; 3cdec (f:4dec) ld c, a .drawHPBar xor a - ld [wListMenuID], a + ld [wHPBarType], a hlCoord 2, 2 call DrawHPBar ld a, $1 @@ -2080,9 +2080,9 @@ DisplayBattleMenu: ; 3ceb3 (f:4eb3) .nonstandardbattle ld a, [W_BATTLETYPE] cp $2 ; safari - ld a, $b ; safari menu id + ld a, BATTLE_MENU_TEMPLATE jr nz, .menuselected - ld a, $1b ; regular menu id + ld a, SAFARI_BATTLE_MENU_TEMPLATE .menuselected ld [wTextBoxID], a call DisplayTextBoxID @@ -2270,9 +2270,9 @@ BagWasSelected: jr nz, DisplayPlayerBag ; no, it is a normal battle ld hl, OldManItemList ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a jr DisplayBagMenu OldManItemList: @@ -2284,9 +2284,9 @@ DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle ld hl, wNumBagItems ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a DisplayBagMenu: xor a @@ -2402,7 +2402,7 @@ PartyMenuOrRockOrRun: call GoBackToPartyMenu jr .checkIfPartyMonWasSelected .partyMonWasSelected - ld a, $c ; switch/stats/cancel menu + ld a, SWITCH_STATS_CANCEL_MENU_TEMPLATE ld [wTextBoxID], a call DisplayTextBoxID ld hl, wTopMenuItemY @@ -2533,21 +2533,21 @@ MoveSelectionMenu: ; 3d219 (f:5219) jr .regularmenu .loadmoves - ld de, wd0dc - ld bc, $4 + ld de, wMoves + ld bc, NUM_MOVES call CopyData - callab Func_39b87 + callab FormatMovesString ret .writemoves - ld de, wd0e1 - ld a, [$fff6] + ld de, wMovesString + ld a, [hFlags_0xFFF6] set 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a call PlaceString - ld a, [$fff6] + ld a, [hFlags_0xFFF6] res 2, a - ld [$fff6], a + ld [hFlags_0xFFF6], a ret .regularmenu @@ -2666,10 +2666,10 @@ SelectMenuItem: ; 3d2fe (f:52fe) call AddNTimes ld [hl], $ec .select - ld hl, $fff6 + ld hl, hFlags_0xFFF6 set 1, [hl] call HandleMenuInput - ld hl, $fff6 + ld hl, hFlags_0xFFF6 res 1, [hl] bit 6, a jp nz, CursorUp ; up @@ -2959,7 +2959,7 @@ PrintMenuItem: ; 3d4b6 (f:54b6) call PrintNumber call GetCurrentMove hlCoord 2, 10 - predef Func_27d98 + predef PrintMoveType .moveDisabled ld a, $1 ld [H_AUTOBGTRANSFERENABLED], a @@ -3554,7 +3554,7 @@ CheckPlayerStatusConditions: ; 3d854 (f:5854) ld a,[hld] add a ld b,a - ld [wd0d8],a + ld [W_DAMAGE + 1],a ld a,[hl] rl a ; double the damage ld [W_DAMAGE],a @@ -4451,7 +4451,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld [wd0b5], a call GetMonHeader ld hl, wEnemyMonDVs - ld de, wcfaf + ld de, wLoadedMonSpeedExp ld a, [hli] ld [de], a inc de @@ -4459,7 +4459,7 @@ GetEnemyMonStat: ; 3df1c (f:5f1c) ld [de], a pop bc ld b, $0 - ld hl, wcfa4 + ld hl, wLoadedMonSpeedExp - $b ; this base address makes CalcStat look in [wLoadedMonSpeedExp] for DVs call CalcStat pop de ret @@ -4899,7 +4899,7 @@ ApplyDamageToEnemyPokemon: ; 3e142 (f:6142) ld [wHPBarNewHP],a hlCoord 2, 2 xor a - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToEnemyPokemonDone: ; 3e19d (f:619d) jp DrawHUDsAndHPBars @@ -5017,7 +5017,7 @@ ApplyDamageToPlayerPokemon: ; 3e200 (f:6200) ld [wHPBarMaxHP],a hlCoord 10, 9 ld a,$01 - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 ; animate the HP bar shortening ApplyAttackToPlayerPokemonDone jp DrawHUDsAndHPBars @@ -5671,7 +5671,7 @@ EnemyCanExecuteChargingMove: ; 3e70b (f:670b) ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld de, wcd6d call CopyStringToCF4B @@ -6053,7 +6053,7 @@ CheckEnemyStatusConditions: ; 3e88f (f:688f) ld a, [hld] add a ld b, a - ld [wd0d8], a + ld [W_DAMAGE + 1], a ld a, [hl] rl a ld [W_DAMAGE], a @@ -6148,7 +6148,7 @@ GetCurrentMove: ; 3eabe (f:6abe) ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld de, wcd6d jp CopyStringToCF4B @@ -6339,7 +6339,7 @@ DoBattleTransitionAndInitBattleVariables: ; 3ec32 (f:6c32) ld [hWY], a ld [rWY], a ld [hTilesetType], a - ld hl, wd060 + ld hl, wPlayerStatsToDouble ld [hli], a ld [hli], a ld [hli], a @@ -6423,10 +6423,11 @@ LoadPlayerBackPic: ; 3ec92 (f:6c92) hlCoord 1, 5 predef_jump Func_3f0c6 -Func_3ed02: ; 3ed02 (f:6d02) - callab Func_39680 - ld hl, Func_396a7 - ld b, BANK(Func_396a7) +; does nothing since no stats are ever selected (barring glitches) +DoubleOrHalveSelectedStats: ; 3ed02 (f:6d02) + callab DoubleSelectedStats + ld hl, HalveSelectedStats + ld b, BANK(HalveSelectedStats) jp Bankswitch ScrollTrainerPicAfterBattle: ; 3ed12 (f:6d12) @@ -6814,7 +6815,7 @@ asm_3ef23: ; 3ef23 (f:6f23) ld a, [wNumberOfNoRandomBattleStepsLeft] and a ret nz - callab Func_13870 + callab TryDoWildEncounter ret nz asm_3ef3d: ; 3ef3d (f:6f3d) ld a, [wMapPalOffset] @@ -6823,7 +6824,7 @@ asm_3ef3d: ; 3ef3d (f:6f3d) ld a, [hl] push af res 1, [hl] - callab Func_525af + callab InitBattleVariables ld a, [wEnemyMonSpecies2] sub $c8 jp c, InitWildBattle @@ -7637,7 +7638,7 @@ UpdateStatDone: ; 3f4ca (f:74ca) call nz, Bankswitch ; play Minimize animation unless there's Substitute involved pop de .asm_3f4f9 - call Func_3fba8 + call PlayCurrentMoveAnimation ld a, [de] cp MINIMIZE jr nz, .applyBadgeBoostsAndStatusPenalties @@ -8451,7 +8452,7 @@ MimicEffect: ; 3f9ed (f:79ed) ld [hl], a ld [wd11e], a call GetMoveName - call Func_3fba8 + call PlayCurrentMoveAnimation ld hl, MimicLearnedMoveText jp PrintText .asm_3fa74 @@ -8467,7 +8468,7 @@ LeechSeedEffect: ; 3fa7c (f:7a7c) jp Bankswitch SplashEffect: ; 3fa84 (f:7a84) - call Func_3fba8 + call PlayCurrentMoveAnimation jp PrintNoEffectText DisableEffect: ; 3fa8a (f:7a8a) @@ -8662,15 +8663,15 @@ Func_3fb96: ; 3fb96 (f:7b96) ld [wcc5b], a jp Func_3fbbc -Func_3fba8: ; 3fba8 (f:7ba8) +PlayCurrentMoveAnimation: ; 3fba8 (f:7ba8) xor a ld [wcc5b], a ld a, [H_WHOSETURN] and a ld a, [W_PLAYERMOVENUM] - jr z, .asm_3fbb7 + jr z, .notEnemyTurn ld a, [W_ENEMYMOVENUM] -.asm_3fbb7 +.notEnemyTurn and a ret z diff --git a/engine/battle/e.asm b/engine/battle/e.asm index 9f93baa6..d124b77a 100755 --- a/engine/battle/e.asm +++ b/engine/battle/e.asm @@ -1,24 +1,25 @@ -Func_39680: ; 39680 (e:5680) - ld a, [H_WHOSETURN] ; $fff3 +; does nothing since no stats are ever selected (barring glitches) +DoubleSelectedStats: ; 39680 (e:5680) + ld a, [H_WHOSETURN] and a - ld a, [wd060] + ld a, [wPlayerStatsToDouble] ld hl, wBattleMonAttack + 1 - jr z, .asm_39691 - ld a, [wd065] + jr z, .notEnemyTurn + ld a, [wEnemyStatsToDouble] ld hl, wEnemyMonAttack + 1 -.asm_39691 - ld c, $4 +.notEnemyTurn + ld c, 4 ld b, a -.asm_39694 +.loop srl b - call c, Func_3969f + call c, .doubleStat inc hl inc hl dec c ret z - jr .asm_39694 + jr .loop -Func_3969f: ; 3969f (e:569f) +.doubleStat ld a, [hl] add a ld [hld], a @@ -27,35 +28,36 @@ Func_3969f: ; 3969f (e:569f) ld [hli], a ret -Func_396a7: ; 396a7 (e:56a7) - ld a, [H_WHOSETURN] ; $fff3 +; does nothing since no stats are ever selected (barring glitches) +HalveSelectedStats: ; 396a7 (e:56a7) + ld a, [H_WHOSETURN] and a - ld a, [wd061] + ld a, [wPlayerStatsToHalve] ld hl, wBattleMonAttack - jr z, .asm_396b8 - ld a, [wd066] + jr z, .notEnemyTurn + ld a, [wEnemyStatsToHalve] ld hl, wEnemyMonAttack -.asm_396b8 - ld c, $4 +.notEnemyTurn + ld c, 4 ld b, a -.asm_396bb +.loop srl b - call c, Func_396c6 + call c, .halveStat inc hl inc hl dec c ret z - jr .asm_396bb + jr .loop -Func_396c6: ; 396c6 (e:56c6) +.halveStat ld a, [hl] srl a ld [hli], a rr [hl] or [hl] - jr nz, .asm_396d1 - ld [hl], $1 -.asm_396d1 + jr nz, .nonzeroStat + ld [hl], 1 +.nonzeroStat dec hl ret @@ -69,41 +71,42 @@ _ScrollTrainerPicAfterBattle: ; 396d3 (e:56d3) callab _LoadTrainerPic hlCoord 19, 0 ld c, $0 -.asm_396e9 +.scrollLoop inc c ld a, c - cp $7 + cp 7 ret z ld d, $0 push bc push hl -.asm_396f2 - call Func_39707 +.drawTrainerPicLoop + call DrawTrainerPicColumn inc hl - ld a, $7 + ld a, 7 add d ld d, a dec c - jr nz, .asm_396f2 - ld c, $4 + jr nz, .drawTrainerPicLoop + ld c, 4 call DelayFrames pop hl pop bc dec hl - jr .asm_396e9 + jr .scrollLoop -Func_39707: ; 39707 (e:5707) +; write one 7-tile column of the trainer pic to the tilemap +DrawTrainerPicColumn: ; 39707 (e:5707) push hl push de push bc - ld e, $7 -.asm_3970c + ld e, 7 +.loop ld [hl], d - ld bc, $14 + ld bc, SCREEN_WIDTH add hl, bc inc d dec e - jr nz, .asm_3970c + jr nz, .loop pop bc pop de pop hl @@ -577,121 +580,124 @@ TrainerPicAndMoneyPointers: ; 39914 (e:5914) INCLUDE "text/trainer_names.asm" -Func_39b87: ; 39b87 (e:5b87) - ld hl, wd0dc - ld de, wd0e1 +; formats a string at wMovesString that lists the moves at wMoves +FormatMovesString: ; 39b87 (e:5b87) + ld hl, wMoves + ld de, wMovesString ld b, $0 -.asm_39b8f +.printMoveNameLoop ld a, [hli] - and a - jr z, .asm_39bc1 + and a ; end of move list? + jr z, .printDashLoop ; print dashes when no moves are left push hl ld [wd0b5], a ld a, BANK(MoveNames) ld [wPredefBank], a ld a, MOVE_NAME - ld [W_LISTTYPE], a + ld [wNameListType], a call GetName ld hl, wcd6d -.asm_39ba7 +.copyNameLoop ld a, [hli] cp $50 - jr z, .asm_39bb0 + jr z, .doneCopyingName ld [de], a inc de - jr .asm_39ba7 -.asm_39bb0 + jr .copyNameLoop +.doneCopyingName ld a, b ld [wcd6c], a inc b - ld a, $4e + ld a, $4e ; line break ld [de], a inc de pop hl ld a, b - cp $4 - jr z, .asm_39bd1 - jr .asm_39b8f -.asm_39bc1 + cp NUM_MOVES + jr z, .done + jr .printMoveNameLoop +.printDashLoop ld a, "-" ld [de], a inc de inc b ld a, b - cp $4 - jr z, .asm_39bd1 - ld a, $4e + cp NUM_MOVES + jr z, .done + ld a, $4e ; line break ld [de], a inc de - jr .asm_39bc1 -.asm_39bd1 + jr .printDashLoop +.done ld a, "@" ld [de], a ret +; XXX this is called in a few places, but it doesn't appear to do anything useful Func_39bd5: ; 39bd5 (e:5bd5) ld a, [wd11b] cp $1 jr nz, .asm_39be6 - ld hl, wEnemyPartyCount ; wEnemyPartyCount - ld de, wEnemyMonOT ; wd9ac OT names of other player - ld a, $6 + ld hl, wEnemyPartyCount + ld de, wEnemyMonOT + ld a, ENEMYOT_NAME jr .asm_39c18 .asm_39be6 cp $4 jr nz, .calcAttackStat4 - ld hl, wPartyCount ; wPartyCount - ld de, wPartyMonOT ; wd273 - ld a, $5 + ld hl, wPartyCount + ld de, wPartyMonOT + ld a, PLAYEROT_NAME jr .asm_39c18 .calcAttackStat4 cp $5 jr nz, .asm_39c02 ld hl, wStringBuffer2 + 11 - ld de, MonsterNames ; $421e - ld a, $1 + ld de, MonsterNames + ld a, MONSTER_NAME jr .asm_39c18 .asm_39c02 cp $2 jr nz, .asm_39c10 - ld hl, wNumBagItems ; wNumBagItems - ld de, ItemNames ; $472b - ld a, $4 + ld hl, wNumBagItems + ld de, ItemNames + ld a, ITEM_NAME jr .asm_39c18 .asm_39c10 ld hl, wStringBuffer2 + 11 - ld de, ItemNames ; $472b + ld de, ItemNames ld a, ITEM_NAME .asm_39c18 - ld [W_LISTTYPE], a + ld [wNameListType], a ld a, l - ld [wcf8b], a + ld [wList], a ld a, h - ld [wcf8c], a + ld [wList + 1], a ld a, e ld [wcf8d], a ld a, d ld [wcf8e], a - ld bc, ItemPrices ; $4608 + ld bc, ItemPrices ld a, c - ld [wcf8f], a + ld [wItemPrices], a ld a, b - ld [wcf90], a + ld [wItemPrices + 1], a ret -Func_39c37: ; 39c37 (e:5c37) +; get species of mon e in list [wcc49] for LoadMonData +GetMonSpecies: ; 39c37 (e:5c37) ld hl, wPartySpecies ld a, [wcc49] and a - jr z, .asm_39c4b + jr z, .getSpecies dec a - jr z, .asm_39c48 + jr z, .enemyParty ld hl, wBoxSpecies - jr .asm_39c4b -.asm_39c48 + jr .getSpecies +.enemyParty ld hl, wEnemyPartyMons -.asm_39c4b - ld d, $0 +.getSpecies + ld d, 0 add hl, de ld a, [hl] ld [wcf91], a @@ -954,7 +960,7 @@ TrainerAIPointers: ; 3a55c (e:655c) JugglerAI: ; 3a5e9 (e:65e9) cp $40 ret nc - jp Func_3a72a + jp AISwitchIfEnoughMons BlackbeltAI: ; 3a5ef (e:65ef) cp $20 @@ -974,12 +980,12 @@ CooltrainerMAI: ; 3a5fb (e:65fb) CooltrainerFAI: ; 3a601 (e:6601) cp $40 ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction jp c,AIUseHyperPotion ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc - jp Func_3a72a + jp AISwitchIfEnoughMons BrockAI: ; 3a614 (e:6614) ; if his active monster has a status condition, use a full heal @@ -1002,7 +1008,7 @@ ErikaAI: ; 3a628 (e:6628) cp $80 ret nc ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1020,7 +1026,7 @@ SabrinaAI: ; 3a640 (e:6640) cp $40 ret nc ld a,$A - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseHyperPotion @@ -1028,7 +1034,7 @@ Sony2AI: ; 3a64c (e:664c) cp $20 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUsePotion @@ -1036,7 +1042,7 @@ Sony3AI: ; 3a658 (e:6658) cp $20 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseFullRestore @@ -1044,7 +1050,7 @@ LoreleiAI: ; 3a664 (e:6664) cp $80 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1055,11 +1061,11 @@ BrunoAI: ; 3a670 (e:6670) AgathaAI: ; 3a676 (e:6676) cp $14 - jp c,Func_3a72a + jp c,AISwitchIfEnoughMons cp $80 ret nc ld a,4 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseSuperPotion @@ -1067,7 +1073,7 @@ LanceAI: ; 3a687 (e:6687) cp $80 ret nc ld a,5 - call Func_3a7cf + call AICheckIfHPBelowFraction ret nc jp AIUseHyperPotion @@ -1109,7 +1115,7 @@ AIUseFullRestore: ; 3a6a0 (e:66a0) ld [de],a ld [wHPBarMaxHP+1],a ld [wEnemyMonHP],a - jr Func_3a718 + jr AIPrintItemUseAndUpdateHPBar AIUsePotion: ; 3a6ca (e:66ca) ; enemy trainer heals his monster with a potion @@ -1159,7 +1165,7 @@ AIRecoverHP: ; 3a6da (e:66da) ld a,[de] ld [wHPBarMaxHP+1],a sbc b - jr nc,Func_3a718 + jr nc,AIPrintItemUseAndUpdateHPBar inc de ld a,[de] dec de @@ -1170,15 +1176,16 @@ AIRecoverHP: ; 3a6da (e:66da) ld [wHPBarNewHP+1],a ; fallthrough -Func_3a718: ; 3a718 (e:6718) +AIPrintItemUseAndUpdateHPBar: ; 3a718 (e:6718) call AIPrintItemUse_ hlCoord 2, 2 xor a - ld [wListMenuID],a + ld [wHPBarType],a predef UpdateHPBar2 jp DecrementAICount -Func_3a72a: ; 3a72a (e:672a) +AISwitchIfEnoughMons: ; 3a72a (e:672a) +; enemy trainer switches if there are 3 or more unfainted mons in party ld a,[wEnemyPartyCount] ld c,a ld hl,wEnemyMon1HP @@ -1280,7 +1287,8 @@ AIUseDireHit: ; 0x3a7c2 unused ld a,DIRE_HIT jp AIPrintItemUse -Func_3a7cf: ; 3a7cf (e:67cf) +AICheckIfHPBelowFraction: ; 3a7cf (e:67cf) +; return carry if enemy trainer's current HP is below 1 / a of the maximum ld [H_DIVISOR],a ld hl,wEnemyMonMaxHP ld a,[hli] @@ -1394,7 +1402,7 @@ SetupOwnPartyPokeballs: ; 3a869 (e:6869) ld a, $8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer - jp Func_3a8e1 + jp WritePokeballOAMData SetupEnemyPartyPokeballs: ; 3a887 (e:6887) call PlaceEnemyHUDTiles @@ -1408,7 +1416,7 @@ SetupEnemyPartyPokeballs: ; 3a887 (e:6887) ld a, $f8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer + PARTY_LENGTH * 4 - jp Func_3a8e1 + jp WritePokeballOAMData SetupPokeballs: ; 0x3a8a6 ld a, [de] @@ -1420,7 +1428,7 @@ SetupPokeballs: ; 0x3a8a6 ld [de], a inc de dec c - jr nz, .emptyloop ; 0x3a8b2 $fb + jr nz, .emptyloop pop af ld de, wBuffer .monloop @@ -1460,10 +1468,10 @@ PickPokeball: ; 3a8c2 (e:68c2) add hl, bc ret -Func_3a8e1: ; 3a8e1 (e:68e1) - ld de, wHPBarMaxHP +WritePokeballOAMData: ; 3a8e1 (e:68e1) + ld de, wBuffer ld c, PARTY_LENGTH -.asm_3a8e6 +.loop ld a, [W_BASECOORDY] ; wd082 ld [hli], a ld a, [W_BASECOORDX] ; wd081 @@ -1479,7 +1487,7 @@ Func_3a8e1: ; 3a8e1 (e:68e1) ld [W_BASECOORDX], a ; wd081 inc de dec c - jr nz, .asm_3a8e6 + jr nz, .loop ret PlacePlayerHUDTiles: ; 3a902 (e:6902) @@ -1541,7 +1549,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) ld a, $8 ld [wTrainerEngageDistance], a ld hl, wOAMBuffer - call Func_3a8e1 + call WritePokeballOAMData ld hl, wEnemyMons ; wEnemyMon1Species ld de, wEnemyPartyCount ; wEnemyPartyCount call SetupPokeballs @@ -1550,7 +1558,7 @@ SetupPlayerAndEnemyPokeballs: ; 3a948 (e:6948) ld [hli], a ld [hl], $68 ld hl, wOAMBuffer + $18 - jp Func_3a8e1 + jp WritePokeballOAMData ; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon) PokeballTileGraphics:: ; 3a97e (e:697e) diff --git a/engine/battle/e_2.asm b/engine/battle/e_2.asm index 6c159c56..9400282d 100755 --- a/engine/battle/e_2.asm +++ b/engine/battle/e_2.asm @@ -1,13 +1,13 @@ HealEffect_: ; 3b9ec (e:79ec) - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a - ld de, wBattleMonHP ; wd015 - ld hl, wBattleMonMaxHP ; wd023 - ld a, [W_PLAYERMOVENUM] ; wcfd2 + ld de, wBattleMonHP + ld hl, wBattleMonMaxHP + ld a, [W_PLAYERMOVENUM] jr z, .asm_3ba03 - ld de, wEnemyMonHP ; wEnemyMonHP - ld hl, wEnemyMonMaxHP ; wEnemyMonMaxHP - ld a, [W_ENEMYMOVENUM] ; W_ENEMYMOVENUM + ld de, wEnemyMonHP + ld hl, wEnemyMonMaxHP + ld a, [W_ENEMYMOVENUM] .asm_3ba03 ld b, a ld a, [de] @@ -16,27 +16,27 @@ HealEffect_: ; 3b9ec (e:79ec) inc hl ld a, [de] sbc [hl] - jp z, Func_3ba97 + jp z, .failed ld a, b cp REST jr nz, .asm_3ba37 push hl push de push af - ld c, $32 + ld c, 50 call DelayFrames - ld hl, wBattleMonStatus ; wBattleMonStatus - ld a, [H_WHOSETURN] ; $fff3 + ld hl, wBattleMonStatus + ld a, [H_WHOSETURN] and a jr z, .asm_3ba25 - ld hl, wEnemyMonStatus ; wcfe9 + ld hl, wEnemyMonStatus .asm_3ba25 ld a, [hl] and a ld [hl], 2 ; Number of turns from Rest - ld hl, StartedSleepingEffect ; $7aa2 + ld hl, StartedSleepingEffect jr z, .asm_3ba31 - ld hl, FellAsleepBecameHealthyText ; $7aa7 + ld hl, FellAsleepBecameHealthyText .asm_3ba31 call PrintText pop af @@ -81,9 +81,9 @@ HealEffect_: ; 3b9ec (e:79ec) ld [de], a ld [wHPBarNewHP], a .asm_3ba6f - ld hl, Func_3fba8 ; $7ba8 + ld hl, PlayCurrentMoveAnimation call BankswitchEtoF - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a hlCoord 10, 9 ld a, $1 @@ -91,15 +91,14 @@ HealEffect_: ; 3b9ec (e:79ec) hlCoord 2, 2 xor a .asm_3ba83 - ld [wListMenuID], a ; wListMenuID + ld [wHPBarType], a predef UpdateHPBar2 - ld hl, DrawHUDsAndHPBars ; $4d5a + ld hl, DrawHUDsAndHPBars call BankswitchEtoF - ld hl, RegainedHealthText ; $7aac + ld hl, RegainedHealthText jp PrintText - -Func_3ba97: ; 3ba97 (e:7a97) - ld c, $32 +.failed + ld c, 50 call DelayFrames ld hl, PrintButItFailedText_ jp BankswitchEtoF @@ -119,37 +118,37 @@ RegainedHealthText: ; 3baac (e:7aac) TransformEffect_: ; 3bab1 (e:7ab1) ld hl, wBattleMonSpecies ld de, wEnemyMonSpecies - ld bc, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld a, [W_ENEMYBATTSTATUS1] ; W_ENEMYBATTSTATUS1 - ld a, [H_WHOSETURN] ; $fff3 + ld bc, W_ENEMYBATTSTATUS3 + ld a, [W_ENEMYBATTSTATUS1] + ld a, [H_WHOSETURN] and a jr nz, .asm_3bad1 ld hl, wEnemyMonSpecies ld de, wBattleMonSpecies - ld bc, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 - ld [wPlayerMoveListIndex], a ; wPlayerMoveListIndex - ld a, [W_PLAYERBATTSTATUS1] ; W_PLAYERBATTSTATUS1 + ld bc, W_PLAYERBATTSTATUS3 + ld [wPlayerMoveListIndex], a + ld a, [W_PLAYERBATTSTATUS1] .asm_3bad1 bit Invulnerable, a ; is mon invulnerable to typical attacks? (fly/dig) - jp nz, Func_3bb8c + jp nz, .failed push hl push de push bc - ld hl, W_PLAYERBATTSTATUS2 ; W_PLAYERBATTSTATUS2 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS2 + ld a, [H_WHOSETURN] and a jr z, .asm_3bae4 - ld hl, W_ENEMYBATTSTATUS2 ; W_ENEMYBATTSTATUS2 + ld hl, W_ENEMYBATTSTATUS2 .asm_3bae4 bit HasSubstituteUp, [hl] push af ld hl, Func_79747 ld b, BANK(Func_79747) call nz, Bankswitch - ld a, [W_OPTIONS] ; W_OPTIONS + ld a, [W_OPTIONS] add a - ld hl, Func_3fba8 ; $7ba8 - ld b, BANK(Func_3fba8) + ld hl, PlayCurrentMoveAnimation + ld b, BANK(PlayCurrentMoveAnimation) jr nc, .asm_3baff ld hl, AnimationTransformMon ld b, BANK(AnimationTransformMon) @@ -178,7 +177,7 @@ TransformEffect_: ; 3bab1 (e:7ab1) inc bc inc bc call CopyData - ld a, [H_WHOSETURN] ; $fff3 + ld a, [H_WHOSETURN] and a jr z, .asm_3bb32 ld a, [de] @@ -228,15 +227,15 @@ TransformEffect_: ; 3bab1 (e:7ab1) call GetMonName ld hl, wEnemyMonUnmodifiedAttack ld de, wPlayerMonUnmodifiedAttack - call Func_3bb7d - ld hl, wEnemyMonStatMods ; wcd2e - ld de, wPlayerMonStatMods ; wcd1a - call Func_3bb7d - ld hl, TransformedText ; $7b92 + call .copyBasedOnTurn + ld hl, wEnemyMonStatMods + ld de, wPlayerMonStatMods + call .copyBasedOnTurn + ld hl, TransformedText jp PrintText -Func_3bb7d: ; 3bb7d (e:7b7d) - ld a, [H_WHOSETURN] ; $fff3 +.copyBasedOnTurn + ld a, [H_WHOSETURN] and a jr z, .asm_3bb86 push hl @@ -247,8 +246,8 @@ Func_3bb7d: ; 3bb7d (e:7b7d) ld bc, $8 jp CopyData -Func_3bb8c: ; 3bb8c (e:7b8c) - ld hl, PrintButItFailedText_ ; $7b53 +.failed + ld hl, PrintButItFailedText_ jp BankswitchEtoF TransformedText: ; 3bb92 (e:7b92) @@ -256,13 +255,13 @@ TransformedText: ; 3bb92 (e:7b92) db "@" ReflectLightScreenEffect_: ; 3bb97 (e:7b97) - ld hl, W_PLAYERBATTSTATUS3 ; W_PLAYERBATTSTATUS3 - ld de, W_PLAYERMOVEEFFECT ; wcfd3 - ld a, [H_WHOSETURN] ; $fff3 + ld hl, W_PLAYERBATTSTATUS3 + ld de, W_PLAYERMOVEEFFECT + ld a, [H_WHOSETURN] and a jr z, .asm_3bba8 - ld hl, W_ENEMYBATTSTATUS3 ; W_ENEMYBATTSTATUS3 - ld de, W_ENEMYMOVEEFFECT ; W_ENEMYMOVEEFFECT + ld hl, W_ENEMYBATTSTATUS3 + ld de, W_ENEMYMOVEEFFECT .asm_3bba8 ld a, [de] cp LIGHT_SCREEN_EFFECT @@ -270,23 +269,23 @@ ReflectLightScreenEffect_: ; 3bb97 (e:7b97) bit HasLightScreenUp, [hl] ; is mon already protected by light screen? jr nz, .moveFailed set HasLightScreenUp, [hl] ; mon is now protected by light screen - ld hl, LightScreenProtectedText ; $7bd7 + ld hl, LightScreenProtectedText jr .asm_3bbc1 .reflect bit HasReflectUp, [hl] ; is mon already protected by reflect? jr nz, .moveFailed set HasReflectUp, [hl] ; mon is now protected by reflect - ld hl, ReflectGainedArmorText ; $7bdc + ld hl, ReflectGainedArmorText .asm_3bbc1 push hl - ld hl, Func_3fba8 ; $7ba8 + ld hl, PlayCurrentMoveAnimation call BankswitchEtoF pop hl jp PrintText .moveFailed ld c, $32 call DelayFrames - ld hl, PrintButItFailedText_ ; $7b53 + ld hl, PrintButItFailedText_ jp BankswitchEtoF LightScreenProtectedText: ; 3bbd7 (e:7bd7) |