-
Notifications
You must be signed in to change notification settings - Fork 0
/
enemy_starglasses.asm
79 lines (73 loc) · 1.47 KB
/
enemy_starglasses.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
starglasses_spawn: subroutine
; x is set by enemy spawner
jsr get_next_random
sta enemy_ram_ac,x ; animation counter
lda #$c0
sta enemy_ram_pc,x ; pattern counter
lda #$f8
sta enemy_ram_x,x ; x pos
jsr get_next_random
lsr
lsr
clc
adc #$18
sta enemy_ram_y,x ; y pos
rts
;;; HANDLING STARGLASSES
starglasses_cycle: subroutine
lda #$10
sta collision_0_w
sta collision_0_h
jsr enemy_handle_damage_and_death
.x_decide_action
; calc x
lda enemy_ram_x,x
cmp #$10
beq .x_sine_pattern
inc enemy_ram_x,x
lda enemy_ram_x,x
jsr sprite_4_set_x
jmp .y_calc_pos
.x_sine_pattern
; using pattern_counter for x sin
inc enemy_ram_pc,x
lda enemy_ram_pc,x
tax
lda sine_table,x
lsr
lsr
ldx enemy_ram_offset
clc
adc enemy_ram_x,x
jsr sprite_4_set_x
.y_calc_pos
; using anim_counter for y sin
inc enemy_ram_ac,x
inc enemy_ram_ac,x
; calc y
ldx enemy_ram_offset
lda enemy_ram_ac,x
tax
lda sine_table,x
lsr
lsr
clc
ldx enemy_ram_offset
adc enemy_ram_y,x
jsr sprite_4_set_y
; tiles
ldx enemy_ram_offset
lda enemy_ram_ac,x
and #$40
beq .frame1
.frame0
lda #$7a
bne .frame_done
.frame1
lda #$7c
.frame_done
jsr sprite_4_set_sprite
lda #$03
jsr sprite_4_set_palette
.done
jmp update_enemies_handler_next