From 0b13ce175eed15ac419c72e110fcb6de1f080eb3 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 3 Jun 2020 16:43:21 +0200 Subject: [PATCH] added helper marks for head align tool, use CIA for stable timing --- c64/,,config_custom.s | 8 +- c64/kernal/init/fda3.ioinit.s | 12 +- c64/kernal/tape/tape_head_align.s | 135 +++++++++++++++++--- c64/kernal/tape/tape_head_align_get_pulse.s | 14 +- 4 files changed, 129 insertions(+), 40 deletions(-) diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index bb93e633..d98e0103 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -46,10 +46,10 @@ // I/O devices #define CONFIG_IEC -//#define CONFIG_IEC_DOLPHINDOS -//#define CONFIG_IEC_DOLPHINDOS_FAST -//#define CONFIG_IEC_JIFFYDOS -//#define CONFIG_IEC_JIFFYDOS_BLANK +#define CONFIG_IEC_DOLPHINDOS +#define CONFIG_IEC_DOLPHINDOS_FAST +#define CONFIG_IEC_JIFFYDOS +#define CONFIG_IEC_JIFFYDOS_BLANK // #define CONFIG_IEC_BURST_CIA1 // please keep disabled for now // #define CONFIG_IEC_BURST_CIA2 // please keep disabled for now // #define CONFIG_IEC_BURST_SOFT // please keep disabled for now diff --git a/c64/kernal/init/fda3.ioinit.s b/c64/kernal/init/fda3.ioinit.s index 9e67a661..f6398b4d 100644 --- a/c64/kernal/init/fda3.ioinit.s +++ b/c64/kernal/init/fda3.ioinit.s @@ -138,26 +138,26 @@ IOINIT: // Checked using VICE that original ROM initializes timers this way ldx #$08 - stx CIA1_CRB // $DC0F - stx CIA2_CRA // $DD0E - stx CIA2_CRB // $DD0F + stx CIA1_CRB // $DC0F + stx CIA2_CRA // $DD0E + stx CIA2_CRB // $DD0F // Set VIC-II bank - at least the 'Operacja Proboszcz' game needs this within IOINIT // Checked on original ROMs, that it sets bit #2 (RS-232 output) high ldx #%00000111 // XXX adapt this to IEC idle state, JMP at the end won't be needed - stx CIA2_PRA // $DD00 + stx CIA2_PRA // $DD00 // Put something sane in the IRQ timer jsr setup_irq_timer // Enable timer A to run continuously (http://codebase64.org/doku.php?id=base:timerinterrupts) ldx #$11 - stx CIA1_CRA // $DC0E + stx CIA1_CRA // $DC0E // Enable timer interrupt ldx #$81 - stx CIA1_ICR // $DC0D + stx CIA1_ICR // $DC0D #if CONFIG_IEC diff --git a/c64/kernal/tape/tape_head_align.s b/c64/kernal/tape/tape_head_align.s index a669a2a1..53e46861 100644 --- a/c64/kernal/tape/tape_head_align.s +++ b/c64/kernal/tape/tape_head_align.s @@ -11,8 +11,8 @@ #if CONFIG_TAPE_HEAD_ALIGN -.label __ha_start = 3 // starting row of the chart -.label __ha_rows = 20 // number of rows for scrolling +.label __ha_start = 12 // starting row of the chart +.label __ha_rows = 10 // number of rows for scrolling // Helper tables @@ -23,7 +23,7 @@ .label __ha_lda_addr = $1200; // 2 bytes, for code generator .label __ha_sta_addr = $1202; // 2 bytes, for code generator -.label __ha_counter = $1204; // 3 bytes +.label __ha_gfxflag = $1204; // Generated code location @@ -50,6 +50,10 @@ tape_head_align: ldx #$02 // set timer A to 3 ticks jsr tape_common_prepare_cia_by_x + ldx #$FF // timer to control scroll speed + stx CIA1_TIMBLO // $DC06 + stx CIA1_TIMBHI // $DC07 + jsr tape_motor_on // Clear color data ($0800) @@ -69,9 +73,10 @@ tape_head_align: // Make sure the row where the chart is being created is not visible lda #(CONFIG_COLOR_BG * $10 + CONFIG_COLOR_BG) - ldy #$28 + ldy #$22 !: - sta $0800 + __ha_start * 40 - 1, y + sta $0800 + __ha_start * 40 + 2, y + // sta $0800 + __ha_start * 40 + 2 + (__ha_rows + 1) * 40, y dey bne !- @@ -128,14 +133,34 @@ tape_head_align: inx bne !-- - // Generate helpercode for screen scrolling + // Initialize flag for additional GFX effects + + stx __ha_gfxflag + + // Generate helper code for screen scrolling jsr tape_head_align_gen_code + // Scroll several times to fill-in the screen + + ldx #(__ha_rows * 8) +!: + phx_trash_a + jsr tape_head_align_scroll_gfx + plx_trash_a + + dex + bne !- + tape_head_align_loop_1: // XXX check for STOP key, possibly terminate + // Launch the timer + + ldx #%00011001 // start timer, one-shot force latch reload, count system ticks + stx CIA1_CRB // $DC0F + // Scroll the whole chart one line down ldx #$00 @@ -148,15 +173,9 @@ tape_head_align_loop_1: tax bne !- - // XXX draw helper lines + // Draw helpers and decorators - // Initialize counter - - lda #$80 - sta __ha_counter + 1 - lda #$00 - sta __ha_counter + 0 - sta __ha_counter + 2 + jsr tape_head_align_apply_gfx // Skip 2 pulses, these measurements will be too imprecise @@ -186,9 +205,12 @@ tape_head_align_loop_2: tape_head_align_drawn: - lda __ha_counter + 2 - beq tape_head_align_loop_2 - bne tape_head_align_loop_1 + lda CIA1_TIMBLO + and CIA1_TIMBHI + eor #$FF + + bne tape_head_align_loop_2 + beq tape_head_align_loop_1 tape_head_align_quit: @@ -201,6 +223,85 @@ tape_head_align_quit: cli rts // XXX perform new after quit + + + +// XXX size-optimize code below + +tape_head_align_scroll_gfx: + + ldx #(8 * 0) + jsr __ha_scroll + ldx #(8 * 1) + jsr __ha_scroll + ldx #(8 * 6) + jsr __ha_scroll + ldx #(8 * 13) + jsr __ha_scroll + ldx #(8 * 21) + jsr __ha_scroll + ldx #(8 * 30) + jsr __ha_scroll + ldx #(8 * 31) + jsr __ha_scroll + + // FALLTROUGH + +tape_head_align_apply_gfx: + + // Apply GFX effects XXX improve it + + lda __ha_gfxflag + inc __ha_gfxflag + and #%00001100 + bne !+ + ldy #%11110001 + lda #%10001111 + bne !++ +!: + ldy #%00000001 + lda #%10000000 +!: + ora __ha_chart + 7 + 8 * 0 + sta __ha_chart + 7 + 8 * 0 + + tya + ora __ha_chart + 7 + 8 * 31 + sta __ha_chart + 7 + 8 * 31 + + // Draw helper lines + + lda __ha_gfxflag + and #%00000010 + beq !+ + + lda #%00010000 + ora __ha_chart + 7 + 8 * 1 + sta __ha_chart + 7 + 8 * 1 + + lda #%00001000 + ora __ha_chart + 7 + 8 * 30 + sta __ha_chart + 7 + 8 * 30 + + // For normal XXX check values + + lda #%00000100 + ora __ha_chart + 7 + 8 * 6 + sta __ha_chart + 7 + 8 * 6 + + lda #%00010000 + ora __ha_chart + 7 + 8 * 13 + sta __ha_chart + 7 + 8 * 13 + + // For turbo XXX check values + + lda #%01000000 + ora __ha_chart + 7 + 8 * 21 + sta __ha_chart + 7 + 8 * 21 +!: + rts + + #endif // ROM layout diff --git a/c64/kernal/tape/tape_head_align_get_pulse.s b/c64/kernal/tape/tape_head_align_get_pulse.s index 15739ef9..03d04d7c 100644 --- a/c64/kernal/tape/tape_head_align_get_pulse.s +++ b/c64/kernal/tape/tape_head_align_get_pulse.s @@ -12,10 +12,9 @@ tape_head_align_get_pulse: - // This routine differs a lot from the one used to read pulse during tape reading: + // This routine differs from the one used to read pulse during tape reading: // - it is not as precise // - it terminates when timer reaches $FF - // - it updates lda #$10 !: @@ -33,17 +32,6 @@ tape_head_align_get_pulse: ldx #%01010001 stx CIA2_CRB // $DD0F - // Update time counter - - tya - clc - adc __ha_counter + 0 - sta __ha_counter + 0 - bcc !+ - inc __ha_counter + 1 - bne !+ - inc __ha_counter + 2 -!: // Return with time elapsed tya