87 lines
2.1 KiB
C
87 lines
2.1 KiB
C
/* K&R source for the M4 differential Xlib-image golden.
|
|
*
|
|
* It models the X11R4 32-bit XImage/Display/Screen layout and the ten-argument
|
|
* XCreateImage/XPutImage, five-argument XCreatePixmap and nine-argument
|
|
* XCreateSimpleWindow calls. The 1987 TI compiler packs struct members and
|
|
* its &-of-member is already a bit address, so the golden carries the ROM
|
|
* bit displacements directly: Display.screens 1152 (byte 0x90), Screen.root
|
|
* 64 (byte 0x8), and XImage data/byte_order/bytes_per_line/bits_per_pixel/f
|
|
* 128/160/320/352/512 (bytes 16/20/40/44/64).
|
|
*/
|
|
struct display {
|
|
char pad[0x90];
|
|
void *screens;
|
|
};
|
|
|
|
struct screen {
|
|
char pad[0x8];
|
|
unsigned int root;
|
|
};
|
|
|
|
struct ximage_funcs {
|
|
void *create_image;
|
|
void *destroy_image;
|
|
void *get_pixel;
|
|
void *put_pixel;
|
|
void *sub_image;
|
|
void *add_pixel;
|
|
};
|
|
|
|
struct ximage {
|
|
int width, height;
|
|
int xoffset;
|
|
int format;
|
|
char *data;
|
|
int byte_order;
|
|
int bitmap_unit;
|
|
int bitmap_bit_order;
|
|
int bitmap_pad;
|
|
int depth;
|
|
int bytes_per_line;
|
|
int bits_per_pixel;
|
|
unsigned long red_mask, green_mask, blue_mask;
|
|
void *obdata;
|
|
struct ximage_funcs f;
|
|
};
|
|
|
|
extern struct display *XOpenDisplay();
|
|
extern int XCreateSimpleWindow();
|
|
extern unsigned int XCreatePixmap();
|
|
extern struct ximage *XCreateImage();
|
|
extern int XPutImage();
|
|
extern int XMapWindow();
|
|
extern int XSync();
|
|
|
|
int image(d, w, gc, data)
|
|
struct display *d;
|
|
unsigned int w;
|
|
void *gc;
|
|
char *data;
|
|
{
|
|
struct ximage *img;
|
|
unsigned int root;
|
|
unsigned int pm;
|
|
|
|
root = ((struct screen *)d->screens)->root;
|
|
img = XCreateImage(d, 0, 1, 0, 0, data, 640, 480, 32, 80);
|
|
img->byte_order = 0;
|
|
img->bytes_per_line = 80;
|
|
img->bits_per_pixel = 1;
|
|
img->f.create_image = 0;
|
|
pm = XCreatePixmap(d, w, 640, 480, 1);
|
|
XPutImage(d, pm, gc, img, 0, 0, 0, 0, 640, 32);
|
|
img->data = data;
|
|
XMapWindow(d, w);
|
|
XSync(d, 0);
|
|
return root + pm;
|
|
}
|
|
|
|
int window(d)
|
|
struct display *d;
|
|
{
|
|
unsigned int root;
|
|
|
|
root = ((struct screen *)d->screens)->root;
|
|
return XCreateSimpleWindow(d, root, 20, 20, 640, 480, 0, 0, 0);
|
|
}
|