ref: 6931ce96259d366263c63e704dfaac6f241d8e4a
parent: aa3da5f3b07b8965bf7d4f1b5449ce67bed4fb87
author: YamaArashi <shadow962@live.com>
date: Thu Jul 16 21:21:40 EDT 2015
money / coins hram constants
--- a/engine/menu/prize_menu.asm
+++ b/engine/menu/prize_menu.asm
@@ -179,11 +179,11 @@
ld hl,wd141 ; first prize's price
add hl,de ; get selected prize's price
xor a
- ld [$FF9F],a
+ ld [hCoins - 1],a
ld a,[hli]
- ld [$FFA0],a
+ ld [hCoins],a
ld a,[hl]
- ld [$FFA1],a
+ ld [hCoins + 1],a
ret
HandlePrizeChoice: ; 528c6 (14:68c6)
@@ -239,7 +239,7 @@
ret nc
.SubtractCoins
call LoadCoinsToSubtract
- ld hl,$FFA1
+ ld hl,hCoins + 1
ld de,wPlayerCoins + 1
ld c,$02 ; how many bytes
predef SubBCDPredef ; subtract coins (BCD daa operations)
--- a/engine/menu/vending_machine.asm
+++ b/engine/menu/vending_machine.asm
@@ -37,10 +37,10 @@
cp 3 ; chose Cancel?
jr z, .notThirsty
xor a
- ld [$ff9f], a
- ld [$ffa1], a
+ ld [hMoney], a
+ ld [hMoney + 2], a
ld a, $2
- ld [$ffa0], a
+ ld [hMoney + 1], a
call HasEnoughMoney
jr nc, .enoughMoney
ld hl, VendingMachineText4
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -67,9 +67,9 @@
and a
ret nz
xor a
- ld [$ff9f], a
- ld [$ffa0], a
- ld [$ffa1], a
+ ld [hCoins - 1], a
+ ld [hCoins], a
+ ld [hCoins + 1], a
ld a, [wWhichTrade]
sub COIN
cp 10
@@ -81,22 +81,22 @@
jr .bcd100
.bcd10
ld a, $10
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd20
ld a, $20
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd40 ; due to a typo, this is never used
ld a, $40
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd100
ld a, $1
- ld [$ffa0], a
+ ld [hCoins], a
.bcddone
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
ld hl, wd6fe
--- a/engine/overworld/pokemart.asm
+++ b/engine/overworld/pokemart.asm
@@ -206,7 +206,7 @@
jp .loop
.isThereEnoughMoney
ld de,wPlayerMoney
- ld hl,$ff9f ; item price
+ ld hl,hMoney
ld c,3 ; length of money in bytes
jp StringCmp
.notEnoughMoney
--- a/home.asm
+++ b/home.asm
@@ -1630,7 +1630,7 @@
ld c,$03
ld a,[wItemQuantity]
ld b,a
- ld hl,$ff9f ; total price
+ ld hl,hMoney ; total price
; initialize total price to 0
xor a
ld [hli],a
@@ -1637,8 +1637,8 @@
ld [hli],a
ld [hl],a
.addLoop ; loop to multiply the individual price by the quantity to get the total price
- ld de,$ffa1
- ld hl,$ff8d
+ ld de,hMoney + 2
+ ld hl,hItemPrice + 2
push bc
predef AddBCDPredef ; add the individual price to the current sum
pop bc
@@ -1648,23 +1648,23 @@
and a ; should the price be halved (for selling items)?
jr z,.skipHalvingPrice
xor a
- ld [$ffa2],a
- ld [$ffa3],a
+ ld [hDivideBCDDivisor],a
+ ld [hDivideBCDDivisor + 1],a
ld a,$02
- ld [$ffa4],a
+ ld [hDivideBCDDivisor + 2],a
predef DivideBCDPredef3 ; halves the price
; store the halved price
- ld a,[$ffa2]
- ld [$ff9f],a
- ld a,[$ffa3]
- ld [$ffa0],a
- ld a,[$ffa4]
- ld [$ffa1],a
+ ld a,[hDivideBCDQuotient]
+ ld [hMoney],a
+ ld a,[hDivideBCDQuotient + 1]
+ ld [hMoney + 1],a
+ ld a,[hDivideBCDQuotient + 2]
+ ld [hMoney + 2],a
.skipHalvingPrice
hlCoord 12, 10
ld de,SpacesBetweenQuantityAndPriceText
call PlaceString
- ld de,$ff9f ; total price
+ ld de,hMoney ; total price
ld c,$a3
call PrintBCDNumber
hlCoord 9, 10
@@ -2942,17 +2942,17 @@
HasEnoughMoney::
; Check if the player has at least as much
-; money as the 3-byte BCD value at $ff9f.
+; money as the 3-byte BCD value at hMoney.
ld de, wPlayerMoney
- ld hl, $ff9f
+ ld hl, hMoney
ld c, 3
jp StringCmp
HasEnoughCoins::
; Check if the player has at least as many
-; coins as the 2-byte BCD value at $ffa0.
+; coins as the 2-byte BCD value at hCoins.
ld de, wPlayerCoins
- ld hl, $ffa0
+ ld hl, hCoins
ld c, 2
jp StringCmp
--- a/hram.asm
+++ b/hram.asm
@@ -92,6 +92,12 @@
; 1 = target is to the west
hNPCPlayerRelativePosFlags EQU $FF9D
+hMoney EQU $FF9F ; 3-byte BCD number
+hCoins EQU $FFA0 ; 2-byte BCD number
+
+hDivideBCDDivisor EQU $FFA2 ; 3-byte BCD number
+hDivideBCDQuotient EQU $FFA2 ; 3-byte BCD number
+
hSerialReceivedNewData EQU $FFA9
; $01 = using external clock
--- a/main.asm
+++ b/main.asm
@@ -31,30 +31,30 @@
ld [wNPCMovementScriptPointerTableNum], a
ld [wFlags_0xcd60], a
- ld [$ff9f], a
- ld [$ff9f + 1], a
- ld [$ff9f + 2], a
+ ld [hMoney], a
+ ld [hMoney + 1], a
+ ld [hMoney + 2], a
call HasEnoughMoney
jr c, .lostmoney ; never happens
; Halve the player's money.
ld a, [wPlayerMoney]
- ld [$ff9f], a
+ ld [hMoney], a
ld a, [wPlayerMoney + 1]
- ld [$ff9f + 1], a
+ ld [hMoney + 1], a
ld a, [wPlayerMoney + 2]
- ld [$ff9f + 2], a
+ ld [hMoney + 2], a
xor a
- ld [$ffa2], a
- ld [$ffa3], a
+ ld [hDivideBCDDivisor], a
+ ld [hDivideBCDDivisor + 1], a
ld a, 2
- ld [$ffa4], a
+ ld [hDivideBCDDivisor + 2], a
predef DivideBCDPredef3
- ld a, [$ffa2]
+ ld a, [hDivideBCDQuotient]
ld [wPlayerMoney], a
- ld a, [$ffa2 + 1]
+ ld a, [hDivideBCDQuotient + 1]
ld [wPlayerMoney + 1], a
- ld a, [$ffa2 + 2]
+ ld a, [hDivideBCDQuotient + 2]
ld [wPlayerMoney + 2], a
.lostmoney
@@ -789,12 +789,12 @@
; sets carry flag if there is enough money and unsets carry flag if not
SubtractAmountPaidFromMoney_: ; 6b21 (1:6b21)
ld de,wPlayerMoney
- ld hl,$ff9f ; total price of items
+ ld hl,hMoney ; total price of items
ld c,3 ; length of money in bytes
call StringCmp
ret c
ld de,wPlayerMoney + 2
- ld hl,$ffa1 ; total price of items
+ ld hl,hMoney + 2 ; total price of items
ld c,3 ; length of money in bytes
predef SubBCDPredef ; subtract total price from money
ld a,MONEY_BOX
--- a/scripts/celadongamecorner.asm
+++ b/scripts/celadongamecorner.asm
@@ -151,10 +151,10 @@
call Has9990Coins
jr nc, .asm_48d14
xor a
- ld [$ff9f], a
- ld [$ffa1], a
+ ld [hMoney], a
+ ld [hMoney + 2], a
ld a, $10
- ld [$ffa0], a
+ ld [hMoney + 1], a
call HasEnoughMoney
jr nc, .asm_48cdb
ld hl, CeladonGameCornerText_48d31
@@ -161,21 +161,21 @@
jr .asm_48d1c
.asm_48cdb
xor a
- ld [$ff9f], a
- ld [$ffa1], a
+ ld [hMoney], a
+ ld [hMoney + 2], a
ld a, $10
- ld [$ffa0], a
- ld hl, $ffa1
+ ld [hMoney + 1], a
+ ld hl, hMoney + 2
ld de, wPlayerMoney + 2
ld c, $3
predef SubBCDPredef
xor a
- ld [$ff9f], a
- ld [$ffa0], a
+ ld [hCoins - 1], a
+ ld [hCoins], a
ld a, $50
- ld [$ffa1], a
+ ld [hCoins + 1], a
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
call CeladonGameCornerScript_48f1e
@@ -238,12 +238,12 @@
call Has9990Coins
jr nc, .asm_48d8e
xor a
- ld [$ff9f], a
- ld [$ffa0], a
+ ld [hCoins - 1], a
+ ld [hCoins], a
ld a, $10
- ld [$ffa1], a
+ ld [hCoins + 1], a
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
ld hl, wd77e
@@ -320,12 +320,12 @@
call Has9990Coins
jr nc, .asm_48e18
xor a
- ld [$ff9f], a
- ld [$ffa0], a
+ ld [hCoins - 1], a
+ ld [hCoins], a
ld a, $20
- ld [$ffa1], a
+ ld [hCoins + 1], a
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
ld hl, wd77e
@@ -373,12 +373,12 @@
call Has9990Coins
jr z, .asm_48e7a
xor a
- ld [$ff9f], a
- ld [$ffa0], a
+ ld [hCoins - 1], a
+ ld [hCoins], a
ld a, $20
- ld [$ffa1], a
+ ld [hCoins + 1], a
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
ld hl, wd77e
@@ -527,7 +527,7 @@
Has9990Coins: ; 48f95 (12:4f95)
ld a, $99
- ld [$ffa0], a
+ ld [hCoins], a
ld a, $90
- ld [$ffa1], a
+ ld [hCoins + 1], a
jp HasEnoughCoins
--- a/scripts/daycarem.asm
+++ b/scripts/daycarem.asm
@@ -137,11 +137,11 @@
and a
jp nz, .asm_56403
ld hl, wTrainerFacingDirection
- ld [$ff9f], a
+ ld [hMoney], a
ld a, [hli]
- ld [$ffa0], a
+ ld [hMoney + 1], a
ld a, [hl]
- ld [$ffa1], a
+ ld [hMoney + 2], a
call HasEnoughMoney
jr nc, .asm_56396
ld hl, DayCareMText_56454
--- a/scripts/mtmoonpokecenter.asm
+++ b/scripts/mtmoonpokecenter.asm
@@ -35,10 +35,10 @@
ld a, [wCurrentMenuItem]
and a
jp nz, .asm_4934e
- ld [$ff9f], a
- ld [$ffa1], a
+ ld [hMoney], a
+ ld [hMoney + 2], a
ld a, $5
- ld [$ffa0], a
+ ld [hMoney + 1], a
call HasEnoughMoney
jr nc, .asm_faa09
ld hl, MtMoonPokecenterText_49366
--- a/scripts/museum1f.asm
+++ b/scripts/museum1f.asm
@@ -81,10 +81,10 @@
and a
jr nz, .asm_de133
xor a
- ld [$ff9f], a
- ld [$ffa0], a
+ ld [hMoney], a
+ ld [hMoney + 1], a
ld a, $50
- ld [$ffa1], a
+ ld [hMoney + 2], a
call HasEnoughMoney
jr nc, .asm_0f3e3
ld hl, Museum1FText_5c229
--- a/scripts/safarizoneentrance.asm
+++ b/scripts/safarizoneentrance.asm
@@ -155,11 +155,11 @@
and a
jp nz,.PleaseComeAgain
xor a
- ld [$ff9f],a
+ ld [hMoney],a
ld a,$05
- ld [$ffa0],a
+ ld [hMoney + 1],a
ld a,$00
- ld [$ffa1],a
+ ld [hMoney + 2],a
call HasEnoughMoney
jr nc,.success
ld hl,.NotEnoughMoneyText
--- a/text.asm
+++ b/text.asm
@@ -15,9 +15,9 @@
MOVE_NAMES EQU $2c
INCLUDE "macros.asm"
+INCLUDE "hram.asm"
-
SECTION "Text 1", ROMX, BANK[TEXT_1]
_CardKeySuccessText1:: ; 80000 (20:4000)
@@ -1015,13 +1015,13 @@
_FoundHiddenCoinsText:: ; 8950b (22:550b)
text $52, " found"
line "@"
- TX_BCD $ffa0, $c2
+ TX_BCD hCoins, $c2
text " coins!@@"
_FoundHiddenCoins2Text:: ; 89523 (22:5523)
text $52, " found"
line "@"
- TX_BCD $ffa0, $c2
+ TX_BCD hCoins, $c2
text " coins!@@"
_DroppedHiddenCoinsText:: ; 8953b (22:553b)
@@ -2635,7 +2635,7 @@
text "?"
line "That will be"
cont "¥@"
- TX_BCD $ff9f, $c3
+ TX_BCD hMoney, $c3
text ". OK?"
done
@@ -2662,7 +2662,7 @@
_PokemartTellSellPriceText:: ; a26ae (28:66ae)
text "I can pay you"
line "¥@"
- TX_BCD $ff9f, $c3
+ TX_BCD hMoney, $c3
text " for that."
done