From 870d85fc2713703f6dbc760df5b2c54328f0c9c3 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 3 Jul 2018 13:27:51 -0400 Subject: Merge branch 'master' of https://github.com/pret/pokegold-spaceworld --- home/items.asm | 138 ++++++++++++++++++++++++++++---------------------------- home/tables.asm | 54 +++++++++++----------- 2 files changed, 96 insertions(+), 96 deletions(-) (limited to 'home') diff --git a/home/items.asm b/home/items.asm index dd4e8d3..332d5e1 100755 --- a/home/items.asm +++ b/home/items.asm @@ -1,69 +1,69 @@ -INCLUDE "constants.asm" - -if DEBUG -SECTION "TossItem", ROM0[$3243] -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 "GiveItem", ROM0[$366C] -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 +INCLUDE "constants.asm" + +if DEBUG +SECTION "TossItem", ROM0[$3243] +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 "GiveItem", ROM0[$366C] +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 diff --git a/home/tables.asm b/home/tables.asm index 5c35a4f..02fc78a 100755 --- a/home/tables.asm +++ b/home/tables.asm @@ -1,27 +1,27 @@ -INCLUDE "constants.asm" - -SECTION "FindItemInTable", ROM0[$35F8] - -; find value a from table hl with row length de -; returns carry and row index b if successful -FindItemInTable: ; 00:35F8 - ld b, 0 - ld c, a - -.loop - ld a, [hl] - cp -1 - jr z, .fail - cp c - jr z, .success - inc b - add hl, de - jr .loop - -.fail - and a - ret - -.success - scf - ret +INCLUDE "constants.asm" + +SECTION "FindItemInTable", ROM0[$35F8] + +; find value a from table hl with row length de +; returns carry and row index b if successful +FindItemInTable: ; 00:35F8 + ld b, 0 + ld c, a + +.loop + ld a, [hl] + cp -1 + jr z, .fail + cp c + jr z, .success + inc b + add hl, de + jr .loop + +.fail + and a + ret + +.success + scf + ret -- cgit v1.2.3