2006-02-25 20:50:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
2010-12-18 20:58:29 +00:00
|
|
|
/*
|
|
|
|
AppleWin : An Apple //e emulator for Windows
|
|
|
|
|
|
|
|
Copyright (C) 1994-1996, Michael O'Brien
|
|
|
|
Copyright (C) 1999-2001, Oliver Schmidt
|
|
|
|
Copyright (C) 2002-2005, Tom Charlesworth
|
|
|
|
Copyright (C) 2006-2010, Tom Charlesworth, Michael Pohoreski
|
|
|
|
|
|
|
|
AppleWin is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
AppleWin is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with AppleWin; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2014-08-14 16:48:38 +00:00
|
|
|
#include "DiskDefs.h"
|
2014-08-14 16:24:03 +00:00
|
|
|
|
2020-11-10 20:33:55 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
|
|
#define RAND_THRESHOLD(num, den) ((RAND_MAX * num) / den)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// RAND_MAX is a massive number which overflows when (* num) is applied above
|
|
|
|
#define RAND_THRESHOLD(num, den) ((RAND_MAX / den) * num)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2010-12-18 20:58:29 +00:00
|
|
|
#define TRACK_DENIBBLIZED_SIZE (16 * 256) // #Sectors x Sector-size
|
|
|
|
|
|
|
|
#define TRACKS_STANDARD 35
|
|
|
|
#define TRACKS_EXTRA 5 // Allow up to a 40-track .dsk image (160KB)
|
|
|
|
#define TRACKS_MAX (TRACKS_STANDARD+TRACKS_EXTRA)
|
|
|
|
|
|
|
|
enum Disk_Status_e
|
|
|
|
{
|
2023-04-28 15:28:49 +00:00
|
|
|
DISK_STATUS_OFF , // motor is off
|
2010-12-18 20:58:29 +00:00
|
|
|
DISK_STATUS_READ ,
|
|
|
|
DISK_STATUS_WRITE,
|
2023-04-28 15:28:49 +00:00
|
|
|
DISK_STATUS_PROT , // NOTE: GetDriveLightStatus() and GetCurrentState() return slightly different states
|
|
|
|
DISK_STATUS_EMPTY, // See: GetCurrentState(); no disk image mounted
|
|
|
|
DISK_STATUS_SPIN , // See: GetCurrentState(), motor has been turned off, spinning before stopping
|
2010-12-18 20:58:29 +00:00
|
|
|
NUM_DISK_STATUS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ImageError_e
|
|
|
|
{
|
|
|
|
eIMAGE_ERROR_NONE,
|
|
|
|
eIMAGE_ERROR_BAD_POINTER,
|
|
|
|
eIMAGE_ERROR_BAD_SIZE,
|
|
|
|
eIMAGE_ERROR_BAD_FILE,
|
|
|
|
eIMAGE_ERROR_UNSUPPORTED,
|
|
|
|
eIMAGE_ERROR_UNSUPPORTED_HDV,
|
|
|
|
eIMAGE_ERROR_GZ,
|
|
|
|
eIMAGE_ERROR_ZIP,
|
|
|
|
eIMAGE_ERROR_REJECTED_MULTI_ZIP,
|
|
|
|
eIMAGE_ERROR_UNABLE_TO_OPEN,
|
|
|
|
eIMAGE_ERROR_UNABLE_TO_OPEN_GZ,
|
|
|
|
eIMAGE_ERROR_UNABLE_TO_OPEN_ZIP,
|
2015-02-13 22:40:53 +00:00
|
|
|
eIMAGE_ERROR_FAILED_TO_GET_PATHNAME,
|
2018-01-14 18:01:22 +00:00
|
|
|
eIMAGE_ERROR_ZEROLENGTH_WRITEPROTECTED,
|
|
|
|
eIMAGE_ERROR_FAILED_TO_INIT_ZEROLENGTH,
|
2010-12-18 20:58:29 +00:00
|
|
|
};
|
2006-03-09 21:40:16 +00:00
|
|
|
|
2015-02-13 22:40:53 +00:00
|
|
|
const int MAX_DISK_IMAGE_NAME = 15;
|
|
|
|
const int MAX_DISK_FULL_NAME = 127;
|
|
|
|
|
2016-10-25 20:09:48 +00:00
|
|
|
struct ImageInfo;
|
2015-02-13 22:40:53 +00:00
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
ImageError_e ImageOpen(const std::string & pszImageFilename, ImageInfo** ppImageInfo, bool* pWriteProtected, const bool bCreateIfNecessary, std::string& strFilenameInZip, const bool bExpectFloppy=true);
|
2020-02-09 21:23:15 +00:00
|
|
|
void ImageClose(ImageInfo* const pImageInfo);
|
2016-10-25 20:09:48 +00:00
|
|
|
BOOL ImageBoot(ImageInfo* const pImageInfo);
|
2006-03-09 21:40:16 +00:00
|
|
|
|
2019-07-05 22:01:19 +00:00
|
|
|
void ImageReadTrack(ImageInfo* const pImageInfo, float phase, LPBYTE pTrackImageBuffer, int* pNibbles, UINT* pBitCount, bool enhanceDisk);
|
|
|
|
void ImageWriteTrack(ImageInfo* const pImageInfo, float phase, LPBYTE pTrackImageBuffer, int nNibbles);
|
2016-10-25 20:09:48 +00:00
|
|
|
bool ImageReadBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer);
|
|
|
|
bool ImageWriteBlock(ImageInfo* const pImageInfo, UINT nBlock, LPBYTE pBlockBuffer);
|
2009-05-29 21:39:13 +00:00
|
|
|
|
2019-07-05 22:01:19 +00:00
|
|
|
UINT ImageGetNumTracks(ImageInfo* const pImageInfo);
|
2016-10-25 20:09:48 +00:00
|
|
|
bool ImageIsMultiFileZip(ImageInfo* const pImageInfo);
|
2019-09-07 08:02:39 +00:00
|
|
|
const std::string & ImageGetPathname(ImageInfo* const pImageInfo);
|
2016-10-25 20:09:48 +00:00
|
|
|
UINT ImageGetImageSize(ImageInfo* const pImageInfo);
|
2019-07-05 22:01:19 +00:00
|
|
|
bool ImageIsWOZ(ImageInfo* const pImageInfo);
|
|
|
|
BYTE ImageGetOptimalBitTiming(ImageInfo* const pImageInfo);
|
|
|
|
UINT ImagePhaseToTrack(ImageInfo* const pImageInfo, const float phase, const bool limit=true);
|
2019-12-31 12:07:45 +00:00
|
|
|
UINT ImageGetMaxNibblesPerTrack(ImageInfo* const pImageInfo);
|
2020-02-22 11:38:25 +00:00
|
|
|
bool ImageIsBootSectorFormatSector13(ImageInfo* const pImageInfo);
|
2015-02-13 22:40:53 +00:00
|
|
|
|
2019-09-07 08:02:39 +00:00
|
|
|
void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pFullName);
|