From 5fafddb0972ffffe44e0cbde0e1f27a2a69ced90 Mon Sep 17 00:00:00 2001 From: Philip Smart Date: Wed, 10 Jun 2020 21:49:02 +0100 Subject: [PATCH] Added MZ700 modes, still work needed on the ISR for reliability --- common/tranzputer.c | 66 +++++++++++++++++++++++++------- include/tranzputer.h | 15 +++++++- libraries/lib/libimath2-k64f.a | Bin 12504 -> 12504 bytes libraries/lib/libumansi-k64f.a | Bin 124218 -> 124218 bytes libraries/lib/libummath-k64f.a | Bin 2660 -> 2660 bytes libraries/lib/libummathf-k64f.a | Bin 63972 -> 63972 bytes libraries/lib/libummisc-k64f.a | Bin 6222 -> 6222 bytes libraries/lib/libumstdio-k64f.a | Bin 80050 -> 80050 bytes 8 files changed, 66 insertions(+), 15 deletions(-) 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 02ab5e95a341ff9919222ffa3134e203a0cdc3b6..4251f2a821a681479f2d5f8755d37490bf50e360 100644 GIT binary patch delta 71 zcmcbScq4Iw44Z|ag_)V@M5Q_?Yw|it@r`?D^Fg_r=COJqBlAogFw8?3b930VJa8T^-9JV$jds2JA zD_`w_ND0Molq5+=aoZE?8$0i3-QMT@d49f`#JM|h?haPu_*#8luf9|Ll9et!D7g;u zoZ6IJ3ceQ}XJ8pG%2K(sYiXNQM>cLj!C-@t?+kZ6-i$j1huUxd;ok0qz*bzvx`9`L zC6|G7qeB8)njd}Rouq|S*&6cWc^szpY=Oi-54hzJxO=1@1y;obHqk!b-8zu~V@lKTs^2(qNAUP%bX2scd)}=E)X& zn1OqtVgDfPZUMsNDXp;-g8m{h#eI|z;BHkEJ9@LWcr8*S30~rHNz9OTUaJOac$vE0|mxBlTk^<{-1sjIn z1ePp5T$~scSXaI1nd%`e^iQuz*&bUKZfQ2?ma%GO(u4|b1r&ljkq;Zgf*Jj>e(Iqf z|DjsbRaui#&7qkxsMee{`RHMTB+p447&|H!!x_@*b3v-@rWM?{-OK4G?#;e`+JSX1 z*CGNJLn##|e%wu8iCrF@J=;KJCufX1o23ozNMYZVuw$;pWp-K*-Siq6&rEHF%VOi+ z*jFb!(Rk=_8yxJj7p!)p{eMzE0_&x8(L5D9_Cii9_T&RIm#!*oYz~&l7JHnB2cePq zAnbk_g5>F6V|4?DO2`!VQAU6#^|JA}8J$J;VS?xm4k1c)i0kyQ_cPd}lfSsJ8%PN& ITs>U$3%)VoEdT%j diff --git a/libraries/lib/libummath-k64f.a b/libraries/lib/libummath-k64f.a index b1aa88ad0eabe586053b01a6ce9aeed9a5675d2f..9ee1087879c8167269fd2e65afd57d293a27440e 100644 GIT binary patch delta 27 dcmaDN@(;M>xqq^qhUDhzeWh@< rAb0bfP=fRAG?r|>b@3esOz*i{dT=>8Yp2aFPiDaRps@P+_BA&Eyp(JI delta 335 zcmaFznfb|Q<_R)v=9Y#AhK3uJ(;M>xqq^qhUDhzeWh@< rAb0bfP=fRAG?r|>b@3esOz*i{dT=>8Yp2aFPiDaRps@P+_BA&E=MrkY diff --git a/libraries/lib/libummisc-k64f.a b/libraries/lib/libummisc-k64f.a index a28188f42597c1920a87c752f4921ca0d26268f7..017901307dd131df8928dafbc9b2d2852002da3c 100644 GIT binary patch delta 39 kcmX?SaL!IYh#5R50tri4$mfT0O9Kj?*IS* delta 39 lcmX?SaL!uB{u(&Rzs2( z+ia)#LK-12zS-GzIUj^?y7@yeOsy%=ki^6{-(IvGg};9Naj08Bdc-$R-g_D@Ur;Ntx#rX)R6DMz!{tHh^B)zX w=>Pv-7)4(HPcSln`+N>Ygo1)v@$KhD7?rt@e6gKhp0ONBi^TRN+Kha>0Fi%rGynhq delta 371 zcmdn=k!90ImI*R!=9Y#AhK3uJN*JNc$sd9xHg93{;zjVqH%s#$=0Wf!Hvf@ULy{NU zY^V7`8X+&f+1YhDAC$lOLoljZqeKgswVMlS=W!$J)9y@1vL|Y?oebONA5)JZiHUE% zy=XfMfBpL7NNy3|JbCYFxO_pa#O9h)lThurrVf|?5G=kq|4}iD{{QcVQRMai1S9je k&*xx7C@82E-+o?%QJD+L7u)&e8OxEhNNiuC&B(_K0GL>J-~a#s