diff --git a/README.rst b/README.rst index 8d38e06..acf635a 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,14 @@ Fujirun My (winning!) entry in the `KansasFest `_ 2017 `HackFest `_ competition. +Code Walkthrough +================ + +TBD + +* any place you see the "_smc" extension, that's a target for self-modifying code. Got that from Quinn Dunki. + + References ========== diff --git a/actors.s b/actors.s index 68d2cd7..976b6b6 100644 --- a/actors.s +++ b/actors.s @@ -1,7 +1,7 @@ level_enemies .byte 55, 4, 5, 6, 7, 8 ;# level starts counting from 1, so dummy zeroth level info level_speed_l .byte 255, 200, 210, 220, 230, 240 ;# increment of fractional pixel per game frame -level_speed_h .byte 2, 2, 2, 2, 2, 2 -;level_speed_h .byte 0, 0, 0, 0, 0, 0 +level_speed_h .byte 2, 2, 2, 2, 2, 2 ; increment of whole pixels + player_score_row .byte 2, 7, 12, 17 player_lives_row .byte 3, 8, 13, 18 player_score_l .byte 0, 0, 0, 0 diff --git a/logic.s b/logic.s index 7a6e8e1..ffae821 100644 --- a/logic.s +++ b/logic.s @@ -1,51 +1,4 @@ - -; def draw_actors(): -; zp.current_actor = 0 -; while zp.current_actor <= zp.last_enemy: -; r = actor_row[zp.current_actor] -; c = actor_col[zp.current_actor] -; get_sprite() -; draw_sprite(r, c) -; zp.current_actor += 1 -; -; def get_sprite(): -; a = actor_status[zp.current_actor] -; if a == PLAYER_ALIVE: -; c = ord("$") + zp.current_actor -; elif a == PLAYER_EXPLODING: -; collision_log.debug("p%d: exploding, frame=%d" % (zp.current_actor, actor_frame_counter[zp.current_actor])) -; c = ord(exploding_char[actor_frame_counter[zp.current_actor]]) -; actor_frame_counter[zp.current_actor] -= 1 -; if actor_frame_counter[zp.current_actor] <= 0: -; actor_status[zp.current_actor] = PLAYER_DEAD -; actor_frame_counter[zp.current_actor] = DEAD_TIME -; elif a == PLAYER_DEAD: -; collision_log.debug("p%d: dead, waiting=%d" % (zp.current_actor, actor_frame_counter[zp.current_actor])) -; c = None -; actor_frame_counter[zp.current_actor] -= 1 -; if actor_frame_counter[zp.current_actor] <= 0: -; player_lives[zp.current_actor] -= 1 -; if player_lives[zp.current_actor] > 0: -; init_player() -; actor_status[zp.current_actor] = PLAYER_REGENERATING -; actor_frame_counter[zp.current_actor] = REGENERATING_TIME -; else: -; actor_status[zp.current_actor] = GAME_OVER -; elif a == PLAYER_REGENERATING: -; collision_log.debug("p%d: regenerating, frame=%d" % (zp.current_actor, actor_frame_counter[zp.current_actor])) -; if actor_frame_counter[zp.current_actor] & 1: -; c = ord("$") + zp.current_actor -; else: -; c = ord(" ") -; actor_frame_counter[zp.current_actor] -= 1 -; if actor_frame_counter[zp.current_actor] <= 0: -; actor_status[zp.current_actor] = PLAYER_ALIVE -; elif a == AMIDAR_NORMAL or a == ORBITER_NORMAL: -; c = ord("0") + zp.current_actor - FIRST_AMIDAR -; else: -; c = None -; zp.sprite_addr = c - +; check the player and change its state if necessary evaluate_status nop ; update pixel position lda actor_status,x @@ -100,7 +53,7 @@ evaluate_status nop sta actor_status,x ?end rts - +; convert tile and sub-tile position into coordinate on screen get_sprite nop lda actor_row,x tay @@ -114,17 +67,10 @@ get_sprite nop clc adc actor_xpixel,x sta actor_x,x - ?end rts -?game_over - rts -; -; -; ##### Game logic -; ; # Determine which of the 4 directions is allowed at the given row, col ; def get_allowed_dirs(r, c): ; addr = mazerow(r) @@ -140,7 +86,6 @@ get_allowed_dirs nop rts - ; # See if current tile has a dot ; def has_dot(r, c): ; addr = mazerow(r) @@ -154,11 +99,6 @@ has_dot nop rts -; # clear a dot -; def clear_dot(r, c): -; addr = mazerow(r) -; addr[c] &= ~TILE_DOT -; ; # Determine the tile location given the direction of the actor's movement ; def get_next_tile(r, c, dir): ; if dir & TILE_UP: @@ -270,7 +210,8 @@ get_target_col nop rts ; actor_target_col[zp.current_actor] = target_col ; return current -; + + ; def check_midpoint(current): ; # set up decision point flag to see if we have crossed the midpoint ; # after the movement diff --git a/main.s b/main.s index 7f890e5..dfd1dd9 100644 --- a/main.s +++ b/main.s @@ -16,7 +16,7 @@ param_index .ds 1 param_count .ds 1 param_save .ds 1 - *= $0010 + *= $0080 ; scratch areas: these may be modified by child subroutines scratch_addr .ds 2 scratch_ptr .ds 2 @@ -28,8 +28,8 @@ scratch_count .ds 1 scratch_col .ds 1 scratch_row .ds 1 - *= $0020 -; required variables for HiSprite + *= $0090 +; required variables for HiSprite/asmgen damageindex .ds 1 damageindex1 .ds 1 damageindex2 .ds 1 @@ -40,7 +40,7 @@ damageptr .ds 2 damageptr1 .ds 2 damageptr2 .ds 2 - *= $0030 + *= $00a0 tdamageindex .ds 1 tdamageindex1 .ds 1 tdamageindex2 .ds 1 @@ -51,7 +51,7 @@ end .ds 2 count .ds 2 delta .ds 2 - *= $0040 + *= $00b0 ; global variables for this program rendercount .ds 1 drawpage .ds 1 ; pos = page1, neg = page2 @@ -65,7 +65,7 @@ temprow .ds 1 tempcol .ds 1 tempcheck .ds 1 - *= $0050 + *= $00c0 mazeaddr .ds 2 next_level_box .ds 1 box_row_save .ds 1 @@ -77,7 +77,7 @@ frame_count .ds 2 countdown_time .ds 1 still_alive .ds 1 - *= $0060 + *= $00d0 current_actor .ds 1 current .ds 1 ; current direction last_dir .ds 1 @@ -95,7 +95,7 @@ c2 .ds 1 size .ds 1 dot .ds 1 - * = $0070 + * = $00e0 before .ds 1 crossed .ds 1 round_robin_index .ds 2 @@ -130,21 +130,19 @@ start jsr set_hires ; start with HGR page 1, full screen sta dst+1 jsr unpack_lz4 - ;jsr clrscr - jsr init_once - -restart jsr title_screen +restart jsr init_once + jsr title_screen jsr init_game jsr game_loop -check_restart ldx #34 +check_restart ldx #34 ; x coord on screen for "GAME" ldy player_score_row lda #game_text sta scratch_ptr+1 jsr printstr - ldx #35 + ldx #35 ; x coordinate for "OVER" ldy player_lives_row lda #