// license:BSD-3-Clause // copyright-holders:Robbbert /******************************************************************** Support for Exidy Sorcerer cassette images Sorcerer tapes consist of these sections: 1. A high tone whenever idle 2. A header 3. The data, in blocks of 256 bytes plus a CRC byte 4. The last block may be shorter, depending on the number of bytes left to save. Each byte has 1 start bit, 8 data bits (0-7), 2 stop bits. The default speed is 1200 baud, which is what we emulate here. A high bit is 1 cycle of 1200 Hz, while a low bit is half a cycle of 600 Hz. Formats: TAPE - this contains a byte for each real byte, including all the header and leader bytes. ********************************************************************/ #include "sorc_cas.h" #include #define WAVEENTRY_LOW -32768 #define WAVEENTRY_HIGH 32767 #define SORCERER_WAV_FREQUENCY 4788 // image size static int sorcerer_image_size; static bool level; static int sorcerer_put_samples(int16_t *buffer, int sample_pos, int count) { if (buffer) { for (int i=0; i> i) & 1); /* stop */ for (i = 0; i<2; i++) samples += sorcerer_output_bit (buffer, sample_pos + samples, 1); return samples; } static int sorcerer_handle_cassette(int16_t *buffer, const uint8_t *bytes) { uint32_t sample_count = 0; uint32_t i; /* idle */ for (i=0; i<2000; i++) sample_count += sorcerer_output_bit(buffer, sample_count, 1); /* data */ for (i=0; ilegacy_identify(opts, &sorcerer_legacy_fill_wave); } static cassette_image::error sorcerer_cassette_load(cassette_image *cassette) { return cassette->legacy_construct(&sorcerer_legacy_fill_wave); } static const cassette_image::Format sorcerer_cassette_image_format = { "tape", sorcerer_cassette_identify, sorcerer_cassette_load, nullptr }; CASSETTE_FORMATLIST_START(sorcerer_cassette_formats) CASSETTE_FORMAT(sorcerer_cassette_image_format) CASSETTE_FORMATLIST_END