/[gxemul]/trunk/src/devices/fb_include.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/src/devices/fb_include.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (hide annotations)
Mon Oct 8 16:19:37 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 7498 byte(s)
++ trunk/HISTORY	(local)
$Id: HISTORY,v 1.1121 2006/02/18 21:03:08 debug Exp $
20051126	Cobalt and PReP now work with the 21143 NIC.
		Continuing on Alpha dyntrans things.
		Fixing some more left-shift-by-24 to unsigned.
20051127	Working on OpenFirmware emulation; major cleanup/redesign.
		Progress on MacPPC emulation: NetBSD detects two CPUs (when
		running with -n 2), framebuffer output (for text) works.
		Adding quick-hack Bandit PCI controller and "gc" interrupt
		controller for MacPPC.
20051128	Changing from a Bandit to a Uni-North controller for macppc.
		Continuing on OpenFirmware and MacPPC emulation in general
		(obio controller, and wdc attached to the obio seems to work).
20051129	More work on MacPPC emulation (adding a dummy ADB controller).
		Continuing the PCI bus cleanup (endianness and tag composition)
		and rewriting all PCI controllers' access functions.
20051130	Various minor PPC dyntrans optimizations.
		Manually inlining some parts of the framebuffer redraw routine.
		Slowly beginning the conversion of the old MIPS emulation into
		dyntrans (but this will take quite some time to get right).
		Generalizing quick_pc_to_pointers.
20051201	Documentation update (David Muse has made available a kernel
		which simplifies Debian/DECstation installation).
		Continuing on the ADB bus controller.
20051202	Beginning a rewrite of the Zilog serial controller (dev_zs).
20051203	Continuing on the zs rewrite (now called dev_z8530); conversion
		to devinit style.
		Reworking some of the input-only vs output-only vs input-output
		details of src/console.c, better warning messages, and adding
		a debug dump.
		Removing the concept of "device state"; it wasn't really used.
		Changing some debug output (-vv should now be used to show all
		details about devices and busses; not shown during normal
		startup anymore).
		Beginning on some SPARC instruction disassembly support.
20051204	Minor PPC updates (WALNUT skeleton stuff).
		Continuing on the MIPS dyntrans rewrite.
		More progress on the ADB controller (a keyboard is "detected"
		by NetBSD and OpenBSD).
		Downgrading OpenBSD/arc as a guest OS from "working" to
		"almost working" in the documentation.
		Progress on Algor emulation ("v3" PCI controller).
20051205	Minor updates.
20051207	Sorting devices according to address; this reduces complexity
		of device lookups from O(n) to O(log n) in memory_rw (but no
		real performance increase (yet) in experiments).
20051210	Beginning the work on native dyntrans backends (by making a
		simple skeleton; so far only for Alpha hosts).
20051211	Some very minor SPARC updates.
20051215	Fixing a bug in the MIPS mul (note: not mult) instruction,
		so it also works with non-64-bit emulation. (Thanks to Alec
		Voropay for noticing the problem.)
20051216	More work on the fake/empty/simple/skeleton/whatever backend;
		performance doesn't increase, so this isn't really worth it,
		but it was probably worth it to prepare for a real backend
		later.
20051219	More instr call statistics gathering and analysis stuff.
20051220	Another fix for MIPS 'mul'. Also converting mul and {d,}cl{o,z}
		to dyntrans.
		memory_ppc.c syntax error fix (noticed by Peter Valchev).
		Beginning to move out machines from src/machine.c into
		individual files in src/machines (in a way similar to the
		autodev system for devices).
20051222	Updating the documentation regarding NetBSD/pmax 3.0.
20051223	- " - NetBSD/cats 3.0.
20051225	- " - NetBSD/hpcmips 3.0.
20051226	Continuing on the machine registry redesign.
		Adding support for ARM rrx (33-bit rotate).
		Fixing some signed/unsigned issues (exposed by gcc -W).
20051227	Fixing the bug which prevented a NetBSD/prep 3.0 install kernel
		from starting (triggered when an mtmsr was the last instruction
		on a page). Unfortunately not enough to get the kernel to run
		as well as the 2.1 kernels did.
20051230	Some dyntrans refactoring.
20051231	Continuing on the machine registry redesign.
20060101-10	Continuing... moving more machines. Moving MD interrupt stuff
		from machine.c into a new src/machines/interrupts.c.
