Add_To_Inventory 0, 1, 1
Add_To_Inventory 0, 4, 5
Add_To_Inventory 0, 19, 3
Add_To_Inventory 0, 9, 1
Add_To_Inventory 0, 29, 45
Add_To_Inventory 0, 100, 103
Print_Inventory 0
Remove_Inventory 0, 29, 5
Print_Inventory 0
Remove_Inventory 0, 9, 1
Print_Inventory 0
SUB Add_To_Inventory
(Who%%
, Item%%
, Count%%
) Match%% = false
IF Item%%
= _MEMGET(P
(Who%%
).Pack
, P
(Who%%
).Pack.OFFSET
+ i%%
* 2, _BYTE) THEN Match%%
= i%%: i%%
= 30 _MEMPUT P
(Who%%
).Pack
, P
(Who%%
).Pack.OFFSET
+ P
(Who%%
).Items
* 2, Item%%
'POKE _MEMPUT P
(Who%%
).Pack
, P
(Who%%
).Pack.OFFSET
+ P
(Who%%
).Items
* 2 + 1, Count%%
'POKE P(Who%%).Items = P(Who%%).Items + 1
temp%%
= _MEMGET(P
(Who%%
).Pack
, P
(Who%%
).Pack.OFFSET
+ Match%%
* 2 + 1, _BYTE) temp%% = temp%% + 1
_MEMPUT P
(Who%%
).Pack
, P
(Who%%
).Pack.OFFSET
+ Match%%
* 2 + 1, Count%%
'POKE
SUB Remove_Inventory
(who%%
, Item%%
, Count%%
) Match%% = false
FOR i%%
= 0 TO 15 'find the item IF Item%%
= _MEMGET(P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
+ i%%
* 2, _BYTE) THEN Match%%
= i%%: i%%
= 30 'something went horribly wrong!
PRINT "ERROR ITEM NOT FOUND!"; Item%%; Match%%
temp%%
= _MEMGET(P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
+ Match%%
* 2 + 1, _BYTE) temp%% = temp%% - Count%%
IF temp%%
= 0 THEN 'item is out so remove from inventory temp$
= _MEMGET(P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
, STRING * 32) 'get entire pack string temp$
= LEFT$(temp$
, Match%%
* 2 - 1) + MID$(temp$
, 2 * Match%%
+ 2) P(who%%).Items = P(who%%).Items - 1
FOR i%%
= l%%
TO 31 'pad temp$ to full 32 characters
_MEMPUT P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
, temp$
'put invetory back _MEMPUT P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
+ Match%%
* 2 + 1, temp%%
'put adjusted count back
SUB Print_Inventory
(who%%
) 'check that values in inventory are correct
'DEBUGGING!_-------------------------------
FOR i%%
= 0 TO P
(who%%
).Items
PRINT "Item Count:";
_MEMGET(P
(who%%
).Pack
, P
(who%%
).Pack.OFFSET
+ 2 * i%%
+ 1, _BYTE)