1 |
|
/* |
2 |
|
* video_amiga.cpp - Video/graphics emulation, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2000 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
22 |
|
#include <intuition/intuition.h> |
23 |
|
#include <graphics/rastport.h> |
24 |
|
#include <graphics/gfx.h> |
25 |
+ |
#include <cybergraphx/cybergraphics.h> |
26 |
|
#include <dos/dostags.h> |
27 |
|
#include <devices/timer.h> |
28 |
|
#include <proto/exec.h> |
30 |
|
#include <proto/intuition.h> |
31 |
|
#include <proto/graphics.h> |
32 |
|
#include <proto/Picasso96.h> |
33 |
+ |
#include <proto/cybergraphics.h> |
34 |
|
|
35 |
|
#include "sysdeps.h" |
36 |
|
#include "main.h" |
39 |
|
#include "user_strings.h" |
40 |
|
#include "video.h" |
41 |
|
|
42 |
< |
#define DEBUG 1 |
42 |
> |
#define DEBUG 0 |
43 |
|
#include "debug.h" |
44 |
|
|
45 |
|
|
47 |
|
enum { |
48 |
|
DISPLAY_WINDOW, |
49 |
|
DISPLAY_PIP, |
50 |
< |
DISPLAY_SCREEN |
50 |
> |
DISPLAY_SCREEN_P96, |
51 |
> |
DISPLAY_SCREEN_CGFX |
52 |
|
}; |
53 |
|
|
54 |
|
// Global variables |
185 |
|
return true; |
186 |
|
} |
187 |
|
|
188 |
< |
// Open screen (requires Picasso96 as we need chunky modes) |
189 |
< |
static bool init_screen(ULONG mode_id) |
188 |
> |
// Open Picasso96 screen |
189 |
> |
static bool init_screen_p96(ULONG mode_id) |
190 |
|
{ |
191 |
|
// Set relative mouse mode |
192 |
|
ADBSetRelMouseMode(true); |
193 |
|
|
191 |
– |
// Check if the mode is a Picasso96 mode |
192 |
– |
if (!p96GetModeIDAttr(mode_id, P96IDA_ISP96)) { |
193 |
– |
ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); |
194 |
– |
return false; |
195 |
– |
} |
196 |
– |
|
194 |
|
// Check if the mode is one we can handle |
195 |
|
uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH); |
196 |
|
uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT); |
197 |
+ |
|
198 |
|
switch (depth) { |
199 |
|
case 8: |
200 |
|
VideoMonitor.mode = VMODE_8BIT; |
223 |
|
// Yes, get width and height |
224 |
|
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
225 |
|
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
226 |
+ |
|
227 |
|
VideoMonitor.x = width; |
228 |
|
VideoMonitor.y = height; |
229 |
|
|
266 |
|
return true; |
267 |
|
} |
268 |
|
|
269 |
+ |
// Open CyberGraphX screen |
270 |
+ |
static bool init_screen_cgfx(ULONG mode_id) |
271 |
+ |
{ |
272 |
+ |
// Set relative mouse mode |
273 |
+ |
ADBSetRelMouseMode(true); |
274 |
+ |
|
275 |
+ |
// Check if the mode is one we can handle |
276 |
+ |
uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id); |
277 |
+ |
uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id); |
278 |
+ |
|
279 |
+ |
switch (depth) { |
280 |
+ |
case 8: |
281 |
+ |
VideoMonitor.mode = VMODE_8BIT; |
282 |
+ |
break; |
283 |
+ |
case 15: |
284 |
+ |
case 16: |
285 |
+ |
if (format != PIXFMT_RGB16) { |
286 |
+ |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
287 |
+ |
return false; |
288 |
+ |
} |
289 |
+ |
VideoMonitor.mode = VMODE_16BIT; |
290 |
+ |
break; |
291 |
+ |
case 24: |
292 |
+ |
case 32: |
293 |
+ |
if (format != PIXFMT_ARGB32) { |
294 |
+ |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
295 |
+ |
return false; |
296 |
+ |
} |
297 |
+ |
VideoMonitor.mode = VMODE_32BIT; |
298 |
+ |
break; |
299 |
+ |
default: |
300 |
+ |
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
301 |
+ |
return false; |
302 |
+ |
} |
303 |
+ |
|
304 |
+ |
// Yes, get width and height |
305 |
+ |
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
306 |
+ |
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
307 |
+ |
|
308 |
+ |
VideoMonitor.x = width; |
309 |
+ |
VideoMonitor.y = height; |
310 |
+ |
|
311 |
+ |
// Open screen |
312 |
+ |
the_screen = OpenScreenTags(NULL, |
313 |
+ |
SA_DisplayID, mode_id, |
314 |
+ |
SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
315 |
+ |
SA_Quiet, TRUE, |
316 |
+ |
SA_Exclusive, TRUE, |
317 |
+ |
TAG_END |
318 |
+ |
); |
319 |
+ |
if (the_screen == NULL) { |
320 |
+ |
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
321 |
+ |
return false; |
322 |
+ |
} |
323 |
+ |
|
324 |
+ |
// Open window |
325 |
+ |
the_win = OpenWindowTags(NULL, |
326 |
+ |
WA_Left, 0, WA_Top, 0, |
327 |
+ |
WA_Width, width, WA_Height, height, |
328 |
+ |
WA_NoCareRefresh, TRUE, |
329 |
+ |
WA_Borderless, TRUE, |
330 |
+ |
WA_Activate, TRUE, |
331 |
+ |
WA_RMBTrap, TRUE, |
332 |
+ |
WA_ReportMouse, TRUE, |
333 |
+ |
WA_CustomScreen, (ULONG)the_screen, |
334 |
+ |
TAG_END |
335 |
+ |
); |
336 |
+ |
if (the_win == NULL) { |
337 |
+ |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
338 |
+ |
return false; |
339 |
+ |
} |
340 |
+ |
|
341 |
+ |
// Set VideoMonitor |
342 |
+ |
ScreenToFront(the_screen); |
343 |
+ |
static UWORD ptr[] = { 0, 0, 0, 0 }; |
344 |
+ |
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide mouse pointer |
345 |
+ |
APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, |
346 |
+ |
LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, |
347 |
+ |
TAG_END); |
348 |
+ |
UnLockBitMap(handle); |
349 |
+ |
VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); |
350 |
+ |
return true; |
351 |
+ |
} |
352 |
+ |
|
353 |
|
bool VideoInit(bool classic) |
354 |
|
{ |
355 |
|
// Read frame skip prefs |
373 |
|
display_type = DISPLAY_WINDOW; |
374 |
|
else if (sscanf(mode_str, "pip/%d/%d", &width, &height) == 2 && P96Base) |
375 |
|
display_type = DISPLAY_PIP; |
376 |
< |
else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && P96Base) |
377 |
< |
display_type = DISPLAY_SCREEN; |
376 |
> |
else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base)) { |
377 |
> |
if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96)) |
378 |
> |
display_type = DISPLAY_SCREEN_P96; |
379 |
> |
else if (CyberGfxBase && IsCyberModeID(mode_id)) |
380 |
> |
display_type = DISPLAY_SCREEN_CGFX; |
381 |
> |
else { |
382 |
> |
ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); |
383 |
> |
return false; |
384 |
> |
} |
385 |
> |
} |
386 |
|
} |
387 |
|
|
388 |
|
// Open display |
397 |
|
return false; |
398 |
|
break; |
399 |
|
|
400 |
< |
case DISPLAY_SCREEN: |
401 |
< |
if (!init_screen(mode_id)) |
400 |
> |
case DISPLAY_SCREEN_P96: |
401 |
> |
if (!init_screen_p96(mode_id)) |
402 |
> |
return false; |
403 |
> |
break; |
404 |
> |
|
405 |
> |
case DISPLAY_SCREEN_CGFX: |
406 |
> |
if (!init_screen_cgfx(mode_id)) |
407 |
|
return false; |
408 |
|
break; |
409 |
|
} |
462 |
|
p96PIP_Close(the_win); |
463 |
|
break; |
464 |
|
|
465 |
< |
case DISPLAY_SCREEN: |
465 |
> |
case DISPLAY_SCREEN_P96: |
466 |
|
|
467 |
|
// Close window |
468 |
|
if (the_win) |
469 |
|
CloseWindow(the_win); |
470 |
|
|
471 |
|
// Close screen |
472 |
< |
if (the_screen) |
472 |
> |
if (the_screen) { |
473 |
|
p96CloseScreen(the_screen); |
474 |
+ |
the_screen = NULL; |
475 |
+ |
} |
476 |
+ |
break; |
477 |
+ |
|
478 |
+ |
case DISPLAY_SCREEN_CGFX: |
479 |
+ |
|
480 |
+ |
// Close window |
481 |
+ |
if (the_win) |
482 |
+ |
CloseWindow(the_win); |
483 |
+ |
|
484 |
+ |
// Close screen |
485 |
+ |
if (the_screen) { |
486 |
+ |
CloseScreen(the_screen); |
487 |
+ |
the_screen = NULL; |
488 |
+ |
} |
489 |
|
break; |
490 |
|
} |
491 |
|
} |
497 |
|
|
498 |
|
void video_set_palette(uint8 *pal) |
499 |
|
{ |
500 |
< |
if (display_type == DISPLAY_SCREEN) { |
500 |
> |
if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) { |
501 |
|
|
502 |
|
// Convert palette to 32 bits |
503 |
|
ULONG table[2 + 256 * 3]; |
540 |
|
if (win_port) { |
541 |
|
win_mask = 1 << win_port->mp_SigBit; |
542 |
|
the_win->UserPort = win_port; |
543 |
< |
ModifyIDCMP(the_win, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY | (display_type == DISPLAY_SCREEN ? IDCMP_DELTAMOVE : 0)); |
543 |
> |
ModifyIDCMP(the_win, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY | ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) ? IDCMP_DELTAMOVE : 0)); |
544 |
|
} |
545 |
|
|
546 |
|
// Start 60Hz timer for window refresh |
598 |
|
// Handle message according to class |
599 |
|
switch (cl) { |
600 |
|
case IDCMP_MOUSEMOVE: |
601 |
< |
if (display_type == DISPLAY_SCREEN) |
601 |
> |
if (display_type == DISPLAY_SCREEN || display_type == DISPLAY_SCREEN_CGFX) |
602 |
|
ADBMouseMoved(mx, my); |
603 |
|
else |
604 |
|
ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); |