From 3a4382c6055e21da72357dd18638947a2acbbda9 Mon Sep 17 00:00:00 2001 From: Narishma-gb <194818981+Narishma-gb@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:39:25 +0100 Subject: Use more Pokemon data constants, create MOVE_NAME_LENGTH (#543) --- engine/battle/experience.asm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engine/battle/experience.asm') diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index a8ee6747..4e44643c 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -21,7 +21,7 @@ GainExperience: and a ; is mon's gain exp flag set? pop hl jp z, .nextMon ; if mon's gain exp flag not set, go to next mon - ld de, (wPartyMon1HPExp + 1) - (wPartyMon1HP + 1) + ld de, (MON_HP_EXP + 1) - (MON_HP + 1) add hl, de ld d, h ld e, l @@ -66,9 +66,9 @@ GainExperience: ldh [hDivisor], a ld b, 4 call Divide - ld hl, wPartyMon1OTID - (wPartyMon1DVs - 1) + ld hl, MON_OTID - (MON_DVS - 1) add hl, de - ld b, [hl] ; party mon OTID + ld b, [hl] ; wPartyMon*OTID inc hl ld a, [wPlayerID] cp b @@ -152,7 +152,7 @@ GainExperience: ld [wMonDataLocation], a call LoadMonData pop hl - ld bc, wPartyMon1Level - wPartyMon1Exp + ld bc, MON_LEVEL - MON_EXP add hl, bc push hl farcall CalcLevelFromExperience @@ -166,13 +166,13 @@ GainExperience: ld a, d ld [wCurEnemyLevel], a ld [hl], a - ld bc, wPartyMon1Species - wPartyMon1Level + ld bc, MON_SPECIES - MON_LEVEL add hl, bc ld a, [hl] ld [wCurSpecies], a ld [wPokedexNum], a call GetMonHeader - ld bc, (wPartyMon1MaxHP + 1) - wPartyMon1Species + ld bc, (MON_MAXHP + 1) - MON_SPECIES add hl, bc push hl ld a, [hld] @@ -181,7 +181,7 @@ GainExperience: push bc ; push max HP (from before levelling up) ld d, h ld e, l - ld bc, (wPartyMon1HPExp - 1) - wPartyMon1MaxHP + ld bc, (MON_HP_EXP - 1) - MON_MAXHP add hl, bc ld b, $1 ; consider stat exp when calculating stats call CalcStats @@ -193,15 +193,15 @@ GainExperience: ld a, [hl] sbc b ld b, a ; bc = difference between old max HP and new max HP after levelling - ld de, (wPartyMon1HP + 1) - wPartyMon1MaxHP + ld de, (MON_HP + 1) - MON_MAXHP add hl, de ; add to the current HP the amount of max HP gained when levelling - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 add c ld [hld], a - ld a, [hl] ; wPartyMon1HP + 1 + ld a, [hl] ; wPartyMon*HP + 1 adc b - ld [hl], a ; wPartyMon1HP + ld [hl], a ; wPartyMon*HP ld a, [wPlayerMonNumber] ld b, a ld a, [wWhichPokemon] @@ -216,7 +216,7 @@ GainExperience: ld a, [hl] ld [de], a ; copy other stats from party mon to battle mon - ld bc, wPartyMon1Level - (wPartyMon1HP + 1) + ld bc, MON_LEVEL - (MON_HP + 1) add hl, bc push hl ld de, wBattleMonLevel @@ -271,7 +271,7 @@ GainExperience: cp b jr z, .done ld [wWhichPokemon], a - ld bc, wPartyMon2 - wPartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1 call AddNTimes jp .partyMonLoop -- cgit v1.3.1-sl0p From 8bb03542bd0dd01b1e4fce990751edc0822a878f Mon Sep 17 00:00:00 2001 From: Narishma-gb <194818981+Narishma-gb@users.noreply.github.com> Date: Mon, 1 Dec 2025 20:46:28 +0100 Subject: Update `StatusScreen`, add `*_STATS_BOX` constants (#546) --- constants/menu_constants.asm | 5 +++ engine/battle/experience.asm | 2 +- engine/items/item_effects.asm | 22 ++++++------- engine/pokemon/status_screen.asm | 70 ++++++++++++++++++---------------------- home/pics.asm | 4 +-- 5 files changed, 51 insertions(+), 52 deletions(-) (limited to 'engine/battle/experience.asm') diff --git a/constants/menu_constants.asm b/constants/menu_constants.asm index a6e035e7..c4476e03 100644 --- a/constants/menu_constants.asm +++ b/constants/menu_constants.asm @@ -90,3 +90,8 @@ DEF FIRST_PARTY_MENU_TEXT_ID EQU const_value const NAME_PLAYER_SCREEN ; 0 const NAME_RIVAL_SCREEN ; 1 const NAME_MON_SCREEN ; 2 + +; Stats box layout (see engine/pokemon/status_screen.asm) + const_def + const STATUS_SCREEN_STATS_BOX ; 0 + const LEVEL_UP_STATS_BOX ; 1 diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index 4e44643c..f9f47f82 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -245,7 +245,7 @@ GainExperience: xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a call LoadMonData - ld d, $1 + ld d, LEVEL_UP_STATS_BOX callfar PrintStatsBox call WaitForTextScrollButtonPress call LoadScreenTilesFromBuffer1 diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index a716ebb7..90853bee 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -1400,15 +1400,15 @@ ItemUseMedicine: xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a call LoadMonData - ld d, $01 - callfar PrintStatsBox ; display new stats text box - call WaitForTextScrollButtonPress ; wait for button press + ld d, LEVEL_UP_STATS_BOX + callfar PrintStatsBox + call WaitForTextScrollButtonPress xor a ; PLAYER_PARTY_DATA ld [wMonDataLocation], a - predef LearnMoveFromLevelUp ; learn level up move, if any + predef LearnMoveFromLevelUp xor a ld [wForceEvolution], a - callfar TryEvolvingMon ; evolve pokemon, if appropriate + callfar TryEvolvingMon ld a, $01 ld [wUpdateSpritesEnabled], a pop af @@ -1433,11 +1433,11 @@ INCLUDE "data/battle/stat_names.asm" ItemUseBait: ld hl, ThrewBaitText call PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate srl [hl] ; halve catch rate ld a, BAIT_ANIM - ld hl, wSafariBaitFactor ; bait factor - ld de, wSafariEscapeFactor ; escape factor + ld hl, wSafariBaitFactor + ld de, wSafariEscapeFactor jr BaitRockCommon ; for CASCADEBADGE when used from the @@ -1446,7 +1446,7 @@ ItemUseBait: ItemUseRock: ld hl, ThrewRockText call PrintText - ld hl, wEnemyMonActualCatchRate ; catch rate + ld hl, wEnemyMonActualCatchRate ld a, [hl] add a ; double catch rate jr nc, .noCarry @@ -1454,8 +1454,8 @@ ItemUseRock: .noCarry ld [hl], a ld a, ROCK_ANIM - ld hl, wSafariEscapeFactor ; escape factor - ld de, wSafariBaitFactor ; bait factor + ld hl, wSafariEscapeFactor + ld de, wSafariBaitFactor BaitRockCommon: ld [wAnimationID], a diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 9c708a22..84a56d5a 100644 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -61,8 +61,6 @@ DrawHP_: pop de ret - -; Predef 0x37 StatusScreen: call LoadMonData ld a, [wMonDataLocation] @@ -75,7 +73,7 @@ StatusScreen: ld hl, wLoadedMonHPExp - 1 ld de, wLoadedMonStats ld b, $1 - call CalcStats ; Recalculate stats + call CalcStats .DontRecalculate ld hl, wStatusFlags2 set BIT_NO_AUDIO_FADE_OUT, [hl] @@ -117,8 +115,8 @@ StatusScreen: lb bc, 8, 6 call DrawLineBox ; Draws the box around types, ID No. and OT hlcoord 10, 9 - ld de, Type1Text - call PlaceString ; "TYPE1/" + ld de, TypesIDNoOTText + call PlaceString hlcoord 11, 3 predef DrawHP ld hl, wStatusScreenHPBarColor @@ -137,7 +135,7 @@ StatusScreen: ld de, StatusText call PlaceString ; "STATUS/" hlcoord 14, 2 - call PrintLevel ; Pokémon level + call PrintLevel ld a, [wMonHIndex] ld [wPokedexNum], a ld [wCurSpecies], a @@ -164,7 +162,7 @@ StatusScreen: ld de, wLoadedMonOTID lb bc, LEADING_ZEROES | 2, 5 call PrintNumber ; ID Number - ld d, $0 + ld d, STATUS_SCREEN_STATS_BOX call PrintStatsBox call Delay3 call GBPalNormal @@ -204,20 +202,11 @@ NamePointers2: dw wBoxMonNicks dw wDayCareMonName -Type1Text: +TypesIDNoOTText: db "TYPE1/" - next "" - ; fallthrough -Type2Text: - db "TYPE2/" - next "" - ; fallthrough -IDNoText: - db "№/" - next "" - ; fallthrough -OTText: - db "OT/" + next "TYPE2/" + next "№/" + next "OT/" next "@" StatusText: @@ -248,40 +237,42 @@ PTile: INCBIN "gfx/font/P.1bpp" PrintStatsBox: ld a, d - and a ; a is 0 from the status screen - jr nz, .DifferentBox + ASSERT STATUS_SCREEN_STATS_BOX == 0 + and a + jr nz, .LevelUpStatsBox ; battle or Rare Candy hlcoord 0, 8 ld b, 8 ld c, 8 - call TextBoxBorder ; Draws the box - hlcoord 1, 9 ; Start printing stats from here - ld bc, $19 ; Number offset + call TextBoxBorder + hlcoord 1, 9 + ld bc, SCREEN_WIDTH + 5 ; one row down and 5 columns right jr .PrintStats -.DifferentBox +.LevelUpStatsBox hlcoord 9, 2 ld b, 8 ld c, 9 call TextBoxBorder hlcoord 11, 3 - ld bc, $18 + ld bc, SCREEN_WIDTH + 4 ; one row down and 4 columns right .PrintStats push bc push hl - ld de, StatsText + ld de, .StatsText call PlaceString pop hl pop bc add hl, bc ld de, wLoadedMonAttack lb bc, 2, 3 - call PrintStat + call .PrintStat ld de, wLoadedMonDefense - call PrintStat + call .PrintStat ld de, wLoadedMonSpeed - call PrintStat + call .PrintStat ld de, wLoadedMonSpecial jp PrintNumber -PrintStat: + +.PrintStat: push hl call PrintNumber pop hl @@ -289,7 +280,7 @@ PrintStat: add hl, de ret -StatsText: +.StatsText: db "ATTACK" next "DEFENSE" next "SPEED" @@ -323,10 +314,10 @@ StatusScreen2: call PlaceString ; Print moves ld a, [wNumMovesMinusOne] inc a - ld c, a - ld a, $4 + ld c, a ; number of known moves + ld a, NUM_MOVES sub c - ld b, a ; Number of moves ? + ld b, a ; number of blank moves hlcoord 11, 10 ld de, SCREEN_WIDTH * 2 ld a, '' @@ -386,7 +377,7 @@ StatusScreen2: pop bc inc b ld a, b - cp $4 + cp NUM_MOVES jr nz, .PrintPP .PPDone hlcoord 9, 3 @@ -415,8 +406,11 @@ StatusScreen2: hlcoord 7, 6 lb bc, 3, 7 call PrintNumber ; exp needed to level up + + ; unneeded, this clears the diacritic characters in JPN versions hlcoord 9, 0 call StatusScreen_ClearName + hlcoord 9, 1 call StatusScreen_ClearName ld a, [wMonHIndex] @@ -468,7 +462,7 @@ StatusScreenExpText: next "LEVEL UP@" StatusScreen_ClearName: - ld bc, 10 + ld bc, NAME_LENGTH - 1 ld a, ' ' jp FillMemory diff --git a/home/pics.asm b/home/pics.asm index 475e834d..5ebb8f82 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -188,9 +188,9 @@ InterlaceMergeSpriteBuffers:: or c jr nz, .swapLoop .notFlipped - pop hl + pop hl ; hl = output address ld de, sSpriteBuffer1 - ld c, (2 * SPRITEBUFFERSIZE) / TILE_SIZE ; $31, number of 16 byte chunks to be copied + ld c, PIC_SIZE ; tiles ldh a, [hLoadedROMBank] ld b, a jp CopyVideoData -- cgit v1.3.1-sl0p