1 |
|
/* |
2 |
|
* video_vosf.h - Video/graphics emulation, video on SEGV signals support |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2001 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 |
29 |
|
*/ |
30 |
|
|
31 |
|
// Align on page boundaries |
32 |
< |
static uint32 align_on_page_boundary(uint32 size) |
32 |
> |
static uintptr align_on_page_boundary(uintptr size) |
33 |
|
{ |
34 |
|
const uint32 page_size = getpagesize(); |
35 |
|
const uint32 page_mask = page_size - 1; |
45 |
|
|
46 |
|
|
47 |
|
/* |
48 |
– |
* Screen depth identification |
49 |
– |
*/ |
50 |
– |
|
51 |
– |
enum { |
52 |
– |
ID_DEPTH_UNKNOWN = -1, |
53 |
– |
ID_DEPTH_1, |
54 |
– |
ID_DEPTH_8, |
55 |
– |
ID_DEPTH_15, |
56 |
– |
ID_DEPTH_16, |
57 |
– |
ID_DEPTH_24, |
58 |
– |
ID_DEPTH_32 = ID_DEPTH_24, |
59 |
– |
ID_DEPTH_COUNT |
60 |
– |
}; |
61 |
– |
|
62 |
– |
static int depth_id(int depth) |
63 |
– |
{ |
64 |
– |
int id; |
65 |
– |
switch (depth) { |
66 |
– |
case 1 : id = ID_DEPTH_1; break; |
67 |
– |
case 8 : id = ID_DEPTH_8; break; |
68 |
– |
case 15 : id = ID_DEPTH_15; break; |
69 |
– |
case 16 : id = ID_DEPTH_16; break; |
70 |
– |
case 24 : id = ID_DEPTH_24; break; |
71 |
– |
case 32 : id = ID_DEPTH_32; break; |
72 |
– |
default : id = ID_DEPTH_UNKNOWN; |
73 |
– |
} |
74 |
– |
return id; |
75 |
– |
} |
76 |
– |
|
77 |
– |
|
78 |
– |
/* |
79 |
– |
* Frame buffer copy function templates |
80 |
– |
*/ |
81 |
– |
|
82 |
– |
// No conversion required |
83 |
– |
|
84 |
– |
#define MEMCPY_PROFITABLE |
85 |
– |
#ifdef MEMCPY_PROFITABLE |
86 |
– |
static void do_fbcopy_raw(uint8 * dest, const uint8 * source, uint32 length) |
87 |
– |
{ |
88 |
– |
memcpy(dest, source, length); |
89 |
– |
} |
90 |
– |
#else |
91 |
– |
#define FB_BLIT_1(dst, src) (dst = (src)) |
92 |
– |
#define FB_BLIT_2(dst, src) (dst = (src)) |
93 |
– |
#define FB_DEPTH 0 |
94 |
– |
#define FB_FUNC_NAME do_fbcopy_raw |
95 |
– |
#include "video_blit.h" |
96 |
– |
#endif |
97 |
– |
|
98 |
– |
|
99 |
– |
// RGB 555 |
100 |
– |
|
101 |
– |
#ifdef WORDS_BIGENDIAN |
102 |
– |
# define FB_FUNC_NAME do_fbcopy_15_obo |
103 |
– |
#else |
104 |
– |
# define FB_FUNC_NAME do_fbcopy_15_nbo |
105 |
– |
#endif |
106 |
– |
|
107 |
– |
#define FB_BLIT_1(dst, src) \ |
108 |
– |
(dst = (((src) >> 8) & 0xff) | (((src) & 0xff) << 8)) |
109 |
– |
|
110 |
– |
#define FB_BLIT_2(dst, src) \ |
111 |
– |
(dst = (((src) >> 8) & 0x00ff00ff) | (((src) & 0x00ff00ff) << 8)) |
112 |
– |
|
113 |
– |
#define FB_DEPTH 15 |
114 |
– |
#include "video_blit.h" |
115 |
– |
|
116 |
– |
|
117 |
– |
// RGB 565 |
118 |
– |
|
119 |
– |
#ifdef WORDS_BIGENDIAN |
120 |
– |
|
121 |
– |
// native byte order |
122 |
– |
|
123 |
– |
#define FB_BLIT_1(dst, src) \ |
124 |
– |
(dst = (((src) & 0x1f) | (((src) << 1) & 0xffc0))) |
125 |
– |
|
126 |
– |
#define FB_BLIT_2(dst, src) \ |
127 |
– |
(dst = (((src) & 0x001f001f) | (((src) << 1) & 0xffc0ffc0))) |
128 |
– |
|
129 |
– |
#define FB_DEPTH 16 |
130 |
– |
#define FB_FUNC_NAME do_fbcopy_16_nbo |
131 |
– |
#include "video_blit.h" |
132 |
– |
|
133 |
– |
// opposite byte order (untested) |
134 |
– |
|
135 |
– |
#define FB_BLIT_1(dst, src) \ |
136 |
– |
(dst = ((((src) >> 6) & 0xff) | (((src) & 0x60) << 9))) |
137 |
– |
|
138 |
– |
#define FB_BLIT_2(dst, src) \ |
139 |
– |
(dst = ((((src) >> 6) & 0x00ff00ff) | (((src) & 0x00600060) << 9))) |
140 |
– |
|
141 |
– |
#define FB_DEPTH 16 |
142 |
– |
#define FB_FUNC_NAME do_fbcopy_16_obo |
143 |
– |
#include "video_blit.h" |
144 |
– |
|
145 |
– |
#else |
146 |
– |
|
147 |
– |
// native byte order |
148 |
– |
|
149 |
– |
#define FB_BLIT_1(dst, src) \ |
150 |
– |
(dst = (((src) >> 8) & 0x001f) | (((src) << 9) & 0xfe00) | (((src) >> 7) & 0x01c0)) |
151 |
– |
|
152 |
– |
#define FB_BLIT_2(dst, src) \ |
153 |
– |
(dst = (((src) >> 8) & 0x001f001f) | (((src) << 9) & 0xfe00fe00) | (((src) >> 7) & 0x01c001c0)) |
154 |
– |
|
155 |
– |
#define FB_DEPTH 16 |
156 |
– |
#define FB_FUNC_NAME do_fbcopy_16_nbo |
157 |
– |
#include "video_blit.h" |
158 |
– |
|
159 |
– |
// opposite byte order (untested) |
160 |
– |
|
161 |
– |
#define FB_BLIT_1(dst, src) \ |
162 |
– |
(dst = (((src) & 0x1f00) | (((src) << 1) & 0xe0fe) | (((src) >> 15) & 1))) |
163 |
– |
|
164 |
– |
#define FB_BLIT_2(dst, src) \ |
165 |
– |
(dst = (((src) & 0x1f001f00) | (((src) << 1) & 0xe0fee0fe) | (((src) >> 15) & 0x10001))) |
166 |
– |
|
167 |
– |
#define FB_DEPTH 16 |
168 |
– |
#define FB_FUNC_NAME do_fbcopy_16_obo |
169 |
– |
#include "video_blit.h" |
170 |
– |
|
171 |
– |
#endif |
172 |
– |
|
173 |
– |
// RGB 888 |
174 |
– |
|
175 |
– |
#ifdef WORDS_BIGENDIAN |
176 |
– |
# define FB_FUNC_NAME do_fbcopy_24_obo |
177 |
– |
#else |
178 |
– |
# define FB_FUNC_NAME do_fbcopy_24_nbo |
179 |
– |
#endif |
180 |
– |
|
181 |
– |
#define FB_BLIT_1(dst, src) \ |
182 |
– |
(dst = (src)) |
183 |
– |
|
184 |
– |
#define FB_BLIT_2(dst, src) \ |
185 |
– |
(dst = (((src) >> 24) & 0xff) | (((src) >> 16) & 0xff00) | (((src) & 0xff00) << 16) | (((src) & 0xff) << 24)) |
186 |
– |
|
187 |
– |
#define FB_DEPTH 24 |
188 |
– |
#include "video_blit.h" |
189 |
– |
|
190 |
– |
|
191 |
– |
/* |
192 |
– |
* Frame buffer copy functions map table |
193 |
– |
*/ |
194 |
– |
|
195 |
– |
typedef void (*fbcopy_func)(uint8 *, const uint8 *, uint32); |
196 |
– |
static fbcopy_func do_update_framebuffer; |
197 |
– |
|
198 |
– |
#define FBCOPY_FUNC(aHandler) do_ ## aHandler |
199 |
– |
|
200 |
– |
#if REAL_ADDRESSING || DIRECT_ADDRESSING |
201 |
– |
#define WD(X) { FBCOPY_FUNC(X), FBCOPY_FUNC(X) } |
202 |
– |
#else |
203 |
– |
#define WD(X) { FBCOPY_FUNC(fbcopy_raw), FBCOPY_FUNC(fbcopy_raw) } |
204 |
– |
#endif |
205 |
– |
|
206 |
– |
// fb_copy_funcs[depth_id][native_byte_order][dga_mode] |
207 |
– |
// NT : not tested |
208 |
– |
// OK : has been successfully tested |
209 |
– |
// NBO : native byte order |
210 |
– |
// OBO : opposite byte order |
211 |
– |
static fbcopy_func fbcopy_funcs[ID_DEPTH_COUNT][2][2] = { |
212 |
– |
#ifdef WORDS_BIGENDIAN |
213 |
– |
/* opposite byte order native byte order */ |
214 |
– |
/* 1 bpp */ { WD(fbcopy_raw) , WD(fbcopy_raw) }, // NT |
215 |
– |
/* 8 bpp */ { WD(fbcopy_raw) , WD(fbcopy_raw) }, // OK (NBO) |
216 |
– |
/* 15 bpp */ { WD(fbcopy_15_obo) , WD(fbcopy_raw) }, // NT |
217 |
– |
/* 16 bpp */ { WD(fbcopy_16_obo) , WD(fbcopy_16_nbo) }, // NT |
218 |
– |
/* 24 bpp */ { WD(fbcopy_24_obo) , WD(fbcopy_raw) } // NT |
219 |
– |
#else |
220 |
– |
/* opposite byte order native byte order */ |
221 |
– |
/* 1 bpp */ { WD(fbcopy_raw) , WD(fbcopy_raw) }, // NT |
222 |
– |
/* 8 bpp */ { WD(fbcopy_raw) , WD(fbcopy_raw) }, // OK (NBO) |
223 |
– |
/* 15 bpp */ { WD(fbcopy_raw) , WD(fbcopy_15_nbo) }, // OK (NBO) |
224 |
– |
/* 16 bpp */ { WD(fbcopy_16_obo) , WD(fbcopy_16_nbo) }, // OK (NBO) |
225 |
– |
/* 24 bpp */ { WD(fbcopy_raw) , WD(fbcopy_24_nbo) } // NT |
226 |
– |
#endif |
227 |
– |
}; |
228 |
– |
|
229 |
– |
#undef WD |
230 |
– |
|
231 |
– |
#define FBCOPY_FUNC_ERROR \ |
232 |
– |
ErrorAlert("Invalid screen depth") |
233 |
– |
|
234 |
– |
#define GET_FBCOPY_FUNC(aDepth, aNativeByteOrder, aDisplay) \ |
235 |
– |
((depth_id(aDepth) == ID_DEPTH_UNKNOWN) ? ( FBCOPY_FUNC_ERROR, (fbcopy_func)0 ) : \ |
236 |
– |
fbcopy_funcs[depth_id(aDepth)][(aNativeByteOrder)][(aDisplay) == DISPLAY_DGA ? 1 : 0]) |
237 |
– |
|
238 |
– |
|
239 |
– |
/* |
48 |
|
* Screen fault handler |
49 |
|
*/ |
50 |
|
|
51 |
< |
static inline void do_handle_screen_fault(unsigned long addr) |
51 |
> |
const uintptr INVALID_PC = (uintptr)-1; |
52 |
> |
|
53 |
> |
static inline void do_handle_screen_fault(uintptr addr, uintptr pc = INVALID_PC) |
54 |
|
{ |
55 |
< |
if ((addr < mainBuffer.memStart) || (addr >= mainBuffer.memEnd)) { |
56 |
< |
fprintf(stderr, "Segmentation fault at 0x%08X\n", addr); |
57 |
< |
abort(); |
55 |
> |
/* Someone attempted to write to the frame buffer. Make it writeable |
56 |
> |
* now so that the data could actually be written. It will be made |
57 |
> |
* read-only back in one of the screen update_*() functions. |
58 |
> |
*/ |
59 |
> |
if ((addr >= mainBuffer.memStart) && (addr < mainBuffer.memEnd)) { |
60 |
> |
const int page = (addr - mainBuffer.memStart) >> mainBuffer.pageBits; |
61 |
> |
caddr_t page_ad = (caddr_t)(addr & ~(mainBuffer.pageSize - 1)); |
62 |
> |
LOCK_VOSF; |
63 |
> |
PFLAG_SET(page); |
64 |
> |
mprotect(page_ad, mainBuffer.pageSize, PROT_READ | PROT_WRITE); |
65 |
> |
mainBuffer.dirty = true; |
66 |
> |
UNLOCK_VOSF; |
67 |
> |
return; |
68 |
|
} |
69 |
|
|
70 |
< |
const int page = (addr - mainBuffer.memStart) >> mainBuffer.pageBits; |
71 |
< |
caddr_t page_ad = (caddr_t)(addr & ~(mainBuffer.pageSize - 1)); |
72 |
< |
#ifdef HAVE_PTHREADS |
73 |
< |
pthread_mutex_lock(&Screen_draw_lock); |
74 |
< |
#endif |
75 |
< |
PFLAG_SET(page); |
76 |
< |
mprotect(page_ad, mainBuffer.pageSize, PROT_READ | PROT_WRITE); |
257 |
< |
#ifdef HAVE_PTHREADS |
258 |
< |
pthread_mutex_unlock(&Screen_draw_lock); |
259 |
< |
#endif |
70 |
> |
/* Otherwise, we don't know how to handle the fault, let it crash */ |
71 |
> |
fprintf(stderr, "do_handle_screen_fault: unhandled address 0x%08X", addr); |
72 |
> |
if (pc != INVALID_PC) |
73 |
> |
fprintf(stderr, " [IP=0x%08X]", pc); |
74 |
> |
fprintf(stderr, "\n"); |
75 |
> |
|
76 |
> |
signal(SIGSEGV, SIG_DFL); |
77 |
|
} |
78 |
|
|
79 |
|
#if defined(HAVE_SIGINFO_T) |
80 |
+ |
|
81 |
|
static void Screen_fault_handler(int, siginfo_t * sip, void *) |
82 |
|
{ |
83 |
|
D(bug("Screen_fault_handler: ADDR=0x%08X\n", sip->si_addr)); |
84 |
< |
do_handle_screen_fault((unsigned long)sip->si_addr); |
84 |
> |
do_handle_screen_fault((uintptr)sip->si_addr); |
85 |
|
} |
86 |
+ |
|
87 |
|
#elif defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
88 |
+ |
|
89 |
|
# if defined(__i386__) && defined(__linux__) |
90 |
|
static void Screen_fault_handler(int, struct sigcontext scs) |
91 |
|
{ |
92 |
|
D(bug("Screen_fault_handler: ADDR=0x%08X from IP=0x%08X\n", scs.cr2, scs.eip)); |
93 |
< |
do_handle_screen_fault((unsigned long)scs.cr2); |
93 |
> |
do_handle_screen_fault((uintptr)scs.cr2, (uintptr)scs.eip); |
94 |
> |
} |
95 |
> |
|
96 |
> |
# elif defined(__m68k__) && defined(__NetBSD__) |
97 |
> |
|
98 |
> |
# include <m68k/frame.h> |
99 |
> |
static void Screen_fault_handler(int, int code, struct sigcontext *scp) |
100 |
> |
{ |
101 |
> |
D(bug("Screen_fault_handler: ADDR=0x%08X\n", code)); |
102 |
> |
struct sigstate { |
103 |
> |
int ss_flags; |
104 |
> |
struct frame ss_frame; |
105 |
> |
}; |
106 |
> |
struct sigstate *state = (struct sigstate *)scp->sc_ap; |
107 |
> |
uintptr fault_addr; |
108 |
> |
switch (state->ss_frame.f_format) { |
109 |
> |
case 7: // 68040 access error |
110 |
> |
// "code" is sometimes unreliable (i.e. contains NULL or a bogus address), reason unknown |
111 |
> |
fault_addr = state->ss_frame.f_fmt7.f_fa; |
112 |
> |
break; |
113 |
> |
default: |
114 |
> |
fault_addr = (uintptr)code; |
115 |
> |
break; |
116 |
> |
} |
117 |
> |
do_handle_screen_fault(fault_addr); |
118 |
|
} |
119 |
+ |
|
120 |
+ |
# elif defined(__powerpc__) && defined(__linux__) |
121 |
+ |
|
122 |
+ |
static void Screen_fault_handler(int, struct sigcontext_struct *scs) |
123 |
+ |
{ |
124 |
+ |
D(bug("Screen_fault_handler: ADDR=0x%08X from IP=0x%08X\n", scs->regs->dar, scs->regs->nip)); |
125 |
+ |
do_handle_screen_fault((uintptr)scs->regs->dar, (uintptr)scs->regs->nip); |
126 |
+ |
} |
127 |
+ |
|
128 |
|
# else |
129 |
|
# error "No suitable subterfuge for Video on SEGV signals" |
130 |
|
# endif |
143 |
|
// Setup SIGSEGV handler to process writes to frame buffer |
144 |
|
sigemptyset(&vosf_sa.sa_mask); |
145 |
|
vosf_sa.sa_sigaction = Screen_fault_handler; |
146 |
< |
vosf_sa.sa_flags = 0; |
146 |
> |
vosf_sa.sa_flags = SA_SIGINFO; |
147 |
|
return (sigaction(SIGSEGV, &vosf_sa, NULL) == 0); |
148 |
|
} |
149 |
|
#elif defined(HAVE_SIGCONTEXT_SUBTERFUGE) |
152 |
|
// Setup SIGSEGV handler to process writes to frame buffer |
153 |
|
sigemptyset(&vosf_sa.sa_mask); |
154 |
|
vosf_sa.sa_handler = (void (*)(int)) Screen_fault_handler; |
155 |
+ |
#if !EMULATED_68K && defined(__NetBSD__) |
156 |
+ |
sigaddset(&vosf_sa.sa_mask, SIGALRM); |
157 |
+ |
vosf_sa.sa_flags = SA_ONSTACK; |
158 |
+ |
#else |
159 |
|
vosf_sa.sa_flags = 0; |
160 |
+ |
#endif |
161 |
|
return (sigaction(SIGSEGV, &vosf_sa, NULL) == 0); |
162 |
|
} |
163 |
|
#endif |
167 |
|
* Update display for Windowed mode and VOSF |
168 |
|
*/ |
169 |
|
|
170 |
+ |
// From video_blit.cpp |
171 |
+ |
extern void (*Screen_blit)(uint8 * dest, const uint8 * source, uint32 length); |
172 |
+ |
extern bool Screen_blitter_init(XVisualInfo * visual_info, bool native_byte_order); |
173 |
+ |
|
174 |
+ |
/* How can we deal with array overrun conditions ? |
175 |
+ |
|
176 |
+ |
The state of the framebuffer pages that have been touched are maintained |
177 |
+ |
in the dirtyPages[] table. That table is (pageCount + 2) bytes long. |
178 |
+ |
|
179 |
+ |
Terminology |
180 |
+ |
|
181 |
+ |
"Last Page" denotes the pageCount-nth page, i.e. dirtyPages[pageCount - 1]. |
182 |
+ |
"CLEAR Page Guard" refers to the page following the Last Page but is always |
183 |
+ |
in the CLEAR state. "SET Page Guard" refers to the page following the CLEAR |
184 |
+ |
Page Guard but is always in the SET state. |
185 |
+ |
|
186 |
+ |
Rough process |
187 |
+ |
|
188 |
+ |
The update routines must determine which pages have to be blitted to the |
189 |
+ |
screen. This job consists in finding the first_page that was touched. |
190 |
+ |
i.e. find the next page that is SET. Then, finding how many pages were |
191 |
+ |
touched starting from first_page. i.e. find the next page that is CLEAR. |
192 |
+ |
|
193 |
+ |
There are two cases to check: |
194 |
+ |
|
195 |
+ |
- Last Page is CLEAR: find_next_page_set() will reach the SET Page Guard |
196 |
+ |
but it is beyond the valid pageCount value. Therefore, we exit from the |
197 |
+ |
update routine. |
198 |
+ |
|
199 |
+ |
- Last Page is SET: first_page equals (pageCount - 1) and |
200 |
+ |
find_next_page_clear() will reach the CLEAR Page Guard. We blit the last |
201 |
+ |
page to the screen. On the next iteration, page equals pageCount and |
202 |
+ |
find_next_page_set() will reach the SET Page Guard. We still safely exit |
203 |
+ |
from the update routine because the SET Page Guard position is greater |
204 |
+ |
than pageCount. |
205 |
+ |
*/ |
206 |
+ |
|
207 |
|
static inline void update_display_window_vosf(void) |
208 |
|
{ |
209 |
|
int page = 0; |
210 |
|
for (;;) { |
211 |
< |
while (PFLAG_ISCLEAR_4(page)) |
212 |
< |
page += 4; |
318 |
< |
|
319 |
< |
while (PFLAG_ISCLEAR(page)) |
320 |
< |
page++; |
321 |
< |
|
322 |
< |
if (page >= mainBuffer.pageCount) |
211 |
> |
const int first_page = find_next_page_set(page); |
212 |
> |
if (first_page >= mainBuffer.pageCount) |
213 |
|
break; |
214 |
< |
|
215 |
< |
const int first_page = page; |
216 |
< |
PFLAG_CLEAR(first_page); |
217 |
< |
while ((++page < mainBuffer.pageCount) && PFLAG_ISSET(page)) |
328 |
< |
PFLAG_CLEAR(page); |
329 |
< |
|
214 |
> |
|
215 |
> |
page = find_next_page_clear(first_page); |
216 |
> |
PFLAG_CLEAR_RANGE(first_page, page); |
217 |
> |
|
218 |
|
// Make the dirty pages read-only again |
219 |
|
const int32 offset = first_page << mainBuffer.pageBits; |
220 |
|
const uint32 length = (page - first_page) << mainBuffer.pageBits; |
227 |
|
|
228 |
|
const int bytes_per_row = VideoMonitor.bytes_per_row; |
229 |
|
const int bytes_per_pixel = VideoMonitor.bytes_per_row / VideoMonitor.x; |
230 |
< |
int i, j; |
230 |
> |
int i = y1 * bytes_per_row, j; |
231 |
|
|
232 |
< |
// Check for first column from left and first column |
233 |
< |
// from right that have changed |
234 |
< |
int x1 = VideoMonitor.x * bytes_per_pixel - 1; |
235 |
< |
for (j = y1; j <= y2; j++) { |
236 |
< |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
237 |
< |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
350 |
< |
for (i = 0; i < x1; i++) { |
351 |
< |
if (p1[i] != p2[i]) { |
352 |
< |
x1 = i; |
353 |
< |
break; |
354 |
< |
} |
232 |
> |
if (depth == 1) { |
233 |
> |
|
234 |
> |
// Update the_host_buffer and copy of the_buffer |
235 |
> |
for (j = y1; j <= y2; j++) { |
236 |
> |
Screen_blit(the_host_buffer + i, the_buffer + i, VideoMonitor.x >> 3); |
237 |
> |
i += bytes_per_row; |
238 |
|
} |
239 |
< |
} |
240 |
< |
x1 /= bytes_per_pixel; |
241 |
< |
|
242 |
< |
int x2 = x1 * bytes_per_pixel; |
243 |
< |
for (j = y2; j >= y1; j--) { |
244 |
< |
uint8 * const p1 = &the_buffer[j * bytes_per_row]; |
245 |
< |
uint8 * const p2 = &the_buffer_copy[j * bytes_per_row]; |
363 |
< |
for (i = VideoMonitor.x * bytes_per_pixel - 1; i > x2; i--) { |
364 |
< |
if (p1[i] != p2[i]) { |
365 |
< |
x2 = i; |
366 |
< |
break; |
367 |
< |
} |
239 |
> |
|
240 |
> |
} else { |
241 |
> |
|
242 |
> |
// Update the_host_buffer and copy of the_buffer |
243 |
> |
for (j = y1; j <= y2; j++) { |
244 |
> |
Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * VideoMonitor.x); |
245 |
> |
i += bytes_per_row; |
246 |
|
} |
247 |
|
} |
248 |
< |
x2 /= bytes_per_pixel; |
371 |
< |
|
372 |
< |
// Update the_host_buffer and copy of the_buffer |
373 |
< |
// There is at least one pixel to copy |
374 |
< |
const int width = x2 - x1 + 1; |
375 |
< |
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
376 |
< |
for (j = y1; j <= y2; j++) { |
377 |
< |
do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
378 |
< |
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
379 |
< |
i += bytes_per_row; |
380 |
< |
} |
381 |
< |
|
248 |
> |
|
249 |
|
if (have_shm) |
250 |
< |
XShmPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, width, height, 0); |
250 |
> |
XShmPutImage(x_display, the_win, the_gc, img, 0, y1, 0, y1, VideoMonitor.x, height, 0); |
251 |
|
else |
252 |
< |
XPutImage(x_display, the_win, the_gc, img, x1, y1, x1, y1, width, height); |
252 |
> |
XPutImage(x_display, the_win, the_gc, img, 0, y1, 0, y1, VideoMonitor.x, height); |
253 |
|
} |
254 |
+ |
|
255 |
+ |
mainBuffer.dirty = false; |
256 |
|
} |
257 |
|
|
258 |
|
|
266 |
|
{ |
267 |
|
int page = 0; |
268 |
|
for (;;) { |
269 |
< |
while (PFLAG_ISCLEAR_4(page)) |
270 |
< |
page += 4; |
402 |
< |
|
403 |
< |
while (PFLAG_ISCLEAR(page)) |
404 |
< |
page++; |
405 |
< |
|
406 |
< |
if (page >= mainBuffer.pageCount) |
269 |
> |
const int first_page = find_next_page_set(page); |
270 |
> |
if (first_page >= mainBuffer.pageCount) |
271 |
|
break; |
272 |
< |
|
273 |
< |
const int first_page = page; |
274 |
< |
PFLAG_CLEAR(first_page); |
275 |
< |
while ((++page < mainBuffer.pageCount) && PFLAG_ISSET(page)) |
412 |
< |
PFLAG_CLEAR(page); |
413 |
< |
|
272 |
> |
|
273 |
> |
page = find_next_page_clear(first_page); |
274 |
> |
PFLAG_CLEAR_RANGE(first_page, page); |
275 |
> |
|
276 |
|
// Make the dirty pages read-only again |
277 |
|
const int32 offset = first_page << mainBuffer.pageBits; |
278 |
|
const uint32 length = (page - first_page) << mainBuffer.pageBits; |
319 |
|
const int width = x2 - x1 + 1; |
320 |
|
i = y1 * bytes_per_row + x1 * bytes_per_pixel; |
321 |
|
for (j = y1; j <= y2; j++) { |
322 |
< |
do_update_framebuffer(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
322 |
> |
Screen_blit(the_host_buffer + i, the_buffer + i, bytes_per_pixel * width); |
323 |
|
memcpy(the_buffer_copy + i, the_buffer + i, bytes_per_pixel * width); |
324 |
|
i += bytes_per_row; |
325 |
|
} |
326 |
|
} |
327 |
+ |
mainBuffer.dirty = false; |
328 |
|
} |
329 |
|
#endif |
330 |
|
|