#include "defs.h" /* * Copy entire entry from one place to another. * */ DL copy(af, at) DL af, at; { REG MEMPTR t=memptr(at); REG MEMPTR f=memptr(af); REG INT L=len(af)/MEMSIZ; while(L--) { *t++ = *f++; } return(at); } /* * Remove an entry from the display list. * * p = entry to remove */ delete(p) REG DL p; { moveup(p, len(p)); } /* * Length of entry. * */ VOID len(p) REG DL p; { switch(p->type) { case 'Z': return(DLPSIZ); case 'B': case 'J': case 'M': return(DLHSIZ); case 'e': case 'a': case 'A': case 'h': case 'o': case 'p': case 'v': case 'V': case 'x': case 'X': return(p->size); case 'L': case 'c': case 'w': case 'b': return(dln(p)->size); default: debug++; error("DL system error"); return(junk(INT)); } } /* * Close a hole in the display list. * * p = start of area to delete * l = number of bytes to remove */ moveup(p, L) DL p; REG INT L; { REG MEMPTR f, t; f = memptr( adr(p)+L ); t = memptr(p); do *t++ = *f++; while(f < memptr(dend)); dend = dl( adr(dend)-L ); lesscore(); modified=1; } /* * Make a hole in the display list. * * p = entry before which hole is to be made * l = length (bytes) of hole */ DL movedown(p, L) REG DL p; INT L; { REG MEMPTR f, t; modified=1; if(adr(dlim)-adr(dend) < 96) morecore(256); f = memptr(dend); dend = dl( adr(dend)+L ); t = memptr(dend); do *--t = *--f; while(f > memptr(p)); return(dl(t)); } /* * Shrink dynamic area. * * n = number of bytes to return to the system */ lesscore() { if( (adr(dlim)-adr(dend))>512 ) { dlim = dl( adr(dlim)-256 ); brk(adr(dlim)); } } /* * Increase dynamic area. * * n = number of bytes to add to area */ morecore(n) { dlim = dl( adr(dlim)+n ); if(brk(adr(dlim)) == adr(-1)){ error("OUT OF SPACE"); } } /* * return version number of current image */ version() { REG DL p; p = dstart; if (len(p) == 2) return(0); else return(p->x); } setpag(n) INT n; { REG DL p; p=dstart; p->y=n; } pagnum() { REG DL p; p = dstart; return(p->y); } checkdl(h) DL h; { REG DL p=h; REG DL q=dend; while(p=succa(p)) q=p; if(q!=dend) error("dl list error- write file and get srb"); } /* * First entry of a given type */ DL first(k) { REG DL p; p=next(k, dstart); return(p); } /* * Last entry of a given type. */ DL last(k) CHAR k; { REG DL p, q; p = dstart; q = nil(DL); while(p = succa(p)) if(p->type==k) q = p; elif(p->type=='Z') break; return(q); } /* * Find next major entry */ DL next(t, p) REG DL p; REG CHAR t; { REG DL q; if( (q=succ(t,p)) && ((q->flag&END)==0) ) return(q); else return(nil(DL)); } DL nexta(t, p) REG DL p; REG S_POS t; { REG DL q; q=succa(p); if(q->type==t) return(nil(DL)); else return(q); } /* * Find successor. * * t = entry type * p = current entry * return = if p is END then p, else next entry of type t * if any, otherwise 0 */ DL succ(t, p) REG DL p; REG S_POS t; { if((p->type == t) && (p->flag&END)) return(p); while(p = succa(p)) if(p->type == t) return(p); return(nil(DL)); } /* * Immediate successor of entry. * * p = current entry * return = next entry, 0 if p is at end of display list */ DL succa(p) REG DL p; { if(p >= dend || p == nil(DL)) return(nil(DL)); return(dl(adr(p)+len(p))); }