47 |
|
enum { |
48 |
|
DISPLAY_WINDOW, |
49 |
|
DISPLAY_PIP, |
50 |
< |
DISPLAY_SCREEN |
50 |
> |
DISPLAY_SCREEN_P96, |
51 |
> |
DISPLAY_SCREEN_CGFX |
52 |
|
}; |
53 |
|
|
54 |
|
// Global variables |
59 |
|
static struct BitMap *the_bitmap = NULL; |
60 |
|
static LONG black_pen = -1, white_pen = -1; |
61 |
|
static struct Process *periodic_proc = NULL; // Periodic process |
61 |
– |
static bool is_cgfx = false; // Flag: screen mode is a CyberGfx mode |
62 |
– |
static bool is_p96 = false; // Flag: screen mode is a Picasso96 mode |
62 |
|
|
63 |
|
extern struct Task *MainTask; // Pointer to main task (from main_amiga.cpp) |
64 |
|
|
185 |
|
return true; |
186 |
|
} |
187 |
|
|
188 |
< |
// Open screen (requires Picasso96/CyberGfx 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 |
|
|
194 |
< |
// Check whether the mode is a Picasso96 mode or a CyberGfx mode |
195 |
< |
if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96)) |
196 |
< |
is_p96 = true; |
197 |
< |
else if (CyberGfxBase && IsCyberModeID(mode_id)) |
198 |
< |
is_cgfx = true; |
199 |
< |
else { |
200 |
< |
ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); |
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; |
201 |
> |
break; |
202 |
> |
case 15: |
203 |
> |
case 16: |
204 |
> |
if (format != RGBFB_R5G5B5) { |
205 |
> |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
206 |
> |
return false; |
207 |
> |
} |
208 |
> |
VideoMonitor.mode = VMODE_16BIT; |
209 |
> |
break; |
210 |
> |
case 24: |
211 |
> |
case 32: |
212 |
> |
if (format != RGBFB_A8R8G8B8) { |
213 |
> |
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
214 |
> |
return false; |
215 |
> |
} |
216 |
> |
VideoMonitor.mode = VMODE_32BIT; |
217 |
> |
break; |
218 |
> |
default: |
219 |
> |
ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); |
220 |
> |
return false; |
221 |
> |
} |
222 |
> |
|
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 |
> |
|
230 |
> |
// Open screen |
231 |
> |
the_screen = p96OpenScreenTags( |
232 |
> |
P96SA_DisplayID, mode_id, |
233 |
> |
P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
234 |
> |
P96SA_Quiet, TRUE, |
235 |
> |
P96SA_NoMemory, TRUE, |
236 |
> |
P96SA_NoSprite, TRUE, |
237 |
> |
P96SA_Exclusive, TRUE, |
238 |
> |
TAG_END |
239 |
> |
); |
240 |
> |
if (the_screen == NULL) { |
241 |
> |
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
242 |
|
return false; |
243 |
|
} |
244 |
|
|
245 |
< |
uint32 depth; |
246 |
< |
uint32 format; |
245 |
> |
// Open window |
246 |
> |
the_win = OpenWindowTags(NULL, |
247 |
> |
WA_Left, 0, WA_Top, 0, |
248 |
> |
WA_Width, width, WA_Height, height, |
249 |
> |
WA_NoCareRefresh, TRUE, |
250 |
> |
WA_Borderless, TRUE, |
251 |
> |
WA_Activate, TRUE, |
252 |
> |
WA_RMBTrap, TRUE, |
253 |
> |
WA_ReportMouse, TRUE, |
254 |
> |
WA_CustomScreen, (ULONG)the_screen, |
255 |
> |
TAG_END |
256 |
> |
); |
257 |
> |
if (the_win == NULL) { |
258 |
> |
ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); |
259 |
> |
return false; |
260 |
> |
} |
261 |
> |
|
262 |
> |
// Set VideoMonitor |
263 |
> |
ScreenToFront(the_screen); |
264 |
> |
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
265 |
> |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
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 |
< |
if (is_p96) { |
277 |
< |
depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH); |
211 |
< |
format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT); |
212 |
< |
} else { |
213 |
< |
depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id); |
214 |
< |
format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id); |
215 |
< |
} |
276 |
> |
uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id); |
277 |
> |
uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id); |
278 |
|
|
279 |
|
switch (depth) { |
280 |
|
case 8: |
282 |
|
break; |
283 |
|
case 15: |
284 |
|
case 16: |
285 |
< |
if (format != RGBFB_R5G5B5 && format != PIXFMT_RGB16) { |
285 |
> |
if (format != PIXFMT_RGB16) { |
286 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
287 |
|
return false; |
288 |
|
} |
290 |
|
break; |
291 |
|
case 24: |
292 |
|
case 32: |
293 |
< |
if (format != RGBFB_A8R8G8B8 && format != PIXFMT_ARGB32) { |
293 |
> |
if (format != PIXFMT_ARGB32) { |
294 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
295 |
|
return false; |
296 |
|
} |
302 |
|
} |
303 |
|
|
304 |
|
// Yes, get width and height |
305 |
< |
uint32 width; |
306 |
< |
uint32 height; |
305 |
> |
uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
306 |
> |
uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
307 |
|
|
246 |
– |
if (is_p96) { |
247 |
– |
width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
248 |
– |
height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
249 |
– |
} else { |
250 |
– |
width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); |
251 |
– |
height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); |
252 |
– |
} |
308 |
|
VideoMonitor.x = width; |
309 |
|
VideoMonitor.y = height; |
310 |
|
|
311 |
|
// Open screen |
312 |
< |
if (is_p96) { |
313 |
< |
the_screen = p96OpenScreenTags( |
314 |
< |
P96SA_DisplayID, mode_id, |
315 |
< |
P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
316 |
< |
P96SA_Quiet, TRUE, |
317 |
< |
P96SA_NoMemory, TRUE, |
318 |
< |
P96SA_NoSprite, TRUE, |
264 |
< |
P96SA_Exclusive, TRUE, |
265 |
< |
TAG_END |
266 |
< |
); |
267 |
< |
} else { |
268 |
< |
the_screen = OpenScreenTags(NULL, |
269 |
< |
SA_DisplayID, mode_id, |
270 |
< |
SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
271 |
< |
SA_Quiet, TRUE, |
272 |
< |
SA_Exclusive, TRUE, |
273 |
< |
TAG_END |
274 |
< |
); |
275 |
< |
} |
276 |
< |
|
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; |
340 |
|
|
341 |
|
// Set VideoMonitor |
342 |
|
ScreenToFront(the_screen); |
343 |
< |
if (is_p96) { |
344 |
< |
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
345 |
< |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
346 |
< |
} else { |
347 |
< |
static UWORD ptr[] = { 0, 0, 0, 0 }; |
348 |
< |
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide Pointer |
349 |
< |
|
308 |
< |
APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, |
309 |
< |
LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, |
310 |
< |
TAG_END); |
311 |
< |
UnLockBitMap(handle); |
312 |
< |
VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); |
313 |
< |
} |
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 |
|
|
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 && (CyberGfxBase || 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) |
470 |
|
|
471 |
|
// Close screen |
472 |
|
if (the_screen) { |
473 |
< |
if (is_p96) |
474 |
< |
p96CloseScreen(the_screen); |
475 |
< |
else |
476 |
< |
CloseScreen(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; |
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); |