// **************************** // * Demo Game for SixtyPical * // **************************** // ---------------------------------------------------------------- // System Locations // ---------------------------------------------------------------- byte vic_border @ 53280 byte vic_bg @ 53281 byte table screen1 @ 1024 byte table screen2 @ 1274 byte table screen3 @ 1524 byte table screen4 @ 1774 byte table colormap1 @ 55296 byte table colormap2 @ 55546 byte table colormap3 @ 55796 byte table colormap4 @ 56046 buffer[2048] screen @ 1024 byte joy2 @ $dc00 // ---------------------------------------------------------------- // Global Variables // ---------------------------------------------------------------- pointer ptr @ 254 word table actor_pos word pos word new_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. // // It's very arguable that screen1/2/3/4 and colormap1/2/3/4 are not REALLY inputs. // They're only there to support the fact that game states sometimes clear the // screen, and sometimes don't. When they don't, they preserve the screen, and // currently the way to say "we preserve the screen" is to have it as both input // and output. There is probably a better way to do this, but it needs thought. // vector dispatch_game_state inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, actor_pos, pos, new_pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 outputs button_down, dispatch_game_state, save_x, actor_pos, pos, new_pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr // // The constraints on these 2 vectors are kind-of sort-of big fibs. // They're only written this way so they can be compatible with our // routine. In fact, CINV is an interrupt routine where it doesn't // really matter what you trash anyway, because all registers were /// saved by the caller (the KERNAL) and will be restored by the end // of the code of the saved origin cinv routine that we goto. // // I wonder if this could be arranged somehow to be less fibby, in // a future version of SixtyPical. // vector cinv inputs joy2, button_down, press_fire_msg, dispatch_game_state, save_x, actor_pos, pos, new_pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 outputs button_down, dispatch_game_state, save_x, actor_pos, pos, new_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, button_down, press_fire_msg, dispatch_game_state, save_x, actor_pos, pos, new_pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 outputs button_down, dispatch_game_state, save_x, actor_pos, pos, new_pos, actor_delta, delta, screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, x, y, c, z, n, v, ptr // ---------------------------------------------------------------- // Utility Routines // ---------------------------------------------------------------- routine read_stick inputs joy2 outputs delta trashes a, x, z, n { ld x, joy2 ld a, x and a, 1 // up if z { copy $ffd8, delta // -40 } else { ld a, x and a, 2 // down if z { copy word 40, delta } else { ld a, x and a, 4 // left if z { copy $ffff, delta // -1 } else { ld a, x and a, 8 // right if z { copy word 1, delta } else { copy word 0, delta } } } } } // You can repeatedly (i.e. as part of actor logic or an IRQ handler) // call this routine. // Upon return, if carry is set, the button was pressed then released. routine check_button inputs joy2, button_down outputs c, button_down trashes a, z, n { ld a, button_down if z { ld a, joy2 and a, $10 if z { ld a, 1 st a, button_down } st off, c } else { ld a, joy2 and a, $10 if not z { ld a, 0 st a, button_down st on, c } else { st off, c } } } routine clear_screen outputs screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 trashes a, y, c, n, z { ld y, 0 repeat { ld a, 1 st a, colormap1 + y st a, colormap2 + y st a, colormap3 + y st a, colormap4 + y ld a, 32 st a, screen1 + y st a, screen2 + y st a, screen3 + y st a, screen4 + y inc y cmp y, 250 } until z } routine calculate_new_position inputs pos, delta outputs new_pos trashes a, c, n, z, v { copy pos, new_pos st off, c add new_pos, delta } // routine compare_new_pos // { // lda >new_position // cmp >compare_target // if beq { // lda