shithub: pokered

Download patch

ref: 3cf945bad4fdf40c528147a8d1fd9c5565425232
parent: 5b7c8541db9fac9c74508541c9199223fdae4c21
author: Marcus Huderle <huderlem@gmail.com>
date: Sat Jan 24 07:41:20 EST 2015

Better documenting for GetMachinePrice and TechnicalMachinePrices.

--- a/data/tm_prices.asm
+++ b/data/tm_prices.asm
@@ -1,7 +1,27 @@
 TechnicalMachinePrices: ; 7bfa7 (1e:7fa7)
 ; In thousands (nybbles).
-	db $32, $21, $34, $24, $34
-	db $21, $45, $55, $32, $32
-	db $55, $52, $54, $52, $41
-	db $21, $12, $42, $25, $24
-	db $22, $52, $24, $34, $42
+	dn 3, 2  ; TM_01, TM_02
+	dn 2, 1  ; TM_03, TM_04
+	dn 3, 4  ; TM_05, TM_06
+	dn 2, 4  ; TM_07, TM_08
+	dn 3, 4  ; TM_09, TM_10
+	dn 2, 1  ; TM_11, TM_12
+	dn 4, 5  ; TM_13, TM_14
+	dn 5, 5  ; TM_15, TM_16
+	dn 3, 2  ; TM_17, TM_18
+	dn 3, 2  ; TM_19, TM_20
+	dn 5, 5  ; TM_21, TM_22
+	dn 5, 2  ; TM_23, TM_24
+	dn 5, 4  ; TM_25, TM_26
+	dn 5, 2  ; TM_27, TM_28
+	dn 4, 1  ; TM_29, TM_30
+	dn 2, 1  ; TM_31, TM_32
+	dn 1, 2  ; TM_33, TM_34
+	dn 4, 2  ; TM_35, TM_36
+	dn 2, 5  ; TM_37, TM_38
+	dn 2, 4  ; TM_39, TM_40
+	dn 2, 2  ; TM_41, TM_42
+	dn 5, 2  ; TM_43, TM_44
+	dn 2, 4  ; TM_45, TM_46
+	dn 3, 4  ; TM_47, TM_48
+	dn 4, 2  ; TM_49, TM_50
--- a/engine/items/tm_prices.asm
+++ b/engine/items/tm_prices.asm
@@ -1,5 +1,8 @@
 GetMachinePrice: ; 7bf86 (1e:7f86)
-	ld a, [wcf91]
+; 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
 	sub TM_01
 	ret c
 	ld d, a
@@ -8,11 +11,11 @@
 	ld c, a
 	ld b, 0
 	add hl, bc
-	ld a, [hl]
+	ld a, [hl] ; a contains byte whose high or low nybble is the TM price (in thousands)
 	srl d
-	jr nc, .asm_7bf9d
+	jr nc, .highNybbleIsPrice ; is TM id odd?
 	swap a
-.asm_7bf9d
+.highNybbleIsPrice
 	and $f0
 	ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
 	xor a
--- a/home.asm
+++ b/home.asm
@@ -3335,6 +3335,8 @@
 	ret
 
 GetItemPrice:: ; 37df (0:37df)
+; Stores item's price as BCD in [H_DOWNARROWBLINKCNT1] and [[H_DOWNARROWBLINKCNT2]
+; Input: [wcf91] = item id
 	ld a, [H_LOADEDROMBANK]
 	push af
 	ld a, [wListMenuID] ; wListMenuID
@@ -3349,9 +3351,9 @@
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld a, [wcf91]
+	ld a, [wcf91] ; a contains item id
 	cp HM_01
-	jr nc, .asm_3812
+	jr nc, .getTMPrice
 	ld bc, $3
 .asm_3802
 	add hl, bc
@@ -3365,7 +3367,7 @@
 	ld a, [hl]
 	ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
 	jr .asm_381c
-.asm_3812
+.getTMPrice
 	ld a, Bank(GetMachinePrice)
 	ld [H_LOADEDROMBANK], a
 	ld [$2000], a