Previous 15994 Revisions Next

r6736 Thursday 24th December, 2009 at 17:20:24 UTC by Miodrag Milanović
Tape k7 support on Micronique [JJ Stacino]
[src/mess]mess.mak
[src/mess/drivers]hec2hrp.c interact.c
[src/mess/formats]hect_tap.c* hect_tap.h*
[src/mess/tools/castool]castool.mak main.c

src/mess/tools/castool/main.c
r6735r6736
3232#include "formats/csw_cas.h"
3333#include "formats/fmsx_cas.h"
3434#include "formats/gtp_cas.h"
35#include "formats/hect_tap.h"
3536#include "formats/jupi_tap.h"
3637#include "formats/kim1_cas.h"
3738#include "formats/lviv_lvt.h"
r6735r6736
6667   {"bbc", bbc_cassette_formats               ,"BBC"},
6768   {"fmxs", fmsx_cassette_formats             ,"MSX"},
6869   {"gtp", gtp_cassette_formats               ,"Galaksija"},
70   {"hector", hector_cassette_formats         ,"Hector - k7 : classical, FOR : forth cassette "},
6971   {"jupiter", jupiter_cassette_formats       ,"Jupiter"},
7072   {"kim1", kim1_cassette_formats             ,"KIM-1"},
7173   {"lviv", lviv_lvt_format                   ,"Lviv"},
src/mess/tools/castool/castool.mak
r6735r6736
4444   $(MESS_FORMATS)/fmsx_cas.o          \
4545   $(MESS_FORMATS)/gtp_cas.o           \
4646   $(MESS_FORMATS)/jupi_tap.o          \
47   $(MESS_FORMATS)/hect_tap.o          \
4748   $(MESS_FORMATS)/kim1_cas.o          \
4849   $(MESS_FORMATS)/lviv_lvt.o          \
4950   $(MESS_FORMATS)/mz_cas.o            \
src/mess/formats/hect_tap.c
r0r6736
1/********************************************************************
2
3Support for Micronique machine .K7 and *.FOR cassette images
4
5Note that the usual type for hector cassette is *.K7,
6     the *.FOR type is only for programming screen in forth format.
7
8You can find some *.K7 file on serveral server in France
9(Micronique is a French factory) Enjoy !
10 
11 jj.stacino@aliceadsl.fr
12
13********************************************************************/
14#include "hect_tap.h"
15
16
17#define SMPLO   -32768
18#define SILENCE   0
19#define SMPHI   32767
20
21
22static int cas_size;
23
24
25int  Header_cycles = 66; //Valeur Théorique = 44100 * 1.5 / 1000  // mesuré sur jeu Formule1 = 1,75ms
26int  Zero_cycles =   17; //Valeur Théorique = 44100 * 0.4 / 1000  // mesuré sur jeu Formule1 = 0,61ms
27int  Un_cycles =     40; //Valeur Théorique = 44100 * 0.9 / 1000  // mesuré sur jeu Formule1 = 1,13ms
28
29/*******************************************************************
30   Generate one high-low cycle of sample data
31********************************************************************/
32INLINE int hector_tap_cycle(INT16 *buffer, int sample_pos, int high, int low)
33{
34   int i = 0;
35
36   if ( buffer )
37   {
38      while( i < high)
39      {
40         buffer[ sample_pos + i ] = SMPHI;
41         i++;
42      }
43
44      while( i < high + low )
45      {
46         buffer[ sample_pos + i ] = SMPLO;
47         i++;
48      }
49   }
50   return high + low;
51}
52
53
54INLINE int hector_tap_byte(INT16 *buffer, int sample_pos, UINT8 data)
55{
56// Writing an entire byte
57   int i, samples;
58
59   samples = 0;
60   for ( i = 0; i < 8; i++ )
61   {
62      if ( data & 0x01 )
63         samples += hector_tap_cycle( buffer, sample_pos + samples, Un_cycles/2, Un_cycles/2 );
64      else
65         samples += hector_tap_cycle( buffer, sample_pos + samples, Zero_cycles/2, Zero_cycles/2 );
66
67      data >>= 1;
68   }
69   return samples;
70}
71
72
73INLINE int hector_tap_synchro(INT16 *buffer, int sample_pos, int nb_synchro)
74{
75// Writing an entire byte
76   int i, samples;
77
78   samples = 0;
79   for ( i = 0; i < nb_synchro ; i++ )
80         samples += hector_tap_cycle( buffer, sample_pos + samples, Header_cycles/2, Header_cycles/2 );
81
82   return samples;
83}
84
85
86static int hector_handle_tap(INT16 *buffer, const UINT8 *casdata)
87{
88   int   data_pos, sample_count, block_count;
89    int previous_block=0;
90
91   data_pos = 0;
92   sample_count = 0;
93    block_count = 0;
94    previous_block = 0;
95   
96   /* First 768 cycle of synchro */
97   sample_count += hector_tap_synchro( buffer, sample_count, 768-4 );     
98   
99   // Sur la longeure du fichier
100    while( data_pos < cas_size )
101   {
102      UINT16   block_size;
103
104        if (previous_block == 0xFE)
105                 /* Starting a block with 150 cycle of synchro to let time to Hector to do the job ! */
106              sample_count += hector_tap_synchro( buffer, sample_count, 150 );
107        else
108                  /* Starting a block with 4 cycle of synchro */
109              sample_count += hector_tap_synchro( buffer, sample_count, 4 );
110
111       if (data_pos>1)
112                previous_block = casdata[data_pos-1];
113
114      /* Handle block lenght on tape data */
115      block_size = casdata[data_pos] ;
116      if (block_size==0)
117         block_size=256;
118         
119      block_count++;
120        sample_count += hector_tap_byte(buffer, sample_count, casdata[data_pos] );
121        data_pos++;
122
123      /* Data samples */
124      for ( ; block_size ; data_pos++, block_size-- )
125        {
126          /* Make sure there are enough bytes left */
127          if ( data_pos > cas_size )
128            return -1;
129
130         sample_count += hector_tap_byte( buffer, sample_count, casdata[data_pos] );
131
132        }
133    }
134    //Finish by a zero
135    sample_count += hector_tap_byte( buffer, sample_count, 0 );
136   
137   return sample_count;
138}
139/////////////////////////////////////////////////////////////////////
140////  FORTH DATA CASSETTE
141/////////////////////////////////////////////////////////////////////
142
143
144static int hector_handle_forth_tap(INT16 *buffer, const UINT8 *casdata)
145{
146   int   data_pos, sample_count, block_count;
147    int previous_block=0;
148
149   data_pos = 0;
150   sample_count = 0;
151    block_count = 0;
152    previous_block = 0;
153
154    // Out if len of file not modulo 822 octets   
155   if ( (cas_size % 822) != 0 )
156      return -1;
157
158   // on the entire file
159    while( data_pos < cas_size )
160   {
161      UINT16   block_size;
162
163       // Starting a block with 768 cycle of synchro
164       sample_count += hector_tap_synchro( buffer, sample_count, 768 );
165
166      // Handle block lenght on tape data
167      block_size = 822 ; // Fixed size for the forth
168
169      block_count=0;
170
171      // Data samples
172      for ( ; block_size ; data_pos++, block_size-- )
173        {
174          // Make sure there are enough bytes left
175          if ( data_pos > cas_size )
176            return -1;
177
178         sample_count += hector_tap_byte( buffer, sample_count, casdata[data_pos] );
179
180        }
181    }
182
183    //Finish by a zero
184    sample_count += hector_tap_byte( buffer, sample_count, 0 );
185   
186   return sample_count;
187}
188///////////////////////////////////////////////////////////////////////
189/////  END FORTH DATA CASSETTE
190///////////////////////////////////////////////////////////////////////
191
192
193/*******************************************************************
194   Generate samples for the tape image
195********************************************************************/
196static int hector_tap_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
197{
198   return hector_handle_tap( buffer, bytes );
199}
200
201
202/*******************************************************************
203   Calculate the number of samples needed for this tape image  FORTH
204********************************************************************/
205static int hector_tap_forth_to_wav_size(const UINT8 *casdata, int caslen)
206{
207   cas_size = caslen ;
208
209   return hector_handle_forth_tap( NULL, casdata );
210}
211
212/*******************************************************************
213   Generate samples for the tape image FORTH
214********************************************************************/
215static int hector_tap_forth_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
216{
217   return hector_handle_forth_tap( buffer, bytes ); //forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
218}
219
220
221/*******************************************************************
222   Calculate the number of samples needed for this tape image classical
223********************************************************************/
224static int hector_tap_to_wav_size(const UINT8 *casdata, int caslen)
225{
226   cas_size = caslen ;
227
228   return hector_handle_tap( NULL, casdata );//forth removed here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
229}
230
231
232static const struct CassetteLegacyWaveFiller hector_legacy_fill_wave =
233{
234   hector_tap_fill_wave,               /* fill_wave */
235   -1,                              /* chunk_size */
236   0,                              /* chunk_samples */
237   hector_tap_to_wav_size,                /* chunk_sample_calc */
238   44100,                           /* sample_frequency */
239   0,                              /* header_samples */
240   0                              /* trailer_samples */
241};
242
243static const struct CassetteLegacyWaveFiller hector_forth_legacy_fill_wave =
244{
245   hector_tap_forth_fill_wave,            /* fill_wave */
246   -1,                              /* chunk_size */
247   0,                              /* chunk_samples */
248   hector_tap_forth_to_wav_size,          /* chunk_sample_calc */
249   44100,                           /* sample_frequency */
250   0,                              /* header_samples */
251   0                              /* trailer_samples */
252};
253
254
255static casserr_t hector_k7_identify(cassette_image *cassette, struct CassetteOptions *opts)
256{
257   return cassette_legacy_identify(cassette, opts, &hector_legacy_fill_wave);
258}
259
260
261static casserr_t hector_k7_load(cassette_image *cassette)
262{
263   return cassette_legacy_construct(cassette, &hector_legacy_fill_wave);
264}
265
266static casserr_t hector_k7forth_identify(cassette_image *cassette, struct CassetteOptions *opts)
267{
268   return cassette_legacy_identify(cassette, opts, &hector_forth_legacy_fill_wave);
269}
270
271
272static casserr_t hector_k7forth_load(cassette_image *cassette)
273{
274   return cassette_legacy_construct(cassette, &hector_forth_legacy_fill_wave);
275}
276
277
278static const struct CassetteFormat hector_k7_format =
279{
280   "k7",
281   hector_k7_identify,
282   hector_k7_load,
283   NULL
284};
285
286static const struct CassetteFormat hector_k7Forth_format =
287{
288   "for",
289   hector_k7forth_identify,
290   hector_k7forth_load,
291   NULL
292};
293
294
295CASSETTE_FORMATLIST_START(hector_cassette_formats)
296   CASSETTE_FORMAT(hector_k7_format)
297   CASSETTE_FORMAT(hector_k7Forth_format)
298CASSETTE_FORMATLIST_END
src/mess/formats/hect_tap.h
r0r6736
1/*********************************************************************
2
3    hect_tap.h
4
5    Format code for Micronique cassette files
6
7*********************************************************************/
8
9#ifndef HECT_TAP_H
10#define HECT_TAP_H
11
12#include "formats/cassimg.h"
13
14CASSETTE_FORMATLIST_EXTERN(hector_cassette_formats);
15
16#endif /* HECT_TAP_H */
17
src/mess/mess.mak
r6735r6736
495495   $(MESS_DEVICES)/appldriv.o   \
496496   $(MESS_FORMATS)/ap2_dsk.o   \
497497   $(MESS_FORMATS)/ap_dsk35.o   \
498   $(MESS_FORMATS)/hect_tap.o   \
498499
499500
500501
src/mess/drivers/interact.c
r6735r6736
3131
3232               => add Keyboard,
3333               => add color,
34               => add cassette,
34               => add cassette (24/12/09 add the *.K7 and *.FOR format for the file and castools),
3535               => add sn76477 sound and 1bit sound,
3636               => add joysticks (stick, pot, fire)
3737               => add BR/HR switching
r6735r6736
5050#include "cpu/i8085/i8085.h"
5151#include "machine/pckeybrd.h"
5252#include "devices/cassette.h"
53#include "formats/hect_tap.h"
5354#include "devices/printer.h"
5455#include "sound/wave.h"      // for K7 sound
5556#include "sound/sn76477.h"   // for sn sound
r6735r6736
8889
8990static const cassette_config interact_cassette_config =
9091{
91   cassette_default_formats,
92   hector_cassette_formats,
9293   &interact_cassette_options,
9394   CASSETTE_STOPPED | CASSETTE_MASK_SPEAKER
9495};
src/mess/drivers/hec2hrp.c
r6735r6736
1515
1616               => add Keyboard,
1717               => add color,
18               => add cassette,
18               => add cassette(24/12/09 add the *.K7 and *.FOR format for the file and castools),
1919               => add sn76477 sound and 1bit sound,
2020               => add joysticks (stick, pot, fire)
2121               => add BR/HR switching
r6735r6736
5050#include "driver.h"
5151#include "machine/pckeybrd.h"
5252#include "devices/cassette.h"
53#include "formats/hect_tap.h"
5354#include "devices/printer.h"
5455#include "sound/wave.h"      // for K7 sound
5556#include "sound/sn76477.h"   // for sn sound
r6735r6736
154155
155156static const cassette_config hector_cassette_config =
156157{
157   cassette_default_formats,
158   hector_cassette_formats,
158159   &hector_cassette_options,
159160   CASSETTE_STOPPED | CASSETTE_MASK_SPEAKER
160161};

Previous 15994 Revisions Next


© 1998-2018 The MESS Team