summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/p2000t_cas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/formats/p2000t_cas.cpp')
-rw-r--r--src/lib/formats/p2000t_cas.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/lib/formats/p2000t_cas.cpp b/src/lib/formats/p2000t_cas.cpp
index e3351dc99dc..7bc0c6b21a9 100644
--- a/src/lib/formats/p2000t_cas.cpp
+++ b/src/lib/formats/p2000t_cas.cpp
@@ -1,12 +1,12 @@
// license:BSD-3-Clause
// copyright-holders:Curt Coder
-#include <cassert>
-
-#include "cassimg.h"
#include "p2000t_cas.h"
+
+#include <cassert>
#include <ostream>
+
// This code will reproduce the timing of a P2000 mini cassette tape.
constexpr double P2000_CLOCK_PERIOD = 0.000084;
constexpr double P2000_BOT_GAP = 1;
@@ -153,10 +153,10 @@ struct P2000T_Header
std::ostream &operator<<(std::ostream &os, P2000T_Header const &hdr)
{
return os << "File: " << std::string(hdr.file_name, 8) << '.'
- << std::string(hdr.ext, 3) << " " << hdr.file_length;
+ << std::string(hdr.ext, 3) << " " << hdr.file_length;
}
-static cassette_image::error p2000t_cas_identify(cassette_image *cass, struct CassetteOptions *opts)
+static cassette_image::error p2000t_cas_identify(cassette_image *cass, cassette_image::Options *opts)
{
opts->bits_per_sample = 32;
opts->channels = 1;
@@ -189,36 +189,36 @@ void update_chksum(uint16_t *de, bool bit)
}
/*
- A transition on a clock boundary from low to high is a 1.
- A transition on a clock boundary from high to low is a 0
- An intermediate transition halfway between the clock boundary
- can occur when there are consecutive 0s or 1s. See the example
- below where the clock is marked by a |
-
-
- 1 0 1 1 0 0
- RDA: _|----|____|--__|----|__--|__--
- RDC: _|-___|-___|-___|-___|-___|-___
- ^ ^
- |-- clock signal |-- intermediate transition.
-
- This signal can be written by a simple algorithm where the first bit
- is always false (transition to low, half clock). Now only one bit is needed
- to determine what the next partial clock should look like.
-
- This works because we are always guaranteed that a block starts with 0xAA,
- and hence will ALWAYS find a signal like this on tape: _-- (low, high, high)
- after a gap. This is guaranteed when the tape is moving forward as well as
- backwards.
+ A transition on a clock boundary from low to high is a 1.
+ A transition on a clock boundary from high to low is a 0
+ An intermediate transition halfway between the clock boundary
+ can occur when there are consecutive 0s or 1s. See the example
+ below where the clock is marked by a |
+
+
+ 1 0 1 1 0 0
+ RDA: _|----|____|--__|----|__--|__--
+ RDC: _|-___|-___|-___|-___|-___|-___
+ ^ ^
+ |-- clock signal |-- intermediate transition.
+
+ This signal can be written by a simple algorithm where the first bit
+ is always false (transition to low, half clock). Now only one bit is needed
+ to determine what the next partial clock should look like.
+
+ This works because we are always guaranteed that a block starts with 0xAA,
+ and hence will ALWAYS find a signal like this on tape: _-- (low, high, high)
+ after a gap. This is guaranteed when the tape is moving forward as well as
+ backwards.
*/
cassette_image::error p2000t_put_bit(cassette_image *cass, double *time_index, bool bit)
{
const int channel = 0;
cassette_image::error err = cassette_image::error::SUCCESS;
- CHR(cassette_put_sample(cass, channel, *time_index, P2000_CLOCK_PERIOD, bit ? P2000_HIGH : P2000_LOW));
+ CHR(cass->put_sample(channel, *time_index, P2000_CLOCK_PERIOD, bit ? P2000_HIGH : P2000_LOW));
*time_index += P2000_CLOCK_PERIOD;
- CHR(cassette_put_sample(cass, channel, *time_index, P2000_CLOCK_PERIOD, bit ? P2000_LOW : P2000_HIGH));
+ CHR(cass->put_sample(channel, *time_index, P2000_CLOCK_PERIOD, bit ? P2000_LOW : P2000_HIGH));
*time_index += P2000_CLOCK_PERIOD;
return err;
}
@@ -251,7 +251,7 @@ cassette_image::error p2000t_silence(cassette_image *cassette,
double *time_index,
double time)
{
- auto err = cassette_put_sample(cassette, 0, *time_index, time, 0);
+ auto err = cassette->put_sample(0, *time_index, time, 0);
*time_index += time;
return err;
}
@@ -259,21 +259,21 @@ double time)
static cassette_image::error p2000t_cas_load(cassette_image *cassette)
{
cassette_image::error err = cassette_image::error::SUCCESS;
- uint64_t image_size = cassette_image_size(cassette);
+ uint64_t image_size = cassette->image_size();
constexpr int CAS_BLOCK = 1280;
/*
- The cas format is pretty simple. it consists of a sequence of blocks,
- where a block consists of the following:
+ The cas format is pretty simple. it consists of a sequence of blocks,
+ where a block consists of the following:
- [0-256] P2000 memory address 0x6000 - 0x6100
- .... Nonsense (keyboard status etc.)
- 0x30 P200T_Header
- 0x50
- ... Nonsense..
- [0-1024] Data block
+ [0-256] P2000 memory address 0x6000 - 0x6100
+ .... Nonsense (keyboard status etc.)
+ 0x30 P200T_Header
+ 0x50
+ ... Nonsense..
+ [0-1024] Data block
- This means that one block gets stored in 1280 bytes.
+ This means that one block gets stored in 1280 bytes.
*/
if (image_size % CAS_BLOCK != 0)
{
@@ -290,7 +290,7 @@ static cassette_image::error p2000t_cas_load(cassette_image *cassette)
for (int i = 0; i < blocks; i++)
{
uint16_t crc = 0, unused = 0;
- cassette_image_read(cassette, &block, CAS_BLOCK * i, CAS_BLOCK);
+ cassette->image_read(&block, CAS_BLOCK * i, CAS_BLOCK);
// Insert sync header.. 0xAA, 0x00, 0x00, 0xAA
CHR(p2000t_silence(cassette, &time_idx, P2000_BOB_GAP));
@@ -312,7 +312,7 @@ static cassette_image::error p2000t_cas_load(cassette_image *cassette)
return p2000t_silence(cassette, &time_idx, P2000_EOT_GAP);
}
-static const struct CassetteFormat p2000t_cas = {
+static const cassette_image::Format p2000t_cas = {
"cas", p2000t_cas_identify, p2000t_cas_load, nullptr /* no save */
};