-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_demo.asm
145 lines (129 loc) · 2.78 KB
/
player_demo.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
; controls player in demo mode
player_demo_controls: subroutine
; PLAYER MOVEMENT
; clear player directions
lda #$00
sta player_controls
sta player_controls_debounced
; set flags in y register
tay
; check x coordinate
lda player_x_hi
cmp player_demo_x
beq .player_x_equal
bcs .player_x_greater
.player_x_lesser
lda player_demo_lr
cmp #$ff
beq .player_x_equal
; go right
lda #BUTTON_RIGHT
ora player_controls
sta player_controls
;inc player_x_hi
jmp .player_x_done
.player_x_greater
lda player_demo_lr
cmp #$00
beq .player_x_equal
; go left
lda #BUTTON_LEFT
ora player_controls
sta player_controls
;dec player_x_hi
jmp .player_x_done
.player_x_equal
iny
.player_x_done
; check y coordinate
lda player_y_hi
cmp player_demo_y
beq .player_y_equal
bcs .player_y_greater
.player_y_lesser
lda player_demo_ud
cmp #$ff
beq .player_y_equal
; go down
lda #BUTTON_DOWN
ora player_controls
sta player_controls
;inc player_y_hi
jmp .player_y_done
.player_y_greater
lda player_demo_ud
cmp #$00
beq .player_y_equal
; go up
lda #BUTTON_UP
ora player_controls
sta player_controls
;dec player_y_hi
jmp .player_y_done
.player_y_equal
iny
.player_y_done
; check if both coordinates are met
cpy #$02
beq .set_demo_new_target
jmp .done
.set_demo_new_target
; set x target
lda rng0
jsr NextRandom
sta rng0
lsr
clc
adc #$5e
sta player_demo_x
cmp player_x_hi
bcs .player_going_left
.player_going_right
lda #$ff
sta player_demo_lr
jmp .player_x_dir_done
.player_going_left
lda #$00
sta player_demo_lr
.player_x_dir_done
; set y target
lda rng0
jsr NextRandom
sta rng0
lsr
clc
adc #$10
sta player_demo_y
cmp player_y_hi
bcs .player_going_up
.player_going_down
lda #$ff
sta player_demo_ud
jmp .player_y_dir_done
.player_going_up
lda #$00
sta player_demo_ud
.player_y_dir_done
.done
jsr player_move_position
; PLAYER GUN
lda wtf
and #$47
cmp #$40
bne .fire_not_turbo
lda #BUTTON_A
ora player_controls
sta player_controls
.fire_not_turbo
lda #BUTTON_B
ora player_controls
sta player_controls
lda wtf
and #$0f ; should be 7
cmp #$00
bne .fire_done
lda #BUTTON_B
sta player_controls_debounced
.fire_done
jsr player_bullets_check_controls
rts