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.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.6 by cebix, 2000-07-14T21:29:12Z

# 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 <cybergraphx/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 107 | Line 110 | static bool init_window(int width, int h
110                  WA_DragBar, TRUE,
111                  WA_DepthGadget, TRUE,
112                  WA_SizeGadget, FALSE,
113 <                WA_Title, GetString(STR_WINDOW_TITLE),
113 >                WA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
114                  TAG_END
115          );
116          if (the_win == NULL) {
# Line 150 | Line 153 | static bool init_pip(int width, int heig
153                  P96PIP_SourceFormat, RGBFB_R5G5B5,
154                  P96PIP_SourceWidth, width,
155                  P96PIP_SourceHeight, height,
156 <                P96PIP_ErrorCode, &error,
156 >                P96PIP_ErrorCode, (ULONG)&error,
157                  WA_Left, 0, WA_Top, 0,
158                  WA_InnerWidth, width, WA_InnerHeight, height,
159                  WA_SimpleRefresh, TRUE,
# Line 161 | Line 164 | static bool init_pip(int width, int heig
164                  WA_DragBar, TRUE,
165                  WA_DepthGadget, TRUE,
166                  WA_SizeGadget, FALSE,
167 <                WA_Title, GetString(STR_WINDOW_TITLE),
168 <                WA_PubScreenName, "Workbench",
167 >                WA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
168 >                WA_PubScreenName, (ULONG)"Workbench",
169                  TAG_END
170          );
171          if (the_win == NULL || error) {
# Line 171 | Line 174 | static bool init_pip(int width, int heig
174          }
175  
176          // Find bitmap
177 <        p96PIP_GetTags(the_win, P96PIP_SourceBitMap, &the_bitmap, TAG_END);
177 >        p96PIP_GetTags(the_win, P96PIP_SourceBitMap, (ULONG)&the_bitmap, TAG_END);
178  
179          // Set VideoMonitor
180          VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY);
# Line 182 | Line 185 | static bool init_pip(int width, int heig
185          return true;
186   }
187  
188 < // Open screen (requires Picasso96 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  
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
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;
# Line 225 | Line 223 | static bool init_screen(ULONG mode_id)
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, GetString(STR_WINDOW_TITLE),
233 >                P96SA_Title, (ULONG)GetString(STR_WINDOW_TITLE),
234                  P96SA_Quiet, TRUE,
235                  P96SA_NoMemory, TRUE,
236                  P96SA_NoSprite, TRUE,
# Line 252 | Line 251 | static bool init_screen(ULONG mode_id)
251                  WA_Activate, TRUE,
252                  WA_RMBTrap, TRUE,
253                  WA_ReportMouse, TRUE,
254 <                WA_CustomScreen, the_screen,
254 >                WA_CustomScreen, (ULONG)the_screen,
255                  TAG_END
256          );
257          if (the_win == NULL) {
# Line 267 | Line 266 | static bool init_screen(ULONG mode_id)
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 +        uint32 depth = GetCyberIDAttr(CYBRIDATTR_DEPTH, mode_id);
277 +        uint32 format = GetCyberIDAttr(CYBRIDATTR_PIXFMT, mode_id);
278 +
279 +        switch (depth) {
280 +                case 8:
281 +                        VideoMonitor.mode = VMODE_8BIT;
282 +                        break;
283 +                case 15:
284 +                case 16:
285 +                        if (format != PIXFMT_RGB16) {
286 +                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
287 +                                return false;
288 +                        }
289 +                        VideoMonitor.mode = VMODE_16BIT;
290 +                        break;
291 +                case 24:
292 +                case 32:
293 +                        if (format != PIXFMT_ARGB32) {
294 +                                ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR));
295 +                                return false;
296 +                        }
297 +                        VideoMonitor.mode = VMODE_32BIT;
298 +                        break;
299 +                default:
300 +                        ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR));
301 +                        return false;
302 +        }
303 +
304 +        // Yes, get width and height
305 +        uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id);
306 +        uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id);
307 +
308 +        VideoMonitor.x = width;
309 +        VideoMonitor.y = height;
310 +
311 +        // Open screen
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;
322 +        }
323 +
324 +        // Open window
325 +        the_win = OpenWindowTags(NULL,
326 +                WA_Left, 0, WA_Top, 0,
327 +                WA_Width, width, WA_Height, height,
328 +                WA_NoCareRefresh, TRUE,
329 +                WA_Borderless, TRUE,
330 +                WA_Activate, TRUE,
331 +                WA_RMBTrap, TRUE,
332 +                WA_ReportMouse, TRUE,
333 +                WA_CustomScreen, (ULONG)the_screen,
334 +                TAG_END
335 +        );
336 +        if (the_win == NULL) {
337 +                ErrorAlert(GetString(STR_OPEN_WINDOW_ERR));
338 +                return false;
339 +        }
340 +
341 +        // Set VideoMonitor
342 +        ScreenToFront(the_screen);
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 +
353   bool VideoInit(bool classic)
354   {
355          // Read frame skip prefs
# Line 290 | Line 373 | bool VideoInit(bool classic)
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 && 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
# Line 306 | Line 397 | bool VideoInit(bool classic)
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          }
410  
411          // Start periodic process
412          periodic_proc = CreateNewProcTags(
413 <                NP_Entry, periodic_func,
414 <                NP_Name, "Basilisk II IDCMP Handler",
413 >                NP_Entry, (ULONG)periodic_func,
414 >                NP_Name, (ULONG)"Basilisk II IDCMP Handler",
415                  NP_Priority, 0,
416                  TAG_END
417          );
# Line 366 | Line 462 | void VideoExit(void)
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)
469                                  CloseWindow(the_win);
470  
471                          // Close screen
472 <                        if (the_screen)
472 >                        if (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;
490          }
491   }
# Line 386 | Line 497 | void VideoExit(void)
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];
# Line 429 | Line 540 | static __saveds void periodic_func(void)
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
# Line 487 | Line 598 | static __saveds void periodic_func(void)
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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines