Skip to content

Commit

Permalink
File API: tellg() is no longer used (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Aug 31, 2024
1 parent ed1f7a4 commit bdd424e
Show file tree
Hide file tree
Showing 29 changed files with 1 addition and 293 deletions.
11 changes: 0 additions & 11 deletions Emulator/Base/CoreComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,6 @@ CoreComponent::getFallback(Option opt) const
return emulator.defaults.get(opt);
}

void
CoreComponent::routeOption(Option opt, std::vector<Configurable *> &result)
{
for (auto &o : getOptions()) {
if (o == opt) result.push_back(this);
}
for (auto &c : subComponents) {
c->routeOption(opt, result);
}
}

Configurable *
CoreComponent::routeOption(Option opt, isize objid)
{
Expand Down
1 change: 0 additions & 1 deletion Emulator/Base/CoreComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public CoreObject, public Serializable, public Suspendable, public Synchronizabl
virtual void resetConfig();

// Returns the target component for a given configuration option
[[deprecated]] void routeOption(Option opt, std::vector<Configurable *> &result);
Configurable *routeOption(Option opt, isize objid);

// Returns the fallback value for a config option
Expand Down
1 change: 0 additions & 1 deletion Emulator/Media/AnyFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class AnyFile : public CoreObject, public MediaFile {
virtual bool isCompatiblePath(const fs::path &path) = 0;
virtual bool isCompatibleBuffer(const u8 *buf, isize len) = 0;
bool isCompatibleBuffer(const Buffer<u8> &buffer);
[[deprecated]] virtual bool isCompatibleStream(std::istream &stream) = 0;

isize readFromBuffer(const u8 *buf, isize len) throws override;
isize readFromBuffer(const Buffer<u8> &buffer) throws;
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Media/CRTFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ CRTFile::isCompatible(const fs::path &path)
return s == ".CRT";
}

bool
CRTFile::isCompatible(std::istream &stream)
{
return util::matchingStreamHeader(stream, "C64 CARTRIDGE ");
}

bool
CRTFile::isCompatible(const u8 *buf, isize len)
{
Expand Down
2 changes: 0 additions & 2 deletions Emulator/Media/CRTFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class CRTFile : public AnyFile {

static string cartridgeTypeName(CartridgeType type);
static bool isCompatible(const fs::path &path);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

Expand All @@ -69,7 +68,6 @@ class CRTFile : public AnyFile {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_CRT; }
PETName<16> getName() const override;
Expand Down
40 changes: 0 additions & 40 deletions Emulator/Media/Cartridges/CustomCartridges/Reu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,46 +471,6 @@ Reu::processEvent(EventID id)
}
}

void
Reu::stash(isize len)
{
debug(REU_DEBUG, "stash(%x,%x,%ld)\n", c64Addr, reuAddr, len);

// Perform DMA
for (isize i = 0; i < len; i++) doDma(EXP_REU_STASH);
finalizeDma(EXP_REU_STASH);
}

void
Reu::fetch(isize len)
{
debug(REU_DEBUG, "fetch(%x,%x,%ld)\n", c64Addr, reuAddr, len);

// Perform DMA
for (isize i = 0; i < len; i++) doDma(EXP_REU_FETCH);
finalizeDma(EXP_REU_FETCH);
}

void
Reu::swap(isize len)
{
debug(REU_DEBUG, "swap(%x,%x,%ld)\n", c64Addr, reuAddr, len);

// Perform DMA
for (isize i = 0; i < len; i++) doDma(EXP_REU_SWAP);
finalizeDma(EXP_REU_SWAP);
}

void
Reu::verify(isize len)
{
debug(REU_DEBUG, "verify(%x,%x,%ld)\n", c64Addr, reuAddr, len);

// Perform DMA
for (isize i = 0; i < len; i++) if (!doDma(EXP_REU_VERIFY)) break;
finalizeDma(EXP_REU_VERIFY);
}

void
Reu::triggerEndOfBlockIrq()
{
Expand Down
8 changes: 1 addition & 7 deletions Emulator/Media/Cartridges/CustomCartridges/Reu.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,7 @@ class Reu final : public Cartridge {
bool doDma(EventID id);
void finalizeDma(EventID id);

// [[deprecated]] void doDma();
[[deprecated]] void stash(isize len);
[[deprecated]] void fetch(isize len);
[[deprecated]] void swap(isize len);
[[deprecated]] void verify(isize len);



//
// Processing events
//
Expand Down
14 changes: 0 additions & 14 deletions Emulator/Media/D64File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ D64File::isCompatible(const fs::path &path)
return s == ".D64";
}

bool
D64File::isCompatible(std::istream &stream)
{
isize len = util::streamLength(stream);

return
len == D64_683_SECTORS ||
len == D64_683_SECTORS_ECC ||
len == D64_768_SECTORS ||
len == D64_768_SECTORS_ECC ||
len == D64_802_SECTORS ||
len == D64_802_SECTORS_ECC;
}

bool
D64File::isCompatible(const u8 *buf, isize len)
{
Expand Down
2 changes: 0 additions & 2 deletions Emulator/Media/D64File.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class D64File : public AnyFile {
u8 errors[802];

static bool isCompatible(const fs::path &name);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

Expand Down Expand Up @@ -69,7 +68,6 @@ class D64File : public AnyFile {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_D64; }
PETName<16> getName() const override;
Expand Down
1 change: 0 additions & 1 deletion Emulator/Media/Folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Folder : public AnyCollection {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_FOLDER; }

Expand Down
10 changes: 0 additions & 10 deletions Emulator/Media/G64File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ G64File::isCompatible(const fs::path &path)
return s == ".G64";
}

bool
G64File::isCompatible(std::istream &stream)
{
// const u8 magicBytes[] = { 0x47, 0x43, 0x52, 0x2D, 0x31, 0x35, 0x34, 0x31 };
const u8 magicBytes[] = { 'G', 'C', 'R', '-', '1', '5', '4', '1' };

if (util::streamLength(stream) < 0x2AC) return false;
return util::matchingStreamHeader(stream, magicBytes, sizeof(magicBytes));
}

bool
G64File::isCompatible(const u8 *buf, isize len)
{
Expand Down
2 changes: 0 additions & 2 deletions Emulator/Media/G64File.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class G64File : public AnyFile {
//

static bool isCompatible(const fs::path &path);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

Expand Down Expand Up @@ -61,7 +60,6 @@ class G64File : public AnyFile {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_G64; }

Expand Down
9 changes: 0 additions & 9 deletions Emulator/Media/P00File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ P00File::isCompatible(const fs::path &path)
return s == ".P00";
}

bool
P00File::isCompatible(std::istream &stream)
{
const u8 magicBytes[] = { 0x43, 0x36, 0x34, 0x46, 0x69, 0x6C, 0x65 };

if (util::streamLength(stream) < 0x1A) return false;
return util::matchingStreamHeader(stream, magicBytes, sizeof(magicBytes));
}

bool
P00File::isCompatible(const u8 *buf, isize len)
{
Expand Down
2 changes: 0 additions & 2 deletions Emulator/Media/P00File.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class P00File : public AnyCollection {
public:

static bool isCompatible(const fs::path &path);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

Expand Down Expand Up @@ -54,7 +53,6 @@ class P00File : public AnyCollection {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_P00; }
PETName<16> getName() const override;
Expand Down
6 changes: 0 additions & 6 deletions Emulator/Media/PRGFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ PRGFile::isCompatible(const fs::path &path)
return s == ".PRG";
}

bool
PRGFile::isCompatible(std::istream &stream)
{
return (util::streamLength(stream) >= 2);
}

bool
PRGFile::isCompatible(const u8 *buf, isize len)
{
Expand Down
2 changes: 0 additions & 2 deletions Emulator/Media/PRGFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class PRGFile : public AnyCollection {
//

static bool isCompatible(const fs::path &path);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

Expand Down Expand Up @@ -58,7 +57,6 @@ class PRGFile : public AnyCollection {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return FILETYPE_PRG; }

Expand Down
88 changes: 0 additions & 88 deletions Emulator/Media/RomFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ RomFile::isCompatible(const fs::path &path)
return true;
}

bool
RomFile::isCompatible(std::istream &stream)
{
return
isBasicRomStream(stream) ||
isCharRomStream(stream) ||
isKernalRomStream(stream) ||
isVC1541RomStream(stream);
}

bool
RomFile::isCompatible(const u8 *buf, isize len)
{
Expand All @@ -77,84 +67,6 @@ RomFile::isCompatible(const Buffer<u8> &buf)
return isCompatible(buf.ptr, buf.size);
}

bool
RomFile::isRomStream(RomType type, std::istream &is)
{
isize size = util::streamLength(is);

for (isize i = 0; signatures[i].size != 0; i++) {

// Only proceed if the file type matches
if (signatures[i].type != type) continue;

// Only proceed if the file size matches
if (signatures[i].size != size) continue;

// Only proceed if the matches bytes matche
if (!util::matchingStreamHeader(is, signatures[i].magic, 3, signatures[i].offset))
continue;

return true;
}

return false;
}

bool
RomFile::isBasicRomStream(std::istream &is)
{
return isRomStream(ROM_TYPE_BASIC, is);
}

bool
RomFile::isCharRomStream(std::istream &is)
{
return isRomStream(ROM_TYPE_CHAR, is);
}

bool
RomFile::isKernalRomStream(std::istream &is)
{
return isRomStream(ROM_TYPE_KERNAL, is);
}

bool
RomFile::isVC1541RomStream(std::istream &is)
{
return isRomStream(ROM_TYPE_VC1541, is);
}

bool
RomFile::isRomFile(RomType type, const fs::path &path)
{
std::ifstream stream(path);
return isRomStream(type, stream);
}

bool
RomFile::isBasicRomFile(const fs::path &path)
{
return isRomFile(ROM_TYPE_BASIC, path);
}

bool
RomFile::isCharRomFile(const fs::path &path)
{
return isRomFile(ROM_TYPE_CHAR, path);
}

bool
RomFile::isKernalRomFile(const fs::path &path)
{
return isRomFile(ROM_TYPE_KERNAL, path);
}

bool
RomFile::isVC1541RomFile(const fs::path &path)
{
return isRomFile(ROM_TYPE_VC1541, path);
}

bool
RomFile::isRomBuffer(RomType type, const u8 *buf, isize len)
{
Expand Down
14 changes: 0 additions & 14 deletions Emulator/Media/RomFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,9 @@ class RomFile : public AnyFile {
//

static bool isCompatible(const fs::path &name);
[[deprecated]] static bool isCompatible(std::istream &stream);
static bool isCompatible(const u8 *buf, isize len);
static bool isCompatible(const Buffer<u8> &buffer);

[[deprecated]] static bool isRomStream(RomType type, std::istream &stream);
[[deprecated]] static bool isBasicRomStream(std::istream &stream);
[[deprecated]] static bool isCharRomStream(std::istream &stream);
[[deprecated]] static bool isKernalRomStream(std::istream &stream);
[[deprecated]] static bool isVC1541RomStream(std::istream &stream);

[[deprecated]] static bool isRomFile(RomType type, const fs::path &path);
[[deprecated]] static bool isBasicRomFile(const fs::path &path);
[[deprecated]] static bool isCharRomFile(const fs::path &path);
[[deprecated]] static bool isKernalRomFile(const fs::path &path);
[[deprecated]] static bool isVC1541RomFile(const fs::path &path);

static bool isRomBuffer(RomType type, const u8 *buf, isize len);
static bool isBasicRomBuffer(const u8 *buf, isize len);
static bool isCharRomBuffer(const u8 *buf, isize len);
Expand Down Expand Up @@ -87,7 +74,6 @@ class RomFile : public AnyFile {
//

bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
[[deprecated]] bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
bool isCompatibleBuffer(const u8 *buf, isize len) override { return isCompatible(buf, len); }
FileType type() const override { return romFileType; }
void finalizeRead() override;
Expand Down
Loading

0 comments on commit bdd424e

Please sign in to comment.