summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/vertigo.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-11-05 16:04:56 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-11-05 16:04:56 +0000
commita33640f46d16c62ace042db3d788279006e5319e (patch)
tree550b75365697963288c5abb3bb161aaa4f0d9732 /src/mame/machine/vertigo.c
parent82c3ffc15337feabd3407f3dc5fce04f98279f71 (diff)
Added concept of scheduling quanta to the timer system. Also added
means of setting the minimum useful scheduling quantum, and clamping all quanta to that value. Changed interleave/boost handling to use scheduling quanta instead of timers. Added machine parameter to cpu_boost_interleave. Updated cpuexec to compute the "perfect" interleave value taking into account the minimum number of cycles per instruction specified by the CPU core. Updated Z80 core to indicate that the minimum cpi is 2. Fixed incorrect minimum cpi in the 68020+ cores. Simplified a bit of logic in cpuexec_timeslice.
Diffstat (limited to 'src/mame/machine/vertigo.c')
-rw-r--r--src/mame/machine/vertigo.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mame/machine/vertigo.c b/src/mame/machine/vertigo.c
index 66766023e0a..a58d5bf2872 100644
--- a/src/mame/machine/vertigo.c
+++ b/src/mame/machine/vertigo.c
@@ -181,7 +181,7 @@ static TIMER_CALLBACK( sound_command_w )
quickly. Otherwise the main CPU gives up with sound. Boosting
the interleave for a while helps. */
- cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
+ cpu_boost_interleave(machine, attotime_zero, ATTOTIME_IN_USEC(100));
}
ef='#n160'>160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
// license:BSD-3-Clause
// copyright-holders:JJ Stacino
/********************************************************************

Support for Micronique machine .K7 and *.FOR cassette images

Note that the usual type for hector cassette is *.K7,
     the *.FOR type is only for programming screen in forth format.

You can find some *.K7 file on serveral server in France
(Micronique is a French factory) Enjoy !

 jj.stacino@aliceadsl.fr

Updated 3/1/10 : use real value for timing.
********************************************************************/
#include <cassert>

#include "hect_tap.h"


#define SMPLO   -32768
#define SILENCE 0
#define SMPHI   32767


static int cas_size;


enum
{
	Header_cycles = 77, /* Valeur Th?orique 66 = 44100 * 1.5 / 1000  // mesur? sur jeu Formule1 = 1,75ms*/
	Zero_cycles =   27, /* Valeur Th?orique 17 = 44100 * 0.4 / 1000  // mesur? sur jeu Formule1 = 0,61ms*/
	Un_cycles =     50  /* Valeur Th?orique 40 = 44100 * 0.9 / 1000  // mesur? sur jeu Formule1 = 1,13ms*/
};

/* Here I prefer use the value that I read on a real tape, and not the theorical value; note that these
   value work best on my HRX...    Yo_fr   (jj.stacino@aliceadsl.fr)  */

/*******************************************************************
   Generate one high-low cycle of sample data
********************************************************************/
static inline int hector_tap_cycle(int16_t *buffer, int sample_pos, int high, int low)
{
	int i = 0;

	if ( buffer )
	{
		while( i < high)
		{
			buffer[ sample_pos + i ] = SMPHI;
			i++;
		}

		while( i < high + low )
		{
			buffer[ sample_pos + i ] = SMPLO;
			i++;
		}
	}
	return high + low;
}


static inline int hector_tap_byte(int16_t *buffer, int sample_pos, uint8_t data)
{
/* Writing an entire byte */
	int i, samples;

	samples = 0;
	for ( i = 0; i < 8; i++ )
	{
		if ( data & 0x01 )
			samples += hector_tap_cycle( buffer, sample_pos + samples, Un_cycles/2, Un_cycles/2 );
		else
			samples += hector_tap_cycle( buffer, sample_pos + samples, Zero_cycles/2, Zero_cycles/2 );

		data >>= 1;
	}
	return samples;
}


static inline int hector_tap_synchro(int16_t *buffer, int sample_pos, int nb_synchro)
{
/* Writing an entire byte */
	int i, samples;

	samples = 0;
	for ( i = 0; i < nb_synchro ; i++ )
			samples += hector_tap_cycle( buffer, sample_pos + samples, Header_cycles/2, Header_cycles/2 );

	return samples;
}


static int hector_handle_tap(int16_t *buffer, const uint8_t *casdata)
{
	int data_pos, sample_count/*, block_count*/;
	int previous_block=0;

	data_pos = 0;
	sample_count = 0;
	/*block_count = 0;*/
	previous_block = 0;

	/* First 768 cycle of synchro */
	sample_count += hector_tap_synchro( buffer, sample_count, 768-4 );

	/* on the entire file*/
	while( data_pos < cas_size )
	{
		uint16_t  block_size;

		if (previous_block == 0xFE)
				/* Starting a block with 150 cycle of synchro to let time to Hector to do the job ! */
				sample_count += hector_tap_synchro( buffer, sample_count, 150 );
		else
					/* Starting a block with 4 cycle of synchro */
				sample_count += hector_tap_synchro( buffer, sample_count, 4 );

		if (data_pos>1)
				previous_block = casdata[data_pos-1];

		/* Handle block lenght on tape data */
		block_size = casdata[data_pos] ;
		if (block_size==0)
			block_size=256;

		/*block_count++;*/
		sample_count += hector_tap_byte(buffer, sample_count, casdata[data_pos] );
		data_pos++;

		/* Data samples */
		for ( ; block_size ; data_pos++, block_size-- )
		{
			/* Make sure there are enough bytes left */
			if ( data_pos > cas_size )
				return -1;

			sample_count += hector_tap_byte( buffer, sample_count, casdata[data_pos] );

		}
	}
	/*Finish by a zero*/
	sample_count += hector_tap_byte( buffer, sample_count, 0 );

	return sample_count;
}
/*******************************************************************
////  FORTH DATA CASSETTE
*******************************************************************/


