git @ Cat's Eye Technologies SixtyPical / 0452d5f
Add game_state_game_over. Needs a bit of work, though. Chris Pressey 7 years ago
1 changed file(s) with 85 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
242242 // ----------------------------------------------------------------
243243
244244 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
247249 trashes a, x, y, c, z, n, v, ptr, compare_target
248250 {
249251 call read_stick
269271 copy 32, [ptr] + y
270272
271273 copy new_pos, pos
274 trash y
275 trash c
272276 } else {
273 // copy game_state_game_over, dispatch_game_state
277 call clear_screen
278 copy forward game_state_game_over, dispatch_game_state
274279 trash n
275280 trash a
276281 trash z
284289 trash y
285290 trash a
286291 trash v
292 trash c
293 } else {
294 trash c
287295 }
288296 }
289297
308316 // Because these all `goto save_cinv` at the end, they must have the same signature as that routine.
309317 //
310318
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
351319 routine game_state_title_screen
352320 inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x,
353321 actor_pos, pos, new_pos, actor_delta, delta,
375343 if c {
376344 call clear_screen
377345 call init_game
378 copy game_state_play, dispatch_game_state
346 copy forward game_state_play, dispatch_game_state
379347
380348 // FIXME these trashes, strictly speaking, probably shouldn't be needed,
381349 // but currently the compiler cares too much about values that are
393361 goto save_cinv
394362 }
395363
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
396437 // *************************
397438 // * Main Game Loop Driver *
398439 // *************************