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 |
95 |
|
* Initialization |
96 |
|
*/ |
97 |
|
|
98 |
+ |
// Add resolution to list of supported modes and set VideoMonitor |
99 |
+ |
static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, int depth) |
100 |
+ |
{ |
101 |
+ |
video_mode mode; |
102 |
+ |
|
103 |
+ |
mode.x = width; |
104 |
+ |
mode.y = height; |
105 |
+ |
mode.resolution_id = 0x80; |
106 |
+ |
mode.bytes_per_row = bytes_per_row; |
107 |
+ |
|
108 |
+ |
switch (depth) { |
109 |
+ |
case 1: |
110 |
+ |
mode.depth = VDEPTH_1BIT; |
111 |
+ |
break; |
112 |
+ |
case 2: |
113 |
+ |
mode.depth = VDEPTH_2BIT; |
114 |
+ |
break; |
115 |
+ |
case 4: |
116 |
+ |
mode.depth = VDEPTH_4BIT; |
117 |
+ |
break; |
118 |
+ |
case 8: |
119 |
+ |
mode.depth = VDEPTH_8BIT; |
120 |
+ |
break; |
121 |
+ |
case 15: |
122 |
+ |
mode.depth = VDEPTH_16BIT; |
123 |
+ |
break; |
124 |
+ |
case 16: |
125 |
+ |
mode.depth = VDEPTH_16BIT; |
126 |
+ |
break; |
127 |
+ |
case 24: |
128 |
+ |
case 32: |
129 |
+ |
mode.depth = VDEPTH_32BIT; |
130 |
+ |
break; |
131 |
+ |
} |
132 |
+ |
|
133 |
+ |
VideoModes.push_back(mode); |
134 |
+ |
VideoMonitor.mode = mode; |
135 |
+ |
} |
136 |
+ |
|
137 |
|
// Open window |
138 |
|
static bool init_window(int width, int height) |
139 |
|
{ |
167 |
|
return false; |
168 |
|
} |
169 |
|
|
170 |
< |
// Set VideoMonitor |
170 |
> |
// Add resolution and set VideoMonitor |
171 |
> |
set_video_monitor(width, height, the_bitmap->BytesPerRow, 1); |
172 |
|
VideoMonitor.mac_frame_base = (uint32)the_bitmap->Planes[0]; |
133 |
– |
VideoMonitor.bytes_per_row = the_bitmap->BytesPerRow; |
134 |
– |
VideoMonitor.x = width; |
135 |
– |
VideoMonitor.y = height; |
136 |
– |
VideoMonitor.mode = VMODE_1BIT; |
173 |
|
|
174 |
|
// Set FgPen and BgPen |
175 |
|
black_pen = ObtainBestPenA(the_win->WScreen->ViewPort.ColorMap, 0, 0, 0, NULL); |
215 |
|
// Find bitmap |
216 |
|
p96PIP_GetTags(the_win, P96PIP_SourceBitMap, (ULONG)&the_bitmap, TAG_END); |
217 |
|
|
218 |
< |
// Set VideoMonitor |
218 |
> |
// Add resolution and set VideoMonitor |
219 |
> |
set_video_monitor(width, height, p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW), 16); |
220 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY); |
184 |
– |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW); |
185 |
– |
VideoMonitor.x = width; |
186 |
– |
VideoMonitor.y = height; |
187 |
– |
VideoMonitor.mode = VMODE_16BIT; |
221 |
|
return true; |
222 |
|
} |
223 |
|
|
233 |
|
|
234 |
|
switch (depth) { |
235 |
|
case 8: |
203 |
– |
VideoMonitor.mode = VMODE_8BIT; |
236 |
|
break; |
237 |
|
case 15: |
238 |
|
case 16: |
240 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
241 |
|
return false; |
242 |
|
} |
211 |
– |
VideoMonitor.mode = VMODE_16BIT; |
243 |
|
break; |
244 |
|
case 24: |
245 |
|
case 32: |
247 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
248 |
|
return false; |
249 |
|
} |
219 |
– |
VideoMonitor.mode = VMODE_32BIT; |
250 |
|
break; |
251 |
|
default: |
252 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
257 |
|
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
258 |
|
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
259 |
|
|
230 |
– |
VideoMonitor.x = width; |
231 |
– |
VideoMonitor.y = height; |
232 |
– |
|
260 |
|
// Open screen |
261 |
|
the_screen = p96OpenScreenTags( |
262 |
|
P96SA_DisplayID, mode_id, |
289 |
|
return false; |
290 |
|
} |
291 |
|
|
265 |
– |
// Set VideoMonitor |
292 |
|
ScreenToFront(the_screen); |
293 |
+ |
|
294 |
+ |
// Add resolution and set VideoMonitor |
295 |
+ |
set_video_monitor(width, height, p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW), depth); |
296 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
268 |
– |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
297 |
|
return true; |
298 |
|
} |
299 |
|
|
309 |
|
|
310 |
|
switch (depth) { |
311 |
|
case 8: |
284 |
– |
VideoMonitor.mode = VMODE_8BIT; |
312 |
|
break; |
313 |
|
case 15: |
314 |
|
case 16: |
317 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
318 |
|
return false; |
319 |
|
} |
293 |
– |
VideoMonitor.mode = VMODE_16BIT; |
320 |
|
break; |
321 |
|
case 24: |
322 |
|
case 32: |
324 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
325 |
|
return false; |
326 |
|
} |
301 |
– |
VideoMonitor.mode = VMODE_32BIT; |
327 |
|
break; |
328 |
|
default: |
329 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
334 |
|
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
335 |
|
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
336 |
|
|
312 |
– |
VideoMonitor.x = width; |
313 |
– |
VideoMonitor.y = height; |
314 |
– |
|
337 |
|
// Open screen |
338 |
|
the_screen = OpenScreenTags(NULL, |
339 |
|
SA_DisplayID, mode_id, |
364 |
|
return false; |
365 |
|
} |
366 |
|
|
345 |
– |
// Set VideoMonitor |
367 |
|
ScreenToFront(the_screen); |
368 |
|
static UWORD ptr[] = { 0, 0, 0, 0 }; |
369 |
|
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide mouse pointer |
370 |
+ |
|
371 |
+ |
// Set VideoMonitor |
372 |
+ |
ULONG frame_base; |
373 |
|
APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, |
374 |
< |
LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, |
375 |
< |
TAG_END); |
374 |
> |
LBMI_BASEADDRESS, (ULONG)&frame_base, |
375 |
> |
TAG_END |
376 |
> |
); |
377 |
|
UnLockBitMap(handle); |
378 |
< |
VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); |
378 |
> |
set_video_monitor(width, height, GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD), depth); |
379 |
> |
VideoMonitor.mac_frame_base = frame_base; |
380 |
|
return true; |
381 |
|
} |
382 |
|
|
559 |
|
|
560 |
|
|
561 |
|
/* |
562 |
+ |
* Switch video mode |
563 |
+ |
*/ |
564 |
+ |
|
565 |
+ |
void video_switch_to_mode(const video_mode &mode) |
566 |
+ |
{ |
567 |
+ |
} |
568 |
+ |
|
569 |
+ |
|
570 |
+ |
/* |
571 |
|
* Video message handling (not neccessary under AmigaOS, handled by periodic_func()) |
572 |
|
*/ |
573 |
|
|
625 |
|
|
626 |
|
// Timer tick, update display |
627 |
|
BltTemplate(the_bitmap->Planes[0], 0, the_bitmap->BytesPerRow, the_win->RPort, |
628 |
< |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.x, VideoMonitor.y); |
628 |
> |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.mode.x, VideoMonitor.mode.y); |
629 |
|
|
630 |
|
// Restart timer |
631 |
|
timer_io->tr_node.io_Command = TR_ADDREQUEST; |
656 |
|
ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); |
657 |
|
if (mx < the_win->BorderLeft |
658 |
|
|| my < the_win->BorderTop |
659 |
< |
|| mx >= the_win->BorderLeft + VideoMonitor.x |
660 |
< |
|| my >= the_win->BorderTop + VideoMonitor.y) { |
659 |
> |
|| mx >= the_win->BorderLeft + VideoMonitor.mode.x |
660 |
> |
|| my >= the_win->BorderTop + VideoMonitor.mode.y) { |
661 |
|
if (current_pointer) { |
662 |
|
ClearPointer(the_win); |
663 |
|
current_pointer = NULL; |
690 |
|
case IDCMP_RAWKEY: |
691 |
|
if (qualifier & IEQUALIFIER_REPEAT) // Keyboard repeat is done by MacOS |
692 |
|
break; |
693 |
< |
if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == |
694 |
< |
(IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) |
660 |
< |
&& code == 0x5f) { |
693 |
> |
if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == |
694 |
> |
(IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL) && code == 0x5f) { |
695 |
|
SetInterruptFlag(INTFLAG_NMI); |
696 |
|
TriggerInterrupt(); |
697 |
|
break; |