1 /*
2 * vicii-resources.c - Resources for the MOS 6569 (VIC-II) emulation.
3 *
4 * Written by
5 * Andreas Boose <viceteam@t-online.de>
6 * Ettore Perazzoli <ettore@comm2000.it>
7 *
8 * This file is part of VICE, the Versatile Commodore Emulator.
9 * See README for copyright notice.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 * 02111-1307 USA.
25 *
26 */
27
28 #include "vice.h"
29
30 #include <stdio.h>
31
32 #include "archdep.h"
33 #include "fullscreen.h"
34 #include "machine.h"
35 #include "raster-resources.h"
36 #include "resources.h"
37 #include "vicii-color.h"
38 #include "vicii-resources.h"
39 #include "vicii-timing.h"
40 #include "vicii.h"
41 #include "viciitypes.h"
42 #include "video.h"
43 #include "vsync.h"
44
45 vicii_resources_t vicii_resources = { 0, 0, 0, 0, 0 };
46 static video_chip_cap_t video_chip_cap;
47
48 static int next_border_mode;
49
on_vsync_set_border_mode(void * unused)50 static void on_vsync_set_border_mode(void *unused)
51 {
52 int sync;
53
54 if (resources_get_int("MachineVideoStandard", &sync) < 0) {
55 sync = MACHINE_SYNC_PAL;
56 }
57
58 if (vicii_resources.border_mode != next_border_mode) {
59 vicii_resources.border_mode = next_border_mode;
60 machine_change_timing(sync, vicii_resources.border_mode);
61 }
62 }
63
set_border_mode(int val,void * param)64 static int set_border_mode(int val, void *param)
65 {
66 switch (val) {
67 case VICII_NORMAL_BORDERS:
68 case VICII_FULL_BORDERS:
69 case VICII_DEBUG_BORDERS:
70 case VICII_NO_BORDERS:
71 break;
72 default:
73 return -1;
74 }
75
76 next_border_mode = val;
77 vsync_on_vsync_do(on_vsync_set_border_mode, NULL);
78
79 return 0;
80 }
81
set_sprite_sprite_collisions_enabled(int val,void * param)82 static int set_sprite_sprite_collisions_enabled(int val, void *param)
83 {
84 vicii_resources.sprite_sprite_collisions_enabled = val ? 1 : 0;
85
86 return 0;
87 }
88
set_sprite_background_collisions_enabled(int val,void * param)89 static int set_sprite_background_collisions_enabled(int val, void *param)
90 {
91 vicii_resources.sprite_background_collisions_enabled = val ? 1 : 0;
92
93 return 0;
94 }
95
96 static const resource_int_t resources_int[] =
97 {
98 { "VICIIBorderMode", VICII_NORMAL_BORDERS, RES_EVENT_SAME, NULL,
99 &vicii_resources.border_mode,
100 set_border_mode, NULL },
101 { "VICIICheckSsColl", 1, RES_EVENT_SAME, NULL,
102 &vicii_resources.sprite_sprite_collisions_enabled,
103 set_sprite_sprite_collisions_enabled, NULL },
104 { "VICIICheckSbColl", 1, RES_EVENT_SAME, NULL,
105 &vicii_resources.sprite_background_collisions_enabled,
106 set_sprite_background_collisions_enabled, NULL },
107 RESOURCE_INT_LIST_END
108 };
109
set_new_luminances(int val,void * param)110 static int set_new_luminances(int val, void *param)
111 {
112 vicii_resources.new_luminances = val ? 1 : 0;
113
114 return vicii_color_update_palette(vicii.raster.canvas);
115 }
116
117 static const resource_int_t resources_int_dtv[] =
118 {
119 { "VICIINewLuminances", 1, RES_EVENT_NO, NULL,
120 &vicii_resources.new_luminances,
121 set_new_luminances, NULL },
122 RESOURCE_INT_LIST_END
123 };
124
vicii_resources_init(void)125 int vicii_resources_init(void)
126 {
127 video_chip_cap.dsize_allowed = ARCHDEP_VICII_DSIZE;
128 video_chip_cap.dsize_default = ARCHDEP_VICII_DSIZE;
129 video_chip_cap.dsize_limit_width = 0;
130 video_chip_cap.dsize_limit_height = 0;
131 video_chip_cap.dscan_allowed = ARCHDEP_VICII_DSCAN;
132 video_chip_cap.hwscale_allowed = ARCHDEP_VICII_HWSCALE;
133 video_chip_cap.scale2x_allowed = ARCHDEP_VICII_DSIZE;
134 if (machine_class == VICE_MACHINE_C64DTV) {
135 video_chip_cap.external_palette_name = "spiff";
136 } else {
137 video_chip_cap.external_palette_name = "pepto-pal";
138 }
139 video_chip_cap.double_buffering_allowed = ARCHDEP_VICII_DBUF;
140 video_chip_cap.single_mode.sizex = 1;
141 video_chip_cap.single_mode.sizey = 1;
142 video_chip_cap.single_mode.rmode = VIDEO_RENDER_PAL_1X1;
143 video_chip_cap.double_mode.sizex = 2;
144 video_chip_cap.double_mode.sizey = 2;
145 video_chip_cap.double_mode.rmode = VIDEO_RENDER_PAL_2X2;
146
147 fullscreen_capability(&(video_chip_cap.fullscreen));
148
149 vicii.video_chip_cap = &video_chip_cap;
150
151 if (raster_resources_chip_init("VICII", &vicii.raster, &video_chip_cap) < 0) {
152 return -1;
153 }
154 if (machine_class == VICE_MACHINE_C64DTV) {
155 if (resources_register_int(resources_int_dtv) < 0) {
156 return -1;
157 }
158 }
159
160 return resources_register_int(resources_int);
161 }
162
vicii_comply_with_video_standard(int machine_sync)163 void vicii_comply_with_video_standard(int machine_sync)
164 {
165 /* dummy function */
166 }
167