Previous 15994 Revisions Next

r1436 Wednesday 26th December, 2007 at 08:33:55 UTC by Barry Rodewald
[TZX] Added Amstrad CPC .cdt support, fixed pause length
[src/mess/drivers]amstrad.c
[src/mess/formats]tzx_cas.c tzx_cas.h

src/mess/formats/tzx_cas.c
r1435r1436
7070static INT16   wave_data;
7171static int   block_count;
7272static UINT8**   blocks;
73static float t_scale = 1;  /* for scaling T-states to the 4MHz CPC */
7374
7475static void toggle_wave_data(void) {
7576   if ( wave_data == WAVE_LOW ) {
r1435r1436
184185}
185186
186187INLINE int millisec_to_samplecount( int millisec ) {
187   return (int) ( ( millisec * ( (double)TZX_WAV_FREQUENCY / 3500000 ) ) / 1000.0 );
188   return (int) ( millisec * ( (double)TZX_WAV_FREQUENCY / 1000.0 ) );
188189}
189190
190191INLINE int tcycles_to_samplecount( int tcycles ) {
191   return (int) ( 0.5 + ( ( (double)TZX_WAV_FREQUENCY / 3500000 ) * (double)tcycles ) );
192   return (int) ( ( 0.5 + ( ( (double)TZX_WAV_FREQUENCY / 3500000 ) * (double)tcycles ) ) * t_scale );
192193}
193194
194195static void tzx_output_wave( INT16 **buffer, int length ) {
r1435r1436
256257      tzx_output_wave( buffer, rest_pause_samples );
257258      size += rest_pause_samples;
258259   }
260   else  /* default value for pause is 1000ms */
261   {
262      int start_pause_samples = millisec_to_samplecount( 1 );
263      int rest_pause_samples = millisec_to_samplecount( 1000 - 1 );
264
265      tzx_output_wave( buffer, start_pause_samples );
266      size += start_pause_samples;
267      wave_data = WAVE_LOW;
268      tzx_output_wave( buffer, rest_pause_samples );
269      size += rest_pause_samples;
270   }
259271        return size;
260272}
261273
r1435r1436
404416static int tzx_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
405417   INT16   *p = buffer;
406418   int   size = 0;
419   t_scale = 1.0;
407420   size = tzx_cas_do_work( &p );
408421   return size;
409422}
410423
424static int cdt_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
425   INT16   *p = buffer;
426   int   size = 0;
427   t_scale = (40 / 35);  /* scale to 4MHz */
428   size = tzx_cas_do_work( &p );
429   return size;
430}
431
411432static int tap_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
412433   int size = 0;
413434   const UINT8 *p = casdata;
r1435r1436
461482   0               /* trailer_samples */
462483};
463484
485static struct CassetteLegacyWaveFiller cdt_legacy_fill_wave = {
486   cdt_cas_fill_wave,         /* fill_wave */
487   -1,               /* chunk_size */
488   0,               /* chunk_samples */
489   tzx_cas_to_wav_size,         /* chunk_sample_calc */
490   TZX_WAV_FREQUENCY,         /* sample_frequency */
491   0,               /* header_samples */
492   0               /* trailer_samples */
493};
494
464495static casserr_t tzx_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts ) {
465496   return cassette_legacy_identify( cassette, opts, &tzx_legacy_fill_wave );
466497}
r1435r1436
469500   return cassette_legacy_identify( cassette, opts, &tap_legacy_fill_wave );
470501}
471502
503static casserr_t cdt_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts ) {
504   return cassette_legacy_identify( cassette, opts, &cdt_legacy_fill_wave );
505}
506
472507static casserr_t tzx_cassette_load( cassette_image *cassette ) {
473508   return cassette_legacy_construct( cassette, &tzx_legacy_fill_wave );
474509}
r1435r1436
477512   return cassette_legacy_construct( cassette, &tap_legacy_fill_wave );
478513}
479514
515static casserr_t cdt_cassette_load( cassette_image *cassette ) {
516   return cassette_legacy_construct( cassette, &cdt_legacy_fill_wave );
517}
518
480519static struct CassetteFormat tzx_cassette_format = {
481520   "tzx",
482521   tzx_cassette_identify,
r1435r1436
491530   NULL
492531};
493532
533struct CassetteFormat cdt_cassette_format = {
534   "cdt",
535   cdt_cassette_identify,
536   cdt_cassette_load,
537   NULL
538};
539
494540CASSETTE_FORMATLIST_START(tzx_cassette_formats)
495541   CASSETTE_FORMAT(tzx_cassette_format)
496542   CASSETTE_FORMAT(tap_cassette_format)
497543CASSETTE_FORMATLIST_END
498544
545CASSETTE_FORMATLIST_START(cdt_cassette_formats)
546   CASSETTE_FORMAT(cdt_cassette_format)
547CASSETTE_FORMATLIST_END
548
src/mess/formats/tzx_cas.h
r1435r1436
1111#include "formats/cassimg.h"
1212
1313CASSETTE_FORMATLIST_EXTERN(tzx_cassette_formats);
14CASSETTE_FORMATLIST_EXTERN(cdt_cassette_formats);
1415
1516#endif /* TZX_CAS_H */
src/mess/drivers/amstrad.c
r1435r1436
7878#include "inputx.h"
7979#include "mslegacy.h"
8080#include "sound/ay8910.h"
81#include "formats/tzx_cas.h"
8182
8283#ifdef AMSTRAD_VIDEO_EVENT_LIST
8384/* for event list */
r1435r1436
25212522      /* --- the following bits of info are returned as 64-bit signed integers --- */
25222523      case DEVINFO_INT_COUNT:                     info->i = 1; break;
25232524      case DEVINFO_INT_CASSETTE_DEFAULT_STATE:      info->i = CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED; break;
2525      case DEVINFO_PTR_CASSETTE_FORMATS:            info->p = (void *)cdt_cassette_formats; break;
25242526
25252527      default:                              cassette_device_getinfo(devclass, state, info); break;
25262528   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team