-
Notifications
You must be signed in to change notification settings - Fork 0
/
inventory.asm
57 lines (45 loc) · 1.08 KB
/
inventory.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.updateInventory:
{
LDA keyFlags
AND #_keyInventory
BEQ checkWasPressed
STA wasPressedFlagInventory
RTS
.checkWasPressed:
LDA wasPressedFlagInventory
BNE attemptChange
RTS
.attemptChange:
LDA playerUsingItem
BEQ inventoryOut ; quit if using nothing
LDX #$0
.searchForBit:
CMP itemTable,X
BEQ itemLookup
INX
INX
JMP searchForBit
.rescan:
LDX #$fe
.itemLookup:
INX
.innerItemLookup:
INX
LDA itemTable,X
BEQ rescan; if this is zero, we've wrapped
TAY ; Store the item in Y ready
INX
LDA itemTable,X
AND playerInventory
BNE foundItem
JMP innerItemLookup
; Here we have found an item and it's in Y
.foundItem:
STY playerUsingItem
JSR drawItem
.inventoryOut:
LDA #0
STA wasPressedFlagInventory
RTS
}
PRINT "* Inventory size: ",P%-updateInventory