autogenerated scrolling code for head align tool

This commit is contained in:
FeralChild64 committed 2020-06-02 23:06:13 +02:00
1 parent 175465f6c7
commit db9d6e7b60
13 files changed
+241 -311

No files matched your search

+4 -4
View File
@@ -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
+16
View File
@@ -344,6 +344,22 @@
}
// Setup colors
#if CONFIG_COLORS_BRAND && CONFIG_BRAND_ULTIMATE_64
.const CONFIG_COLOR_BG = $00
.const CONFIG_COLOR_TXT = $01
#else
.const CONFIG_COLOR_BG = $06
.const CONFIG_COLOR_TXT = $01
#endif
// Function for printing out build features
.var feature_new_line = false
+2
View File
@@ -54,3 +54,5 @@
#if CONFIG_TAPE_HEAD_ALIGN
.label tape_head_align = KERNAL().tape_head_align
#endif
.label filename_any = KERNAL().filename_any
+2 -6
View File
@@ -27,15 +27,11 @@ cmd_load:
// Try to load the first file from disk
lda #$01 // name length
ldx #<cmd_load_default_filename
ldy #>cmd_load_default_filename
ldx #<filename_any
ldy #>filename_any
jsr JSETNAM
jmp got_filename
cmd_load_default_filename:
.text "*"
cmd_load_fetch_filename:
jsr basic_fetch_and_consume_character
+8
View File
@@ -0,0 +1,8 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
filename_any:
.text "*"
+1 -1
View File
@@ -60,7 +60,7 @@ cint_screen_keyboard:
#endif
// Set current colour for text (Computes Mapping the 64 p215)
ldx #$01 // default is light blue ($0E), but we use a different one
ldx #CONFIG_COLOR_TXT
stx COLOR
// Set maximum keyboard buffer size (Computes Mapping the 64 p215)
+1 -11
View File
@@ -60,20 +60,10 @@ setup_vicii:
// We use a different colour scheme of white text on all blue by default,
// but brand-specific color scheme can also be enabled
#if CONFIG_COLORS_BRAND && CONFIG_BRAND_ULTIMATE_64
lda #$00
lda #CONFIG_COLOR_BG
sta VIC_EXTCOL
sta VIC_BGCOL0
#else
lda #$06
sta VIC_EXTCOL
sta VIC_BGCOL0
#endif
// Setup default I/O devices
jmp clrchn_reset
-1
View File
@@ -45,7 +45,6 @@ load_tape_normal:
// Start playing
jsr tape_common_prepare_cia
jsr tape_ask_play
jsr tape_prepare_reading
// FALLTROUGH
-1
View File
@@ -32,7 +32,6 @@ load_tape_auto:
// Start playing
jsr tape_common_prepare_cia
jsr tape_ask_play
jsr tape_prepare_reading
// FALLTROUGH
-9
View File
@@ -104,15 +104,6 @@ tape_wait_first_pulse:
tape_wait_play_done:
rts
//
// Prepare screen / tape motor for reading
//
tape_prepare_reading:
#if CONFIG_MB_MEGA_65
// Display confirmation
+23 -278
View File
@@ -1,11 +1,10 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape (normal) helper routine - reading speed calibration
//
// Needs pulse length in .A
// Tape head alignemnt tool
//
@@ -13,6 +12,7 @@
.label __ha_start = 3 // starting row of the chart
.label __ha_rows = 20 // number of rows for scrolling
// Helper tables
@@ -21,7 +21,13 @@
// Helper variables
.label __ha_counter = $1200; // 3 bytes
.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
// Generated code location
.label __ha_scroll = $1300;
tape_head_align:
@@ -34,24 +40,23 @@ tape_head_align:
#else
// Start by asking for playback
// XXX jsr tape_ask_play
// Disable interrupts, set proper I/O values
sei
jsr CLALL
jsr IOINIT
jsr cint_legacy
jsr tape_motor_on
ldx #$02 // set timer A to 3 ticks
jsr tape_common_prepare_cia_by_x
jsr tape_motor_on
// Clear color data ($0800)
ldy #$00
!:
lda #($01 * $10 + $06) // XXX synchronize colors with setup_vicii
lda #(CONFIG_COLOR_TXT * $10 + CONFIG_COLOR_BG)
sta $0800, y
sta $0900, y
@@ -61,9 +66,9 @@ tape_head_align:
iny
bne !-
// Make sure the row where the chart is created is not visible
// Make sure the row where the chart is being created is not visible
lda #($06 * $10 + $06) // XXX synchronize colors with setup_vicii
lda #(CONFIG_COLOR_BG * $10 + CONFIG_COLOR_BG)
ldy #$28
!:
sta $0800 + __ha_start * 40 - 1, y
@@ -88,7 +93,7 @@ tape_head_align:
// Set graphics mode
lda #$28 // graphic memory start at $2000, color at $0800
lda #$28 // graphics start at $2000, color at $0800
sta VIC_YMCSB
lda #$3B // set bit 5 to enable graphic mode
@@ -123,6 +128,10 @@ tape_head_align:
inx
bne !--
// Generate helpercode for screen scrolling
jsr tape_head_align_gen_code
tape_head_align_loop_1:
// XXX check for STOP key, possibly terminate
@@ -131,7 +140,7 @@ tape_head_align_loop_1:
ldx #$00
!:
jsr tape_head_align_scroll_column
jsr __ha_scroll // scroll one column down, using fast generated code
txa
clc
@@ -192,270 +201,6 @@ tape_head_align_quit:
cli
rts // XXX perform new after quit
tape_head_align_get_pulse:
// This routine differs a lot 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
!:
// Loop to detect signal
ldy CIA2_TIMBLO // $DD06
bit CIA1_ICR // $DC0D
bne !+
cpy #$FF
bne !-
!:
// Start timer again, force latch reload, count timer A underflows
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
rts
tape_head_align_scroll_column:
// XXX autogenerate this code somewhere
lda __ha_chart + 9 * (8 * 40) + 6, x
sta __ha_chart + 9 * (8 * 40) + 7, x
lda __ha_chart + 9 * (8 * 40) + 5, x
sta __ha_chart + 9 * (8 * 40) + 6, x
lda __ha_chart + 9 * (8 * 40) + 4, x
sta __ha_chart + 9 * (8 * 40) + 5, x
lda __ha_chart + 9 * (8 * 40) + 3, x
sta __ha_chart + 9 * (8 * 40) + 4, x
lda __ha_chart + 9 * (8 * 40) + 2, x
sta __ha_chart + 9 * (8 * 40) + 3, x
lda __ha_chart + 9 * (8 * 40) + 1, x
sta __ha_chart + 9 * (8 * 40) + 2, x
lda __ha_chart + 9 * (8 * 40) + 0, x
sta __ha_chart + 9 * (8 * 40) + 1, x
lda __ha_chart + 8 * (8 * 40) + 7, x
sta __ha_chart + 9 * (8 * 40) + 0, x
lda __ha_chart + 8 * (8 * 40) + 6, x
sta __ha_chart + 8 * (8 * 40) + 7, x
lda __ha_chart + 8 * (8 * 40) + 5, x
sta __ha_chart + 8 * (8 * 40) + 6, x
lda __ha_chart + 8 * (8 * 40) + 4, x
sta __ha_chart + 8 * (8 * 40) + 5, x
lda __ha_chart + 8 * (8 * 40) + 3, x
sta __ha_chart + 8 * (8 * 40) + 4, x
lda __ha_chart + 8 * (8 * 40) + 2, x
sta __ha_chart + 8 * (8 * 40) + 3, x
lda __ha_chart + 8 * (8 * 40) + 1, x
sta __ha_chart + 8 * (8 * 40) + 2, x
lda __ha_chart + 8 * (8 * 40) + 0, x
sta __ha_chart + 8 * (8 * 40) + 1, x
lda __ha_chart + 7 * (8 * 40) + 7, x
sta __ha_chart + 8 * (8 * 40) + 0, x
lda __ha_chart + 7 * (8 * 40) + 6, x
sta __ha_chart + 7 * (8 * 40) + 7, x
lda __ha_chart + 7 * (8 * 40) + 5, x
sta __ha_chart + 7 * (8 * 40) + 6, x
lda __ha_chart + 7 * (8 * 40) + 4, x
sta __ha_chart + 7 * (8 * 40) + 5, x
lda __ha_chart + 7 * (8 * 40) + 3, x
sta __ha_chart + 7 * (8 * 40) + 4, x
lda __ha_chart + 7 * (8 * 40) + 2, x
sta __ha_chart + 7 * (8 * 40) + 3, x
lda __ha_chart + 7 * (8 * 40) + 1, x
sta __ha_chart + 7 * (8 * 40) + 2, x
lda __ha_chart + 7 * (8 * 40) + 0, x
sta __ha_chart + 7 * (8 * 40) + 1, x
lda __ha_chart + 6 * (8 * 40) + 7, x
sta __ha_chart + 7 * (8 * 40) + 0, x
lda __ha_chart + 6 * (8 * 40) + 6, x
sta __ha_chart + 6 * (8 * 40) + 7, x
lda __ha_chart + 6 * (8 * 40) + 5, x
sta __ha_chart + 6 * (8 * 40) + 6, x
lda __ha_chart + 6 * (8 * 40) + 4, x
sta __ha_chart + 6 * (8 * 40) + 5, x
lda __ha_chart + 6 * (8 * 40) + 3, x
sta __ha_chart + 6 * (8 * 40) + 4, x
lda __ha_chart + 6 * (8 * 40) + 2, x
sta __ha_chart + 6 * (8 * 40) + 3, x
lda __ha_chart + 6 * (8 * 40) + 1, x
sta __ha_chart + 6 * (8 * 40) + 2, x
lda __ha_chart + 6 * (8 * 40) + 0, x
sta __ha_chart + 6 * (8 * 40) + 1, x
lda __ha_chart + 5 * (8 * 40) + 7, x
sta __ha_chart + 6 * (8 * 40) + 0, x
lda __ha_chart + 5 * (8 * 40) + 6, x
sta __ha_chart + 5 * (8 * 40) + 7, x
lda __ha_chart + 5 * (8 * 40) + 5, x
sta __ha_chart + 5 * (8 * 40) + 6, x
lda __ha_chart + 5 * (8 * 40) + 4, x
sta __ha_chart + 5 * (8 * 40) + 5, x
lda __ha_chart + 5 * (8 * 40) + 3, x
sta __ha_chart + 5 * (8 * 40) + 4, x
lda __ha_chart + 5 * (8 * 40) + 2, x
sta __ha_chart + 5 * (8 * 40) + 3, x
lda __ha_chart + 5 * (8 * 40) + 1, x
sta __ha_chart + 5 * (8 * 40) + 2, x
lda __ha_chart + 5 * (8 * 40) + 0, x
sta __ha_chart + 5 * (8 * 40) + 1, x
lda __ha_chart + 4 * (8 * 40) + 7, x
sta __ha_chart + 5 * (8 * 40) + 0, x
lda __ha_chart + 4 * (8 * 40) + 6, x
sta __ha_chart + 4 * (8 * 40) + 7, x
lda __ha_chart + 4 * (8 * 40) + 5, x
sta __ha_chart + 4 * (8 * 40) + 6, x
lda __ha_chart + 4 * (8 * 40) + 4, x
sta __ha_chart + 4 * (8 * 40) + 5, x
lda __ha_chart + 4 * (8 * 40) + 3, x
sta __ha_chart + 4 * (8 * 40) + 4, x
lda __ha_chart + 4 * (8 * 40) + 2, x
sta __ha_chart + 4 * (8 * 40) + 3, x
lda __ha_chart + 4 * (8 * 40) + 1, x
sta __ha_chart + 4 * (8 * 40) + 2, x
lda __ha_chart + 4 * (8 * 40) + 0, x
sta __ha_chart + 4 * (8 * 40) + 1, x
lda __ha_chart + 3 * (8 * 40) + 7, x
sta __ha_chart + 4 * (8 * 40) + 0, x
lda __ha_chart + 3 * (8 * 40) + 6, x
sta __ha_chart + 3 * (8 * 40) + 7, x
lda __ha_chart + 3 * (8 * 40) + 5, x
sta __ha_chart + 3 * (8 * 40) + 6, x
lda __ha_chart + 3 * (8 * 40) + 4, x
sta __ha_chart + 3 * (8 * 40) + 5, x
lda __ha_chart + 3 * (8 * 40) + 3, x
sta __ha_chart + 3 * (8 * 40) + 4, x
lda __ha_chart + 3 * (8 * 40) + 2, x
sta __ha_chart + 3 * (8 * 40) + 3, x
lda __ha_chart + 3 * (8 * 40) + 1, x
sta __ha_chart + 3 * (8 * 40) + 2, x
lda __ha_chart + 3 * (8 * 40) + 0, x
sta __ha_chart + 3 * (8 * 40) + 1, x
lda __ha_chart + 2 * (8 * 40) + 7, x
sta __ha_chart + 3 * (8 * 40) + 0, x
lda __ha_chart + 2 * (8 * 40) + 6, x
sta __ha_chart + 2 * (8 * 40) + 7, x
lda __ha_chart + 2 * (8 * 40) + 5, x
sta __ha_chart + 2 * (8 * 40) + 6, x
lda __ha_chart + 2 * (8 * 40) + 4, x
sta __ha_chart + 2 * (8 * 40) + 5, x
lda __ha_chart + 2 * (8 * 40) + 3, x
sta __ha_chart + 2 * (8 * 40) + 4, x
lda __ha_chart + 2 * (8 * 40) + 2, x
sta __ha_chart + 2 * (8 * 40) + 3, x
lda __ha_chart + 2 * (8 * 40) + 1, x
sta __ha_chart + 2 * (8 * 40) + 2, x
lda __ha_chart + 2 * (8 * 40) + 0, x
sta __ha_chart + 2 * (8 * 40) + 1, x
lda __ha_chart + 1 * (8 * 40) + 7, x
sta __ha_chart + 2 * (8 * 40) + 0, x
lda __ha_chart + 1 * (8 * 40) + 6, x
sta __ha_chart + 1 * (8 * 40) + 7, x
lda __ha_chart + 1 * (8 * 40) + 5, x
sta __ha_chart + 1 * (8 * 40) + 6, x
lda __ha_chart + 1 * (8 * 40) + 4, x
sta __ha_chart + 1 * (8 * 40) + 5, x
lda __ha_chart + 1 * (8 * 40) + 3, x
sta __ha_chart + 1 * (8 * 40) + 4, x
lda __ha_chart + 1 * (8 * 40) + 2, x
sta __ha_chart + 1 * (8 * 40) + 3, x
lda __ha_chart + 1 * (8 * 40) + 1, x
sta __ha_chart + 1 * (8 * 40) + 2, x
lda __ha_chart + 1 * (8 * 40) + 0, x
sta __ha_chart + 1 * (8 * 40) + 1, x
lda __ha_chart + 0 * (8 * 40) + 7, x
sta __ha_chart + 1 * (8 * 40) + 0, x
lda #$00
sta __ha_chart + 0 * (8 * 40) + 7, x
rts
#endif // ROM layout
+132
View File
@@ -0,0 +1,132 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape head alignemnt tool - helper code generator
//
#if CONFIG_TAPE_HEAD_ALIGN
tape_head_align_gen_code:
// Setup generated code start address
lda #<__ha_scroll
sta SAL+0
lda #>__ha_scroll
sta SAL+1
// Setup initial source and destination addresses
ldy #<(__ha_chart + __ha_rows * (8 * 40) + 6)
sty __ha_lda_addr + 0
iny
sty __ha_sta_addr + 0
ldy #>(__ha_chart + __ha_rows * (8 * 40) + 6)
sty __ha_lda_addr + 1
sty __ha_sta_addr + 1
// Emit code to move 7 rows of one 8x8 cell
!:
ldx #$07
!:
jsr tape_head_align_gen_code_emit_pair
dec __ha_lda_addr + 0
dec __ha_sta_addr + 0
dex
bne !-
// Emit code to fetch a top row from the cell above
inc __ha_lda_addr + 0
sec
lda __ha_lda_addr + 0
sbc #<(8 * 40 - 7)
sta __ha_lda_addr + 0
lda __ha_lda_addr + 1
sbc #>(8 * 40 - 7)
sta __ha_lda_addr + 1
jsr tape_head_align_gen_code_emit_pair
// Prepare addresses for the next iteration
lda __ha_lda_addr + 0
sta __ha_sta_addr + 0
lda __ha_lda_addr + 1
sta __ha_sta_addr + 1
dec __ha_lda_addr + 0
// Now, new iteration - if needed
lda __ha_sta_addr + 0
cmp #<(__ha_chart + 7)
bne !--
lda __ha_sta_addr + 1
cmp #>(__ha_chart + 7)
bne !--
// Last pair to be generated starts from LDA #$00
lda #$A9
jsr tape_head_align_gen_code_emit_byte
lda #$00
jsr tape_head_align_gen_code_emit_byte
jsr tape_head_align_gen_code_emit_sta
// Emit RTS and quit
lda #$60
jmp tape_head_align_gen_code_emit_byte
tape_head_align_gen_code_emit_pair:
lda #$BD // LDA absolute, x
jsr tape_head_align_gen_code_emit_byte
lda __ha_lda_addr + 0
jsr tape_head_align_gen_code_emit_byte
lda __ha_lda_addr + 1
jsr tape_head_align_gen_code_emit_byte
// FALLTROUGH
tape_head_align_gen_code_emit_sta:
lda #$9D // STA absolute, x
jsr tape_head_align_gen_code_emit_byte
lda __ha_sta_addr + 0
jsr tape_head_align_gen_code_emit_byte
lda __ha_sta_addr + 1
// FALLTROUGH
tape_head_align_gen_code_emit_byte:
ldy #$00
sta (SAL), y
#if HAS_OPCODES_65CE02
inw SAL
#else
inc SAL+0
bne !+
inc SAL+1
!:
#endif
rts
#endif // CONFIG_TAPE_HEAD_ALIGN
@@ -0,0 +1,52 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
//
// Tape head alignemnt tool - helper routine for reading pulses
//
#if CONFIG_TAPE_HEAD_ALIGN
tape_head_align_get_pulse:
// This routine differs a lot 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
!:
// Loop to detect signal
ldy CIA2_TIMBLO // $DD06
bit CIA1_ICR // $DC0D
bne !+
cpy #$FF
bne !-
!:
// Start timer again, force latch reload, count timer A underflows
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
rts
#endif // CONFIG_TAPE_HEAD_ALIGN