~ubuntu-branches/ubuntu/dapper/vice/dapper

« back to all changes in this revision

Viewing changes to src/video/video-resources.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2004-08-26 13:35:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040826133551-gcje8j31q5cqgdq2
Tags: 1.14-3
Apply patch from Spiro Trikaliotis <vice@trikaliotis.net> to fix a
problem that some users were experiencing with a floating point
exception on startup related to the fullscreen option being enabled
during compile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Written by
5
5
 *  John Selck <graham@cruise.de>
 
6
 *  Andreas Boose <viceteam@t-online.de>
6
7
 *
7
8
 * This file is part of VICE, the Versatile Commodore Emulator.
8
9
 * See README for copyright notice.
29
30
#include <stdio.h>
30
31
 
31
32
#include "resources.h"
32
 
#include "utils.h"
 
33
#include "lib.h"
33
34
#include "video-resources.h"
34
35
#include "video-color.h"
35
36
#include "video.h"
36
37
#include "videoarch.h"
37
 
#include "ui.h"
 
38
#include "util.h"
38
39
 
39
40
 
40
41
video_resources_t video_resources =
41
42
{
42
 
    1000, 1100, 1100, 880,
43
 
    0, 0,
44
 
    0, 0,
45
 
};
46
 
 
47
 
static int set_color_saturation(resource_value_t v, void *param)
48
 
{
49
 
    int val;
50
 
    val = (int)v;
51
 
    if (val < 0)
52
 
        val = 0;
53
 
    if (val > 2000)
54
 
        val = 2000;
55
 
    video_resources.color_saturation = val;
56
 
    return video_color_update_palette();
57
 
}
58
 
 
59
 
static int set_color_contrast(resource_value_t v, void *param)
60
 
{
61
 
    int val;
62
 
    val = (int)v;
63
 
    if (val < 0)
64
 
        val = 0;
65
 
    if (val > 2000)
66
 
        val = 2000;
67
 
    video_resources.color_contrast = val;
68
 
    return video_color_update_palette();
69
 
}
70
 
 
71
 
static int set_color_brightness(resource_value_t v, void *param)
72
 
{
73
 
    int val;
74
 
    val = (int)v;
75
 
    if (val < 0)
76
 
        val = 0;
77
 
    if (val > 2000)
78
 
        val = 2000;
79
 
    video_resources.color_brightness = val;
80
 
    return video_color_update_palette();
81
 
}
82
 
 
83
 
static int set_color_gamma(resource_value_t v, void *param)
84
 
{
85
 
    int val;
86
 
    val = (int)v;
87
 
    if (val < 0)
88
 
        val=0;
89
 
    if (val > 2000)
90
 
        val=2000;
91
 
    video_resources.color_gamma = val;
92
 
    return video_color_update_palette();
93
 
}
 
43
    1000, 1100, 1100, 880, 500,
 
44
    0, 0, 0
 
45
};
 
46
 
 
47
int video_resources_init(void)
 
48
{
 
49
    return video_arch_resources_init();
 
50
}
 
51
 
 
52
void video_resources_shutdown(void)
 
53
{
 
54
    video_arch_resources_shutdown();
 
55
}
 
56
 
 
57
/*-----------------------------------------------------------------------*/
 
58
/* Per chip resources.  */
 
59
 
 
60
struct video_resource_chip_s {
 
61
    struct video_canvas_s **canvas;
 
62
    video_chip_cap_t *video_chip_cap;
 
63
    int double_scan_enabled;
 
64
    int double_size_enabled;
 
65
    int scale2x_enabled;
 
66
    int fullscreen_enabled;
 
67
    char *fullscreen_device;
 
68
    int fullscreen_double_size_enabled;
 
69
    int fullscreen_double_scan_enabled;
 
70
    int fullscreen_mode[FULLSCREEN_MAXDEV];
 
71
    int external_palette_enabled;
 
72
    char *external_palette_name;
 
73
};
 
74
typedef struct video_resource_chip_s video_resource_chip_t;
 
75
 
 
76
static void video_resources_update_ui(video_resource_chip_t *video_resource_chip);
 
77
 
 
78
struct video_resource_chip_mode_s {
 
79
    video_resource_chip_t *resource_chip;
 
80
    unsigned int device;
 
81
};
 
82
typedef struct video_resource_chip_mode_s video_resource_chip_mode_t;
 
83
 
 
84
static int set_double_size_enabled(resource_value_t v, void *param)
 
85
{
 
86
    video_resource_chip_t *video_resource_chip;
 
87
    video_chip_cap_t *video_chip_cap;
 
88
    cap_render_t *cap_render;
 
89
    video_canvas_t *canvas;
 
90
 
 
91
    video_resource_chip = (video_resource_chip_t *)param;
 
92
    video_chip_cap = video_resource_chip->video_chip_cap;
 
93
    canvas = *(video_resource_chip->canvas);
 
94
 
 
95
    if ((int)v)
 
96
        cap_render = &video_chip_cap->double_mode;
 
97
    else
 
98
        cap_render = &video_chip_cap->single_mode;
 
99
 
 
100
    canvas->videoconfig->rendermode = cap_render->rmode;
 
101
 
 
102
    if (cap_render->sizex > 1
 
103
        && (video_chip_cap->dsize_limit_width == 0
 
104
        || canvas->draw_buffer->canvas_width
 
105
        <= video_chip_cap->dsize_limit_width))
 
106
        canvas->videoconfig->doublesizex = 1;
 
107
    else
 
108
        canvas->videoconfig->doublesizex = 0;
 
109
 
 
110
    if (cap_render->sizey > 1
 
111
        && (video_chip_cap->dsize_limit_height == 0
 
112
        || canvas->draw_buffer->canvas_height
 
113
        <= video_chip_cap->dsize_limit_height))
 
114
        canvas->videoconfig->doublesizey = 1;
 
115
    else
 
116
        canvas->videoconfig->doublesizey = 0;
 
117
 
 
118
    /* FIXME: Kludge needed until kind of render and dimensions are
 
119
       separated from `rendermode' (which is overloaded currently). */
 
120
    if (canvas->videoconfig->rendermode == VIDEO_RENDER_RGB_2X2) {
 
121
        if (canvas->videoconfig->doublesizex == 0)
 
122
            canvas->videoconfig->rendermode = VIDEO_RENDER_RGB_1X2;
 
123
        if (canvas->videoconfig->doublesizex == 0
 
124
            && canvas->videoconfig->doublesizey == 0)
 
125
            canvas->videoconfig->rendermode = VIDEO_RENDER_RGB_1X1;
 
126
    }
 
127
 
 
128
    if (video_resource_chip->double_size_enabled != (int)v
 
129
        && canvas->initialized
 
130
        && canvas->viewport->update_canvas > 0) {
 
131
        video_viewport_resize(canvas);
 
132
    }
 
133
 
 
134
    video_resource_chip->double_size_enabled = (int)v;
 
135
 
 
136
    video_resources_update_ui(video_resource_chip);
 
137
 
 
138
    return 0;
 
139
}
 
140
 
 
141
static const char *vname_chip_size[] = { "DoubleSize", NULL };
 
142
 
 
143
static resource_t resources_chip_size[] =
 
144
{
 
145
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
146
      set_double_size_enabled, NULL },
 
147
    { NULL }
 
148
};
 
149
 
 
150
static int set_double_scan_enabled(resource_value_t v, void *param)
 
151
{
 
152
    video_resource_chip_t *video_resource_chip;
 
153
    video_canvas_t *canvas;
 
154
 
 
155
    video_resource_chip = (video_resource_chip_t *)param;
 
156
    canvas = *(video_resource_chip->canvas);
 
157
 
 
158
    video_resource_chip->double_scan_enabled = (int)v;
 
159
    canvas->videoconfig->doublescan = (int)v;
 
160
 
 
161
    if (canvas->initialized)
 
162
        video_canvas_refresh_all(canvas);
 
163
 
 
164
    video_resources_update_ui(video_resource_chip);
 
165
 
 
166
    return 0;
 
167
}
 
168
 
 
169
static const char *vname_chip_scan[] = { "DoubleScan", NULL };
 
170
 
 
171
static resource_t resources_chip_scan[] =
 
172
{
 
173
    { NULL, RES_INTEGER, (resource_value_t)1, NULL,
 
174
      set_double_scan_enabled, NULL },
 
175
    { NULL }
 
176
};
 
177
 
 
178
static int set_scale2x_enabled(resource_value_t v, void *param)
 
