summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/special.c
Bad commit: 5ae389eef4755866b11a7e3038ff74b220814ee4
>
fe68338c2ca

62d841c2703




10385fe1302

62d841c2703


0e19f641d31


62d841c2703
0e19f641d31
62d841c2703




0e19f641d31
62d841c2703
ddb290d5f61
62d841c2703









ddb290d5f61
62d841c2703











0e19f641d31
62d841c2703

ddb290d5f61
62d841c2703








ddb290d5f61
62d841c2703



ddb290d5f61
62d841c2703



ddb290d5f61
62d841c2703



ddb290d5f61
62d841c2703



ddb290d5f61
62d841c2703
ddb290d5f61
62d841c2703












ddb290d5f61
62d841c2703
ddb290d5f61
62d841c2703












ddb290d5f61
62d841c2703
ddb290d5f61
62d841c2703












ddb290d5f61
62d841c2703
ddb290d5f61
62d841c2703











0e19f641d31






62d841c2703

d1227cb38f2
62d841c2703


d1227cb38f2
62d841c2703



0e19f641d31






62d841c2703

d1227cb38f2
62d841c2703


d1227cb38f2
62d841c2703



0e19f641d31






62d841c2703

d1227cb38f2
62d841c2703


d1227cb38f2
62d841c2703



0e19f641d31






62d841c2703

d1227cb38f2
62d841c2703


d1227cb38f2
62d841c2703






5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





5a2f80dcde2
62d841c2703





































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
310
311
312
313
314

                                      




                              

                   


                   


                                 
 
                           




                     
                          
 
                                                               









                               
                                                                











                                                          
                 

 
                                                                    








                                                               
                                                                       



                                                                              
                                                                       



                                                                              
                                                                       



                                                                              
                                                                      



                                                                        
                                                                              
              
                             












                                                             
                                                                              
              
                             












                                                             
                                                                              
              
                             












                                                             
                                                                             
              
                             











                                                                      






                                                               

  
                                                                                                               


                                                                                  
                                                                             



                                                                             






                                                               

  
                                                                                                               


                                                                                  
                                                                             



                                                                             






                                                               

  
                                                                                                              


                                                                                 
                                                                            



                                                                            






                                                               

  
                                                                                                               


                                                                                  
                                                                             






                                                                             
               





                                                          
               





                                                          
               





                                                          
               





                                                          
               





                                                          
               





                                                          
               





                                                          
               





                                                          
               





































                                               
// license:BSD-3-Clause
// copyright-holders:Miodrag Milanovic
/*

    Tape support for RK format

*/
#include <assert.h>

#include "rk_cas.h"


#define RK_WAV_FREQUENCY    44000
#define WAVE_HIGH       32767
#define WAVE_LOW        -32768

#define RK_HEADER_LEN   256

#define RK_SIZE_20 20
#define RK_SIZE_22 22
#define RK_SIZE_60 60

static int      data_size;

static int16_t *rk_emit_level(int16_t *p, int count, int level)
{
	int i;

	for (i=0; i<count; i++)
	{
		*(p++) = level;
	}
	return p;
}

static int16_t* rk_output_bit(int16_t *p, uint8_t b,int bitsize)
{
	if (b)
	{
		p = rk_emit_level (p, bitsize, WAVE_HIGH);
		p = rk_emit_level (p, bitsize, WAVE_LOW);
	}
	else
	{
		p = rk_emit_level (p, bitsize, WAVE_LOW);
		p = rk_emit_level (p, bitsize, WAVE_HIGH);

	}
	return p;
}

static int16_t* rk_output_byte(int16_t *p, uint8_t byte,int bitsize)
{
	int i;
	for (i=7; i>=0; i--)
		p = rk_output_bit(p,(byte>>i) & 0x01, bitsize);

	return p;
}


static int rk20_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
	data_size = caslen;
	return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_20;
}

static int rk22_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
	data_size = caslen;
	return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_22;
}

static int rk60_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
	data_size = caslen;
	return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_60;
}

static int gam_cas_to_wav_size( const uint8_t *casdata, int caslen ) {
	data_size = caslen;
	return  (RK_HEADER_LEN  * 8 * 2 +  caslen * 8 * 2) * RK_SIZE_20;
}

static int rk20_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes ) {
	int i;
	int16_t * p = buffer;

	for (i=0; i<RK_HEADER_LEN; i++) {
		p = rk_output_byte (p, 0x00, RK_SIZE_20 );
	}

	p = rk_output_byte (p, 0xE6, RK_SIZE_20);

	for (i=0; i<data_size; i++)
		p = rk_output_byte (p, bytes[i], RK_SIZE_20);

	return p - buffer;
}

static int rk22_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes ) {
	int i;
	int16_t * p = buffer;

	for (i=0; i<RK_HEADER_LEN; i++) {
		p = rk_output_byte (p, 0x00, RK_SIZE_22 );
	}

	p = rk_output_byte (p, 0xE6, RK_SIZE_22);

	for (i=0; i<data_size; i++)
		p = rk_output_byte (p, bytes[i], RK_SIZE_22);

	return p - buffer;
}

static int rk60_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes ) {
	int i;
	int16_t * p = buffer;

	for (i=0; i<RK_HEADER_LEN; i++) {
		p = rk_output_byte (p, 0x00, RK_SIZE_60 );
	}

	p = rk_output_byte (p, 0xE6, RK_SIZE_60);

	for (i=0; i<data_size; i++)
		p = rk_output_byte (p, bytes[i], RK_SIZE_60);

	return p - buffer;
}

static int gam_cas_fill_wave( int16_t *buffer, int length, uint8_t *bytes ) {
	int i;
	int16_t * p = buffer;

	for (i=0; i<RK_HEADER_LEN; i++) {
		p = rk_output_byte (p, 0x00, RK_SIZE_20 );
	}

	for (i=0; i<data_size; i++)
		p = rk_output_byte (p, bytes[i], RK_SIZE_20);

	return p - buffer;
}

static const struct CassetteLegacyWaveFiller rk20_legacy_fill_wave = {
	rk20_cas_fill_wave,         /* fill_wave */
	-1,                 /* chunk_size */
	0,                  /* chunk_samples */
	rk20_cas_to_wav_size,           /* chunk_sample_calc */
	RK_WAV_FREQUENCY,           /* sample_frequency */
	0,                  /* header_samples */
	0                   /* trailer_samples */
};

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

static cassette_image::error rk20_cassette_load( cassette_image *cassette ) {
	return cassette_legacy_construct( cassette, &rk20_legacy_fill_wave );
}

static const struct CassetteLegacyWaveFiller rk22_legacy_fill_wave = {
	rk22_cas_fill_wave,         /* fill_wave */
	-1,                 /* chunk_size */
	0,                  /* chunk_samples */
	rk22_cas_to_wav_size,           /* chunk_sample_calc */
	RK_WAV_FREQUENCY,           /* sample_frequency */
	0,                  /* header_samples */
	0                   /* trailer_samples */
};

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

static cassette_image::error rk22_cassette_load( cassette_image *cassette ) {
	return cassette_legacy_construct( cassette, &rk22_legacy_fill_wave );
}

static const struct CassetteLegacyWaveFiller gam_legacy_fill_wave = {
	gam_cas_fill_wave,          /* fill_wave */
	-1,                 /* chunk_size */
	0,                  /* chunk_samples */
	gam_cas_to_wav_size,            /* chunk_sample_calc */
	RK_WAV_FREQUENCY,           /* sample_frequency */
	0,                  /* header_samples */
	0                   /* trailer_samples */
};

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

static cassette_image::error gam_cassette_load( cassette_image *cassette ) {
	return cassette_legacy_construct( cassette, &gam_legacy_fill_wave );
}

static const struct CassetteLegacyWaveFiller rk60_legacy_fill_wave = {
	rk60_cas_fill_wave,         /* fill_wave */
	-1,                 /* chunk_size */
	0,                  /* chunk_samples */
	rk60_cas_to_wav_size,           /* chunk_sample_calc */
	RK_WAV_FREQUENCY,           /* sample_frequency */
	0,                  /* header_samples */
	0                   /* trailer_samples */
};

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

static cassette_image::error rk60_cassette_load( cassette_image *cassette ) {
	return cassette_legacy_construct( cassette, &rk60_legacy_fill_wave );
}

static const struct CassetteFormat rku_cassette_format = {
	"rku",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat rk8_cassette_format = {
	"rk8",
	rk60_cassette_identify,
	rk60_cassette_load,
	nullptr
};

static const struct CassetteFormat rks_cassette_format = {
	"rks",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat rko_cassette_format = {
	"rko",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat rkr_cassette_format = {
	"rk,rkr",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat rka_cassette_format = {
	"rka",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat rkm_cassette_format = {
	"rkm",
	rk22_cassette_identify,
	rk22_cassette_load,
	nullptr
};

static const struct CassetteFormat rkp_cassette_format = {
	"rkp",
	rk20_cassette_identify,
	rk20_cassette_load,
	nullptr
};

static const struct CassetteFormat gam_cassette_format = {
	"gam,g16,pki",
	gam_cassette_identify,
	gam_cassette_load,
	nullptr
};

CASSETTE_FORMATLIST_START(rku_cassette_formats)
	CASSETTE_FORMAT(rku_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rk8_cassette_formats)
	CASSETTE_FORMAT(rk8_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rks_cassette_formats)
	CASSETTE_FORMAT(rks_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rko_cassette_formats)
	CASSETTE_FORMAT(rko_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rkr_cassette_formats)
	CASSETTE_FORMAT(rkr_cassette_format)
	CASSETTE_FORMAT(gam_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rka_cassette_formats)
	CASSETTE_FORMAT(rka_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rkm_cassette_formats)
	CASSETTE_FORMAT(rkm_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(rkp_cassette_formats)
	CASSETTE_FORMAT(rkp_cassette_format)
CASSETTE_FORMATLIST_END

CASSETTE_FORMATLIST_START(gam_cassette_formats)
	CASSETTE_FORMAT(gam_cassette_format)
CASSETTE_FORMATLIST_END