1 |
|
/* |
2 |
|
* video_amiga.cpp - Video/graphics emulation, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 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 |
33 |
|
#include <proto/cybergraphics.h> |
34 |
|
|
35 |
|
#include "sysdeps.h" |
36 |
+ |
#include "cpu_emulation.h" |
37 |
|
#include "main.h" |
38 |
|
#include "adb.h" |
39 |
|
#include "prefs.h" |
62 |
|
static UWORD *current_pointer = (UWORD *)-1; // Currently visible mouse pointer data |
63 |
|
static LONG black_pen = -1, white_pen = -1; |
64 |
|
static struct Process *periodic_proc = NULL; // Periodic process |
65 |
+ |
static int window_width, window_height; // width and height for window display |
66 |
+ |
static ULONG screen_mode_id; // mode ID for screen display |
67 |
|
|
68 |
|
extern struct Task *MainTask; // Pointer to main task (from main_amiga.cpp) |
69 |
|
|
90 |
|
|
91 |
|
|
92 |
|
// Prototypes |
93 |
+ |
static bool video_open(const video_mode &mode); |
94 |
+ |
static void video_close(); |
95 |
|
static void periodic_func(void); |
96 |
+ |
static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth); |
97 |
+ |
static void add_modes(uint32 width, uint32 height, video_depth depth); |
98 |
+ |
static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth); |
99 |
+ |
static ULONG bits_from_depth(video_depth depth); |
100 |
|
|
101 |
|
|
102 |
|
/* |
103 |
|
* Initialization |
104 |
|
*/ |
105 |
|
|
106 |
+ |
|
107 |
|
// Open window |
108 |
|
static bool init_window(int width, int height) |
109 |
|
{ |
126 |
|
TAG_END |
127 |
|
); |
128 |
|
if (the_win == NULL) { |
129 |
< |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
129 |
> |
ErrorAlert(STR_OPEN_WINDOW_ERR); |
130 |
|
return false; |
131 |
|
} |
132 |
|
|
133 |
|
// Create bitmap ("height + 2" for safety) |
134 |
|
the_bitmap = AllocBitMap(width, height + 2, 1, BMF_CLEAR, NULL); |
135 |
|
if (the_bitmap == NULL) { |
136 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
136 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
137 |
|
return false; |
138 |
|
} |
139 |
|
|
140 |
< |
// Set VideoMonitor |
140 |
> |
// Add resolution and set VideoMonitor |
141 |
|
VideoMonitor.mac_frame_base = (uint32)the_bitmap->Planes[0]; |
132 |
– |
VideoMonitor.bytes_per_row = the_bitmap->BytesPerRow; |
133 |
– |
VideoMonitor.x = width; |
134 |
– |
VideoMonitor.y = height; |
135 |
– |
VideoMonitor.mode = VMODE_1BIT; |
142 |
|
|
143 |
|
// Set FgPen and BgPen |
144 |
|
black_pen = ObtainBestPenA(the_win->WScreen->ViewPort.ColorMap, 0, 0, 0, NULL); |
177 |
|
TAG_END |
178 |
|
); |
179 |
|
if (the_win == NULL || error) { |
180 |
< |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
180 |
> |
ErrorAlert(STR_OPEN_WINDOW_ERR); |
181 |
|
return false; |
182 |
|
} |
183 |
|
|
184 |
|
// Find bitmap |
185 |
|
p96PIP_GetTags(the_win, P96PIP_SourceBitMap, (ULONG)&the_bitmap, TAG_END); |
186 |
|
|
187 |
< |
// Set VideoMonitor |
187 |
> |
// Add resolution and set VideoMonitor |
188 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY); |
189 |
< |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW); |
184 |
< |
VideoMonitor.x = width; |
185 |
< |
VideoMonitor.y = height; |
186 |
< |
VideoMonitor.mode = VMODE_16BIT; |
189 |
> |
|
190 |
|
return true; |
191 |
|
} |
192 |
|
|
202 |
|
|
203 |
|
switch (depth) { |
204 |
|
case 8: |
202 |
– |
VideoMonitor.mode = VMODE_8BIT; |
205 |
|
break; |
206 |
|
case 15: |
207 |
|
case 16: |
208 |
|
if (format != RGBFB_R5G5B5) { |
209 |
< |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
209 |
> |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
210 |
|
return false; |
211 |
|
} |
210 |
– |
VideoMonitor.mode = VMODE_16BIT; |
212 |
|
break; |
213 |
|
case 24: |
214 |
|
case 32: |
215 |
|
if (format != RGBFB_A8R8G8B8) { |
216 |
< |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
216 |
> |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
217 |
|
return false; |
218 |
|
} |
218 |
– |
VideoMonitor.mode = VMODE_32BIT; |
219 |
|
break; |
220 |
|
default: |
221 |
< |
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
221 |
> |
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); |
222 |
|
return false; |
223 |
|
} |
224 |
|
|
226 |
|
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
227 |
|
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
228 |
|
|
229 |
– |
VideoMonitor.x = width; |
230 |
– |
VideoMonitor.y = height; |
231 |
– |
|
229 |
|
// Open screen |
230 |
|
the_screen = p96OpenScreenTags( |
231 |
|
P96SA_DisplayID, mode_id, |
237 |
|
TAG_END |
238 |
|
); |
239 |
|
if (the_screen == NULL) { |
240 |
< |
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
240 |
> |
ErrorAlert(STR_OPEN_SCREEN_ERR); |
241 |
|
return false; |
242 |
|
} |
243 |
|
|
245 |
|
the_win = OpenWindowTags(NULL, |
246 |
|
WA_Left, 0, WA_Top, 0, |
247 |
|
WA_Width, width, WA_Height, height, |
248 |
+ |
WA_SimpleRefresh, TRUE, |
249 |
|
WA_NoCareRefresh, TRUE, |
250 |
|
WA_Borderless, TRUE, |
251 |
|
WA_Activate, TRUE, |
255 |
|
TAG_END |
256 |
|
); |
257 |
|
if (the_win == NULL) { |
258 |
< |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
258 |
> |
ErrorAlert(STR_OPEN_WINDOW_ERR); |
259 |
|
return false; |
260 |
|
} |
261 |
|
|
264 |
– |
// Set VideoMonitor |
262 |
|
ScreenToFront(the_screen); |
263 |
+ |
|
264 |
+ |
// Add resolution and set VideoMonitor |
265 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
266 |
< |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
266 |
> |
|
267 |
|
return true; |
268 |
|
} |
269 |
|
|
279 |
|
|
280 |
|
switch (depth) { |
281 |
|
case 8: |
283 |
– |
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)); |
285 |
> |
// !!! PIXFMT_RGB15 is correct !!! |
286 |
> |
if (format != PIXFMT_RGB15) { |
287 |
> |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
288 |
|
return false; |
289 |
|
} |
291 |
– |
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)); |
294 |
> |
ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); |
295 |
|
return false; |
296 |
|
} |
299 |
– |
VideoMonitor.mode = VMODE_32BIT; |
297 |
|
break; |
298 |
|
default: |
299 |
< |
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
299 |
> |
ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); |
300 |
|
return false; |
301 |
|
} |
302 |
|
|
304 |
|
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
305 |
|
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
306 |
|
|
310 |
– |
VideoMonitor.x = width; |
311 |
– |
VideoMonitor.y = height; |
312 |
– |
|
307 |
|
// Open screen |
308 |
|
the_screen = OpenScreenTags(NULL, |
309 |
|
SA_DisplayID, mode_id, |
313 |
|
TAG_END |
314 |
|
); |
315 |
|
if (the_screen == NULL) { |
316 |
< |
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
316 |
> |
ErrorAlert(STR_OPEN_SCREEN_ERR); |
317 |
|
return false; |
318 |
|
} |
319 |
|
|
321 |
|
the_win = OpenWindowTags(NULL, |
322 |
|
WA_Left, 0, WA_Top, 0, |
323 |
|
WA_Width, width, WA_Height, height, |
324 |
+ |
WA_SimpleRefresh, TRUE, |
325 |
|
WA_NoCareRefresh, TRUE, |
326 |
|
WA_Borderless, TRUE, |
327 |
|
WA_Activate, TRUE, |
331 |
|
TAG_END |
332 |
|
); |
333 |
|
if (the_win == NULL) { |
334 |
< |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
334 |
> |
ErrorAlert(STR_OPEN_WINDOW_ERR); |
335 |
|
return false; |
336 |
|
} |
337 |
|
|
343 |
– |
// Set VideoMonitor |
338 |
|
ScreenToFront(the_screen); |
339 |
|
static UWORD ptr[] = { 0, 0, 0, 0 }; |
340 |
|
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide mouse pointer |
341 |
+ |
|
342 |
+ |
// Set VideoMonitor |
343 |
+ |
ULONG frame_base; |
344 |
|
APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, |
345 |
< |
LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, |
346 |
< |
TAG_END); |
345 |
> |
LBMI_BASEADDRESS, (ULONG)&frame_base, |
346 |
> |
TAG_END |
347 |
> |
); |
348 |
|
UnLockBitMap(handle); |
349 |
< |
VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); |
349 |
> |
|
350 |
> |
VideoMonitor.mac_frame_base = frame_base; |
351 |
> |
|
352 |
|
return true; |
353 |
|
} |
354 |
|
|
355 |
|
bool VideoInit(bool classic) |
356 |
|
{ |
357 |
+ |
int default_width, default_height, default_depth; |
358 |
+ |
|
359 |
|
// Allocate blank mouse pointer data |
360 |
|
null_pointer = (UWORD *)AllocMem(12, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR); |
361 |
|
if (null_pointer == NULL) { |
362 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
362 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
363 |
|
return false; |
364 |
|
} |
365 |
|
|
377 |
|
|
378 |
|
// Determine type and mode |
379 |
|
display_type = DISPLAY_WINDOW; |
380 |
< |
int width = 512, height = 384; |
381 |
< |
ULONG mode_id = 0; |
380 |
> |
|
381 |
> |
default_width = window_width = 512; |
382 |
> |
default_height = window_height = 384; |
383 |
> |
|
384 |
|
if (mode_str) { |
385 |
< |
if (sscanf(mode_str, "win/%d/%d", &width, &height) == 2) |
385 |
> |
if (sscanf(mode_str, "win/%d/%d", &window_width, &window_height) == 2) |
386 |
|
display_type = DISPLAY_WINDOW; |
387 |
< |
else if (sscanf(mode_str, "pip/%d/%d", &width, &height) == 2 && P96Base) |
387 |
> |
else if (sscanf(mode_str, "pip/%d/%d", &window_width, &window_height) == 2 && P96Base) |
388 |
|
display_type = DISPLAY_PIP; |
389 |
< |
else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base)) { |
390 |
< |
if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96)) |
389 |
> |
else if (sscanf(mode_str, "scr/%08lx", &screen_mode_id) == 1 && (CyberGfxBase || P96Base)) { |
390 |
> |
if (P96Base && p96GetModeIDAttr(screen_mode_id, P96IDA_ISP96)) |
391 |
|
display_type = DISPLAY_SCREEN_P96; |
392 |
< |
else if (CyberGfxBase && IsCyberModeID(mode_id)) |
392 |
> |
else if (CyberGfxBase && IsCyberModeID(screen_mode_id)) |
393 |
|
display_type = DISPLAY_SCREEN_CGFX; |
394 |
|
else { |
395 |
< |
ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); |
395 |
> |
ErrorAlert(STR_NO_P96_MODE_ERR); |
396 |
|
return false; |
397 |
|
} |
398 |
|
} |
399 |
|
} |
400 |
|
|
401 |
+ |
// Construct list of supported modes |
402 |
+ |
switch (display_type) { |
403 |
+ |
case DISPLAY_WINDOW: |
404 |
+ |
default_width = window_width; |
405 |
+ |
default_height = window_height; |
406 |
+ |
default_depth = 1; |
407 |
+ |
add_modes(window_width, window_height, VDEPTH_1BIT); |
408 |
+ |
break; |
409 |
+ |
|
410 |
+ |
case DISPLAY_PIP: |
411 |
+ |
default_depth = 16; |
412 |
+ |
default_width = window_width; |
413 |
+ |
default_height = window_height; |
414 |
+ |
add_modes(window_width, window_height, VDEPTH_16BIT); |
415 |
+ |
break; |
416 |
+ |
|
417 |
+ |
case DISPLAY_SCREEN_P96: |
418 |
+ |
case DISPLAY_SCREEN_CGFX: |
419 |
+ |
struct DimensionInfo dimInfo; |
420 |
+ |
DisplayInfoHandle handle = FindDisplayInfo(screen_mode_id); |
421 |
+ |
|
422 |
+ |
if (NULL == handle) |
423 |
+ |
return false; |
424 |
+ |
|
425 |
+ |
if (GetDisplayInfoData(handle, (UBYTE *) &dimInfo, sizeof(dimInfo), DTAG_DIMS, 0) <= 0) |
426 |
+ |
return false; |
427 |
+ |
|
428 |
+ |
default_width = 1 + dimInfo.Nominal.MaxX - dimInfo.Nominal.MinX; |
429 |
+ |
default_height = 1 + dimInfo.Nominal.MaxY - dimInfo.Nominal.MinY; |
430 |
+ |
default_depth = dimInfo.MaxDepth; |
431 |
+ |
|
432 |
+ |
for (unsigned d=VDEPTH_1BIT; d<=VDEPTH_32BIT; d++) |
433 |
+ |
{ |
434 |
+ |
if (INVALID_ID != find_mode_for_depth(default_width, default_height, bits_from_depth(video_depth(d)))) |
435 |
+ |
{ |
436 |
+ |
add_modes(default_width, default_height, video_depth(d)); |
437 |
+ |
} |
438 |
+ |
} |
439 |
+ |
break; |
440 |
+ |
} |
441 |
+ |
|
442 |
+ |
video_init_depth_list(); |
443 |
+ |
|
444 |
+ |
#if DEBUG |
445 |
+ |
bug("Available video modes:\n"); |
446 |
+ |
vector<video_mode>::const_iterator i = VideoModes.begin(), end = VideoModes.end(); |
447 |
+ |
while (i != end) { |
448 |
+ |
bug(" %dx%d (ID %02x), %d colors\n", i->x, i->y, i->resolution_id, 1 << bits_from_depth(i->depth)); |
449 |
+ |
++i; |
450 |
+ |
} |
451 |
+ |
#endif |
452 |
+ |
|
453 |
+ |
D(bug("VideoInit: def_width=%ld def_height=%ld def_depth=%ld\n", default_width, default_height, default_depth)); |
454 |
+ |
|
455 |
+ |
// Find requested default mode and open display |
456 |
+ |
if (VideoModes.size() == 1) |
457 |
+ |
return video_open(VideoModes[0]); |
458 |
+ |
else { |
459 |
+ |
// Find mode with specified dimensions |
460 |
+ |
std::vector<video_mode>::const_iterator i, end = VideoModes.end(); |
461 |
+ |
for (i = VideoModes.begin(); i != end; ++i) |
462 |
+ |
{ |
463 |
+ |
D(bug("VideoInit: w=%ld h=%ld d=%ld\n", i->x, i->y, bits_from_depth(i->depth))); |
464 |
+ |
if (i->x == default_width && i->y == default_height && bits_from_depth(i->depth) == default_depth) |
465 |
+ |
return video_open(*i); |
466 |
+ |
} |
467 |
+ |
return video_open(VideoModes[0]); |
468 |
+ |
} |
469 |
+ |
|
470 |
+ |
return true; |
471 |
+ |
} |
472 |
+ |
|
473 |
+ |
|
474 |
+ |
static bool video_open(const video_mode &mode) |
475 |
+ |
{ |
476 |
+ |
ULONG depth_bits = bits_from_depth(mode.depth); |
477 |
+ |
ULONG ID = find_mode_for_depth(mode.x, mode.y, depth_bits); |
478 |
+ |
|
479 |
+ |
D(bug("video_open: width=%ld height=%ld depth=%ld ID=%08lx\n", mode.x, mode.y, depth_bits, ID)); |
480 |
+ |
|
481 |
+ |
if (INVALID_ID == ID) |
482 |
+ |
{ |
483 |
+ |
ErrorAlert(STR_NO_VIDEO_MODE_ERR); |
484 |
+ |
return false; |
485 |
+ |
} |
486 |
+ |
|
487 |
+ |
VideoMonitor.mode = mode; |
488 |
+ |
|
489 |
|
// Open display |
490 |
|
switch (display_type) { |
491 |
|
case DISPLAY_WINDOW: |
492 |
< |
if (!init_window(width, height)) |
492 |
> |
if (!init_window(mode.x, mode.y)) |
493 |
|
return false; |
494 |
|
break; |
495 |
|
|
496 |
|
case DISPLAY_PIP: |
497 |
< |
if (!init_pip(width, height)) |
497 |
> |
if (!init_pip(mode.x, mode.y)) |
498 |
|
return false; |
499 |
|
break; |
500 |
|
|
501 |
|
case DISPLAY_SCREEN_P96: |
502 |
< |
if (!init_screen_p96(mode_id)) |
502 |
> |
if (!init_screen_p96(ID)) |
503 |
|
return false; |
504 |
|
break; |
505 |
|
|
506 |
|
case DISPLAY_SCREEN_CGFX: |
507 |
< |
if (!init_screen_cgfx(mode_id)) |
507 |
> |
if (!init_screen_cgfx(ID)) |
508 |
|
return false; |
509 |
|
break; |
510 |
|
} |
517 |
|
TAG_END |
518 |
|
); |
519 |
|
if (periodic_proc == NULL) { |
520 |
< |
ErrorAlert(GetString(STR_NO_MEM_ERR)); |
520 |
> |
ErrorAlert(STR_NO_MEM_ERR); |
521 |
|
return false; |
522 |
|
} |
523 |
+ |
|
524 |
|
return true; |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
< |
/* |
436 |
< |
* Deinitialization |
437 |
< |
*/ |
438 |
< |
|
439 |
< |
void VideoExit(void) |
528 |
> |
static void video_close() |
529 |
|
{ |
530 |
|
// Stop periodic process |
531 |
|
if (periodic_proc) { |
550 |
|
ReleasePen(the_win->WScreen->ViewPort.ColorMap, white_pen); |
551 |
|
|
552 |
|
CloseWindow(the_win); |
553 |
+ |
the_win = NULL; |
554 |
|
} |
555 |
|
break; |
556 |
|
|
565 |
|
|
566 |
|
// Close window |
567 |
|
if (the_win) |
568 |
+ |
{ |
569 |
|
CloseWindow(the_win); |
570 |
+ |
the_win = NULL; |
571 |
+ |
} |
572 |
|
|
573 |
|
// Close screen |
574 |
|
if (the_screen) { |
581 |
|
|
582 |
|
// Close window |
583 |
|
if (the_win) |
584 |
+ |
{ |
585 |
|
CloseWindow(the_win); |
586 |
+ |
the_win = NULL; |
587 |
+ |
} |
588 |
|
|
589 |
|
// Close screen |
590 |
|
if (the_screen) { |
603 |
|
|
604 |
|
|
605 |
|
/* |
606 |
+ |
* Deinitialization |
607 |
+ |
*/ |
608 |
+ |
|
609 |
+ |
void VideoExit(void) |
610 |
+ |
{ |
611 |
+ |
video_close(); |
612 |
+ |
} |
613 |
+ |
|
614 |
+ |
|
615 |
+ |
/* |
616 |
|
* Set palette |
617 |
|
*/ |
618 |
|
|
619 |
< |
void video_set_palette(uint8 *pal) |
619 |
> |
void video_set_palette(uint8 *pal, int num) |
620 |
|
{ |
621 |
< |
if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) { |
621 |
> |
if ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) |
622 |
> |
&& !IsDirectMode(VideoMonitor.mode)) { |
623 |
|
|
624 |
|
// Convert palette to 32 bits |
625 |
|
ULONG table[2 + 256 * 3]; |
626 |
< |
table[0] = 256 << 16; |
627 |
< |
table[256 * 3 + 1] = 0; |
628 |
< |
for (int i=0; i<256; i++) { |
626 |
> |
table[0] = num << 16; |
627 |
> |
table[num * 3 + 1] = 0; |
628 |
> |
for (int i=0; i<num; i++) { |
629 |
|
table[i*3+1] = pal[i*3] * 0x01010101; |
630 |
|
table[i*3+2] = pal[i*3+1] * 0x01010101; |
631 |
|
table[i*3+3] = pal[i*3+2] * 0x01010101; |
638 |
|
|
639 |
|
|
640 |
|
/* |
641 |
+ |
* Switch video mode |
642 |
+ |
*/ |
643 |
+ |
|
644 |
+ |
void video_switch_to_mode(const video_mode &mode) |
645 |
+ |
{ |
646 |
+ |
// Close and reopen display |
647 |
+ |
video_close(); |
648 |
+ |
if (!video_open(mode)) |
649 |
+ |
{ |
650 |
+ |
ErrorAlert(STR_OPEN_WINDOW_ERR); |
651 |
+ |
QuitEmulator(); |
652 |
+ |
} |
653 |
+ |
} |
654 |
+ |
|
655 |
+ |
|
656 |
+ |
/* |
657 |
+ |
* Close down full-screen mode (if bringing up error alerts is unsafe while in full-screen mode) |
658 |
+ |
*/ |
659 |
+ |
|
660 |
+ |
void VideoQuitFullScreen(void) |
661 |
+ |
{ |
662 |
+ |
} |
663 |
+ |
|
664 |
+ |
|
665 |
+ |
/* |
666 |
|
* Video message handling (not neccessary under AmigaOS, handled by periodic_func()) |
667 |
|
*/ |
668 |
|
|
720 |
|
|
721 |
|
// Timer tick, update display |
722 |
|
BltTemplate(the_bitmap->Planes[0], 0, the_bitmap->BytesPerRow, the_win->RPort, |
723 |
< |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.x, VideoMonitor.y); |
723 |
> |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.mode.x, VideoMonitor.mode.y); |
724 |
|
|
725 |
|
// Restart timer |
726 |
|
timer_io->tr_node.io_Command = TR_ADDREQUEST; |
751 |
|
ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); |
752 |
|
if (mx < the_win->BorderLeft |
753 |
|
|| my < the_win->BorderTop |
754 |
< |
|| mx >= the_win->BorderLeft + VideoMonitor.x |
755 |
< |
|| my >= the_win->BorderTop + VideoMonitor.y) { |
754 |
> |
|| mx >= the_win->BorderLeft + VideoMonitor.mode.x |
755 |
> |
|| my >= the_win->BorderTop + VideoMonitor.mode.y) { |
756 |
|
if (current_pointer) { |
757 |
|
ClearPointer(the_win); |
758 |
|
current_pointer = NULL; |
785 |
|
case IDCMP_RAWKEY: |
786 |
|
if (qualifier & IEQUALIFIER_REPEAT) // Keyboard repeat is done by MacOS |
787 |
|
break; |
788 |
+ |
if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == |
789 |
+ |
(IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL) && code == 0x5f) { |
790 |
+ |
SetInterruptFlag(INTFLAG_NMI); |
791 |
+ |
TriggerInterrupt(); |
792 |
+ |
break; |
793 |
+ |
} |
794 |
+ |
|
795 |
|
if (code & IECODE_UP_PREFIX) |
796 |
|
ADBKeyUp(keycode2mac[code & 0x7f]); |
797 |
|
else |
833 |
|
Forbid(); |
834 |
|
Signal(MainTask, SIGF_SINGLE); |
835 |
|
} |
836 |
+ |
|
837 |
+ |
|
838 |
+ |
// Add mode to list of supported modes |
839 |
+ |
static void add_mode(uint32 width, uint32 height, uint32 resolution_id, uint32 bytes_per_row, video_depth depth) |
840 |
+ |
{ |
841 |
+ |
video_mode mode; |
842 |
+ |
mode.x = width; |
843 |
+ |
mode.y = height; |
844 |
+ |
mode.resolution_id = resolution_id; |
845 |
+ |
mode.bytes_per_row = bytes_per_row; |
846 |
+ |
mode.depth = depth; |
847 |
+ |
|
848 |
+ |
D(bug("Added video mode: w=%ld h=%ld d=%ld\n", width, height, depth)); |
849 |
+ |
|
850 |
+ |
VideoModes.push_back(mode); |
851 |
+ |
} |
852 |
+ |
|
853 |
+ |
// Add standard list of windowed modes for given color depth |
854 |
+ |
static void add_modes(uint32 width, uint32 height, video_depth depth) |
855 |
+ |
{ |
856 |
+ |
D(bug("add_modes: w=%ld h=%ld d=%ld\n", width, height, depth)); |
857 |
+ |
|
858 |
+ |
if (width >= 512 && height >= 384) |
859 |
+ |
add_mode(512, 384, 0x80, TrivialBytesPerRow(512, depth), depth); |
860 |
+ |
if (width >= 640 && height >= 480) |
861 |
+ |
add_mode(640, 480, 0x81, TrivialBytesPerRow(640, depth), depth); |
862 |
+ |
if (width >= 800 && height >= 600) |
863 |
+ |
add_mode(800, 600, 0x82, TrivialBytesPerRow(800, depth), depth); |
864 |
+ |
if (width >= 1024 && height >= 768) |
865 |
+ |
add_mode(1024, 768, 0x83, TrivialBytesPerRow(1024, depth), depth); |
866 |
+ |
if (width >= 1152 && height >= 870) |
867 |
+ |
add_mode(1152, 870, 0x84, TrivialBytesPerRow(1152, depth), depth); |
868 |
+ |
if (width >= 1280 && height >= 1024) |
869 |
+ |
add_mode(1280, 1024, 0x85, TrivialBytesPerRow(1280, depth), depth); |
870 |
+ |
if (width >= 1600 && height >= 1200) |
871 |
+ |
add_mode(1600, 1200, 0x86, TrivialBytesPerRow(1600, depth), depth); |
872 |
+ |
} |
873 |
+ |
|
874 |
+ |
|
875 |
+ |
static ULONG find_mode_for_depth(uint32 width, uint32 height, uint32 depth) |
876 |
+ |
{ |
877 |
+ |
ULONG ID = BestModeID(BIDTAG_NominalWidth, width, |
878 |
+ |
BIDTAG_NominalHeight, height, |
879 |
+ |
BIDTAG_Depth, depth, |
880 |
+ |
TAG_END); |
881 |
+ |
|
882 |
+ |
return ID; |
883 |
+ |
} |
884 |
+ |
|
885 |
+ |
|
886 |
+ |
static ULONG bits_from_depth(video_depth depth) |
887 |
+ |
{ |
888 |
+ |
int bits = 1 << depth; |
889 |
+ |
if (bits == 16) |
890 |
+ |
bits = 15; |
891 |
+ |
else if (bits == 32) |
892 |
+ |
bits = 24; |
893 |
+ |
|
894 |
+ |
return bits; |
895 |
+ |
} |
896 |
+ |
|