pokered/engine/items/tm_prices.asm

27 lines
627 B
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
GetMachinePrice: ; 7bf86 (1e:7f86)
; 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
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
jr nc, .highNybbleIsPrice ; is TM id odd?
2014-05-22 22:13:20 +00:00
swap a
.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"