From e06046e82e58a29da3a908fb4d799affe382ef5e Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 2 Jun 2020 15:27:16 +0200 Subject: [PATCH] started work on integrated head align tool --- c64/,,config_custom.s | 5 +- c64/,,config_cx16.s | 1 + c64/,,config_generic.s | 1 + c64/,,config_mega65.s | 7 +- c64/,,config_testing.s | 1 + c64/,,config_ultimate64.s | 1 + c64/aliases/,aliases_config.s | 3 + c64/aliases/,aliases_hardware.s | 4 + c64/basic/,imports.s | 4 + c64/basic/commands/cmd_load.s | 23 +--- c64/basic/wedge_tape.s | 23 +++- .../board_m65/4000.mega65_vectable_kernal_1.s | 6 + c64/kernal/board_m65/mega65_proxies.s | 1 - ...ect_load_tape.s => mega65_redirect_tape.s} | 13 ++- c64/kernal/screen/e8ea.screen_scroll_up.s | 2 +- c64/kernal/screen/screen_calculate_pnt_user.s | 2 +- c64/kernal/tape/load_tape_normal.s | 1 + c64/kernal/tape/load_tape_turbo.s | 1 + c64/kernal/tape/tape_common.s | 9 ++ c64/kernal/tape/tape_head_align.s | 109 ++++++++++++++++++ 20 files changed, 187 insertions(+), 30 deletions(-) rename c64/kernal/board_m65/{mega65_redirect_load_tape.s => mega65_redirect_tape.s} (74%) create mode 100644 c64/kernal/tape/tape_head_align.s diff --git a/c64/,,config_custom.s b/c64/,,config_custom.s index d5983fcb..d98e0103 100644 --- a/c64/,,config_custom.s +++ b/c64/,,config_custom.s @@ -54,9 +54,9 @@ // #define CONFIG_IEC_BURST_CIA2 // please keep disabled for now // #define CONFIG_IEC_BURST_SOFT // please keep disabled for now -#define CONFIG_TAPE_NORMAL +// #define CONFIG_TAPE_NORMAL #define CONFIG_TAPE_TURBO -#define CONFIG_TAPE_AUTODETECT +// #define CONFIG_TAPE_AUTODETECT // #define CONFIG_TAPE_NO_KEY_SENSE // #define CONFIG_TAPE_NO_MOTOR_CONTROL // #define CONFIG_TAPE_NO_ERROR_CORRECTION @@ -124,6 +124,7 @@ #define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_TAPE_WEDGE +#define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/,,config_cx16.s b/c64/,,config_cx16.s index 828f0e73..cda04d71 100644 --- a/c64/,,config_cx16.s +++ b/c64/,,config_cx16.s @@ -117,6 +117,7 @@ // #define CONFIG_PANIC_SCREEN // #define CONFIG_DOS_WEDGE // #define CONFIG_TAPE_WEDGE +// #define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index b74339af..74cee7a8 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -115,6 +115,7 @@ #define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_TAPE_WEDGE +// #define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 60826470..a4089233 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -96,11 +96,11 @@ .const CONFIG_KEYCMD_HELP = @"LIST" -.const CONFIG_KEYCMD_F9 = @"REM F9" +.const CONFIG_KEYCMD_F9 = @"BOOT" .const CONFIG_KEYCMD_F10 = @"REM F10" -.const CONFIG_KEYCMD_F11 = @"REM F11" +.const CONFIG_KEYCMD_F11 = @"MONITOR" .const CONFIG_KEYCMD_F12 = @"REM F12" -.const CONFIG_KEYCMD_F13 = @"REM F13" +.const CONFIG_KEYCMD_F13 = @"\$5FH" .const CONFIG_KEYCMD_F14 = @"REM F14" @@ -115,6 +115,7 @@ #define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_TAPE_WEDGE +// #define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index d6743178..afe531bf 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -115,6 +115,7 @@ #define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_TAPE_WEDGE +// #define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 9cbd6819..707b1939 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -115,6 +115,7 @@ #define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_TAPE_WEDGE +// #define CONFIG_TAPE_HEAD_ALIGN // XXX work in progress #define CONFIG_BCD_SAFE_INTERRUPTS diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index ebf44ae2..7dbc16f9 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -298,6 +298,9 @@ #if CONFIG_TAPE_WEDGE && !CONFIG_TAPE_TURBO .error "CONFIG_TAPE_WEDGE requires CONFIG_TAPE_TURBO" #endif +#if !CONFIG_TAPE_WEDGE && CONFIG_TAPE_HEAD_ALIGN + .error "CONFIG_TAPE_HEAD_ALIGN requires CONFIG_TAPE_WEDGE" +#endif } diff --git a/c64/aliases/,aliases_hardware.s b/c64/aliases/,aliases_hardware.s index bdd0f5e5..74e8b6d3 100644 --- a/c64/aliases/,aliases_hardware.s +++ b/c64/aliases/,aliases_hardware.s @@ -125,6 +125,10 @@ .label SID_RANDOM = $D41B .label SID_ENV3 = $D41C + // Color COLOR_RAM + + .label COLOR_RAM = $D800 + // CIA #1 registers .label __CIA1_BASE = $DC00 // base address of the chip diff --git a/c64/basic/,imports.s b/c64/basic/,imports.s index 8c7b7643..e7b92c3e 100644 --- a/c64/basic/,imports.s +++ b/c64/basic/,imports.s @@ -50,3 +50,7 @@ #if CONFIG_SHOW_PAL_NTSC .label print_pal_ntsc = KERNAL().print_pal_ntsc #endif + +#if CONFIG_TAPE_HEAD_ALIGN +.label tape_head_align = KERNAL().tape_head_align +#endif diff --git a/c64/basic/commands/cmd_load.s b/c64/basic/commands/cmd_load.s index 08d2b93c..ad49632b 100644 --- a/c64/basic/commands/cmd_load.s +++ b/c64/basic/commands/cmd_load.s @@ -22,25 +22,9 @@ cmd_load: // Check for the file name jsr basic_end_of_statement_check - bcc !+ + bcc cmd_load_fetch_filename -#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO - - // No file name given, just load the first file from tape - - ldx #$00 - stx SA // secondary address -#if CONFIG_TAPE_NORMAL - inx // 1 - for normal tape format -#else - ldx #$07 // 7 - for turbo tape format -#endif - stx FA // device number - bne cmd_load_got_secondaryaddress // branch always - -#else - - // Without tape support, try to load the first file from disk + // Try to load the first file from disk lda #$01 // name length ldx #$D800 + lda #>COLOR_RAM sta PNT+1 sta USER+1 diff --git a/c64/kernal/screen/screen_calculate_pnt_user.s b/c64/kernal/screen/screen_calculate_pnt_user.s index 4fc409fa..75603fc1 100644 --- a/c64/kernal/screen/screen_calculate_pnt_user.s +++ b/c64/kernal/screen/screen_calculate_pnt_user.s @@ -50,7 +50,7 @@ screen_calculate_USER: sec sbc HIBASE clc - adc #>$d800 + adc #>COLOR_RAM sta USER+1 rts diff --git a/c64/kernal/tape/load_tape_normal.s b/c64/kernal/tape/load_tape_normal.s index c53dabdb..a3d08d45 100644 --- a/c64/kernal/tape/load_tape_normal.s +++ b/c64/kernal/tape/load_tape_normal.s @@ -45,6 +45,7 @@ load_tape_normal: // Start playing jsr tape_common_prepare_cia jsr tape_ask_play + jsr tape_prepare_reading // FALLTROUGH diff --git a/c64/kernal/tape/load_tape_turbo.s b/c64/kernal/tape/load_tape_turbo.s index 7c421e90..0bf65d07 100644 --- a/c64/kernal/tape/load_tape_turbo.s +++ b/c64/kernal/tape/load_tape_turbo.s @@ -32,6 +32,7 @@ load_tape_auto: // Start playing jsr tape_common_prepare_cia jsr tape_ask_play + jsr tape_prepare_reading // FALLTROUGH diff --git a/c64/kernal/tape/tape_common.s b/c64/kernal/tape/tape_common.s index fa813aef..75e49567 100644 --- a/c64/kernal/tape/tape_common.s +++ b/c64/kernal/tape/tape_common.s @@ -104,6 +104,15 @@ 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 diff --git a/c64/kernal/tape/tape_head_align.s b/c64/kernal/tape/tape_head_align.s new file mode 100644 index 00000000..bb98ddea --- /dev/null +++ b/c64/kernal/tape/tape_head_align.s @@ -0,0 +1,109 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# M65 KERNAL_1 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Tape (normal) helper routine - reading speed calibration +// +// Needs pulse length in .A +// + + +#if CONFIG_TAPE_HEAD_ALIGN + + +tape_head_align: + +#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_0) + + jsr map_KERNAL_1 + jsr_ind VK1__tape_head_align + jmp map_NORMAL + +#else + + // Start by asking for tape playback + + // jsr tape_ask_play + + // Disable interrupts + + sei + + // Set IO to default values + + jsr IOINIT + jsr cint_legacy + + // Clear color data ($0800) + + ldy #$00 +!: + lda #($10 + $06) // XXX synchronize colors with setup_vicii + + sta $0800, y + sta $0900, y + sta $0A00, y + sta $0B00, y + + iny + bne !- + + // Clear bitmap data ($2000) + + lda #$20 + sta SAL+1 + tya // put 0 to .A + sta SAL+0 +!: + sta (SAL), y + iny + bne !- + + inc SAL+1 + ldx SAL+1 + cpx #$40 + bne !- + + // Set graphics mode + + lda #$28 // graphic memory start at $2000, color at $0800 + sta VIC_YMCSB + + lda #$3B // set bit 5 to enable graphic mode + sta VIC_SCROLY + + // Set tape timing + + // XXX + +tape_head_align_loop_1: + + // XXX waste pulse + +tape_head_align_loop_2: + + // XXX get pulse + // XXX put pulse + // XXX check time; if not enough passed - next iteration tape_head_align_loop2 + // XXX check for STOP key; if pressed, quit + // XXX scroll + + jmp tape_head_align_loop_1 + +tape_head_align_quit: + + // Clear screen, restore old display settings + + jsr cint_legacy + + // XXX restore COLOR, VIC_EXTCOL, VIC_BGCOL0, CIA2_PRA + + cli + rts // XXX perform new after quit + + +#endif // ROM layout + + +#endif // CONFIG_TAPE_HEAD_ALIGN