From 1478db0fb48fec0c1311b8f4cfcb68159454dc6a Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Wed, 13 Dec 2017 13:14:10 +0000 Subject: [PATCH] Use word tables, in game, to store the actors' positions and deltas. --- eg/proto-game.60p | 112 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 25 deletions(-) diff --git a/eg/proto-game.60p b/eg/proto-game.60p index 89977de..87725fc 100644 --- a/eg/proto-game.60p +++ b/eg/proto-game.60p @@ -27,12 +27,18 @@ byte joy2 @ $dc00 // ---------------------------------------------------------------- pointer ptr @ 254 + +word table actor_pos word pos + +word table actor_delta word delta byte button_down : 0 // effectively static-local to check_button byte table press_fire_msg: "PRESS`FIRE`TO`PLAY" +byte save_x + // // Points to the routine that implements the current game state. // @@ -44,9 +50,11 @@ byte table press_fire_msg: "PRESS`FIRE`TO`PLAY" // vector dispatch_game_state - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr @@ -63,17 +71,21 @@ vector dispatch_game_state // vector cinv - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr @ 788 vector save_cinv - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr @@ -169,18 +181,12 @@ routine clear_screen } // ---------------------------------------------------------------- -// Game States +// Actor Logics // ---------------------------------------------------------------- -// -// Because these all `goto save_cinv` at the end, they must have the same signature as that routine. -// - -routine game_state_play - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, - screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 +routine player_logic + inputs pos, delta, joy2, screen + outputs pos, delta, screen trashes a, x, y, c, z, n, v, ptr { call read_stick @@ -194,14 +200,68 @@ routine game_state_play ld y, 0 copy 81, [ptr] + y +} + +routine enemy_logic + inputs pos, delta, joy2, screen + outputs pos, delta, screen + trashes a, x, y, c, z, n, v, ptr +{ +} + +// ---------------------------------------------------------------- +// Game States +// ---------------------------------------------------------------- + +// +// Because these all `goto save_cinv` at the end, they must have the same signature as that routine. +// + +routine game_state_play + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + trashes a, x, y, c, z, n, v, ptr +{ + ld x, 0 + repeat { + copy actor_pos + x, pos + copy actor_delta + x, delta + + st x, save_x + + ////// FIXME need VECTOR TABLEs to make this happen: + ////// copy actor_logic, x dispatch_logic + ////// call indirect_jsr_logic + + cmp x, 0 + if z { + call player_logic + } else { + call enemy_logic + } + + ld x, save_x + + copy pos, actor_pos + x + copy delta, actor_delta + x + + inc x + cmp x, 16 + } until z goto save_cinv } routine game_state_title_screen - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr { @@ -239,9 +299,11 @@ routine game_state_title_screen // ************************* routine our_cinv - inputs joy2, pos, button_down, press_fire_msg, dispatch_game_state, - screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 - outputs delta, pos, button_down, dispatch_game_state, + inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, + screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 + outputs button_down, dispatch_game_state, save_x, + actor_pos, pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr {