-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lookup.cs
346 lines (290 loc) · 10.1 KB
/
Lookup.cs
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
using RetroDevStudio.Formats;
using System;
namespace RetroDevStudio
{
static class Lookup
{
public static int NumberOfColorsInCharacter( TextCharMode Mode )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
case TextCharMode.COMMODORE_HIRES:
case TextCharMode.COMMODORE_MULTICOLOR:
case TextCharMode.VIC20:
return 16;
case TextCharMode.MEGA65_FCM:
case TextCharMode.MEGA65_FCM_16BIT:
return 256;
default:
Debug.Log( "NumberOfColorsInCharacter unsupported Mode " + Mode );
return 16;
}
}
public static int NumBytesOfSingleCharacter( TextCharMode Mode )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
case TextCharMode.COMMODORE_HIRES:
case TextCharMode.COMMODORE_MULTICOLOR:
case TextCharMode.VIC20:
return 8;
case TextCharMode.MEGA65_FCM:
case TextCharMode.MEGA65_FCM_16BIT:
return 64;
default:
Debug.Log( "NumBytesOfSingleCharacter unsupported Mode " + Mode );
return 8;
}
}
internal static int NumBytes( int Width, int Height, GraphicTileMode Mode )
{
switch ( Mode )
{
case GraphicTileMode.COMMODORE_ECM:
case GraphicTileMode.COMMODORE_HIRES:
case GraphicTileMode.COMMODORE_MULTICOLOR:
return ( ( Width + 7 ) / 8 ) * Height;
case GraphicTileMode.MEGA65_FCM_16_COLORS:
return ( ( Width + 1 ) / 2 ) * Height;
case GraphicTileMode.MEGA65_FCM_256_COLORS:
return Width * Height;
default:
Debug.Log( "Lookup.NumBytes unsupported mode " + Mode );
return 0;
}
}
public static TextCharMode FromTextMode( TextMode Mode )
{
switch ( Mode )
{
case TextMode.COMMODORE_40_X_25_ECM:
case TextMode.MEGA65_80_X_25_ECM:
return TextCharMode.COMMODORE_ECM;
case TextMode.COMMODORE_40_X_25_HIRES:
case TextMode.MEGA65_80_X_25_HIRES:
return TextCharMode.COMMODORE_HIRES;
case TextMode.COMMODORE_40_X_25_MULTICOLOR:
case TextMode.MEGA65_80_X_25_MULTICOLOR:
return TextCharMode.COMMODORE_MULTICOLOR;
case TextMode.MEGA65_40_X_25_FCM:
case TextMode.MEGA65_80_X_25_FCM:
return TextCharMode.MEGA65_FCM;
case TextMode.MEGA65_40_X_25_FCM_16BIT:
case TextMode.MEGA65_80_X_25_FCM_16BIT:
return TextCharMode.MEGA65_FCM_16BIT;
case TextMode.COMMODORE_VIC20_22_X_23:
return TextCharMode.VIC20;
default:
Debug.Log( "FromTextMode unsupported Mode " + Mode );
return TextCharMode.COMMODORE_HIRES;
}
}
internal static int NumCharactersForMode( TextCharMode Mode )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
case TextCharMode.COMMODORE_HIRES:
case TextCharMode.COMMODORE_MULTICOLOR:
case TextCharMode.MEGA65_FCM:
case TextCharMode.VIC20:
return 256;
case TextCharMode.MEGA65_FCM_16BIT:
return 8192;
default:
Debug.Log( "NumCharactersForMode unsupported Mode " + Mode );
return 256;
}
}
internal static bool RequiresCustomColorForCharacter( TextCharMode Mode )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
case TextCharMode.COMMODORE_HIRES:
case TextCharMode.COMMODORE_MULTICOLOR:
case TextCharMode.VIC20:
return true;
case TextCharMode.MEGA65_FCM:
case TextCharMode.MEGA65_FCM_16BIT:
return false;
default:
Debug.Log( "RequiresCustomColorForCharacter unsupported Mode " + Mode );
return false;
}
}
internal static bool HasCustomPalette( GraphicTileMode Mode )
{
switch ( Mode )
{
case GraphicTileMode.COMMODORE_ECM:
case GraphicTileMode.COMMODORE_HIRES:
case GraphicTileMode.COMMODORE_MULTICOLOR:
return false;
case GraphicTileMode.MEGA65_FCM_16_COLORS:
case GraphicTileMode.MEGA65_FCM_256_COLORS:
return true;
default:
Debug.Log( "HasCustomPalette unsupported Mode " + Mode );
return false;
}
}
internal static int NumBytesOfSingleSprite( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
return 63;
case SpriteProject.SpriteProjectMode.MEGA65_8_X_21_16_COLORS:
return 84;
case SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS:
return 168;
default:
Debug.Log( "NumBytesOfSingleSprite unsupported Mode " + Mode );
return 63;
}
}
internal static int NumPaddedBytesOfSingleSprite( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
return 64;
case SpriteProject.SpriteProjectMode.MEGA65_8_X_21_16_COLORS:
return 128;
case SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS:
return 256;
default:
Debug.Log( "NumPaddedBytesOfSingleSprite unsupported Mode " + Mode );
return 64;
}
}
internal static int NumberOfColorsInSprite( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
case SpriteProject.SpriteProjectMode.MEGA65_8_X_21_16_COLORS:
case SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS:
return 16;
default:
Debug.Log( "NumberOfColorsInCharacter unsupported Mode " + Mode );
return 16;
}
}
internal static GraphicTileMode GraphicTileModeFromTextCharMode( TextCharMode Mode, int CustomColor )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
return GraphicTileMode.COMMODORE_ECM;
case TextCharMode.COMMODORE_HIRES:
default:
return GraphicTileMode.COMMODORE_HIRES;
case TextCharMode.COMMODORE_MULTICOLOR:
case TextCharMode.VIC20:
if ( CustomColor < 8 )
{
return GraphicTileMode.COMMODORE_HIRES;
}
return GraphicTileMode.COMMODORE_MULTICOLOR;
case TextCharMode.MEGA65_FCM:
return GraphicTileMode.MEGA65_FCM_256_COLORS;
}
}
internal static GraphicTileMode GraphicTileModeFromSpriteDisplayMode( SpriteDisplayMode Mode )
{
switch ( Mode )
{
case SpriteDisplayMode.COMMODORE_24_X_21_HIRES:
default:
return GraphicTileMode.COMMODORE_HIRES;
case SpriteDisplayMode.COMMODORE_24_X_21_MULTICOLOR:
return GraphicTileMode.COMMODORE_MULTICOLOR;
case SpriteDisplayMode.MEGA65_8_X_21_16_COLORS:
case SpriteDisplayMode.MEGA65_16_X_21_16_COLORS:
return GraphicTileMode.MEGA65_FCM_16_COLORS;
}
}
internal static GraphicTileMode GraphicTileModeFromSpriteProjectMode( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
default:
return GraphicTileMode.COMMODORE_HIRES;
case SpriteProject.SpriteProjectMode.MEGA65_8_X_21_16_COLORS:
case SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS:
return GraphicTileMode.MEGA65_FCM_16_COLORS;
}
}
internal static bool HaveCustomSpriteColor( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
return true;
}
return false;
}
internal static SpriteMode SpriteModeFromSpriteProjectMode( SpriteProject.SpriteProjectMode Mode )
{
switch ( Mode )
{
case SpriteProject.SpriteProjectMode.COMMODORE_24_X_21_HIRES_OR_MC:
default:
// TODO - not correct!
return SpriteMode.COMMODORE_24_X_21_HIRES;
case SpriteProject.SpriteProjectMode.MEGA65_8_X_21_16_COLORS:
return SpriteMode.MEGA65_8_X_21_16_COLORS;
case SpriteProject.SpriteProjectMode.MEGA65_16_X_21_16_COLORS:
return SpriteMode.MEGA65_16_X_21_16_COLORS;
}
}
internal static int PixelWidth( GraphicTileMode Mode )
{
switch ( Mode )
{
case GraphicTileMode.COMMODORE_MULTICOLOR:
return 2;
}
return 1;
}
internal static TextMode TextModeFromTextCharMode( TextCharMode Mode )
{
switch ( Mode )
{
case TextCharMode.COMMODORE_ECM:
return TextMode.COMMODORE_40_X_25_ECM;
case TextCharMode.COMMODORE_HIRES:
default:
return TextMode.COMMODORE_40_X_25_HIRES;
case TextCharMode.COMMODORE_MULTICOLOR:
return TextMode.COMMODORE_40_X_25_MULTICOLOR;
case TextCharMode.MEGA65_FCM:
return TextMode.MEGA65_40_X_25_FCM;
case TextCharMode.MEGA65_FCM_16BIT:
return TextMode.MEGA65_40_X_25_FCM_16BIT;
case TextCharMode.VIC20:
return TextMode.COMMODORE_VIC20_22_X_23;
}
}
internal static SpriteMode SpriteModeFromTileMode( GraphicTileMode Mode )
{
switch ( Mode )
{
case GraphicTileMode.COMMODORE_ECM:
case GraphicTileMode.COMMODORE_HIRES:
default:
return SpriteMode.COMMODORE_24_X_21_HIRES;
case GraphicTileMode.COMMODORE_MULTICOLOR:
return SpriteMode.COMMODORE_24_X_21_MULTICOLOR;
case GraphicTileMode.MEGA65_FCM_16_COLORS:
case GraphicTileMode.MEGA65_FCM_256_COLORS:
return SpriteMode.MEGA65_16_X_21_16_COLORS;
}
}
}
}