diff --git a/common/tranzputer.c b/common/tranzputer.c index 03f634f..0b7ee02 100644 --- a/common/tranzputer.c +++ b/common/tranzputer.c @@ -1700,19 +1700,23 @@ void setCtrlLatch(uint8_t latchVal) // Method to change the secondary CPU frequency and optionally enable/disable it. // Input: frequency = desired frequency in Hertz. -// action = 0 - take no action, just change frequency, 1 - enable the secondary CPU frequency, 2 - disable the secondary CPU frequency. +// action = 0 - take no action, just change frequency, 1 - set and enable the secondary CPU frequency, 2 - set and disable the secondary CPU frequency, +// 3 - enable the secondary CPU frequency, 4 - disable the secondary CPU frequency // Output: actual set frequency in Hertz. // uint32_t setZ80CPUFrequency(float frequency, uint8_t action) { // Locals. // - uint32_t actualFreq; + uint32_t actualFreq = 0; // Setup the alternative clock frequency on the CTL_CLK pin. // - actualFreq=analogWriteFrequency(CTL_CLK_PIN, frequency); - analogWrite(CTL_CLK_PIN, 128); + if(action < 3) + { + actualFreq=analogWriteFrequency(CTL_CLK_PIN, frequency); + analogWrite(CTL_CLK_PIN, 128); + } // Process action, enable, disable or do nothing (just freq change). // @@ -1725,7 +1729,7 @@ uint32_t setZ80CPUFrequency(float frequency, uint8_t action) // Setup the pins to perform a write operation. // setupSignalsForZ80Access(WRITE); - writeZ80IO((action == 1 ? IO_TZ_SETXMHZ : IO_TZ_SET2MHZ), 0); + writeZ80IO((action == 1 || action == 3 ? IO_TZ_SETXMHZ : IO_TZ_SET2MHZ), 0); releaseZ80(); } } @@ -2619,14 +2623,6 @@ void loadTranZPUterDefaultROMS(void) { printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_SA1510_40C); } - //if((result=loadZ80Memory((const char *)MZ_ROM_1Z_013A, 0, MZ_MROM_ADDR, 0, 0, 1)) != FR_OK) - //{ - // printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_1Z_013A); - //} - if((result=loadZ80Memory((const char *)MZ_ROM_1Z_013A, 0, 0x60000, 0, 0, 1)) != FR_OK) - { - printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_1Z_013A); - } if(!result && (result=loadZ80Memory((const char *)MZ_ROM_TZFS, 0, MZ_UROM_ADDR, 0x1800, 0, 1) != FR_OK)) { printf("Error: Failed to load bank 1 of %s into tranZPUter memory.\n", MZ_ROM_TZFS); @@ -3796,6 +3792,9 @@ void processServiceRequest(void) { printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_SA1510_40C); } + + // Change frequency to default. + setZ80CPUFrequency(MZ_80A_CPU_FREQ, 2); break; // Load the 80 column version of the SA1510 bios into memory. @@ -3804,6 +3803,31 @@ void processServiceRequest(void) { printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_SA1510_80C); } + + // Change frequency to default. + setZ80CPUFrequency(MZ_80A_CPU_FREQ, 2); + break; + + // Load the 40 column MZ700 1Z-013A bios into memory. + case TZSVC_CMD_LOAD700BIOS40: + if((status=loadZ80Memory((const char *)MZ_ROM_1Z_013A_40C, 0, MZ_MROM_ADDR, 0, 0, 1)) != FR_OK) + { + printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_1Z_013A_40C); + } + + // Change frequency to match Sharp MZ-700 + setZ80CPUFrequency(MZ_700_CPU_FREQ, 1); + break; + + // Load the 80 column MZ700 1Z-013A bios into memory. + case TZSVC_CMD_LOAD700BIOS80: + if((status=loadZ80Memory((const char *)MZ_ROM_1Z_013A_80C, 0, MZ_MROM_ADDR, 0, 0, 1)) != FR_OK) + { + printf("Error: Failed to load %s into tranZPUter memory.\n", MZ_ROM_1Z_013A_80C); + } + + // Change frequency to match Sharp MZ-700 + setZ80CPUFrequency(MZ_700_CPU_FREQ, 1); break; // Load the CPM CCP+BDOS from file into the address given. @@ -3836,6 +3860,22 @@ void processServiceRequest(void) copySize = TZSVC_CMD_SIZE; break; + // Switch to the mainboard frequency (default). + case TZSVC_CMD_CPU_BASEFREQ: + setZ80CPUFrequency(0, 4); + break; + + // Switch to the alternate frequency managed by the K64F counters. + case TZSVC_CMD_CPU_ALTFREQ: + setZ80CPUFrequency(0, 3); + break; + + // Set the alternate frequency. The TZFS command provides the frequency in KHz so multiply up to Hertz before changing. + case TZSVC_CMD_CPU_CHGFREQ: +printf("Changing to Freq:%ld\n", (svcControl.cpuFreq * 1000)); + setZ80CPUFrequency(svcControl.cpuFreq * 1000, 1); + break; + default: break; } diff --git a/include/tranzputer.h b/include/tranzputer.h index f7ae318..3fe4799 100755 --- a/include/tranzputer.h +++ b/include/tranzputer.h @@ -93,9 +93,12 @@ #define MZ_MEMORY_RESET 0xE010 // Address when read resets the memory to the default location 0000-0FFF. #define MZ_CRT_NORMAL 0xE014 // Address when read sets the CRT to normal display mode. #define MZ_CRT_INVERSE 0xE018 // Address when read sets the CRT to inverted display mode. +#define MZ_80A_CPU_FREQ 2000000 // CPU Speed of the Sharp MZ-80A +#define MZ_700_CPU_FREQ 3580000 // CPU Speed of the Sharp MZ-700 #define MZ_ROM_SA1510_40C "0:\\TZFS\\SA1510.ROM" // Original 40 character Monitor ROM. #define MZ_ROM_SA1510_80C "0:\\TZFS\\SA1510-8.ROM" // Original Monitor ROM patched for 80 character screen mode. -#define MZ_ROM_1Z_013A "0:\\TZFS\\1Z-013A.ROM" // Original 40 character Monitor ROM for the Sharp MZ700. +#define MZ_ROM_1Z_013A_40C "0:\\TZFS\\1Z-013A.ROM" // Original 40 character Monitor ROM for the Sharp MZ700. +#define MZ_ROM_1Z_013A_80C "0:\\TZFS\\1Z-013A-8.ROM" // Original Monitor ROM patched for the Sharp MZ700 patched for 80 column mode. #define MZ_ROM_TZFS "0:\\TZFS\\TZFS.ROM" // tranZPUter Filing System ROM. // CP/M constants. @@ -128,10 +131,15 @@ #define TZSVC_CMD_CHANGEDIR 0x09 // Service command to change active directory on the SD card. #define TZSVC_CMD_LOAD40BIOS 0x20 // Service command requesting that the 40 column version of the SA1510 BIOS is loaded. #define TZSVC_CMD_LOAD80BIOS 0x21 // Service command requesting that the 80 column version of the SA1510 BIOS is loaded. +#define TZSVC_CMD_LOAD700BIOS40 0x22 // Service command requesting that the MZ700 1Z-013A 40 column BIOS is loaded. +#define TZSVC_CMD_LOAD700BIOS80 0x23 //Service command requesting that the MZ700 1Z-013A 80 column patched BIOS is loaded. #define TZSVC_CMD_LOADBDOS 0x30 // Service command to reload CPM BDOS+CCP. #define TZSVC_CMD_ADDSDDRIVE 0x31 // Service command to attach a CPM disk to a drive number. #define TZSVC_CMD_READSDDRIVE 0x32 // Service command to read an attached SD file as a CPM disk drive. #define TZSVC_CMD_WRITESDDRIVE 0x33 // Service command to write to a CPM disk drive which is an attached SD file. +#define TZSVC_CMD_CPU_BASEFREQ 0x40 // Service command to switch to the mainboard frequency. +#define TZSVC_CMD_CPU_ALTFREQ 0x41 // Service command to switch to the alternate frequency provided by the K64F. +#define TZSVC_CMD_CPU_CHGFREQ 0x42 // Service command to set the alternate frequency in hertz. #define TZSVC_DEFAULT_DIR "MZF" // Default directory where MZF files are stored. #define TZSVC_DEFAULT_EXT "MZF" // Default file extension for MZF files. #define TZSVC_DEFAULT_WILDCARD "*" // Default wildcard file matching. @@ -525,7 +533,10 @@ typedef struct __attribute__((__packed__)) { uint16_t trackNo; // For virtual drives with track and sector this is the track number uint16_t sectorNo; // For virtual drives with tracl and sector this is the sector number. uint8_t fileNo; // File number of a file within the last directory listing to open/update. - uint16_t loadAddr; // Load address for ROM/File images which need to be dynamic. + union { + uint16_t loadAddr; // Load address for ROM/File images which need to be dynamic. + uint16_t cpuFreq; // CPU Frequency in KHz - used for setting of the alternate CPU clock frequency. + }; uint16_t loadSize; // Size for ROM/File to be loaded. uint8_t directory[TZSVC_DIRNAME_SIZE]; // Directory in which to look for a file. If no directory is given default to MZF. uint8_t filename[TZSVC_FILENAME_SIZE]; // File to open or create. diff --git a/libraries/lib/libimath2-k64f.a b/libraries/lib/libimath2-k64f.a index 02ab5e9..4251f2a 100644 Binary files a/libraries/lib/libimath2-k64f.a and b/libraries/lib/libimath2-k64f.a differ diff --git a/libraries/lib/libumansi-k64f.a b/libraries/lib/libumansi-k64f.a index bbb4b57..986c374 100644 Binary files a/libraries/lib/libumansi-k64f.a and b/libraries/lib/libumansi-k64f.a differ diff --git a/libraries/lib/libummath-k64f.a b/libraries/lib/libummath-k64f.a index b1aa88a..9ee1087 100644 Binary files a/libraries/lib/libummath-k64f.a and b/libraries/lib/libummath-k64f.a differ diff --git a/libraries/lib/libummathf-k64f.a b/libraries/lib/libummathf-k64f.a index f3a1e0e..c598c7b 100644 Binary files a/libraries/lib/libummathf-k64f.a and b/libraries/lib/libummathf-k64f.a differ diff --git a/libraries/lib/libummisc-k64f.a b/libraries/lib/libummisc-k64f.a index a28188f..0179013 100644 Binary files a/libraries/lib/libummisc-k64f.a and b/libraries/lib/libummisc-k64f.a differ diff --git a/libraries/lib/libumstdio-k64f.a b/libraries/lib/libumstdio-k64f.a index b6c2454..e53d34c 100644 Binary files a/libraries/lib/libumstdio-k64f.a and b/libraries/lib/libumstdio-k64f.a differ