22 |
|
#include <intuition/intuition.h> |
23 |
|
#include <graphics/rastport.h> |
24 |
|
#include <graphics/gfx.h> |
25 |
+ |
#include <cybergraphx/cybergraphics.h> |
26 |
|
#include <dos/dostags.h> |
27 |
|
#include <devices/timer.h> |
28 |
|
#include <proto/exec.h> |
30 |
|
#include <proto/intuition.h> |
31 |
|
#include <proto/graphics.h> |
32 |
|
#include <proto/Picasso96.h> |
33 |
+ |
#include <proto/cybergraphics.h> |
34 |
|
|
35 |
|
#include "sysdeps.h" |
36 |
|
#include "main.h" |
39 |
|
#include "user_strings.h" |
40 |
|
#include "video.h" |
41 |
|
|
42 |
< |
#define DEBUG 1 |
42 |
> |
#define DEBUG 0 |
43 |
|
#include "debug.h" |
44 |
|
|
45 |
|
|
58 |
|
static struct BitMap *the_bitmap = NULL; |
59 |
|
static LONG black_pen = -1, white_pen = -1; |
60 |
|
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 |
63 |
|
|
64 |
|
extern struct Task *MainTask; // Pointer to main task (from main_amiga.cpp) |
65 |
|
|
186 |
|
return true; |
187 |
|
} |
188 |
|
|
189 |
< |
// Open screen (requires Picasso96 as we need chunky modes) |
189 |
> |
// Open screen (requires Picasso96/CyberGfx as we need chunky modes) |
190 |
|
static bool init_screen(ULONG mode_id) |
191 |
|
{ |
192 |
|
// Set relative mouse mode |
193 |
|
ADBSetRelMouseMode(true); |
194 |
|
|
195 |
< |
// Check if the mode is a Picasso96 mode |
196 |
< |
if (!p96GetModeIDAttr(mode_id, P96IDA_ISP96)) { |
195 |
> |
// Check whether the mode is a Picasso96 mode or a CyberGfx mode |
196 |
> |
if (CyberGfxBase && IsCyberModeID(mode_id)) |
197 |
> |
is_cgfx = true; |
198 |
> |
else if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96)) |
199 |
> |
is_p96 = true; |
200 |
> |
else { |
201 |
|
ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); |
202 |
|
return false; |
203 |
|
} |
204 |
|
|
205 |
+ |
uint32 depth; |
206 |
+ |
uint32 format; |
207 |
+ |
|
208 |
|
// Check if the mode is one we can handle |
209 |
< |
uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH); |
210 |
< |
uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT); |
209 |
> |
if (is_p96) { |
210 |
> |
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 |
> |
} |
216 |
> |
|
217 |
|
switch (depth) { |
218 |
|
case 8: |
219 |
|
VideoMonitor.mode = VMODE_8BIT; |
220 |
|
break; |
221 |
|
case 15: |
222 |
|
case 16: |
223 |
< |
if (format != RGBFB_R5G5B5) { |
223 |
> |
if (format != RGBFB_R5G5B5 && format != PIXFMT_RGB16) { |
224 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
225 |
|
return false; |
226 |
|
} |
228 |
|
break; |
229 |
|
case 24: |
230 |
|
case 32: |
231 |
< |
if (format != RGBFB_A8R8G8B8) { |
231 |
> |
if (format != RGBFB_A8R8G8B8 && format != PIXFMT_ARGB32) { |
232 |
|
ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); |
233 |
|
return false; |
234 |
|
} |
240 |
|
} |
241 |
|
|
242 |
|
// Yes, get width and height |
243 |
< |
uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); |
244 |
< |
uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); |
243 |
> |
uint32 width; |
244 |
> |
uint32 height; |
245 |
> |
|
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 |
> |
} |
253 |
|
VideoMonitor.x = width; |
254 |
|
VideoMonitor.y = height; |
255 |
|
|
256 |
|
// Open screen |
257 |
< |
the_screen = p96OpenScreenTags( |
258 |
< |
P96SA_DisplayID, mode_id, |
259 |
< |
P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
260 |
< |
P96SA_Quiet, TRUE, |
261 |
< |
P96SA_NoMemory, TRUE, |
262 |
< |
P96SA_NoSprite, TRUE, |
263 |
< |
P96SA_Exclusive, TRUE, |
264 |
< |
TAG_END |
265 |
< |
); |
257 |
> |
if (is_p96) { |
258 |
> |
the_screen = p96OpenScreenTags( |
259 |
> |
P96SA_DisplayID, mode_id, |
260 |
> |
P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE), |
261 |
> |
P96SA_Quiet, TRUE, |
262 |
> |
P96SA_NoMemory, TRUE, |
263 |
> |
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 |
> |
|
277 |
|
if (the_screen == NULL) { |
278 |
|
ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); |
279 |
|
return false; |
298 |
|
|
299 |
|
// Set VideoMonitor |
300 |
|
ScreenToFront(the_screen); |
301 |
< |
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
302 |
< |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
301 |
> |
if (is_p96) { |
302 |
> |
VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); |
303 |
> |
VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); |
304 |
> |
} else { |
305 |
> |
static UWORD ptr[] = { 0, 0, 0, 0 }; |
306 |
> |
SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide Pointer |
307 |
> |
|
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 |
> |
} |
314 |
|
return true; |
315 |
|
} |
316 |
|
|
337 |
|
display_type = DISPLAY_WINDOW; |
338 |
|
else if (sscanf(mode_str, "pip/%d/%d", &width, &height) == 2 && P96Base) |
339 |
|
display_type = DISPLAY_PIP; |
340 |
< |
else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && P96Base) |
340 |
> |
else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base)) |
341 |
|
display_type = DISPLAY_SCREEN; |
342 |
|
} |
343 |
|
|
420 |
|
CloseWindow(the_win); |
421 |
|
|
422 |
|
// Close screen |
423 |
< |
if (the_screen) |
424 |
< |
p96CloseScreen(the_screen); |
423 |
> |
if (the_screen) { |
424 |
> |
if (is_p96) |
425 |
> |
p96CloseScreen(the_screen); |
426 |
> |
else |
427 |
> |
CloseScreen(the_screen); |
428 |
> |
|
429 |
> |
the_screen = NULL; |
430 |
> |
} |
431 |
|
break; |
432 |
|
} |
433 |
|
} |