-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplot_enemies.asm
91 lines (78 loc) · 1.4 KB
/
plot_enemies.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
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; plot enemies and bullets if visible
;
plot_enemy:
ld iy,ram_sat+4*3
ld ix,enemies
ld b,max_enem + max_bullets + max_enem_bullets
ld c,3 ; main ship and its shadow
npc_loop1:
ld a,(ix+enemy_data.status)
and 1
jr z,.next
ld l,(ix+enemy_data.x+0)
ld h,(ix+enemy_data.x+1)
ld de,32
add hl,de
ld de,(xmap)
and a
sbc hl,de ; dx = enemy.x + 32 - xmap
jp c,.next ; dx <-32
ld de,32
sbc hl,de
jp c,.ecset ; -32<dx<0
ld a,h
and a
jp nz,.next ; dx >255
res 7,(iy+3)
.cont:
ld a,(ix+enemy_data.frame)
cp 16*4 ; hard coded in the SPT
jp nc,.two_layers
.one_layer:
ld (iy+2),a ; write shape
ld (iy+1),l ; write X
ld a,(ix+enemy_data.y) ; write Y
ld (iy+0),a
ld a,(iy+3)
and 0xF0
or (ix+enemy_data.color)
ld (iy+3),a ; write colour
inc c
ld de,4
add iy,de
.next:
ld de,enemy_data
add ix,de
djnz npc_loop1
ld a,c
add a,a ; x4 -> sat data
add a,a
ld (visible_sprts),a
ret
.two_layers:
ld (iy+2),a ; write shape
add a,8
ld (iy+2+4),a ; second layer shape
ld (iy+1),l ; write X
ld (iy+1+4),l
ld a,(ix+enemy_data.y) ; write Y
ld (iy+0),a
ld (iy+0+4),a
ld a,(iy+3)
and 0xF0
or (ix+enemy_data.color)
ld (iy+3),a ; write colour
and 0xF0
or 1 ; second layer colour
ld (iy+3+4),a
inc c
inc c
ld de,8
add iy,de
jp .next
.ecset:
add hl,de
set 7,(iy+3)
jp .cont