mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-08 05:29:40 +00:00
2beb78727f
* Added support for new interfaces syntax * rasctl output update * Added operation parameters * Fixed typo * Manpage update * Added deprecation warning * Moved parser * Updated parser * Updated parameter override * Removed debug code * Made netmask handling more flexible * Updated logging * Logging update * Logging update * Comment update * Removed unused field * Replaced BOOL by bool * Moved code * Logging update * Removed useless comments * Added TODZ * Logging update * Logging update * Logging update * No need to report that an error is an error twice * Removed duplicate logging * Updated error handling * Updated error handling * Fixed typo * Removed magic constant * Fixed 32 bit platform issue * Signature update * Fixed message string * Comment update * Fixed SCSI command opcode * Updated StopPrint * Logging update * Removed obsolete casts * Renaming * Removed duplicate logging * Updated flushing caches * Added FlushCache() method * Reduced visibility * Reduced visibility * Reduced visibility * Code cleanup, removed useless comments * Removed useless comments * Updated error handling * Removed duplicate code * Manpage update
98 lines
2.7 KiB
C++
98 lines
2.7 KiB
C++
//---------------------------------------------------------------------------
|
||
//
|
||
// X68000 EMULATOR "XM6"
|
||
//
|
||
// Copyright (C) 2001-2006 PI.(ytanaka@ipc-tokai.or.jp)
|
||
// Copyright (C) 2014-2020 GIMONS
|
||
//
|
||
// XM6i
|
||
// Copyright (C) 2010-2015 isaki@NetBSD.org
|
||
//
|
||
// Imported sava's Anex86/T98Next image and MO format support patch.
|
||
// Comments translated to english by akuker.
|
||
//
|
||
// [ DiskTrack and DiskCache ]
|
||
//
|
||
//---------------------------------------------------------------------------
|
||
|
||
#pragma once
|
||
|
||
#include "filepath.h"
|
||
|
||
// Number of tracks to cache
|
||
#define CacheMax 16
|
||
|
||
class DiskTrack
|
||
{
|
||
private:
|
||
struct {
|
||
int track; // Track Number
|
||
int size; // Sector Size (8=256, 9=512, 10=1024, 11=2048, 12=4096)
|
||
int sectors; // Number of sectors(<0x100)
|
||
DWORD length; // Data buffer length
|
||
BYTE *buffer; // Data buffer
|
||
BOOL init; // Is it initilized?
|
||
BOOL changed; // Changed flag
|
||
DWORD maplen; // Changed map length
|
||
BOOL *changemap; // Changed map
|
||
BOOL raw; // RAW mode flag
|
||
off_t imgoffset; // Offset to actual data
|
||
} dt;
|
||
|
||
public:
|
||
DiskTrack();
|
||
~DiskTrack();
|
||
|
||
private:
|
||
friend class DiskCache;
|
||
|
||
void Init(int track, int size, int sectors, BOOL raw = FALSE, off_t imgoff = 0);
|
||
bool Load(const Filepath& path);
|
||
bool Save(const Filepath& path);
|
||
|
||
// Read / Write
|
||
bool ReadSector(BYTE *buf, int sec) const; // Sector Read
|
||
bool WriteSector(const BYTE *buf, int sec); // Sector Write
|
||
|
||
int GetTrack() const { return dt.track; } // Get track
|
||
};
|
||
|
||
class DiskCache
|
||
{
|
||
public:
|
||
// Internal data definition
|
||
typedef struct {
|
||
DiskTrack *disktrk; // Disk Track
|
||
DWORD serial; // Serial
|
||
} cache_t;
|
||
|
||
public:
|
||
DiskCache(const Filepath& path, int size, uint32_t blocks, off_t imgoff = 0);
|
||
~DiskCache();
|
||
|
||
void SetRawMode(BOOL raw); // CD-ROM raw mode setting
|
||
|
||
// Access
|
||
bool Save(); // Save and release all
|
||
bool ReadSector(BYTE *buf, int block); // Sector Read
|
||
bool WriteSector(const BYTE *buf, int block); // Sector Write
|
||
bool GetCache(int index, int& track, DWORD& serial) const; // Get cache information
|
||
|
||
private:
|
||
// Internal Management
|
||
void Clear(); // Clear all tracks
|
||
DiskTrack* Assign(int track); // Load track
|
||
bool Load(int index, int track, DiskTrack *disktrk = NULL); // Load track
|
||
void UpdateSerialNumber(); // Update serial number
|
||
|
||
// Internal data
|
||
cache_t cache[CacheMax]; // Cache management
|
||
DWORD serial; // Last serial number
|
||
Filepath sec_path; // Path
|
||
int sec_size; // Sector Size (8=256, 9=512, 10=1024, 11=2048, 12=4096)
|
||
int sec_blocks; // Blocks per sector
|
||
BOOL cd_raw; // CD-ROM RAW mode
|
||
off_t imgoffset; // Offset to actual data
|
||
};
|
||
|