fixed distrubances in head align tool

This commit is contained in:
FeralChild64 committed 2020-06-04 15:41:04 +02:00
1 parent 023a21c3ef
commit cefa6ec1fb
5 files changed
+147 -102

No files matched your search

+26 -92
View File
@@ -12,6 +12,13 @@
// XXX for Mega65 it can be done more easily, by just disabling the badlines
// XXX consider "PRESS PLAY ON TAPE" before start, with option to stop
// XXX add some text explaining what tool it is ('head align chart', or something similar)
// XXX make tape wedge (and this tool) available also without tape turbo support
// XXX create separate configuration for tape users
// XXX block NMIs
// XXX fix Mega65 build compilation issues
.label __ha_start = 11 // starting row of the chart
.label __ha_rows = 10 // number of rows for scrolling
@@ -25,9 +32,9 @@
.label __ha_lda_addr = $1200; // 2 bytes, for code generator
.label __ha_sta_addr = $1202; // 2 bytes, for code generator
.label __ha_pulses = $1204; // 16 bytes
.label __ha_gfxflag = $1214; // 1 byte
.label __ha_loopcnt = $1215; // 1 byte
.label __ha_pulses = $1204; // 64 bytes
.label __ha_gfxflag = $1244; // 1 byte
.label __ha_loopcnt = $1245; // 1 byte
// Generated code location
@@ -75,16 +82,6 @@ tape_head_align:
iny
bne !-
// Make sure the row where the chart is being created is not visible
lda #(CONFIG_COLOR_TXT * $10 + CONFIG_COLOR_TXT)
ldy #$24
!:
sta $0800 + __ha_start * 40 + 1, y
sta $0800 + __ha_start * 40 + 1 + (__ha_rows + 1) * 40, y
dey
bne !-
// Clear bitmap data ($2000)
lda #$20
@@ -101,6 +98,19 @@ tape_head_align:
cpx #$40
bne !-
// Make sure the row where the chart is being created is not visible
lda #(CONFIG_COLOR_TXT * $10 + CONFIG_COLOR_TXT)
ldy #$24
!:
sta $0800 + __ha_start * 40 + 1, y
sta $0800 + __ha_start * 40 + 1 + (__ha_rows + 1) * 40, y
dey
bne !-
// Set graphics mode
lda #$28 // graphics start at $2000, color at $0800
@@ -141,7 +151,7 @@ tape_head_align:
// Initialize flag for additional GFX effects and the pulse lengths
lda #$00
ldx #$10
ldx #$40
!:
sta __ha_pulses, x
dex
@@ -166,7 +176,7 @@ tape_head_align:
and VIC_SCROLY // clear the highest bit of RASTER
sta VIC_SCROLY // $D011
lda #$FF // setup interrupt on line 255, near no-badline area
lda #$F3 // the last raster where badline can occur, this is 100% safe start
sta VIC_RASTER
lda #%00000001 // enable raster interrupts
@@ -225,7 +235,7 @@ tape_head_align_loop_2:
ldx __ha_loopcnt
inx
cpx #$10
cpx #$40
bne !-
// FALLTROUGH
@@ -257,82 +267,6 @@ tape_head_align_quit:
jmp hw_entry_reset
tape_head_align_draw_pulse:
// Put pulse on the screen; center the chart horizontaly, with some margin from top
.label __ha_chart = $2000 + 8 * (40 * __ha_start + 4)
tax
lda __ha_offsets, x
tay
lda __ha_masks, x
ora __ha_chart + 7, y
sta __ha_chart + 7, y
!:
rts
tape_head_align_apply_gfx:
// Apply GFX effects
lda __ha_gfxflag
inc __ha_gfxflag
clc
adc #$08
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
@@ -0,0 +1,70 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape head alignemnt tool - draw helper symbols
//
#if CONFIG_TAPE_HEAD_ALIGN
tape_head_align_apply_gfx:
// Apply GFX effects
lda __ha_gfxflag
inc __ha_gfxflag
clc
adc #$08
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
lda #%00000001
ora __ha_chart + 7 + 8 * 6
sta __ha_chart + 7 + 8 * 6
lda #%00000001
ora __ha_chart + 7 + 8 * 13
sta __ha_chart + 7 + 8 * 13
// For turbo
lda #%00010000
ora __ha_chart + 7 + 8 * 21
sta __ha_chart + 7 + 8 * 21
!:
rts
#endif
@@ -0,0 +1,29 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape head alignemnt tool - draw pulses
//
#if CONFIG_TAPE_HEAD_ALIGN
tape_head_align_draw_pulse:
// Put pulse on the screen; center the chart horizontaly, with some margin from top
.label __ha_chart = $2000 + 8 * (40 * __ha_start + 4)
tax
lda __ha_offsets, x
tay
lda __ha_masks, x
ora __ha_chart + 7, y
sta __ha_chart + 7, y
!:
rts
#endif
+2 -2
View File
@@ -3,7 +3,7 @@
// #LAYOUT# * * #IGNORE
//
// Tape head alignemnt tool - helper routine for reading pulses
// Tape head alignemnt tool - reading pulses from tape
//
@@ -15,7 +15,7 @@ tape_head_align_get_pulse:
// This routine differs from the one used to read pulse during tape reading:
// - it is not as precise
// - it terminates when timer reaches $FF
// - ir returns value in .Y
// - it returns value in .Y
lda #$10
!:
+20 -8
View File
@@ -12,8 +12,6 @@
tape_head_align_irq:
// inc $d020 // XXX for debug only
// Acknowledge interrupt
asl VIC_IRQ
@@ -21,7 +19,7 @@ tape_head_align_irq:
// Clear table of pulses stored
lda #$FF
ldy #$0F
ldy #$3F
!:
sta __ha_pulses, y
dey
@@ -32,21 +30,35 @@ tape_head_align_irq:
jsr tape_head_align_get_pulse
jsr tape_head_align_get_pulse
// Now, we can retrieve a pulse for real
// Now, we can retrieve a pulse for the charts
ldx #$00
!:
jsr tape_head_align_get_pulse
// If we approached badlines again - we cannot use this measurement anymore
lda VIC_SCROLY
bmi !+ // branch if lower border
lda VIC_RASTER
cmp #$33 // first line where badline can occur
bcs tape_head_align_irq_end
!:
// Store measurement
tya
sta __ha_pulses, x
// XXX terminate ion case VIC_RASTER went too far
// Next iteration
inx
cpx #$10
bne !-
cpx #$40
bne !--
// dec $d020 // XXX for debug only
// FALLTROUGH
tape_head_align_irq_end:
jmp return_from_interrupt