pokegold-spaceworld/home/items.asm
luckytyphlosion e1659ecd41 Introduce linkerscript.
Addresses of sections will now be added to the linkerscript via `org`, and the section name will be the path/to/file. If there is more than one section in the file, then add a @SectionName after the path/to/file to describe the section.
2018-07-03 17:07:05 -04:00

69 lines
1.2 KiB
NASM
Executable File

INCLUDE "constants.asm"
; if DEBUG
SECTION "home/items.asm@TossItem", ROM0
; else
; SECTION "TossItem", ROM0[$3207]
; endc
TossItem: ; 00:3243
ldh a, [hROMBank]
push af
ld a, BANK(_TossItem)
call Bankswitch
push hl
push de
push bc
call _TossItem
pop bc
pop de
pop hl
pop af
call Bankswitch
ret
ReceiveItem:: ; 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)
; [wCurItem] = item ID
; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
push bc
ldh a, [hROMBank]
push af
ld a, BANK(_ReceiveItem)
call Bankswitch
push hl
push de
call _ReceiveItem
pop de
pop hl
pop bc
ld a, b
call Bankswitch
pop bc
ret
; if DEBUG
SECTION "home/items.asm@GiveItem", ROM0
; else
; SECTION "GiveItem", ROM0[$3630]
; endc
GiveItem::
; Give player quantity c of item b,
; and copy the item's name to wcf4b.
; Return carry on success.
ld a, b
ld [wNamedObjectIndexBuffer], a
ld [wCurItem], a
ld a, c
ld [wItemQuantity], a
ld hl, wNumBagItems
call ReceiveItem
ret nc
call GetItemName
call CopyStringToStringBuffer2
scf
ret