project64/Source/Project64-core/N64System/N64DiskClass.h

75 lines
2.9 KiB
C
Raw Normal View History

/****************************************************************************
* *
* Project64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#include <Project64-core/N64System/N64Types.h>
#include <Common/stdtypes.h>
class CN64Disk
{
public:
2016-01-20 13:31:29 +00:00
CN64Disk();
~CN64Disk();
2016-01-20 13:31:29 +00:00
bool LoadDiskImage(const char * FileLoc);
bool SaveDiskImage();
void SwapDiskImage(const char * FileLoc);
2016-01-20 13:31:29 +00:00
static bool IsValidDiskImage(uint8_t Test[4]);
2019-01-25 20:32:26 +00:00
void SaveDiskSettingID(bool temp);
void ClearDiskSettingID();
2016-01-20 13:31:29 +00:00
uint8_t * GetDiskAddress() { return m_DiskImage; }
2016-01-20 16:43:23 +00:00
uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; }
uint8_t * GetDiskHeader() { return m_DiskHeader; }
2016-01-20 16:43:23 +00:00
void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; }
2019-01-25 20:32:26 +00:00
stdstr GetRomName() const { return m_RomName; }
stdstr GetFileName() const { return m_FileName; }
stdstr GetDiskIdent() const { return m_DiskIdent; }
Country GetCountry() const { return m_Country; }
2016-01-20 13:31:29 +00:00
void UnallocateDiskImage();
2016-01-20 16:43:23 +00:00
LanguageStringID GetError() const { return m_ErrorMsg; }
private:
2016-01-20 13:31:29 +00:00
bool AllocateDiskImage(uint32_t DiskFileSize);
bool AllocateDiskHeader();
2016-01-20 13:31:29 +00:00
bool AllocateAndLoadDiskImage(const char * FileLoc);
void ByteSwapDisk();
void ForceByteSwapDisk();
2016-01-20 13:31:29 +00:00
void SetError(LanguageStringID ErrorMsg);
void ConvertDiskFormat();
void ConvertDiskFormatBack();
2016-01-20 13:31:29 +00:00
//constant values
enum { ReadFromRomSection = 0x400000, MameFormatSize = 0x0435B0C0, SDKFormatSize = 0x03DEC800,
DiskFormatMAME = 0x0, DiskFormatSDK = 0x1 };
2016-01-20 13:31:29 +00:00
//class variables
CFile m_DiskFile;
uint8_t * m_DiskImage;
uint8_t * m_DiskImageBase;
uint8_t * m_DiskHeader;
uint8_t * m_DiskHeaderBase;
2016-01-20 13:31:29 +00:00
uint32_t m_DiskFileSize;
2016-01-20 16:43:23 +00:00
uint32_t m_DiskBufAddress;
2016-01-20 13:31:29 +00:00
LanguageStringID m_ErrorMsg;
2019-01-25 20:32:26 +00:00
Country m_Country;
stdstr m_RomName, m_FileName, m_DiskIdent;
uint8_t m_DiskFormat; //0 = MAME, 1 = SDK
//disk convert
#define SECTORS_PER_BLOCK 85
#define BLOCKS_PER_TRACK 2
#define BLOCKSIZE(_zone) ZoneSecSize[_zone] * SECTORS_PER_BLOCK
#define TRACKSIZE(_zone) BLOCKSIZE(_zone) * BLOCKS_PER_TRACK
#define ZONESIZE(_zone) TRACKSIZE(_zone) * ZoneTracks[_zone]
#define VZONESIZE(_zone) TRACKSIZE(_zone) * (ZoneTracks[_zone] - 0xC)
};