2016-06-12 00:24:04 +00:00
|
|
|
GetMachinePrice:
|
2015-01-24 20:41:20 +00:00
|
|
|
; Input: [wcf91] = Item Id of a TM
|
2015-07-18 15:17:29 +00:00
|
|
|
; Output: Stores the TM price at hItemPrice
|
2015-01-24 20:41:20 +00:00
|
|
|
ld a, [wcf91] ; a contains TM item id
|
2014-05-22 22:13:20 +00:00
|
|
|
sub TM_01
|
|
|
|
ret c
|
|
|
|
ld d, a
|
2015-07-03 19:37:53 +00:00
|
|
|
ld hl, TechnicalMachinePrices
|
2014-05-22 22:13:20 +00:00
|
|
|
srl a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
2015-01-24 20:41:20 +00:00
|
|
|
ld a, [hl] ; a contains byte whose high or low nybble is the TM price (in thousands)
|
2014-05-22 22:13:20 +00:00
|
|
|
srl d
|
2015-01-24 20:41:20 +00:00
|
|
|
jr nc, .highNybbleIsPrice ; is TM id odd?
|
2014-05-22 22:13:20 +00:00
|
|
|
swap a
|
2015-01-24 20:41:20 +00:00
|
|
|
.highNybbleIsPrice
|
2014-05-22 22:13:20 +00:00
|
|
|
and $f0
|
2015-07-18 15:17:29 +00:00
|
|
|
ld [hItemPrice + 1], a
|
2014-05-22 22:13:20 +00:00
|
|
|
xor a
|
2015-07-18 15:17:29 +00:00
|
|
|
ld [hItemPrice], a
|
|
|
|
ld [hItemPrice + 2], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/tm_prices.asm"
|