2014-05-22 22:13:20 +00:00
|
|
|
GetMachinePrice: ; 7bf86 (1e:7f86)
|
2015-01-24 20:41:20 +00:00
|
|
|
; Input: [wcf91] = Item Id of a TM
|
|
|
|
; Output: Stores the 2-byte TM price in [H_DOWNARROWBLINKCNT1] and [H_DOWNARROWBLINKCNT2]
|
|
|
|
; as a BCD
|
|
|
|
ld a, [wcf91] ; a contains TM item id
|
2014-05-22 22:13:20 +00:00
|
|
|
sub TM_01
|
|
|
|
ret c
|
|
|
|
ld d, a
|
|
|
|
ld hl, TechnicalMachinePrices ; $7fa7
|
|
|
|
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
|
|
|
|
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
|
|
|
|
xor a
|
|
|
|
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
|
|
|
|
ld [$ff8d], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
INCLUDE "data/tm_prices.asm"
|