diff --git a/Makefile b/Makefile index 5e0b8662..30c6b004 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \ c64/kernal/memory \ c64/kernal/print \ c64/kernal/rom_revision \ + c64/kernal/rs232 \ c64/kernal/screen \ c64/kernal/time diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index e5920bef..9fdebcbd 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -40,10 +40,11 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE_NORMAL // please keep disabled for now -// #define CONFIG_TAPE_TURBO // please keep disabled for now -// #define CONFIG_RS232_USERPORT // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_UP2400 // please keep disabled for now +// #define CONFIG_RS232_UP9600 // please keep disabled for now // Multiple SID support diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 441f6b48..1f003c0b 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -42,10 +42,11 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE_NORMAL // please keep disabled for now -// #define CONFIG_TAPE_TURBO // please keep disabled for now -// #define CONFIG_RS232_USERPORT // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_UP2400 // please keep disabled for now +// #define CONFIG_RS232_UP9600 // please keep disabled for now // Multiple SID support diff --git a/c64/,,config_testing.s b/c64/,,config_testing.s index 50130b12..b8364118 100644 --- a/c64/,,config_testing.s +++ b/c64/,,config_testing.s @@ -41,10 +41,11 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE_NORMAL // please keep disabled for now -// #define CONFIG_TAPE_TURBO // please keep disabled for now -// #define CONFIG_RS232_USERPORT // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_UP2400 // please keep disabled for now +// #define CONFIG_RS232_UP9600 // please keep disabled for now // Multiple SID support diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 5d9d4a07..a1209988 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -40,10 +40,11 @@ // I/O devices -#define CONFIG_IEC // please keep enabled for now -// #define CONFIG_TAPE_NORMAL // please keep disabled for now -// #define CONFIG_TAPE_TURBO // please keep disabled for now -// #define CONFIG_RS232_USERPORT // please keep disabled for now +#define CONFIG_IEC // please keep enabled for now +// #define CONFIG_TAPE_NORMAL // please keep disabled for now +// #define CONFIG_TAPE_TURBO // please keep disabled for now +// #define CONFIG_RS232_UP2400 // please keep disabled for now +// #define CONFIG_RS232_UP9600 // please keep disabled for now // Multiple SID support diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index b6868d3a..3a231e52 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -107,6 +107,20 @@ } +// Check that I/O configuration is correct +{ + .var selected_rs232 = 0; + +#if CONFIG_RS232_UP2400 + .eval selected_rs232++ +#endif +#if CONFIG_RS232_UP9600 + .eval selected_rs232++ +#endif + + .if (selected_rs232 > 1) .error "Please select at most one CONFIG_RS232_* option" +} + // Check that startup banner configuration is correct { @@ -207,6 +221,12 @@ #endif +// Handle I/O configuration + +#if CONFIG_RS232_UP2400 || CONFIG_RS232_UP9600 +#define HAS_RS232 +#endif + // Handle configuration of various features diff --git a/c64/kernal/chkinout_real.s b/c64/kernal/chkinout_real.s index 427d1c63..69b4be9d 100644 --- a/c64/kernal/chkinout_real.s +++ b/c64/kernal/chkinout_real.s @@ -5,7 +5,7 @@ // - [RG64] C64 Programmer's Reference Guide - page 275 (CHKIN) / 276 (CKOUT) // - [CM64] Compute's Mapping the Commodore 64 - page 229 // -// CPU registers that has to be preserved (see [RG64]): .Y, possibly .A (XXX - see [CM64], page 213) +// CPU registers that has to be preserved (see [RG64]): .Y, .A (see [CM64], page 213) // @@ -13,7 +13,8 @@ chkin_real: - // Store Y for preservation + // Store registers for preservation + pha phy_trash_a // Reset status @@ -37,7 +38,7 @@ chkin_real: lda LAT, Y cmp #$01 - beq chkinout_file_not_input + beq chkin_file_not_input #if CONFIG_IEC @@ -58,47 +59,41 @@ chkin_real: chkin_set_device: lda FAT,Y sta DFLTN - clc // for success + // FALLTROUGH // Common part for booth CHKIN and CKOUT -// XXX add CPU-dependent optimizations here chkinout_end: - tax + ply_trash_a pla - tay - txa + clc // indicate success rts +chkin_file_not_input: // XXX move this out of common section + ply_trash_a + pla + jmp kernalerror_FILE_NOT_INPUT + chkinout_file_not_open: + ply_trash_a pla - tay jmp kernalerror_FILE_NOT_OPEN chkinout_device_not_present: + ply_trash_a pla - tay jsr kernalstatus_DEVICE_NOT_FOUND jmp kernalerror_DEVICE_NOT_FOUND -chkinout_file_not_input: - pla - tay - jmp kernalerror_FILE_NOT_INPUT - -chkinout_file_not_output: - pla - tay - jmp kernalerror_FILE_NOT_OUTPUT // CKOUT implementation ckout_real: - // Store Y for preservation - tya + // Store registers for preservation pha + phy_trash_a // Reset status jsr kernalstatus_reset @@ -118,19 +113,19 @@ ckout_real: beq chkinout_device_not_present // RS-232 not implemented cmp #$00 - beq chkinout_file_not_output // cannot output to keyboard - XXX check real ROM behaviour + beq ckout_file_not_output // cannot output to keyboard - XXX check real ROM behaviour // Fail if the file is open for reading (secondary address 0) lda LAT, Y - beq chkinout_file_not_output + beq ckout_file_not_output #if CONFIG_IEC // For IEC devices, send LISTEN + SECOND first lda FAT,Y jsr iec_check_devnum_oc - bcs chkout_set_device + bcs ckout_set_device jsr LISTEN bcs chkinout_device_not_present // don't set DFLTO in case of failure @@ -141,9 +136,13 @@ ckout_real: #endif // CONFIG_IEC -chkout_set_device: +ckout_set_device: lda FAT,Y sta DFLTO - clc // for success - jmp chkinout_end + +ckout_file_not_output: + ply_trash_a + pla + jmp kernalerror_FILE_NOT_OUTPUT + diff --git a/c64/kernal/rs232/chkin_rs232.s b/c64/kernal/rs232/chkin_rs232.s new file mode 100644 index 00000000..6cc6d002 --- /dev/null +++ b/c64/kernal/rs232/chkin_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the CHKIN routine +// + + +#if HAS_RS232 + + +chkin_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/chrin_rs232.s b/c64/kernal/rs232/chrin_rs232.s new file mode 100644 index 00000000..7c39d342 --- /dev/null +++ b/c64/kernal/rs232/chrin_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the CHKRIN routine +// + + +#if HAS_RS232 + + +chrin_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/chrout_rs232.s b/c64/kernal/rs232/chrout_rs232.s new file mode 100644 index 00000000..9c3af02f --- /dev/null +++ b/c64/kernal/rs232/chrout_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the CHROUT routine +// + + +#if HAS_RS232 + + +chrout_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/ckout_rs232.s b/c64/kernal/rs232/ckout_rs232.s new file mode 100644 index 00000000..66d4b3e7 --- /dev/null +++ b/c64/kernal/rs232/ckout_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the CKOUT routine +// + + +#if HAS_RS232 + + +ckout_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/close_rs232.s b/c64/kernal/rs232/close_rs232.s new file mode 100644 index 00000000..3871fe04 --- /dev/null +++ b/c64/kernal/rs232/close_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the CLOSE routine +// + + +#if HAS_RS232 + + +close_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/getin_rs232.s b/c64/kernal/rs232/getin_rs232.s new file mode 100644 index 00000000..17215ead --- /dev/null +++ b/c64/kernal/rs232/getin_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the GETIN routine +// + + +#if HAS_RS232 + + +getin_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232 diff --git a/c64/kernal/rs232/open_rs232.s b/c64/kernal/rs232/open_rs232.s new file mode 100644 index 00000000..c347ec70 --- /dev/null +++ b/c64/kernal/rs232/open_rs232.s @@ -0,0 +1,14 @@ + +// +// RS-232 part of the OPEN routine +// + + +#if HAS_RS232 + + +open_rs232: + STUB_IMPLEMENTATION() // XXX provide implementation for both UP2400 and UP9600 + + +#endif // HAS_RS232