mirror of
https://github.com/holub/mame
synced 2025-05-17 11:15:06 +03:00
formats/cassimg.cpp: Pass byte count to wave fill function for legacy cassette formats. (#13294)
formats/tzx_cass.cpp: Check length of data read for TAP format blocks (fixes MT08952).
This commit is contained in:
parent
bbb45dfa64
commit
0855e13672
@ -120,7 +120,7 @@ static int a26_cas_do_work( int16_t **buffer, const uint8_t *bytes ) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int a26_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int a26_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
|
|
||||||
return a26_cas_do_work( &p, (const uint8_t *)bytes );
|
return a26_cas_do_work( &p, (const uint8_t *)bytes );
|
||||||
|
@ -135,7 +135,7 @@ static int ace_handle_tap(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int ace_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int ace_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return ace_handle_tap( buffer, bytes );
|
return ace_handle_tap( buffer, bytes );
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,12 @@ static int apf_cpf_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int apf_apt_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int apf_apt_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return apf_apt_handle_cassette(buffer, bytes);
|
return apf_apt_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int apf_cpf_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int apf_cpf_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return apf_cpf_handle_cassette(buffer, bytes);
|
return apf_cpf_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ static int camplynx_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int camplynx_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int camplynx_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return camplynx_handle_cassette(buffer, bytes);
|
return camplynx_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -859,7 +859,7 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
|
|||||||
/* if there has to be a header */
|
/* if there has to be a header */
|
||||||
if (args.header_samples > 0)
|
if (args.header_samples > 0)
|
||||||
{
|
{
|
||||||
length = args.fill_wave(&samples[pos], sample_count - pos, CODE_HEADER);
|
length = args.fill_wave(&samples[pos], sample_count - pos, CODE_HEADER, -1);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
err = error::INVALID_IMAGE;
|
err = error::INVALID_IMAGE;
|
||||||
@ -877,20 +877,11 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
|
|||||||
}
|
}
|
||||||
while ((pos < sample_count) && (offset < size))
|
while ((pos < sample_count) && (offset < size))
|
||||||
{
|
{
|
||||||
image_read(chunk.get(), offset, args.chunk_size);
|
const int slice = std::min<int>(args.chunk_size, size - offset);
|
||||||
offset += args.chunk_size;
|
image_read(chunk.get(), offset, slice);
|
||||||
|
offset += slice;
|
||||||
|
|
||||||
/*
|
length = args.fill_wave(&samples[pos], sample_count - pos, chunk.get(), slice);
|
||||||
This approach is problematic because we don't have control on incomming image size when processing the data
|
|
||||||
(at least in tap implementation).
|
|
||||||
The method sending the size of output (calculated in 'chunk_sample_calc' above) which uses same data as a input but
|
|
||||||
without knowing how much data available in the image. Having wrong header with size bigger than image couses illegal
|
|
||||||
access beyond image data.
|
|
||||||
Desired state is:
|
|
||||||
length = args.fill_wave(&samples[pos], args.chunk_size, chunk.get());
|
|
||||||
aslo the fix for tap is commented out in 'tap_cas_fill_wave'
|
|
||||||
*/
|
|
||||||
length = args.fill_wave(&samples[pos], sample_count - pos, chunk.get());
|
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
err = error::INVALID_IMAGE;
|
err = error::INVALID_IMAGE;
|
||||||
@ -905,7 +896,7 @@ cassette_image::error cassette_image::legacy_construct(const LegacyWaveFiller *l
|
|||||||
/* if there has to be a trailer */
|
/* if there has to be a trailer */
|
||||||
if (args.trailer_samples > 0)
|
if (args.trailer_samples > 0)
|
||||||
{
|
{
|
||||||
length = args.fill_wave(&samples[pos], sample_count - pos, CODE_TRAILER);
|
length = args.fill_wave(&samples[pos], sample_count - pos, CODE_TRAILER, -1);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
err = error::INVALID_IMAGE;
|
err = error::INVALID_IMAGE;
|
||||||
|
@ -120,7 +120,7 @@ public:
|
|||||||
/* code to adapt existing legacy fill_wave functions */
|
/* code to adapt existing legacy fill_wave functions */
|
||||||
struct LegacyWaveFiller
|
struct LegacyWaveFiller
|
||||||
{
|
{
|
||||||
int (*fill_wave)(int16_t *, int, const uint8_t *) = nullptr;
|
int (*fill_wave)(int16_t *, int, const uint8_t *, int) = nullptr;
|
||||||
int chunk_size = 0;
|
int chunk_size = 0;
|
||||||
int chunk_samples = 0;
|
int chunk_samples = 0;
|
||||||
int (*chunk_sample_calc)(const uint8_t *bytes, int length) = nullptr;
|
int (*chunk_sample_calc)(const uint8_t *bytes, int length) = nullptr;
|
||||||
|
@ -330,7 +330,7 @@ static int cbm_tap_to_wav_size( const uint8_t *tapdata, int taplen )
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cbm_tap_fill_wave( int16_t *buffer, int length, const uint8_t *bytes )
|
static int cbm_tap_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int )
|
||||||
{
|
{
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ static int cgenie_handle_cas(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int cgenie_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int cgenie_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return cgenie_handle_cas(buffer, bytes);
|
return cgenie_handle_cas(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ static int fc100_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int fc100_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int fc100_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return fc100_handle_cassette(buffer, bytes);
|
return fc100_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ static int fm7_cas_to_wav_size (const uint8_t *casdata, int caslen)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int fm7_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int fm7_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return fm7_handle_t77(buffer,bytes);
|
return fm7_handle_t77(buffer,bytes);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ static int fmsx_cas_to_wav_size (const uint8_t *casdata, int caslen)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int fmsx_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int fmsx_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int cas_pos, bit, state = 1, samples_pos, size, n, i, p;
|
int cas_pos, bit, state = 1, samples_pos, size, n, i, p;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ static int gtp_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gtp_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int gtp_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i,size,n;
|
int i,size,n;
|
||||||
size = 0;
|
size = 0;
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -203,7 +203,7 @@ static int hector_handle_forth_tap(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int hector_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int hector_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return hector_handle_tap( buffer, bytes );
|
return hector_handle_tap( buffer, bytes );
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ static int hector_tap_forth_to_wav_size(const uint8_t *casdata, int caslen)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image FORTH
|
Generate samples for the tape image FORTH
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int hector_tap_forth_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int hector_tap_forth_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return hector_handle_forth_tap( buffer, bytes ); //forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
return hector_handle_forth_tap( buffer, bytes ); //forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ static int kc_handle_sss(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int kc_kcc_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int kc_kcc_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return kc_handle_kcc(buffer, bytes);
|
return kc_handle_kcc(buffer, bytes);
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ static const cassette_image::Format kc_kcc_format =
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int kc_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int kc_tap_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return kc_handle_tap(buffer, bytes);
|
return kc_handle_tap(buffer, bytes);
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ static const cassette_image::Format kc_tap_format =
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int kc_sss_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int kc_sss_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return kc_handle_sss(buffer, bytes);
|
return kc_handle_sss(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ static int kim1_handle_kim(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int kim1_kim_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int kim1_kim_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return kim1_handle_kim( buffer, bytes );
|
return kim1_handle_kim( buffer, bytes );
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ static int lviv_cassette_calculate_size_in_samples(const uint8_t *bytes, int len
|
|||||||
|
|
||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
static int lviv_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int lviv_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ static int mbee_handle_tap(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int mbee_tap_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int mbee_tap_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return mbee_handle_tap(buffer, bytes);
|
return mbee_handle_tap(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ static int fill_wave_b(int16_t *buffer, int offs, int byte)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fill_wave(int16_t *buffer, int length, const uint8_t *code)
|
static int fill_wave(int16_t *buffer, int length, const uint8_t *code, int)
|
||||||
{
|
{
|
||||||
static int16_t *beg;
|
static int16_t *beg;
|
||||||
static uint16_t csum = 0;
|
static uint16_t csum = 0;
|
||||||
|
@ -62,7 +62,7 @@ static int orao_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int orao_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int orao_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i,j,size,k;
|
int i,j,size,k;
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
@ -345,7 +345,7 @@ static int oric_cassette_calculate_size_in_samples(const uint8_t *bytes, int len
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* length is length of sample buffer to fill! */
|
/* length is length of sample buffer to fill! */
|
||||||
static int oric_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int oric_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
unsigned char header[9];
|
unsigned char header[9];
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
|
@ -53,7 +53,7 @@ static int pc6001_cas_to_wav_size (const uint8_t *casdata, int caslen)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int pc6001_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int pc6001_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return pc6001_handle_cas(buffer,bytes);
|
return pc6001_handle_cas(buffer,bytes);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ static int phc25_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int phc25_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int phc25_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return phc25_handle_cassette(buffer, bytes);
|
return phc25_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ static int pmd85_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int pmd85_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int pmd85_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return pmd85_handle_cassette(buffer, bytes);
|
return pmd85_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ static int primo_cassette_calculate_size_in_samples(const uint8_t *bytes, int le
|
|||||||
return size_in_samples;
|
return size_in_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int primo_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int primo_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int i = 0, j = 0, k;
|
int i = 0, j = 0, k;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ static int gam_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
|
|||||||
return (RK_HEADER_LEN * 8 * 2 + caslen * 8 * 2) * RK_SIZE_20;
|
return (RK_HEADER_LEN * 8 * 2 + caslen * 8 * 2) * RK_SIZE_20;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rk20_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int rk20_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i;
|
int i;
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ static int rk20_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes
|
|||||||
return p - buffer;
|
return p - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rk22_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int rk22_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i;
|
int i;
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ static int rk22_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes
|
|||||||
return p - buffer;
|
return p - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rk60_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int rk60_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i;
|
int i;
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ static int rk60_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes
|
|||||||
return p - buffer;
|
return p - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gam_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes ) {
|
static int gam_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int ) {
|
||||||
int i;
|
int i;
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ static int sol20_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int sol20_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int sol20_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return sol20_handle_cassette(buffer, bytes);
|
return sol20_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ static int sorcerer_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int sorcerer_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int sorcerer_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return sorcerer_handle_cassette(buffer, bytes);
|
return sorcerer_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,12 @@ static int spc1000_handle_cas(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int spc1000_tap_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int spc1000_tap_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return spc1000_handle_tap(buffer, bytes);
|
return spc1000_handle_tap(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spc1000_cas_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int spc1000_cas_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return spc1000_handle_cas(buffer, bytes);
|
return spc1000_handle_cas(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ static int cas_size; // FIXME: global variable prevents multiple instances
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int svi_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int svi_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int cas_pos, samples_pos, n, i;
|
int cas_pos, samples_pos, n, i;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ static int trs80m3_handle_cas(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int trs80_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int trs80_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
if (cas_size && (bytes[0] == 0x55))
|
if (cas_size && (bytes[0] == 0x55))
|
||||||
return trs80m3_handle_cas( buffer, bytes );
|
return trs80m3_handle_cas( buffer, bytes );
|
||||||
|
@ -786,7 +786,7 @@ cleanup:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tzx_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes )
|
static int tzx_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int )
|
||||||
{
|
{
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@ -795,7 +795,7 @@ static int tzx_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cdt_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes )
|
static int cdt_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int )
|
||||||
{
|
{
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@ -853,26 +853,25 @@ static int tap_cas_to_wav_size(const uint8_t *casdata, int caslen)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tap_cas_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int tap_cas_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int bytes_length)
|
||||||
{
|
{
|
||||||
int16_t *p = buffer;
|
int16_t *p = buffer;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
//while (length > 0)
|
while (bytes_length > 2)
|
||||||
while (size < length)
|
|
||||||
{
|
{
|
||||||
int data_size = get_u16le(&bytes[0]);
|
int data_size = get_u16le(&bytes[0]);
|
||||||
bytes += 2;
|
bytes += 2;
|
||||||
|
bytes_length -= 2;
|
||||||
|
|
||||||
|
LOG_FORMATS("tap_cas_fill_wave: Handling TAP block containing 0x%X bytes\n", data_size);
|
||||||
|
if (bytes_length < data_size)
|
||||||
|
{
|
||||||
|
data_size = bytes_length; // Take as much as we can.
|
||||||
|
}
|
||||||
|
bytes_length -= data_size;
|
||||||
|
|
||||||
int pilot_length = (bytes[0] == 0x00) ? 8063 : 3223;
|
int pilot_length = (bytes[0] == 0x00) ? 8063 : 3223;
|
||||||
LOG_FORMATS("tap_cas_fill_wave: Handling TAP block containing 0x%X bytes\n", data_size);
|
|
||||||
/*
|
|
||||||
length -= data_size;
|
|
||||||
if (length < 0)
|
|
||||||
{
|
|
||||||
data_size += length; // Take as much as we can.
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
size += tzx_cas_handle_block(&p, bytes, 1000, data_size, 2168, pilot_length, 667, 735, 855, 1710, 8);
|
size += tzx_cas_handle_block(&p, bytes, 1000, data_size, 2168, pilot_length, 667, 735, 855, 1710, 8);
|
||||||
bytes += data_size;
|
bytes += data_size;
|
||||||
}
|
}
|
||||||
@ -881,35 +880,35 @@ static int tap_cas_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
|||||||
|
|
||||||
static const cassette_image::LegacyWaveFiller tzx_legacy_fill_wave =
|
static const cassette_image::LegacyWaveFiller tzx_legacy_fill_wave =
|
||||||
{
|
{
|
||||||
tzx_cas_fill_wave, /* fill_wave */
|
tzx_cas_fill_wave, // fill_wave
|
||||||
-1, /* chunk_size */
|
-1, // chunk_size
|
||||||
0, /* chunk_samples */
|
0, // chunk_samples
|
||||||
tzx_cas_to_wav_size, /* chunk_sample_calc */
|
tzx_cas_to_wav_size, // chunk_sample_calc
|
||||||
TZX_WAV_FREQUENCY, /* sample_frequency */
|
TZX_WAV_FREQUENCY, // sample_frequency
|
||||||
0, /* header_samples */
|
0, // header_samples
|
||||||
0 /* trailer_samples */
|
0, // trailer_samples
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cassette_image::LegacyWaveFiller tap_legacy_fill_wave =
|
static const cassette_image::LegacyWaveFiller tap_legacy_fill_wave =
|
||||||
{
|
{
|
||||||
tap_cas_fill_wave, /* fill_wave */
|
tap_cas_fill_wave, // fill_wave
|
||||||
-1, /* chunk_size */
|
-1, // chunk_size
|
||||||
0, /* chunk_samples */
|
0, // chunk_samples
|
||||||
tap_cas_to_wav_size, /* chunk_sample_calc */
|
tap_cas_to_wav_size, // chunk_sample_calc
|
||||||
TZX_WAV_FREQUENCY, /* sample_frequency */
|
TZX_WAV_FREQUENCY, // sample_frequency
|
||||||
0, /* header_samples */
|
0, // header_samples
|
||||||
0 /* trailer_samples */
|
0 // trailer_samples
|
||||||
};
|
};
|
||||||
|
|
||||||
static const cassette_image::LegacyWaveFiller cdt_legacy_fill_wave =
|
static const cassette_image::LegacyWaveFiller cdt_legacy_fill_wave =
|
||||||
{
|
{
|
||||||
cdt_cas_fill_wave, /* fill_wave */
|
cdt_cas_fill_wave, // fill_wave
|
||||||
-1, /* chunk_size */
|
-1, // chunk_size
|
||||||
0, /* chunk_samples */
|
0, // chunk_samples
|
||||||
tzx_cas_to_wav_size, /* chunk_sample_calc */
|
tzx_cas_to_wav_size, // chunk_sample_calc
|
||||||
TZX_WAV_FREQUENCY, /* sample_frequency */
|
TZX_WAV_FREQUENCY, // sample_frequency
|
||||||
0, /* header_samples */
|
0, // header_samples
|
||||||
0 /* trailer_samples */
|
0 // trailer_samples
|
||||||
};
|
};
|
||||||
|
|
||||||
static cassette_image::error tzx_cassette_identify( cassette_image *cassette, cassette_image::Options *opts )
|
static cassette_image::error tzx_cassette_identify( cassette_image *cassette, cassette_image::Options *opts )
|
||||||
|
@ -247,7 +247,7 @@ static int16_t* uef_cas_fill_bit( uint8_t loops, int16_t *buffer, bool bit )
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uef_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes )
|
static int uef_cas_fill_wave( int16_t *buffer, int length, const uint8_t *bytes, int )
|
||||||
{
|
{
|
||||||
if ( bytes[0] == 0x1f && bytes[1] == 0x8b ) {
|
if ( bytes[0] == 0x1f && bytes[1] == 0x8b ) {
|
||||||
if ( gz_ptr == nullptr ) {
|
if ( gz_ptr == nullptr ) {
|
||||||
|
@ -184,7 +184,7 @@ static int vg5k_handle_tap(int16_t *buffer, const uint8_t *casdata)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int vg5k_k7_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int vg5k_k7_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return vg5k_handle_tap(buffer, bytes);
|
return vg5k_handle_tap(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ static int16_t *vtech1_fill_wave_byte(int16_t *buffer, int byte)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vtech1_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *code)
|
static int vtech1_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *code, int)
|
||||||
{
|
{
|
||||||
return generic_fill_wave(buffer, length, code, V1_BITSAMPLES, V1_BYTESAMPLES, V1_LO, vtech1_fill_wave_byte);
|
return generic_fill_wave(buffer, length, code, V1_BITSAMPLES, V1_BYTESAMPLES, V1_LO, vtech1_fill_wave_byte);
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ static int16_t *vtech2_fill_wave_byte(int16_t *buffer, int byte)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vtech2_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *code)
|
static int vtech2_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *code, int)
|
||||||
{
|
{
|
||||||
return generic_fill_wave(buffer, length, code, VT2_BITSAMPLES, VT2_BYTESAMPLES, VT2_LO, vtech2_fill_wave_byte);
|
return generic_fill_wave(buffer, length, code, VT2_BITSAMPLES, VT2_BYTESAMPLES, VT2_LO, vtech2_fill_wave_byte);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ static int x07_handle_cassette(int16_t *buffer, const uint8_t *bytes)
|
|||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
static int x07_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int x07_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return x07_handle_cassette(buffer, bytes);
|
return x07_handle_cassette(buffer, bytes);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ static int x1_cas_to_wav_size (const uint8_t *casdata, int caslen)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Generate samples for the tape image
|
Generate samples for the tape image
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static int x1_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes)
|
static int x1_cas_fill_wave(int16_t *buffer, int sample_count, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
return x1_handle_tap(buffer,bytes);
|
return x1_handle_tap(buffer,bytes);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ static int zx81_cassette_calculate_size_in_samples(const uint8_t *bytes, int len
|
|||||||
return (number_of_0_data+number_of_0_name)*ZX81_LOW_BIT_LENGTH + (number_of_1_data+number_of_1_name)*ZX81_HIGH_BIT_LENGTH + ZX81_PILOT_LENGTH;
|
return (number_of_0_data+number_of_0_name)*ZX81_LOW_BIT_LENGTH + (number_of_1_data+number_of_1_name)*ZX81_HIGH_BIT_LENGTH + ZX81_PILOT_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zx81_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int zx81_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
int i;
|
int i;
|
||||||
@ -250,7 +250,7 @@ static int zx80_cassette_calculate_size_in_samples(const uint8_t *bytes, int len
|
|||||||
return number_of_0_data*ZX81_LOW_BIT_LENGTH + number_of_1_data*ZX81_HIGH_BIT_LENGTH + ZX81_PILOT_LENGTH;
|
return number_of_0_data*ZX81_LOW_BIT_LENGTH + number_of_1_data*ZX81_HIGH_BIT_LENGTH + ZX81_PILOT_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zx80_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes)
|
static int zx80_cassette_fill_wave(int16_t *buffer, int length, const uint8_t *bytes, int)
|
||||||
{
|
{
|
||||||
int16_t * p = buffer;
|
int16_t * p = buffer;
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user