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.2 by cebix, 1999-10-19T19:28:21Z vs.
Revision 1.8 by cebix, 2000-07-22T18:25:48Z

# Line 1 | Line 1
1   /*
2   *  video_amiga.cpp - Video/graphics emulation, AmigaOS specific stuff
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2000 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
# Line 22 | Line 22
22   #include <intuition/intuition.h>
23   #include <graphics/rastport.h>
24   #include <graphics/gfx.h>
25 + #include <cybergraphics/cybergraphics.h>
26   #include <dos/dostags.h>
27   #include <devices/timer.h>
28   #include <proto/exec.h>
# Line 29 | Line 30
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"
# Line 37 | Line 39
39   #include "user_strings.h"
40   #include "video.h"
41  
42 < #define DEBUG 1
42 > #define DEBUG 0
43   #include "debug.h"
44  
45  
# Line 45 | 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 54 | 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
64  
# Line 182 | Line 187 | static bool init_pip(int width, int heig
187          return true;
188   }
189  
190 < // Open screen (requires Picasso96 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  
191        // Check if the mode is a Picasso96 mode
192        if (!p96GetModeIDAttr(mode_id, P96IDA_ISP96)) {
193                ErrorAlert(GetString(STR_NO_P96_MODE_ERR));
194                return false;
195        }
196
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;
# Line 225 | Line 225 | static bool init_screen(ULONG mode_id)
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  
# Line 267 | Line 268 | static bool init_screen(ULONG mode_id)
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 +        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
279 +        uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
280 +
281 +        switch (depth) {
282 +                case 8:
283 +                        VideoMonitor.mode = VMODE_8BIT;
284 +                        break;
285 +                case 15:
286 +                case 16:
287 +                        if (format != PIXFMT_RGB16) {
288 +                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
289 +                                return false;
290 +                        }
291 +                        VideoMonitor.mode = VMODE_16BIT;
292 +                        break;
293 +                case 24:
294 +                case 32:
295 +                        if (format != PIXFMT_ARGB32) {
296 +                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
297 +                                return false;
298 +                        }
299 +                        VideoMonitor.mode = VMODE_32BIT;
300 +                        break;
301 +                default:
302 +                        ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR));
303 +                        return false;
304 +        }
305 +
306 +        // Yes, get width and height
307 +        uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
308 +        uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
309 +
310 +        VideoMonitor.x = width;
311 +        VideoMonitor.y = height;
312 +
313 +        // Open screen
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;
324 +        }
325 +
326 +        // Open window
327 +        the_win = OpenWindowTags(NULL,
328 +                WA_Left, 0, WA_Top, 0,
329 +                WA_Width, width, WA_Height, height,
330 +                WA_NoCareRefresh, TRUE,
331 +                WA_Borderless, TRUE,
332 +                WA_Activate, TRUE,
333 +                WA_RMBTrap, TRUE,
334 +                WA_ReportMouse, TRUE,
335 +                WA_CustomScreen, (ULONG)the_screen,
336 +                TAG_END
337 +        );
338 +        if (the_win == NULL) {
339 +                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
340 +                return false;
341 +        }
342 +
343 +        // Set VideoMonitor
344 +        ScreenToFront(the_screen);
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 290 | 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 && 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 306 | 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 366 | 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)
478                                  CloseWindow(the_win);
479  
480                          // Close screen
481 <                        if (the_screen)
481 >                        if (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  
# Line 386 | 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 429 | 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 487 | 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