20060114	Adding various mvmeppc machine skeletons.
20060115	Continuing on mvme* stuff. NetBSD/mvmeppc prints boot messages
		(for MVME1600) and reaches the root device prompt, but no
		specific hardware devices are emulated yet.
20060116	Minor updates to the mvme1600 emulation mode; the Eagle PCI bus
		seems to work without much modification, and a 21143 can be
		detected, interrupts might work (but untested so far).
		Adding a fake MK48Txx (mkclock) device, for NetBSD/mvmeppc.
20060121	Adding an aux control register for ARM. (A BIG thank you to
		Olivier Houchard for tracking down this bug.)
20060122	Adding more ARM instructions (smulXY), and dev_iq80321_7seg.
20060124	Adding disassembly of more ARM instructions (mia*, mra/mar),
		and some semi-bogus XScale and i80321 registers.
20060201-02	Various minor updates. Moving the last machines out of
		machine.c.
20060204	Adding a -c command line option, for running debugger commands
		before the simulation starts, but after all files have been
		loaded.
		Minor iq80321-related updates.
20060209	Minor hacks (DEVINIT macro, etc).
		Preparing for the generalization of the 64-bit dyntrans address
		translation subsystem.
20060216	Adding ARM ldrd (double-register load).
20060217	Continuing on various ARM-related stuff.
20060218	More progress on the ATA/wdc emulation for NetBSD/iq80321.
		NetBSD/evbarm can now be installed :-)  Updating the docs, etc.
		Continuing on Algor emulation.

==============  RELEASE 0.3.8  ==============


1 dpavlin 22 /*
2     * $Id: fb_include.c,v 1.2 2005/11/30 21:20:42 debug Exp $
3     *
4     * Included from dev_fb.c.
5     *
6     * FB_SCALEDOWN should be defined if d->vfb_scaledown > 1.
7     * FB_BO for d->fb_window->fb_ximage->byte_order non-zero
8     * FB_24 for 24-bit X11 color.
9     * FB_16 for 16-bit X11 color.
10     * FB_15 for 15-bit X11 color.
11     * (Default is to fallback to grayscale.)
12     */
13    
14    
15     #ifdef macro_put_pixel1
16     #undef macro_put_pixel1
17     #endif
18    
19     /* Combine the color into an X11 long and display it: */ \
20     /* TODO: construct color in a more portable way: */ \
21    
22     #ifdef FB_24
23     #ifdef FB_BO
24     #define macro_put_pixel1 color = (b << 16) + (g << 8) + r
25     #else
26     #define macro_put_pixel1 color = (r << 16) + (g << 8) + b
27     #endif
28    
29     #else /* !24 */
30     #ifdef FB_16
31     #ifdef FB_BO
32     #define macro_put_pixel1 color = ((b >> 3) << 11) + ((g >> 2) << 5) + (r >> 3)
33     #else
34     #define macro_put_pixel1 color = ((r >> 3) << 11) + ((g >> 2) << 5) + (b >> 3)
35     #endif
36    
37     #else /* !16 */
38     #ifdef FB_15
39     #ifdef FB_BO
40     #define macro_put_pixel1 color = ((b >> 3) << 10) + ((g >> 3) << 5) + (r >> 3)
41     #else
42     #define macro_put_pixel1 color = ((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)
43     #endif
44    
45     #else /* !15 */
46     #define macro_put_pixel1 color = d->fb_window->x11_graycolor[15 * \
47     (r + g + b) / (255 * 3)].pixel
48    
49     #endif /* !15 */
50    
51     #endif /* !16 */
52    
53     #endif /* !24 */
54    
55    
56     #ifdef macro_put_pixel
57     #undef macro_put_pixel
58     #endif
59    
60     #define macro_put_pixel macro_put_pixel1; \
61     if (x>=0 && x<d->x11_xsize && y>=0 && y<d->x11_ysize) \
62     XPutPixel(d->fb_window->fb_ximage, x, y, color); \
63    
64    
65     void REDRAW(struct vfb_data *d, int addr, int len)
66     {
67     int x, y, pixel, npixels;
68     long color_r, color_g, color_b;
69     long color;
70    
71     #ifndef FB_SCALEDOWN
72    
73     /* Which framebuffer pixel does addr correspond to? */
74     pixel = addr * 8 / d->bit_depth;
75     y = pixel / d->xsize;
76     x = pixel % d->xsize;
77    
78     /* How many framebuffer pixels? */
79     npixels = len * 8 / d->bit_depth;
80     if (npixels == 0)
81     npixels = 1;
82    
83     if (d->bit_depth < 8) {
84     for (pixel=0; pixel<npixels; pixel++) {
85     int fb_addr, c, r, g, b;
86     color_r = color_g = color_b = 0;
87    
88     fb_addr = (y * d->xsize + x) * d->bit_depth;
89     /* fb_addr is now which _bit_ in
90     the framebuffer */
91    
92     c = d->framebuffer[fb_addr >> 3];
93     fb_addr &= 7;
94    
95     /* HPC is reverse: */
96     if (d->vfb_type == VFB_HPC)
97     fb_addr = 8 - d->bit_depth - fb_addr;
98    
99     c = (c >> fb_addr) & ((1<<d->bit_depth) - 1);
100     /* c <<= (8 - d->bit_depth); */
101    
102     r = d->rgb_palette[c*3 + 0];
103     g = d->rgb_palette[c*3 + 1];
104     b = d->rgb_palette[c*3 + 2];
105    
106     macro_put_pixel;
107     x++;
108     }
109     } else if (d->bit_depth == 8) {
110     for (pixel=0; pixel<npixels; pixel++) {
111     int fb_addr, c, r, g, b;
112     color_r = color_g = color_b = 0;
113    
114     fb_addr = y * d->xsize + x;
115     /* fb_addr is now which byte in framebuffer */
116     c = d->framebuffer[fb_addr];
117     r = d->rgb_palette[c*3 + 0];
118     g = d->rgb_palette[c*3 + 1];
119     b = d->rgb_palette[c*3 + 2];
120    
121     macro_put_pixel;
122     x++;
123     }
124     } else { /* d->bit_depth > 8 */
125     for (pixel=0; pixel<npixels; pixel++) {
126     int fb_addr, r, g, b;
127     color_r = color_g = color_b = 0;
128    
129     fb_addr = (y * d->xsize + x) * d->bit_depth;
130     /* fb_addr is now which byte in framebuffer */
131    
132     /* > 8 bits color. */
133     fb_addr >>= 3;
134     switch (d->bit_depth) {
135     case 24:
136     r = d->framebuffer[fb_addr];
137     g = d->framebuffer[fb_addr + 1];
138     b = d->framebuffer[fb_addr + 2];
139     break;
140     /* TODO: copy to the scaledown code below */
141     case 16:
142     if (d->vfb_type == VFB_HPC) {
143     b = d->framebuffer[fb_addr] +
144     (d->framebuffer[fb_addr+1] << 8);
145    
146     if (d->color32k) {
147     r = b >> 11;
148     g = b >> 5;
149     r = r & 31;
150     g = (g & 31) * 2;
151     b = b & 31;
152     } else if (d->psp_15bit) {
153     int tmp;
154     r = (b >> 10) & 0x1f;
155     g = (b >> 5) & 0x1f;
156     b = b & 0x1f;
157     g <<= 1;
158     tmp = r; r = b; b = tmp;
159     } else {
160     r = (b >> 11) & 0x1f;
161     g = (b >> 5) & 0x3f;
162     b = b & 0x1f;
163     }
164     } else {
165     r = d->framebuffer[fb_addr] >> 3;
166     /* HUH? TODO: */
167     g = (d->framebuffer[fb_addr] << 5) +
168     (d->framebuffer[fb_addr + 1] >>5);
169     b = d->framebuffer[fb_addr + 1]&31;
170     }
171    
172     r *= 8;
173     g *= 4;
174     b *= 8;
175     break;
176     default:
177     r = g = b = random() & 255;
178     }
179    
180     macro_put_pixel;
181     x++;
182     }
183     }
184    
185     #else /* FB_SCALEDOWN */
186    
187     /* scaledown > 1: */
188     int scaledown = d->vfb_scaledown;
189     int scaledownXscaledown = scaledown * scaledown;
190    
191     /* Which framebuffer pixel does addr correspond to? */
192     pixel = addr * 8 / d->bit_depth;
193     y = pixel / d->xsize;
194     x = pixel % d->xsize;
195    
196     /* How many framebuffer pixels? */
197     npixels = len * 8 / d->bit_depth;
198    
199     /* Which x11 pixel? */
200     x /= scaledown;
201     y /= scaledown;
202    
203     /* How many x11 pixels: */
204     npixels /= scaledown;
205     if (npixels == 0)
206     npixels = 1;
207    
208     if (d->bit_depth < 8) {
209     for (pixel=0; pixel<npixels; pixel++) {
210     int subx, suby, r, g, b;
211     color_r = color_g = color_b = 0;
212     for (suby=0; suby<scaledown; suby++)
213     for (subx=0; subx<scaledown; subx++) {
214     int fb_x, fb_y, fb_addr, c;
215    
216     fb_x = x * scaledown + subx;
217     fb_y = y * scaledown + suby;
218     fb_addr = fb_y * d->xsize + fb_x;
219     fb_addr = fb_addr * d->bit_depth;
220     /* fb_addr is now which _bit_ in
221     the framebuffer */
222    
223     c = d->framebuffer[fb_addr >> 3];
224     fb_addr &= 7;
225    
226     /* HPC is reverse: */
227     if (d->vfb_type == VFB_HPC)
228     fb_addr = 8 - d->bit_depth - fb_addr;
229    
230     c = (c >> fb_addr) & ((1<<d->bit_depth) - 1);
231     /* c <<= (8 - d->bit_depth); */
232    
233     r = d->rgb_palette[c*3 + 0];
234     g = d->rgb_palette[c*3 + 1];
235     b = d->rgb_palette[c*3 + 2];
236    
237     color_r += r;
238     color_g += g;
239     color_b += b;
240     }
241    
242     r = color_r / scaledownXscaledown;
243     g = color_g / scaledownXscaledown;
244     b = color_b / scaledownXscaledown;
245     macro_put_pixel;
246     x++;
247     }
248     } else if (d->bit_depth == 8) {
249     for (pixel=0; pixel<npixels; pixel++) {
250     int subx, suby, r, g, b;
251     color_r = color_g = color_b = 0;
252     for (suby=0; suby<scaledown; suby++)
253     for (subx=0; subx<scaledown; subx++) {
254     int fb_x, fb_y, fb_addr, c;
255    
256     fb_x = x * scaledown + subx;
257     fb_y = y * scaledown + suby;
258     fb_addr = fb_y * d->xsize + fb_x;
259     /* fb_addr is which _byte_ in framebuffer */
260     c = d->framebuffer[fb_addr] * 3;
261     r = d->rgb_palette[c + 0];
262     g = d->rgb_palette[c + 1];
263     b = d->rgb_palette[c + 2];
264     color_r += r;
265     color_g += g;
266     color_b += b;
267     }
268    
269     r = color_r / scaledownXscaledown;
270     g = color_g / scaledownXscaledown;
271     b = color_b / scaledownXscaledown;
272     macro_put_pixel;
273     x++;
274     }
275     } else {
276     /* Generic > 8 bit bit-depth: */
277     for (pixel=0; pixel<npixels; pixel++) {
278     int subx, suby, r, g, b;
279     color_r = color_g = color_b = 0;
280     for (suby=0; suby<scaledown; suby++)
281     for (subx=0; subx<scaledown; subx++) {
282     int fb_x, fb_y, fb_addr;
283    
284     fb_x = x * scaledown + subx;
285     fb_y = y * scaledown + suby;
286     fb_addr = fb_y * d->xsize + fb_x;
287     fb_addr = (fb_addr * d->bit_depth) >> 3;
288     /* fb_addr is which _byte_ in framebuffer */
289    
290     /* > 8 bits color. */
291     switch (d->bit_depth) {
292     case 24:
293     r = d->framebuffer[fb_addr];
294     g = d->framebuffer[fb_addr + 1];
295     b = d->framebuffer[fb_addr + 2];
296     break;
297     default:
298     r = g = b = random() & 255;
299     }
300     color_r += r;
301     color_g += g;
302     color_b += b;
303     }
304     r = color_r / scaledownXscaledown;
305     g = color_g / scaledownXscaledown;
306     b = color_b / scaledownXscaledown;
307     macro_put_pixel;
308     x++;
309     }
310     }
311     #endif /* FB_SCALEDOWN */
312     }
313    

  ViewVC Help
Powered by ViewVC 1.1.26