179
{
 
180
    video_resource_chip_t *video_resource_chip;
 
181
    video_canvas_t *canvas;
 
182
 
 
183
    video_resource_chip = (video_resource_chip_t *)param;
 
184
    canvas = *(video_resource_chip->canvas);
 
185
 
 
186
    video_resource_chip->scale2x_enabled = (int)v;
 
187
    canvas->videoconfig->scale2x = (int)v;
 
188
 
 
189
    if (canvas->initialized)
 
190
        video_canvas_refresh_all(canvas);
 
191
 
 
192
    video_resources_update_ui(video_resource_chip);
 
193
 
 
194
    return 0;
 
195
}
 
196
 
 
197
static const char *vname_chip_scale2x[] = { "Scale2x", NULL };
 
198
 
 
199
static resource_t resources_chip_scale2x[] =
 
200
{
 
201
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
202
      set_scale2x_enabled, NULL },
 
203
    { NULL }
 
204
};
 
205
 
 
206
static int set_fullscreen_enabled(resource_value_t v, void *param)
 
207
{
 
208
    video_resource_chip_t *video_resource_chip;
 
209
    video_chip_cap_t *video_chip_cap;
 
210
    video_canvas_t *canvas;
 
211
 
 
212
    video_resource_chip = (video_resource_chip_t *)param;
 
213
    video_chip_cap = video_resource_chip->video_chip_cap;
 
214
    canvas = *(video_resource_chip->canvas);
 
215
 
 
216
    video_resource_chip->fullscreen_enabled = (int)v;
 
217
 
 
218
    if (canvas->initialized)
 
219
        return (video_chip_cap->fullscreen.enable)(canvas, (int)v);
 
220
 
 
221
    return 0;
 
222
}
 
223
 
 
224
static int set_fullscreen_double_size_enabled(resource_value_t v, void *param)
 
225
{
 
226
    video_resource_chip_t *video_resource_chip;
 
227
    video_chip_cap_t *video_chip_cap;
 
228
    video_canvas_t *canvas;
 
229
 
 
230
    video_resource_chip = (video_resource_chip_t *)param;
 
231
    video_chip_cap = video_resource_chip->video_chip_cap;
 
232
    canvas = *(video_resource_chip->canvas);
 
233
 
 
234
    video_resource_chip->fullscreen_double_size_enabled = (int)v;
 
235
 
 
236
    return (video_chip_cap->fullscreen.double_size)(canvas, (int)v);
 
237
}
 
238
 
 
239
static int set_fullscreen_double_scan_enabled(resource_value_t v, void *param)
 
240
{
 
241
    video_resource_chip_t *video_resource_chip;
 
242
    video_chip_cap_t *video_chip_cap;
 
243
    video_canvas_t *canvas;
 
244
 
 
245
    video_resource_chip = (video_resource_chip_t *)param;
 
246
    video_chip_cap = video_resource_chip->video_chip_cap;
 
247
    canvas = *(video_resource_chip->canvas);
 
248
 
 
249
    video_resource_chip->fullscreen_double_scan_enabled = (int)v;
 
250
 
 
251
    return (video_chip_cap->fullscreen.double_scan)(canvas, (int)v);
 
252
}
 
253
 
 
254
static int set_fullscreen_device(resource_value_t v, void *param)
 
255
{
 
256
    video_resource_chip_t *video_resource_chip;
 
257
    video_chip_cap_t *video_chip_cap;
 
258
    video_canvas_t *canvas;
 
259
 
 
260
    video_resource_chip = (video_resource_chip_t *)param;
 
261
    video_chip_cap = video_resource_chip->video_chip_cap;
 
262
    canvas = *(video_resource_chip->canvas);
 
263
 
 
264
    if (util_string_set(&video_resource_chip->fullscreen_device,
 
265
        (const char *)v))
 
266
        return 0;
 
267
 
 
268
    return (video_chip_cap->fullscreen.device)(canvas, (const char *)v);
 
269
}
 
270
 
 
271
static const char *vname_chip_fullscreen[] = {
 
272
    "Fullscreen", "FullscreenDoubleSize", "FullscreenDoubleScan",
 
273
    "FullscreenDevice", NULL
 
274
};
 
275
 
 
276
static resource_t resources_chip_fullscreen[] =
 
277
{
 
278
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
279
      set_fullscreen_enabled, NULL },
 
280
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
281
      set_fullscreen_double_size_enabled, NULL },
 
282
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
283
      set_fullscreen_double_scan_enabled, NULL },
 
284
    { NULL, RES_STRING, (resource_value_t)NULL, NULL,
 
285
      set_fullscreen_device, NULL },
 
286
    { NULL }
 
287
};
 
288
 
 
289
static int set_fullscreen_mode(resource_value_t v, void *param)
 
290
{
 
291
    video_resource_chip_mode_t *video_resource_chip_mode;
 
292
    video_resource_chip_t *video_resource_chip;
 
293
    video_chip_cap_t *video_chip_cap;
 
294
    video_canvas_t *canvas;
 
295
 
 
296
    unsigned device;
 
297
 
 
298
    video_resource_chip_mode = (video_resource_chip_mode_t *)param;
 
299
    video_resource_chip = video_resource_chip_mode->resource_chip;
 
300
    video_chip_cap = video_resource_chip->video_chip_cap;
 
301
    canvas = *(video_resource_chip->canvas);
 
302
 
 
303
    device = video_resource_chip_mode->device;
 
304
 
 
305
    video_resource_chip->fullscreen_mode[device] = (int)v;
 
306
 
 
307
    return (video_chip_cap->fullscreen.mode[device])(canvas, (int)v);
 
308
}
 
309
 
 
310
static const char *vname_chip_fullscreen_mode[] = { "FullscreenMode", NULL };
 
311
 
 
312
static resource_t resources_chip_fullscreen_mode[] =
 
313
{
 
314
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
 
315
      set_fullscreen_mode, NULL },
 
316
    { NULL }
 
317
};
94
318
 
95
319
static int set_ext_palette(resource_value_t v, void *param)
96
320
{
97
 
    video_resources.ext_palette = (int)v;
98
 
    return video_color_update_palette();
 
321
    video_resource_chip_t *video_resource_chip;
 
322
    video_chip_cap_t *video_chip_cap;
 
323
    video_canvas_t *canvas;
 
324
 
 
325
    video_resource_chip = (video_resource_chip_t *)param;
 
326
    video_chip_cap = video_resource_chip->video_chip_cap;
 
327
    canvas = *(video_resource_chip->canvas);
 
328
 
 
329
    video_resource_chip->external_palette_enabled = (int)v;
 
330
    canvas->videoconfig->external_palette = (unsigned int)v;
 
331
 
 
332
    return video_color_update_palette(canvas);
99
333
}
100
334
 
101
335
static int set_palette_file_name(resource_value_t v, void *param)
102
336
{
103
 
    util_string_set(&video_resources.palette_file_name, (char *)v);
104
 
    return video_color_update_palette();
105
 
}
106
 
 
107
 
#ifndef USE_GNOMEUI
108
 
/* remove this once all ports have implemented this ui function */
109
 
#define ui_update_pal_ctrls(a) 
110
 
#endif
111
 
 
112
 
static int set_delayloop_emulation(resource_value_t v, void *param)
113
 
{
114
 
    int old = video_resources.delayloop_emulation;
115
 
    video_resources.delayloop_emulation = (int)v;
116
 
 
117
 
    if (video_color_update_palette() < 0) {
118
 
        video_resources.delayloop_emulation = old;
119
 
        ui_update_pal_ctrls(video_resources.delayloop_emulation);
120
 
        return -1;
121
 
    }
122
 
    ui_update_pal_ctrls(video_resources.delayloop_emulation);
123
 
 
124
 
    return 0;
125
 
}
126
 
 
127
 
static int set_pal_emulation(resource_value_t v, void *param)
128
 
{
129
 
    int old = video_resources.pal_emulation;
130
 
    video_resources.pal_emulation = (int)v;
131
 
 
132
 
    if (video_color_update_palette() < 0) {
133
 
        video_resources.pal_emulation = old;
134
 
        return -1;
135
 
    }
136
 
 
137
 
    return 0;
138
 
}
139
 
 
140
 
static resource_t resources[] =
141
 
