mirror of
https://git.k-space.ee/arti/vt1200.git
synced 2026-11-02 12:23:17 +02:00
The XIE path now runs end to end: XieCreateImage -> XieCreatePhoto ->
XiePutTile -> XieExport(photomap -> depth-1 pixmap) -> XCopyArea(pixmap ->
window), and the client's tile appears on screen at the client's own window
position, pixel-exact.
TWO FAULTS BEHIND THE LONG DEAD END
1. Device model (harness/mame/vt1200.cpp, opt-in VT1200_ACCEL=1). The
accelerator's output port 0x5600200 returns the pixel stream the firmware
pushed into the FIFO -- the firmware then stores it into the drawable itself
(file 0x125528: MOVE *B6,*B1 ; ADDK 0x10,B1). The FIFO read pointer was
never reset between transfers, so consecutive exports read stale words and
the same fill produced 759 then 516 set pixels. Reset m_fifo_in/out on the
data-register write; the export is now deterministic.
2. Measurement, not the device.
- dwt/screenshot.py without --real reads 1024x1024 at a 128-byte row stride,
but the VR319 default programs 1280x1024 at a 2048-bit (256-byte) pitch.
That is the "shifted" picture; --real is the correct read.
- The earlier "0 differing bytes over 128 KiB" VRAM comparison stepped peek
by 1024 *bit* addresses, so it scanned rows 0..63 only -- never the window
at rows 200..263. Over the real raster the white/black diff is 576 bytes
spanning exactly those rows.
- New instrument: decclient does a server-side XGetImage readback of the
pixmap and window and counts set pixels. That separated "the server never
drew it" from "the framebuffer view is wrong".
EVIDENCE (reproduced twice, the second time from a fresh machine)
no export vs 0xFF : 4096 / 4096 pixels differ
no export vs 0x00 : 0 / 4096 (the window background is black)
0xFF vs 0x00 : 4096 / 4096
0xAA vs 0x0F : 2048 / 4096 (the two stripe phases)
Tile byte 0xAA reproduces as 1-pixel vertical stripes, 0x0F as 4-pixel, with
no shear -- so the placement is right and the pixels are the client's.
Contents: xie/ holds DEC XIE 2.3 headers, 84 man pages and complete
client+server source; a libXie.a and decclient built from DEC's own code; the
XIE probes; and evidence/ with every measurement, including explicit
retractions of the earlier wrong readings (VRAM_IDENTICAL_FOR_BOTH_FILLS and
friends). xie/evidence/XIE_IMAGE_DISPLAYED.md is the report; frames are in
xie/evidence/png/.
The accelerator model stays opt-in: it answers the status poll and relays the
pixel stream, but performs no compositing, so it is a stand-in and the verified
default configuration is unchanged (a no-env run still parks in the level-0
diagnostics menu at PC=3FDCE400).
167 lines
5.8 KiB
C
167 lines
5.8 KiB
C
/*
|
|
* xshow - put a 1-bit test pattern on a display and verify it landed.
|
|
*
|
|
* This is the display half, not XIE: it uses core X11 PutImage. It exists so
|
|
* the VT1200 can be shown an image from this tree while the XIE 2.3
|
|
* create/photoflo/export path is still being recovered. The window title says
|
|
* "core X", and the program prints that it is the fallback.
|
|
*
|
|
* Build: gcc -O2 -o xshow xshow.c -lX11
|
|
* Run: ./xshow -display 192.168.99.2:0 -width 640 -height 480 -seconds 30
|
|
*/
|
|
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
static int bpl_for(int w) { return ((w + 31) / 32) * 4; }
|
|
|
|
static void set_pixel(unsigned char *data, int bpl, int x, int y, int on)
|
|
{
|
|
unsigned char *p = data + y * bpl + (x >> 3);
|
|
unsigned char bit = 1u << (x & 7); /* LSBFirst */
|
|
if (on)
|
|
*p |= bit;
|
|
else
|
|
*p &= (unsigned char)~bit;
|
|
}
|
|
|
|
static void pattern(unsigned char *data, int w, int h, int bpl, const char *kind)
|
|
{
|
|
int x, y;
|
|
memset(data, 0, (size_t)bpl * h);
|
|
if (strcmp(kind, "solid") == 0) {
|
|
for (y = 0; y < h; y++)
|
|
for (x = 0; x < w; x++)
|
|
set_pixel(data, bpl, x, y, 1);
|
|
} else if (strcmp(kind, "gradient") == 0) {
|
|
for (y = 0; y < h; y++)
|
|
for (x = 0; x < w; x++)
|
|
set_pixel(data, bpl, x, y, ((x * 16 / w) ^ (y * 16 / h)) & 1);
|
|
} else if (strcmp(kind, "rings") == 0) {
|
|
int cx = w / 2, cy = h / 2;
|
|
for (y = 0; y < h; y++)
|
|
for (x = 0; x < w; x++) {
|
|
int dx = x - cx, dy = y - cy;
|
|
int d = (dx * dx + dy * dy) / 64;
|
|
set_pixel(data, bpl, x, y, (d / 16) & 1);
|
|
}
|
|
} else { /* checker */
|
|
int cell = w / 16;
|
|
if (cell < 4) cell = 4;
|
|
for (y = 0; y < h; y++)
|
|
for (x = 0; x < w; x++)
|
|
set_pixel(data, bpl, x, y, ((x / cell) + (y / cell)) & 1);
|
|
}
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
const char *display = "192.168.99.2:0";
|
|
const char *kind = "checker";
|
|
int w = 640, h = 480, seconds = 30;
|
|
int i;
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
if (!strcmp(argv[i], "-display") && i + 1 < argc) display = argv[++i];
|
|
else if (!strcmp(argv[i], "-width") && i + 1 < argc) w = atoi(argv[++i]);
|
|
else if (!strcmp(argv[i], "-height") && i + 1 < argc) h = atoi(argv[++i]);
|
|
else if (!strcmp(argv[i], "-seconds") && i + 1 < argc) seconds = atoi(argv[++i]);
|
|
else if (!strcmp(argv[i], "-pattern") && i + 1 < argc) kind = argv[++i];
|
|
else {
|
|
fprintf(stderr, "usage: %s [-display host:0] [-width N] [-height N] "
|
|
"[-seconds N] [-pattern checker|gradient|rings|solid]\n", argv[0]);
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
Display *dpy = XOpenDisplay(display);
|
|
if (!dpy) {
|
|
fprintf(stderr, "xshow: cannot open %s\n", display);
|
|
return 1;
|
|
}
|
|
|
|
int scr = DefaultScreen(dpy);
|
|
Visual *vis = DefaultVisual(dpy, scr);
|
|
int depth = DefaultDepth(dpy, scr);
|
|
if (depth != 1)
|
|
fprintf(stderr, "xshow: warning: depth is %d, expected 1\n", depth);
|
|
|
|
int bpl = bpl_for(w);
|
|
unsigned char *data = calloc((size_t)bpl, (size_t)h);
|
|
if (!data) return 1;
|
|
pattern(data, w, h, bpl, kind);
|
|
|
|
Window win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 20, 20,
|
|
(unsigned)w, (unsigned)h, 0,
|
|
BlackPixel(dpy, scr), WhitePixel(dpy, scr));
|
|
XStoreName(dpy, win, "xshow: core X fallback (not XIE)");
|
|
XSelectInput(dpy, win, ExposureMask | KeyPressMask | ButtonPressMask |
|
|
StructureNotifyMask);
|
|
GC gc = XCreateGC(dpy, win, 0, NULL);
|
|
XSetForeground(dpy, gc, BlackPixel(dpy, scr));
|
|
XSetBackground(dpy, gc, WhitePixel(dpy, scr));
|
|
|
|
XImage *img = XCreateImage(dpy, vis, (unsigned)depth, XYBitmap, 0,
|
|
(char *)data, (unsigned)w, (unsigned)h, 32, bpl);
|
|
if (!img) {
|
|
fprintf(stderr, "xshow: XCreateImage failed\n");
|
|
return 1;
|
|
}
|
|
img->byte_order = LSBFirst;
|
|
img->bitmap_bit_order = LSBFirst;
|
|
|
|
XMapWindow(dpy, win);
|
|
XPutImage(dpy, win, gc, img, 0, 0, 0, 0, (unsigned)w, (unsigned)h);
|
|
XSync(dpy, False);
|
|
|
|
/* Verify by reading the window back. A 1-bit XGetImage returns one
|
|
* bit per pixel in the server's bit order; compare the on-pixel count
|
|
* against the source rather than raw bytes. */
|
|
XImage *got = XGetImage(dpy, win, 0, 0, (unsigned)w, (unsigned)h,
|
|
AllPlanes, ZPixmap);
|
|
long src_on = 0, got_on = 0;
|
|
int x, y;
|
|
for (y = 0; y < h; y++)
|
|
for (x = 0; x < w; x++) {
|
|
unsigned char *p = data + y * bpl + (x >> 3);
|
|
if (p[0] & (1u << (x & 7))) src_on++;
|
|
if (got && XGetPixel(got, x, y)) got_on++;
|
|
}
|
|
|
|
if (!got) {
|
|
printf("xshow: displayed %dx%d %s on %s, but XGetImage failed\n",
|
|
w, h, kind, display);
|
|
} else {
|
|
printf("xshow: displayed %dx%d %s on %s; source on-pixels=%ld "
|
|
"window on-pixels=%ld %s\n", w, h, kind, display, src_on, got_on,
|
|
(src_on == got_on) ? "MATCH" : "MISMATCH");
|
|
XDestroyImage(got);
|
|
}
|
|
printf("xshow: core X fallback window; XIE 2.3 export path is separate\n");
|
|
fflush(stdout);
|
|
|
|
time_t end = time(NULL) + seconds;
|
|
while (time(NULL) < end) {
|
|
while (XPending(dpy)) {
|
|
XEvent ev;
|
|
XNextEvent(dpy, &ev);
|
|
if (ev.type == KeyPress || ev.type == ButtonPress) {
|
|
end = 0;
|
|
break;
|
|
}
|
|
}
|
|
usleep(100000);
|
|
}
|
|
|
|
XDestroyImage(img); /* also frees data */
|
|
XFreeGC(dpy, gc);
|
|
XDestroyWindow(dpy, win);
|
|
XCloseDisplay(dpy);
|
|
return 0;
|
|
}
|