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 |
|
|
616 |
|
|
617 |
|
// Timer tick, update display |
618 |
|
BltTemplate(the_bitmap->Planes[0], 0, the_bitmap->BytesPerRow, the_win->RPort, |
619 |
< |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.x, VideoMonitor.y); |
619 |
> |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.mode.x, VideoMonitor.mode.y); |
620 |
|
|
621 |
|
// Restart timer |
622 |
|
timer_io->tr_node.io_Command = TR_ADDREQUEST; |
647 |
|
ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); |
648 |
|
if (mx < the_win->BorderLeft |
649 |
|
|| my < the_win->BorderTop |
650 |
< |
|| mx >= the_win->BorderLeft + VideoMonitor.x |
651 |
< |
|| my >= the_win->BorderTop + VideoMonitor.y) { |
650 |
> |
|| mx >= the_win->BorderLeft + VideoMonitor.mode.x |
651 |
> |
|| my >= the_win->BorderTop + VideoMonitor.mode.y) { |
652 |
|
if (current_pointer) { |
653 |
|
ClearPointer(the_win); |
654 |
|
current_pointer = NULL; |
681 |
|
case IDCMP_RAWKEY: |
682 |
|
if (qualifier & IEQUALIFIER_REPEAT) // Keyboard repeat is done by MacOS |
683 |
|
break; |
684 |
< |
if ((IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL) == |
685 |
< |
(qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) |
660 |
< |
&& 0x5f == code) |
661 |
< |
{ |
684 |
> |
if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == |
685 |
> |
(IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL) && code == 0x5f) { |
686 |
|
SetInterruptFlag(INTFLAG_NMI); |
687 |
|
TriggerInterrupt(); |
688 |
|
break; |
689 |
< |
} |
689 |
> |
} |
690 |
|
|
691 |
|
if (code & IECODE_UP_PREFIX) |
692 |
|
ADBKeyUp(keycode2mac[code & 0x7f]); |