mirror of
https://github.com/robmcmullen/fujirun.git
synced 2024-06-07 11:29:30 +00:00
Corrected midpoint tile changes for orbiter & higher speeds
This commit is contained in:
parent
85fb9cd036
commit
27ee9349cb
10
actors.s
10
actors.s
|
@ -1,5 +1,7 @@
|
||||||
level_enemies .byte 55, 4, 5, 6, 7, 8 ;# level starts counting from 1, so dummy zeroth level info
|
level_enemies .byte 55, 4, 5, 6, 7, 8 ;# level starts counting from 1, so dummy zeroth level info
|
||||||
level_speeds .byte 255, 200, 210, 220, 230, 240 ;# increment of fractional pixel per game frame
|
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
|
||||||
player_score_row .byte 2, 7, 12, 17
|
player_score_row .byte 2, 7, 12, 17
|
||||||
player_score_l .byte 0, 0, 0, 0
|
player_score_l .byte 0, 0, 0, 0
|
||||||
player_score_h .byte 0, 0, 0, 0
|
player_score_h .byte 0, 0, 0, 0
|
||||||
|
@ -197,9 +199,11 @@ init_actor nop
|
||||||
sta actor_ypixel,x
|
sta actor_ypixel,x
|
||||||
lda #0
|
lda #0
|
||||||
sta actor_xfrac,x
|
sta actor_xfrac,x
|
||||||
sta actor_xspeed,x
|
sta actor_xspeed_l,x
|
||||||
|
sta actor_xspeed_h,x
|
||||||
sta actor_yfrac,x
|
sta actor_yfrac,x
|
||||||
sta actor_yspeed,x
|
sta actor_yspeed_l,x
|
||||||
|
sta actor_yspeed_h,x
|
||||||
sta actor_input_dir,x
|
sta actor_input_dir,x
|
||||||
sta actor_frame_counter,x
|
sta actor_frame_counter,x
|
||||||
sta actor_target_col,x
|
sta actor_target_col,x
|
||||||
|
|
12
debug.s
12
debug.s
|
@ -206,6 +206,18 @@ debug_player nop
|
||||||
ldy scratch_row
|
ldy scratch_row
|
||||||
jsr printhex
|
jsr printhex
|
||||||
|
|
||||||
|
dec scratch_row
|
||||||
|
ldx #FIRST_AMIDAR
|
||||||
|
lda actor_xfrac,x
|
||||||
|
ldx #35
|
||||||
|
ldy scratch_row
|
||||||
|
jsr printhex
|
||||||
|
ldx #FIRST_AMIDAR
|
||||||
|
lda actor_yfrac,x
|
||||||
|
ldx #38
|
||||||
|
ldy scratch_row
|
||||||
|
jsr printhex
|
||||||
|
|
||||||
dec scratch_row
|
dec scratch_row
|
||||||
ldx #34
|
ldx #34
|
||||||
ldy scratch_row
|
ldy scratch_row
|
||||||
|
|
194
logic.s
194
logic.s
|
@ -202,6 +202,85 @@ check_midpoint nop
|
||||||
?mid lda #1
|
?mid lda #1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
before_midpoint nop
|
||||||
|
lda current
|
||||||
|
and #TILE_UP
|
||||||
|
beq ?down
|
||||||
|
lda actor_ypixel,x
|
||||||
|
cmp #Y_MIDPOINT
|
||||||
|
bcc ?n
|
||||||
|
beq ?n
|
||||||
|
bcs ?y
|
||||||
|
?down lda current
|
||||||
|
and #TILE_DOWN
|
||||||
|
beq ?left
|
||||||
|
lda actor_ypixel,x
|
||||||
|
cmp #Y_MIDPOINT
|
||||||
|
bcc ?y
|
||||||
|
bcs ?n
|
||||||
|
?left lda current
|
||||||
|
and #TILE_LEFT
|
||||||
|
beq ?right
|
||||||
|
lda actor_xpixel,x
|
||||||
|
cmp #X_MIDPOINT
|
||||||
|
bcc ?n
|
||||||
|
beq ?n
|
||||||
|
bcs ?y
|
||||||
|
?right lda current
|
||||||
|
and #TILE_RIGHT
|
||||||
|
beq ?n
|
||||||
|
lda actor_xpixel,x
|
||||||
|
cmp #X_MIDPOINT
|
||||||
|
bcc ?y
|
||||||
|
;bcs ?n
|
||||||
|
?n lda #0
|
||||||
|
sta crossed
|
||||||
|
rts
|
||||||
|
?y lda #1
|
||||||
|
sta crossed
|
||||||
|
rts
|
||||||
|
|
||||||
|
; check if midpoint OR after
|
||||||
|
crossed_midpoint nop
|
||||||
|
lda crossed
|
||||||
|
bne ?1
|
||||||
|
rts ; immediately abort if already after midpoint
|
||||||
|
?1 lda current
|
||||||
|
and #TILE_UP
|
||||||
|
beq ?down
|
||||||
|
lda actor_ypixel,x
|
||||||
|
cmp #Y_MIDPOINT
|
||||||
|
bcc ?y
|
||||||
|
beq ?y
|
||||||
|
bcs ?n
|
||||||
|
?down lda current
|
||||||
|
and #TILE_DOWN
|
||||||
|
beq ?left
|
||||||
|
lda actor_ypixel,x
|
||||||
|
cmp #Y_MIDPOINT
|
||||||
|
bcc ?n
|
||||||
|
bcs ?y
|
||||||
|
?left lda current
|
||||||
|
and #TILE_LEFT
|
||||||
|
beq ?right
|
||||||
|
lda actor_xpixel,x
|
||||||
|
cmp #X_MIDPOINT
|
||||||
|
bcc ?y
|
||||||
|
beq ?y
|
||||||
|
bcs ?n
|
||||||
|
?right lda current
|
||||||
|
and #TILE_RIGHT
|
||||||
|
beq ?n
|
||||||
|
lda actor_xpixel,x
|
||||||
|
cmp #X_MIDPOINT
|
||||||
|
; bcc ?n
|
||||||
|
bcs ?y
|
||||||
|
?n lda #0 ; no
|
||||||
|
sta crossed
|
||||||
|
rts
|
||||||
|
?y lda #1 ; yes
|
||||||
|
sta crossed
|
||||||
|
rts
|
||||||
|
|
||||||
; # Move enemy given the enemy index
|
; # Move enemy given the enemy index
|
||||||
; def move_enemy():
|
; def move_enemy():
|
||||||
|
@ -225,24 +304,41 @@ move_enemy nop
|
||||||
;
|
;
|
||||||
; # check sub-pixel location to see if we've reached a decision point
|
; # check sub-pixel location to see if we've reached a decision point
|
||||||
; temp = check_midpoint(current)
|
; temp = check_midpoint(current)
|
||||||
jsr check_midpoint
|
jsr before_midpoint
|
||||||
sta tempcheck
|
|
||||||
|
|
||||||
; pixel_move(current)
|
; pixel_move(current)
|
||||||
jsr pixel_move
|
jsr pixel_move
|
||||||
|
|
||||||
|
jsr crossed_midpoint ; save this for later
|
||||||
|
lda crossed
|
||||||
|
beq ?left
|
||||||
|
|
||||||
|
; if check_midpoint(current):
|
||||||
|
; # crossed the midpoint! Make a decision on the next allowed direction
|
||||||
|
; if actor_status[zp.current_actor] == ORBITER_NORMAL:
|
||||||
|
; decide_orbiter()
|
||||||
|
; else:
|
||||||
|
; decide_direction()
|
||||||
|
lda actor_type,x
|
||||||
|
cmp #ORBITER_TYPE
|
||||||
|
bne ?dir
|
||||||
|
jsr decide_orbiter
|
||||||
|
jmp ?left
|
||||||
|
?dir jsr decide_direction
|
||||||
|
|
||||||
; # check if moved to next tile. pixel fraction stays the same to keep
|
; # check if moved to next tile. pixel fraction stays the same to keep
|
||||||
; # the speed consistent, only the pixel gets adjusted
|
; # the speed consistent, only the pixel gets adjusted
|
||||||
; if actor_xpixel[zp.current_actor] < 0:
|
; if actor_xpixel[zp.current_actor] < 0:
|
||||||
; actor_col[zp.current_actor] -= 1
|
; actor_col[zp.current_actor] -= 1
|
||||||
; actor_xpixel[zp.current_actor] += X_TILEMAX
|
; actor_xpixel[zp.current_actor] += X_TILEMAX
|
||||||
lda actor_xpixel,x
|
?left lda actor_xpixel,x
|
||||||
bpl ?right
|
bpl ?right
|
||||||
dec actor_col,x
|
dec actor_col,x
|
||||||
lda actor_xpixel,x
|
lda actor_xpixel,x
|
||||||
clc
|
clc
|
||||||
adc #X_TILEMAX
|
adc #X_TILEMAX
|
||||||
sta actor_xpixel,x
|
sta actor_xpixel,x
|
||||||
jmp ?mid
|
jmp ?ret
|
||||||
|
|
||||||
; elif actor_xpixel[zp.current_actor] >= X_TILEMAX:
|
; elif actor_xpixel[zp.current_actor] >= X_TILEMAX:
|
||||||
; actor_col[zp.current_actor] += 1
|
; actor_col[zp.current_actor] += 1
|
||||||
|
@ -255,7 +351,7 @@ move_enemy nop
|
||||||
sec
|
sec
|
||||||
sbc #X_TILEMAX
|
sbc #X_TILEMAX
|
||||||
sta actor_xpixel,x
|
sta actor_xpixel,x
|
||||||
jmp ?mid
|
jmp ?ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,40 +365,20 @@ move_enemy nop
|
||||||
clc
|
clc
|
||||||
adc #Y_TILEMAX
|
adc #Y_TILEMAX
|
||||||
sta actor_ypixel,x
|
sta actor_ypixel,x
|
||||||
jmp ?mid
|
jmp ?ret
|
||||||
|
|
||||||
; elif actor_ypixel[zp.current_actor] >= Y_TILEMAX:
|
; elif actor_ypixel[zp.current_actor] >= Y_TILEMAX:
|
||||||
; actor_row[zp.current_actor] += 1
|
; actor_row[zp.current_actor] += 1
|
||||||
; actor_ypixel[zp.current_actor] -= Y_TILEMAX
|
; actor_ypixel[zp.current_actor] -= Y_TILEMAX
|
||||||
?down lda actor_ypixel,x
|
?down lda actor_ypixel,x
|
||||||
cmp #Y_TILEMAX
|
cmp #Y_TILEMAX
|
||||||
bcc ?mid
|
bcc ?ret
|
||||||
inc actor_row,x
|
inc actor_row,x
|
||||||
lda actor_ypixel,x
|
lda actor_ypixel,x
|
||||||
sec
|
sec
|
||||||
sbc #Y_TILEMAX
|
sbc #Y_TILEMAX
|
||||||
sta actor_ypixel,x
|
sta actor_ypixel,x
|
||||||
|
|
||||||
; s = "#%d: tile=%d,%d pix=%d,%d frac=%d,%d " % (zp.current_actor, actor_col[zp.current_actor], actor_row[zp.current_actor], actor_xpixel[zp.current_actor], actor_ypixel[zp.current_actor], actor_xfrac[zp.current_actor], actor_yfrac[zp.current_actor])
|
|
||||||
; logic_log.debug(s)
|
|
||||||
; pad.addstr(0 + zp.current_actor, 40, s)
|
|
||||||
; if not temp:
|
|
||||||
?mid lda tempcheck ; check if crossing onto midpoint
|
|
||||||
bne ?ret ; nope, already on midpoint so must have checked last time
|
|
||||||
|
|
||||||
jsr check_midpoint
|
|
||||||
beq ?ret ; nope, still not on midpoint
|
|
||||||
; if check_midpoint(current):
|
|
||||||
; # crossed the midpoint! Make a decision on the next allowed direction
|
|
||||||
; if actor_status[zp.current_actor] == ORBITER_NORMAL:
|
|
||||||
; decide_orbiter()
|
|
||||||
; else:
|
|
||||||
; decide_direction()
|
|
||||||
lda actor_type,x
|
|
||||||
cmp #ORBITER_TYPE
|
|
||||||
bne ?dir
|
|
||||||
jmp decide_orbiter
|
|
||||||
?dir jmp decide_direction
|
|
||||||
?ret rts
|
?ret rts
|
||||||
|
|
||||||
;
|
;
|
||||||
|
@ -319,10 +395,11 @@ pixel_move nop
|
||||||
bne ?down
|
bne ?down
|
||||||
lda actor_yfrac,x
|
lda actor_yfrac,x
|
||||||
sec
|
sec
|
||||||
sbc actor_yspeed,x
|
sbc actor_yspeed_l,x
|
||||||
sta actor_yfrac,x
|
sta actor_yfrac,x
|
||||||
bcs ?ret
|
lda actor_ypixel,x
|
||||||
dec actor_ypixel,x ; haha! Don't have to adjust yfrac because it's only 8 bits!
|
sbc actor_yspeed_h,x
|
||||||
|
sta actor_ypixel,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; elif current & TILE_DOWN:
|
; elif current & TILE_DOWN:
|
||||||
|
@ -334,10 +411,11 @@ pixel_move nop
|
||||||
bne ?left
|
bne ?left
|
||||||
lda actor_yfrac,x
|
lda actor_yfrac,x
|
||||||
clc
|
clc
|
||||||
adc actor_yspeed,x
|
adc actor_yspeed_l,x
|
||||||
sta actor_yfrac,x
|
sta actor_yfrac,x
|
||||||
bcc ?ret
|
lda actor_ypixel,x
|
||||||
inc actor_ypixel,x
|
adc actor_yspeed_h,x
|
||||||
|
sta actor_ypixel,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; elif current & TILE_LEFT:
|
; elif current & TILE_LEFT:
|
||||||
|
@ -349,10 +427,11 @@ pixel_move nop
|
||||||
bne ?right
|
bne ?right
|
||||||
lda actor_xfrac,x
|
lda actor_xfrac,x
|
||||||
sec
|
sec
|
||||||
sbc actor_xspeed,x
|
sbc actor_xspeed_l,x
|
||||||
sta actor_xfrac,x
|
sta actor_xfrac,x
|
||||||
bcs ?ret
|
lda actor_xpixel,x
|
||||||
dec actor_xpixel,x
|
sbc actor_xspeed_h,x
|
||||||
|
sta actor_xpixel,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; elif current & TILE_RIGHT:
|
; elif current & TILE_RIGHT:
|
||||||
|
@ -364,10 +443,11 @@ pixel_move nop
|
||||||
bne ?ret
|
bne ?ret
|
||||||
lda actor_xfrac,x
|
lda actor_xfrac,x
|
||||||
clc
|
clc
|
||||||
adc actor_xspeed,x
|
adc actor_xspeed_l,x
|
||||||
sta actor_xfrac,x
|
sta actor_xfrac,x
|
||||||
bcc ?ret
|
lda actor_xpixel,x
|
||||||
inc actor_xpixel,x
|
adc actor_xspeed_h,x
|
||||||
|
sta actor_xpixel,x
|
||||||
?ret rts
|
?ret rts
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,16 +464,22 @@ set_speed nop
|
||||||
and #TILE_VERT
|
and #TILE_VERT
|
||||||
beq ?1
|
beq ?1
|
||||||
lda #0
|
lda #0
|
||||||
sta actor_xspeed,x
|
sta actor_xspeed_l,x
|
||||||
|
sta actor_xspeed_h,x
|
||||||
ldy level
|
ldy level
|
||||||
lda level_speeds,y
|
lda level_speed_l,y
|
||||||
sta actor_yspeed,x
|
sta actor_yspeed_l,x
|
||||||
|
lda level_speed_h,y
|
||||||
|
sta actor_yspeed_h,x
|
||||||
rts
|
rts
|
||||||
?1 lda #0
|
?1 lda #0
|
||||||
sta actor_yspeed,x
|
sta actor_yspeed_l,x
|
||||||
|
sta actor_yspeed_h,x
|
||||||
ldy level
|
ldy level
|
||||||
lda level_speeds,y
|
lda level_speed_l,y
|
||||||
sta actor_xspeed,x
|
sta actor_xspeed_l,x
|
||||||
|
lda level_speed_h,y
|
||||||
|
sta actor_xspeed_h,x
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,10 +523,24 @@ decide_orbiter nop
|
||||||
beq ?lr
|
beq ?lr
|
||||||
lda allowed
|
lda allowed
|
||||||
and #TILE_HORZ
|
and #TILE_HORZ
|
||||||
bne ?set
|
beq ?lr
|
||||||
|
|
||||||
|
sta actor_dir,x
|
||||||
|
; horizontal direction allowed; reset vertical subpixel to be right in the middle
|
||||||
|
lda #Y_MIDPOINT
|
||||||
|
sta actor_ypixel,x
|
||||||
|
lda #0
|
||||||
|
sta actor_yfrac,x
|
||||||
|
jmp set_speed
|
||||||
|
|
||||||
?lr lda allowed
|
?lr lda allowed
|
||||||
and #TILE_VERT
|
and #TILE_VERT
|
||||||
?set sta actor_dir,x
|
sta actor_dir,x
|
||||||
|
; vertial direction allowed; reset horizontal subpixel to be right in the middle
|
||||||
|
lda #X_MIDPOINT
|
||||||
|
sta actor_xpixel,x
|
||||||
|
lda #0
|
||||||
|
sta actor_xfrac,x
|
||||||
jmp set_speed
|
jmp set_speed
|
||||||
|
|
||||||
|
|
||||||
|
|
2
maze.s
2
maze.s
|
@ -58,7 +58,7 @@ SCREEN_COLS = 40
|
||||||
|
|
||||||
;# Orbiter goes around the outside border, but not through the maze
|
;# Orbiter goes around the outside border, but not through the maze
|
||||||
ORBITER_START_COL = MAZE_RIGHT_COL
|
ORBITER_START_COL = MAZE_RIGHT_COL
|
||||||
ORBITER_START_ROW = (MAZE_TOP_ROW + MAZE_BOT_ROW) / 2
|
ORBITER_START_ROW = 2
|
||||||
|
|
||||||
;# Returns address of tile in col 0 of row y
|
;# Returns address of tile in col 0 of row y
|
||||||
;def mazerow(y):
|
;def mazerow(y):
|
||||||
|
|
6
vars.s
6
vars.s
|
@ -6,10 +6,12 @@ actor_row .ds MAX_ACTORS ; # current tile row
|
||||||
actor_y .ds MAX_ACTORS
|
actor_y .ds MAX_ACTORS
|
||||||
actor_xpixel .ds MAX_ACTORS ; # current pixel offset in col
|
actor_xpixel .ds MAX_ACTORS ; # current pixel offset in col
|
||||||
actor_xfrac .ds MAX_ACTORS ; # current fractional pixel
|
actor_xfrac .ds MAX_ACTORS ; # current fractional pixel
|
||||||
actor_xspeed .ds MAX_ACTORS ; # current speed (affects fractional)
|
actor_xspeed_l .ds MAX_ACTORS ; # current speed (affects fractional)
|
||||||
|
actor_xspeed_h .ds MAX_ACTORS ; # current speed (affects pixel)
|
||||||
actor_ypixel .ds MAX_ACTORS ; # current pixel offset in row
|
actor_ypixel .ds MAX_ACTORS ; # current pixel offset in row
|
||||||
actor_yfrac .ds MAX_ACTORS ; # current fractional pixel
|
actor_yfrac .ds MAX_ACTORS ; # current fractional pixel
|
||||||
actor_yspeed .ds MAX_ACTORS ; # current speed (affects fractional)
|
actor_yspeed_l .ds MAX_ACTORS ; # current speed (affects fractional)
|
||||||
|
actor_yspeed_h .ds MAX_ACTORS ; # current speed (affects pixel)
|
||||||
actor_updown .ds MAX_ACTORS ; # preferred direction
|
actor_updown .ds MAX_ACTORS ; # preferred direction
|
||||||
actor_dir .ds MAX_ACTORS ; # actual direction
|
actor_dir .ds MAX_ACTORS ; # actual direction
|
||||||
actor_target_col .ds MAX_ACTORS ; # target column at bot or top T
|
actor_target_col .ds MAX_ACTORS ; # target column at bot or top T
|
||||||
|
|
|
@ -100,6 +100,10 @@ round_robin_index .ds 2
|
||||||
level .ds 1
|
level .ds 1
|
||||||
last_enemy .ds 1
|
last_enemy .ds 1
|
||||||
|
|
||||||
|
* = $0070
|
||||||
|
before .ds 1
|
||||||
|
crossed .ds 1
|
||||||
|
|
||||||
|
|
||||||
; memory map
|
; memory map
|
||||||
; BF00 - BFFF: damage for page 1
|
; BF00 - BFFF: damage for page 1
|
||||||
|
@ -211,8 +215,6 @@ game_loop nop
|
||||||
inc frame_count+1
|
inc frame_count+1
|
||||||
?1 jsr userinput
|
?1 jsr userinput
|
||||||
|
|
||||||
jsr debug_player
|
|
||||||
|
|
||||||
lda config_quit
|
lda config_quit
|
||||||
beq ?2
|
beq ?2
|
||||||
rts
|
rts
|
||||||
|
@ -255,6 +257,7 @@ game_loop nop
|
||||||
jsr paint_boxes
|
jsr paint_boxes
|
||||||
jsr renderstart
|
jsr renderstart
|
||||||
jsr pageflip
|
jsr pageflip
|
||||||
|
jsr debug_player
|
||||||
jsr wait
|
jsr wait
|
||||||
jmp game_loop
|
jmp game_loop
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user