ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/video_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/video_amiga.cpp (file contents):
Revision 1.5 by cebix, 2000-07-13T17:45:33Z vs.
Revision 1.8 by cebix, 2000-07-22T18:25:48Z

# Line 22 | Line 22
22   #include <intuition/intuition.h>
23   #include <graphics/rastport.h>
24   #include <graphics/gfx.h>
25 < #include <cybergraphx/cybergraphics.h>
25 > #include <cybergraphics/cybergraphics.h>
26   #include <dos/dostags.h>
27   #include <devices/timer.h>
28   #include <proto/exec.h>
# Line 47 | Line 47
47   enum {
48          DISPLAY_WINDOW,
49          DISPLAY_PIP,
50 <        DISPLAY_SCREEN
50 >        DISPLAY_SCREEN_P96,
51 >        DISPLAY_SCREEN_CGFX
52   };
53  
54   // Global variables
# Line 56 | Line 57 | static int display_type = DISPLAY_WINDOW
57   static struct Screen *the_screen = NULL;
58   static struct Window *the_win = NULL;
59   static struct BitMap *the_bitmap = NULL;
60 + static UWORD *null_pointer = NULL;                              // Blank mouse pointer data
61 + static UWORD *current_pointer = (UWORD *)-1;    // Currently visible mouse pointer data
62   static LONG black_pen = -1, white_pen = -1;
63   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
64  
65   extern struct Task *MainTask;                                   // Pointer to main task (from main_amiga.cpp)
66  
# Line 186 | Line 187 | static bool init_pip(int width, int heig
187          return true;
188   }
189  
190 < // Open screen (requires Picasso96/CyberGfx as we need chunky modes)
191 < static bool init_screen(ULONG mode_id)
190 > // Open Picasso96 screen
191 > static bool init_screen_p96(ULONG mode_id)
192   {
193          // Set relative mouse mode
194          ADBSetRelMouseMode(true);
195  
196 <        // Check whether the mode is a Picasso96 mode or a CyberGfx mode
197 <        if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96))
198 <                is_p96 = true;
199 <        else if (CyberGfxBase && IsCyberModeID(mode_id))
200 <                is_cgfx = true;
201 <        else {
202 <                ErrorAlert(GetString(STR_NO_P96_MODE_ERR));
196 >        // Check if the mode is one we can handle
197 >        uint32 depth = p96GetModeIDAttr(mode_id, P96IDA_DEPTH);
198 >        uint32 format = p96GetModeIDAttr(mode_id, P96IDA_RGBFORMAT);
199 >
200 >        switch (depth) {
201 >                case 8:
202 >                        VideoMonitor.mode = VMODE_8BIT;
203 >                        break;
204 >                case 15:
205 >                case 16:
206 >                        if (format != RGBFB_R5G5B5) {
207 >                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
208 >                                return false;
209 >                        }
210 >                        VideoMonitor.mode = VMODE_16BIT;
211 >                        break;
212 >                case 24:
213 >                case 32:
214 >                        if (format != RGBFB_A8R8G8B8) {
215 >                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
216 >                                return false;
217 >                        }
218 >                        VideoMonitor.mode = VMODE_32BIT;
219 >                        break;
220 >                default:
221 >                        ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR));
222 >                        return false;
223 >        }
224 >
225 >        // Yes, get width and height
226 >        uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH);
227 >        uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT);
228 >
229 >        VideoMonitor.x = width;
230 >        VideoMonitor.y = height;
231 >
232 >        // Open screen
233 >        the_screen = p96OpenScreenTags(
234 >                P96SA_DisplayID, mode_id,
235 >                P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
236 >                P96SA_Quiet, TRUE,
237 >                P96SA_NoMemory, TRUE,
238 >                P96SA_NoSprite, TRUE,
239 >                P96SA_Exclusive, TRUE,
240 >                TAG_END
241 >        );
242 >        if (the_screen == NULL) {
243 >                ErrorAlert(GetString(STR_OPEN_SCREEN_ERR));
244                  return false;
245          }
246  
247 <        uint32 depth;
248 <        uint32 format;
247 >        // Open window
248 >        the_win = OpenWindowTags(NULL,
249 >                WA_Left, 0, WA_Top, 0,
250 >                WA_Width, width, WA_Height, height,
251 >                WA_NoCareRefresh, TRUE,
252 >                WA_Borderless, TRUE,
253 >                WA_Activate, TRUE,
254 >                WA_RMBTrap, TRUE,
255 >                WA_ReportMouse, TRUE,
256 >                WA_CustomScreen, (ULONG)the_screen,
257 >                TAG_END
258 >        );
259 >        if (the_win == NULL) {
260 >                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
261 >                return false;
262 >        }
263 >
264 >        // Set VideoMonitor
265 >        ScreenToFront(the_screen);
266 >        VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY);
267 >        VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW);
268 >        return true;
269 > }
270 >
271 > // Open CyberGraphX screen
272 > static bool init_screen_cgfx(ULONG mode_id)
273 > {
274 >        // Set relative mouse mode
275 >        ADBSetRelMouseMode(true);
276  
277          // Check if the mode is one we can handle
278 <        if (is_p96) {
279 <                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 <        }
278 >        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
279 >        uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
280  
281          switch (depth) {
282                  case 8:
# Line 220 | Line 284 | static bool init_screen(ULONG mode_id)
284                          break;
285                  case 15:
286                  case 16:
287 <                        if (format != RGBFB_R5G5B5 && format != PIXFMT_RGB16) {
287 >                        if (format != PIXFMT_RGB16) {
288                                  ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
289                                  return false;
290                          }
# Line 228 | Line 292 | static bool init_screen(ULONG mode_id)
292                          break;
293                  case 24:
294                  case 32:
295 <                        if (format != RGBFB_A8R8G8B8 && format != PIXFMT_ARGB32) {
295 >                        if (format != PIXFMT_ARGB32) {
296                                  ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
297                                  return false;
298                          }
# Line 240 | Line 304 | static bool init_screen(ULONG mode_id)
304          }
305  
306          // Yes, get width and height
307 <        uint32 width;
308 <        uint32 height;
307 >        uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
308 >        uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
309  
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        }
310          VideoMonitor.x = width;
311          VideoMonitor.y = height;
312  
313          // Open screen
314 <        if (is_p96) {
315 <                the_screen = p96OpenScreenTags(
316 <                        P96SA_DisplayID, mode_id,
317 <                        P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
318 <                        P96SA_Quiet, TRUE,
319 <                        P96SA_NoMemory, TRUE,
320 <                        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 <
314 >        the_screen = OpenScreenTags(NULL,
315 >                SA_DisplayID, mode_id,
316 >                SA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
317 >                SA_Quiet, TRUE,
318 >                SA_Exclusive, TRUE,
319 >                TAG_END
320 >        );
321          if (the_screen == NULL) {
322                  ErrorAlert(GetString(STR_OPEN_SCREEN_ERR));
323                  return false;
# Line 298 | Line 342 | static bool init_screen(ULONG mode_id)
342  
343          // Set VideoMonitor
344          ScreenToFront(the_screen);
345 <        if (is_p96) {
346 <                VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY);
347 <                VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW);
348 <        } else {
349 <                static UWORD ptr[] = { 0, 0, 0, 0 };
350 <                SetPointer(the_win, ptr, 0, 0, 0, 0);   // Hide Pointer
351 <
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 <        }
345 >        static UWORD ptr[] = { 0, 0, 0, 0 };
346 >        SetPointer(the_win, ptr, 0, 0, 0, 0);   // Hide mouse pointer
347 >        APTR handle = LockBitMapTags(the_screen->RastPort.BitMap,
348 >                        LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base,
349 >                        TAG_END);
350 >        UnLockBitMap(handle);
351 >        VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD);
352          return true;
353   }
354  
355   bool VideoInit(bool classic)
356   {
357 +        // Allocate blank mouse pointer data
358 +        null_pointer = (UWORD *)AllocMem(12, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR);
359 +        if (null_pointer == NULL) {
360 +                ErrorAlert(GetString(STR_NO_MEM_ERR));
361 +                return false;
362 +        }
363 +
364          // Read frame skip prefs
365          frame_skip = PrefsFindInt32("frameskip");
366          if (frame_skip == 0)
# Line 337 | Line 382 | bool VideoInit(bool classic)
382                          display_type = DISPLAY_WINDOW;
383                  else if (sscanf(mode_str, "pip/%d/%d", &width, &height) == 2 && P96Base)
384                          display_type = DISPLAY_PIP;
385 <                else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base))
386 <                        display_type = DISPLAY_SCREEN;
385 >                else if (sscanf(mode_str, "scr/%08lx", &mode_id) == 1 && (CyberGfxBase || P96Base)) {
386 >                        if (P96Base && p96GetModeIDAttr(mode_id, P96IDA_ISP96))
387 >                                display_type = DISPLAY_SCREEN_P96;
388 >                        else if (CyberGfxBase && IsCyberModeID(mode_id))
389 >                                display_type = DISPLAY_SCREEN_CGFX;
390 >                        else {
391 >                                ErrorAlert(GetString(STR_NO_P96_MODE_ERR));
392 >                                return false;
393 >                        }
394 >                }
395          }
396  
397          // Open display
# Line 353 | Line 406 | bool VideoInit(bool classic)
406                                  return false;
407                          break;
408  
409 <                case DISPLAY_SCREEN:
410 <                        if (!init_screen(mode_id))
409 >                case DISPLAY_SCREEN_P96:
410 >                        if (!init_screen_p96(mode_id))
411 >                                return false;
412 >                        break;
413 >
414 >                case DISPLAY_SCREEN_CGFX:
415 >                        if (!init_screen_cgfx(mode_id))
416                                  return false;
417                          break;
418          }
# Line 413 | Line 471 | void VideoExit(void)
471                                  p96PIP_Close(the_win);
472                          break;
473  
474 <                case DISPLAY_SCREEN:
474 >                case DISPLAY_SCREEN_P96:
475  
476                          // Close window
477                          if (the_win)
# Line 421 | Line 479 | void VideoExit(void)
479  
480                          // Close screen
481                          if (the_screen) {
482 <                                if (is_p96)
483 <                                        p96CloseScreen(the_screen);
484 <                                else
485 <                                        CloseScreen(the_screen);
482 >                                p96CloseScreen(the_screen);
483 >                                the_screen = NULL;
484 >                        }
485 >                        break;
486 >
487 >                case DISPLAY_SCREEN_CGFX:
488  
489 +                        // Close window
490 +                        if (the_win)
491 +                                CloseWindow(the_win);
492 +
493 +                        // Close screen
494 +                        if (the_screen) {
495 +                                CloseScreen(the_screen);
496                                  the_screen = NULL;
497                          }
498                          break;
499          }
500 +
501 +        // Free mouse pointer
502 +        if (null_pointer) {
503 +                FreeMem(null_pointer, 12);
504 +                null_pointer = NULL;
505 +        }
506   }
507  
508  
# Line 439 | Line 512 | void VideoExit(void)
512  
513   void video_set_palette(uint8 *pal)
514   {
515 <        if (display_type == DISPLAY_SCREEN) {
515 >        if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) {
516  
517                  // Convert palette to 32 bits
518                  ULONG table[2 + 256 * 3];
# Line 482 | Line 555 | static __saveds void periodic_func(void)
555          if (win_port) {
556                  win_mask = 1 << win_port->mp_SigBit;
557                  the_win->UserPort = win_port;
558 <                ModifyIDCMP(the_win, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY | (display_type == DISPLAY_SCREEN ? IDCMP_DELTAMOVE : 0));
558 >                ModifyIDCMP(the_win, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY | ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) ? IDCMP_DELTAMOVE : 0));
559          }
560  
561          // Start 60Hz timer for window refresh
# Line 540 | Line 613 | static __saveds void periodic_func(void)
613                                  // Handle message according to class
614                                  switch (cl) {
615                                          case IDCMP_MOUSEMOVE:
616 <                                                if (display_type == DISPLAY_SCREEN)
616 >                                                if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX)
617                                                          ADBMouseMoved(mx, my);
618 <                                                else
618 >                                                else {
619                                                          ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop);
620 +                                                        if (mx < the_win->BorderLeft
621 +                                                         || my < the_win->BorderTop
622 +                                                         || mx >= the_win->BorderLeft + VideoMonitor.x
623 +                                                         || my >= the_win->BorderTop + VideoMonitor.y) {
624 +                                                                if (current_pointer) {
625 +                                                                        ClearPointer(the_win);
626 +                                                                        current_pointer = NULL;
627 +                                                                }
628 +                                                        } else {
629 +                                                                if (current_pointer != null_pointer) {
630 +                                                                        // Hide mouse pointer inside window
631 +                                                                        SetPointer(the_win, null_pointer, 1, 16, 0, 0);
632 +                                                                        current_pointer = null_pointer;
633 +                                                                }
634 +                                                        }
635 +                                                }
636                                                  break;
637  
638                                          case IDCMP_MOUSEBUTTONS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines