From 7c19aac60e12d6f5ea301bdb34d7826a01e0b06f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 8 Nov 2015 12:56:12 +0100 Subject: Rename *.c -> *.cpp in our source (nw) --- src/lib/formats/apf_apt.cpp | 252 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 src/lib/formats/apf_apt.cpp (limited to 'src/lib/formats/apf_apt.cpp') diff --git a/src/lib/formats/apf_apt.cpp b/src/lib/formats/apf_apt.cpp new file mode 100644 index 00000000000..b609a109ef6 --- /dev/null +++ b/src/lib/formats/apf_apt.cpp @@ -0,0 +1,252 @@ +// license:BSD-3-Clause +// copyright-holders: Original author, Robbbert +/******************************************************************** + +Support for APF Imagination Machine cassette images + +CPF and CAS images consist of the screen and then the program, +and are exactly 1E00 bytes in length. + +APT images are much the same, however it includes a series of FF +bytes as a header. There's also a large amount of what seems to +be rubbish at the end. + +APW images are not emulated, and are used by the closed-source +emulator APF_EMUW. Quote: "They allow recording in special formats +and recording audio. They are audio files sampled at 11025 Hz 8 bits +unsigned mono, without header. The bit 1 stores the state of the +recording head." + +S19 images are not emulated, however there's no need to as they +are only used to hold cartridge hex dumps. + +TXT images can be copy/pasted by using the Paste menu option. + +Each byte after conversion becomes bit 7,6,etc to 0, There are +no start or stop bits. + +An actual tape consists of 6 sections +a. silence until you press Enter (no offset) +b. 11secs of high bits then 1 low bit +c. The screen ram +d. The program ram +e. A checksum byte (8-bit addition) + +********************************************************************/ + +#include + +#include "formats/apf_apt.h" + +#define WAVEENTRY_LOW -32768 +#define WAVEENTRY_HIGH 32767 + +/* frequency of wave */ +#define APF_WAV_FREQUENCY 8000 + +/* 500 microsecond of bit 0 and 1000 microsecond of bit 1 */ +static int apf_image_size; + +static int apf_put_samples(INT16 *buffer, int sample_pos, int count, int level) +{ + if (buffer) + { + for (int i=0; i> (7-i)) & 1); + + return samples; +} + +static int apf_apt_handle_cassette(INT16 *buffer, const UINT8 *bytes) +{ + UINT32 sample_count = 0; + UINT32 i; + UINT8 cksm = 0; + UINT32 temp = 0; + + // silence + sample_count += apf_put_samples(buffer, 0, 12000, 0); + + for (i=0; i