|
|
1.1 root 1: /* 1.1.1.3 root 2: Hatari - st.c 1.1 root 3: 1.1.1.11! root 4: This file is distributed under the GNU General Public License, version 2 ! 5: or at your option any later version. Read the file gpl.txt for details. 1.1.1.3 root 6: 1.1.1.6 root 7: ST disk image support. 1.1 root 8: 1.1.1.6 root 9: The file format of the .ST image files is simplicity itself. They are just 10: straight images of the disk in question, with sectors stored in the expected 11: logical order. 12: So, on a sector basis the images run from sector 0 (bootsector) to however 13: many sectors are on the disk. On a track basis the layout is the same as for 14: MSA files but obviously the data is raw, no track header or compression or 15: anything like that. 1.1 root 16: 17: TRACK 0, SIDE 0 18: TRACK 0, SIDE 1 19: TRACK 1, SIDE 0 20: TRACK 1, SIDE 1 21: TRACK 2, SIDE 0 22: TRACK 2, SIDE 1 23: */ 1.1.1.9 root 24: const char ST_fileid[] = "Hatari st.c : " __DATE__ " " __TIME__; 1.1.1.6 root 25: 26: #include "main.h" 27: #include "file.h" 28: #include "st.h" 29: 30: #define SAVE_TO_ST_IMAGES 31: 32: 33: #if defined(__riscos) 34: /* The following two lines are required on RISC OS for preventing it from 35: * interfering with the .ST image files: */ 36: #include <unixlib/local.h> 37: int __feature_imagefs_is_file = 1; 38: #endif 1.1 root 39: 40: 1.1.1.2 root 41: /*-----------------------------------------------------------------------*/ 1.1.1.6 root 42: /** 1.1.1.9 root 43: * Does filename end with a .ST extension? If so, return true. 1.1.1.6 root 44: */ 1.1.1.10 root 45: bool ST_FileNameIsST(const char *pszFileName, bool bAllowGZ) 1.1 root 46: { 1.1.1.3 root 47: return(File_DoesFileExtensionMatch(pszFileName,".st") 48: || (bAllowGZ && File_DoesFileExtensionMatch(pszFileName,".st.gz"))); 49: } 50: 51: 52: /*-----------------------------------------------------------------------*/ 1.1.1.6 root 53: /** 54: * Load .ST file into memory, set number of bytes loaded and return a pointer 55: * to the buffer. 56: */ 1.1.1.10 root 57: Uint8 *ST_ReadDisk(const char *pszFileName, long *pImageSize) 1.1.1.3 root 58: { 1.1.1.6 root 59: Uint8 *pStFile; 1.1.1.3 root 60: 61: *pImageSize = 0; 1.1 root 62: 1.1.1.3 root 63: /* Just load directly a buffer, and set ImageSize accordingly */ 1.1.1.6 root 64: pStFile = File_Read(pszFileName, pImageSize, NULL); 1.1.1.3 root 65: if (!pStFile) 66: *pImageSize = 0; 1.1 root 67: 1.1.1.6 root 68: return pStFile; 1.1 root 69: } 70: 1.1.1.2 root 71: 72: /*-----------------------------------------------------------------------*/ 1.1.1.6 root 73: /** 1.1.1.9 root 74: * Save .ST file from memory buffer. Returns true is all OK. 1.1.1.6 root 75: */ 1.1.1.10 root 76: bool ST_WriteDisk(const char *pszFileName, Uint8 *pBuffer, int ImageSize) 1.1 root 77: { 78: #ifdef SAVE_TO_ST_IMAGES 79: 1.1.1.3 root 80: /* Just save buffer directly to file */ 1.1.1.9 root 81: return File_Save(pszFileName, pBuffer, ImageSize, false); 1.1 root 82: 1.1.1.2 root 83: #else /*SAVE_TO_ST_IMAGES*/ 1.1 root 84: 1.1.1.3 root 85: /* Oops, cannot save */ 1.1.1.9 root 86: return false; 1.1 root 87: 1.1.1.2 root 88: #endif /*SAVE_TO_ST_IMAGES*/ 1.1 root 89: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.