1 /*
2 * video-render-pal.c - Implementation of framebuffer to physical screen copy
3 *
4 * Written by
5 * John Selck <graham@cruise.de>
6 * Dag Lem <resid@nimrod.no>
7 * Andreas Boose <viceteam@t-online.de>
8 *
9 * This file is part of VICE, the Versatile Commodore Emulator.
10 * See README for copyright notice.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 * 02111-1307 USA.
26 *
27 */
28
29 #include "vice.h"
30
31 #include <stdio.h>
32
33 #include "log.h"
34 #include "machine.h"
35 #include "render1x1.h"
36 #include "render1x1pal.h"
37 #include "render1x1ntsc.h"
38 #include "render1x2.h"
39 #include "render1x2crt.h"
40 #include "render2x2.h"
41 #include "render2x2pal.h"
42 #include "render2x2ntsc.h"
43 #include "renderscale2x.h"
44 #include "resources.h"
45 #include "types.h"
46 #include "video-render.h"
47 #include "video.h"
48
49
video_render_pal_main(video_render_config_t * config,uint8_t * src,uint8_t * trg,int width,int height,int xs,int ys,int xt,int yt,int pitchs,int pitcht,int depth,viewport_t * viewport)50 static void video_render_pal_main(video_render_config_t *config,
51 uint8_t *src, uint8_t *trg,
52 int width, int height, int xs, int ys, int xt,
53 int yt, int pitchs, int pitcht, int depth,
54 viewport_t *viewport)
55 {
56 video_render_color_tables_t *colortab;
57 int doublescan, delayloop, rendermode, scale2x, video;
58
59 video = viewport->crt_type;
60
61 rendermode = config->rendermode;
62 doublescan = config->doublescan;
63 colortab = &config->color_tables;
64 scale2x = config->scale2x;
65
66 delayloop = (config->filter == VIDEO_FILTER_CRT);
67
68 /*
69 if (config->external_palette)
70 delayloop = 0;
71 */
72
73 if ((rendermode == VIDEO_RENDER_PAL_1X1
74 || rendermode == VIDEO_RENDER_PAL_2X2)
75 && config->video_resources.pal_scanlineshade <= 0) {
76 doublescan = 0;
77 }
78
79 switch (rendermode) {
80 case VIDEO_RENDER_NULL:
81 break;
82
83 case VIDEO_RENDER_PAL_1X1:
84 if (delayloop && depth != 8) {
85 if (video) {
86 switch (depth) {
87 case 16:
88 render_16_1x1_pal(colortab, src, trg, width, height,
89 xs, ys, xt, yt, pitchs, pitcht, config);
90 return;
91 case 24:
92 render_24_1x1_pal(colortab, src, trg, width, height,
93 xs, ys, xt, yt, pitchs, pitcht, config);
94 return;
95 case 32:
96 render_32_1x1_pal(colortab, src, trg, width, height,
97 xs, ys, xt, yt, pitchs, pitcht, config);
98 return;
99 }
100 } else {
101 switch (depth) {
102 case 16:
103 render_16_1x1_ntsc(colortab, src, trg, width, height,
104 xs, ys, xt, yt, pitchs, pitcht);
105 return;
106 case 24:
107 render_24_1x1_ntsc(colortab, src, trg, width, height,
108 xs, ys, xt, yt, pitchs, pitcht);
109 return;
110 case 32:
111 render_32_1x1_ntsc(colortab, src, trg, width, height,
112 xs, ys, xt, yt, pitchs, pitcht);
113 return;
114 }
115 }
116 } else {
117 switch (depth) {
118 case 8:
119 render_08_1x1_04(colortab, src, trg, width, height,
120 xs, ys, xt, yt, pitchs, pitcht);
121 return;
122 case 16:
123 render_16_1x1_04(colortab, src, trg, width, height,
124 xs, ys, xt, yt, pitchs, pitcht);
125 return;
126 case 24:
127 render_24_1x1_04(colortab, src, trg, width, height,
128 xs, ys, xt, yt, pitchs, pitcht);
129 return;
130 case 32:
131 render_32_1x1_04(colortab, src, trg, width, height,
132 xs, ys, xt, yt, pitchs, pitcht);
133 return;
134 }
135 }
136 return;
137 case VIDEO_RENDER_PAL_2X2:
138 if (delayloop && depth != 8) {
139 switch (video) {
140 case 0: /* NTSC */
141 switch (depth) {
142 case 16:
143 render_16_2x2_ntsc(colortab, src, trg, width, height,
144 xs, ys, xt, yt, pitchs, pitcht,
145 viewport, config);
146 return;
147 case 24:
148 render_24_2x2_ntsc(colortab, src, trg, width, height,
149 xs, ys, xt, yt, pitchs, pitcht,
150 viewport, config);
151 return;
152 case 32:
153 render_32_2x2_ntsc(colortab, src, trg, width, height,
154 xs, ys, xt, yt, pitchs, pitcht,
155 viewport, config);
156 return;
157 }
158 break;
159 case 1: /* PAL */
160 switch (depth) {
161 case 16:
162 render_16_2x2_pal(colortab, src, trg, width, height,
163 xs, ys, xt, yt, pitchs, pitcht,
164 viewport, config);
165 return;
166 case 24:
167 render_24_2x2_pal(colortab, src, trg, width, height,
168 xs, ys, xt, yt, pitchs, pitcht,
169 viewport, config);
170 return;
171 case 32:
172 render_32_2x2_pal(colortab, src, trg, width, height,
173 xs, ys, xt, yt, pitchs, pitcht,
174 viewport, config);
175 return;
176 }
177 break;
178 }
179 } else if (scale2x) {
180 switch (depth) {
181 case 8:
182 render_08_scale2x(colortab, src, trg, width, height,
183 xs, ys, xt, yt, pitchs, pitcht);
184 return;
185 case 16:
186 render_16_scale2x(colortab, src, trg, width, height,
187 xs, ys, xt, yt, pitchs, pitcht);
188 return;
189 case 24:
190 render_24_scale2x(colortab, src, trg, width, height,
191 xs, ys, xt, yt, pitchs, pitcht);
192 return;
193 case 32:
194 render_32_scale2x(colortab, src, trg, width, height,
195 xs, ys, xt, yt, pitchs, pitcht);
196 return;
197 }
198 } else {
199 switch (depth) {
200 case 8:
201 render_08_2x2_04(colortab, src, trg, width, height,
202 xs, ys, xt, yt, pitchs, pitcht, doublescan, config);
203 return;
204 case 16:
205 render_16_2x2_04(colortab, src, trg, width, height,
206 xs, ys, xt, yt, pitchs, pitcht, doublescan, config);
207 return;
208 case 24:
209 render_24_2x2_04(colortab, src, trg, width, height,
210 xs, ys, xt, yt, pitchs, pitcht, doublescan, config);
211 return;
212 case 32:
213 render_32_2x2_04(colortab, src, trg, width, height,
214 xs, ys, xt, yt, pitchs, pitcht, doublescan, config);
215 return;
216 }
217 }
218 }
219 log_debug("video_render_pal_main unsupported rendermode (%d)\n", rendermode);
220 }
221
video_render_pal_init(void)222 void video_render_pal_init(void)
223 {
224 video_render_palfunc_set(video_render_pal_main);
225 }
226