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

56 lines
2.2 KiB
C++

/****************************************************************************
* *
* 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 <Common/stdtypes.h>
class CN64Disk
{
public:
CN64Disk();
~CN64Disk();
bool LoadDiskImage(const char * FileLoc);
static bool IsValidDiskImage(uint8_t Test[4]);
uint8_t * GetDiskAddress() { return m_DiskImage; }
uint8_t * GetDiskAddressBuffer() { return m_DiskImage + m_DiskBufAddress; }
void SetDiskAddressBuffer(uint32_t address) { m_DiskBufAddress = address; }
void UnallocateDiskImage();
LanguageStringID GetError() const { return m_ErrorMsg; }
private:
bool AllocateDiskImage(uint32_t DiskFileSize);
bool AllocateAndLoadDiskImage(const char * FileLoc);
void ByteSwapDisk();
void SetError(LanguageStringID ErrorMsg);
void ConvertDiskFormat();
//constant values
enum { ReadFromRomSection = 0x400000, MameFormatSize = 0x0435B0C0, SDKFormatSize = 0x03DEC800 };
//class variables
CFile m_DiskFile;
uint8_t * m_DiskImage;
uint8_t * m_DiskImageBase;
uint32_t m_DiskFileSize;
uint32_t m_DiskBufAddress;
LanguageStringID m_ErrorMsg;
stdstr m_FileName, m_DiskIdent;
//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)
};