// license:BSD-3-Clause // copyright-holders:Robbbert /******************************************************************** Support for Camputers Lynx cassette images We support TAP files used by the Pale and Jynx emulators. Tape format: - about 7 seconds of zeroes - A5 byte - 22 byte - program name - 22 byte - about 7 seconds of zeroes - A5 byte - header - main program - checksum Each byte is 8 bits (MSB first) with no start or stop bits. ********************************************************************/ #include "emu.h" // for popmessage and #include "camplynx_cas.h" #define WAVEENTRY_LOW -32768 #define WAVEENTRY_HIGH 32767 #define LYNX48K_WAV_FREQUENCY 4000 #define LYNX128K_WAV_FREQUENCY 8000 // image size static int camplynx_image_size; static int camplynx_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 camplynx_handle_cassette(int16_t *buffer, const uint8_t *bytes) { uint32_t sample_count = 0; uint32_t byte_count = 0; uint32_t i; /* header zeroes */ for (i=0; i<555; i++) sample_count += camplynx_output_byte(buffer, sample_count, 0); if (bytes[0] == 0x22) { std::string pgmname = " LOAD \""; byte_count++; sample_count += camplynx_output_byte(buffer, sample_count, 0xA5); sample_count += camplynx_output_byte(buffer, sample_count, 0x22); /* program name - include protection in case tape is corrupt */ for (i=1; bytes[i]!=0x22; i++) { if (i < camplynx_image_size) { sample_count += camplynx_output_byte(buffer, sample_count, bytes[i]); pgmname.append(1, (char)bytes[i]); } else return sample_count; byte_count++; } pgmname.append(1, (char)0x22); sample_count += camplynx_output_byte(buffer, sample_count, bytes[byte_count++]); // should be 0x22 // if a machine-language program, say to use MLOAD if (bytes[byte_count] == 0x4D) pgmname[0] = (char)0x4D; // Tell user how to load the tape osd_printf_info("%s",pgmname.c_str()); /* data zeroes */ for (i=0; i<555; i++) sample_count += camplynx_output_byte(buffer, sample_count, 0); sample_count += camplynx_output_byte(buffer, sample_count, 0xA5); } /* data */ for (i=byte_count; i