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

Comparing BasiliskII/src/Unix/video_x.cpp (file contents):
Revision 1.33 by cebix, 2001-01-06T22:15:35Z vs.
Revision 1.34 by gbeauche, 2001-01-11T16:38:48Z

# Line 197 | Line 197 | struct ScreenInfo {
197      int pageBits;                               // Shift count to get the page number
198      uint32 pageCount;                   // Number of pages allocated to the screen
199      
200 <    uint8 * dirtyPages;                 // Table of flags set if page was altered
200 >    char * dirtyPages;                  // Table of flags set if page was altered
201      ScreenPageInfo * pageInfo;  // Table of mappings page -> Mac scanlines
202   };
203  
204   static ScreenInfo mainBuffer;
205  
206 < #define PFLAG_SET(page)                 mainBuffer.dirtyPages[page] = 1
207 < #define PFLAG_CLEAR(page)               mainBuffer.dirtyPages[page] = 0
208 < #define PFLAG_ISSET(page)               mainBuffer.dirtyPages[page]
209 < #define PFLAG_ISCLEAR(page)             (mainBuffer.dirtyPages[page] == 0)
206 > #define PFLAG_SET_VALUE                 0x00
207 > #define PFLAG_CLEAR_VALUE               0x01
208 > #define PFLAG_SET_VALUE_4               0x00000000
209 > #define PFLAG_CLEAR_VALUE_4             0x01010101
210 > #define PFLAG_SET(page)                 mainBuffer.dirtyPages[page] = PFLAG_SET_VALUE
211 > #define PFLAG_CLEAR(page)               mainBuffer.dirtyPages[page] = PFLAG_CLEAR_VALUE
212 > #define PFLAG_ISSET(page)               (mainBuffer.dirtyPages[page] == PFLAG_SET_VALUE)
213 > #define PFLAG_ISCLEAR(page)             (mainBuffer.dirtyPages[page] != PFLAG_SET_VALUE)
214 >
215   #ifdef UNALIGNED_PROFITABLE
216 < # define PFLAG_ISCLEAR_4(page)  (*((uint32 *)(mainBuffer.dirtyPages + page)) == 0)
216 > # define PFLAG_ISSET_4(page)    (*((uint32 *)(mainBuffer.dirtyPages + (page))) == PFLAG_SET_VALUE_4)
217 > # define PFLAG_ISCLEAR_4(page)  (*((uint32 *)(mainBuffer.dirtyPages + (page))) == PFLAG_CLEAR_VALUE_4)
218 > #else
219 > # define PFLAG_ISSET_4(page) \
220 >                PFLAG_ISSET(page  ) && PFLAG_ISSET(page+1) \
221 >        &&      PFLAG_ISSET(page+2) && PFLAG_ISSET(page+3)
222 > # define PFLAG_ISCLEAR_4(page) \
223 >                PFLAG_ISCLEAR(page  ) && PFLAG_ISCLEAR(page+1) \
224 >        &&      PFLAG_ISCLEAR(page+2) && PFLAG_ISCLEAR(page+3)
225 > #endif
226 >
227 > // Set the selected page range [ first_page, last_page [ into the SET state
228 > #define PFLAG_SET_RANGE(first_page, last_page) \
229 >        memset(mainBuffer.dirtyPages + (first_page), PFLAG_SET_VALUE, \
230 >                (last_page) - (first_page))
231 >
232 > // Set the selected page range [ first_page, last_page [ into the CLEAR state
233 > #define PFLAG_CLEAR_RANGE(first_page, last_page) \
234 >        memset(mainBuffer.dirtyPages + (first_page), PFLAG_CLEAR_VALUE, \
235 >                (last_page) - (first_page))
236 >
237 > #define PFLAG_SET_ALL \
238 >        PFLAG_SET_RANGE(0, mainBuffer.pageCount)
239 >
240 > #define PFLAG_CLEAR_ALL \
241 >        PFLAG_CLEAR_RANGE(0, mainBuffer.pageCount)
242 >
243 > // Set the following macro definition to 1 if your system
244 > // provides a really fast strchr() implementation
245 > //#define HAVE_FAST_STRCHR 0
246 >
247 > static inline int find_next_page_set(int page)
248 > {
249 > #if HAVE_FAST_STRCHR
250 >        char *match = strchr(mainBuffer.dirtyPages + page, PFLAG_SET_VALUE);
251 >        return match ? match - mainBuffer.dirtyPages : mainBuffer.pageCount;
252 > #else
253 >        while (PFLAG_ISCLEAR_4(page))
254 >                page += 4;
255 >        while (PFLAG_ISCLEAR(page))
256 >                page++;
257 >        return page;
258 > #endif
259 > }
260 >
261 > static inline int find_next_page_clear(int page)
262 > {
263 > #if HAVE_FAST_STRCHR
264 >        char *match = strchr(mainBuffer.dirtyPages + page, PFLAG_CLEAR_VALUE);
265 >        return match ? match - mainBuffer.dirtyPages : mainBuffer.pageCount;
266   #else
267 < # define PFLAG_ISCLEAR_4(page)  \
268 <                (mainBuffer.dirtyPages[page  ] == 0) \
269 <        &&      (mainBuffer.dirtyPages[page+1] == 0) \
270 <        &&      (mainBuffer.dirtyPages[page+2] == 0) \
271 <        &&      (mainBuffer.dirtyPages[page+3] == 0)
267 >        // NOTE: the loop is bound to terminate because the last
268 >        // page in mainBuffer.dirtyPages[] shall be set to CLEAR
269 >        while (PFLAG_ISSET_4(page))
270 >                page += 4;
271 >        while (PFLAG_ISSET(page))
272 >                page++;
273 >        return page;
274   #endif
275 < #define PFLAG_CLEAR_ALL                 memset(mainBuffer.dirtyPages, 0, mainBuffer.pageCount)
220 < #define PFLAG_SET_ALL                   memset(mainBuffer.dirtyPages, 1, mainBuffer.pageCount)
275 > }
276  
277   static int zero_fd = -1;
278   static bool Screen_fault_handler_init();
# Line 242 | Line 297 | static int log_base_2(uint32 x)
297          }
298          return l;
299   }
300 <
246 < #endif
300 > #endif /* ENABLE_VOSF */
301  
302   // VideoRefresh function
303   void VideoRefreshInit(void);
# Line 891 | Line 945 | bool VideoInitBuffer()
945                  if (mainBuffer.dirtyPages != 0)
946                          free(mainBuffer.dirtyPages);
947  
948 <                mainBuffer.dirtyPages = (uint8 *) malloc(mainBuffer.pageCount);
948 >                mainBuffer.dirtyPages = (char *) malloc(mainBuffer.pageCount + 1);
949  
950                  if (mainBuffer.pageInfo != 0)
951                          free(mainBuffer.pageInfo);
# Line 902 | Line 956 | bool VideoInitBuffer()
956                          return false;
957  
958                  PFLAG_CLEAR_ALL;
959 +                
960 +                // Make sure there is at least one page marked, so the
961 +                // loops in the update routine will terminate
962 +                // gb-- Set the last page as cleared because the update
963 +                // routine finally searches for a page that was not touched
964 +                PFLAG_CLEAR(mainBuffer.pageCount);
965  
966                  uint32 a = 0;
967                  for (int i = 0; i < mainBuffer.pageCount; i++) {
# Line 1893 | Line 1953 | static void update_display_static(void)
1953   *      Screen refresh functions
1954   */
1955  
1956 < // The specialisations hereunder are meant to enable VOSF with DGA in direct
1957 < // addressing mode in case the address spaces (RAM, ROM, FrameBuffer) could
1958 < // not get mapped correctly with respect to the predetermined host frame
1959 < // buffer base address.
1960 < //
1901 < // Hmm, in other words, when in direct addressing mode and DGA is requested,
1902 < // we first try to "triple allocate" the address spaces according to the real
1903 < // host frame buffer address. Then, if it fails, we will use a temporary
1904 < // frame buffer thus making the real host frame buffer updated when pages
1905 < // of the temp frame buffer are altered.
1906 < //
1907 < // As a side effect, a little speed gain in screen updates could be noticed
1908 < // for other modes than DGA.
1909 < //
1910 < // The following two functions below are inline so that a clever compiler
1911 < // could specialise the code according to the current screen depth and
1912 < // display type. A more clever compiler would the job by itself though...
1913 < // (update_display_vosf is inlined as well)
1956 > // We suggest the compiler to inline the next two functions so that it
1957 > // may specialise the code according to the current screen depth and
1958 > // display type. A clever compiler would that job by itself though...
1959 >
1960 > // NOTE: update_display_vosf is inlined too
1961  
1962   static inline void possibly_quit_dga_mode()
1963   {
# Line 2092 | Line 2139 | static void *redraw_func(void *arg)
2139                  ticks++;
2140          }
2141          uint64 end = GetTicks_usec();
2142 <        printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, (end - start) / ticks);
2142 >        printf("%Ld ticks in %Ld usec = %Ld ticks/sec\n", ticks, end - start, ticks * 1000000 / (end - start));
2143          return NULL;
2144   }
2145   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines