1 /* fmfconv_types.c: .fmf movie file types
2    Copyright (c) 2017 Fredrick Meunier
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License along
15    with this program; if not, write to the Free Software Foundation, Inc.,
16    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 
18    Author contact information:
19 
20    E-mail: fredm@spamcop.net
21 */
22 
23 #include <stdlib.h>
24 
25 #include "fmfconv.h"
26 
27 fmf_screen_type
get_screen_type(libspectrum_byte screen_type)28 get_screen_type(libspectrum_byte screen_type)
29 {
30   fmf_screen_type retval;
31 
32   switch(screen_type) {
33   case '$':
34     retval = STANDARD;
35     break;
36   case 'X':
37     retval = STANDARD_TIMEX;
38     break;
39   case 'R':
40     retval = HIRES;
41     break;
42   case 'C':
43     retval = HICOLOR;
44     break;
45   default:
46     printe( "Unknown Screen$ type '%d', sorry...\n", screen_type );
47     exit(-1);
48     break;
49   }
50 
51   return retval;
52 }
53 
54 fmf_sound_type
get_sound_type(int sound_type)55 get_sound_type( int sound_type )
56 {
57   fmf_sound_type retval;
58 
59   switch(sound_type) {
60   case 'P':
61     retval = PCM;
62     break;
63   case 'A':
64     retval = ALW;
65     break;
66   case 'U':
67     retval = ULW;
68     break;
69   default:
70     printe( "Unknown sound_type:%x\n", sound_type );
71     exit( -1 );
72     break;
73   }
74 
75   return retval;
76 }
77 
78 const char*
get_sound_type_string(fmf_sound_type sound_type)79 get_sound_type_string( fmf_sound_type sound_type )
80 {
81   const char *retval;
82 
83   switch( sound_type ) {
84   case PCM:
85     retval = "PCM";
86     break;
87   case ALW:
88     retval = "ALAW";
89     break;
90   case ULW:
91     retval = "ULAW";
92     break;
93   default:
94     printe( "Unknown sound_type:%x\n", sound_type );
95     exit(-1);
96     break;
97   }
98 
99   return retval;
100 }
101 
102 fmf_sound_channels_type
get_sound_channels_type(int sound_channels_type)103 get_sound_channels_type( int sound_channels_type )
104 {
105   fmf_sound_channels_type retval;
106 
107   switch( sound_channels_type ) {
108   case 'S':
109     retval = STEREO;
110     break;
111   case 'M':
112     retval = MONO;
113     break;
114   default:
115     printe( "Unknown FMF sound channels type '%d', sorry...\n", sound_channels_type );
116     exit(-1);
117     break;
118   }
119 
120   return retval;
121 }
122 
123 int
get_sound_channels_count(int sound_channels_type)124 get_sound_channels_count( int sound_channels_type )
125 {
126   return get_sound_channels_type( sound_channels_type ) == STEREO ? 2 : 1;
127 }
128 
129 fmf_machine_type
get_machine_type(char machine_type)130 get_machine_type( char machine_type )
131 {
132   fmf_machine_type retval;
133 
134   switch(machine_type) {
135   case 'A':
136     retval = SPECTRUM_48K_LIKE;
137     break;
138   case 'B':
139     retval = SPECTRUM_128K_LIKE;
140     break;
141   case 'C':
142     retval = TS2068_LIKE;
143     break;
144   case 'D':
145     retval = PENTAGON_LIKE;
146     break;
147   case 'E':
148     retval = SPECTRUM_NTSC_LIKE;
149     break;
150   default:
151     printe( "Unknown Machine type '%c', sorry...\n", machine_type );
152     exit(-1);
153     break;
154   }
155 
156   return retval;
157 }
158 
159 const char *machine_name[] = {
160  "ZX Spectrum 16K/48K, Timex TC2048/2068, Scorpion, Spectrum SE",	/* A */
161  "ZX Spectrum 128K/+2/+2A/+3/+3e/128Ke",				/* B */
162  "Timex TS2068", 							/* C */
163  "Pentagon 128K/512K/1024K"						/* D */
164  "ZX Spectrum 48K (NTSC)"						/* E */
165 };
166 
167 const char*
get_machine_type_string(fmf_machine_type type)168 get_machine_type_string(fmf_machine_type type) {
169   return machine_name[type];
170 }
171