From bb66cfef4e2d1a099dc78ac70fb087acc5975866 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 8 Oct 2018 12:20:09 -0400 Subject: [PATCH] space_bars: add timing code --- space_bars/game.s | 54 ++++++++++++++++++++++++++++++----------- space_bars/space_bars.s | 2 ++ 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/space_bars/game.s b/space_bars/game.s index 63dc60f3..02f9af0f 100644 --- a/space_bars/game.s +++ b/space_bars/game.s @@ -14,6 +14,9 @@ game: lda #38 sta YPOS + lda #0 + sta FRAMEH + ;============================= ; Load graphic hgr @@ -289,28 +292,43 @@ sbloopF:dex ; 2 ; do_nothing should be 4550 ; -3470 draw_framebuffer - ; -193 setup framebuffer + ; -418 setup framebuffer + ; -21 frame count ; -34 keypress ; -1 adjust center mark back ; =========== - ; 852 + ; 606 - ; Try X=6 Y=29 cycles=1045 - ; Try X=20 Y=8 cycles=849 R3 + ; Try X=23 Y=5 cycles=606 - lda $0 - - ldy #8 ; 2 -sbloop1:ldx #20 ; 2 + ldy #5 ; 2 +sbloop1:ldx #23 ; 2 sbloop2:dex ; 2 bne sbloop2 ; 2nt/3 dey ; 2 bne sbloop1 ; 2nt/3 - jsr setup_framebuffer ; 6+187 + jsr setup_framebuffer ; 6+412 jsr draw_framebuffer ; 6+3464 + ; Increment frame count + ; noflo: 16 + 2 + (3) = 21 + ; oflo: 16 + 5 = 21 + inc FRAME ; 5 + lda FRAME ; 3 + and #3 ; 15 Hz ; 2 + sta FRAME ; 3 + beq sb_frame_oflo ; 3 + ;============ + ; 16 + ; -1 + lda $0 ; nop ; 3 + jmp sb_frame_noflo ; 3 +sb_frame_oflo: + inc FRAMEH ; 5 +sb_frame_noflo: + ; no keypress = 10+(24) = 34 ; left pressed = 9+8+12+(5)= 34 @@ -499,18 +517,26 @@ raster_texture: .byte $0,$0,$0,$0,$0,$0,$0,$0 - ; 2 + 15*12 + 5 = 187 + ; 4 + 31*13 + 5 = 412 setup_framebuffer: ldx #0 ; 2 + ldy #0 ; 2 setup_fb_loop: - lda raster_texture,x ; 4 - sta FRAMEBUFFER,x ; 4 + lda raster_texture+1,y ; 4 + asl ; 2 + asl ; 2 + asl ; 2 + asl ; 2 + ora raster_texture,y ; 4 + sta FRAMEBUFFER,x ; zp ; 4 + iny ; 2 + iny ; 2 inx ; 2 - cpx #12 ; 2 + cpx #13 ; 2 bne setup_fb_loop ; 3 ;=========== - ; 15 + ; 31 ; -1 rts ; 6 diff --git a/space_bars/space_bars.s b/space_bars/space_bars.s index 9c938426..8128fea0 100644 --- a/space_bars/space_bars.s +++ b/space_bars/space_bars.s @@ -26,7 +26,9 @@ BASH = $29 MASK = $2E COLOR = $30 FRAME = $60 +FRAMEH = $61 BLARGH = $69 +ZPOS = $78 DRAW_PAGE = $EE LASTKEY = $F1 PADDLE_STATUS = $F2