Repository navigation
Expand file tree
/
Copy pathobjects.z80
More file actions
104 lines (90 loc) · 1.35 KB
/
Copy pathobjects.z80
File metadata and controls
104 lines (90 loc) · 1.35 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
struct object
y byte
x byte
mirror byte
sprite word
state word
state_2 word
spritesheet word
behaviour word
ends
struct object_behaviour
tick word
turn word
interact word
draw word
ends
module objects
; hl - object list (preserved)
; a - behaviour offset
object_loop:
1
push hl
ld b, a
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
xor a
or h
jr z, 2F
ld a, b
push af
call call_behaviour
pop af
pop hl
.2 inc hl
jr 1B
2
pop hl
ret
; hl - object
; a - behaviour offset
; corrupts de and bc
call_behaviour:
ld d, h
ld e, l
ld bc, object.behaviour
add hl, bc
ld c, (hl)
inc hl
ld h, (hl)
bit 7, h
ret z
ld l, c
ld c, a
add hl, bc
ld c, (hl)
inc hl
ld h, (hl)
bit 7, h
ret z
ld l, c
push hl
ex de, hl
ret
;; ix - character object
;; a - sprite number
update_sprite:
push hl
push de
ld e, a
ld d, 0
ld hl, sprite.spritesheet_table
add hl, de
add hl, de
ld e, (hl)
inc hl
ld h, (hl)
ld l, e
ld e, (ix + object.spritesheet)
ld d, (ix + object.spritesheet + 1)
add hl, de
ld (ix + object.sprite), l
ld (ix + object.sprite + 1), h
ld a, 1
ld (dirty_screen), a
pop de
pop hl
ret
endmodule