Add game_state_game_over. Needs a bit of work, though.
Chris Pressey
7 years ago
242 | 242 | // ---------------------------------------------------------------- |
243 | 243 | |
244 | 244 | routine player_logic |
245 | inputs pos, delta, joy2, screen | |
246 | outputs pos, delta, new_pos, screen | |
245 | inputs pos, delta, joy2, screen, dispatch_game_state, | |
246 | screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
247 | outputs pos, delta, new_pos, screen, dispatch_game_state, | |
248 | screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
247 | 249 | trashes a, x, y, c, z, n, v, ptr, compare_target |
248 | 250 | { |
249 | 251 | call read_stick |
269 | 271 | copy 32, [ptr] + y |
270 | 272 | |
271 | 273 | copy new_pos, pos |
274 | trash y | |
275 | trash c | |
272 | 276 | } else { |
273 | // copy game_state_game_over, dispatch_game_state | |
277 | call clear_screen | |
278 | copy forward game_state_game_over, dispatch_game_state | |
274 | 279 | trash n |
275 | 280 | trash a |
276 | 281 | trash z |
284 | 289 | trash y |
285 | 290 | trash a |
286 | 291 | trash v |
292 | trash c | |
293 | } else { | |
294 | trash c | |
287 | 295 | } |
288 | 296 | } |
289 | 297 | |
308 | 316 | // Because these all `goto save_cinv` at the end, they must have the same signature as that routine. |
309 | 317 | // |
310 | 318 | |
311 | routine game_state_play | |
312 | inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, | |
313 | actor_pos, pos, new_pos, actor_delta, delta, | |
314 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
315 | outputs button_down, dispatch_game_state, | |
316 | actor_pos, pos, new_pos, actor_delta, delta, | |
317 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
318 | trashes a, x, y, c, z, n, v, ptr, save_x, compare_target | |
319 | { | |
320 | ld x, 0 | |
321 | repeat { | |
322 | copy actor_pos + x, pos | |
323 | copy actor_delta + x, delta | |
324 | ||
325 | st x, save_x | |
326 | ||
327 | // FIXME need VECTOR TABLEs to make this happen: | |
328 | // copy actor_logic, x dispatch_logic | |
329 | // call indirect_jsr_logic | |
330 | // For now, just check the actor ID to see what type it is, and go from there. | |
331 | ||
332 | cmp x, 0 | |
333 | if z { | |
334 | call player_logic | |
335 | } else { | |
336 | call enemy_logic | |
337 | } | |
338 | ||
339 | ld x, save_x | |
340 | ||
341 | copy pos, actor_pos + x | |
342 | copy delta, actor_delta + x | |
343 | ||
344 | inc x | |
345 | cmp x, 16 | |
346 | } until z | |
347 | ||
348 | goto save_cinv | |
349 | } | |
350 | ||
351 | 319 | routine game_state_title_screen |
352 | 320 | inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, |
353 | 321 | actor_pos, pos, new_pos, actor_delta, delta, |
375 | 343 | if c { |
376 | 344 | call clear_screen |
377 | 345 | call init_game |
378 | copy game_state_play, dispatch_game_state | |
346 | copy forward game_state_play, dispatch_game_state | |
379 | 347 | |
380 | 348 | // FIXME these trashes, strictly speaking, probably shouldn't be needed, |
381 | 349 | // but currently the compiler cares too much about values that are |
393 | 361 | goto save_cinv |
394 | 362 | } |
395 | 363 | |
364 | routine game_state_play | |
365 | inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, | |
366 | actor_pos, pos, new_pos, actor_delta, delta, | |
367 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
368 | outputs button_down, dispatch_game_state, | |
369 | actor_pos, pos, new_pos, actor_delta, delta, | |
370 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
371 | trashes a, x, y, c, z, n, v, ptr, save_x, compare_target | |
372 | { | |
373 | ld x, 0 | |
374 | repeat { | |
375 | copy actor_pos + x, pos | |
376 | copy actor_delta + x, delta | |
377 | ||
378 | st x, save_x | |
379 | ||
380 | // FIXME need VECTOR TABLEs to make this happen: | |
381 | // copy actor_logic, x dispatch_logic | |
382 | // call indirect_jsr_logic | |
383 | // For now, just check the actor ID to see what type it is, and go from there. | |
384 | ||
385 | cmp x, 0 | |
386 | if z { | |
387 | call player_logic | |
388 | } else { | |
389 | call enemy_logic | |
390 | } | |
391 | ||
392 | ld x, save_x | |
393 | ||
394 | copy pos, actor_pos + x | |
395 | copy delta, actor_delta + x | |
396 | ||
397 | inc x | |
398 | cmp x, 16 | |
399 | } until z | |
400 | ||
401 | goto save_cinv | |
402 | } | |
403 | ||
404 | routine game_state_game_over | |
405 | inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, | |
406 | actor_pos, pos, new_pos, actor_delta, delta, | |
407 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
408 | outputs button_down, dispatch_game_state, | |
409 | actor_pos, pos, new_pos, actor_delta, delta, | |
410 | screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 | |
411 | trashes a, x, y, c, z, n, v, ptr, save_x, compare_target | |
412 | { | |
413 | st off, c | |
414 | call check_button | |
415 | ||
416 | if c { | |
417 | call clear_screen | |
418 | call init_game | |
419 | copy game_state_title_screen, dispatch_game_state | |
420 | ||
421 | // FIXME these trashes, strictly speaking, probably shouldn't be needed, | |
422 | // but currently the compiler cares too much about values that are | |
423 | // initialized in one branch of an `if`, but not the other, but trashed | |
424 | // at the end of the routine anyway. | |
425 | trash a | |
426 | trash n | |
427 | trash z | |
428 | } else { | |
429 | trash y | |
430 | trash c | |
431 | trash v | |
432 | } | |
433 | ||
434 | goto save_cinv | |
435 | } | |
436 | ||
396 | 437 | // ************************* |
397 | 438 | // * Main Game Loop Driver * |
398 | 439 | // ************************* |