!*********************************************************************** !* !* SCRIBE device driver for Canon LBP-10 laser printer !* !* Copyright (C) R.D. Eager University of Kent MCMLXXXVI !* !*********************************************************************** ! %include "SCRIBE_DEVDEFS" %include "SCRIBE_LBP10CONST" ! !*********************************************************************** !* !* Constants !* !*********************************************************************** ! %constantinteger false = 0, true = 1 %constantinteger ppi = 1080; ! Points per inch %constantreal fact240 = ppi/240; ! Points to driver units, 240ths ! ! Font codes ! %constantinteger TimesB6 = 0; ! Times Bold 6 point %constantinteger TimesI6 = 1; ! Times Italic 6 point %constantinteger TimesR6 = 2; ! Times Roman 6 point %constantinteger TimesS6 = 3; ! Times Special 6 point %constantinteger TimesB8 = 4; ! Times Bold 8 point %constantinteger TimesI8 = 5; ! Times Italic 8 point %constantinteger TimesR8 = 6; ! Times Roman 8 point %constantinteger TimesS8 = 7; ! Times Special 8 point %constantinteger TimesB9 = 8; ! Times Bold 9 point %constantinteger TimesI9 = 9; ! Times Italic 9 point %constantinteger TimesR9 = 10; ! Times Roman 9 point %constantinteger TimesS9 = 11; ! Times Special 9 point %constantinteger TimesB10 = 12; ! Times Bold 10 point %constantinteger TimesI10 = 13; ! Times Italic 10 point %constantinteger TimesR10 = 14; ! Times Roman 10 point %constantinteger TimesS10 = 15; ! Times Special 10 point %constantinteger TimesB11 = 16; ! Times Bold 11 point %constantinteger TimesI11 = 17; ! Times Italic 11 point %constantinteger TimesR11 = 18; ! Times Roman 11 point %constantinteger TimesS11 = 19; ! Times Special 11 point %constantinteger TimesB13 = 20; ! Times Bold 13 point %constantinteger TimesI13 = 21; ! Times Italic 13 point %constantinteger TimesR13 = 22; ! Times Roman 13 point %constantinteger TimesS13 = 23; ! Times Special 13 point %constantinteger PrintOut6 = 24; ! Print Out 6 point %constantinteger PrintOut8 = 25; ! Print Out 8 point %constantinteger PrintOut10 = 26; ! Print Out 10 point %constantinteger PrintOut11 = 27; ! Print Out 11 point ! ! Font names (as held by file server) ! %constantinteger maxfont = 27; ! Maximum legal font number (starts at 0) %constantstring(20)%array fontnames(0:maxfont) = %c "times.b.6", "times.i.6", "times.r.6", "times.s.6", "times.b.8", "times.i.8", "times.r.8", "times.s.8", "times.b.9", "times.i.9", "times.r.9", "times.s.9", "times.b.10", "times.i.10", "times.r.10", "times.s.10", "times.b.11", "times.i.11", "times.r.11", "times.s.11", "times.b.13", "times.i.13", "times.r.13", "times.s.13", "po.6", "po.8", "po.10", "po.11" ! ! !*********************************************************************** !* !* Subsystem references !* !*********************************************************************** ! %externalstringfunctionspec uinfs(%integer entry) ! ! !*********************************************************************** !* !* External references !* !*********************************************************************** ! %externalstring(31)%spec output file; ! Name of output file (for header) %externalintegerarrayspec pb(1:max pb); ! Page buffer ! ! !*********************************************************************** !* !* Forward references !* !*********************************************************************** ! %routinespec print16(%integer n) ! ! !*********************************************************************** !* !* Own variables !* !*********************************************************************** ! %owninteger pages; ! Count of pages output %owninteger new page pending; ! Flag used to avoid blank page at end %owninteger boldness; ! Nonzero iff bold on %owninteger scriptness; ! Superscript/subscript flags %owninteger fontness; ! Current font %owninteger bfont; ! Most recently selected baseline font %ownbyteintegerarray fontset(0:maxfont) = false(maxfont+1) ! Indicates if font declared yet ! ! !*********************************************************************** !* !* Service routines !* !*********************************************************************** ! %routine begin new page ! Performs all necessary actions to start a new page. pages = pages + 1 printch(BEGINPAGE) print16(pages) printch(1); ! Number of copies new page pending = false %end; ! of begin new page ! !----------------------------------------------------------------------- ! %routine outstring(%string(255) s) ! Outputs a string preceded by a length byte. printch(length(s)) printstring(s) %end; ! of outstring ! !----------------------------------------------------------------------- ! %routine print16(%integer n) ! Outputs 'n' as two bytes, most significant byte first. printch(n >> 8) printch(n) %end; ! of print16 ! !----------------------------------------------------------------------- ! %routine print header %string(255) s ! printch(HEADER); ! Start header outstring(output file); ! Job name outstring(uinfs(7)); ! Local name (surname) outstring(uinfs(1)); ! System-id (user number) s = uinfs(16) %if s -> (".").s %then %start; %finish outstring(s); ! Host outstring(uinfs(2)); ! Delivery %end; ! of print header ! !----------------------------------------------------------------------- ! %routine selectfont(%integer n) ! Selects font 'n' for output, declaring it to the LBP-10 if necessary. %if 0 <= n <= maxfont %then %start %if n # fontness %then %start %if fontset(n) = false %then %start printch(DECLAREFONT) printch(n) outstring(fontnames(n)) fontset(n) = true %finish printch(CHANGEFONT) printch(n) fontness = n %finish %else selectfont(TimesR10) %finish %end; ! of selectfont ! ! !*********************************************************************** !* !* L B P 1 0 !* !*********************************************************************** ! %externalroutine lbp10 %alias "DP#LBP10" (%integer fn,start,end) %integer w,h,i,j,ch %real xs,r %switch fnsw(1:5) ! -> fnsw(fn) ! fnsw(1): ! Initialise print header ! scriptness = 0; ! On baseline boldness = false fontness = -1 printch(LPSETUP) print16(0) %for i = 1,1,4 printch(LPMODEON) pages = 0 new page pending = true selectfont(TimesR10) bfont = fontness %return ! fnsw(2): ! Print line from pb(start) to pb(end-1) %if new page pending = true %then begin new page xs = 0 %for i = start,1,end-1 %cycle w = pb(i) ! Check subscript/superscript status j = w & (subscript!supscript) %if j # scriptness %then %start ! What else???? scriptness = j %finish ! Handle horizontal movement %if w & (htab!sigsp!reverse htab) # 0 %then %start h = w & x'ffff'; ! Points to go r = h/fact240; ! Convert to 240ths for LBP-10 %if w & reverse htab = 0 %then r = r + xs %if r < 0 %then %start; ! Can only be for forward move xs = r; ! Wish to move less than the outstanding (-ve) xs %else h = int(r); ! Nearest 240th r = r - h; ! The xs for this step %if w & reverse htab = 0 %then %start ! Forward %if h + 127 <= MAXSHORTMOVE %then %start printch(h+127) %else printch(MOVEBYX) print16(h) %finish xs = r %else; ! Backward printch(MOVEBYX) print16(-h) xs = xs - r %finish %finish %else; ! A printing character j = w & bold; ! Check bold status %if j # boldness %then %start boldness = j %if j = 0 %then selectfont(TimesR10) %else selectfont(TimesB10) %finish ! Check font j = (w & fontmask) >> 8 %if j # fontness %then %start; ! Changed selectfont(j) %finish bfont = fontness %if scriptness = 0 ! The most recent baseline font ch = w & x'ff' %if ch > 127 %then %start; ! Extended set character printch(EXTSETCHAR) %finish printch(ch) %finish %repeat ! %return ! fnsw(3): ! Vertical tab in pb(end) %if new page pending = true %then begin new page j = int((pb(end) & x'ffff')/fact240);! Nearest 240th, relative down printch(MOVETOX) print16(0) printch(MOVEBYY) print16(j) %return ! fnsw(4): ! Initialise for new page new page pending = true %return ! fnsw(5): ! Close printch(STOP); ! Print last page and banner page %return %end; ! of lbp10 %endoffile