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 |
+ |
case 16: |
123 |
+ |
mode.depth = VDEPTH_16BIT; |
124 |
+ |
break; |
125 |
+ |
case 24: |
126 |
+ |
case 32: |
127 |
+ |
mode.depth = VDEPTH_32BIT; |
128 |
+ |
break; |
129 |
+ |
} |
130 |
+ |
|
131 |
+ |
VideoModes.push_back(mode); |
132 |
+ |
VideoMonitor.mode = mode; |
133 |
+ |
} |
134 |
+ |
|
135 |
|
// Open window |
136 |
|
static bool init_window(int width, int height) |
137 |
|
{ |
165 |
|
return false; |
166 |
|
} |
167 |
|
|
168 |
< |
// Set VideoMonitor |
168 |
> |
// Add resolution and set VideoMonitor |
169 |
> |
set_video_monitor(width, height, the_bitmap->BytesPerRow, 1); |
170 |
|
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; |
171 |
|
|
172 |
|
// Set FgPen and BgPen |
173 |
|
black_pen = ObtainBestPenA(the_win->WScreen->ViewPort.ColorMap, 0, 0, 0, NULL); |
213 |
|
// Find bitmap |
214 |
|
p96PIP_GetTags(the_win, P96PIP_SourceBitMap, (ULONG)&the_bitmap, TAG_END); |
215 |
|
|
216 |
< |
// Set VideoMonitor |
216 |
> |
// Add resolution and set VideoMonitor |
217 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY); |
218 |
< |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW); |
185 |
< |
VideoMonitor.x = width; |
186 |
< |
VideoMonitor.y = height; |
187 |
< |
VideoMonitor.mode = VMODE_16BIT; |
218 |
> |
set_video_monitor(width, height, p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW), 16); |
219 |
|
return true; |
220 |
|
} |
221 |
|
|
231 |
|
|
232 |
|
switch (depth) { |
233 |
|
case 8: |
203 |
– |
VideoMonitor.mode = VMODE_8BIT; |
234 |
|
break; |
235 |
|
case 15: |
236 |
|
case 16: |
238 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
239 |
|
return false; |
240 |
|
} |
211 |
– |
VideoMonitor.mode = VMODE_16BIT; |
241 |
|
break; |
242 |
|
case 24: |
243 |
|
case 32: |
245 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
246 |
|
return false; |
247 |
|
} |
219 |
– |
VideoMonitor.mode = VMODE_32BIT; |
248 |
|
break; |
249 |
|
default: |
250 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
255 |
|
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
256 |
|
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
257 |
|
|
230 |
– |
VideoMonitor.x = width; |
231 |
– |
VideoMonitor.y = height; |
232 |
– |
|
258 |
|
// Open screen |
259 |
|
the_screen = p96OpenScreenTags( |
260 |
|
P96SA_DisplayID, mode_id, |
287 |
|
return false; |
288 |
|
} |
289 |
|
|
265 |
– |
// Set VideoMonitor |
290 |
|
ScreenToFront(the_screen); |
291 |
+ |
|
292 |
+ |
// Add resolution and set VideoMonitor |
293 |
+ |
set_video_monitor(width, height, p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW), depth); |
294 |
|
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
268 |
– |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
295 |
|
return true; |
296 |
|
} |
297 |
|
|
307 |
|
|
308 |
|
switch (depth) { |
309 |
|
case 8: |
284 |
– |
VideoMonitor.mode = VMODE_8BIT; |
310 |
|
break; |
311 |
|
case 15: |
312 |
|
case 16: |
315 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
316 |
|
return false; |
317 |
|
} |
293 |
– |
VideoMonitor.mode = VMODE_16BIT; |
318 |
|
break; |
319 |
|
case 24: |
320 |
|
case 32: |
322 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
323 |
|
return false; |
324 |
|
} |
301 |
– |
VideoMonitor.mode = VMODE_32BIT; |
325 |
|
break; |
326 |
|
default: |
327 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
332 |
|
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
333 |
|
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
334 |
|
|
312 |
– |
VideoMonitor.x = width; |
313 |
– |
VideoMonitor.y = height; |
314 |
– |
|
335 |
|
// Open screen |
336 |
|
the_screen = OpenScreenTags(NULL, |
337 |
|
SA_DisplayID, mode_id, |
362 |
|
return false; |
363 |
|
} |
364 |
|
|
345 |
– |
// Set VideoMonitor |
365 |
|
ScreenToFront(the_screen); |
366 |
|
static UWORD ptr[] = { 0, 0, 0, 0 }; |
367 |
|
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide mouse pointer |
368 |
+ |
|
369 |
+ |
// Set VideoMonitor |
370 |
+ |
ULONG frame_base; |
371 |
|
APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, |
372 |
< |
LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, |
373 |
< |
TAG_END); |
372 |
> |
LBMI_BASEADDRESS, (ULONG)&frame_base, |
373 |
> |
TAG_END |
374 |
> |
); |
375 |
|
UnLockBitMap(handle); |
376 |
< |
VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); |
376 |
> |
set_video_monitor(width, height, GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD), depth); |
377 |
> |
VideoMonitor.mac_frame_base = frame_base; |
378 |
|
return true; |
379 |
|
} |
380 |
|
|
538 |
|
|
539 |
|
void video_set_palette(uint8 *pal) |
540 |
|
{ |
541 |
< |
if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) { |
541 |
> |
if ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) |
542 |
> |
&& !IsDirectMode(VideoMonitor.mode)) { |
543 |
|
|
544 |
|
// Convert palette to 32 bits |
545 |
|
ULONG table[2 + 256 * 3]; |
558 |
|
|
559 |
|
|
560 |
|
/* |
561 |
+ |
* Switch video mode |
562 |
+ |
*/ |
563 |
+ |
|
564 |
+ |
void video_switch_to_mode(const video_mode &mode) |
565 |
+ |
{ |
566 |
+ |
} |
567 |
+ |
|
568 |
+ |
|
569 |
+ |
/* |
570 |
|
* Video message handling (not neccessary under AmigaOS, handled by periodic_func()) |
571 |
|
*/ |
572 |
|
|
624 |
|
|
625 |
|
// Timer tick, update display |
626 |
|
BltTemplate(the_bitmap->Planes[0], 0, the_bitmap->BytesPerRow, the_win->RPort, |
627 |
< |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.x, VideoMonitor.y); |
627 |
> |
the_win->BorderLeft, the_win->BorderTop, VideoMonitor.mode.x, VideoMonitor.mode.y); |
628 |
|
|
629 |
|
// Restart timer |
630 |
|
timer_io->tr_node.io_Command = TR_ADDREQUEST; |
655 |
|
ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); |
656 |
|
if (mx < the_win->BorderLeft |
657 |
|
|| my < the_win->BorderTop |
658 |
< |
|| mx >= the_win->BorderLeft + VideoMonitor.x |
659 |
< |
|| my >= the_win->BorderTop + VideoMonitor.y) { |
658 |
> |
|| mx >= the_win->BorderLeft + VideoMonitor.mode.x |
659 |
> |
|| my >= the_win->BorderTop + VideoMonitor.mode.y) { |
660 |
|
if (current_pointer) { |
661 |
|
ClearPointer(the_win); |
662 |
|
current_pointer = NULL; |