mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
(MESS) sorcerer : added .TAPE cassette format [Robbbert]
This commit is contained in:
parent
4b4c023274
commit
c828d34891
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2937,6 +2937,8 @@ src/lib/formats/sf7000_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/sf7000_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/smx_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/smx_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/sorc_cas.c svneol=native#text/plain
|
||||
src/lib/formats/sorc_cas.h svneol=native#text/plain
|
||||
src/lib/formats/sorc_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/sorc_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/sord_cas.c svneol=native#text/plain
|
||||
|
156
src/lib/formats/sorc_cas.c
Normal file
156
src/lib/formats/sorc_cas.c
Normal file
@ -0,0 +1,156 @@
|
||||
// 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"
|
||||
|
||||
#define WAVEENTRY_LOW -32768
|
||||
#define WAVEENTRY_HIGH 32767
|
||||
|
||||
#define SORCERER_WAV_FREQUENCY 4800
|
||||
|
||||
// image size
|
||||
static int sorcerer_image_size;
|
||||
static bool level;
|
||||
|
||||
static int sorcerer_put_samples(INT16 *buffer, int sample_pos, int count)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
for (int i=0; i<count; i++)
|
||||
buffer[sample_pos + i] = level ? WAVEENTRY_LOW : WAVEENTRY_HIGH;
|
||||
|
||||
level ^= 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int sorcerer_output_bit(INT16 *buffer, int sample_pos, bool bit)
|
||||
{
|
||||
int samples = 0;
|
||||
|
||||
if (bit)
|
||||
{
|
||||
samples += sorcerer_put_samples(buffer, sample_pos + samples, 2);
|
||||
samples += sorcerer_put_samples(buffer, sample_pos + samples, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
samples += sorcerer_put_samples(buffer, sample_pos + samples, 4);
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
static int sorcerer_output_byte(INT16 *buffer, int sample_pos, UINT8 byte)
|
||||
{
|
||||
int samples = 0;
|
||||
UINT8 i;
|
||||
|
||||
/* start */
|
||||
samples += sorcerer_output_bit (buffer, sample_pos + samples, 0);
|
||||
|
||||
/* data */
|
||||
for (i = 0; i<8; i++)
|
||||
samples += sorcerer_output_bit (buffer, sample_pos + samples, (byte >> 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 *buffer, const UINT8 *bytes)
|
||||
{
|
||||
UINT32 sample_count = 0;
|
||||
UINT32 i;
|
||||
|
||||
/* idle */
|
||||
for (i=0; i<2000; i++)
|
||||
sample_count += sorcerer_output_bit(buffer, sample_count, 1);
|
||||
|
||||
/* data */
|
||||
for (i=0; i<sorcerer_image_size; i++)
|
||||
sample_count += sorcerer_output_byte(buffer, sample_count, bytes[i]);
|
||||
|
||||
return sample_count;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Generate samples for the tape image
|
||||
********************************************************************/
|
||||
|
||||
static int sorcerer_cassette_fill_wave(INT16 *buffer, int length, UINT8 *bytes)
|
||||
{
|
||||
return sorcerer_handle_cassette(buffer, bytes);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Calculate the number of samples needed for this tape image
|
||||
********************************************************************/
|
||||
|
||||
static int sorcerer_cassette_calculate_size_in_samples(const UINT8 *bytes, int length)
|
||||
{
|
||||
sorcerer_image_size = length;
|
||||
|
||||
return sorcerer_handle_cassette(NULL, bytes);
|
||||
}
|
||||
|
||||
static const struct CassetteLegacyWaveFiller sorcerer_legacy_fill_wave =
|
||||
{
|
||||
sorcerer_cassette_fill_wave, /* fill_wave */
|
||||
-1, /* chunk_size */
|
||||
0, /* chunk_samples */
|
||||
sorcerer_cassette_calculate_size_in_samples, /* chunk_sample_calc */
|
||||
SORCERER_WAV_FREQUENCY, /* sample_frequency */
|
||||
0, /* header_samples */
|
||||
0 /* trailer_samples */
|
||||
};
|
||||
|
||||
static casserr_t sorcerer_cassette_identify(cassette_image *cassette, struct CassetteOptions *opts)
|
||||
{
|
||||
return cassette_legacy_identify(cassette, opts, &sorcerer_legacy_fill_wave);
|
||||
}
|
||||
|
||||
static casserr_t sorcerer_cassette_load(cassette_image *cassette)
|
||||
{
|
||||
return cassette_legacy_construct(cassette, &sorcerer_legacy_fill_wave);
|
||||
}
|
||||
|
||||
static const struct CassetteFormat sorcerer_cassette_image_format =
|
||||
{
|
||||
"tape",
|
||||
sorcerer_cassette_identify,
|
||||
sorcerer_cassette_load,
|
||||
NULL
|
||||
};
|
||||
|
||||
CASSETTE_FORMATLIST_START(sorcerer_cassette_formats)
|
||||
CASSETTE_FORMAT(sorcerer_cassette_image_format)
|
||||
CASSETTE_FORMATLIST_END
|
15
src/lib/formats/sorc_cas.h
Normal file
15
src/lib/formats/sorc_cas.h
Normal file
@ -0,0 +1,15 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Robbbert
|
||||
/*********************************************************************
|
||||
|
||||
sorc_cas.h
|
||||
|
||||
Format code for Exidy Sorcerer cassette images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#include "cassimg.h"
|
||||
|
||||
CASSETTE_FORMATLIST_EXTERN(sorcerer_cassette_formats);
|
||||
|
@ -181,6 +181,7 @@ FORMATSOBJS = \
|
||||
$(LIBOBJ)/formats/sf7000_dsk.o \
|
||||
$(LIBOBJ)/formats/smx_dsk.o \
|
||||
$(LIBOBJ)/formats/sorc_dsk.o \
|
||||
$(LIBOBJ)/formats/sorc_cas.o \
|
||||
$(LIBOBJ)/formats/sord_cas.o \
|
||||
$(LIBOBJ)/formats/spc1000_cas.o \
|
||||
$(LIBOBJ)/formats/st_dsk.o \
|
||||
|
@ -158,7 +158,6 @@ NOTES (2011-08-08)
|
||||
********************************************************************************/
|
||||
|
||||
#include "includes/sorcerer.h"
|
||||
#include "bus/centronics/covox.h"
|
||||
|
||||
static ADDRESS_MAP_START( sorcerer_mem, AS_PROGRAM, 8, sorcerer_state)
|
||||
ADDRESS_MAP_UNMAP_HIGH
|
||||
@ -399,9 +398,9 @@ static const ay31015_config sorcerer_ay31015_config =
|
||||
|
||||
static const cassette_interface sorcerer_cassette_interface =
|
||||
{
|
||||
cassette_default_formats,
|
||||
sorcerer_cassette_formats,
|
||||
NULL,
|
||||
(cassette_state)(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
|
||||
(cassette_state)(CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED),
|
||||
"sorcerer_cass",
|
||||
NULL
|
||||
};
|
||||
|
@ -13,12 +13,14 @@
|
||||
#include "sound/wave.h"
|
||||
#include "machine/ay31015.h"
|
||||
#include "bus/centronics/ctronics.h"
|
||||
#include "bus/centronics/covox.h"
|
||||
#include "machine/ram.h"
|
||||
#include "imagedev/cartslot.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include "imagedev/snapquik.h"
|
||||
#include "imagedev/flopdrv.h"
|
||||
#include "formats/sorc_dsk.h"
|
||||
#include "formats/sorc_cas.h"
|
||||
#include "machine/micropolis.h"
|
||||
|
||||
#define SORCERER_USING_RS232 0
|
||||
@ -48,17 +50,17 @@ public:
|
||||
};
|
||||
|
||||
sorcerer_state(const machine_config &mconfig, device_type type, const char *tag)
|
||||
: driver_device(mconfig, type, tag),
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_cassette1(*this, "cassette"),
|
||||
m_cassette2(*this, "cassette2"),
|
||||
m_wave1(*this, WAVE_TAG),
|
||||
m_wave2(*this, WAVE2_TAG),
|
||||
m_uart(*this, "uart"),
|
||||
m_centronics(*this, "centronics"),
|
||||
m_ram(*this, RAM_TAG),
|
||||
m_iop_config(*this, "CONFIG"),
|
||||
m_iop_vs(*this, "VS")
|
||||
: driver_device(mconfig, type, tag)
|
||||
, m_maincpu(*this, "maincpu")
|
||||
, m_cassette1(*this, "cassette")
|
||||
, m_cassette2(*this, "cassette2")
|
||||
, m_wave1(*this, WAVE_TAG)
|
||||
, m_wave2(*this, WAVE2_TAG)
|
||||
, m_uart(*this, "uart")
|
||||
, m_centronics(*this, "centronics")
|
||||
, m_ram(*this, RAM_TAG)
|
||||
, m_iop_config(*this, "CONFIG")
|
||||
, m_iop_vs(*this, "VS")
|
||||
{ }
|
||||
|
||||
DECLARE_READ8_MEMBER(sorcerer_fc_r);
|
||||
@ -68,6 +70,15 @@ public:
|
||||
DECLARE_WRITE8_MEMBER(sorcerer_fd_w);
|
||||
DECLARE_WRITE8_MEMBER(sorcerer_fe_w);
|
||||
DECLARE_WRITE8_MEMBER(sorcerer_ff_w);
|
||||
DECLARE_MACHINE_START(sorcererd);
|
||||
DECLARE_DRIVER_INIT(sorcerer);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_serial_tc);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_cassette_tc);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_reset);
|
||||
DECLARE_SNAPSHOT_LOAD_MEMBER( sorcerer );
|
||||
DECLARE_QUICKLOAD_LOAD_MEMBER( sorcerer);
|
||||
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
private:
|
||||
UINT8 m_fe;
|
||||
UINT8 m_keyboard_line;
|
||||
const UINT8 *m_p_videoram;
|
||||
@ -75,7 +86,9 @@ public:
|
||||
emu_timer *m_cassette_timer;
|
||||
cass_data_t m_cass_data;
|
||||
virtual void video_start();
|
||||
UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
|
||||
virtual void machine_start();
|
||||
virtual void machine_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<cassette_image_device> m_cassette1;
|
||||
required_device<cassette_image_device> m_cassette2;
|
||||
@ -86,18 +99,6 @@ public:
|
||||
required_device<ram_device> m_ram;
|
||||
required_ioport m_iop_config;
|
||||
required_ioport m_iop_vs;
|
||||
DECLARE_DRIVER_INIT(sorcerer);
|
||||
virtual void machine_start();
|
||||
virtual void machine_reset();
|
||||
DECLARE_MACHINE_START(sorcererd);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_serial_tc);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_cassette_tc);
|
||||
TIMER_CALLBACK_MEMBER(sorcerer_reset);
|
||||
DECLARE_SNAPSHOT_LOAD_MEMBER( sorcerer );
|
||||
DECLARE_QUICKLOAD_LOAD_MEMBER( sorcerer);
|
||||
|
||||
protected:
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
};
|
||||
|
||||
#endif /* SORCERER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user