// 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_t *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_t *buffer, const uint8_t *bytes) { uint32_t sample_count = 0; uint32_t i; uint8_t cksm = 0; uint32_t temp = 0; // silence sample_count += apf_put_samples(buffer, 0, 12000, 0); for (i=0; i