interlace: got vapor lock, but one cycle off....

This commit is contained in:
Vince Weaver 2019-09-13 00:59:51 -04:00
parent d42eee8c5c
commit fc275eecde
5 changed files with 128 additions and 23 deletions

View File

@ -7,11 +7,11 @@ PNG_TO_40x48D = ../gr-utils/png_to_40x48d
all: interlace.dsk
interlace.dsk: INTERLACE RASTERBARS SPRITES HELLO RASTERBARS_SOUND
interlace.dsk: INTERLACE RASTERBARS HELLO RASTERBARS_SOUND #SPRITES
$(DOS33) -y interlace.dsk SAVE A HELLO
$(DOS33) -y interlace.dsk BSAVE -a 0x1000 INTERLACE
$(DOS33) -y interlace.dsk BSAVE -a 0x1000 RASTERBARS
$(DOS33) -y interlace.dsk BSAVE -a 0x1000 SPRITES
# $(DOS33) -y interlace.dsk BSAVE -a 0x1000 SPRITES
$(DOS33) -y interlace.dsk BSAVE -a 0x1000 RASTERBARS_SOUND
####
@ -45,7 +45,7 @@ RASTERBARS_SOUND: rasterbars_sound.o
rasterbars_sound.o: rasterbars_sound.s gr_copy.s \
rasterbars_screen.s rasterbars_table.s movement_table.s rb_bg.inc \
pt3_lib_ci.s pt3_lib_init.s pt3_lib_mockingboard.s
pt3_lib_core.s pt3_lib_init.s pt3_lib_mockingboard.s pt3_write_frame.s
ca65 -o rasterbars_sound.o rasterbars_sound.s -l rasterbars_sound.lst

View File

@ -1466,7 +1466,7 @@ not_done:
; update pattern or line if necessary
; then calculate the values for the next frame
; 8+355=363
; 8+367=375
;==========================
; pattern done early!
@ -1558,13 +1558,15 @@ next_pattern:
.endif
;======================================
; do frame
;======================================
; ????? FIXME/calculate note
;
; 9+ 184 + 36+11+18+30+18+49 = 355
; 9+ 196 + 36+11+18+30+18+49 = 367
do_frame:
; AY-3-8910 register summary
@ -1586,13 +1588,13 @@ do_frame:
; 9
;;ldx #(NOTE_STRUCT_SIZE*0) ; Note A
jsr calculate_note ; 6+54
jsr calculate_note ; 6+58
ldx #(NOTE_STRUCT_SIZE*1) ; Note B ; 2
jsr calculate_note ; 6+54
jsr calculate_note ; 6+58
ldx #(NOTE_STRUCT_SIZE*2) ; Note C ; 2
jsr calculate_note ; 6+54
jsr calculate_note ; 6+58
;=============
; FIXME 184
; FIXME 196
; Note, we assume 1MHz timings, adjust pt3 as needed
@ -1675,8 +1677,8 @@ pt3_envelope_slide_h_smc:
;========================
; Envelope shape
; same=18
; diff=14+[4]
; same=11 + 7 = 18
; diff=11 + [4] + 3 = 18
pt3_envelope_type_smc:
lda #$d1 ; 2
@ -1684,6 +1686,8 @@ pt3_envelope_type_old_smc:
cmp #$d1 ; 2
sta pt3_envelope_type_old_smc+1; copy old to new ; 4
bne envelope_diff_waste ; 3
;============
; 11
envelope_same:
;-1
lda #$ff ; if same, store $ff ; 2
@ -1702,9 +1706,9 @@ envelope_diff:
;==============================
; if envelope delay 0, skip
; = 5+6 + [38] = 49
; = 5+ [38] + 6 = 49
; else if envelope delay 1, skip
; = 5+8+6 + [30] = 49
; = 5+8+[30] + 6 = 49
; else
; = 5+8+30+6 = 49
@ -1712,6 +1716,9 @@ pt3_envelope_delay_smc:
lda #$d1 ; 2
beq done_do_frame_x ; assume can't be negative? ; 3
; do this if envelope_delay>0
;====
; 5
; -1
dec pt3_envelope_delay_smc+1 ; 6
bne done_do_frame_y ; 3

View File

@ -0,0 +1,97 @@
.align $100
;====================================
; mb_write_frame
;====================================
; cycle counted
; 2 + 13*(70) + 74 + 5 = 991
mb_write_frame:
ldx #0 ; set up reg count ; 2
;============
; 2
;==================================
; loop through the 14 registers
; reading the value, then write out
;==================================
mb_write_loop:
;=============================
; not r13 -- 4+5+28+26+7 = 70
; r13, not ff -- 4+5+ 4 +28+26+7 = 74
; r13 is ff -- 4+5+3+1=[61] = 74
lda AY_REGISTERS,X ; load register value ; 4
; special case R13. If it is 0xff, then don't update
; otherwise might spuriously reset the envelope settings
cpx #13 ; 2
bne mb_not_13 ; 3
; -1
cmp #$ff ; 2
bne mb_not_13 ; 3
; -1
; delay 61
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
inc TEMP ; 5
lda TEMP ; 3
jmp mb_skip_13 ; 3
mb_not_13:
; address
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
ldy #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
sty MOCK_6522_ORB1 ; latch_address on PB1 ; 4
sty MOCK_6522_ORB2 ; latch_address on PB2 ; 4
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
;==========
; 28
; value
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
lda #MOCK_AY_WRITE ; ; 2
sta MOCK_6522_ORB1 ; write on PB1 ; 4
sta MOCK_6522_ORB2 ; write on PB2 ; 4
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
;===========
; 26
mb_no_write:
inx ; point to next register ; 2
cpx #14 ; if 14 we're done ; 2
bmi mb_write_loop ; otherwise, loop ; 3
;============
; 7
mb_skip_13:
; -1
rts ; 6
pt3_loop_smc:
.byte $0,$0

View File

@ -178,10 +178,10 @@ display_loop:
; -582 -- erase 22+4*(8+6+126) = 582
; -696 -- move+draw 4*(16+26+6+126) = 696
; -10 -- keypress
; -369 -- calc values
; -381 -- calc values
; -997 -- mockingboard out
;=======
; 1896
; 1884 2881 2265
pad_time:
@ -211,7 +211,7 @@ pad_time:
; erase yellow
lda yellow_x ; 4
lda yellow_x ; 4
and #$7f ; 2
tax ; 2
@ -354,7 +354,7 @@ pad_time:
;============================
jsr pt3_make_frame ; 6+363 = 369
jsr pt3_make_frame ; 6+375 = 381
jsr mb_write_frame ; 6+991 = 997
@ -362,12 +362,16 @@ pad_time:
; WAIT for VBLANK to finish
;============================
; Try X=125 Y=3 cycles=1894R2
; Try X=124 Y=3 cycles=1879R5
lda TEMP
nop
; Try X=2 Y=180 cycles=2881
; Try X=112 Y=4 cycles=2265
ldy #3 ; 2
loop1: ldx #125 ; 2
loop1: ldx #124 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
@ -460,10 +464,6 @@ smc_raster_color1_2:
.include "gr_offsets.s"
.include "gr_unrle.s"
; dummy value for pt3 routines
pt3_loop_smc:
.byte $00,$00
.align $100
.include "rasterbars_table.s"
.include "movement_table.s"
@ -484,6 +484,7 @@ blue_x: .byte $40
.include "pt3_lib_core.s"
.include "pt3_lib_init.s"
.include "pt3_lib_mockingboard.s"
.include "pt3_write_frame.s"
;=============
; include song