Previous 15994 Revisions Next

r5700 Saturday 12th September, 2009 at 01:17:52 UTC by Barry Rodewald
[X1] Added very basic .TAP cassette image support.
[src/mess]mess.mak
[src/mess/drivers]x1.c
[src/mess/formats]x1_tap.c* x1_tap.h*

src/mess/mess.mak
r5699r5700
12201220   $(MESS_VIDEO)/mz80.o      \
12211221   $(MESS_MACHINE)/mz80.o      \
12221222   $(MESS_DRIVERS)/x1.o      \
1223   $(MESS_FORMATS)/x1_tap.o   \
12231224
12241225$(MESSOBJ)/sinclair.a:         \
12251226   $(MESS_VIDEO)/border.o      \
src/mess/formats/x1_tap.c
r0r5700
1/*
2 *
3 *   Sharp X1 TAP image format
4 *
5 *   "New" header format:
6 *   0x00: Index - must be "TAPE" (4 bytes)
7 *   0x04: Image title. (null-terminated string, 17 bytes)
8 *   0x15: Reserved (5 bytes)
9 *   0x1a: Write protect (bit 4, 1 byte)
10 *   0x1b: Format (bit 0, 1 byte)
11 *            if bit 0 is high, uses "speed limit sampling method"
12 *   0x1c: Sample rate, per bit (in Hz, 4 bytes)
13 *   0x20: Tape data size, in bits (4 bytes)
14 *   0x24: Tape position (4 bytes, usually 0)
15 *   0x28: Tape data (data size / 8)
16 *
17 *   "Old" header format:
18 *   0x00: Sampling rate (4 bytes)
19 *
20 */
21
22#include "driver.h"
23#include "x1_tap.h"
24
25#define WAVE_HIGH       0x5a9e
26#define WAVE_LOW      -0x5a9e
27
28static int cas_size;
29static int samplerate;
30
31static int x1_fill_wave(INT16* buffer, UINT8 data, int sample_pos)
32{
33   int x;
34   int sample_count = 0;
35   
36   // one byte = 8 samples
37   for(x=0;x<8;x++)
38   {
39      if(buffer)
40         buffer[sample_pos+x] = (data & (1 << (7-x))) ? WAVE_HIGH : WAVE_LOW;
41      sample_count++;
42   }
43   
44   return sample_count;
45}
46
47static int x1_handle_tap(INT16* buffer, const UINT8* casdata)
48{
49   int sample_count = 0;
50   int data_pos = 0x28;
51
52   if(memcmp(casdata, "TAPE",4))  // header check
53   {
54      logerror("TAP: image is not a 'new' format TAP image\n");
55      return -1;
56   }
57   if(samplerate != 8000)
58   {
59      logerror("TAP: images that are not 8000Hz are not yet supported\n");
60      return -1;
61   }
62   
63   while(sample_count < cas_size)
64   {
65      sample_count += x1_fill_wave(buffer,casdata[data_pos],sample_count);
66      data_pos++;
67   }
68   
69   return sample_count;
70}
71
72/*******************************************************************
73   Calculate the number of samples needed for this tape image
74********************************************************************/
75static int x1_cas_to_wav_size (const UINT8 *casdata, int caslen)
76{
77   UINT32 ret;
78   
79   ret = casdata[0x20] | (casdata[0x21] << 8) | (casdata[0x22] << 16) | (casdata[0x23] << 24);
80   cas_size = ret;
81
82   samplerate = casdata[0x1c] | (casdata[0x1d] << 8) | (casdata[0x1e] << 16) | (casdata[0x1f] << 24);
83   
84   return ret;
85}
86
87/*******************************************************************
88   Generate samples for the tape image
89********************************************************************/
90static int x1_cas_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
91{
92   return x1_handle_tap(buffer,bytes);
93}
94
95static const struct CassetteLegacyWaveFiller x1_legacy_fill_wave =
96{
97   x1_cas_fill_wave,                  /* fill_wave */
98   -1,                              /* chunk_size */
99   0,                              /* chunk_samples */
100   x1_cas_to_wav_size,               /* chunk_sample_calc */
101   8000,                           /* sample_frequency */
102   0,                              /* header_samples */
103   0                              /* trailer_samples */
104};
105
106static casserr_t x1_cas_identify(cassette_image *cassette, struct CassetteOptions *opts)
107{
108   return cassette_legacy_identify(cassette, opts, &x1_legacy_fill_wave);
109}
110
111
112
113static casserr_t x1_cas_load(cassette_image *cassette)
114{
115   return cassette_legacy_construct(cassette, &x1_legacy_fill_wave);
116}
117
118
119static const struct CassetteFormat x1_cassette_format = {
120   "tap",
121   x1_cas_identify,
122   x1_cas_load,
123   NULL
124};
125
126CASSETTE_FORMATLIST_START(x1_cassette_formats)
127   CASSETTE_FORMAT(x1_cassette_format)
128CASSETTE_FORMATLIST_END
src/mess/formats/x1_tap.h
r0r5700
1/*
2 *
3 *   Sharp X1 TAP image format
4 *
5 */
6
7#ifndef X1_TAP_H_
8#define X1_TAP_H_
9
10#include "formats/cassimg.h"
11
12CASSETTE_FORMATLIST_EXTERN( x1_cassette_formats );
13
14#endif /*X1_TAP_H_*/
src/mess/drivers/x1.c
r5699r5700
156156#include "devices/mflopimg.h"
157157#include "formats/basicdsk.h"
158158#include "formats/fm7_dsk.h"
159#include "formats/x1_tap.h"
159160#include <ctype.h>
160161
161162static UINT8 hres_320,io_switch,io_sys,vsync,vdisp;
r5699r5700
17851786// (ym-2151 handler here)
17861787
17871788/*************************************
1789 *
1790 *  Cassette configuration
1791 *
1792 *************************************/
1793
1794static const cassette_config x1_cassette_config =
1795{
1796   x1_cassette_formats,
1797   NULL,
1798   CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED
1799};
1800
1801
1802/*************************************
17881803 *
17891804 *  Machine Functions
17901805 *
r5699r5700
19381953   MDRV_SOUND_WAVE_ADD("wave","cass")
19391954   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
19401955
1941   MDRV_CASSETTE_ADD("cass",default_cassette_config)
1956   MDRV_CASSETTE_ADD("cass",x1_cassette_config)
19421957MACHINE_DRIVER_END
19431958
19441959static MACHINE_DRIVER_START( x1turbo )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team