1 /*
2
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20 #include "cit2d.h"
21 #include "gr2ss.h"
22 #include "frtypes.h"
23 #include "frintern.h"
24 #include "frprotox.h"
25 #include "gamescr.h"
26
27 //¥¥#include <inp6d.h>
28
29 #ifdef STEREO_SUPPORT
30 #include <i6dvideo.h>
31 extern uchar inp6d_stereo_active;
32
33 #define S_DELTA 5
34 #endif
35
36 #ifdef SVGA_SUPPORT
37 uchar gr2ss_override = OVERRIDE_NONE;
38 char convert_type = 0;
39 char convert_use_mode = 0;
40
41 char mode_count[MAX_CONVERT_TYPES];
42 fix convert_x[MAX_CONVERT_TYPES][MAX_USE_MODES];
43 fix convert_y[MAX_CONVERT_TYPES][MAX_USE_MODES];
44 fix inv_convert_x[MAX_CONVERT_TYPES][MAX_USE_MODES];
45 fix inv_convert_y[MAX_CONVERT_TYPES][MAX_USE_MODES];
46
47 #define SVGA_CONV_NONE 0
48 #define SVGA_CONV_NORMAL 1
49 #define SVGA_CONV_SCREEN 2
50
51 // Internal prototypes
52 uchar perform_svga_conversion(uchar mask);
53 void ss_scale_string(char *s, short x, short y);
54 void mouse_unconstrain(void);
55
perform_svga_conversion(uchar mask)56 uchar perform_svga_conversion(uchar mask) {
57 extern uchar full_game_3d;
58
59 if (gr2ss_override & OVERRIDE_FAIL)
60 return (SVGA_CONV_NONE);
61 // for now - if ((convert_use_mode == 0) && (!inp6d_stereo_active))
62 if (convert_use_mode == 0)
63 return (SVGA_CONV_NONE);
64 if (_fr->draw_canvas.bm.bits == grd_canvas->bm.bits)
65 return (SVGA_CONV_SCREEN);
66 if (grd_canvas->bm.bits == grd_screen_canvas->bm.bits)
67 return (SVGA_CONV_SCREEN);
68 if (gr2ss_override & mask)
69 return (SVGA_CONV_NORMAL);
70 if (convert_use_mode == 3) // KLC - the normal mode for Mac Shock.
71 return (SVGA_CONV_SCREEN);
72 return (SVGA_CONV_NONE);
73 }
74
75 // Conversion functions from "abstract" shock 2d functions
76 // to the actual 2d functions, with appropriate compensations
77 // for screen mode coordinates and aspect ratios.
78
79 // Note, x and y already converted here!
ss_scale_string(char * s,short x,short y)80 void ss_scale_string(char *s, short x, short y) {
81 // needs to scale still!
82 // know about different fonts instead? That would be better...
83 grs_font *ttfont = (grs_font *)ResLock(RES_tinyTechFont);
84 grs_font *mlfont = (grs_font *)ResLock(RES_mediumLEDFont);
85 grs_font *f = gr_get_font();
86 int c = gr_get_fcolor();
87 Id use_font = ID_NULL;
88 #ifdef STEREO_SUPPORT
89 uchar rv = perform_svga_conversion(OVERRIDE_SCALE);
90 #endif
91
92 if (convert_use_mode == 0) {
93 gr_string(s, x, y);
94 return;
95 }
96
97 if ((f == ttfont) || (f == mlfont)) {
98 switch (convert_use_mode) {
99 case 1:
100 if (f == ttfont)
101 use_font = RES_tallTinyTechFont;
102 break;
103 case 2:
104 case 3:
105 if (f == ttfont)
106 use_font = RES_doubleTinyTechFont;
107 else if (f == mlfont)
108 use_font = RES_doubleMediumLEDFont;
109 break;
110 case 4:
111 if (f == ttfont)
112 use_font = RES_megaTinyTechFont;
113 else if (f == mlfont)
114 use_font = RES_megaMediumLEDFont;
115 break;
116 }
117 #ifdef STEREO_SUPPORT
118 if ((rv == SVGA_CONV_SCREEN) && inp6d_stereo_active) {
119 if (use_font == ID_NULL) {
120 short w, h;
121 gr_string_size(s, (short *)&w, (short *)&h);
122 gr_push_canvas(i6d_ss->cf_left);
123 gr_set_font(f);
124 gr_set_fcolor(c);
125 gr_scale_string(s, x + S_DELTA, y, SCONV_X(w) + S_DELTA, SCONV_Y(h));
126 gr_pop_canvas();
127 gr_push_canvas(i6d_ss->cf_right);
128 gr_set_font(f);
129 gr_set_fcolor(c);
130 gr_scale_string(s, x - S_DELTA, y, SCONV_X(w) - S_DELTA, SCONV_Y(h));
131 } else {
132 gr_push_canvas(i6d_ss->cf_left);
133 gr_set_font((grs_font *)ResLock(use_font));
134 gr_set_fcolor(c);
135 gr_string(s, x + S_DELTA, y);
136 gr_pop_canvas();
137 gr_push_canvas(i6d_ss->cf_right);
138 gr_set_font((grs_font *)ResLock(use_font));
139 gr_set_fcolor(c);
140 gr_string(s, x - S_DELTA, y);
141 }
142 gr_pop_canvas();
143 } else {
144 #endif
145 if (use_font == ID_NULL) {
146 short w, h;
147 gr_string_size(s, (short *)&w, (short *)&h);
148 gr_scale_string(s, x, y, SCONV_X(w), SCONV_Y(h));
149 } else {
150 gr_set_font((grs_font *)ResLock(use_font));
151 gr_string(s, x, y);
152 }
153 #ifdef STEREO_SUPPORT
154 }
155 #endif
156 if (use_font != ID_NULL)
157 ResUnlock(use_font);
158 gr_set_font(ttfont);
159 ResUnlock(RES_tinyTechFont);
160 ResUnlock(RES_mediumLEDFont);
161 } else {
162 // Attempt to scale it
163 short w, h;
164 gr_string_size(s, (short *)&w, (short *)&h);
165 gr_scale_string(s, x, y, SCONV_X(w), SCONV_Y(h));
166 }
167 }
168
ss_string(char * s,short x,short y)169 void ss_string(char *s, short x, short y) {
170 uchar rv;
171 if ((rv = perform_svga_conversion(OVERRIDE_SCALE))) {
172 #ifdef STEREO_SUPPORT
173 if ((rv == SVGA_CONV_SCREEN) && (inp6d_stereo_active)) {
174 gr_push_canvas(i6d_ss->cf_left);
175 if (convert_use_mode)
176 ss_scale_string(s, SCONV_X(x) + S_DELTA, SCONV_Y(y));
177 else
178 ss_scale_string(s, x + S_DELTA, y);
179 gr_set_canvas(i6d_ss->cf_right);
180 if (convert_use_mode)
181 ss_scale_string(s, SCONV_X(x) - S_DELTA, SCONV_Y(y));
182 else
183 ss_scale_string(s, x - S_DELTA, y);
184 gr_pop_canvas();
185 } else
186 #endif
187 ss_scale_string(s, SCONV_X(x), SCONV_Y(y));
188 } else {
189 gr_string(s, x, y);
190 }
191 }
192
ss_bitmap(grs_bitmap * bmp,short x,short y)193 void ss_bitmap(grs_bitmap *bmp, short x, short y) {
194 uchar rv;
195 if ((rv = perform_svga_conversion(OVERRIDE_SCALE))) {
196 #ifdef STEREO_SUPPORT
197 if ((rv == SVGA_CONV_SCREEN) && (inp6d_stereo_active)) {
198 gr_push_canvas(i6d_ss->cf_left);
199 if (convert_use_mode)
200 gr_scale_bitmap(bmp, SCONV_X(x) + S_DELTA, SCONV_Y(y), SCONV_X(bmp->w) + S_DELTA, SCONV_Y(bmp->h));
201 else
202 gr_bitmap(bmp, x + S_DELTA, y);
203 gr_set_canvas(i6d_ss->cf_right);
204 if (convert_use_mode)
205 gr_scale_bitmap(bmp, SCONV_X(x) - S_DELTA, SCONV_Y(y), SCONV_X(bmp->w) - S_DELTA, SCONV_Y(bmp->h));
206 else
207 gr_bitmap(bmp, x - S_DELTA, y);
208 gr_pop_canvas();
209 } else
210 #endif
211 gr_scale_bitmap(bmp, SCONV_X(x), SCONV_Y(y), SCONV_X(bmp->w), SCONV_Y(bmp->h));
212 // Warning(("scaling %d x %d to %d x %d\n",bmp->w,bmp->h,SCONV_X(bmp->w),SCONV_Y(bmp->h)));
213 } else
214 gr_bitmap(bmp, x, y);
215 }
216
ss_ubitmap(grs_bitmap * bmp,short x,short y)217 void ss_ubitmap(grs_bitmap *bmp, short x, short y) {
218 if (perform_svga_conversion(OVERRIDE_SCALE))
219 gr_scale_ubitmap(bmp, SCONV_X(x), SCONV_Y(y), SCONV_X(bmp->w), SCONV_Y(bmp->h));
220 else
221 gr_ubitmap(bmp, x, y);
222 }
223
ss_noscale_bitmap(grs_bitmap * bmp,short x,short y)224 void ss_noscale_bitmap(grs_bitmap *bmp, short x, short y) {
225 uchar rv;
226 if ((rv = perform_svga_conversion(OVERRIDE_SCALE))) // ?
227 #ifdef STEREO_SUPPORT
228 if ((rv == SVGA_CONV_SCREEN) && (inp6d_stereo_active)) {
229 gr_push_canvas(i6d_ss->cf_left);
230 if (convert_use_mode)
231 gr_bitmap(bmp, SCONV_X(x) + S_DELTA, SCONV_Y(y));
232 else
233 gr_bitmap(bmp, x + S_DELTA, y);
234 gr_set_canvas(i6d_ss->cf_right);
235 if (convert_use_mode)
236 gr_bitmap(bmp, SCONV_X(x) - S_DELTA, SCONV_Y(y));
237 else
238 gr_bitmap(bmp, x - S_DELTA, y);
239 gr_pop_canvas();
240 } else
241 #endif
242 gr_bitmap(bmp, SCONV_X(x), SCONV_Y(y));
243 else
244 gr_bitmap(bmp, x, y);
245 }
246
ss_scale_bitmap(grs_bitmap * bmp,short x,short y,short w,short h)247 void ss_scale_bitmap(grs_bitmap *bmp, short x, short y, short w, short h) {
248 if (perform_svga_conversion(OVERRIDE_SCALE))
249 gr_scale_bitmap(bmp, SCONV_X(x), SCONV_Y(y), SCONV_X(w), SCONV_Y(h));
250 else
251 gr_scale_bitmap(bmp, x, y, w, h);
252 }
253
ss_rect(short x1,short y1,short x2,short y2)254 void ss_rect(short x1, short y1, short x2, short y2) {
255 uchar rv;
256 if ((rv = perform_svga_conversion(OVERRIDE_SCALE))) {
257 #ifdef STEREO_SUPPORT
258 if ((rv == SVGA_CONV_SCREEN) && (inp6d_stereo_active)) {
259 int c = gr_get_fcolor();
260 gr_push_canvas(i6d_ss->cf_left);
261 gr_set_fcolor(c);
262 if (convert_use_mode)
263 gr_rect(SCONV_X(x1) + S_DELTA, SCONV_Y(y1), SCONV_X(x2) + S_DELTA, SCONV_Y(y2));
264 else
265 gr_rect(x1 + S_DELTA, y1, x2 + S_DELTA, y2);
266 gr_set_canvas(i6d_ss->cf_right);
267 gr_set_fcolor(c);
268 if (convert_use_mode)
269 gr_rect(SCONV_X(x1) - S_DELTA, SCONV_Y(y1), SCONV_X(x2) - S_DELTA, SCONV_Y(y2));
270 else
271 gr_rect(x1 - S_DELTA, y1, x2 - S_DELTA, y2);
272 gr_pop_canvas();
273 } else
274 #endif
275 gr_rect(SCONV_X(x1), SCONV_Y(y1), SCONV_X(x2), SCONV_Y(y2));
276 } else {
277 gr_rect(x1, y1, x2, y2);
278 }
279 }
280
ss_box(short x1,short y1,short x2,short y2)281 void ss_box(short x1, short y1, short x2, short y2) {
282 uchar rv;
283 if ((rv = perform_svga_conversion(OVERRIDE_SCALE))) {
284 #ifdef STEREO_SUPPORT
285 if ((rv == SVGA_CONV_SCREEN) && (inp6d_stereo_active)) {
286 int c = gr_get_fcolor();
287 gr_push_canvas(i6d_ss->cf_left);
288 gr_set_fcolor(c);
289 if (convert_use_mode)
290 gr_box(SCONV_X(x1) + S_DELTA, SCONV_Y(y1), SCONV_X(x2) + S_DELTA, SCONV_Y(y2));
291 else
292 gr_box(x1 + S_DELTA, y1, x2 + S_DELTA, y2);
293 gr_set_canvas(i6d_ss->cf_right);
294 gr_set_fcolor(c);
295 if (convert_use_mode)
296 gr_box(SCONV_X(x1) - S_DELTA, SCONV_Y(y1), SCONV_X(x2) - S_DELTA, SCONV_Y(y2));
297 else
298 gr_box(x1 - S_DELTA, y1, x2 - S_DELTA, y2);
299 gr_pop_canvas();
300 } else
301 #endif
302 gr_box(RSCONV_X(x1), RSCONV_Y(y1), RSCONV_X(x2), RSCONV_Y(y2));
303 } else {
304 gr_box(x1, y1, x2, y2);
305 }
306 }
307
ss_safe_set_cliprect(short x1,short y1,short x2,short y2)308 void ss_safe_set_cliprect(short x1, short y1, short x2, short y2) {
309 if (perform_svga_conversion(OVERRIDE_CLIP)) {
310 // Warning(("setting rect (%d, %d) (%d,%d)!\n",SCONV_X(x1),SCONV_Y(y1),SCONV_X(x2),SCONV_Y(y2)));
311 safe_set_cliprect(SCONV_X(x1), SCONV_Y(y1), SCONV_X(x2), SCONV_Y(y2));
312 } else
313 safe_set_cliprect(x1, y1, x2, y2);
314 }
315
ss_cset_cliprect(grs_canvas * pcanv,short x,short y,short w,short h)316 void ss_cset_cliprect(grs_canvas *pcanv, short x, short y, short w, short h) {
317 if (perform_svga_conversion(OVERRIDE_CLIP)) {
318 // Warning(("cset to %d,%d %d, %d!\n",SCONV_X(x), SCONV_Y(y), SCONV_X(w), SCONV_Y(h)));
319 gr_cset_cliprect(pcanv, SCONV_X(x), SCONV_Y(y), SCONV_X(w), SCONV_Y(h));
320 } else
321 gr_cset_cliprect(pcanv, x, y, w, h);
322 }
323
ss_int_line(short x1,short y1,short x2,short y2)324 void ss_int_line(short x1, short y1, short x2, short y2) {
325 if (perform_svga_conversion(OVERRIDE_SCALE))
326 gr_int_line(SCONV_X(x1), SCONV_Y(y1), SCONV_X(x2), SCONV_Y(y2));
327 else
328 gr_int_line(x1, y1, x2, y2);
329 }
330
ss_thick_int_line(short x1,short y1,short x2,short y2)331 void ss_thick_int_line(short x1, short y1, short x2, short y2) {
332 if (perform_svga_conversion(OVERRIDE_SCALE)) {
333 short min_y, max_y, use_y, min_x, max_x, use_x;
334 min_y = SCONV_Y(y1);
335 max_y = SCONV_Y(y1 + 1);
336 min_x = SCONV_X(x1);
337 max_x = SCONV_X(x1 + 1);
338 for (use_y = min_y; use_y < max_y; use_y++)
339 gr_int_line(SCONV_X(x1), use_y, SCONV_X(x2), SCONV_Y(y2) + use_y - min_y);
340 for (use_x = min_x; use_x < max_x; use_x++)
341 gr_int_line(use_x, SCONV_Y(y1), SCONV_X(x2) + use_x - min_x, SCONV_Y(y2));
342 } else
343 gr_int_line(x1, y1, x2, y2);
344 }
345
ss_int_disk(short x1,short y1,short diam)346 void ss_int_disk(short x1, short y1, short diam) {
347 if (perform_svga_conversion(OVERRIDE_SCALE))
348 gr_int_disk(SCONV_X(x1), SCONV_Y(y1), SCONV_X(diam) >> 1);
349 // Hm, should we convert rad?
350 // Yes, but sadly it's hosed in 320x400 mode, where
351 // we need to draw an ellipse. This stuff really
352 // needs to be in the 2D.
353 else
354 gr_int_disk(x1, y1, diam >> 1);
355 }
356
ss_vline(short x1,short y1,short y2)357 void ss_vline(short x1, short y1, short y2) {
358 if (perform_svga_conversion(OVERRIDE_SCALE))
359 gr_vline(SCONV_X(x1), SCONV_Y(y1), SCONV_Y(y2));
360 else
361 gr_vline(x1, y1, y2);
362 }
363
ss_hline(short x1,short y1,short x2)364 void ss_hline(short x1, short y1, short x2) {
365 if (perform_svga_conversion(OVERRIDE_SCALE))
366 gr_hline(SCONV_X(x1), SCONV_Y(y1), SCONV_X(x2));
367 else
368 gr_hline(x1, y1, x2);
369 }
370
ss_fix_line(fix x1,fix y1,fix x2,fix y2)371 void ss_fix_line(fix x1, fix y1, fix x2, fix y2) {
372 if (perform_svga_conversion(OVERRIDE_SCALE))
373 gr_fix_line(FIXCONV_X(x1), FIXCONV_Y(y1), FIXCONV_X(x2), FIXCONV_Y(y2));
374 else
375 gr_fix_line(x1, y1, x2, y2);
376 }
377
ss_thick_fix_line(fix x1,fix y1,fix x2,fix y2)378 void ss_thick_fix_line(fix x1, fix y1, fix x2, fix y2) {
379 if (perform_svga_conversion(OVERRIDE_SCALE)) {
380 fix min_y, max_y, use_y, min_x, max_x, use_x;
381 min_y = FIXCONV_Y(y1);
382 max_y = FIXCONV_Y(y1 + FIX_UNIT);
383 min_x = FIXCONV_X(x1);
384 max_x = FIXCONV_X(x1 + FIX_UNIT);
385 for (use_y = min_y; use_y < max_y; use_y = use_y + FIX_UNIT)
386 gr_fix_line(FIXCONV_X(x1), use_y, FIXCONV_X(x2), FIXCONV_Y(y2) + use_y - min_y);
387 for (use_x = min_x; use_x < max_x; use_x = use_x + FIX_UNIT)
388 gr_fix_line(use_x, FIXCONV_Y(y1), FIXCONV_X(x2) + use_x - min_x, FIXCONV_Y(y2));
389 } else
390 gr_fix_line(x1, y1, x2, y2);
391 }
392
ss_get_bitmap(grs_bitmap * bmp,short x,short y)393 void ss_get_bitmap(grs_bitmap *bmp, short x, short y) {
394 if (perform_svga_conversion(OVERRIDE_GET_BM))
395 gr_get_bitmap(bmp, SCONV_X(x), SCONV_Y(y));
396 else
397 gr_get_bitmap(bmp, x, y);
398 }
399
ss_set_pixel(long color,short x,short y)400 void ss_set_pixel(long color, short x, short y) {
401 if (perform_svga_conversion(OVERRIDE_SCALE))
402 gr_set_pixel(color, SCONV_X(x), SCONV_Y(y));
403 else
404 gr_set_pixel(color, x, y);
405 }
406
ss_set_thick_pixel(long color,short x,short y)407 void ss_set_thick_pixel(long color, short x, short y) {
408 if (perform_svga_conversion(OVERRIDE_SCALE)) {
409 // gr_set_pixel(color, SCONV_X(x), SCONV_Y(y));
410 gr_set_fcolor(color);
411 gr_box(SCONV_X(x), SCONV_Y(y), SCONV_X(x + 1) - 1, SCONV_Y(y + 1) - 1);
412 } else
413 gr_set_pixel(color, x, y);
414 }
415
ss_clut_ubitmap(grs_bitmap * bmp,short x,short y,uchar * cl)416 void ss_clut_ubitmap(grs_bitmap *bmp, short x, short y, uchar *cl) {
417 if (perform_svga_conversion(OVERRIDE_SCALE))
418 gr_clut_scale_ubitmap(bmp, SCONV_X(x), SCONV_Y(y), SCONV_X(bmp->w), SCONV_Y(bmp->h), cl);
419 else
420 gr_clut_ubitmap(bmp, x, y, cl);
421 }
422
423 // Registration!
424
425 // Note that the zeroth element of the conversion arrays
426 // are used to store the base size, since perform_svga_conversion
427 // already filters out calls with use_mode of 0.
gr2ss_register_init(char ctype,short init_x,short init_y)428 void gr2ss_register_init(char ctype, short init_x, short init_y) {
429 convert_x[ctype][0] = fix_make(init_x, 0);
430 convert_y[ctype][0] = fix_make(init_y, 0);
431 }
432
433 #define WACKY_FIX_COMPENSATION
gr2ss_register_mode(char conv_mode,short nx,short ny)434 void gr2ss_register_mode(char conv_mode, short nx, short ny) {
435 char m;
436 mode_count[conv_mode]++;
437 m = mode_count[conv_mode];
438 convert_x[conv_mode][m] = fix_div(fix_make(nx, 0), convert_x[conv_mode][0]);
439 convert_y[conv_mode][m] = fix_div(fix_make(ny, 0), convert_y[conv_mode][0]);
440 inv_convert_x[conv_mode][m] = fix_div(convert_x[conv_mode][0], fix_make(nx, 0));
441 inv_convert_y[conv_mode][m] = fix_div(convert_y[conv_mode][0], fix_make(ny, 0));
442
443 #ifdef WACKY_FIX_COMPENSATION
444 // wacky fix point compensation!
445 if (convert_x[conv_mode][m] & 0xF)
446 convert_x[conv_mode][m]++;
447 if (convert_y[conv_mode][m] & 0xF)
448 convert_y[conv_mode][m]++;
449 if (inv_convert_x[conv_mode][m] & 0xF)
450 inv_convert_x[conv_mode][m]++;
451 if (inv_convert_y[conv_mode][m] & 0xF)
452 inv_convert_y[conv_mode][m]++;
453 #endif
454 }
455
ss_recompute_zoom(frc * which_frc,short oldm)456 void ss_recompute_zoom(frc *which_frc, short oldm) {
457 fr_mod_cams(which_frc, FR_NOCAM, fix_div(convert_x[convert_type][convert_use_mode], convert_x[convert_type][oldm]));
458 }
459
ss_point_convert(short * px,short * py,uchar down)460 void ss_point_convert(short *px, short *py, uchar down) {
461 #ifdef SVGA_SUPPORT
462 if (convert_use_mode != 0) {
463 short ox, oy;
464 ox = *px;
465 oy = *py;
466 if (down) {
467 *px = INV_SCONV_X(*px);
468 *py = INV_SCONV_Y(*py);
469 } else {
470 *px = SCONV_X(*px);
471 *py = SCONV_Y(*py);
472 }
473 // Warning(("%d >> %d %d --> %d %d\n",down,ox,oy,*px,*py));
474 }
475 #endif
476 }
477
ss_curr_mode_width(void)478 short ss_curr_mode_width(void) { return (SCONV_X(convert_x[convert_type][0])); }
479
ss_curr_mode_height(void)480 short ss_curr_mode_height(void) { return (SCONV_Y(convert_y[convert_type][0])); }
481
482 // Basically, if you are in the secret hack mode 5
483 // then MODE_SCONV_X will act as if you are in mode M
484 // otherwise it behaves like SCONV_{X,Y}
MODE_SCONV_X(short cval,short m)485 short MODE_SCONV_X(short cval, short m) {
486 if ((!m) || (convert_use_mode != 5))
487 return (SCONV_X(cval));
488 return (fast_fix_mul_int(fix_make(cval, 0), convert_x[convert_type][m]));
489 }
490
MODE_SCONV_Y(short cval,short m)491 short MODE_SCONV_Y(short cval, short m) {
492 if ((!m) || (convert_use_mode != 5))
493 return (SCONV_Y(cval));
494 return (fast_fix_mul_int(fix_make(cval, 0), convert_y[convert_type][m]));
495 }
496
497 // This allows us to override the real mode with some
498 // fake pretender mode, but only if we are in the magic hack mode 5
499 short hack_mode_on;
ss_set_hack_mode(short new_m,short * tval)500 void ss_set_hack_mode(short new_m, short *tval) {
501 if ((convert_use_mode != 5) && (!hack_mode_on))
502 return;
503 if (new_m) {
504 *tval = convert_use_mode;
505 convert_use_mode = new_m;
506 hack_mode_on++;
507 } else {
508 convert_use_mode = *tval;
509 hack_mode_on--;
510 }
511 }
512
513 #endif
514
ss_mouse_convert(short * px,short * py,uchar down)515 void ss_mouse_convert(short *px, short *py, uchar down) {
516 if (convert_use_mode != 0) {
517 #ifdef STEREO_SUPPORT
518 if (convert_use_mode == 5) {
519 switch (i6d_device) {
520 case I6D_CTM:
521 return;
522 break;
523 case I6D_VFX1:
524 if (down)
525 *py = fix_int(fix_mul_div(fix_make(*py, 0), fix_make(200, 0), fix_make(480, 0)));
526 else
527 *py = fix_int(fix_mul_div(fix_make(*py, 0), fix_make(480, 0), fix_make(200, 0)));
528 return;
529 }
530 }
531 #endif
532
533 if (down) {
534 *px = INV_SCONV_X(*px);
535 *py = INV_SCONV_Y(*py);
536 } else {
537 *px = SCONV_X(*px);
538 *py = SCONV_Y(*py);
539 }
540 }
541 }
542
ss_mouse_convert_round(short * px,short * py,uchar down)543 void ss_mouse_convert_round(short *px, short *py, uchar down) {
544 short ox, oy;
545
546 if (convert_use_mode != 0) {
547 #ifdef STEREO_SUPPORT
548 if (convert_use_mode == 5) {
549 ss_mouse_convert(px, py, down);
550 return;
551 }
552 #endif
553 ox = *px;
554 oy = *py;
555 if (down) {
556 *px = fix_int(INV_FIXCONV_X(fix_make(*px, 0x8000)));
557 *py = fix_int(INV_FIXCONV_Y(fix_make(*py, 0x8000)));
558 } else {
559 *px = fix_int(FIXCONV_X(fix_make(*px, 0x8000)));
560 *py = fix_int(FIXCONV_Y(fix_make(*py, 0x8000)));
561 }
562 }
563 }
564
mouse_unconstrain(void)565 void mouse_unconstrain(void) {
566 /* for now
567 #ifdef SVGA_SUPPORT
568 if (convert_use_mode == 5)
569 {
570 switch (i6d_device)
571 {
572 case I6D_CTM:
573 mouse_constrain_xy(0,0,grd_cap->w-1,grd_cap->h-1);
574 break;
575 case I6D_VFX1:
576 mouse_constrain_xy(0,0,i6d_ss->scr_w >> 1, i6d_ss->scr_h);
577 break;
578 }
579 }
580 else
581 #endif */
582 mouse_constrain_xy(0, 0, grd_cap->w - 1, grd_cap->h - 1);
583 }
584