|
|
1.1 root 1: /*
1.1.1.3 root 2: Hatari - st.c
1.1 root 3:
1.1.1.3 root 4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
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.6 ! root 24: const char ST_rcsid[] = "Hatari $Id: st.c,v 1.9 2007/10/31 21:31:50 eerot Exp $";
! 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: /**
! 43: * Does filename end with a .ST extension? If so, return TRUE
! 44: */
1.1.1.3 root 45: BOOL ST_FileNameIsST(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.4 root 57: Uint8 *ST_ReadDisk(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: /**
! 74: * Save .ST file from memory buffer. Returns TRUE is all OK
! 75: */
1.1.1.4 root 76: BOOL ST_WriteDisk(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 */
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.6 ! 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.