Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/items/tm_prices.asm
1271 views
1
GetMachinePrice::
2
; Input: [wCurItem] = Item ID of a TM
3
; Output: Stores the TM price at hItemPrice
4
ld a, [wCurItem]
5
sub TM01 ; underflows below 0 for HM items (before TM items)
6
ret c ; HMs are priceless
7
ld d, a
8
ld hl, TechnicalMachinePrices
9
srl a
10
ld c, a
11
ld b, 0
12
add hl, bc
13
ld a, [hl] ; a contains byte whose high or low nybble is the TM price (in thousands)
14
srl d
15
jr nc, .highNybbleIsPrice ; is TM id odd?
16
swap a
17
.highNybbleIsPrice
18
and $f0
19
ldh [hItemPrice + 1], a
20
xor a
21
ldh [hItemPrice], a
22
ldh [hItemPrice + 2], a
23
ret
24
25
INCLUDE "data/items/tm_prices.asm"
26
27