mirror of
https://github.com/akuker/RASCSI.git
synced 2025-08-10 05:24:58 +00:00
* Fixing SonarCloud issues, first round * Fixing SonarCLoud issues, next round * Fixing SonarQube issues, next round * Fixed warning * Replaced empty constructors/destructors with = default; * Fixed warning * Replaced new * Use constants instead of macros * Use structured binding declarations * Use init statements for if * Use string views * Use enum class, use using instead of typedef * Fixed more SonarCloud warnings * Replaced redundant/duplicate types with auto * Devlared methods const * Memory management update * Fixed warning * Added missing const * Improved RaScsiResponse memory management * Improved memory management * Improved memory management * Replaced macros by constants, removed unused constants * Made member private * Fixed warning * Added comment * Fixed shadowing warnings * Cleanup * Cleanup * Cleanup * Fixed shadowing warning * Removed unused code * Fixed more warnings * Removed obsolete casts * Fixed warnings * Removed unused field * Removed library not needed by rasctl * Include cleanup * Updated platform check for better compatibility * Improved check for invalid option. This prevents rasctl to break on macos. * Updated option check * Fixed typo * Added TODO * Removed macro * Scope update * Replaced macro * Added TODO, update memory management * Fixed typo * Replaced NULL by nullptr * Use more structured bindings * Added TODO * Use calloc instead of mallco to not need memset * Fixed warnings * Fixed SonarQube initialization issues * Fixed warning * Cleaned up override/virtual/final * Fixed warnings * Constructor update * Fixed tests * Improved memory management * Added missing const * Added const * Fixed two bugs reported by SonarCloud * Fix SonarCloud hotspot * Fixed memory management * Memory management update * Addressing hotspot by using strncpy * Fixed SonarCloud issues * Fixed SonarQube issues * Added missing const * Added const * Added const * Suppress false positive * Added SonarQube suppressions for false positives * Added suppresoin * Fixed code smells * Reverted changes that is a SonarQube issue, but caused problems with -O3 * Removed TODO based on review
97 lines
2.7 KiB
C++
97 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
|
||
static const int CACHE_MAX = 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
|
||
using cache_t = struct {
|
||
DiskTrack *disktrk; // Disk Track
|
||
DWORD serial; // Serial
|
||
};
|
||
|
||
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 = nullptr); // Load track
|
||
void UpdateSerialNumber(); // Update serial number
|
||
|
||
// Internal data
|
||
cache_t cache[CACHE_MAX]; // 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
|
||
};
|
||
|