-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinventory.z80
More file actions
115 lines (93 loc) · 1.32 KB
/
inventory.z80
File metadata and controls
115 lines (93 loc) · 1.32 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module inventory
struct inventory_item
icon word
name word
description word
ends
keycard inventory_item res.keycard, i18n.keycard, i18n.keycard_description
; a - item index
add_item:
ld hl, INVENTORY_START
ld b, a
1
ld a, (hl)
or a
jr z, 2F
inc hl
jr 1B
2
ld (hl), b
ret
inventory_items:
dw keycard
; a - item code (overwritten)
; out: hl - item
resolve_item:
push bc
ld c, a
dec c
ld b, 0
ld hl, inventory_items
add hl, bc
add hl, bc
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
pop bc
ret
; de - icon addr (using sprite format)
; hl - screen coords (row /col)
draw_icon:
call screen.pos_to_bitmap_addr
ex de, hl
inc hl
ld (.restore_sp+1), sp
ld sp, hl
ex de, hl
ld b, 8
ld a, h
inc sp
1
pop de
ld (hl), d
inc h
djnz 1B
ld h, a
inc l
ld b, 8
inc sp
2
pop de
ld (hl), d
inc h
djnz 2B
dec l
correct_down_line h, l
ld a, h
inc sp
rept 4, idx
pop de
ld (hl), e
inc h
ld (hl), d
if idx < 3
inc h
endif
endr
ld h, a
inc l
inc sp
rept 4, idx
pop de
ld (hl), e
inc h
ld (hl), d
if idx < 3
inc h
endif
endr
.restore_sp:
ld sp, 0
ret
endmodule