Annotation of hatari/src/st.c, revision 1.1.1.12

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"
1.1.1.12! root       28: #include "floppy.h"
1.1.1.6   root       29: #include "st.h"
                     30: 
                     31: #define SAVE_TO_ST_IMAGES
                     32: 
                     33: 
                     34: #if defined(__riscos)
                     35: /* The following two lines are required on RISC OS for preventing it from
                     36:  * interfering with the .ST image files: */
                     37: #include <unixlib/local.h>
                     38: int __feature_imagefs_is_file = 1;
                     39: #endif
1.1       root       40: 
                     41: 
1.1.1.2   root       42: /*-----------------------------------------------------------------------*/
1.1.1.6   root       43: /**
1.1.1.9   root       44:  * Does filename end with a .ST extension? If so, return true.
1.1.1.6   root       45:  */
1.1.1.10  root       46: bool ST_FileNameIsST(const char *pszFileName, bool bAllowGZ)
1.1       root       47: {
1.1.1.3   root       48:        return(File_DoesFileExtensionMatch(pszFileName,".st")
                     49:               || (bAllowGZ && File_DoesFileExtensionMatch(pszFileName,".st.gz")));
                     50: }
                     51: 
                     52: 
                     53: /*-----------------------------------------------------------------------*/
1.1.1.6   root       54: /**
                     55:  * Load .ST file into memory, set number of bytes loaded and return a pointer
                     56:  * to the buffer.
                     57:  */
1.1.1.12! root       58: Uint8 *ST_ReadDisk(int Drive, const char *pszFileName, long *pImageSize, int *pImageType)
1.1.1.3   root       59: {
1.1.1.6   root       60:        Uint8 *pStFile;
1.1.1.3   root       61: 
                     62:        *pImageSize = 0;
1.1       root       63: 
1.1.1.3   root       64:        /* Just load directly a buffer, and set ImageSize accordingly */
1.1.1.6   root       65:        pStFile = File_Read(pszFileName, pImageSize, NULL);
1.1.1.3   root       66:        if (!pStFile)
1.1.1.12! root       67:        {
1.1.1.3   root       68:                *pImageSize = 0;
1.1.1.12! root       69:                return NULL;
        !            70:        }
1.1       root       71: 
1.1.1.12! root       72:        *pImageType = FLOPPY_IMAGE_TYPE_ST;
1.1.1.6   root       73:        return pStFile;
1.1       root       74: }
                     75: 
1.1.1.2   root       76: 
                     77: /*-----------------------------------------------------------------------*/
1.1.1.6   root       78: /**
1.1.1.9   root       79:  * Save .ST file from memory buffer. Returns true is all OK.
1.1.1.6   root       80:  */
1.1.1.12! root       81: bool ST_WriteDisk(int Drive, const char *pszFileName, Uint8 *pBuffer, int ImageSize)
1.1       root       82: {
                     83: #ifdef SAVE_TO_ST_IMAGES
                     84: 
1.1.1.3   root       85:        /* Just save buffer directly to file */
1.1.1.9   root       86:        return File_Save(pszFileName, pBuffer, ImageSize, false);
1.1       root       87: 
1.1.1.2   root       88: #else   /*SAVE_TO_ST_IMAGES*/
1.1       root       89: 
1.1.1.3   root       90:        /* Oops, cannot save */
1.1.1.9   root       91:        return false;
1.1       root       92: 
1.1.1.2   root       93: #endif  /*SAVE_TO_ST_IMAGES*/
1.1       root       94: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.