Add some demos, one of which works.
Cat's Eye Technologies
8 years ago
|
0 |
assign byte table screen 1024
|
|
1 |
|
|
2 |
assign byte table actor_x 49152
|
|
3 |
assign byte table actor_x 49152
|
|
0 |
assign byte table screen 1024
|
|
1 |
assign byte table screen2 1274
|
|
2 |
assign byte table screen3 1524
|
|
3 |
assign byte table screen4 1774
|
|
4 |
|
|
5 |
assign byte table colormap 55296
|
|
6 |
assign byte table colormap2 55546
|
|
7 |
assign byte table colormap3 55796
|
|
8 |
assign byte table colormap4 56046
|
|
9 |
|
|
10 |
assign byte vic_border 53280
|
|
11 |
assign byte table vic_bg 53281
|
|
12 |
|
|
13 |
assign vector cinv 788
|
|
14 |
reserve vector save_cinv
|
|
15 |
|
|
16 |
routine main {
|
|
17 |
lda #5
|
|
18 |
sta vic_border
|
|
19 |
lda #0
|
|
20 |
sta vic_bg
|
|
21 |
jsr clear_screen
|
|
22 |
sei {
|
|
23 |
copy vector cinv to save_cinv
|
|
24 |
copy routine our_cinv to cinv
|
|
25 |
}
|
|
26 |
clc
|
|
27 |
repeat bcc { }
|
|
28 |
}
|
|
29 |
|
|
30 |
routine our_cinv {
|
|
31 |
inc screen
|
|
32 |
jmp save_cinv
|
|
33 |
}
|
|
34 |
|
|
35 |
routine clear_screen {
|
|
36 |
ldy #0
|
|
37 |
repeat bne {
|
|
38 |
lda #1
|
|
39 |
sta colormap, y
|
|
40 |
sta colormap2, y
|
|
41 |
sta colormap3, y
|
|
42 |
sta colormap4, y
|
|
43 |
|
|
44 |
lda #32
|
|
45 |
sta screen, y
|
|
46 |
sta screen2, y
|
|
47 |
sta screen3, y
|
|
48 |
sta screen4, y
|
|
49 |
|
|
50 |
iny
|
|
51 |
cpy #250
|
|
52 |
}
|
|
53 |
}
|
|
0 |
assign byte table actor_0_sprite_x 60
|
|
1 |
assign byte table actor_0_sprite_y 68
|
|
2 |
assign byte table vic_sprite_0_x 53281
|
|
3 |
assign byte table vic_sprite_0_y 53289
|
|
4 |
|
|
5 |
reserve byte actor_msb
|
|
6 |
reserve byte msb_counter
|
|
7 |
|
|
8 |
reserve vector logic_vector
|
|
9 |
|
|
10 |
assign byte vic_sprite_x_msb 55555
|
|
11 |
|
|
12 |
routine main {
|
|
13 |
jsr display_actors
|
|
14 |
}
|
|
15 |
|
|
16 |
routine display_actors {
|
|
17 |
ldy #0
|
|
18 |
ldx #0
|
|
19 |
|
|
20 |
repeat bne {
|
|
21 |
lda actor_0_sprite_x, y
|
|
22 |
sta vic_sprite_0_x, x
|
|
23 |
lda actor_0_sprite_y, y
|
|
24 |
sta vic_sprite_0_y, x
|
|
25 |
|
|
26 |
iny
|
|
27 |
inx
|
|
28 |
inx
|
|
29 |
cpy #8
|
|
30 |
}
|
|
31 |
|
|
32 |
lda actor_msb
|
|
33 |
sta vic_sprite_x_msb
|
|
34 |
}
|
|
35 |
|
|
36 |
routine update_actors {
|
|
37 |
|
|
38 |
lda #1
|
|
39 |
sta msb_counter
|
|
40 |
lda #0
|
|
41 |
sta actor_msb
|
|
42 |
|
|
43 |
ldy #0
|
|
44 |
repeat ... {
|
|
45 |
|
|
46 |
lda actor_0_logic_high, y
|
|
47 |
if bne {
|
|
48 |
sta logic_vector+1
|
|
49 |
lda actor_0_logic_low, y
|
|
50 |
sta logic_vector
|
|
51 |
|
|
52 |
save y
|
|
53 |
jsr logic_vector
|
|
54 |
restore y
|
|
55 |
}
|
|
56 |
|
|
57 |
// update_xvel
|
|
58 |
|
|
59 |
clc
|
|
60 |
lda actor_0_xvel, y
|
|
61 |
adc actor_0_xacc, y
|
|
62 |
cmp #max_vel
|
|
63 |
bcc xvel_within_limit ; branch if accumulator is less
|
|
64 |
cmp #min_vel
|
|
65 |
bcs xvel_within_limit ; branch if accumulator is greater or equal
|
|
66 |
jmp update_xpos
|
|
67 |
|
|
68 |
xvel_within_limit:
|
|
69 |
sta actor_0_xvel, y
|
|
70 |
|
|
71 |
update_xpos:
|
|
72 |
clc
|
|
73 |
lda actor_0_xpos_low, y
|
|
74 |
adc actor_0_xvel, y
|
|
75 |
sta actor_0_xpos_low, y
|
|
76 |
|
|
77 |
lda #0
|
|
78 |
sta sign_extend
|
|
79 |
lda actor_0_xvel, y
|
|
80 |
and #$80
|
|
81 |
beq carry_x
|
|
82 |
dec sign_extend
|
|
83 |
|
|
84 |
carry_x:
|
|
85 |
lda actor_0_xpos_high, y
|
|
86 |
adc sign_extend ; $00, or $ff if xvel < 0
|
|
87 |
sta actor_0_xpos_high, y
|
|
88 |
|
|
89 |
update_yvel:
|
|
90 |
clc
|
|
91 |
lda actor_0_yvel, y
|
|
92 |
adc actor_0_yacc, y
|
|
93 |
cmp #max_vel
|
|
94 |
bcc yvel_within_limit ; branch if accumulator is less
|
|
95 |
cmp #min_vel
|
|
96 |
bcs yvel_within_limit ; branch if accumulator is greater or equal
|
|
97 |
jmp update_ypos
|
|
98 |
|
|
99 |
yvel_within_limit:
|
|
100 |
sta actor_0_yvel, y
|
|
101 |
|
|
102 |
update_ypos:
|
|
103 |
clc
|
|
104 |
lda actor_0_ypos_low, y
|
|
105 |
adc actor_0_yvel, y
|
|
106 |
sta actor_0_ypos_low, y
|
|
107 |
|
|
108 |
lda #0
|
|
109 |
sta sign_extend
|
|
110 |
lda actor_0_yvel, y
|
|
111 |
and #$80
|
|
112 |
beq carry_y
|
|
113 |
dec sign_extend
|
|
114 |
|
|
115 |
carry_y:
|
|
116 |
lda actor_0_ypos_high, y
|
|
117 |
adc sign_extend
|
|
118 |
sta actor_0_ypos_high, y
|
|
119 |
|
|
120 |
precompute_sprite_position:
|
|
121 |
|
|
122 |
lda actor_0_xpos_low, y
|
|
123 |
sta temp_low
|
|
124 |
lda actor_0_xpos_high, y
|
|
125 |
sta temp_high
|
|
126 |
|
|
127 |
jsr shift_temp
|
|
128 |
jsr shift_temp
|
|
129 |
jsr shift_temp
|
|
130 |
sta actor_0_sprite_x, y
|
|
131 |
|
|
132 |
lda temp_high ; calculate the sprite's msb
|
|
133 |
beq advance_msb_counter
|
|
134 |
lda actor_msb
|
|
135 |
ora msb_counter
|
|
136 |
sta actor_msb
|
|
137 |
|
|
138 |
advance_msb_counter:
|
|
139 |
asl msb_counter
|
|
140 |
|
|
141 |
set_sprite_y:
|
|
142 |
lda actor_0_ypos_low, y
|
|
143 |
sta temp_low
|
|
144 |
lda actor_0_ypos_high, y
|
|
145 |
sta temp_high
|
|
146 |
|
|
147 |
jsr shift_temp
|
|
148 |
jsr shift_temp
|
|
149 |
jsr shift_temp
|
|
150 |
sta actor_0_sprite_y, y
|
|
151 |
|
|
152 |
next_actor:
|
|
153 |
cpy #$07
|
|
154 |
beq exit_actor_loop
|
|
155 |
iny
|
|
156 |
jmp update_actor_loop
|
|
157 |
|
|
158 |
exit_actor_loop:
|
|
159 |
rts
|