git @ Cat's Eye Technologies SixtyPical / 1478db0
Use word tables, in game, to store the actors' positions and deltas. Chris Pressey 7 years ago
1 changed file(s) with 89 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
2626 // ----------------------------------------------------------------
2727
2828 pointer ptr @ 254
29
30 word table actor_pos
2931 word pos
32
33 word table actor_delta
3034 word delta
3135
3236 byte button_down : 0 // effectively static-local to check_button
3337 byte table press_fire_msg: "PRESS`FIRE`TO`PLAY"
38
39 byte save_x
3440
3541 //
3642 // Points to the routine that implements the current game state.
4349 //
4450
4551 vector dispatch_game_state
46 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
47 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
48 outputs delta, pos, button_down, dispatch_game_state,
52 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
53 actor_pos, pos, actor_delta, delta,
54 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
55 outputs button_down, dispatch_game_state, save_x,
56 actor_pos, pos, actor_delta, delta,
4957 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
5058 trashes a, x, y, c, z, n, v, ptr
5159
6270 //
6371
6472 vector cinv
65 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
66 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
67 outputs delta, pos, button_down, dispatch_game_state,
73 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
74 actor_pos, pos, actor_delta, delta,
75 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
76 outputs button_down, dispatch_game_state, save_x,
77 actor_pos, pos, actor_delta, delta,
6878 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
6979 trashes a, x, y, c, z, n, v, ptr
7080 @ 788
7181
7282 vector save_cinv
73 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
74 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
75 outputs delta, pos, button_down, dispatch_game_state,
83 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
84 actor_pos, pos, actor_delta, delta,
85 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
86 outputs button_down, dispatch_game_state, save_x,
87 actor_pos, pos, actor_delta, delta,
7688 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
7789 trashes a, x, y, c, z, n, v, ptr
7890
168180 }
169181
170182 // ----------------------------------------------------------------
171 // Game States
172 // ----------------------------------------------------------------
173
174 //
175 // Because these all `goto save_cinv` at the end, they must have the same signature as that routine.
176 //
177
178 routine game_state_play
179 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
180 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
181 outputs delta, pos, button_down, dispatch_game_state,
182 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
183 // Actor Logics
184 // ----------------------------------------------------------------
185
186 routine player_logic
187 inputs pos, delta, joy2, screen
188 outputs pos, delta, screen
183189 trashes a, x, y, c, z, n, v, ptr
184190 {
185191 call read_stick
193199
194200 ld y, 0
195201 copy 81, [ptr] + y
202 }
203
204 routine enemy_logic
205 inputs pos, delta, joy2, screen
206 outputs pos, delta, screen
207 trashes a, x, y, c, z, n, v, ptr
208 {
209 }
210
211 // ----------------------------------------------------------------
212 // Game States
213 // ----------------------------------------------------------------
214
215 //
216 // Because these all `goto save_cinv` at the end, they must have the same signature as that routine.
217 //
218
219 routine game_state_play
220 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
221 actor_pos, pos, actor_delta, delta,
222 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
223 outputs button_down, dispatch_game_state, save_x,
224 actor_pos, pos, actor_delta, delta,
225 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
226 trashes a, x, y, c, z, n, v, ptr
227 {
228 ld x, 0
229 repeat {
230 copy actor_pos + x, pos
231 copy actor_delta + x, delta
232
233 st x, save_x
234
235 ////// FIXME need VECTOR TABLEs to make this happen:
236 ////// copy actor_logic, x dispatch_logic
237 ////// call indirect_jsr_logic
238
239 cmp x, 0
240 if z {
241 call player_logic
242 } else {
243 call enemy_logic
244 }
245
246 ld x, save_x
247
248 copy pos, actor_pos + x
249 copy delta, actor_delta + x
250
251 inc x
252 cmp x, 16
253 } until z
196254
197255 goto save_cinv
198256 }
199257
200258 routine game_state_title_screen
201 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
202 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
203 outputs delta, pos, button_down, dispatch_game_state,
259 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
260 actor_pos, pos, actor_delta, delta,
261 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
262 outputs button_down, dispatch_game_state, save_x,
263 actor_pos, pos, actor_delta, delta,
204264 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
205265 trashes a, x, y, c, z, n, v, ptr
206266 {
238298 // *************************
239299
240300 routine our_cinv
241 inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state,
242 screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
243 outputs delta, pos, button_down, dispatch_game_state,
301 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
302 actor_pos, pos, actor_delta, delta,
303 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
304 outputs button_down, dispatch_game_state, save_x,
305 actor_pos, pos, actor_delta, delta,
244306 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
245307 trashes a, x, y, c, z, n, v, ptr
246308 {