diff --git a/apps/tzload/tzload.c b/apps/tzload/tzload.c index 45207a1..ad39e74 100644 --- a/apps/tzload/tzload.c +++ b/apps/tzload/tzload.c @@ -362,7 +362,7 @@ uint32_t app(uint32_t param1, uint32_t param2) loadZ80Memory(uploadFile, 0, memAddr, 0, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, (idx == uploadCnt-1) ? 1 : 0); } else { - loadMZFZ80Memory(uploadFile, memAddr, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, (idx == uploadCnt-1) ? 1 : 0); + loadMZFZ80Memory(uploadFile, memAddr, 0, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, (idx == uploadCnt-1) ? 1 : 0); } } } @@ -404,7 +404,7 @@ uint32_t app(uint32_t param1, uint32_t param2) loadZ80Memory(uploadFile, 0, memAddr, 0, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, 1); } else { - loadMZFZ80Memory(uploadFile, memAddr, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, 1); + loadMZFZ80Memory(uploadFile, memAddr, 0, 0, mainboard_flag == 1 ? MAINBOARD : fpga_flag == 1 ? FPGA : TRANZPUTER, 1); } } } diff --git a/buildall b/buildall index d819036..b984c8e 100755 --- a/buildall +++ b/buildall @@ -1,8 +1,8 @@ #!/bin/bash -# Target machine, used to select the right software for the SD card. -#TARGET=MZ-700 -TARGET=MZ-80A +# Not used: Target machine, used to select the right software for the SD card. +# TARGET=MZ-700 +# TARGET=MZ-80A ZPU_SHARPMZ_BUILD=1 ZPU_SHARPMZ_APPADDR=0x100000 @@ -112,6 +112,7 @@ if [ $? != 0 ]; then fi # Use copytosd.sh to transfer files to an SD card. Still need to copy the k64F files manually. +# --------------- # Copy across all the Z80/TZFS software into the target, keep it in one place for placing onto an SD card! #cp $tzfsdir/roms/tzfs.rom $k64fsddir/TZFS/ #cp $tzfsdir/roms/monitor_SA1510.rom $k64fsddir/TZFS/SA1510.rom diff --git a/common/tranzputer.c b/common/tranzputer.c index cbbc6dc..9233b6c 100644 --- a/common/tranzputer.c +++ b/common/tranzputer.c @@ -2025,7 +2025,7 @@ FRESULT loadZ80Memory(const char *src, uint32_t fileOffset, uint32_t addr, uint3 // Method to load an MZF format file from the SD card directly into the tranZPUter static RAM, FPGA or mainboard RAM. // If the load address is specified then it overrides the MZF header value, otherwise load addr is taken from the header. // -FRESULT loadMZFZ80Memory(const char *src, uint32_t addr, uint32_t *bytesRead, enum TARGETS target, uint8_t releaseBus) +FRESULT loadMZFZ80Memory(const char *src, uint32_t addr, uint32_t *bytesRead, uint8_t hdrOnly, enum TARGETS target, uint8_t releaseBus) { // Locals. FIL File; @@ -2040,7 +2040,7 @@ FRESULT loadMZFZ80Memory(const char *src, uint32_t addr, uint32_t *bytesRead, en // Sanity check on filenames. if(src == NULL) return(FR_INVALID_PARAMETER); - + // Try and open the source file. fr0 = f_open(&File, src, FA_OPEN_EXISTING | FA_READ); @@ -2066,34 +2066,37 @@ FRESULT loadMZFZ80Memory(const char *src, uint32_t addr, uint32_t *bytesRead, en // in the service record sector on exit for this purpose. The caller needs to check the service record and if the Load Address is below >= 1200H use the CMT header else // use the service sector. // - // NB: This assumes the TZFS is running and made this call. + // NB: This assumes TZFS is running and made this call. // copyToZ80(addrOffset+MZ_CMT_ADDR, (uint8_t *)&mzfHeader, MZF_HEADER_SIZE, target); - - // Now obtain the parameters. - // - if(addr == 0xFFFFFFFF) + + if(hdrOnly == 0) { - addr = mzfHeader.loadAddr; + // Now obtain the parameters. + // + if(addr == 0xFFFFFFFF) + { + addr = mzfHeader.loadAddr; + } + + // Look at the attribute byte, if it is >= 0xF8 then it is a special tranZPUter binary object requiring loading into a seperate memory bank. + // The attribute & 0x07 << 16 specifies the memory bank in which to load the image. + if(mzfHeader.attr >= 0xF8) + { + addr += ((mzfHeader.attr & 0x07) << 16); + //printf("CPM: Addr=%08lx, Size=%08lx\n", addr, mzfHeader.fileSize); + } else + { + addr += addrOffset; + } + + // Ok, load up the file into Z80 memory. + fr0 = loadZ80Memory(src, MZF_HEADER_SIZE, addr, (mzfHeader.attr >= 0xF8 ? 0 : mzfHeader.fileSize), bytesRead, target, releaseBus); + + // If the load address was below 0x11D0, the lowest free point in the original memory map then the load is said to be in lower DRAM. In this case the CMT header wont be available + // so load the header into the service sector as well so the caller can determine the load state. + memcpy((uint8_t *)&svcControl.sector, (uint8_t *)&mzfHeader, MZF_HEADER_SIZE); } - - // Look at the attribute byte, if it is >= 0xF8 then it is a special tranZPUter binary object requiring loading into a seperate memory bank. - // The attribute & 0x07 << 16 specifies the memory bank in which to load the image. - if(mzfHeader.attr >= 0xF8) - { - addr += ((mzfHeader.attr & 0x07) << 16); - //printf("CPM: Addr=%08lx, Size=%08lx\n", addr, mzfHeader.fileSize); - } else - { - addr += addrOffset; - } - - // Ok, load up the file into Z80 memory. - fr0 = loadZ80Memory(src, MZF_HEADER_SIZE, addr, (mzfHeader.attr >= 0xF8 ? 0 : mzfHeader.fileSize), bytesRead, target, releaseBus); - - // If the load address was below 0x11D0, the lowest free point in the original memory map then the load is said to be in lower DRAM. In this case the CMT header wont be available - // so load the header into the service sector as well so the caller can determine the load state. - memcpy((uint8_t *)&svcControl.sector, (uint8_t *)&mzfHeader, MZF_HEADER_SIZE); } return(fr0 ? fr0 : FR_OK); } @@ -3793,16 +3796,24 @@ uint8_t svcLoadFile(enum FILE_TYPE type) // svcSetDefaults(type); - // MZF are handled with their own methods as it involves looking into the file to determine the name and details. + // MZF and MZF Headers are handled with their own methods as it involves looking into the file to determine the name and details. // - if(type == MZF) + if(type == MZF || type == MZFHDR) { + // Tidy up the MZF filename suitable for file matching. +// for(int idx=0; idx < MZF_FILENAME_LEN; idx++) +// { +// svcControl.filename[idx] = (svcControl.filename[idx] == 0x0d ? 0x00 : svcControl.filename[idx]); +// } +// + // Find the file using the given file number or file name. // - if(svcFindFileCache(fqfn, (char *)&svcControl.filename, svcControl.fileNo, type)) + if(svcFindFileCache(fqfn, (char *)&svcControl.filename, svcControl.fileNo, MZF)) { // Call method to load an MZF file. - result = loadMZFZ80Memory(fqfn, 0xFFFFFFFF, 0, (svcControl.memTarget == 0 ? TRANZPUTER : MAINBOARD), 1); + result = loadMZFZ80Memory(fqfn, (svcControl.loadAddr == 0xFFFF ? 0xFFFFFFFF : svcControl.loadAddr), 0, (type == MZFHDR ? 1 : 0), (svcControl.memTarget == 0 ? TRANZPUTER : MAINBOARD), 1); + // Store the filename, used in reload or immediate saves. // osControl.lastFile = (uint8_t *)realloc(osControl.lastFile, strlen(fqfn)+1); @@ -3814,6 +3825,7 @@ uint8_t svcLoadFile(enum FILE_TYPE type) { strcpy((char *)osControl.lastFile, fqfn); } + } else { result = FR_NO_FILE; @@ -3870,7 +3882,6 @@ uint8_t svcSaveFile(enum FILE_TYPE type) { addrOffset = SRAM_BANK6_ADDR; } - result = loadMZFZ80Memory(fqfn, 0xFFFFFFFF, 0, (svcControl.memTarget == 0 ? TRANZPUTER : MAINBOARD), 1); // Get the MZF header which contains the details of the file to save. copyFromZ80((uint8_t *)&mzfHeader, addrOffset + MZ_CMT_ADDR, MZF_HEADER_SIZE, TRANZPUTER); @@ -4296,7 +4307,7 @@ void processServiceRequest(void) case TZSVC_CMD_LOADFILE: status=svcLoadFile(svcControl.fileType); break; - + // Save a file directly from target memory. case TZSVC_CMD_SAVEFILE: status=svcSaveFile(svcControl.fileType); diff --git a/include/tranzputer.h b/include/tranzputer.h index 22eab29..4dcbc21 100755 --- a/include/tranzputer.h +++ b/include/tranzputer.h @@ -599,8 +599,10 @@ enum CPLD_FLAGS { // enum FILE_TYPE { MZF = 0, // Sharp MZF tape image files. - CAS = 1, // BASIC CASsette image files. - BAS = 2, // BASic ASCII text script files. + MZFHDR = 1, // Sharp MZF Header from file only. + CAS = 2, // BASIC CASsette image files. + BAS = 3, // BASic ASCII text script files. + ALL = 10, // All files to be considered. ALLFMT = 11 // Special case for directory listings, all files but truncated and formatted. }; @@ -839,7 +841,7 @@ char *getVideoFrame(enum VIDEO_FRAMES); char *getAttributeFrame(enum VIDEO_FRAMES); FRESULT loadZ80Memory(const char *, uint32_t, uint32_t, uint32_t, uint32_t *, enum TARGETS, uint8_t); FRESULT saveZ80Memory(const char *, uint32_t, uint32_t, t_svcDirEnt *, enum TARGETS); -FRESULT loadMZFZ80Memory(const char *, uint32_t, uint32_t *, enum TARGETS, uint8_t); +FRESULT loadMZFZ80Memory(const char *, uint32_t, uint32_t *, uint8_t, enum TARGETS, uint8_t); // Getter/Setter methods! uint8_t isZ80Reset(void); diff --git a/libraries/lib/libimath2-k64f.a b/libraries/lib/libimath2-k64f.a index 330b559..097a2a8 100644 Binary files a/libraries/lib/libimath2-k64f.a and b/libraries/lib/libimath2-k64f.a differ diff --git a/libraries/lib/libimath2-zpu.a b/libraries/lib/libimath2-zpu.a index 48affa3..5ebe2cc 100644 Binary files a/libraries/lib/libimath2-zpu.a and b/libraries/lib/libimath2-zpu.a differ diff --git a/libraries/lib/libumansi-k64f.a b/libraries/lib/libumansi-k64f.a index 7c6b224..45b356d 100644 Binary files a/libraries/lib/libumansi-k64f.a and b/libraries/lib/libumansi-k64f.a differ diff --git a/libraries/lib/libumansi-zpu.a b/libraries/lib/libumansi-zpu.a index 11bef3c..d26792e 100644 Binary files a/libraries/lib/libumansi-zpu.a and b/libraries/lib/libumansi-zpu.a differ diff --git a/libraries/lib/libummath-k64f.a b/libraries/lib/libummath-k64f.a index e0b0512..2c52253 100644 Binary files a/libraries/lib/libummath-k64f.a and b/libraries/lib/libummath-k64f.a differ diff --git a/libraries/lib/libummath-zpu.a b/libraries/lib/libummath-zpu.a index abaf632..53b177c 100644 Binary files a/libraries/lib/libummath-zpu.a and b/libraries/lib/libummath-zpu.a differ diff --git a/libraries/lib/libummathf-k64f.a b/libraries/lib/libummathf-k64f.a index 9c1ffbf..7900d33 100644 Binary files a/libraries/lib/libummathf-k64f.a and b/libraries/lib/libummathf-k64f.a differ diff --git a/libraries/lib/libummathf-zpu.a b/libraries/lib/libummathf-zpu.a index bc3adef..d0dc7de 100644 Binary files a/libraries/lib/libummathf-zpu.a and b/libraries/lib/libummathf-zpu.a differ diff --git a/libraries/lib/libummisc-k64f.a b/libraries/lib/libummisc-k64f.a index 7359d1b..a39cd76 100644 Binary files a/libraries/lib/libummisc-k64f.a and b/libraries/lib/libummisc-k64f.a differ diff --git a/libraries/lib/libummisc-zpu.a b/libraries/lib/libummisc-zpu.a index fa41e24..8750b4c 100644 Binary files a/libraries/lib/libummisc-zpu.a and b/libraries/lib/libummisc-zpu.a differ diff --git a/libraries/lib/libumstdio-k64f.a b/libraries/lib/libumstdio-k64f.a index 64b6c69..6ff3ef9 100644 Binary files a/libraries/lib/libumstdio-k64f.a and b/libraries/lib/libumstdio-k64f.a differ diff --git a/libraries/lib/libumstdio-zpu.a b/libraries/lib/libumstdio-zpu.a index 4ec6a02..feb140d 100644 Binary files a/libraries/lib/libumstdio-zpu.a and b/libraries/lib/libumstdio-zpu.a differ