VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
TAPFile.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "AnyFile.h"
16
17namespace vc64 {
18
19class TAPFile : public AnyFile {
20
21 // File pointer (used by read() and seek())
22 isize fp = -1;
23
24public:
25
26 //
27 // Class methods
28 //
29
30 static bool isCompatible(const fs::path &path);
31 static bool isCompatible(std::istream &stream);
32
33
34 //
35 // Initializing
36 //
37
38 TAPFile(const fs::path &path) throws { init(path); }
39 TAPFile(const u8 *buf, isize len) throws { init(buf, len); }
40
41
42 //
43 // Methods from CoreObject
44 //
45
46 const char *objectName() const override { return "TAPFile"; }
47
48
49 //
50 // Methods from AnyFile
51 //
52
53 bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
54 bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
55 FileType type() const override { return FILETYPE_TAP; }
56 PETName<16> getName() const override;
57 void finalizeRead() override;
58
59
60 //
61 // Reading
62 //
63
64 // Returns the TAP version (0 = standard layout, 1 = extended layout)
65 TAPVersion version() const { return (TAPVersion)data[0x000C]; }
66
67 // Returns the position of the first pulse byte
68 isize headerSize() const;
69
70 // Returns the number of stored pulses
71 isize numPulses();
72
73 // Sets the file pointer to a specific pulse
74 void seek(isize nr);
75
76 // Reads the next pulse and advances the file pointer
77 isize read();
78};
79
80}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16