mirror of
https://github.com/holub/mame
synced 2025-04-20 23:42:22 +03:00
(MESS) phc25 : can load .phc cassettes
This commit is contained in:
parent
c5495da07e
commit
fb05c87a0d
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2864,6 +2864,8 @@ src/lib/formats/pc98fdi_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/pc98fdi_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/pc_dsk.c svneol=native#text/plain
|
||||
src/lib/formats/pc_dsk.h svneol=native#text/plain
|
||||
src/lib/formats/phc25_cas.c svneol=native#text/plain
|
||||
src/lib/formats/phc25_cas.h svneol=native#text/plain
|
||||
src/lib/formats/pmd_cas.c svneol=native#text/plain
|
||||
src/lib/formats/pmd_cas.h svneol=native#text/plain
|
||||
src/lib/formats/primoptp.c svneol=native#text/plain
|
||||
|
179
src/lib/formats/phc25_cas.c
Normal file
179
src/lib/formats/phc25_cas.c
Normal file
@ -0,0 +1,179 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Robbbert
|
||||
/********************************************************************
|
||||
|
||||
Support for Sanyo PHC25 cassette images
|
||||
|
||||
phc images consist of 5 sections
|
||||
1. 10 A5 bytes
|
||||
2. 6 name of the program
|
||||
3. The basic program file. Each line is delimited by null. This
|
||||
section is terminated by 3 nulls (1 of them for the preceeding
|
||||
line, the other 2 indicate the end).
|
||||
4. The line numbers and pointers to them. It ends at the image size-1
|
||||
5. A 1-byte trailer of FF which we do not pass on
|
||||
|
||||
Each byte after conversion becomes a start bit, bit 0,1,etc to 7,
|
||||
then 4 end bits.
|
||||
|
||||
An actual tape consists of 6 sections
|
||||
a. 2.656secs of silence
|
||||
b. 4.862secs of high bits
|
||||
c. The header which is parts 1 and 2 above
|
||||
d. 0.652secs of high bits
|
||||
e. The main program wjich is parts 3 and 4 above
|
||||
f. some more silence
|
||||
|
||||
We don't emulate the full silence and high-bits periods, only just
|
||||
enough to make it work.
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#include "phc25_cas.h"
|
||||
|
||||
#define WAVEENTRY_LOW -32768
|
||||
#define WAVEENTRY_HIGH 32767
|
||||
|
||||
#define PHC25_WAV_FREQUENCY 9600
|
||||
#define PHC25_HEADER_BYTES 16
|
||||
|
||||
// image size
|
||||
static int phc25_image_size;
|
||||
|
||||
static int phc25_put_samples(INT16 *buffer, int sample_pos, int count, int level)
|
||||
{
|
||||
if (buffer)
|
||||
{
|
||||
for (int i=0; i<count; i++)
|
||||
buffer[sample_pos + i] = level;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int phc25_output_bit(INT16 *buffer, int sample_pos, bool bit)
|
||||
{
|
||||
int samples = 0;
|
||||
|
||||
if (bit)
|
||||
{
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 2, WAVEENTRY_LOW);
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 2, WAVEENTRY_HIGH);
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 2, WAVEENTRY_LOW);
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 2, WAVEENTRY_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 4, WAVEENTRY_LOW);
|
||||
samples += phc25_put_samples(buffer, sample_pos + samples, 4, WAVEENTRY_HIGH);
|
||||
}
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
static int phc25_output_byte(INT16 *buffer, int sample_pos, UINT8 byte)
|
||||
{
|
||||
int samples = 0;
|
||||
UINT8 i;
|
||||
|
||||
/* start */
|
||||
samples += phc25_output_bit (buffer, sample_pos + samples, 0);
|
||||
|
||||
/* data */
|
||||
for (i = 0; i<8; i++)
|
||||
samples += phc25_output_bit (buffer, sample_pos + samples, (byte >> i) & 1);
|
||||
|
||||
/* stop */
|
||||
for (i = 0; i<4; i++)
|
||||
samples += phc25_output_bit (buffer, sample_pos + samples, 1);
|
||||
|
||||
return samples;
|
||||
}
|
||||
|
||||
static int phc25_handle_cassette(INT16 *buffer, const UINT8 *bytes)
|
||||
{
|
||||
UINT32 sample_count = 0;
|
||||
UINT32 byte_count = 0;
|
||||
UINT32 i;
|
||||
|
||||
// silence
|
||||
// sample_count += phc25_put_samples(buffer, 6640, 2, WAVEENTRY_HIGH);
|
||||
|
||||
/* start */
|
||||
// for (i=0; i<12155; i++)
|
||||
for (i=0; i<2155; i++)
|
||||
sample_count += phc25_output_bit(buffer, sample_count, 1);
|
||||
|
||||
/* header */
|
||||
for (int i=0; i<PHC25_HEADER_BYTES; i++)
|
||||
sample_count += phc25_output_byte(buffer, sample_count, bytes[i]);
|
||||
|
||||
byte_count = PHC25_HEADER_BYTES;
|
||||
|
||||
/* pause */
|
||||
for (i=0; i<1630; i++)
|
||||
sample_count += phc25_output_bit(buffer, sample_count, 1);
|
||||
|
||||
/* data */
|
||||
for (i=byte_count; i<phc25_image_size-1; i++)
|
||||
sample_count += phc25_output_byte(buffer, sample_count, bytes[i]);
|
||||
|
||||
// silence
|
||||
sample_count += phc25_put_samples(buffer, 1000, 2, WAVEENTRY_HIGH);
|
||||
|
||||
return sample_count;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
Generate samples for the tape image
|
||||
********************************************************************/
|
||||
|
||||
static int phc25_cassette_fill_wave(INT16 *buffer, int length, UINT8 *bytes)
|
||||
{
|
||||
return phc25_handle_cassette(buffer, bytes);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Calculate the number of samples needed for this tape image
|
||||
********************************************************************/
|
||||
|
||||
static int phc25_cassette_calculate_size_in_samples(const UINT8 *bytes, int length)
|
||||
{
|
||||
phc25_image_size = length;
|
||||
|
||||
return phc25_handle_cassette(NULL, bytes);
|
||||
}
|
||||
|
||||
static const struct CassetteLegacyWaveFiller phc25_legacy_fill_wave =
|
||||
{
|
||||
phc25_cassette_fill_wave, /* fill_wave */
|
||||
-1, /* chunk_size */
|
||||
0, /* chunk_samples */
|
||||
phc25_cassette_calculate_size_in_samples, /* chunk_sample_calc */
|
||||
PHC25_WAV_FREQUENCY, /* sample_frequency */
|
||||
0, /* header_samples */
|
||||
0 /* trailer_samples */
|
||||
};
|
||||
|
||||
static casserr_t phc25_cassette_identify(cassette_image *cassette, struct CassetteOptions *opts)
|
||||
{
|
||||
return cassette_legacy_identify(cassette, opts, &phc25_legacy_fill_wave);
|
||||
}
|
||||
|
||||
static casserr_t phc25_cassette_load(cassette_image *cassette)
|
||||
{
|
||||
return cassette_legacy_construct(cassette, &phc25_legacy_fill_wave);
|
||||
}
|
||||
|
||||
static const struct CassetteFormat phc25_cassette_image_format =
|
||||
{
|
||||
"phc",
|
||||
phc25_cassette_identify,
|
||||
phc25_cassette_load,
|
||||
NULL
|
||||
};
|
||||
|
||||
CASSETTE_FORMATLIST_START(phc25_cassette_formats)
|
||||
CASSETTE_FORMAT(phc25_cassette_image_format)
|
||||
CASSETTE_FORMATLIST_END
|
15
src/lib/formats/phc25_cas.h
Normal file
15
src/lib/formats/phc25_cas.h
Normal file
@ -0,0 +1,15 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Robbbert
|
||||
/*********************************************************************
|
||||
|
||||
phc25_cas.h
|
||||
|
||||
Format code for Sanyo PHC25 casette images (phc format)
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
|
||||
#include "cassimg.h"
|
||||
|
||||
CASSETTE_FORMATLIST_EXTERN(phc25_cassette_formats);
|
||||
|
@ -168,6 +168,7 @@ FORMATSOBJS = \
|
||||
$(LIBOBJ)/formats/pc_dsk.o \
|
||||
$(LIBOBJ)/formats/pc98_dsk.o \
|
||||
$(LIBOBJ)/formats/pc98fdi_dsk.o \
|
||||
$(LIBOBJ)/formats/phc25_cas.o \
|
||||
$(LIBOBJ)/formats/pmd_cas.o \
|
||||
$(LIBOBJ)/formats/primoptp.o \
|
||||
$(LIBOBJ)/formats/pyldin_dsk.o \
|
||||
|
@ -26,8 +26,7 @@
|
||||
|
||||
TODO:
|
||||
|
||||
- MC6847 mode selection lines (should be ok now but need more testing)
|
||||
- tune cassette trigger level
|
||||
- MC6847 mode selection lines
|
||||
- accurate video timing
|
||||
|
||||
- sound isn't working (should be a keyclick)
|
||||
@ -41,6 +40,7 @@ RUN
|
||||
|
||||
|
||||
10 SCREEN2,1,1:CLS:FORX=0TO8:LINE(X*24,0)-(X*24+16,191),X,BF:NEXT
|
||||
RUN
|
||||
|
||||
*/
|
||||
|
||||
@ -109,12 +109,12 @@ WRITE8_MEMBER( phc25_state::port40_w )
|
||||
m_centronics->strobe_w(BIT(data, 3));
|
||||
|
||||
/* MC6847 */
|
||||
m_ag = BIT(data, 7);
|
||||
m_vdg->intext_w(1);
|
||||
m_vdg->gm0_w(BIT(data, 5));
|
||||
m_vdg->gm1_w(1);
|
||||
m_vdg->css_w(BIT(data, 6));
|
||||
m_vdg->ag_w(m_ag);
|
||||
m_vdg->ag_w(BIT(data, 7));
|
||||
m_port40 = data;
|
||||
}
|
||||
|
||||
/* Memory Maps */
|
||||
@ -266,9 +266,16 @@ INPUT_PORTS_END
|
||||
|
||||
READ8_MEMBER( phc25_state::video_ram_r )
|
||||
{
|
||||
if (m_ag) // graphics (to be checked)
|
||||
if BIT(m_port40, 7) // graphics
|
||||
{
|
||||
return m_video_ram[offset & 0x17ff];
|
||||
if BIT(m_port40, 5)
|
||||
{// screen 4
|
||||
return m_video_ram[((offset & 0x1fe0)<<1) + (offset & 0x1f) + 0x800 ];
|
||||
}
|
||||
else
|
||||
{// screen 3
|
||||
return m_video_ram[((offset & 0x1fc0)<<1) + (offset & 0x3f) + 0x380 ];
|
||||
}
|
||||
}
|
||||
else // text
|
||||
{
|
||||
@ -346,6 +353,7 @@ void phc25_state::video_start()
|
||||
{
|
||||
/* find memory regions */
|
||||
m_char_rom = memregion(Z80_TAG)->base() + 0x5000;
|
||||
m_port40 = 0;
|
||||
}
|
||||
|
||||
/* AY-3-8910 Interface */
|
||||
@ -364,9 +372,9 @@ static const ay8910_interface ay8910_intf =
|
||||
|
||||
static const cassette_interface phc25_cassette_interface =
|
||||
{
|
||||
cassette_default_formats,
|
||||
phc25_cassette_formats,
|
||||
NULL,
|
||||
(cassette_state)(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED),
|
||||
(cassette_state)(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED),
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
@ -383,7 +391,7 @@ static MACHINE_CONFIG_START( phc25, phc25_state )
|
||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||
MCFG_SOUND_ADD(AY8910_TAG, AY8910, 1996750)
|
||||
MCFG_SOUND_CONFIG(ay8910_intf)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
|
||||
MCFG_SOUND_WAVE_ADD(WAVE_TAG, "cassette")
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15)
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "bus/centronics/ctronics.h"
|
||||
#include "video/mc6847.h"
|
||||
#include "sound/ay8910.h"
|
||||
#include "formats/phc25_cas.h"
|
||||
|
||||
#define SCREEN_TAG "screen"
|
||||
#define Z80_TAG "z80"
|
||||
@ -45,7 +46,7 @@ public:
|
||||
private:
|
||||
virtual void video_start();
|
||||
UINT8 *m_char_rom;
|
||||
bool m_ag;
|
||||
UINT8 m_port40;
|
||||
required_shared_ptr<UINT8> m_video_ram;
|
||||
required_device<cpu_device> m_maincpu;
|
||||
required_device<mc6847_base_device> m_vdg;
|
||||
|
Loading…
Reference in New Issue
Block a user