Files
vt1200/xie/decclient.c
T
arti d8d54bb990 feat(xie): a client-chosen XIE image is displayed on the VT1200
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).
2026-11-01 23:22:25 +02:00

174 lines
6.8 KiB
C

/*
* DEC XIE 2.3 client built against DEC's own libXie sources.
*
* XieCreateImage -> XieCreatePhoto -> XiePutTile -> XieExport
*
* Usage: decclient <display> <fill-hex>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/XieLib.h>
/* the client never calls the DDX dispatch table; satisfy the linker */
unsigned long (*xieDdxProc[1])() = { 0 };
/* Read a drawable back from the SERVER (not from the framebuffer) and report
* how many pixels are set. This is server-side truth: if the tile is there,
* the server drew it and the remaining problem is only the framebuffer mapping;
* if it is zero, the export produced nothing at all. */
static void readback(Display *dpy, Drawable d, int w, int h, const char *label)
{
XImage *im;
int x, y, ones = 0, total = 0;
im = XGetImage(dpy, d, 0, 0, w, h, AllPlanes, ZPixmap);
if (!im) { printf(" %s: XGetImage FAILED\n", label); fflush(stdout); return; }
for (y = 0; y < h; y++)
for (x = 0; x < w; x++) {
total++;
if (XGetPixel(im, x, y) != 0) ones++;
}
printf(" %s: %d/%d pixels set (first row bits: ", label, ones, total);
for (x = 0; x < 8 && x < w; x++) printf("%ld", XGetPixel(im, x, 0) ? 1L : 0L);
printf(")\n"); fflush(stdout);
XDestroyImage(im);
}
int main(int argc, char **argv)
{
Display *dpy;
Window win;
GC gc;
XSetWindowAttributes swa;
XieImage img;
XiePhotomap pm;
unsigned long lvl[3];
unsigned int fill;
int w = 64, h = 64, nbytes, org;
if (argc < 3) {
fprintf(stderr, "usage: %s <display> <fill-hex>\n", argv[0]);
return 2;
}
fill = (unsigned int) strtoul(argv[2], NULL, 16);
org = argc > 3 ? atoi(argv[3]) : XieK_BandByPlane;
dpy = XOpenDisplay(argv[1]);
if (!dpy) { fprintf(stderr, "cannot open %s\n", argv[1]); return 1; }
printf("display %s opened (root depth %d)\n", argv[1],
DefaultDepth(dpy, DefaultScreen(dpy)));
lvl[0] = lvl[1] = lvl[2] = 2;
img = XieCreateImage((unsigned long) w, (unsigned long) h,
XieK_PCM, (unsigned char) org, XieK_Bitonal, 1, lvl,
XieK_PP0, XieK_LP270);
if (!img) { fprintf(stderr, "XieCreateImage failed\n"); return 1; }
printf("image: org=%d w=%lu h=%lu levels=%lu,%lu,%lu arSize=%d\n", org,
Width_(img), Height_(img), CmpLvl_(img,0), CmpLvl_(img,1),
CmpLvl_(img,2), (int) uArSize_(img, 0));
if (!uBase_(img, 0)) {
nbytes = (int) uArSize_(img, 0);
if (nbytes <= 0) nbytes = (w + 7) / 8 * h;
uBase_(img, 0) = (unsigned char *) calloc(1, nbytes);
uArSize_(img, 0) = nbytes;
OwnData_(img) = 1;
}
nbytes = (int) uArSize_(img, 0);
printf("filling %d bytes with %02X\n", nbytes, fill);
memset(uBase_(img, 0), fill, nbytes);
pm = XieCreatePhoto(dpy, XieK_Photomap, (unsigned long) w, (unsigned long) h,
XieK_Bitonal, 1, lvl, XieK_ZeroDark, 1.0,
XieK_BandByPlane, XieK_BandByPlane);
if (!pm) { fprintf(stderr, "XieCreatePhoto failed\n"); return 1; }
printf("photomap created\n");
XSync(dpy, False);
XiePutTile(pm, img, XieK_AllPlanes, 0, 0, 0, 0,
(unsigned long) w, (unsigned long) h);
XSync(dpy, False);
printf("put tile sent\n");
fflush(stdout);
swa.background_pixel = 0;
swa.event_mask = ExposureMask;
win = XCreateWindow(dpy, DefaultRootWindow(dpy), 150, 200, w, h, 0,
CopyFromParent, InputOutput, CopyFromParent,
CWBackPixel | CWEventMask, &swa);
XMapWindow(dpy, win);
XSync(dpy, False);
gc = XCreateGC(dpy, win, 0, NULL);
XSync(dpy, False);
if (argc > 4 && atoi(argv[4]) == 9) {
/* control run: window mapped, NO export at all */
printf("NO EXPORT (baseline)\n"); fflush(stdout);
readback(dpy, win, w, h, "window (no export)");
} else if (argc > 4 && atoi(argv[4]) == 2) {
/* DEC's IDS pattern: crop element on the photomap, tap it, export the tap
* into a pixmap (ids_build_xie_pipe.c: XieTapFlo(XieCrop(Photo_,0),True)) */
/* The photoflo must exist and the photomap be bound to it before the
* element chain can be built (crash without it: XieTapFlo derefs a
* flo link that XieCrop never set). */
XiePhoto flo = XieCreatePhoto(dpy, XieK_Photoflo, (unsigned long) w,
(unsigned long) h, XieK_Bitonal, 1, lvl,
XieK_ZeroDark, 1.0,
XieK_BandByPlane, XieK_BandByPlane);
printf("photoflo=%lx\n", (unsigned long) flo); fflush(stdout);
XieBindMapToFlo(flo, pm);
XSync(dpy, False);
printf("bound map to flo\n"); fflush(stdout);
XiePhoto crop = XieCrop(flo, 0);
printf("crop=%lx\n", (unsigned long) crop); fflush(stdout);
XiePhoto tap = XieTapFlo(crop, 1);
printf("tap=%lx\n", (unsigned long) tap); fflush(stdout);
Pixmap px = XCreatePixmap(dpy, win, w, h, 1);
GC pgc = XCreateGC(dpy, px, 0, NULL);
XSync(dpy, False);
printf("crop=%lx tap=%lx\n", (unsigned long) crop, (unsigned long) tap); fflush(stdout);
XieExport(tap, px, pgc, 0, 0, 0, 0, w, h, 0, 0, 0.0, 0.0);
XSync(dpy, False);
printf("export sent (tap->pixmap)\n"); fflush(stdout);
XCopyArea(dpy, px, win, gc, 0, 0, w, h, 0, 0);
XSync(dpy, False);
printf("copyarea sent\n"); fflush(stdout);
} else if (argc > 4 && atoi(argv[4]) == 1) {
Pixmap pmap = XCreatePixmap(dpy, win, w, h, 1);
XSync(dpy, False);
printf("exporting to PIXMAP depth 1\n"); fflush(stdout);
/* Clear the pixmap to a known value so the readback is unambiguous. */
XSetForeground(dpy, gc, 0L);
XFillRectangle(dpy, pmap, gc, 0, 0, w, h);
XSync(dpy, False);
readback(dpy, pmap, w, h, "pixmap after clear(=0)");
XieExport(pm, pmap, gc, 0, 0, 0, 0, w, h, 0,
DefaultColormap(dpy, DefaultScreen(dpy)), 0.0, 0.0);
XSync(dpy, False);
printf("export sent (pixmap)\n"); fflush(stdout);
readback(dpy, pmap, w, h, "pixmap after export");
readback(dpy, win, w, h, "window before copy");
XCopyArea(dpy, pmap, win, gc, 0, 0, w, h, 0, 0);
XSync(dpy, False);
printf("copyarea sent\n"); fflush(stdout);
readback(dpy, win, w, h, "window after copy");
} else {
XieExport(pm, win, gc, 0, 0, 0, 0, w, h, 0,
DefaultColormap(dpy, DefaultScreen(dpy)), 0.0, 0.0);
XSync(dpy, False);
printf("export sent (with colormap)\n");
readback(dpy, win, w, h, "window after direct export");
}
fflush(stdout);
sleep(6);
XCloseDisplay(dpy);
return 0;
}