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

Comparing BasiliskII/src/SDL/video_sdl.cpp (file contents):
Revision 1.12 by gbeauche, 2004-07-27T21:40:52Z vs.
Revision 1.13 by gbeauche, 2004-11-28T19:31:11Z

# Line 56 | Line 56
56   #include "video.h"
57   #include "video_defs.h"
58   #include "video_blit.h"
59 + #include "vm_alloc.h"
60  
61   #define DEBUG 0
62   #include "debug.h"
# Line 96 | Line 97 | static uint32 the_buffer_size;                                         // S
97   static bool redraw_thread_active = false;                       // Flag: Redraw thread installed
98   static volatile bool redraw_thread_cancel;                      // Flag: Cancel Redraw thread
99   static SDL_Thread *redraw_thread = NULL;                        // Redraw thread
100 + static volatile bool thread_stop_req = false;
101 + static volatile bool thread_stop_ack = false;           // Acknowledge for thread_stop_req
102  
103   #ifdef ENABLE_VOSF
104   static bool use_vosf = false;                                           // Flag: VOSF enabled
# Line 145 | Line 148 | extern void SysMountFirstFloppy(void);
148  
149  
150   /*
151 + *  Framebuffer allocation routines
152 + */
153 +
154 + static void *vm_acquire_framebuffer(uint32 size)
155 + {
156 + #ifdef SHEEPSHAVER
157 + #ifdef DIRECT_ADDRESSING_HACK
158 +        const uint32 FRAME_BUFFER_BASE = 0x61000000;
159 +        uint8 *fb = Mac2HostAddr(FRAME_BUFFER_BASE);
160 +        if (vm_acquire_fixed(fb, size) < 0)
161 +                fb = VM_MAP_FAILED;
162 +        return fb;
163 + #endif
164 + #endif
165 +        return vm_acquire(size);
166 + }
167 +
168 + static inline void vm_release_framebuffer(void *fb, uint32 size)
169 + {
170 +        vm_release(fb, size);
171 + }
172 +
173 +
174 + /*
175   *  SheepShaver glue
176   */
177  
# Line 554 | Line 581 | driver_base::~driver_base()
581          if (s)
582                  SDL_FreeSurface(s);
583  
584 +        // the_buffer shall always be mapped through vm_acquire_framebuffer()
585 +        if (the_buffer != VM_MAP_FAILED) {
586 +                D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size));
587 +                vm_release_framebuffer(the_buffer, the_buffer_size);
588 +                the_buffer = NULL;
589 +        }
590 +
591          // Free frame buffer(s)
592          if (!use_vosf) {
559                if (the_buffer) {
560                        free(the_buffer);
561                        the_buffer = NULL;
562                }
593                  if (the_buffer_copy) {
594                          free(the_buffer_copy);
595                          the_buffer_copy = NULL;
# Line 567 | Line 597 | driver_base::~driver_base()
597          }
598   #ifdef ENABLE_VOSF
599          else {
570                // the_buffer shall always be mapped through vm_acquire() so that we can vm_protect() it at will
571                if (the_buffer != VM_MAP_FAILED) {
572                        D(bug(" releasing the_buffer at %p (%d bytes)\n", the_buffer, the_buffer_size));
573                        vm_release(the_buffer, the_buffer_size);
574                        the_buffer = NULL;
575                }
600                  if (the_host_buffer) {
601                          D(bug(" freeing the_host_buffer at %p\n", the_host_buffer));
602                          free(the_host_buffer);
# Line 583 | Line 607 | driver_base::~driver_base()
607                          free(the_buffer_copy);
608                          the_buffer_copy = NULL;
609                  }
610 +
611 +                // Deinitialize VOSF
612 +                video_vosf_exit();
613          }
614   #endif
615   }
# Line 632 | Line 659 | driver_window::driver_window(SDL_monitor
659          // Allocate memory for frame buffer (SIZE is extended to page-boundary)
660          the_host_buffer = (uint8 *)s->pixels;
661          the_buffer_size = page_extend((aligned_height + 2) * s->pitch);
662 <        the_buffer = (uint8 *)vm_acquire(the_buffer_size);
662 >        the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
663          the_buffer_copy = (uint8 *)malloc(the_buffer_size);
664          D(bug("the_buffer = %p, the_buffer_copy = %p, the_host_buffer = %p\n", the_buffer, the_buffer_copy, the_host_buffer));
665  
# Line 656 | Line 683 | driver_window::driver_window(SDL_monitor
683                  // Allocate memory for frame buffer
684                  the_buffer_size = (aligned_height + 2) * s->pitch;
685                  the_buffer_copy = (uint8 *)calloc(1, the_buffer_size);
686 <                the_buffer = (uint8 *)calloc(1, the_buffer_size);
686 >                the_buffer = (uint8 *)vm_acquire_framebuffer(the_buffer_size);
687                  D(bug("the_buffer = %p, the_buffer_copy = %p\n", the_buffer, the_buffer_copy));
688          }
689          
# Line 1048 | Line 1075 | void SDL_monitor_desc::video_close(void)
1075          UNLOCK_FRAME_BUFFER;
1076          D(bug(" frame buffer unlocked\n"));
1077  
1051 #ifdef ENABLE_VOSF
1052        if (use_vosf) {
1053                // Deinitialize VOSF
1054                video_vosf_exit();
1055        }
1056 #endif
1057
1078          // Close display
1079          delete drv;
1080          drv = NULL;
# Line 1213 | Line 1233 | int16 video_mode_change(VidLocals *csSav
1233                          csSave->saveData = ReadMacInt32(ParamPtr + csData);
1234                          csSave->savePage = ReadMacInt16(ParamPtr + csPage);
1235  
1236 <                        // Disable interrupts
1236 >                        // Disable interrupts and pause redraw thread
1237                          DisableInterrupt();
1238 +                        thread_stop_ack = false;
1239 +                        thread_stop_req = true;
1240 +                        while (!thread_stop_ack) ;
1241  
1242                          cur_mode = i;
1243                          monitor_desc *monitor = VideoMonitors[0];
# Line 1225 | Line 1248 | int16 video_mode_change(VidLocals *csSav
1248                          csSave->saveData=VModes[cur_mode].viAppleID;/* First mode ... */
1249                          csSave->saveMode=VModes[cur_mode].viAppleMode;
1250  
1251 <                        // Enable interrupts
1251 >                        // Enable interrupts and resume redraw thread
1252 >                        thread_stop_req = false;
1253                          EnableInterrupt();
1254                          return noErr;
1255                  }
# Line 1866 | Line 1890 | static int redraw_func(void *arg)
1890                          next = GetTicks_usec();
1891                  ticks++;
1892  
1893 + #ifdef SHEEPSHAVER
1894 +                // Pause if requested (during video mode switches)
1895 +                if (thread_stop_req) {
1896 +                        thread_stop_ack = true;
1897 +                        continue;
1898 +                }
1899 + #endif
1900 +
1901                  // Handle SDL events
1902                  handle_events();
1903  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines