Previous 15994 Revisions Next

r2697 Thursday 22nd May, 2008 at 19:27:10 UTC by Miodrag Milanović
[GALAXY] GTP file support
[docs]messnew.txt
[src/mess]mess.mak
[src/mess/drivers]galaxy.c
[src/mess/formats]gtp_cas.c* gtp_cas.h*

src/mess/formats/gtp_cas.c
r0r2697
1/*
2   
3   Tape support for Glaksija GTP format
4       
5   Miodrag Milanovic
6*/
7#include "driver.h"
8#include "formats/gtp_cas.h"
9 
10 
11#define GTP_WAV_FREQUENCY   44100
12#define WAVE_LOW      -0x5a9e
13#define WAVE_HIGH      0x5a9e
14#define WAVE_NULL      0
15 
16 
17#define    GTP_BLOCK_STANDARD   0x00
18#define      GTP_BLOCK_TURBO      0x01
19#define      GTP_BLOCK_NAME      0x10
20 
21static INT16   wave_data;
22static INT16     len;
23 
24#define PULSE_WIDTH      30
25#define PERIOD_BASE      150
26#define PERIOD_1      75
27#define PERIOD_0      150
28 
29#define INTERBYTE_PAUSE      225
30#define INTERBLOCK_PAUSE    100000
31 
32 
33static void gtp_output_wave( INT16 **buffer, int length ) {
34   if ( buffer == NULL ) {
35      return;
36   }
37 
38   for( ; length > 0; length-- ) {
39      **buffer = wave_data;
40      *buffer = *buffer + 1;
41   }
42}
43 
44 
45 
46static int gtp_mod_1( INT16 **buffer )
47{
48   wave_data = WAVE_LOW;
49   gtp_output_wave(buffer,PULSE_WIDTH);
50   wave_data = WAVE_HIGH;
51   gtp_output_wave(buffer,PULSE_WIDTH);
52   wave_data = WAVE_NULL;
53   gtp_output_wave(buffer,PERIOD_1 - 2 * PULSE_WIDTH);
54   wave_data = WAVE_LOW;
55   gtp_output_wave(buffer,PULSE_WIDTH);
56   wave_data = WAVE_HIGH;
57   gtp_output_wave(buffer,PULSE_WIDTH);
58   wave_data = WAVE_NULL;
59   gtp_output_wave(buffer,PERIOD_1 - 2 * PULSE_WIDTH);
60   
61   return PERIOD_1 * 2;
62}
63 
64static int gtp_mod_0( INT16 **buffer )
65{
66   wave_data = WAVE_LOW;
67   gtp_output_wave(buffer,PULSE_WIDTH);
68   wave_data = WAVE_HIGH;
69   gtp_output_wave(buffer,PULSE_WIDTH);
70   wave_data = WAVE_NULL;
71   gtp_output_wave(buffer,PERIOD_0 - 2 * PULSE_WIDTH);
72   
73   return PERIOD_0;
74}
75 
76static int gtp_byte( INT16 **buffer, UINT8 val )
77{
78   UINT8 b;
79   int j,size = 0;
80   for (j=0;j<8;j++) {
81      b = (val >> j) & 1;         
82      if (b==0) {             
83         size += gtp_mod_0(buffer);
84      } else {             
85         size += gtp_mod_1(buffer);
86      }             
87   }
88   return size;
89}
90 
91static int gtp_sync( INT16 **buffer )
92{
93   int i;
94   int size = 0;
95 
96   for(i=0;i<100;i++) {
97      if (i!=0) {
98         // Interbyte pause
99         wave_data = WAVE_NULL;
100         gtp_output_wave(buffer,INTERBYTE_PAUSE);         
101         size += INTERBYTE_PAUSE;
102      }
103      size += gtp_byte(buffer,0);
104   }
105   return size;   
106}
107 
108static int gtp_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
109   int size,n;   
110   size = 0;   
111   n = 0;
112   if (casdata == NULL) return -1;
113   while(n<caslen) {             
114      int block_type = casdata[n];
115      int block_size = casdata[n+2]*256 + casdata[n+1];
116      n+=5;
117      if (block_type==GTP_BLOCK_STANDARD) {
118         // Interblock pause
119         size += INTERBLOCK_PAUSE;       
120         size += 100 * (PERIOD_0 * 8 + INTERBYTE_PAUSE) - INTERBYTE_PAUSE;       
121         size += (PERIOD_0 * 8 + INTERBYTE_PAUSE) * block_size;
122      }
123      n += block_size;
124   }           
125   len = caslen;       
126   return size;
127}
128 
129static int gtp_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
130   int i,size,n;   
131   size = 0;   
132   n = 0;
133   if (bytes == NULL) return -1;
134   while(n<len) 
135   {         
136      int block_type = bytes[n];
137      int block_size = bytes[n+2]*256 + bytes[n+1];
138      n+=5;
139      if (block_type==GTP_BLOCK_STANDARD) {
140 
141         // Interblock pause
142         wave_data = WAVE_NULL;
143         gtp_output_wave(&buffer,INTERBLOCK_PAUSE);
144         size += INTERBLOCK_PAUSE;       
145         size += gtp_sync(&buffer);
146         
147         for (i=0;i<block_size;i++) {
148            // Interbyte pause
149            wave_data = WAVE_NULL;
150            gtp_output_wave(&buffer,INTERBYTE_PAUSE);         
151            size += INTERBYTE_PAUSE;
152             
153            size += gtp_byte(&buffer,bytes[n]);
154            n++;
155         }         
156      }
157   }             
158   return size;
159}
160 
161 
162 
163 
164static const struct CassetteLegacyWaveFiller gtp_legacy_fill_wave = {
165   gtp_cas_fill_wave,         /* fill_wave */
166   -1,               /* chunk_size */
167   0,               /* chunk_samples */
168   gtp_cas_to_wav_size,         /* chunk_sample_calc */
169   GTP_WAV_FREQUENCY,         /* sample_frequency */
170   0,               /* header_samples */
171   0               /* trailer_samples */
172};
173 
174 
175 
176static casserr_t gtp_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts ) {
177   return cassette_legacy_identify( cassette, opts, &gtp_legacy_fill_wave );
178}
179 
180 
181 
182static casserr_t gtp_cassette_load( cassette_image *cassette ) {
183   return cassette_legacy_construct( cassette, &gtp_legacy_fill_wave );
184}
185 
186 
187 
188static const struct CassetteFormat gtp_cassette_format = {
189   "gtp",
190   gtp_cassette_identify,
191   gtp_cassette_load,
192   NULL
193};
194 
195 
196CASSETTE_FORMATLIST_START(gtp_cassette_formats)
197   CASSETTE_FORMAT(gtp_cassette_format)
198CASSETTE_FORMATLIST_END
199 
200 
src/mess/formats/gtp_cas.h
r0r2697
1/*
2 
3       gtp_cas.h
4 
5       Format code for gtp cassette files
6*/
7 
8#ifndef GTP_CAS_H
9#define GTP_CAS_H
10 
11#include "formats/cassimg.h"
12 
13CASSETTE_FORMATLIST_EXTERN(gtp_cassette_formats);
14 
15#endif /* GTP_CAS_H */
src/mess/mess.mak
r2696r2697
10031003   $(MESS_VIDEO)/galaxy.o   \
10041004   $(MESS_DRIVERS)/galaxy.o   \
10051005   $(MESS_MACHINE)/galaxy.o   \
1006   $(MESS_FORMATS)/gtp_cas.o   \
10061007
10071008$(MESSOBJ)/lviv.a:   \
10081009   $(MESS_VIDEO)/lviv.o   \
src/mess/drivers/galaxy.c
r2696r2697
2727#include "devices/snapquik.h"
2828#include "devices/cassette.h"
2929#include "sound/ay8910.h"
30#include "formats/gtp_cas.h"
3031
3132static ADDRESS_MAP_START (galaxyp_io, ADDRESS_SPACE_IO, 8)
3233   ADDRESS_MAP_GLOBAL_MASK(0x01)
r2696r2697
168169   /* video hardware */
169170   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
170171   MDRV_SCREEN_SIZE(384, 212)
171   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 0, 212-1)
172   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 0, 208-1)
172173   MDRV_GFXDECODE( galaxy )
173174   MDRV_PALETTE_LENGTH(sizeof (galaxy_palette) / 3)
174175   MDRV_PALETTE_INIT( galaxy )
r2696r2697
242243      /* --- the following bits of info are returned as 64-bit signed integers --- */
243244      case MESS_DEVINFO_INT_COUNT:            info->i = 1; break;
244245      case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE:   info->i = CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED; break;
245
246      case MESS_DEVINFO_PTR_CASSETTE_FORMATS:      info->p = (void *)gtp_cassette_formats; break;   
246247      default:               cassette_device_getinfo(devclass, state, info); break;
247248   }
248249}
docs/messnew.txt
r2696r2697
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
55- OSCOM Nano  [Curt Coder, HobbyLabs]
6- Galaksija Plus [Miodrag Milanovic]
67
78
8
99System Driver Changes:
1010----------------------
1111- [AMIGA] Partial keyboard fix. [Roberto Zandonà]
r2696r2697
2121
2222- [COMX35] System is now working.  [Curt Coder, Marcel van Tongeren]
2323
24- [GALAXY] Added real video emulation [Miodrag Milanovic]
25
26- [GALAXY] GTP file support [Miodrag Milanovic]
27
2428- [GAMEBOY] Added .bin extension.  [Fabio Priuli]
2529
2630- [GENESIS / MD] Fixed cheat issue [ShimaPong, Fabio Priuli]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team