summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.acid1533
-rw-r--r--main.c46
2 files changed, 23 insertions, 1556 deletions
diff --git a/main.acid b/main.acid
deleted file mode 100644
index 1a55a8a..0000000
--- a/main.acid
+++ /dev/null
@@ -1,1533 +0,0 @@
-sizeof_1_ = 8;
-aggr _1_
-{
- 'U' 0 lo;
- 'U' 4 hi;
-};
-
-defn
-_1_(addr) {
- complex _1_ addr;
- print(" lo ", addr.lo, "\n");
- print(" hi ", addr.hi, "\n");
-};
-
-sizeofFPdbleword = 8;
-aggr FPdbleword
-{
- 'F' 0 x;
- {
- 'U' 0 lo;
- 'U' 4 hi;
- };
-};
-
-defn
-FPdbleword(addr) {
- complex FPdbleword addr;
- print(" x ", addr.x, "\n");
- print("_1_ {\n");
- _1_(addr+0);
- print("}\n");
-};
-
-UTFmax = 4;
-Runesync = 128;
-Runeself = 128;
-Runeerror = 65533;
-Runemax = 1114111;
-Runemask = 2097151;
-sizeofFmt = 80;
-aggr Fmt
-{
- 'b' 0 runes;
- 'Y' 8 start;
- 'Y' 16 to;
- 'Y' 24 stop;
- 'Y' 32 flush;
- 'Y' 40 farg;
- 'D' 48 nfmt;
- 'Y' 56 args;
- 'D' 64 r;
- 'D' 68 width;
- 'D' 72 prec;
- 'U' 76 flags;
-};
-
-defn
-Fmt(addr) {
- complex Fmt addr;
- print(" runes ", addr.runes, "\n");
- print(" start ", addr.start\Y, "\n");
- print(" to ", addr.to\Y, "\n");
- print(" stop ", addr.stop\Y, "\n");
- print(" flush ", addr.flush\Y, "\n");
- print(" farg ", addr.farg\Y, "\n");
- print(" nfmt ", addr.nfmt, "\n");
- print(" args ", addr.args\Y, "\n");
- print(" r ", addr.r, "\n");
- print(" width ", addr.width, "\n");
- print(" prec ", addr.prec, "\n");
- print(" flags ", addr.flags, "\n");
-};
-
-FmtWidth = 1;
-FmtLeft = 2;
-FmtPrec = 4;
-FmtSharp = 8;
-FmtSpace = 16;
-FmtSign = 32;
-FmtZero = 64;
-FmtUnsigned = 128;
-FmtShort = 256;
-FmtLong = 512;
-FmtVLong = 1024;
-FmtComma = 2048;
-FmtByte = 4096;
-FmtFlag = 8192;
-sizeofTm = 40;
-aggr Tm
-{
- 'D' 0 sec;
- 'D' 4 min;
- 'D' 8 hour;
- 'D' 12 mday;
- 'D' 16 mon;
- 'D' 20 year;
- 'D' 24 wday;
- 'D' 28 yday;
- 'a' 32 zone;
- 'D' 36 tzoff;
-};
-
-defn
-Tm(addr) {
- complex Tm addr;
- print(" sec ", addr.sec, "\n");
- print(" min ", addr.min, "\n");
- print(" hour ", addr.hour, "\n");
- print(" mday ", addr.mday, "\n");
- print(" mon ", addr.mon, "\n");
- print(" year ", addr.year, "\n");
- print(" wday ", addr.wday, "\n");
- print(" yday ", addr.yday, "\n");
- print(" zone ", addr.zone, "\n");
- print(" tzoff ", addr.tzoff, "\n");
-};
-
-PNPROC = 1;
-PNGROUP = 2;
-Profoff = 0;
-Profuser = 1;
-Profkernel = 2;
-Proftime = 3;
-Profsample = 4;
-sizeofLock = 8;
-aggr Lock
-{
- 'D' 0 val;
-};
-
-defn
-Lock(addr) {
- complex Lock addr;
- print(" val ", addr.val, "\n");
-};
-
-sizeofQLp = 16;
-aggr QLp
-{
- 'D' 0 inuse;
- 'D' 4 state;
- 'A' QLp 8 next;
-};
-
-defn
-QLp(addr) {
- complex QLp addr;
- print(" inuse ", addr.inuse, "\n");
- print(" state ", addr.state, "\n");
- print(" next ", addr.next\Y, "\n");
-};
-
-sizeofQLock = 32;
-aggr QLock
-{
- Lock 0 lock;
- 'D' 8 locked;
- 'A' QLp 16 $head;
- 'A' QLp 24 $tail;
-};
-
-defn
-QLock(addr) {
- complex QLock addr;
- print("Lock lock {\n");
- Lock(addr.lock);
- print("}\n");
- print(" locked ", addr.locked, "\n");
- print(" $head ", addr.$head\Y, "\n");
- print(" $tail ", addr.$tail\Y, "\n");
-};
-
-sizeofRWLock = 32;
-aggr RWLock
-{
- Lock 0 lock;
- 'D' 8 readers;
- 'D' 12 writer;
- 'A' QLp 16 $head;
- 'A' QLp 24 $tail;
-};
-
-defn
-RWLock(addr) {
- complex RWLock addr;
- print("Lock lock {\n");
- Lock(addr.lock);
- print("}\n");
- print(" readers ", addr.readers, "\n");
- print(" writer ", addr.writer, "\n");
- print(" $head ", addr.$head\Y, "\n");
- print(" $tail ", addr.$tail\Y, "\n");
-};
-
-sizeofRendez = 24;
-aggr Rendez
-{
- 'A' QLock 0 l;
- 'A' QLp 8 $head;
- 'A' QLp 16 $tail;
-};
-
-defn
-Rendez(addr) {
- complex Rendez addr;
- print(" l ", addr.l\Y, "\n");
- print(" $head ", addr.$head\Y, "\n");
- print(" $tail ", addr.$tail\Y, "\n");
-};
-
-sizeofNetConnInfo = 72;
-aggr NetConnInfo
-{
- 'Y' 0 dir;
- 'Y' 8 root;
- 'Y' 16 spec;
- 'Y' 24 lsys;
- 'Y' 32 lserv;
- 'Y' 40 rsys;
- 'Y' 48 rserv;
- 'Y' 56 laddr;
- 'Y' 64 raddr;
-};
-
-defn
-NetConnInfo(addr) {
- complex NetConnInfo addr;
- print(" dir ", addr.dir\Y, "\n");
- print(" root ", addr.root\Y, "\n");
- print(" spec ", addr.spec\Y, "\n");
- print(" lsys ", addr.lsys\Y, "\n");
- print(" lserv ", addr.lserv\Y, "\n");
- print(" rsys ", addr.rsys\Y, "\n");
- print(" rserv ", addr.rserv\Y, "\n");
- print(" laddr ", addr.laddr\Y, "\n");
- print(" raddr ", addr.raddr\Y, "\n");
-};
-
-RFNAMEG = 1;
-RFENVG = 2;
-RFFDG = 4;
-RFNOTEG = 8;
-RFPROC = 16;
-RFMEM = 32;
-RFNOWAIT = 64;
-RFCNAMEG = 1024;
-RFCENVG = 2048;
-RFCFDG = 4096;
-RFREND = 8192;
-RFNOMNT = 16384;
-sizeofQid = 16;
-aggr Qid
-{
- 'W' 0 path;
- 'U' 8 vers;
- 'b' 12 type;
-};
-
-defn
-Qid(addr) {
- complex Qid addr;
- print(" path ", addr.path, "\n");
- print(" vers ", addr.vers, "\n");
- print(" type ", addr.type, "\n");
-};
-
-sizeofDir = 80;
-aggr Dir
-{
- 'u' 0 type;
- 'U' 4 dev;
- Qid 8 qid;
- 'U' 24 mode;
- 'U' 28 atime;
- 'U' 32 mtime;
- 'V' 40 length;
- 'Y' 48 name;
- 'Y' 56 uid;
- 'Y' 64 gid;
- 'Y' 72 muid;
-};
-
-defn
-Dir(addr) {
- complex Dir addr;
- print(" type ", addr.type, "\n");
- print(" dev ", addr.dev, "\n");
- print("Qid qid {\n");
- Qid(addr.qid);
- print("}\n");
- print(" mode ", addr.mode, "\n");
- print(" atime ", addr.atime, "\n");
- print(" mtime ", addr.mtime, "\n");
- print(" length ", addr.length, "\n");
- print(" name ", addr.name\Y, "\n");
- print(" uid ", addr.uid\Y, "\n");
- print(" gid ", addr.gid\Y, "\n");
- print(" muid ", addr.muid\Y, "\n");
-};
-
-sizeofWaitmsg = 24;
-aggr Waitmsg
-{
- 'D' 0 pid;
- 'a' 4 time;
- 'Y' 16 msg;
-};
-
-defn
-Waitmsg(addr) {
- complex Waitmsg addr;
- print(" pid ", addr.pid, "\n");
- print(" time ", addr.time, "\n");
- print(" msg ", addr.msg\Y, "\n");
-};
-
-sizeofIOchunk = 16;
-aggr IOchunk
-{
- 'Y' 0 addr;
- 'U' 8 len;
-};
-
-defn
-IOchunk(addr) {
- complex IOchunk addr;
- print(" addr ", addr.addr\Y, "\n");
- print(" len ", addr.len, "\n");
-};
-
-Nqwds = 2;
-Nqshift = 5;
-Nqmask = -1;
-Nqbits = 64;
-sizeofChannel = 48;
-aggr Channel
-{
- 'D' 0 s;
- 'U' 4 f;
- 'U' 8 n;
- 'D' 12 e;
- 'D' 16 freed;
- 'Y' 24 qentry;
- 'D' 32 nentry;
- 'D' 36 closed;
- 'a' 40 v;
-};
-
-defn
-Channel(addr) {
- complex Channel addr;
- print(" s ", addr.s, "\n");
- print(" f ", addr.f, "\n");
- print(" n ", addr.n, "\n");
- print(" e ", addr.e, "\n");
- print(" freed ", addr.freed, "\n");
- print(" qentry ", addr.qentry\Y, "\n");
- print(" nentry ", addr.nentry, "\n");
- print(" closed ", addr.closed, "\n");
- print(" v ", addr.v, "\n");
-};
-
-CHANEND = 0;
-CHANSND = 1;
-CHANRCV = 2;
-CHANNOP = 3;
-CHANNOBLK = 4;
-sizeofAlt = 48;
-aggr Alt
-{
- 'A' Channel 0 c;
- 'Y' 8 v;
- 'D' 16 op;
- 'Y' 24 err;
- 'A' Channel 32 tag;
- 'D' 40 entryno;
-};
-
-defn
-Alt(addr) {
- complex Alt addr;
- print(" c ", addr.c\Y, "\n");
- print(" v ", addr.v\Y, "\n");
- print(" op ", addr.op, "\n");
- print(" err ", addr.err\Y, "\n");
- print(" tag ", addr.tag\Y, "\n");
- print(" entryno ", addr.entryno, "\n");
-};
-
-sizeofRef = 8;
-aggr Ref
-{
- 'D' 0 ref;
-};
-
-defn
-Ref(addr) {
- complex Ref addr;
- print(" ref ", addr.ref, "\n");
-};
-
-DOpaque = 4294967295;
-DTransparent = 0;
-DBlack = 255;
-DWhite = 4294967295;
-DRed = 4278190335;
-DGreen = 16711935;
-DBlue = 65535;
-DCyan = 16777215;
-DMagenta = 4278255615;
-DYellow = 4294902015;
-DPaleyellow = 4294945535;
-DDarkyellow = 4008615679;
-DDarkgreen = 1149781247;
-DPalegreen = 2868882175;
-DMedgreen = 2295105791;
-DDarkblue = 22015;
-DPalebluegreen = 2868903935;
-DPaleblue = 48127;
-DBluegreen = 8947967;
-DGreygreen = 1437248255;
-DPalegreygreen = 2666458879;
-DYellowgreen = 2576960767;
-DMedblue = 39423;
-DGreyblue = 6142975;
-DPalegreyblue = 1234427391;
-DPurpleblue = 2290666751;
-DNotacolor = 4294967040;
-DNofill = 4294967040;
-Displaybufsize = 8000;
-ICOSSCALE = 1024;
-Borderwidth = 4;
-Refbackup = 0;
-Refnone = 1;
-Refmesg = 2;
-Endsquare = 0;
-Enddisc = 1;
-Endarrow = 2;
-Endmask = 31;
-Clear = 0;
-SinD = 8;
-DinS = 4;
-SoutD = 2;
-DoutS = 1;
-S = 10;
-SoverD = 11;
-SatopD = 9;
-SxorD = 3;
-D = 5;
-DoverS = 7;
-DatopS = 6;
-DxorS = 3;
-Ncomp = 12;
-CRed = 0;
-CGreen = 1;
-CBlue = 2;
-CGrey = 3;
-CAlpha = 4;
-CMap = 5;
-CIgnore = 6;
-NChan = 7;
-GREY1 = 49;
-GREY2 = 50;
-GREY4 = 52;
-GREY8 = 56;
-CMAP8 = 88;
-RGB15 = 1627723045;
-RGB16 = 333349;
-RGB24 = 530472;
-RGBA32 = 135800904;
-ARGB32 = 1208490024;
-XRGB32 = 1745360936;
-BGR24 = 2627592;
-ABGR32 = 1210587144;
-XBGR32 = 1747458056;
-sizeofPoint = 8;
-aggr Point
-{
- 'D' 0 x;
- 'D' 4 y;
-};
-
-defn
-Point(addr) {
- complex Point addr;
- print(" x ", addr.x, "\n");
- print(" y ", addr.y, "\n");
-};
-
-sizeofRectangle = 16;
-aggr Rectangle
-{
- Point 0 min;
- Point 8 max;
-};
-
-defn
-Rectangle(addr) {
- complex Rectangle addr;
- print("Point min {\n");
- Point(addr.min);
- print("}\n");
- print("Point max {\n");
- Point(addr.max);
- print("}\n");
-};
-
-sizeofScreen = 32;
-aggr Screen
-{
- 'Y' 0 display;
- 'D' 8 id;
- 'Y' 16 image;
- 'Y' 24 fill;
-};
-
-defn
-Screen(addr) {
- complex Screen addr;
- print(" display ", addr.display\Y, "\n");
- print(" id ", addr.id, "\n");
- print(" image ", addr.image\Y, "\n");
- print(" fill ", addr.fill\Y, "\n");
-};
-
-sizeofDisplay = 264;
-aggr Display
-{
- QLock 0 qlock;
- 'D' 32 locking;
- 'D' 36 dirno;
- 'D' 40 fd;
- 'D' 44 reffd;
- 'D' 48 ctlfd;
- 'D' 52 imageid;
- 'D' 56 $local;
- 'Y' 64 error;
- 'Y' 72 devdir;
- 'Y' 80 windir;
- 'a' 88 oldlabel;
- 'U' 152 dataqid;
- 'Y' 160 white;
- 'Y' 168 black;
- 'Y' 176 opaque;
- 'Y' 184 transparent;
- 'Y' 192 image;
- 'Y' 200 buf;
- 'D' 208 bufsize;
- 'Y' 216 bufp;
- 'Y' 224 defaultfont;
- 'Y' 232 defaultsubfont;
- 'Y' 240 windows;
- 'Y' 248 screenimage;
- 'D' 256 _isnewdisplay;
-};
-
-defn
-Display(addr) {
- complex Display addr;
- print("QLock qlock {\n");
- QLock(addr.qlock);
- print("}\n");
- print(" locking ", addr.locking, "\n");
- print(" dirno ", addr.dirno, "\n");
- print(" fd ", addr.fd, "\n");
- print(" reffd ", addr.reffd, "\n");
- print(" ctlfd ", addr.ctlfd, "\n");
- print(" imageid ", addr.imageid, "\n");
- print(" $local ", addr.$local, "\n");
- print(" error ", addr.error\Y, "\n");
- print(" devdir ", addr.devdir\Y, "\n");
- print(" windir ", addr.windir\Y, "\n");
- print(" oldlabel ", addr.oldlabel, "\n");
- print(" dataqid ", addr.dataqid, "\n");
- print(" white ", addr.white\Y, "\n");
- print(" black ", addr.black\Y, "\n");
- print(" opaque ", addr.opaque\Y, "\n");
- print(" transparent ", addr.transparent\Y, "\n");
- print(" image ", addr.image\Y, "\n");
- print(" buf ", addr.buf\Y, "\n");
- print(" bufsize ", addr.bufsize, "\n");
- print(" bufp ", addr.bufp\Y, "\n");
- print(" defaultfont ", addr.defaultfont\Y, "\n");
- print(" defaultsubfont ", addr.defaultsubfont\Y, "\n");
- print(" windows ", addr.windows\Y, "\n");
- print(" screenimage ", addr.screenimage\Y, "\n");
- print(" _isnewdisplay ", addr._isnewdisplay, "\n");
-};
-
-sizeofImage = 80;
-aggr Image
-{
- 'A' Display 0 display;
- 'D' 8 id;
- Rectangle 16 r;
- Rectangle 32 clipr;
- 'D' 48 depth;
- 'U' 52 chan;
- 'D' 56 repl;
- 'A' Screen 64 screen;
- 'A' Image 72 next;
-};
-
-defn
-Image(addr) {
- complex Image addr;
- print(" display ", addr.display\Y, "\n");
- print(" id ", addr.id, "\n");
- print("Rectangle r {\n");
- Rectangle(addr.r);
- print("}\n");
- print("Rectangle clipr {\n");
- Rectangle(addr.clipr);
- print("}\n");
- print(" depth ", addr.depth, "\n");
- print(" chan ", addr.chan, "\n");
- print(" repl ", addr.repl, "\n");
- print(" screen ", addr.screen\Y, "\n");
- print(" next ", addr.next\Y, "\n");
-};
-
-sizeofRGB = 16;
-aggr RGB
-{
- 'U' 0 red;
- 'U' 4 green;
- 'U' 8 blue;
-};
-
-defn
-RGB(addr) {
- complex RGB addr;
- print(" red ", addr.red, "\n");
- print(" green ", addr.green, "\n");
- print(" blue ", addr.blue, "\n");
-};
-
-sizeofFontchar = 8;
-aggr Fontchar
-{
- 'D' 0 x;
- 'b' 4 top;
- 'b' 5 bottom;
- 'C' 6 left;
- 'b' 7 width;
-};
-
-defn
-Fontchar(addr) {
- complex Fontchar addr;
- print(" x ", addr.x, "\n");
- print(" top ", addr.top, "\n");
- print(" bottom ", addr.bottom, "\n");
- print(" left ", addr.left, "\n");
- print(" width ", addr.width, "\n");
-};
-
-sizeofSubfont = 40;
-aggr Subfont
-{
- 'Y' 0 name;
- 'd' 8 n;
- 'b' 10 height;
- 'C' 11 ascent;
- 'A' Fontchar 16 info;
- 'A' Image 24 bits;
- 'D' 32 ref;
-};
-
-defn
-Subfont(addr) {
- complex Subfont addr;
- print(" name ", addr.name\Y, "\n");
- print(" n ", addr.n, "\n");
- print(" height ", addr.height, "\n");
- print(" ascent ", addr.ascent, "\n");
- print(" info ", addr.info\Y, "\n");
- print(" bits ", addr.bits\Y, "\n");
- print(" ref ", addr.ref, "\n");
-};
-
-LOG2NFCACHE = 6;
-NFCACHE = 64;
-NFLOOK = 5;
-NFSUBF = 2;
-MAXFCACHE = 1029;
-MAXSUBF = 50;
-DSUBF = 4;
-SUBFAGE = 10000;
-CACHEAGE = 10000;
-sizeofCachefont = 32;
-aggr Cachefont
-{
- 'U' 0 min;
- 'U' 4 max;
- 'D' 8 offset;
- 'Y' 16 name;
- 'Y' 24 subfontname;
-};
-
-defn
-Cachefont(addr) {
- complex Cachefont addr;
- print(" min ", addr.min, "\n");
- print(" max ", addr.max, "\n");
- print(" offset ", addr.offset, "\n");
- print(" name ", addr.name\Y, "\n");
- print(" subfontname ", addr.subfontname\Y, "\n");
-};
-
-sizeofCacheinfo = 16;
-aggr Cacheinfo
-{
- 'u' 0 x;
- 'b' 2 width;
- 'C' 3 left;
- 'U' 4 value;
- 'u' 8 age;
-};
-
-defn
-Cacheinfo(addr) {
- complex Cacheinfo addr;
- print(" x ", addr.x, "\n");
- print(" width ", addr.width, "\n");
- print(" left ", addr.left, "\n");
- print(" value ", addr.value, "\n");
- print(" age ", addr.age, "\n");
-};
-
-sizeofCachesubf = 24;
-aggr Cachesubf
-{
- 'U' 0 age;
- 'A' Cachefont 8 cf;
- 'A' Subfont 16 f;
-};
-
-defn
-Cachesubf(addr) {
- complex Cachesubf addr;
- print(" age ", addr.age, "\n");
- print(" cf ", addr.cf\Y, "\n");
- print(" f ", addr.f\Y, "\n");
-};
-
-sizeofFont = 72;
-aggr Font
-{
- 'Y' 0 name;
- 'A' Display 8 display;
- 'd' 16 height;
- 'd' 18 ascent;
- 'd' 20 width;
- 'd' 22 nsub;
- 'U' 24 age;
- 'D' 28 maxdepth;
- 'D' 32 ncache;
- 'D' 36 nsubf;
- 'A' Cacheinfo 40 cache;
- 'A' Cachesubf 48 subf;
- 'A' Cachefont 56 sub;
- 'A' Image 64 cacheimage;
-};
-
-defn
-Font(addr) {
- complex Font addr;
- print(" name ", addr.name\Y, "\n");
- print(" display ", addr.display\Y, "\n");
- print(" height ", addr.height, "\n");
- print(" ascent ", addr.ascent, "\n");
- print(" width ", addr.width, "\n");
- print(" nsub ", addr.nsub, "\n");
- print(" age ", addr.age, "\n");
- print(" maxdepth ", addr.maxdepth, "\n");
- print(" ncache ", addr.ncache, "\n");
- print(" nsubf ", addr.nsubf, "\n");
- print(" cache ", addr.cache\Y, "\n");
- print(" subf ", addr.subf\Y, "\n");
- print(" sub ", addr.sub\Y, "\n");
- print(" cacheimage ", addr.cacheimage\Y, "\n");
-};
-
-complex Point ZP;
-complex Rectangle ZR;
-complex Display display;
-complex Font font;
-complex Image screen;
-complex Screen _screen;
-sizeofMemdata = 40;
-aggr Memdata
-{
- 'Y' 0 base;
- 'Y' 8 bdata;
- 'D' 16 ref;
- 'Y' 24 imref;
- 'D' 32 allocd;
-};
-
-defn
-Memdata(addr) {
- complex Memdata addr;
- print(" base ", addr.base\Y, "\n");
- print(" bdata ", addr.bdata\Y, "\n");
- print(" ref ", addr.ref, "\n");
- print(" imref ", addr.imref\Y, "\n");
- print(" allocd ", addr.allocd, "\n");
-};
-
-Frepl = 1;
-Fsimple = 2;
-Fgrey = 4;
-Falpha = 8;
-Fcmap = 16;
-Fbytes = 32;
-sizeofMemimage = 168;
-aggr Memimage
-{
- Rectangle 0 r;
- Rectangle 16 clipr;
- 'D' 32 depth;
- 'D' 36 nchan;
- 'U' 40 chan;
- 'Y' 48 cmap;
- 'A' Memdata 56 data;
- 'D' 64 zero;
- 'U' 68 width;
- 'Y' 72 layer;
- 'U' 80 flags;
- 'a' 84 shift;
- 'a' 112 mask;
- 'a' 140 nbits;
-};
-
-defn
-Memimage(addr) {
- complex Memimage addr;
- print("Rectangle r {\n");
- Rectangle(addr.r);
- print("}\n");
- print("Rectangle clipr {\n");
- Rectangle(addr.clipr);
- print("}\n");
- print(" depth ", addr.depth, "\n");
- print(" nchan ", addr.nchan, "\n");
- print(" chan ", addr.chan, "\n");
- print(" cmap ", addr.cmap\Y, "\n");
- print(" data ", addr.data\Y, "\n");
- print(" zero ", addr.zero, "\n");
- print(" width ", addr.width, "\n");
- print(" layer ", addr.layer\Y, "\n");
- print(" flags ", addr.flags, "\n");
- print(" shift ", addr.shift, "\n");
- print(" mask ", addr.mask, "\n");
- print(" nbits ", addr.nbits, "\n");
-};
-
-sizeofMemcmap = 4864;
-aggr Memcmap
-{
- 'a' 0 cmap2rgb;
- 'a' 768 rgb2cmap;
-};
-
-defn
-Memcmap(addr) {
- complex Memcmap addr;
- print(" cmap2rgb ", addr.cmap2rgb, "\n");
- print(" rgb2cmap ", addr.rgb2cmap, "\n");
-};
-
-sizeofMemsubfont = 32;
-aggr Memsubfont
-{
- 'Y' 0 name;
- 'd' 8 n;
- 'b' 10 height;
- 'C' 11 ascent;
- 'A' Fontchar 16 info;
- 'A' Memimage 24 bits;
-};
-
-defn
-Memsubfont(addr) {
- complex Memsubfont addr;
- print(" name ", addr.name\Y, "\n");
- print(" n ", addr.n, "\n");
- print(" height ", addr.height, "\n");
- print(" ascent ", addr.ascent, "\n");
- print(" info ", addr.info\Y, "\n");
- print(" bits ", addr.bits\Y, "\n");
-};
-
-Simplesrc = 1;
-Simplemask = 2;
-Replsrc = 4;
-Replmask = 8;
-Fullmask = 16;
-sizeofMemdrawparam = 104;
-aggr Memdrawparam
-{
- 'A' Memimage 0 dst;
- Rectangle 8 r;
- 'A' Memimage 24 src;
- Rectangle 32 sr;
- 'A' Memimage 48 mask;
- Rectangle 56 mr;
- 'D' 72 op;
- 'U' 76 state;
- 'U' 80 mval;
- 'U' 84 mrgba;
- 'U' 88 sval;
- 'U' 92 srgba;
- 'U' 96 sdval;
-};
-
-defn
-Memdrawparam(addr) {
- complex Memdrawparam addr;
- print(" dst ", addr.dst\Y, "\n");
- print("Rectangle r {\n");
- Rectangle(addr.r);
- print("}\n");
- print(" src ", addr.src\Y, "\n");
- print("Rectangle sr {\n");
- Rectangle(addr.sr);
- print("}\n");
- print(" mask ", addr.mask\Y, "\n");
- print("Rectangle mr {\n");
- Rectangle(addr.mr);
- print("}\n");
- print(" op ", addr.op, "\n");
- print(" state ", addr.state, "\n");
- print(" mval ", addr.mval, "\n");
- print(" mrgba ", addr.mrgba, "\n");
- print(" sval ", addr.sval, "\n");
- print(" srgba ", addr.srgba, "\n");
- print(" sdval ", addr.sdval, "\n");
-};
-
-complex Memimage memwhite;
-complex Memimage memblack;
-complex Memimage memopaque;
-complex Memimage memtransparent;
-complex Memcmap memdefcmap;
-sizeofMouse = 24;
-aggr Mouse
-{
- 'D' 0 buttons;
- Point 8 xy;
- 'U' 16 msec;
-};
-
-defn
-Mouse(addr) {
- complex Mouse addr;
- print(" buttons ", addr.buttons, "\n");
- print("Point xy {\n");
- Point(addr.xy);
- print("}\n");
- print(" msec ", addr.msec, "\n");
-};
-
-sizeofMousectl = 72;
-aggr Mousectl
-{
- {
- 'D' 0 buttons;
- Point 8 xy;
- 'U' 16 msec;
- };
- 'A' Channel 24 c;
- 'A' Channel 32 resizec;
- 'Y' 40 file;
- 'D' 48 mfd;
- 'D' 52 cfd;
- 'D' 56 pid;
- 'A' Image 64 image;
-};
-
-defn
-Mousectl(addr) {
- complex Mousectl addr;
- print("Mouse {\n");
- Mouse(addr+0);
- print("}\n");
- print(" c ", addr.c\Y, "\n");
- print(" resizec ", addr.resizec\Y, "\n");
- print(" file ", addr.file\Y, "\n");
- print(" mfd ", addr.mfd, "\n");
- print(" cfd ", addr.cfd, "\n");
- print(" pid ", addr.pid, "\n");
- print(" image ", addr.image\Y, "\n");
-};
-
-sizeofMenu = 24;
-aggr Menu
-{
- 'Y' 0 item;
- 'Y' 8 gen;
- 'D' 16 lasthit;
-};
-
-defn
-Menu(addr) {
- complex Menu addr;
- print(" item ", addr.item\Y, "\n");
- print(" gen ", addr.gen\Y, "\n");
- print(" lasthit ", addr.lasthit, "\n");
-};
-
-sizeofKeyboardctl = 32;
-aggr Keyboardctl
-{
- 'A' Channel 0 c;
- 'Y' 8 file;
- 'D' 16 consfd;
- 'D' 20 ctlfd;
- 'D' 24 pid;
-};
-
-defn
-Keyboardctl(addr) {
- complex Keyboardctl addr;
- print(" c ", addr.c\Y, "\n");
- print(" file ", addr.file\Y, "\n");
- print(" consfd ", addr.consfd, "\n");
- print(" ctlfd ", addr.ctlfd, "\n");
- print(" pid ", addr.pid, "\n");
-};
-
-KF = 61440;
-Spec = 63488;
-PF = 63520;
-Kview = 63488;
-Khome = 61453;
-Kup = 61454;
-Kdown = 63488;
-Kpgup = 61455;
-Kprint = 61456;
-Kleft = 61457;
-Kright = 61458;
-Kpgdown = 61459;
-Kins = 61460;
-Kalt = 61461;
-Kshift = 61462;
-Kctl = 61463;
-Kend = 61464;
-Kscroll = 61465;
-Kscrolloneup = 61472;
-Kscrollonedown = 61473;
-Ksoh = 1;
-Kstx = 2;
-Ketx = 3;
-Keof = 4;
-Kenq = 5;
-Kack = 6;
-Kbs = 8;
-Knack = 21;
-Ketb = 23;
-Kdel = 127;
-Kesc = 27;
-Kbreak = 63585;
-Kcaps = 63588;
-Knum = 63589;
-Kmiddle = 63590;
-Kaltgr = 63591;
-Kmouse = 63744;
-sizeofPoint2 = 24;
-aggr Point2
-{
- 'F' 0 x;
- 'F' 8 y;
- 'F' 16 w;
-};
-
-defn
-Point2(addr) {
- complex Point2 addr;
- print(" x ", addr.x, "\n");
- print(" y ", addr.y, "\n");
- print(" w ", addr.w, "\n");
-};
-
-sizeofPoint3 = 32;
-aggr Point3
-{
- 'F' 0 x;
- 'F' 8 y;
- 'F' 16 z;
- 'F' 24 w;
-};
-
-defn
-Point3(addr) {
- complex Point3 addr;
- print(" x ", addr.x, "\n");
- print(" y ", addr.y, "\n");
- print(" z ", addr.z, "\n");
- print(" w ", addr.w, "\n");
-};
-
-sizeofQuaternion = 32;
-aggr Quaternion
-{
- 'F' 0 r;
- 'F' 8 i;
- 'F' 16 j;
- 'F' 24 k;
-};
-
-defn
-Quaternion(addr) {
- complex Quaternion addr;
- print(" r ", addr.r, "\n");
- print(" i ", addr.i, "\n");
- print(" j ", addr.j, "\n");
- print(" k ", addr.k, "\n");
-};
-
-sizeofRFrame = 72;
-aggr RFrame
-{
- Point2 0 p;
- Point2 24 bx;
- Point2 48 by;
-};
-
-defn
-RFrame(addr) {
- complex RFrame addr;
- print("Point2 p {\n");
- Point2(addr.p);
- print("}\n");
- print("Point2 bx {\n");
- Point2(addr.bx);
- print("}\n");
- print("Point2 by {\n");
- Point2(addr.by);
- print("}\n");
-};
-
-sizeofRFrame3 = 128;
-aggr RFrame3
-{
- Point3 0 p;
- Point3 32 bx;
- Point3 64 by;
- Point3 96 bz;
-};
-
-defn
-RFrame3(addr) {
- complex RFrame3 addr;
- print("Point3 p {\n");
- Point3(addr.p);
- print("}\n");
- print("Point3 bx {\n");
- Point3(addr.bx);
- print("}\n");
- print("Point3 by {\n");
- Point3(addr.by);
- print("}\n");
- print("Point3 bz {\n");
- Point3(addr.bz);
- print("}\n");
-};
-
-sizeofTriangle3 = 96;
-aggr Triangle3
-{
- Point3 0 p0;
- Point3 32 p1;
- Point3 64 p2;
-};
-
-defn
-Triangle3(addr) {
- complex Triangle3 addr;
- print("Point3 p0 {\n");
- Point3(addr.p0);
- print("}\n");
- print("Point3 p1 {\n");
- Point3(addr.p1);
- print("}\n");
- print("Point3 p2 {\n");
- Point3(addr.p2);
- print("}\n");
-};
-
-Portho = 0;
-Ppersp = 1;
-sizeofVertex = 64;
-aggr Vertex
-{
- Point3 0 p;
- Point3 32 n;
-};
-
-defn
-Vertex(addr) {
- complex Vertex addr;
- print("Point3 p {\n");
- Point3(addr.p);
- print("}\n");
- print("Point3 n {\n");
- Point3(addr.n);
- print("}\n");
-};
-
-sizeofViewport = 80;
-aggr Viewport
-{
- {
- Point2 0 p;
- Point2 24 bx;
- Point2 48 by;
- };
- 'A' Memimage 72 fb;
-};
-
-defn
-Viewport(addr) {
- complex Viewport addr;
- print("RFrame {\n");
- RFrame(addr+0);
- print("}\n");
- print(" fb ", addr.fb\Y, "\n");
-};
-
-sizeofCamera = 384;
-aggr Camera
-{
- {
- Point3 0 p;
- Point3 32 bx;
- Point3 64 by;
- Point3 96 bz;
- };
- Viewport 128 viewport;
- 'F' 208 fov;
- 'F' 216 clipn;
- 'F' 224 clipf;
- 'a' 232 proj;
- 'D' 360 ptype;
- 'Y' 368 updatefb;
- 'Y' 376 develop;
-};
-
-defn
-Camera(addr) {
- complex Camera addr;
- print("RFrame3 {\n");
- RFrame3(addr+0);
- print("}\n");
- print("Viewport viewport {\n");
- Viewport(addr.viewport);
- print("}\n");
- print(" fov ", addr.fov, "\n");
- print(" clipn ", addr.clipn, "\n");
- print(" clipf ", addr.clipf, "\n");
- print(" proj ", addr.proj, "\n");
- print(" ptype ", addr.ptype, "\n");
- print(" updatefb ", addr.updatefb\Y, "\n");
- print(" develop ", addr.develop\Y, "\n");
-};
-
-OBJVGeometric = 0;
-OBJVTexture = 1;
-OBJVNormal = 2;
-OBJVParametric = 3;
-OBJNVERT = 4;
-OBJEPoint = 0;
-OBJELine = 1;
-OBJEFace = 2;
-OBJECurve = 3;
-OBJECurve2 = 4;
-OBJESurface = 5;
-OBJGGlobal = 0;
-OBJGSmoothing = 1;
-OBJGMerging = 2;
-OBJHTSIZE = 17;
-sizeof_2_ = 32;
-aggr _2_
-{
- 'F' 0 x;
- 'F' 8 y;
- 'F' 16 z;
- 'F' 24 w;
-};
-
-defn
-_2_(addr) {
- complex _2_ addr;
- print(" x ", addr.x, "\n");
- print(" y ", addr.y, "\n");
- print(" z ", addr.z, "\n");
- print(" w ", addr.w, "\n");
-};
-
-sizeof_3_ = 24;
-aggr _3_
-{
- 'F' 0 u;
- 'F' 8 v;
- 'F' 16 vv;
-};
-
-defn
-_3_(addr) {
- complex _3_ addr;
- print(" u ", addr.u, "\n");
- print(" v ", addr.v, "\n");
- print(" vv ", addr.vv, "\n");
-};
-
-sizeof_4_ = 24;
-aggr _4_
-{
- 'F' 0 i;
- 'F' 8 j;
- 'F' 16 k;
-};
-
-defn
-_4_(addr) {
- complex _4_ addr;
- print(" i ", addr.i, "\n");
- print(" j ", addr.j, "\n");
- print(" k ", addr.k, "\n");
-};
-
-sizeof_5_ = 32;
-aggr _5_
-{
- {
- 'F' 0 x;
- 'F' 8 y;
- 'F' 16 z;
- 'F' 24 w;
- };
- {
- 'F' 0 u;
- 'F' 8 v;
- 'F' 16 vv;
- };
- {
- 'F' 0 i;
- 'F' 8 j;
- 'F' 16 k;
- };
-};
-
-defn
-_5_(addr) {
- complex _5_ addr;
- print("_2_ {\n");
- _2_(addr+0);
- print("}\n");
- print("_3_ {\n");
- _3_(addr+0);
- print("}\n");
- print("_4_ {\n");
- _4_(addr+0);
- print("}\n");
-};
-
-sizeofOBJVertex = 32;
-aggr OBJVertex
-{
- {
- {
- 'F' 0 x;
- 'F' 8 y;
- 'F' 16 z;
- 'F' 24 w;
- };
- {
- 'F' 0 u;
- 'F' 8 v;
- 'F' 16 vv;
- };
- {
- 'F' 0 i;
- 'F' 8 j;
- 'F' 16 k;
- };
- };
-};
-
-defn
-OBJVertex(addr) {
- complex OBJVertex addr;
- print("_5_ {\n");
- _5_(addr+0);
- print("}\n");
-};
-
-sizeofOBJVertexArray = 16;
-aggr OBJVertexArray
-{
- 'A' OBJVertex 0 verts;
- 'D' 8 nvert;
-};
-
-defn
-OBJVertexArray(addr) {
- complex OBJVertexArray addr;
- print(" verts ", addr.verts\Y, "\n");
- print(" nvert ", addr.nvert, "\n");
-};
-
-sizeofOBJElem = 24;
-aggr OBJElem
-{
- 'Y' 0 indices;
- 'D' 8 nindex;
- 'D' 12 type;
- 'A' OBJElem 16 next;
-};
-
-defn
-OBJElem(addr) {
- complex OBJElem addr;
- print(" indices ", addr.indices\Y, "\n");
- print(" nindex ", addr.nindex, "\n");
- print(" type ", addr.type, "\n");
- print(" next ", addr.next\Y, "\n");
-};
-
-sizeofOBJObject = 24;
-aggr OBJObject
-{
- 'Y' 0 name;
- 'A' OBJElem 8 child;
- 'A' OBJObject 16 next;
-};
-
-defn
-OBJObject(addr) {
- complex OBJObject addr;
- print(" name ", addr.name\Y, "\n");
- print(" child ", addr.child\Y, "\n");
- print(" next ", addr.next\Y, "\n");
-};
-
-sizeofOBJ = 200;
-aggr OBJ
-{
- 'a' 0 vertdata;
- 'a' 64 objtab;
-};
-
-defn
-OBJ(addr) {
- complex OBJ addr;
- print(" vertdata ", addr.vertdata, "\n");
- print(" objtab ", addr.objtab, "\n");
-};
-
-K↑ = 0;
-K↓ = 1;
-K← = 2;
-K→ = 3;
-Krise = 4;
-Kfall = 5;
-KR↑ = 6;
-KR↓ = 7;
-KR← = 8;
-KR→ = 9;
-KR↺ = 10;
-KR↻ = 11;
-Kcam0 = 12;
-Kcam1 = 13;
-Kcam2 = 14;
-Kcam3 = 15;
-Kscrshot = 16;
-Ke = 17;
-Scamno = 0;
-Sfov = 1;
-Scampos = 2;
-Scambx = 3;
-Scamby = 4;
-Scambz = 5;
-Se = 6;
-sizeofCamcfg = 128;
-aggr Camcfg
-{
- Point3 0 p;
- Point3 32 lookat;
- Point3 64 up;
- 'F' 96 fov;
- 'F' 104 clipn;
- 'F' 112 clipf;
- 'D' 120 ptype;
-};
-
-defn
-Camcfg(addr) {
- complex Camcfg addr;
- print("Point3 p {\n");
- Point3(addr.p);
- print("}\n");
- print("Point3 lookat {\n");
- Point3(addr.lookat);
- print("}\n");
- print("Point3 up {\n");
- Point3(addr.up);
- print("}\n");
- print(" fov ", addr.fov, "\n");
- print(" clipn ", addr.clipn, "\n");
- print(" clipf ", addr.clipf, "\n");
- print(" ptype ", addr.ptype, "\n");
-};
-
-complex Mousectl mctl;
-complex Channel drawc;
-complex Camera maincam;
-complex Fmt vfmt:f;
-complex Point2 vfmt:p;
-complex Fmt Vfmt:f;
-complex Point3 Vfmt:p;
-complex Triangle3 depthcmp:ta;
-complex Triangle3 depthcmp:tb;
-complex Point3 drawaxis:op;
-complex Point3 drawaxis:px;
-complex Point3 drawaxis:py;
-complex Point3 drawaxis:pz;
-complex OBJ threadmain:objmesh;
-MOUSE = 0;
-RESIZE = 1;
-DRAW = 2;
diff --git a/main.c b/main.c
index 9166d7c..6dc32fe 100644
--- a/main.c
+++ b/main.c
@@ -50,25 +50,30 @@ double θ, ω;
Camera cams[4], *maincam;
Camcfg camcfgs[4] = {
+// 2,0,-4,1,
+// 0,0,0,1,
+// 0,1,0,0,
+// 90*DEG, 0.1, 100, PERSPECTIVE,
+
2,0,-4,1,
0,0,0,1,
0,1,0,0,
- 90*DEG, 0.1, 100, PERSPECTIVE,
+ 0, 0.1, 100, ORTHOGRAPHIC,
-2,0,-4,1,
0,0,0,1,
0,1,0,0,
120*DEG, 0.1, 100, PERSPECTIVE,
- -2,0,4,1,
- 0,0,0,1,
- 0,1,0,0,
- 90*DEG, 0.1, 100, PERSPECTIVE,
-
// -2,0,4,1,
// 0,0,0,1,
// 0,1,0,0,
-// 0, 0.1, 100, ORTHOGRAPHIC,
+// 90*DEG, 0.1, 100, PERSPECTIVE,
+
+ -2,0,4,1,
+ 0,0,0,1,
+ 0,1,0,0,
+ 0, 0.1, 100, ORTHOGRAPHIC,
2,0,4,1,
0,0,0,1,
@@ -76,7 +81,7 @@ Camcfg camcfgs[4] = {
120*DEG, 0.1, 100, PERSPECTIVE
};
Point3 center = {0,0,0,1};
-Point3 light = {0,1,1,1}; /* global directional light */
+Point3 light = {0,1,1,1}; /* global point light */
static int
min(int a, int b)
@@ -113,7 +118,7 @@ vertshader(VSparams *sp)
sp->su->var_intensity[sp->idx] = fmax(0, dotvec3(sp->v->n, light));
sp->v->n = world2vcs(maincam, sp->v->n);
sp->v->p = qrotate(sp->v->p, Vec3(0,1,0), θ+fmod(ω*sp->su->uni_time/1e9, 2*PI));
- sp->v->p = ndc2viewport(maincam, world2ndc(maincam, sp->v->p));
+ sp->v->p = world2clip(maincam, sp->v->p);
return sp->v->p;
}
@@ -264,7 +269,7 @@ boxshader(FSparams *sp)
Point3
ivshader(VSparams *sp)
{
- return ndc2viewport(maincam, world2ndc(maincam, sp->v->p));
+ return world2clip(maincam, sp->v->p);
}
Memimage *
@@ -482,8 +487,8 @@ threadmain(int argc, char *argv[])
{
Viewport *v;
Channel *keyc;
- char *mdlpath, *texpath, *sname, *p;
- int i;
+ char *mdlpath, *texpath, *sname;
+ int i, fd;
GEOMfmtinstall();
texpath = nil;
@@ -504,17 +509,12 @@ threadmain(int argc, char *argv[])
if((model = objparse(mdlpath)) == nil)
sysfatal("objparse: %r");
if(texpath != nil){
- if((p = strrchr(texpath, '/')) == nil)
- p = texpath;
- p = strchr(p, '.');
- if(p == nil)
- sysfatal("unknown image file");
- if(strcmp(++p, "tga") == 0 && (modeltex = readtga(texpath)) == nil)
- sysfatal("readtga: %r");
- else if(strcmp(p, "png") == 0 && (modeltex = readpng(texpath)) == nil)
- sysfatal("readpng: %r");
- if(modeltex == nil)
- sysfatal("unknown image file");
+ fd = open(texpath, OREAD);
+ if(fd < 0)
+ sysfatal("open: %r");
+ if((modeltex = readmemimage(fd)) == nil)
+ sysfatal("readmemimage: %r");
+ close(fd);
}
if(initdraw(nil, nil, "3d") < 0)