From 147914d179f29f0d5c08bad027040731e323ed92 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Sat, 8 Mar 2025 11:16:42 -0500 Subject: Use constants for trade text indexes (#501) --- constants/script_constants.asm | 1 + 1 file changed, 1 insertion(+) (limited to 'constants') diff --git a/constants/script_constants.asm b/constants/script_constants.asm index 24ad93f2..8b59a6f6 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -38,6 +38,7 @@ DEF NUM_NPC_TRADES EQU const_value const TRADE_DIALOGSET_CASUAL const TRADE_DIALOGSET_EVOLUTION const TRADE_DIALOGSET_HAPPY +DEF NUM_TRADE_DIALOGSETS EQU const_value ; OaksAideScript results DEF OAKS_AIDE_BAG_FULL EQU $00 -- cgit v1.3.1-sl0p From e1b7b8af0a431f4624fc668a58b535a8be438d72 Mon Sep 17 00:00:00 2001 From: edave64 Date: Wed, 2 Apr 2025 16:49:15 +0200 Subject: Use constants for PP masks instead of magic numbers (#504) --- constants/pokemon_data_constants.asm | 4 ++++ engine/battle/core.asm | 16 ++++++++-------- engine/battle/effects.asm | 2 +- engine/events/heal_party.asm | 2 +- engine/items/item_effects.asm | 10 +++++----- engine/pokemon/status_screen.asm | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) (limited to 'constants') diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 5cc2d344..e174f78d 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -98,3 +98,7 @@ DEF NUM_GROWTH_RATES EQU const_value ; wild data (see data/wild/maps/*.asm) DEF NUM_WILDMONS EQU 10 DEF WILDDATA_LENGTH EQU 1 + NUM_WILDMONS * 2 + +; PP in box_struct (see macros/ram.asm) +DEF PP_UP_MASK EQU %11000000 ; number of PP Up used +DEF PP_MASK EQU %00111111 ; currently remaining PP diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f304af10..4fe7880f 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -2644,7 +2644,7 @@ SelectMenuItem: ld b, $0 add hl, bc ld a, [hl] - and $3f + and PP_MASK jr z, .noPP ld a, [wPlayerDisabledMove] swap a @@ -2724,7 +2724,7 @@ AnyMoveToSelect: or [hl] inc hl or [hl] - and $3f + and PP_MASK ret nz jr .noMovesLeft .handleDisabledMove @@ -2878,7 +2878,7 @@ PrintMenuItem: ld hl, wBattleMonPP add hl, bc ld a, [hl] - and $3f + and PP_MASK ld [wBattleMenuCurrentPP], a ; print TYPE/ and / hlcoord 1, 9 @@ -4071,18 +4071,18 @@ CheckForDisobedience: ld hl, wBattleMonPP push hl ld a, [hli] - and $3f + and PP_MASK ld b, a ld a, [hli] - and $3f + and PP_MASK add b ld b, a ld a, [hli] - and $3f + and PP_MASK add b ld b, a ld a, [hl] - and $3f + and PP_MASK add b pop hl push af @@ -4091,7 +4091,7 @@ CheckForDisobedience: ld b, $0 add hl, bc ld a, [hl] - and $3f + and PP_MASK ld b, a pop af cp b diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 439e41e2..5782a3f0 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -1332,7 +1332,7 @@ DisableEffect: or [hl] inc hl or [hl] - and $3f + and PP_MASK pop hl ; wBattleMonPP or wEnemyMonPP jr z, .moveMissedPopHL ; nothing to do if all moves have no PP left add hl, bc diff --git a/engine/events/heal_party.asm b/engine/events/heal_party.asm index 8bf162a7..e6551bcd 100644 --- a/engine/events/heal_party.asm +++ b/engine/events/heal_party.asm @@ -50,7 +50,7 @@ HealParty: push bc ld b, a ld a, [hl] - and $c0 + and PP_UP_MASK add b ld [hl], a pop bc diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 162e79a7..98f1b066 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -2058,7 +2058,7 @@ ItemUsePPRestore: cp MAX_ETHER jr z, .fullyRestorePP ld a, [hl] ; move PP - and %00111111 ; lower 6 bit bits store current PP + and PP_MASK cp b ; does current PP equal max PP? ret z ; if so, return add 10 ; increase current PP by 10 @@ -2071,7 +2071,7 @@ ItemUsePPRestore: ld b, a .storeNewAmount ld a, [hl] ; move PP - and %11000000 ; PP Up counter bits + and PP_UP_MASK add b ld [hl], a ret @@ -2403,7 +2403,7 @@ RestoreBonusPP: jr nz, .nextMove .skipMenuItemIDCheck ld a, [hl] - and %11000000 ; have any PP Ups been used? + and PP_UP_MASK call nz, AddBonusPP ; if so, add bonus PP .nextMove inc hl @@ -2509,7 +2509,7 @@ GetMaxPP: .addPPOffset add hl, bc ld a, [hl] ; a = current PP - and %11000000 ; get PP Up count + and PP_UP_MASK pop bc or b ; place normal max PP in 6 lower bits of a ASSERT wMoveData + MOVE_PP + 1 == wPPUpCountAndMaxPP @@ -2521,7 +2521,7 @@ GetMaxPP: ld [wUsingPPUp], a call AddBonusPP ; add bonus PP from PP Ups ld a, [hl] - and %00111111 ; mask out the PP Up count + and PP_MASK ld [wMaxPP], a ; store max PP ret diff --git a/engine/pokemon/status_screen.asm b/engine/pokemon/status_screen.asm index 447db8fd..0649949c 100644 --- a/engine/pokemon/status_screen.asm +++ b/engine/pokemon/status_screen.asm @@ -364,7 +364,7 @@ StatusScreen2: ld bc, wPartyMon1PP - wPartyMon1Moves - 1 add hl, bc ld a, [hl] - and $3f + and PP_MASK ld [wStatusScreenCurrentPP], a ld h, d ld l, e -- cgit v1.3.1-sl0p From 0ecc36c83a6bf3ecfee45e9f62afc3ebfb97b024 Mon Sep 17 00:00:00 2001 From: Narishma-gb <194818981+Narishma-gb@users.noreply.github.com> Date: Wed, 9 Apr 2025 05:17:32 +0200 Subject: Use constants in `PrintBCDNumber` calls (#503) --- constants/text_constants.asm | 2 +- engine/events/prize_menu.asm | 11 ++++------- engine/menus/start_sub_menus.asm | 2 +- engine/menus/text_box.asm | 2 +- engine/movie/hall_of_fame.asm | 2 +- engine/slots/slot_machine.asm | 2 +- home/list_menu.asm | 4 ++-- scripts/GameCorner.asm | 2 +- 8 files changed, 12 insertions(+), 15 deletions(-) (limited to 'constants') diff --git a/constants/text_constants.asm b/constants/text_constants.asm index 5943457b..d4e259fe 100644 --- a/constants/text_constants.asm +++ b/constants/text_constants.asm @@ -2,7 +2,7 @@ DEF NAME_LENGTH EQU 11 DEF ITEM_NAME_LENGTH EQU 13 DEF NAME_BUFFER_LENGTH EQU 20 -; PrintNumber +; PrintNumber, PrintBCDNumber const_def 5 const BIT_MONEY_SIGN ; 5 const BIT_LEFT_ALIGN ; 6 diff --git a/engine/events/prize_menu.asm b/engine/events/prize_menu.asm index f2b24a3f..0e78653b 100644 --- a/engine/events/prize_menu.asm +++ b/engine/events/prize_menu.asm @@ -126,18 +126,15 @@ GetPrizeMenuId: ; put prices on the right side of the textbox ld de, wPrize1Price hlcoord 13, 5 -; reg. c: -; [low nybble] number of bytes -; [bits 765 = %100] space-padding (not zero-padding) - ld c, (1 << 7) | 2 + ld c, 2 | LEADING_ZEROES call PrintBCDNumber ld de, wPrize2Price hlcoord 13, 7 - ld c, (1 << 7) | 2 + ld c, 2 | LEADING_ZEROES call PrintBCDNumber ld de, wPrize3Price hlcoord 13, 9 - ld c, (1 << 7) | 2 + ld c, 2 | LEADING_ZEROES jp PrintBCDNumber INCLUDE "data/events/prizes.asm" @@ -156,7 +153,7 @@ PrintPrizePrice: call PlaceString hlcoord 13, 1 ld de, wPlayerCoins - ld c, %10000010 + ld c, 2 | LEADING_ZEROES call PrintBCDNumber ret diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm index 7b0455d0..a45dfc79 100644 --- a/engine/menus/start_sub_menus.asm +++ b/engine/menus/start_sub_menus.asm @@ -552,7 +552,7 @@ DrawTrainerInfo: call PlaceString hlcoord 8, 4 ld de, wPlayerMoney - ld c, $e3 + ld c, 3 | LEADING_ZEROES | LEFT_ALIGN | MONEY_SIGN call PrintBCDNumber hlcoord 9, 6 ld de, wPlayTimeHours ; hours diff --git a/engine/menus/text_box.asm b/engine/menus/text_box.asm index 1c078693..c21f8e6f 100644 --- a/engine/menus/text_box.asm +++ b/engine/menus/text_box.asm @@ -139,7 +139,7 @@ DisplayMoneyBox: call ClearScreenArea hlcoord 12, 1 ld de, wPlayerMoney - ld c, $a3 + ld c, 3 | LEADING_ZEROES | MONEY_SIGN call PrintBCDNumber ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm index aebe65f0..231f3369 100644 --- a/engine/movie/hall_of_fame.asm +++ b/engine/movie/hall_of_fame.asm @@ -237,7 +237,7 @@ HoFDisplayPlayerStats: call PlaceString hlcoord 4, 10 ld de, wPlayerMoney - ld c, $a3 + ld c, 3 | LEADING_ZEROES | MONEY_SIGN call PrintBCDNumber ld hl, DexSeenOwnedText call HoFPrintTextAndDelay diff --git a/engine/slots/slot_machine.asm b/engine/slots/slot_machine.asm index 48cf27de..ac6e642f 100644 --- a/engine/slots/slot_machine.asm +++ b/engine/slots/slot_machine.asm @@ -645,7 +645,7 @@ SlotMachine_SubtractBetFromPlayerCoins: SlotMachine_PrintCreditCoins: hlcoord 5, 1 ld de, wPlayerCoins - ld c, $2 + ld c, 2 jp PrintBCDNumber SlotMachine_PrintPayoutCoins: diff --git a/home/list_menu.asm b/home/list_menu.asm index 646e7b7f..aae7caad 100644 --- a/home/list_menu.asm +++ b/home/list_menu.asm @@ -295,7 +295,7 @@ DisplayChooseQuantityMenu:: ld de, SpacesBetweenQuantityAndPriceText call PlaceString ld de, hMoney ; total price - ld c, $a3 + ld c, 3 | LEADING_ZEROES | MONEY_SIGN call PrintBCDNumber hlcoord 9, 10 .printQuantity @@ -420,7 +420,7 @@ PrintListMenuEntries:: pop hl ld bc, SCREEN_WIDTH + 5 ; 1 row down and 5 columns right add hl, bc - ld c, $a3 ; no leading zeroes, right-aligned, print currency symbol, 3 bytes + ld c, 3 | LEADING_ZEROES | MONEY_SIGN call PrintBCDNumber .skipPrintingItemPrice ld a, [wListMenuID] diff --git a/scripts/GameCorner.asm b/scripts/GameCorner.asm index cac3170c..f95431d1 100644 --- a/scripts/GameCorner.asm +++ b/scripts/GameCorner.asm @@ -511,7 +511,7 @@ GameCornerDrawCoinBox: call PlaceString hlcoord 15, 5 ld de, wPlayerCoins - ld c, $82 + ld c, 2 | LEADING_ZEROES call PrintBCDNumber ld hl, wStatusFlags5 res BIT_NO_TEXT_DELAY, [hl] -- cgit v1.3.1-sl0p