|
|
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.4 ! root 7: ST Disk support.
1.1 root 8: */
1.1.1.4 ! root 9: char ST_rcsid[] = "Hatari $Id: st.c,v 1.5 2005/09/13 01:10:09 thothy Exp $";
1.1 root 10:
11: #include "main.h"
12: #include "file.h"
1.1.1.3 root 13: #include "st.h"
1.1 root 14:
15: #define SAVE_TO_ST_IMAGES
16:
17: /*
18: .ST FILE FORMAT
19: --===============-------------------------------------------------------------
20:
21: The file format of the .ST image files used by PaCifiST is simplicity itself;
22: they are just straight images of the disk in question, with sectors stored in
23: the expected logical order. So, on a sector basis the images run from sector
24: 0 (bootsector) to however many sectors are on the disk. On a track basis the
25: layout is the same as for MSA files but obviously the data is raw, no track
26: header or compression or anything like that.
27:
28: TRACK 0, SIDE 0
29: TRACK 0, SIDE 1
30: TRACK 1, SIDE 0
31: TRACK 1, SIDE 1
32: TRACK 2, SIDE 0
33: TRACK 2, SIDE 1
34: */
35:
36:
1.1.1.2 root 37: /*-----------------------------------------------------------------------*/
1.1 root 38: /*
1.1.1.3 root 39: Does filename end with a .ST extension? If so, return TRUE
1.1 root 40: */
1.1.1.3 root 41: BOOL ST_FileNameIsST(char *pszFileName, BOOL bAllowGZ)
1.1 root 42: {
1.1.1.3 root 43: return(File_DoesFileExtensionMatch(pszFileName,".st")
44: || (bAllowGZ && File_DoesFileExtensionMatch(pszFileName,".st.gz")));
45: }
46:
47:
48: /*-----------------------------------------------------------------------*/
49: /*
50: Load .ST file into memory, set number of bytes loaded and return a pointer
51: to the buffer.
52: */
1.1.1.4 ! root 53: Uint8 *ST_ReadDisk(char *pszFileName, long *pImageSize)
1.1.1.3 root 54: {
55: void *pStFile;
56:
57: *pImageSize = 0;
1.1 root 58:
1.1.1.3 root 59: /* Just load directly a buffer, and set ImageSize accordingly */
60: pStFile = File_Read(pszFileName, NULL, pImageSize, NULL);
61: if (!pStFile)
62: *pImageSize = 0;
1.1 root 63:
1.1.1.3 root 64: return(pStFile);
1.1 root 65: }
66:
1.1.1.2 root 67:
68: /*-----------------------------------------------------------------------*/
1.1 root 69: /*
70: Save .ST file from memory buffer. Returns TRUE is all OK
71: */
1.1.1.4 ! root 72: BOOL ST_WriteDisk(char *pszFileName, Uint8 *pBuffer, int ImageSize)
1.1 root 73: {
74: #ifdef SAVE_TO_ST_IMAGES
75:
1.1.1.3 root 76: /* Just save buffer directly to file */
77: return( File_Save(pszFileName, pBuffer, ImageSize, FALSE) );
1.1 root 78:
1.1.1.2 root 79: #else /*SAVE_TO_ST_IMAGES*/
1.1 root 80:
1.1.1.3 root 81: /* Oops, cannot save */
82: return(FALSE);
1.1 root 83:
1.1.1.2 root 84: #endif /*SAVE_TO_ST_IMAGES*/
1.1 root 85: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.