diff options
-rw-r--r-- | constants/item_constants.asm | 131 | ||||
-rwxr-xr-x | constants/name_constants.asm | 2 | ||||
-rw-r--r-- | data/predef_pointers.inc | 2 | ||||
-rw-r--r-- | home/copy.asm | 32 | ||||
-rwxr-xr-x | home/items.asm | 130 | ||||
-rwxr-xr-x | home/unknown_string_funcs.asm | 114 | ||||
-rw-r--r-- | shim.sym | 1 | ||||
-rw-r--r-- | wram.asm | 24 |
8 files changed, 229 insertions, 207 deletions
diff --git a/constants/item_constants.asm b/constants/item_constants.asm index 017a58e..01a5fb4 100644 --- a/constants/item_constants.asm +++ b/constants/item_constants.asm @@ -192,73 +192,76 @@ const ITEM_BC ; bc *MUSIC_MAIL const ITEM_BD ; bd *MIRAGE_MAIL const ITEM_BE ; be - const ITEM_BF ; bf *TM01 - const ITEM_C0 ; c0 *TM02 - const ITEM_C1 ; c1 *TM03 - const ITEM_C2 ; c2 *TM04 + const ITEM_BF ; bf + const ITEM_C0 ; c0 + const ITEM_C1 ; c1 + const ITEM_C2 ; c2 const ITEM_C3 ; c3 - const ITEM_TM01 ; c4 *TM05 - const ITEM_TM02 ; c5 *TM06 - const ITEM_TM03 ; c6 *TM07 - const ITEM_TM04 ; c7 *TM08 - const ITEM_C8 ; c8 *TM09 - const ITEM_TM05 ; c9 *TM10 - const ITEM_TM06 ; ca *TM11 - const ITEM_TM07 ; cb *TM12 - const ITEM_TM08 ; cc *TM13 - const ITEM_TM09 ; cd *TM14 - const ITEM_TM10 ; ce *TM15 - const ITEM_TM11 ; cf *TM16 - const ITEM_TM12 ; d0 *TM17 - const ITEM_TM13 ; d1 *TM18 - const ITEM_TM14 ; d2 *TM19 - const ITEM_TM15 ; d3 *TM20 - const ITEM_TM16 ; d4 *TM21 - const ITEM_TM17 ; d5 *TM22 - const ITEM_TM18 ; d6 *TM23 - const ITEM_TM19 ; d7 *TM24 - const ITEM_TM20 ; d8 *TM25 - const ITEM_TM21 ; d9 *TM26 - const ITEM_TM22 ; da *TM27 - const ITEM_TM23 ; db *TM28 - const ITEM_TM24 ; dc * - const ITEM_TM25 ; dd *TM29 - const ITEM_TM26 ; de *TM30 - const ITEM_TM27 ; df *TM31 - const ITEM_TM28 ; e0 *TM32 - const ITEM_E1 ; e1 *TM33 - const ITEM_TM29 ; e2 *TM34 - const ITEM_TM30 ; e3 *TM35 - const ITEM_TM31 ; e4 *TM36 - const ITEM_TM32 ; e5 *TM37 - const ITEM_TM33 ; e6 *TM38 - const ITEM_TM34 ; e7 *TM39 - const ITEM_TM35 ; e8 *TM40 - const ITEM_TM36 ; e9 *TM41 - const ITEM_TM37 ; ea *TM42 - const ITEM_TM38 ; eb *TM43 - const ITEM_TM39 ; ec *TM44 - const ITEM_TM40 ; ed *TM45 - const ITEM_TM41 ; ee *TM46 - const ITEM_TM42 ; ef *TM47 - const ITEM_TM43 ; f0 *TM48 - const ITEM_TM44 ; f1 *TM49 - const ITEM_TM45 ; f2 *TM50 - const ITEM_TM46 ; f3 *HM01 - const ITEM_TM47 ; f4 *HM02 - const ITEM_TM48 ; f5 *HM03 - const ITEM_TM49 ; f6 *HM04 - const ITEM_TM50 ; f7 *HM05 -NUM_TMS = const_value - ITEM_TM01 - 2 ; discount ITEM_C8 and ITEM_E1 + const ITEM_HM01 ; c4 *HM01 + const ITEM_HM02 ; c5 *HM02 + const ITEM_HM03 ; c6 *HM03 + const ITEM_HM04 ; c7 *HM04 + const ITEM_HM05 ; c8 *HM05 - const ITEM_HM01 ; f8 *HM06 - const ITEM_HM02 ; f9 *HM07 - const ITEM_HM03 ; fa * - const ITEM_HM04 ; fb * - const ITEM_HM05 ; fc * - const ITEM_HM06 ; fd * - const ITEM_HM07 ; fe * NUM_HMS = const_value - ITEM_HM01 + + const ITEM_TM01 ; c9 *TM01 + const ITEM_TM02 ; ca *TM02 + const ITEM_TM03 ; cb *TM03 + const ITEM_TM04 ; cc *TM04 + const ITEM_TM05 ; cd *TM05 + const ITEM_TM06 ; ce *TM06 + const ITEM_TM07 ; cf *TM07 + const ITEM_TM08 ; d0 *TM08 + const ITEM_TM09 ; d1 *TM09 + const ITEM_TM10 ; d2 *TM10 + const ITEM_TM11 ; d3 *TM11 + const ITEM_TM12 ; d4 *TM12 + const ITEM_TM13 ; d5 *TM13 + const ITEM_TM14 ; d6 *TM14 + const ITEM_TM15 ; d7 *TM15 + const ITEM_TM16 ; d8 *TM16 + const ITEM_TM17 ; d9 *TM17 + const ITEM_TM18 ; da *TM18 + const ITEM_TM19 ; db *TM19 + const ITEM_TM20 ; dc *TM20 + const ITEM_TM21 ; dd *TM21 + const ITEM_TM22 ; de *TM22 + const ITEM_TM23 ; df *TM23 + const ITEM_TM24 ; e0 *TM24 + const ITEM_TM25 ; e1 *TM25 + const ITEM_TM26 ; e2 *TM26 + const ITEM_TM27 ; e3 *TM27 + const ITEM_TM28 ; e4 *TM28 + const ITEM_TM29 ; e5 *TM29 + const ITEM_TM30 ; e6 *TM30 + const ITEM_TM31 ; e7 *TM31 + const ITEM_TM32 ; e8 *TM32 + const ITEM_TM33 ; e9 *TM33 + const ITEM_TM34 ; ea *TM34 + const ITEM_TM35 ; eb *TM35 + const ITEM_TM36 ; ec *TM36 + const ITEM_TM37 ; ed *TM37 + const ITEM_TM38 ; ee *TM38 + const ITEM_TM39 ; ef *TM39 + const ITEM_TM40 ; f0 *TM40 + const ITEM_TM41 ; f1 *TM41 + const ITEM_TM42 ; f2 *TM42 + const ITEM_TM43 ; f3 *TM43 + const ITEM_TM44 ; f4 *TM44 + const ITEM_TM45 ; f5 *TM45 + const ITEM_TM46 ; f6 *TM46 + const ITEM_TM47 ; f7 *TM47 + const ITEM_TM48 ; f8 *TM48 + const ITEM_TM49 ; f8 *TM49 + const ITEM_TM50 ; f9 *TM50 + const ITEM_TM51 ; fa *TM51 + const ITEM_TM52 ; fb *TM52 + const ITEM_TM53 ; fc *TM53 + const ITEM_TM54 ; fd *TM54 + const ITEM_TM55 ; fe *TM55 + +NUM_TMS = const_value - ITEM_TM01 NUM_TMS_HMS = NUM_TMS + NUM_HMS diff --git a/constants/name_constants.asm b/constants/name_constants.asm new file mode 100755 index 0000000..7e35ebb --- /dev/null +++ b/constants/name_constants.asm @@ -0,0 +1,2 @@ +; Name Lists
+ITEM_NAME EQU 4
\ No newline at end of file diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc index 4bf1283..8dd6d54 100644 --- a/data/predef_pointers.inc +++ b/data/predef_pointers.inc @@ -24,7 +24,7 @@ PredefPointers:: ; 1:62d3 dbw 3, $4DF9 dbw 3, $4E10 dbw 3, $4D33 - dbw 3, Func_0x366C + dbw 3, GiveItem dbw 3, $4E3C dbw 3, $5A28 dbw 3, $5886 ; 10 diff --git a/home/copy.asm b/home/copy.asm index 135ee3f..5a73efd 100644 --- a/home/copy.asm +++ b/home/copy.asm @@ -74,12 +74,12 @@ ByteFill:: ; 3339 UncompressSpriteFromDE:: ; Decompress pic at a:de. - ld hl, wSpriteInputPtr - ld [hl],e - inc hl - ld [hl],d - jp UncompressSpriteData - + ld hl, wSpriteInputPtr + ld [hl], e + inc hl + ld [hl], d + jp UncompressSpriteData + BackUpTilesToBuffer:: ; 3355 hlcoord 0, 0 decoord 0, 0, wTileMapBackup @@ -97,16 +97,16 @@ ReloadTilesFromBuffer:: ; 3361 ldh [hBGMapMode], a ret -; copies a string from [de] to [wStringBuffer] -CopyStringToBuffer:: - ld hl, wStringBuffer - ; fall through +; copies a string from [de] to [wcd31] +CopyStringToCD31:: + ld hl, wcd31 + ; fall through ; copies a string from [de] to [hl] CopyString:: - ld a,[de] - inc de - ld [hli],a - cp "@" - jr nz, CopyString - ret
\ No newline at end of file + ld a, [de] + inc de + ld [hli], a + cp "@" + jr nz, CopyString + ret
\ No newline at end of file diff --git a/home/items.asm b/home/items.asm new file mode 100755 index 0000000..36abfb7 --- /dev/null +++ b/home/items.asm @@ -0,0 +1,130 @@ +INCLUDE "constants.asm"
+
+SECTION "AddItemToInventory", ROM0[$3259]
+
+; function to add an item (in varying quantities) to the player's bag or PC box
+; INPUT:
+; HL = address of inventory (either wNumBagItems or wNumBoxItems)
+; [wcd76] = item ID
+; [wItemQuantity] = item quantity
+; sets carry flag if successful, unsets carry flag if unsuccessful
+AddItemToInventory:: ; 3259
+ push bc
+ ldh a, [hROMBank]
+ push af
+ ld a, BANK(AddItemToInventory_)
+ call Bankswitch
+ push hl
+ push de
+ call AddItemToInventory_
+ pop de
+ pop hl
+ pop bc
+ ld a, b
+ call Bankswitch
+ pop bc
+ ret
+
+SECTION "GiveItem", ROM0[$366C]
+
+GiveItem::
+; Give player quantity c of item b,
+; and copy the item's name to wcf4b.
+; Return carry on success.
+ ld a, b
+ ld [wce37], a
+ ld [wcd76], a
+ ld a, c
+ ld [wItemQuantity], a
+ ld hl, wNumBagItems
+ call AddItemToInventory
+ ret nc
+ call GetItemName
+ call CopyStringToCD31
+ scf
+ ret
+
+SECTION "GetItemName", ROM0[$376F]
+
+GetItemName:: ; 376F
+; given an item ID at [wce37], store the name of the item into a string
+; starting at wcd26
+ push hl
+ push bc
+ ld a, [wce37]
+ cp ITEM_HM01
+ jr nc, .Machine
+
+ ld [wcb5b], a
+ ld a, ITEM_NAME
+ ld [wNameCategory], a
+ call GetName
+ jr .Finish
+
+.Machine
+ call GetMachineName
+.Finish
+ ld de, wcd26 ; pointer to where item name is stored in RAM
+ pop bc
+ pop hl
+ ret
+
+SECTION "GetMachineName", ROM0[$378E]
+
+GetMachineName::
+; copies the name of the TM/HM in [wce37] to wcd26
+ push hl
+ push de
+ push bc
+ ld a, [wce37]
+ push af
+ cp ITEM_TM01
+ jr nc, .WriteTM
+; if HM, then write "HM" and add 5 to the item ID, so we can reuse the
+; TM printing code
+ add 5
+ ld [wce37], a
+ ld hl, HiddenPrefix
+ ld bc, 6
+ jr .WriteMachinePrefix
+.WriteTM
+ ld hl, TechnicalPrefix
+ ld bc, 5
+.WriteMachinePrefix
+ ld de, wcd26
+ call CopyBytes
+
+; now get the machine number and convert it to text
+ ld a, [wce37]
+ sub ITEM_TM01 - 1
+ ld b, "0"
+.FirstDigit
+ sub 10
+ jr c, .SecondDigit
+ inc b
+ jr .FirstDigit
+.SecondDigit
+ add 10
+ push af
+ ld a, b
+ ld [de], a
+ inc de
+ pop af
+ ld b, "0"
+ add b
+ ld [de], a
+ inc de
+ ld a, "@"
+ ld [de], a
+ pop af
+ ld [wce37], a
+ pop bc
+ pop de
+ pop hl
+ ret
+
+TechnicalPrefix:
+ db "わざマシン@"
+
+HiddenPrefix:
+ db "ひでんマシン@"
\ No newline at end of file diff --git a/home/unknown_string_funcs.asm b/home/unknown_string_funcs.asm deleted file mode 100755 index f00267d..0000000 --- a/home/unknown_string_funcs.asm +++ /dev/null @@ -1,114 +0,0 @@ -INCLUDE "constants.asm"
-
-SECTION "Func_0x3259", ROM0[$3259]
-
-; Called during start of new game
-; A far call for 03:4AA1
-Func_0x3259:: ; 3259
- push bc
- ld a,[$FF98]
- push af
- ld a,3
- call Bankswitch
- push hl
- push de
- call $4AA1
- pop de
- pop hl
- pop bc
- ld a,b
- call Bankswitch
- pop bc
- ret
-
-SECTION "Func_0x366C", ROM0[$366C]
-
-Func_0x366C:: ; 366c
- ld a,b
- ld [wce37],a
- ld [wcd76],a
- ld a,c
- ld [wcd7d],a
- ld hl,wd19e
- call Func_0x3259
- ret nc
- call Func_0x376F
- call CopyStringToBuffer
- scf
- ret
-
-SECTION "Func_0x376F", ROM0[$376F]
-
-Func_0x376F:: ; 376F
- push hl
- push bc
- ld a,[wce37]
- cp $C4
- jr nc,.skip
- ld [wcb5b],a
- ld a,4
- ld [wNameCategory],a
- call GetName
- jr .next
-.skip
- call Func_0x378E
-.next
- ld de,wcd26
- pop bc
- pop hl
- ret
-
-SECTION "Func_0x378E", ROM0[$378E]
-
-Func_0x378E::
- push hl
- push de
- push bc
- ld a,[wce37]
- push af
- cp $C9
- jr nc,.skip
- add a,5
- ld [wce37],a
- ld hl,HM_String
- ld bc,$0006
- jr .next
-.skip
- ld hl,TM_String
- ld bc,$0005
-.next
- ld de,wcd26
- call CopyBytes
- ld a,[wce37]
- sub a,$C8
- ld b,$F6
-.loop
- sub a,$0A
- jr c,.exit
- inc b
- jr .loop
-.exit
- add a,$0A
- push af
- ld a,b
- ld [de],a
- inc de
- pop af
- ld b,$F6
- add b
- ld [de],a
- inc de
- ld a,$50
- ld [de],a
- pop af
- ld [wce37],a
- pop bc
- pop de
- pop hl
- ret
-
-TM_String:
- db "わざマシン@"
-
-HM_String:
- db "ひでんマシン@"
\ No newline at end of file @@ -62,6 +62,7 @@ 03:4791 DebugWarp 03:479f DebugWarp.Destinations +03:4AA1 AddItemToInventory_ 04:5677 DoPlayerMovement @@ -86,7 +86,7 @@ SECTION "CB14", WRAM0[$CB14] UNION wRedrawRowOrColumnSrcTiles:: ; cb14 ; the tiles of the row or column to be redrawn by RedrawRowOrColumn - ds SCREEN_WIDTH * 2 + ds SCREEN_WIDTH * 2 NEXTU wRedrawFlashlightDst0:: dw ; cb14 wRedrawFlashlightSrc0:: dw ; cb16 @@ -173,11 +173,11 @@ wDisableVBlankWYUpdate:: db ; ccce SECTION "CD26", WRAM0[$CD26] wcd26:: ; cd26 - db + db SECTION "CD31", WRAM0[$CD31] -wStringBuffer:: ; cd31 +wcd31:: ; cd31 db SECTION "CD4F", WRAM0[$CD4F] @@ -193,21 +193,21 @@ wPredefBC:: ; cd54 wFarCallBCBuffer:: ; cd54 dw - + SECTION "CD76", WRAM0[$CD76] wcd76:: ; cd76 - db + db wcd77:: ;cd77 - db + db wMonDexIndex: ds 1 ; cd78 SECTION "CD7D", WRAM0[$CD7D] -wcd7d:: ; cd7d - db +wItemQuantity:: ; cd7d + db SECTION "CE00", WRAM0[$CE00] @@ -278,11 +278,11 @@ wMonHLearnset:: ; ce1e ; bit field flag_array 50 + 5 ds 1 - + SECTION "CE37", WRAM0[$CE37] wce37:: ; ce37 - db + db SECTION "CE3B", WRAM0[$CE3B] @@ -337,8 +337,8 @@ wMapTimeOfDay:: db ; d159 SECTION "D19E", WRAM0[$D19E] -wd19e:: ; d19e - db +wNumBagItems:: ; d19e + db SECTION "D4AB", WRAM0[$D4AB] |