From 5207a14af34f9b84a9e40cc1d4988a0858a4a4e6 Mon Sep 17 00:00:00 2001 From: dannye Date: Wed, 27 Jul 2016 22:08:13 -0500 Subject: Redo audio header macro --- engine/items/items.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engine/items') diff --git a/engine/items/items.asm b/engine/items/items.asm index 42d05981..aaddc396 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -990,7 +990,7 @@ ItemUseMedicine: .notFullHP ; if the pokemon's current HP doesn't equal its max HP xor a ld [wLowHealthAlarm],a ;disable low health alarm - ld [wChannelSoundIDs + CH4],a + ld [wChannelSoundIDs + Ch4],a push hl push de ld bc,wPartyMon1MaxHP - (wPartyMon1HP + 1) @@ -1777,7 +1777,7 @@ ItemUsePokeflute: call WaitForSoundToFinish ; wait for sound to end callba Music_PokeFluteInBattle ; play in-battle pokeflute music .musicWaitLoop ; wait for music to finish playing - ld a,[wChannelSoundIDs + CH6] + ld a,[wChannelSoundIDs + Ch6] and a ; music off? jr nz,.musicWaitLoop .skipMusic @@ -1850,7 +1850,7 @@ PlayedFluteHadEffectText: ld c, BANK(SFX_Pokeflute) call PlayMusic .musicWaitLoop ; wait for music to finish playing - ld a,[wChannelSoundIDs + CH2] + ld a,[wChannelSoundIDs + Ch2] cp a, SFX_POKEFLUE jr z,.musicWaitLoop call PlayDefaultMusic ; start playing normal music again -- cgit v1.2.3 From 52bb07ca18f5475eb9a11c69bf8fee75bcb1abff Mon Sep 17 00:00:00 2001 From: dannye Date: Wed, 27 Jul 2016 22:33:48 -0500 Subject: Replace unnecessary tabs with spaces --- engine/items/items.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/items') diff --git a/engine/items/items.asm b/engine/items/items.asm index aaddc396..f8873a6e 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1,7 +1,7 @@ UseItem_: ld a,1 ld [wActionResultOrTookBattleTurn],a ; initialise to success value - ld a,[wcf91] ;contains item_ID + ld a,[wcf91] ;contains item_ID cp a,HM_01 jp nc,ItemUseTMHM ld hl,ItemUsePtrTable @@ -235,7 +235,7 @@ ItemUseBall: ld b,a .skipAilmentValueSubtraction - push bc ; save (Rand1 - Status) + push bc ; save (Rand1 - Status) ; Calculate MaxHP * 255. xor a -- cgit v1.2.3 From bf67f7174d8e3f1348c786618ee5a3a076d1eff8 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Sat, 31 Dec 2016 17:23:54 -0800 Subject: split code out of main.asm --- engine/items/inventory.asm | 150 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 engine/items/inventory.asm (limited to 'engine/items') diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm new file mode 100644 index 00000000..1294ed8d --- /dev/null +++ b/engine/items/inventory.asm @@ -0,0 +1,150 @@ +; 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) +; [wcf91] = item ID +; [wItemQuantity] = item quantity +; sets carry flag if successful, unsets carry flag if unsuccessful +AddItemToInventory_: + ld a,[wItemQuantity] ; a = item quantity + push af + push bc + push de + push hl + push hl + ld d,PC_ITEM_CAPACITY ; how many items the PC can hold + ld a,wNumBagItems & $FF + cp l + jr nz,.checkIfInventoryFull + ld a,wNumBagItems >> 8 + cp h + jr nz,.checkIfInventoryFull +; if the destination is the bag + ld d,BAG_ITEM_CAPACITY ; how many items the bag can hold +.checkIfInventoryFull + ld a,[hl] + sub d + ld d,a + ld a,[hli] + and a + jr z,.addNewItem +.loop + ld a,[hli] + ld b,a ; b = ID of current item in table + ld a,[wcf91] ; a = ID of item being added + cp b ; does the current item in the table match the item being added? + jp z,.increaseItemQuantity ; if so, increase the item's quantity + inc hl + ld a,[hl] + cp a,$ff ; is it the end of the table? + jr nz,.loop +.addNewItem ; add an item not yet in the inventory + pop hl + ld a,d + and a ; is there room for a new item slot? + jr z,.done +; if there is room + inc [hl] ; increment the number of items in the inventory + ld a,[hl] ; the number of items will be the index of the new item + add a + dec a + ld c,a + ld b,0 + add hl,bc ; hl = address to store the item + ld a,[wcf91] + ld [hli],a ; store item ID + ld a,[wItemQuantity] + ld [hli],a ; store item quantity + ld [hl],$ff ; store terminator + jp .success +.increaseItemQuantity ; increase the quantity of an item already in the inventory + ld a,[wItemQuantity] + ld b,a ; b = quantity to add + ld a,[hl] ; a = existing item quantity + add b ; a = new item quantity + cp a,100 + jp c,.storeNewQuantity ; if the new quantity is less than 100, store it +; if the new quantity is greater than or equal to 100, +; try to max out the current slot and add the rest in a new slot + sub a,99 + ld [wItemQuantity],a ; a = amount left over (to put in the new slot) + ld a,d + and a ; is there room for a new item slot? + jr z,.increaseItemQuantityFailed +; if so, store 99 in the current slot and store the rest in a new slot + ld a,99 + ld [hli],a + jp .loop +.increaseItemQuantityFailed + pop hl + and a + jr .done +.storeNewQuantity + ld [hl],a + pop hl +.success + scf +.done + pop hl + pop de + pop bc + pop bc + ld a,b + ld [wItemQuantity],a ; restore the initial value from when the function was called + ret + +; function to remove an item (in varying quantities) from the player's bag or PC box +; INPUT: +; hl = address of inventory (either wNumBagItems or wNumBoxItems) +; [wWhichPokemon] = index (within the inventory) of the item to remove +; [wItemQuantity] = quantity to remove +RemoveItemFromInventory_: + push hl + inc hl + ld a,[wWhichPokemon] ; index (within the inventory) of the item being removed + sla a + add l + ld l,a + jr nc,.noCarry + inc h +.noCarry + inc hl + ld a,[wItemQuantity] ; quantity being removed + ld e,a + ld a,[hl] ; a = current quantity + sub e + ld [hld],a ; store new quantity + ld [wMaxItemQuantity],a + and a + jr nz,.skipMovingUpSlots +; if the remaining quantity is 0, +; remove the emptied item slot and move up all the following item slots +.moveSlotsUp + ld e,l + ld d,h + inc de + inc de ; de = address of the slot following the emptied one +.loop ; loop to move up the following slots + ld a,[de] + inc de + ld [hli],a + cp a,$ff + jr nz,.loop +; update menu info + xor a + ld [wListScrollOffset],a + ld [wCurrentMenuItem],a + ld [wBagSavedMenuItem],a + ld [wSavedListScrollOffset],a + pop hl + ld a,[hl] ; a = number of items in inventory + dec a ; decrement the number of items + ld [hl],a ; store new number of items + ld [wListCount],a + cp a,2 + jr c,.done + ld [wMaxMenuItem],a + jr .done +.skipMovingUpSlots + pop hl +.done + ret -- cgit v1.2.3 From e9f33ce19c3f573cc7fb312d6869e711d5d9de4f Mon Sep 17 00:00:00 2001 From: dannye Date: Mon, 8 May 2017 02:54:20 -0500 Subject: =?UTF-8?q?Typo:=20SFX=5FPOKEFLUE=20=E2=86=92=20SFX=5FPOKEFLUTE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/items/items.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/items') diff --git a/engine/items/items.asm b/engine/items/items.asm index f8873a6e..057595df 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -1846,12 +1846,12 @@ PlayedFluteHadEffectText: ; play out-of-battle pokeflute music ld a,$ff call PlaySound ; turn off music - ld a, SFX_POKEFLUE + ld a, SFX_POKEFLUTE ld c, BANK(SFX_Pokeflute) call PlayMusic .musicWaitLoop ; wait for music to finish playing ld a,[wChannelSoundIDs + Ch2] - cp a, SFX_POKEFLUE + cp a, SFX_POKEFLUTE jr z,.musicWaitLoop call PlayDefaultMusic ; start playing normal music again .done -- cgit v1.2.3 From 9ea25bc8cd32df5b3bcf6333c3d2582e1b11f2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Fri, 9 Jun 2017 22:54:09 +0100 Subject: Replace deprecated mnemonics by the correct ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old mnemonics generate warnings with new versions of rgbds. This patch replaces them by the correct ones. Signed-off-by: Antonio Niño Díaz --- engine/items/items.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/items') diff --git a/engine/items/items.asm b/engine/items/items.asm index 057595df..f334e384 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -13,7 +13,7 @@ UseItem_: ld a,[hli] ld h,[hl] ld l,a - jp [hl] + jp hl ItemUsePtrTable: dw ItemUseBall ; MASTER_BALL -- cgit v1.2.3 From 7a9a1b1e55f4a7f6c339a86d8cdb7fbf1bee7838 Mon Sep 17 00:00:00 2001 From: dannye Date: Sat, 24 Jun 2017 15:01:43 -0500 Subject: Fix typos in comments --- engine/items/items.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/items') diff --git a/engine/items/items.asm b/engine/items/items.asm index 057595df..f46261b6 100755 --- a/engine/items/items.asm +++ b/engine/items/items.asm @@ -863,7 +863,7 @@ ItemUseMedicine: jp nc,.useVitamin ; if it's a vitamin or Rare Candy cp a,FULL_RESTORE jr nc,.healHP ; if it's a Full Restore or one of the potions -; fall through if it's one of the status-specifc healing items +; fall through if it's one of the status-specific healing items .cureStatusAilment ld bc,wPartyMon1Status - wPartyMon1 add hl,bc ; hl now points to status -- cgit v1.2.3