{
142
 
    { "ExternalPalette", RES_INTEGER, (resource_value_t)0,
143
 
      (resource_value_t *)&video_resources.ext_palette,
 
337
    video_resource_chip_t *video_resource_chip;
 
338
    video_canvas_t *canvas;
 
339
 
 
340
    video_resource_chip = (video_resource_chip_t *)param;
 
341
    canvas = *(video_resource_chip->canvas);
 
342
 
 
343
    util_string_set(&(video_resource_chip->external_palette_name), (char *)v);
 
344
    canvas->videoconfig->external_palette_name
 
345
        = video_resource_chip->external_palette_name;
 
346
 
 
347
    return video_color_update_palette(canvas);
 
348
}
 
349
 
 
350
static const char *vname_chip_palette[] = { "PaletteFile", "ExternalPalette",
 
351
                                            NULL };
 
352
 
 
353
static resource_t resources_chip_palette[] =
 
354
{
 
355
    { NULL, RES_STRING, NULL, NULL,
 
356
      set_palette_file_name, NULL },
 
357
    { NULL, RES_INTEGER, (resource_value_t)0, NULL,
144
358
      set_ext_palette, NULL },
145
 
    { "PaletteFile", RES_STRING, (resource_value_t)"default",
146
 
      (resource_value_t *)&video_resources.palette_file_name,
147
 
      set_palette_file_name, NULL },
148
 
    { NULL }
149
 
};
150
 
 
151
 
static resource_t resources_pal[] =
152
 
{
153
 
    { "ColorSaturation", RES_INTEGER, (resource_value_t)1000,
154
 
      (resource_value_t *)&video_resources.color_saturation,
155
 
      set_color_saturation, NULL },
156
 
    { "ColorContrast", RES_INTEGER, (resource_value_t)1000,
157
 
      (resource_value_t *)&video_resources.color_contrast,
158
 
      set_color_contrast, NULL },
159
 
    { "ColorBrightness", RES_INTEGER, (resource_value_t)1000,
160
 
      (resource_value_t *)&video_resources.color_brightness,
161
 
      set_color_brightness, NULL },
162
 
    { "ColorGamma", RES_INTEGER, (resource_value_t)880,
163
 
      (resource_value_t *)&video_resources.color_gamma,
164
 
      set_color_gamma, NULL },
165
 
    { "DelayLoopEmulation", RES_INTEGER, (resource_value_t)0,
166
 
      (resource_value_t *)&video_resources.delayloop_emulation,
167
 
      set_delayloop_emulation, NULL },
168
 
    { "PALEmulation", RES_INTEGER, (resource_value_t)0,
169
 
      (resource_value_t *)&video_resources.pal_emulation,
170
 
      set_pal_emulation, NULL },
171
 
    { NULL }
172
 
};
173
 
 
174
 
int video_resources_init(int mode)
175
 
{
176
 
    int result = 0;
177
 
 
178
 
    switch (mode) {
179
 
      case VIDEO_RESOURCES_MONOCHROME:
180
 
        result = resources_register(resources);
181
 
        break;
182
 
      case VIDEO_RESOURCES_PAL:
183
 
      case VIDEO_RESOURCES_PAL_NOFAKE:
184
 
       result = resources_register(resources)
185
 
                | resources_register(resources_pal);
186
 
       break;
187
 
    }
188
 
 
189
 
    return result | video_arch_init_resources();
 
359
    { NULL }
 
360
};
 
361
 
 
362
int video_resources_chip_init(const char *chipname,
 
363
                              struct video_canvas_s **canvas,
 
364
                              video_chip_cap_t *video_chip_cap)
 
365
{
 
366
    unsigned int i;
 
367
    video_resource_chip_t *resource_chip;
 
368
 
 
369
    resource_chip
 
370
        = (video_resource_chip_t *)lib_calloc(1, sizeof(video_resource_chip_t));
 
371
    (*canvas)->video_resource_chip = resource_chip;
 
372
 
 
373
    video_render_initconfig((*canvas)->videoconfig);
 
374
    (*canvas)->videoconfig->cap = video_chip_cap;
 
375
 
 
376
    /* Set single size render as default.  */
 
377
    (*canvas)->videoconfig->rendermode = video_chip_cap->single_mode.rmode;
 
378
    (*canvas)->videoconfig->doublesizex
 
379
        = video_chip_cap->single_mode.sizex > 1 ? 1 : 0;
 
380
    (*canvas)->videoconfig->doublesizey
 
381
        = video_chip_cap->single_mode.sizey > 1 ? 1 : 0;
 
382
 
 
383
    resource_chip->canvas = canvas;
 
384
    resource_chip->video_chip_cap = video_chip_cap;
 
385
 
 
386
    if (video_chip_cap->dscan_allowed != 0) {
 
387
        resources_chip_scan[0].name
 
388
            = util_concat(chipname, vname_chip_scan[0], NULL);
 
389
        resources_chip_scan[0].value_ptr
 
390
            = (resource_value_t *)&(resource_chip->double_scan_enabled);
 
391
        resources_chip_scan[0].param = (void *)resource_chip;
 
392
        if (resources_register(resources_chip_scan) < 0)
 
393
            return -1;
 
394
 
 
395
        lib_free((char *)(resources_chip_scan[0].name));
 
396
    }
 
397
 
 
398
    if (video_chip_cap->scale2x_allowed != 0) {
 
399
        resources_chip_scale2x[0].name
 
400
            = util_concat(chipname, vname_chip_scale2x[0], NULL);
 
401
        resources_chip_scale2x[0].value_ptr
 
402
            = (resource_value_t *)&(resource_chip->scale2x_enabled);
 
403
        resources_chip_scale2x[0].param = (void *)resource_chip;
 
404
        if (resources_register(resources_chip_scale2x) < 0)
 
405
            return -1;
 
406
 
 
407
        lib_free((char *)(resources_chip_scale2x[0].name));
 
408
    }
 
409
 
 
410
    if (video_chip_cap->dsize_allowed != 0) {
 
411
        resources_chip_size[0].name
 
412
            = util_concat(chipname, vname_chip_size[0], NULL);
 
413
        resources_chip_size[0].factory_value
 
414
            = (resource_value_t)video_chip_cap->dsize_default;
 
415
        resources_chip_size[0].value_ptr
 
416
            = (resource_value_t *)&(resource_chip->double_size_enabled);
 
417
        resources_chip_size[0].param = (void *)resource_chip;
 
418
        if (resources_register(resources_chip_size) < 0)
 
419
            return -1;
 
420
 
 
421
        lib_free((char *)(resources_chip_size[0].name));
 
422
    }
 
423
 
 
424
    if (video_chip_cap->fullscreen.device_num > 0) {
 
425
        video_resource_chip_mode_t *resource_chip_mode;
 
426
 
 
427
        resources_chip_fullscreen[0].name
 
428
            = util_concat(chipname, vname_chip_fullscreen[0], NULL);
 
429
        resources_chip_fullscreen[0].value_ptr
 
430
            = (resource_value_t *)&(resource_chip->fullscreen_enabled);
 
431
        resources_chip_fullscreen[0].param = (void *)resource_chip;
 
432
 
 
433
        resources_chip_fullscreen[1].name
 
434
            = util_concat(chipname, vname_chip_fullscreen[1], NULL);
 
435
        resources_chip_fullscreen[1].value_ptr
 
436
            = (resource_value_t *)&(resource_chip->fullscreen_double_size_enabled);
 
437
        resources_chip_fullscreen[1].param = (void *)resource_chip;
 
438
 
 
439
        resources_chip_fullscreen[2].name
 
440
            = util_concat(chipname, vname_chip_fullscreen[2], NULL);
 
441
        resources_chip_fullscreen[2].value_ptr
 
442
            = (resource_value_t *)&(resource_chip->fullscreen_double_scan_enabled);
 
443
        resources_chip_fullscreen[2].param = (void *)resource_chip;
 
444
 
 
445
        resources_chip_fullscreen[3].name
 
446
            = util_concat(chipname, vname_chip_fullscreen[3], NULL);
 
447
        resources_chip_fullscreen[3].factory_value
 
448
            = (resource_value_t)(video_chip_cap->fullscreen.device_name[0]);
 
449
        resources_chip_fullscreen[3].value_ptr
 
450
            = (resource_value_t *)&(resource_chip->fullscreen_device);
 
451
        resources_chip_fullscreen[3].param = (void *)resource_chip;
 
452
 
 
453
        if (resources_register(resources_chip_fullscreen) < 0)
 
454
            return -1;
 
455
 
 
456
        lib_free((char *)(resources_chip_fullscreen[0].name));
 
457
        lib_free((char *)(resources_chip_fullscreen[1].name));
 
458
        lib_free((char *)(resources_chip_fullscreen[2].name));
 
459
        lib_free((char *)(resources_chip_fullscreen[3].name));
 
460
 
 
461
        for (i = 0; i < video_chip_cap->fullscreen.device_num; i++) {
 
462
            resource_chip_mode = (video_resource_chip_mode_t *)lib_malloc(
 
463
                                 sizeof(video_resource_chip_mode_t));
 
464
            resource_chip_mode->resource_chip = resource_chip;
 
465
            resource_chip_mode->device = i;
 
466
 
 
467
            resources_chip_fullscreen_mode[0].name
 
468
                = util_concat(chipname,
 
469
                    video_chip_cap->fullscreen.device_name[i],
 
470
                    vname_chip_fullscreen_mode[0], NULL);
 
471
            resources_chip_fullscreen_mode[0].value_ptr
 
472
                = (resource_value_t *)&(resource_chip->fullscreen_mode[i]);
 
473
            resources_chip_fullscreen_mode[0].param
 
474
                = (void *)resource_chip_mode;
 
475
 
 
476
            if (resources_register(resources_chip_fullscreen_mode) < 0)
 
477
                return -1;
 
478
 
 
479
            lib_free((char *)(resources_chip_fullscreen_mode[0].name));
 
480
        }
 
481
    }
 
482
 
 
483
    resources_chip_palette[0].name
 
484
        = util_concat(chipname, vname_chip_palette[0], NULL);
 
485
    resources_chip_palette[0].factory_value
 
486
        = (resource_value_t)video_chip_cap->external_palette_name;
 
487
    resources_chip_palette[0].value_ptr
 
488
        = (resource_value_t *)&(resource_chip->external_palette_name);
 
489
    resources_chip_palette[0].param = (void *)resource_chip;
 
490
 
 
491
    if (video_chip_cap->internal_palette_allowed != 0) {
 
492
        resources_chip_palette[1].name
 
493
            = util_concat(chipname, vname_chip_palette[1], NULL);
 
494
        resources_chip_palette[1].value_ptr
 
495
            = (resource_value_t *)&(resource_chip->external_palette_enabled);
 
496
        resources_chip_palette[1].param = (void *)resource_chip;
 
497
    } else {
 
498
        resources_chip_palette[1].name = NULL;
 
499
        resource_chip->external_palette_enabled = 1;
 
500
        (*canvas)->videoconfig->external_palette = 1;
 
501
    }
 
502
 
 
503
    if (resources_register(resources_chip_palette) < 0)
 
504
        return -1;
 
505
 
 
506
    lib_free((char *)(resources_chip_palette[0].name));
 
507
    if (video_chip_cap->internal_palette_allowed != 0)
 
508
        lib_free((char *)(resources_chip_palette[1].name));
 
509
 
 
510
    return 0;
 
511
}
 
512
 
 
513
void video_resources_chip_shutdown(struct video_canvas_s *canvas)
 
514
{
 
515
    lib_free(canvas->video_resource_chip->external_palette_name);
 
516
    lib_free(canvas->video_resource_chip);
 
517
}
 
518
 
 
519
void video_resources_update_ui(video_resource_chip_t *video_resource_chip)
 
520
{
 
521
    int pal_enabled = 0;
 
522
    int ui_doublescan_enabled, ui_scale2x_enabled;
 
523
 
 
524
    if (video_resource_chip->video_chip_cap->palemulation_allowed)
 
525
        resources_get_value("PALEmulation", &pal_enabled);
 
526
 
 
527
    if (video_resource_chip->double_size_enabled != 0) {
 
528
        if (pal_enabled) {
 
529
            ui_doublescan_enabled = 1;
 
530
            ui_scale2x_enabled = 0;
 
531
        } else if (video_resource_chip->scale2x_enabled != 0) {
 
532
            ui_doublescan_enabled = 0;
 
533
            ui_scale2x_enabled = 1;
 
534
        } else {
 
535
            ui_doublescan_enabled = 1;
 
536
            ui_scale2x_enabled = 1;
 
537
        }
 
538
    } else {
 
539
        ui_doublescan_enabled = 0;
 
540
        ui_scale2x_enabled = 0;
 
541
    }
 
542
/*
 
543
    ui_enable_chip resources(ui_doublescan_enabled, ui_scale2x_enabled);
 
544
*/
190
545
}
191
546