static int hector_handle_forth_tap(int16_t *buffer, const uint8_t *casdata)
{
	int data_pos, sample_count/*, block_count*/;
	/*int previous_block=0;*/

	data_pos = 0;
	sample_count = 0;
	/*block_count = 0;*/
	/*previous_block = 0;*/

	/* Out if len of file not modulo 822 octets    */
	if ( (cas_size % 822) != 0 )
		return -1;

	/* on the entire file*/
	while( data_pos < cas_size )
	{
		uint16_t  block_size;

		/* Starting a block with 768 cycle of synchro*/
		sample_count += hector_tap_synchro( buffer, sample_count, 768 );

		/* Handle block lenght on tape data */
		block_size = 822 ; /* Fixed size for the forth*/

		/*block_count=0;*/

		/* Data samples */
		for ( ; block_size ; data_pos++, block_size-- )
		{
			/* Make sure there are enough bytes left */
			if ( data_pos > cas_size )
				return -1;

			sample_count += hector_tap_byte( buffer, sample_count, casdata[data_pos] );

		}
	}

	/*Finish by a zero*/
	sample_count += hector_tap_byte( buffer, sample_count, 0 );

	return sample_count;
}
/*******************************************************************
/////  END FORTH DATA CASSETTE
*******************************************************************/


/*******************************************************************
   Generate samples for the tape image
********************************************************************/
static int hector_tap_fill_wave(int16_t *buffer, int sample_count, uint8_t *bytes)
{
	return hector_handle_tap( buffer, bytes );
}


/*******************************************************************
   Calculate the number of samples needed for this tape image  FORTH
********************************************************************/
static int hector_tap_forth_to_wav_size(const uint8_t *casdata, int caslen)
{
	cas_size = caslen ;

	return hector_handle_forth_tap( nullptr, casdata );
}

/*******************************************************************
   Generate samples for the tape image FORTH
********************************************************************/
static int hector_tap_forth_fill_wave(int16_t *buffer, int sample_count, uint8_t *bytes)
{
	return hector_handle_forth_tap( buffer, bytes ); //forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}


/*******************************************************************
   Calculate the number of samples needed for this tape image classical
********************************************************************/
static int hector_tap_to_wav_size(const uint8_t *casdata, int caslen)
{
	cas_size = caslen ;

	return hector_handle_tap( nullptr, casdata );//forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}


static const struct CassetteLegacyWaveFiller hector_legacy_fill_wave =
{
	hector_tap_fill_wave,                   /* fill_wave */
	-1,                                     /* chunk_size */
	0,                                      /* chunk_samples */
	hector_tap_to_wav_size,                 /* chunk_sample_calc */
	44100,                                  /* sample_frequency */
	0,                                      /* header_samples */
	0                                       /* trailer_samples */
};

static const struct CassetteLegacyWaveFiller hector_forth_legacy_fill_wave =
{
	hector_tap_forth_fill_wave,             /* fill_wave */
	-1,                                     /* chunk_size */
	0,                                      /* chunk_samples */
	hector_tap_forth_to_wav_size,           /* chunk_sample_calc */
	44100,                                  /* sample_frequency */
	0,                                      /* header_samples */
	0                                       /* trailer_samples */
};


static cassette_image::error hector_k7_identify(cassette_image *cassette, struct CassetteOptions *opts)
{
	return cassette_legacy_identify(cassette, opts, &hector_legacy_fill_wave);
}


static cassette_image::error hector_k7_load(cassette_image *cassette)
{
	return cassette_legacy_construct(cassette, &hector_legacy_fill_wave);
}

static cassette_image::error hector_k7forth_identify(cassette_image *cassette, struct CassetteOptions *opts)
{
	return cassette_legacy_identify(cassette, opts, &hector_forth_legacy_fill_wave);
}


static cassette_image::error hector_k7forth_load(cassette_image *cassette)
{
	return cassette_legacy_construct(cassette, &hector_forth_legacy_fill_wave);
}


static const struct CassetteFormat hector_k7_format =
{
	"k7,cin",
	hector_k7_identify,
	hector_k7_load,
	nullptr
};

static const struct CassetteFormat hector_k7Forth_format =
{
	"for",
	hector_k7forth_identify,
	hector_k7forth_load,
	nullptr
};


CASSETTE_FORMATLIST_START(hector_cassette_formats)
	CASSETTE_FORMAT(hector_k7_format)
	CASSETTE_FORMAT(hector_k7Forth_format)
CASSETTE_FORMATLIST_END