tm_prices.asm 513 B

1234567891011121314151617181920212223242526
  1. GetMachinePrice:
  2. ; Input: [wcf91] = Item Id of a TM
  3. ; Output: Stores the TM price at hItemPrice
  4. ld a, [wcf91] ; a contains TM item id
  5. sub TM_01
  6. ret c
  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. ld [hItemPrice + 1], a
  20. xor a
  21. ld [hItemPrice], a
  22. ld [hItemPrice + 2], a
  23. ret
  24. INCLUDE "data/tm_prices.asm"