%! % AWCB Directors Cut first try awcb.dir1.psl % ============================================================== % Copyright c 2017 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % This is a PDF extract of the magic lamp story in % https://www.tinaja.com/whtnu17.shtml#d11.16.17 %%%%%%%%% % This comment is a reminder that distiller needs an //acrodist.exe /F to use disk files %%%%%%%%% % Define and alter your full gonzo.ps path reminder here It might be % C:/Users/don/Desktop/Dist-FR/gonzo.ps % Preplace gonzo.ps from http://www.tinaja.com/post01.shtml#gonzo to above directory % Make sure there are no previously active instances of distiller. % Then run distiller ONLY from % //acrodist.exe /F run % Then drag and drop this file into Distiller. %%%%%%%%% % Set Directory Headers %%%%%%%% % /gonzodirectory (C:/Users/Don/Desktop/Ghost/gonzo.psl) run % use internal ) store % dbl rvse slashes for ps /imagelocaldirectory (C:/Users/don/Desktop/canal/images/) store % sin fwd slashes for win /imageremotedirectory (http://www.tinaja.com/canal/images/) store % sin fwd slashes for chrome % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def %%%%%%%%% % This code activates gonzo utilities for this document %%%%%%%%% % Required preload of gonzo.ps and adjusted for your machine per above. % gonzodirectory (gonzo.ps) mergestr run % double reverse slashes in PS! (C:/Users/Don/Desktop/Ghost/gonzo.psl) run /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def guru % activate gonzo utilities %%%%%%%%%% % This code locks pdfmark commands out of a PostScript printer. %%%%%%%%%% /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse %%%%%%%%%% % This code changes the page size to smaller %%%%%%%%%% [/CropBox [0 0 520 620] % set the weird size in points X Y. /PAGES pdfmark %%%%%%%%%% % This code is needed for the automatic url placer %%%%%%%%%% % Requires a defined name for the url below % Activate with text text |/surl urlname |/eurl text text % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string % /black cvx 0 /setgray cvx % turn blue marker off % maintextcolor /setrgbcolor cvx % reset to main text color??? /aqua cvx /black cvx /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def % /makeurlx generates the box specific pdfmark, receiving % a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /makeurlx { /cururlnamex exch store % save the url string mark % start pdfmark /Rect [ xpos % set box left x ypos 0.9 sub % set box left y xpos 2.8 add % box right x ypos 0.9 sub 2.8 add % box right y ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def %%%%%%%%%%% % This code inserts color effects mid line %%%%%%%%%% %%%%%%%%%%%%%% COMPACT VERSION OF COLORIZER II %%%%%%%%%%%%%%%%%%%%%% /settint {dup /currenttint exch store 5.999 mul dup floor cvi /&cbar exch store dup floor sub /&cwt exch store [ {/setgray [ /dup cvx 0.3 &cwt 0.59 mul add /ge cvx [1 /exch cvx &cwt 0.59 mul 0.30 add /sub cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx ] cvx [ &cwt 0.59 mul 0.3 add /div cvx /dup cvx &cwt /mul cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub 0.3 mul add /ge cvx [1 &cwt sub 0.3 mul 0.59 add /sub cvx &cwt 0.3 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx /exch cvx 1 /exch cvx] cvx [1 &cwt sub 0.3 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 &cwt 0.11 mul add /ge cvx [&cwt 0.11 mul 0.59 add /sub cvx 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx 1 /exch cvx] cvx [0 /exch cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub mul 0.11 add /ge cvx [1 &cwt sub 0.59 mul 0.11 add /sub cvx &cwt 0.59 mul 0.30 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx 1] cvx [0 /exch cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.11 &cwt 0.30 mul add /ge cvx[&cwt 0.30 mul 0.11 add /sub cvx 1 &cwt sub 0.30 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx 1] cvx [ &cwt 0.30 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx /exch cvx 0 /exch cvx ] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} {/setgray [ /dup cvx 0.30 1 &cwt sub 0.11 mul add /ge cvx[ 1 /exch cvx 1 &cwt sub 0.11 mul 0.30 add /sub cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx ] cvx [ 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx 0 /exch cvx] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} ] &cbar get exec exec} bind def /beige {0.11 settint} def % examples of convenience operators /aqua {0.52 settint} def /blue {0.67 settint} def /lime {0.44 settint} def %%%%%%%%%%% % This code converts a .JPG image into a PS image %%%%%%%%%%% /jpegimageprocwithlink { % hoffset voffset hres vres urlfrom urlto save /snap2 exch def /inurllink exch store % grab link filename /infilename exch store % grab passed pix file /photoscale exch store /vpixels exch store /hpixels exch store % (\nvpixels = )print vpixels == % (\nhpixels = )print hpixels == % (\photoscale = ) print photoscale == % (\ninurllink = ) print inurllink == % (\ninfilemane = ) print infilename == translate % adjust position for final figure ??? inurllink setareaurl % autolink sizing /DeviceRGB setcolorspace % pick color model 0 0 translate % set page position hpixels vpixels scale % magnify unit square photoscale dup scale /infile infilename (r) file def % establish input read file /Data {infile /DCTDecode filter} def % define a data source << % start image dicationary /ImageType 1 % always one /Width hpixels % JPEG width in pixels /Height vpixels % JPEG height in pixels /ImageMatrix [hpixels 0 0 vpixels neg 0 vpixels ] /DataSource Data % proc to get filtered JPEG /BitsPerComponent 8 % color resolution /Decode [0 1 0 1 0 1] % per red book 4.10 >> image % call the image operator ypos snap2 restore /ypos exch def } def /setareaurl { % for auto include routine /cururlname exch store mark % start pdfmark /Rect [ 0 0 hpixels photoscale mul vpixels photoscale mul ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def %%%%%%%%%%% % This code inserts a PS figure proc into a fixed location %%%%%%%%%%% %%%%%%%%%%% % This code autopositions a PS figure proc %%%%%%%%%%% %%%%%%%%%%% % This image code for sequential pages %%%%%%%%%%% /startnewpage { black beige 0.35 setgray 21 -2.5 (|3\320|j|j) ggnum 40 string cvs mergestr (|j |j) mergestr pagenum 10 string cvs mergestr (|j|j\320) mergestr cc aqua showpage %% start next page /pagenum pagenum 1 add store 50 50 10 setgrid % create grid setpagefonts font1 textleft texttop } def %%%%%%%%%%%%%%% % Fat Tail Utilities %%%%%% %%%%%%%%%%%%%%% /arrowcore { %%%%%%% north tail, south tip %%%%%%% /fattailsn { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltay tipy tipdepth sub taily sub enthu mul store tipx tipy mt tipx tipspread 2 div add tipy tipdepth sub lineto tipspread 2 div tipfat 2 div sub pl tipx tipfat 2 div add tipy tipdepth sub deltay sub debug tailx tailfat 2 div add taily deltay add debug tailx tailfat 2 div add taily curveto tailfat pl tailx tailfat 2 div sub taily deltay add debug tipx tipfat 2 div sub tipy tipdepth sub deltay sub debug tipx tipfat 2 div sub tipy tipdepth sub curveto tipspread tipfat sub 2 div pl closepath fill grestore } store %%%%%%% south tail, north tip %%%%%%% /fattailns { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltay tipy tipdepth add taily sub enthu mul store tipx tipy mt tipx tipspread 2 div add tipy tipdepth add lineto tipspread 2 div tipfat 2 div sub pl tipx tipfat 2 div add tipy tipdepth add deltay sub debug tailx tailfat 2 div add taily deltay add debug tailx tailfat 2 div add taily curveto tailfat pl tailx tailfat 2 div sub taily deltay add debug tipx tipfat 2 div sub tipy tipdepth add deltay sub debug tipx tipfat 2 div sub tipy tipdepth add curveto tipspread tipfat sub 2 div pl closepath fill grestore } store %%%%%%% east tail, west tip %%%%%%% /fattailew { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltax tailx tipx tipdepth add sub enthu mul store tipx tipy mt tipx tipdepth add tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth add deltax add tipy tipfat 2 div add debug tailx deltax sub taily tailfat 2 div add debug tailx taily tailfat 2 div add curveto tailfat pd tailx deltax sub taily tailfat 2 div sub debug tipx tipdepth add deltax add tipy tipfat 2 div sub debug tipx tipdepth add tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% west tail, east tip %%%%%%% /fattailwe { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltax tipx tipdepth add tailx sub enthu mul store tipx tipy mt tipx tipdepth sub tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth sub deltax sub tipy tipfat 2 div add debug tailx deltax add taily tailfat 2 div add debug tailx taily tailfat 2 div add curveto tailfat pd tailx deltax add taily tailfat 2 div sub debug tipx tipdepth sub deltax sub tipy tipfat 2 div sub debug tipx tipdepth sub tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% north tail, east tip %%%%%%% /fattailne { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tipx tipdepth sub tailx tailfat 2 div add sub enthu mul store /deltaxs tipx tipdepth sub tailx tailfat 2 div sub sub enthu mul store /deltaye taily tipy tipfat 2 div sub sub enthu mul store /deltayw taily tipy tipfat 2 div add sub enthu mul store tipx tipy mt tipx tipdepth sub tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth sub deltaxn sub tipy tipfat 2 div add debug tailx tailfat 2 div add taily deltayw sub debug tailx tailfat 2 div add taily curveto tailfat pl tailx tailfat 2 div sub taily deltaye sub debug tipx tipdepth sub deltaxs sub tipy tipfat 2 div sub debug tipx tipdepth sub tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% north tail, west tip %%%%%%% /fattailnw { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tailx tailfat 2 div sub tipx tipdepth add sub enthu mul store /deltaxs tailx tailfat 2 div add tipx tipdepth add sub enthu mul store /deltaye taily tipy tipfat 2 div sub sub enthu mul store /deltayw taily tipy tipfat 2 div add sub enthu mul store tipx tipy mt tipx tipdepth add tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth add deltaxn add tipy tipfat 2 div add debug tailx tailfat 2 div sub taily deltayw sub debug tailx tailfat 2 div sub taily curveto tailfat pr tailx tailfat 2 div add taily deltaye sub debug tipx tipdepth add deltaxs add tipy tipfat 2 div sub debug tipx tipdepth add tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% south tail, west tip %%%%%%% /fattailsw { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tailx tailfat 2 div add tipx tipdepth add sub enthu mul store /deltaxs tailx tailfat 2 div sub tipx tipdepth add sub enthu mul store /deltaye tipy tipfat 2 div add taily sub enthu mul store /deltayw tipy tipfat 2 div sub taily sub enthu mul store tipx tipy mt tipx tipdepth add tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth add deltaxn add tipy tipfat 2 div add debug tailx tailfat 2 div add taily deltaye add debug tailx tailfat 2 div add taily curveto tailfat pl tailx tailfat 2 div sub taily deltayw add debug tipx tipdepth add deltaxs add tipy tipfat 2 div sub debug tipx tipdepth add tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% north tail, west tip %%%%%%% /fattailnw { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tailx tailfat 2 div sub tipx tipdepth add sub enthu mul store /deltaxs tailx tailfat 2 div add tipx tipdepth add sub enthu mul store /deltayw taily tipy tipfat 2 div add sub enthu mul store /deltaye taily tipy tipfat 2 div sub sub enthu mul store tipx tipy mt tipx tipdepth add tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth add deltaxn add tipy tipfat 2 div add debug tailx tailfat 2 div sub taily deltayw sub debug tailx tailfat 2 div sub taily curveto tailfat pr tailx tailfat 2 div add taily deltaye sub debug tipx tipdepth add deltaxs add tipy tipfat 2 div sub debug tipx tipdepth add tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% south tail, east tip %%%%%%% /fattailse { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tipx tipdepth sub tailx tailfat 2 div sub sub enthu mul store /deltaxs tipx tipdepth sub tailx tailfat 2 div add sub enthu mul store /deltaye tipy tipfat 2 div sub taily sub enthu mul store /deltayw tipy tipfat 2 div add taily sub enthu mul store tipx tipy mt tipx tipdepth sub tipy tipspread 2 div add lineto tipspread 2 div tipfat 2 div sub pd tipx tipdepth sub deltaxn sub tipy tipfat 2 div add debug tailx tailfat 2 div sub taily deltayw add debug tailx tailfat 2 div sub taily curveto tailfat pr tailx tailfat 2 div add taily deltaye add debug tipx tipdepth sub deltaxs sub tipy tipfat 2 div sub debug tipx tipdepth sub tipy tipfat 2 div sub curveto tipspread tipfat sub 2 div pd closepath fill grestore } store %%%%%%% west tail, north tip %%%%%%% /fattailwn { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tipx tipfat sub tailx sub enthu mul store /deltaxs tipx tipfat add tailx sub enthu mul store /deltaye tipy tipdepth sub taily tailfat 2 div sub sub enthu mul store /deltayw tipy tipdepth sub taily tailfat 2 div add sub enthu mul store tipx tipy mt tipx tipspread 2 div sub tipy tipdepth sub lineto tipspread 2 div tipfat 2 div sub pr tipx tipfat 2 div sub tipy tipdepth sub deltayw sub debug tailx deltaxn add taily tailfat 2 div add debug tailx taily tailfat 2 div add curveto tailfat pd tailx deltaxs add taily tailfat 2 div sub debug tipx tipfat 2 div add tipy tipdepth sub deltaye sub debug tipx tipfat 2 div add tipy tipdepth sub curveto tipspread tipfat sub 2 div pr closepath fill grestore } store %%%%%%% east tail, north tip %%%%%%% /fattailen { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tailx tipx tipfat add sub enthu mul store /deltaxs tipx tipfat sub tailx sub enthu mul store /deltaye tipy tipdepth sub taily tailfat 2 div add sub enthu mul store /deltayw tipy tipdepth sub taily tailfat 2 div sub sub enthu mul store tipx tipy mt tipx tipspread 2 div sub tipy tipdepth sub lineto tipspread 2 div tipfat 2 div sub pr tipx tipfat 2 div sub tipy tipdepth sub deltayw sub debug tailx deltaxs add taily tailfat 2 div sub debug tailx taily tailfat 2 div sub curveto tailfat pu tailx deltaxn sub taily tailfat 2 div add debug tipx tipfat 2 div add tipy tipdepth sub deltaye sub debug tipx tipfat 2 div add tipy tipdepth sub curveto tipspread tipfat sub 2 div pr closepath fill grestore } store %%%%%%% west tail, south tip %%%%%%% /fattailws { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tipx tipfat 2 div add tailx sub enthu mul store /deltaxs tipx tipfat 2 div sub tailx sub enthu mul store /deltaye taily tailfat 2 div add tipy tipdepth add sub enthu mul store /deltayw taily tailfat 2 div sub tipy tipdepth add sub enthu mul store tipx tipy mt tipx tipspread 2 div add tipy tipdepth add lineto tipspread 2 div tipfat 2 div sub pl tipx tipfat 2 div add tipy tipdepth add deltaye add debug tailx deltaxn add taily tailfat 2 div add debug tailx taily tailfat 2 div add curveto tailfat pd tailx deltaxs add taily tailfat 2 div sub debug tipx tipfat 2 div sub tipy tipdepth add deltayw add debug tipx tipfat 2 div sub tipy tipdepth add curveto tipspread tipfat sub 2 div pl closepath fill grestore } store %%%%%%% east tail, south tip %%%%%%% /fattailes { gsave aload pop /tipspread exch store /tipdepth exch store /tailfat exch store /tipfat exch store /taily exch store /tailx exch store /tipy exch store /tipx exch store /enthu 0.28 store /deltaxn tailx tipx tipfat 2 div add sub enthu mul store /deltaxs tailx tipx tipfat 2 div sub sub enthu mul store /deltaye taily tailfat 2 div sub tipy tipdepth add sub enthu mul store /deltayw taily tailfat 2 div add tipy tipdepth add sub enthu mul store tipx tipy mt tipx tipspread 2 div add tipy tipdepth add lineto tipspread 2 div tipfat 2 div sub pl tipx tipfat 2 div add tipy tipdepth add deltaye add debug tailx deltaxn sub taily tailfat 2 div sub debug tailx taily tailfat 2 div sub curveto tailfat pu tailx deltaxs sub taily tailfat 2 div add debug tipx tipfat 2 div sub tipy tipdepth add deltayw add debug tipx tipfat 2 div sub tipy tipdepth add curveto tipspread tipfat sub 2 div pl closepath fill grestore } store /debug {debugflag {gsave 2 copy black mt dot grestore} if } store /debugflag false store } store arrowcore % activate fat tale defs % sequence is [ tipx tipy tailx taily tipfat tailfat tipdepth tipfat] fattailsn % blu [6 2 1.5 5 1 2 1 3 ] fattailne % example % sequence is [ tipx tipy tailx taily tipfat tailfat tipdepth tipspread %%%%%%%%%%% % These code snippets do various things %%%%%%%%%%% /tinton1 {mark 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tintoff {mark 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /to {tinton1 aqua font6} store /tx {tintoff black font1} store /su {surl} store /webtintmat [ 0 1 5 {/a exch store 0 1 5 % webtint color array {/b exch store 0 1 5 {5 div b 5 div a 5 div} for }for } for ] def /setwebtint { abs cvi 216 cvi mod webtintmat % set 215 colors exch 3 mul 3 getinterval aload pop setrgbcolor} def /makered { mark 5 /setwebtint cvx ] cvx printlist exch 3 index exch put exch 1 add exch } store /makeblack { mark 0 /setwebtint cvx ] cvx printlist exch 3 index exch put exch 1 add exch } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% document specific resources start here %%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% % define url's to be generated ... ---> zzzzz <---- search marker %%%%%%%%% << %%% these have been redefined below all should now be 1fn or higher rather than fn1. /gilariver (https://en.wikipedia.org/wiki/Gila_River) /discoveryfn1 (http://www.tinaja.com/canal/field_notes/discoveryfn1.pdf) /ownership (http://gis.azland.gov/webapps/parcel/?loc=-109.7461,32.8033,12&layers=2,1,0) /goatfn1 (http://www.tinaja.com/canal/field_notes/goatfn1.pdf) /ledfordfn1 (http://www.tinaja.com/canal/field_notes/ledfordfn1.pdf) /marijildafn1 (http://www.tinaja.com/canal/field_notes/marijildafn1.pdf) /roperfn1 (http://www.tinaja.com/canal/field_notes/roperfn1.pdf) /kmlx (http://www.tinaja.com/canal/mapimage2.kml) /tbwestfn1 (http://www.tinaja.com/canal/field_notes/tbwestn1.pdf) /lowerfryeconstructfn1 (http://www.tinaja.com/canal/field_notes/lowerfryeconstructfn1.pdf) /deadmanfn1 (http://www.tinaja.com/canal/field_notes/deadmanfn1.pdf) /sandcanalfn1 (http://www.tinaja.com/canal/field_notes/sandcanalfn1.pdf) /fryecomplexfn1 (http://www.tinaja.com/canal/field_notes/fryecomplexfn1.pdf) /bluepondsfn1 (http://www.tinaja.com/canal/field_notes/bluepondsfn1.pdf) /hsfn1 (http://www.tinaja.com/canal/field_notes/hsfn1.pdf) /robinsonfn1 (http://www.tinaja.com/canal/field_notes/robinsonfn1.pdf) /allenfn1 (http://www.tinaja.com/canal/field_notes/allenfn1.pdf) /riggsmesafn1 (http://www.tinaja.com/canal/field_notes/riggsmesafn1.pdf) /golfcoursefn1 (http://www.tinaja.com/canal/field_notes/golfcoursefn1.pdf) /longviewfn1 (http://www.tinaja.com/canal/field_notes/longviewfn1.pdf) /freemanfn1 (http://www.tinaja.com/canal/field_notes/freemanfn1.pdf) /tranquilityfn1 (http://www.tinaja.com/canal/field_notes/tranquilityn1.pdf) /marijildafn1 (http://www.tinaja.com/canal/field_notes/marijildafn1.pdf) /mceniry (https://www.tinaja.com/glib/mtso.pdf) /allendamfail (http://www.tinaja.com/glib/allendam.pdf) /acme (http://www.mapper.acme.com/) /googleearth (https://www.google.com/earth/) /tranquility (http://www.azhotmineralspring.com/) /cottonclouds (http://www.cottonclouds.com/index.asp) /tbeastfn1 (http://www.tinaja.com/canal/field_notes/tbeastfn1.pdf) /mudspringsfn1 (http://www.tinaja.com/canal/field_notes/mudspringsfn1.pdf) /ockham (https://en.wikipedia.org/wiki/Occam%27s_razor) /blm (https://www.blm.gov/office/safford-field-office) /azstateland (https://land.az.gov) /anasazai (https://en.wikipedia.org/wiki/Ancient_Pueblo_peoples) /aqueduct (https://en.wikipedia.org/wiki/Aqueduct_(water_supply)) /AZrepublic (http://www.azcentral.com/news/articles/20130223arizona-hanging-canal-mystery.html) /bajada (https://en.wikipedia.org/wiki/Bajada_(geography)) /cnf (http://www.fs.usda.gov/coronado/) /association (https://en.wikipedia.org/wiki/Archaeological_association) /ccc (https://en.wikipedia.org/wiki/Civilian_Conservation_Corps) /glyphspair (http://www.tinaja.com/canal/cansum1.pdf) /grids (http://www.uapress.arizona.edu/Books/bid1582.htm) /gurgrm01 (http://www.tinaja.com/gurgrm01.shtml) /hohokam (https://en.wikipedia.org/wiki/Hohokam) /hunt (http://www.jstor.org/discover/10.2307/40035308?uid=3739552&uid=2&uid=4&uid=3739256&sid=21103435122901) /joanna (www.azcentral.com/opinions/articles/20130226editorial-admiring-our-forebears.html) /lefthand (http://www.tinaja.com/glib/lefthand.pdf) /maildon (mailto:don@tinaja.com) /mailneely (mailto:neelyja@utexas.edu) /mimbres (https://en.wikipedia.org/wiki/Mimbres_culture#Mimbres_culture) /mongollon (https://en.wikipedia.org/wiki/Mogollon_culture) /murphy (http://www.tinaja.com/glib/neely1.pdf) /newhang3 (http://www.tinaja.com/canal/newhang3.pdf) /tinsamp1 (http://www.tinaja.com/tinsamp1.shtml) /newhangshow3 (http://www.tinaja.com/canal/newhangshow3.pdf) /pinalino (https://en.wikipedia.org/wiki/Pinale%C3%B1o_Mountains) /prebajada (http://www.tinaja.com/glib/prebajada.pdf) /safford (https://en.wikipedia.org/wiki/Safford,_Arizona) /salado (https://en.wikipedia.org/wiki/Salado_culture) /scs (https://en.wikipedia.org/wiki/Natural_Resources_Conservation_Service) /stratigraphy (https://en.wikipedia.org/wiki/Stratigraphy) /tinaja (http://www.tinaja.com) /usatoday (http://www.usatoday.com/story/news/nation/2013/02/24/hanging-canals-whet-appetite-for-ancient-history/1941797) /waterlevel (http://en.wikipedia.org/wiki/Water_level) /whtnu15 (http://www.tinaja.com/whtnu15.shtml) /whtnu17 (http://www.tinaja.com/whtnu17.shtml) >> {mark exch /eurl cvx ] cvx def} forall %%%%%%%%%% % define fonts and main document gonzo params %%%%%%%%%% /setpagefontsold { /font0 /StoneSans-Bold 1.6 gonzofont /font1 /StoneSans 0.95 gonzofont /font2 /StoneSans [0.95 0 0.25 0.95 0 0 ] gonzofont /font4 /StoneSans 0.85 gonzofont /font3 /StoneSans-Bold 0.85 gonzofont /font6 /StoneSans-Bold 0.85 gonzofont /font7 /StoneSans-Bold 1.05 gonzofont % subheaders /font8 /StoneSans-Bold [0.65 0 0 0.65 0 0.4] gonzofont /font9 /StoneSans-Bold 1.05 gonzofont /cstretch 0.005 def /sstretch 0.005 def /txtwide 36 store /yinc 1.2 store /kern 0.1 store /texttop 51 store /textleft 3 store /amacro {(zy0) stringmacro /ypos ypos ypara add def} def % start drop cap /bmacro {(iFy1) stringmacro /ypos ypos ypara add def} def % finish drop cap } store /nogrid {true} store /ggnum (Tugood Canal Field Notes (rev 1)) store % header for pagenumber /pagenum 1 def % initial pagenumber %%%%%%%%%%%%%% % Image common code for sequential pages %%%%%%%%%%%%%% /imagecommoncode { /font6 /StoneSans [2.4 0 0 2.8 0 0 ] gonzofont /font7 /StoneSans 1.2 gonzofont /green { 0 0.4 0 setrgbcolor} store /black { 0 0 0 setrgbcolor } store % text image link [ /Rect [2.0 42.2 39 44.2] /Action << /Subtype /URI /URI imageurl >> /Border [0 0 0] /Color [1 1 1] /Subtype /Link /ANN pdfmark % gps image link [ /Rect [2.0 40.1 39 42.1] /Action << /Subtype /URI /URI acmegpsurl >> /Border [0 0 0] /Color [1 1 1] /Subtype /Link /ANN pdfmark % image image link [ /Rect [2 13.7 39 38.6] /Action << /Subtype /URI /URI imageurl >> /Border [0 0 0] /Color [1 1 1] /Subtype /Link /ANN pdfmark /blue {0 0 1 setrgbcolor} store % not sure why these are needed here /setblue {mark 0 0 1 /setrgbcolor cvx ] cvx printlist exch 3 index exch put exch 1 add exch} store /setblack {mark 0 0 0 /setrgbcolor cvx ] cvx printlist exch 3 index exch put exch 1 add exch} store 0 47.5 (|6|/green ) imagename mergestr cl 0 45 (|7|/green ) imagetitle mergestr cl blue 3 42.8 (|7|/setblue ) imageurl mergestr cl 3 40.6 (|7|/setblue ) imagegps mergestr cl black } store %%% Page Navigation Utilities %%%% % requires gonzo utilities from http://www.tinaja.com/gonzo.psl /kern 0.1 store /navpagenum 1 store /prevpage 1 store /lastpage false store /baux { save /ssnap exch store /sym exch store translate 0 0 mt 2 pu 2 pr 2 pd closepath gsave 0.94 0.94 0.98 setrgbcolor fill grestore 0.8 dup dup setrgbcolor line2 stroke 0.5 dup dup setrgbcolor /font1 /Helvetica 1.5 gonzofont font1 1 0.5 sym cc ssnap restore} store black /glyphnext { 53 (>) baux } store /glyphprev {53 (<) baux } store /glyphone { 53 (1) baux} store /glyphback {53 (<|k|k|k<) baux} store /aaaa { [ /Rect [0 53 2 55] /Page/Next /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [2.5 53 4.5 55] /Page prevpage /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark } store /bbbb { [ /Rect [0 53 2 55] /Page /Prev /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [2.5 53 4.5 55] /Page 1 /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [5 53 7 55] /Page/Next /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [7.5 53 9.5 55] /Page prevpage /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark } store /cccc { [ /Rect [0 53 2 55] /Page /Prev /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [2.5 53 4.5 55] /Page 1 /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark [ /Rect [5 53 7 55] /Page prevpage /View [/XYZ null null null] /Border [0 0 0 ] /Subtype /Link /ANN pdfmark } store /addpagenav { navpagenum 1 eq { 0 glyphnext 2.5 glyphback aaaa} if navpagenum 1 ne lastpage not and {0 glyphprev 2.5 glyphone 5 glyphnext 7.5 glyphback bbbb} if lastpage {0 glyphprev 2.5 glyphone 5 glyphback cccc} if /prevpage pagenum store /navpagenum navpagenum 1 add store} store % ///////// (A) WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color values /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them %%%%%%%%%%%%%%%% begin kml experiment %%%%%%%%%%%%%%%%%%%%%%%%%%% % this still needs a way for Chrome to go directly to Google Earth. % presently opens kml textfile instead. Chrome extensions not helping. % presently usable with this manual workaround: Do a save as from the % clicked kml text. Then click on the saved kml file. /clickforkml { true { save /ksnap exch store 34 53 translate 0 0 mt 2 pu 7.2 pr 2 pd closepath gsave 0.94 0.94 0.98 setrgbcolor fill grestore 0.8 0.8 0.8 setrgbcolor line2 stroke 0.6 0.6 (|6|/surl Click for KML |/kmlx ) cl ksnap restore } if } store % end kml link %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% actual page content starts here %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% % notebox uses modified roundpath %%%%%%%%%%%%% /notebox { % hpos vpos hsize vsize corrad titsize title body save /boxsnap exch store /body exch store /title exch store /titsize exch store /corrad exch store /hsize exch store /vsize exch store translate hsize 2 div 0 moveto 0 0 0 vsize corrad arct 0 vsize hsize vsize corrad arct hsize vsize hsize 0 corrad arct hsize 0 0 0 corrad arct closepath gsave 141 setwebtint fill grestore 54 pop 48 setwebtint line3 stroke hsize 2 div vsize titsize sub moveto 0 vsize titsize sub lineto 0 vsize hsize vsize corrad arct hsize vsize hsize vsize titsize sub corrad arct hsize vsize titsize sub lineto closepath 54 pop 48 setwebtint fill white font3 hsize 2 div vsize 1.5 sub title cc 1 2 3 4 black font3 hsize 2 div vsize titsize sub 1.5 sub body cc boxsnap restore } store % retained page sampler with nav % addpagenav % clickforkml % only for canal! % startnewpage /setred {mark 1 0 0 /setrgbcolor cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } store /setblack { mark 0 0 0 /setrgbcolor cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } store /kern 0.1 store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /startnewpage { showpage 20 20 10 setgrid /cstretch 0.0051 store /sstrecth 0.0051 store setpagefonts } store %%%%%%%%%%%%% /setpagefonts { /font0 /StoneSans-Bold 1.45 gonzofont /font1 /StoneSans 0.95 gonzofont /font2 /StoneSans [0.95 0 0.25 0.95 0 0 ] gonzofont /font3 /StoneSans-Bold 0.95 gonzofont /font5 /StoneSans 1.05 gonzofont /font6 /StoneSans-Bold 1.05 gonzofont /font8 /Courier 0.95 gonzofont /font9 /Courier-Bold 0.95 gonzofont /cstretch 0.005 def /sstretch 0.005 def /midgreen {61 setwebtint} store } store %%%%%%%%%%%%%%% support procs %%%%%%%%%%%%%% /pagenum 285 store % start sequence ONE LESS THAN FIRST /booktit (|2Applewriter Cookbook) store /curtit (|2Internal ProDOS Applewriter 2.0 Program Details) store /boiler { 129 setwebtint /pagenum pagenum 1 add store pagenum cvi 2 mod 0 ne { 0 56.6 font1 curtit cl 46 56.6 font1 pagenum 5 string cvs cr addpagenaveven }{ 0 56.6 font1 pagenum 5 string cvs cl 46 56.6 font2 booktit cr addpagenavodd } ifelse black } store /setred {mark 1 0 0 /setrgbcolor cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } store /setblack { mark 0 0 0 /setrgbcolor cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } store /setburp { mark 152/setwebtint cvx] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } store /kern 0.1 store /greenit { 1.5 1 mt 52 pu 45 pr 52 pd closepath 34 setwebtint fill 1.5 1 mt 52 pu 0.8 setlinewidth 61 setwebtint stroke 2.4 1 mt 52 pu 0.2 setlinewidth stroke 46.5 1 mt 52 pu 0.8 setlinewidth stroke 45.6 1 mt 52 pu 0.2 setlinewidth stroke } store /addpagenavodd {gsave 17.5 3.0 translate addpagenav grestore} store /addpagenaveven {gsave 28.5 3.0 translate addpagenav grestore} store /tabs [-2] store /to {tinton1 setburp font6} store /tx {tintoff setblack font5} store /normtop 54.7 store /normleft 3 store /normtextwide 43 store %%%% burpbox and friends /burpbox { % hpos vpos hsize vsize corrad titsize title body has contrasting title purple 2 strings save /boxsnap exch store /yinc 1.4 store /body exch store /title exch store /titsize exch store /corrad exch store /vsize exch store /hsize exch store translate hsize 2 div 0 moveto 0 0 0 vsize corrad arct 0 vsize hsize vsize corrad arct hsize vsize hsize 0 corrad arct hsize 0 0 0 corrad arct closepath gsave 208 setwebtint fill grestore 54 pop 152 setwebtint line3 stroke hsize 2 div vsize titsize sub moveto 0 vsize titsize sub lineto 0 vsize hsize vsize corrad arct hsize vsize hsize vsize titsize sub corrad arct hsize vsize titsize sub lineto closepath 54 pop 152 setwebtint fill white font3 hsize 2 div vsize 1.5 sub title cc 1 2 3 4 black font3 4 vsize titsize sub 1.6 sub body cl boxsnap restore } store /bluefig {gsave % xpos ypos width height proc just a blue box running a proc /proc1 exch store /fig exch store /bh exch store /bw exch store translate 0 0 mt bh pu bw pr bh pd closepath gsave 214 setwebtint fill grestore line3 192 setwebtint stroke black font2 0 -1.4 fig cl proc1 cvx exec grestore } store /beigebox { % hpos vpos hsize vsize corrad body beigebox rounded running text save /boxsnap exch store /yinc 1.4 store /body exch store /corrad exch store /vsize exch store /hsize exch store translate hsize 2 div 0 moveto 0 0 0 vsize corrad arct 0 vsize hsize vsize corrad arct hsize vsize hsize 0 corrad arct hsize 0 0 0 corrad arct closepath gsave 65 setwebtint fill grestore 15 setwebtint line3 stroke 2 vsize 1.6 sub 15 setwebtint body cl boxsnap restore } store << /dircut (/https://www.tinaja.com/whtnu17.shtml#d12.23.17) /ebooks (https://www.tinaja.com/ebksamp1.shtml) /awcb (https://www.tinaja.com/ebooks/awcb.pdf) /awcb_dc (https://www.tinaja.com/ebooks/awcb_dc.pdf) /awcb_dcps (https://www.tinaja.com/ebooks/awcb_dc.psl) /gonzotut (https://www.tinaja.com/glib/gonzotut.pdf) /linotype (https://en.wikipedia.org/wiki/Linotype_machine) /maildon (mailto:don@tinaja.com) /realbook (https://www.amazon.com/Apple-Writers-Cookbook-Don-Lancaster/dp/0672224607) >> {mark exch /eurl cvx ] cvx def} forall /amacro { setburp font6} store /bmacro {setblack font5} store %%%%%%%%%%%%%%%%%% actual pages start here %%%%%%%%%%% 30 setwebtint 50 50 10 setgrid save /intsnap exch store 0 -6 translate /yinc 1.18 store setpagefonts /txtwide normtextwide store black normleft normtop (|5 |h What follows in a partial and unfinished listing of a possible |/surl |6Director's Cut|/dircut |1 of our |/surl |6Applewriter Cookbook|/awcb |1. Its file is found |/surl |6here|/awcb_dc |1 and its sourcecode |/surl |6here|/awcb_dcps |1, with the original scanned AWCB |/surl |6here|/awcb |1 for comparison. Or the rare original sometimes |/surl |6here|/realbook |1. My director's cuts apply my |/surl |6Gonzo Utilities|/gonzotut |1 and Acrobat Distiller to fully restore |/surl |6Linotype era|/linotype |1 scanned books and articles to significantly beyond their former glory. Resulting in amazingly short file sizes ( often near 4K per page! ), mostly "perfect" error free typography, very "clear" and aligned improved backgrounds, and most artwork newly superb. Plus, of course, optional full URL links and brand new image magnifying clickthrus. And modern nav. All with surprisingly little rekeying. |/to But at a price of a steep learning curve and being labor intensive.|/tx |1As well as being inappropriate for legal documents or "Shakespearian" work. Other Director's cuts and more free eBooks appear |/surl |6here|/ebooks |1. We can |/surl |6consult you|/maildon |1on the Director's Cut techniques or do actual reconstruction projects for you. ) cl intsnap restore startnewpage %%%%%%%%%%%%%% page 136 %%%%%%%%%%%%%%%%%%%% /pagenum 135 store setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -5 translate 1 1.09 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store normleft normtop (|5 |h |/to Listing C.7|/tx summarizes the important entry points. A complete and detailed disassembly script appears in |/to Listing C.8|/tx . This one will tell you more than you could possibly want to know about every module in the working code. |h There's no single answer to the obvious question of "How does Applewriter work?" How you answer depends on what you think is important and where your interests lie. And any attempt to go through the code in numeric order is pretty much fruitless because you lose track of who is doing what to whom. |h Instead, let's see whether we can't thread together some of the important working concepts of this program. Our first concern should be the . . . |h |0|t|t |/setburp ProDOS MLI Links|5 |h The ProDOS used in ProDOS Applewriter 2.0 is totally stock in every way. The program is also installed in its normal space in high main RAM. |h All ProDOS access is by way of its MLI, short for machine language interface, because the klutzy and RAM gobbling BASICS.SYS is not used. To understand ProDOS, you will need the ProDOS Technical Reference Manual and Quality Software's Beneath Apple ProDOS. |h Let's see whether we can't give you a few hints. The usual LOAD, STORE, OPEN, etc. commands do not exist when using the MLI. Each time you want to access ProDOS, you do a machine language |/to JSR $BF00|/tx , immediately followed by a three byte data file. |h The first byte gives you the command, and the second two bytes point to a second data file needed to complete the command. The complexity of the file pointed to varies with the command. This second file typically involves less than a dozen bytes. |h Everything goes to or comes from ProDOS by way of the |/to JSR $BF00|/tx MLI interface. On the next page is a ProDOS command summary. More details appear in the various listings and in your tearing of the code itself. |h The ProDOS interface is far more uniform and far more flexible than was DOS 3.3e. For instance, the exact same command saves a text file, a BASIC program, or a binary file. The only difference lies in the attributes of the file at the time it is written. |h The tab and print constant files are loaded and saved as binary images, putting each in its respective slot in the work files. The glossary and WPL program files are treated similarly, except that they are text files and as before, are loaded into specific places in memory. In fact, the WPL loader does double duty as a glossary loader. |h The loader is simply tricked into putting what it reads in the wrong place when loading a glossary. These files are all read to or from main memory. ) cl grestore % pagefill adjust startnewpage %%%%%%%%%%%%%% page 137 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 0 translate 1 1.0 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 add store} store /yincadj {/yinc 1.24 store} store save /burpsnap exch store 12.5 17 22 37.3 0.8 2.3 (|6PRODOS MLI ACCESS COMMANDS) (|/yadj |h|/yincadj |5|1|/to $40|/tx - Allocate interrupt * |/to $41|/tx - Deallocate interrupt * |/to $65|/tx - Quit |/to $80|/tx - Read block * |/to $81|/tx - Write block * |/to $C0|/tx - Create |/to $C1|/tx - Destroy |/to $C2|/tx - Rename |/to $C3|/tx - Set file info |/to $C4|/tx - Get file info |/to $C5|/tx - Volumes on line |/to $C6|/tx - Set prefix |/to $C7|/tx - Get prefix |/to $C8|/tx - Open |/to $C9|/tx - Newline * |/to $CA|/tx - Read |/to $CB|/tx - Write |/to $CC|/tx - Close |/to $CD|/tx - Flush * |/to $CE|/tx - Set mark * |/to $CF|/tx - Get mark |/to $DO|/tx - Set end of file |/to $D1|/tx - Get end of file |/to $D2|/tx - Set buffer * |/to $03|/tx - Get buffer * |h |/to |6 *| |3- Not used by AWD.SYS ) burpbox burpsnap restore normleft 16.3 (|5 |h These are also total reads or saves, in which the entire file is loaded or saved at once. Your text files may or may not want to use a total load or a total save. |h Applewriter text files often get moved by one 512 byte sector at a time ont or off the disk. This gives an orderly way to search for the delimiters that can allow partial loads and saves. |h Moving one sector at a time also solves a memory management hassle because ProDOS will normally load or store into a buffer in main RAM. After searching or processing, all the needed pieces of the loaded or stored text are transferred to auxiliary RAM by the memory management code. |h Random access a sector at a time is done with the SET.MARK and READ.MARK commands. Appending is done similarly with the SET.EOF and READ.EOF commands. Generally, a file must be created, opened, read or written to, and finally closed. ) cl grestore % pagefill adjust startnewpage %%%%%%%%%%%%%% page 138 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -6.5 translate 1 1.12 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store save /burpsnap exch store 10.5 11 20 10 0.8 2.3 (|6Applewriter Ile Monitor Use ) (|5|h |j|6 |/to There ain't any.|/tx ) burpbox burpsnap restore normleft normtop (|5 |h A catalog display is done using |/to GET.FILE.INFO|/tx . This gets handled by routines internal to Applewriter. Files are locked or unlocked by changing the file attributes and then using |/to SET.FILE.INFO|/tx . Files are deleted with |/to DESTROY|/tx . |h |/to [O]|/tx options are unique to ProDOS. |/to Each ProDOS disk must have a prefix.|/tx Unlike the volume name everyone ignored in DOS 3.3, this prefix must be remembered and available at all times. You also cannot change a disk in a drive without also changing the prefix. A |/to SET.PREFIX|/tx command exists. As we saw in Chapter 6, a one key glossary entry can greatly ease prefix setting hassles. |h The |/to [O]-F|/tx option is used to list the prefixes of the volumes on line. Because ProDOS has no init code, the volume formatter gets a separate program called |/to FORMATTER|/tx and installs it from $0800-17FF in main RAM. This code module then gets run, doing an init for you. The same module also completely and destructively overwrites the glossary, your WPL file, and any footnotes in use. |h You use the final |/to [O]-J|/tx option to set Ile modem or printer parameters. What happens is that the baud rate, start and stop bits, parity, etc., are coded in a proper form to set the 6551 serial interface chip in the Ile. The Ile Tecnical Manual gives full details. |h Unlike earlier versions of this code, you should have no problems when installing ProDOS Applewriter 2.0 onto virtually any hard disk. This happens because the operating system used is totally standard and the program is completely unlocked and movable. |h Nuff said on ProDOS. Let's go on to\274 |0|t|t |/setburp Monitor Access|5 ProDOS Applewriter 2.0 monitor use is nonexistent.. ) cl normleft 10.8 (|5 |h ProDOS Applewriter 2.0 uses zero monitor routines. |/to None at all!|/tx The ROM never gets switched into the high memory area. All of the key getting, disk accessing, and character outputting is done internally to Applewriter. The good news here is the total control you ) cl grestore % pagefill adjust startnewpage %%%%%%%%%%%%%% page 139 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler /tabs [-1.5 -1.5 ] store save /burpsnap exch store 10.5 1.8 22 17 0.8 2.3 (|6Applewriter Internal COUT ($9E,9F) ) (|5 |t 1. On a .pd0 print to screen Points to $4415 screen code. |h |t2. On a .pd1 or .pd2 Points to I/0 space as adjusted by the interface card or circuit. |h |t3. On a .pd8 print to disk Points to $4397 disk write code. ) burpbox burpsnap restore gsave 0 -1 translate 1 1.03 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store normleft normtop (|5 |h get with a built in type-ahead buffer, screen lines up to 240 characters wide, controllable scrolling both vertically and horizontally, ease of output routing, and lots more. |h The bad news is that some parallel cards on the IIe expect normal use of normal monitor routines. In particular, the IIe does not use location $24, in which many parallel printer cards demand to find some horizontal cursor position information. |h As we have seen, |/to custom patches are needed to handle these problem cards|/tx when using version 2.0. A partial fix is available with the 2.1 update. |h Add-on video cards usually will not properly access Applewriter because all screen output characters are handled internally. In fact, these cards are all carefully disconnected by Applewriter as part of the cold startup process in AWD.SYS. |h Actually, with horizontal scrolling to 240 characters, nothing special is needed in the way of character display. To further prevent tampering with the internal Applewriter routines, the usual keyboard input hook |/to KSWH|/tx and |/to KSWL|/tx ($38 and $39) are set to point to a "brick wall" RTS and then are studiously ignored. |h The CSWH and CSWL character output hooks ($36 and $37) are not forgotten. Instead, their primary and only use is to let a serial or parallel interface card adjust them slightly for proper printing. |h Ferinstance, if you set this printer hook to $C100 and send a $00 NULL to the interface, the interface will usually reset the hook to $C105 or something similar. |h ProDOS Applewriter 2.0 uses this hook only to get the interface card started and set to the right I/0 address. The card then grabs the corrected address for its own internal use. |h Characters are output by an internal and protected version of the usual $FDF0 (Fideyfoo) COUT hook. This output is handled by a pointer pair at $9E and $9F on page zero that handles the internal COUT destination setting. |h Applewriter's internal COUT can point several possible places . . . ) cl grestore % pagefill adjust startnewpage %%%%%%%%%%%%%% page 140 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store % /pagenum 140 store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -3 translate 1 1.07 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store normleft normtop (|5 |0|t|t |/setburp Memory Management|5 |h As we have seen, your text files are in auxiliary memory while everything else stays in main memory. Text files are accessed by some code down on page one that does not change as the memory is switched between main RAM and auxiliary RAM. Routines in main RAM that need to read the text file do so via these page one access links. |h Remember that the auxiliary RAM text file is really two files. |/to LOFILE|/tx starts off at $0801 and builds up, and |/to HIFILE|/tx starts at $BDFE and builds down. $FF markers define the beginning of LOFILE and the end of HIFILE. |h The open ends of both files face each other across all the remaining empty space. These open ends are identified with $00 markers. LOFILE holds everything from the start of the message up to |/to one less|/tx than the current cursor position. HIFILE holds everything from a cursed character to the last character in the file. |h |/to Characters are normally entered into the top of LOFILE|/tx . All of the characters will be entered as low ASCII, but another routine carefully re-marks each end of each screen line with a high ASCII character instead. Most of the usual routines enter things to the top of LOFILE. Others will pass a character from LOFILE to HIFILE to back up the cursor. Yet others will pass a character from HIFILE to LOFILE to move the cursor forward. [B] and [E] are extreme examples. |h Several pointers access the text file. These pointers include LOCURS and HICURS, which point to the open ends of LOFILE and HIFILE. You will also find a screen pointer that starts at a point in LOFILE equal to the top screen line, advances through LOFILE to the cursor, then automatically switches to HIFILE to continue. The screen pointer keys on high ASCII characters to count screen lines. |h A printer pointer is used to scan through LOFILE to get characters. Because everything is moved to LOFILE before printing, no switch to HIFILE is needed by this pointer. A general use pointer pair accesses either LOFILE or HIFILE as needed. |h Another specialized pointer |/to ($AE,AF)|/tx will back up automatically to get the first high ASCII character that this pointer finds. This character locates the start of any screen line and can be useful for both screen formatting and tabbing. |h These pointers all work by switching to read auxiliary RAM, getting a needed value, then immediately switching back to read main RAM. Certain other routines will write to auxiliary RAM by switching to it, doing a store, then switching back to main RAM. |h Note that the writing routines can be in main RAM without a conflict. Only the reading routines must be in a portion of the memory that is not switched between main and auxiliary RAM. |h Otherwise, as soon as the main-auxiliary switch is flipped, the op codes being read vanish. As we have seen, no switching into the monitor ROM even takes place. Nor is auxiliary page zero or auxiliary high RAM ever activated. ) cl grestore % remove page adjust startnewpage %%%%%%%%%%%%%% page 141 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -8.5 translate 1 1.17 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store normleft normtop (|5 |h |0|t|t |/setburp Character Entry|5 |h No use is made of the monitor KEYIN routine. If you tried using KEYIN with a different word processor, you probably would drop keystrokes during any hectic typing times. |h Instead, ProDOS Applewriter 2.0 uses its own internal routine to get keystrokes. This routine includes a 64 key type-ahead buffer. If your typing gets ahead of the processing, up to 64 keystrokes are saved in a pair of storage buffers. |h The main keystrokes are saved to the character buffer at $1D40, and [open apple] and [closed apple] keystrokes are separately saved to the apple buffer at $lFC0 to $1FFF. |h Remember that|/to the apple keys as well as the main keystroke must be saved|/tx , or the computer would not handle certain functions correctly. Two round-and-round pointers keep track of where you are in the key buffer. |h A filling pointer $F3 and an emptying pointer $F2 take care of this task. |h During non-hectic times, the filler and the emptier stay together, and the keystrokes should get immediately used. At other times, the filler gets ahead, and characters are saved to the buffer. Routines that take lots of time automatically check the keyboard every now and then to make sure nothing gets missed. |h |/to A busy signal I (|j*|j) prompt appears on the normal status display when busy.|/tx |h As we saw a while back, characters can still get missed every now and then if a sloppy typist, a bug in the keyboard encoder, and the slower insertion mode all gang up on the key buffer. The buffer seems to be working perfectly when characters are lost. The buffer access is what fouls up the works. |h Reviewing, characters can be gotten directly from the keyboard during non-hectic times and otherwise gotten out of the type ahead buffers when things happen too fast. |h Several other character sources exist, in addition to the user. Down on page zero is a special WPL and glossary activity flag $0F. Bit #7 or the MSB |/to N|/tx slot of this flag controls WPL activity, and Bit #6 or the |/to V|tx slot controls glossary activity. |h If the glossary is active, the character is gotten from the glossary file. Similarly, if WPL is active, the character is gotten from the WPL program file. |h Sometimes the WPL file will involve itself with its $A-$D strings. If WPL and these strings are active, the $A-$D string becomes the source for the next character to be used. You'll find a separate string activity flag at $F6 to handle $A-$D activity. |h Sometimes you want to use a string already in the machine, such as the |/to =|/tx filename or something else that has been previously formatted or put together. A special string flag ) cl grestore % pagefill adjust startnewpage %%%%%%%%%%%%%% page 142 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -3 translate 1 1.08 scale % adjust for weak page fill /tabs [-2 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store 10.5 16 27 17 0.8 2.3 (|6SOURCES OF KEYSTROKES) (|/yadj |h |5|t1. Directly from the user during non-hectic times. |h |t2. Indirectly from the user via a type-ahead buffer. |h |t3. From the glossary during glossary activity. |h |t4. From the WPL program during its active use. |h |t5. From the $A-$D strings in WPL if used. |h |t6. From an old string already in the keybuffer. ) burpbox normleft normtop (|5 $AD exists for such cases. If this string flag is set, the old string, which is usually in the key buffer at $0200, is used one character at a time. If the string flag is cleared, new characters are gotten from the user, the type-ahead buffer, the glossary, WPL, or the $A-D flags. |h Yet another source for strings of characters exists. When doing a [Q]-I, you can receive its characters directly from a modem or by way of a modem buffer that scan dave incoming characters during hectic times. This access bypasses the usual key-getting routines. |h ProDOS activities, such as loads and stores, completely bypass any key getting routines and usually put their values directly where they belong. If searching for delimiters is needed, it is done one 512 byte sector at a time by way of a user buffer at $8900. |h The majority of the word processor's time consists of patiently waiting for the user to input a new keystroke. Regardless of a keystroke's source, after that keystroke is received, it gets filtered for control and cursor motion commands. If a valid command is found, it is carried out. If not, the character is entered to the top of LOFILE. |h Summarizing . . . ) cl normleft 15 (|5 We have seen that several sources of keystrokes are available, all of which can be handled internally by the code. User input is accepted directly or is stashed in a pair of buffers if the processor is busy. Characters can also come from the glossary, from WPL, or from a WPL $A-$D string if the controlling flags are set properly. |h Sometimes, an old string will be reused instead of getting new input. And finally, all your characters can come directly from the modem or by way of its type-ahead buffer, and thus bypassing the usual key getting routines. |h Now for some details on the \274 ) cl grestore % for page adjust startnewpage %%%%%%%%%%%%%% page 143 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 -3 translate 1 1.05 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.2 sub store} store normleft normtop (|5 |0|t|t |/setburp SCREEN DISPLAY|5 |h The screen display has some very sneaky and complicated code associated with it. First note that |/to you can turn the screen off and on with flag $F7|/tx . Leaving the screen off speeds up WPL operation considerably. Naturally, seeing what you are doing when the screen is off is tricky. A screen that is turned off is useful, though, to display WPL menus, prompts, and a few other operations. |h Before a screen display is updated, any routine that messes with the text files will reformat the screen lines in that file. Reformatting is done by backing up two lines from the cursed position and then counting how many whole words will fit on a line. Each line stops either on a carriage return or when the line does not have enough room for the next word. |h At that point, a marker character, usually an $0D carriage return or an $20 space, will get changed to a high ASCII $8D or $A0 and restored to the text file. All older and lower ASCII characters are erased from the text file. The process continues forward through the text file until a carriage return is found that is already correctly formatted. |h Note that anything two lines before the current activity had to be correct already, thanks to previous reformatting. Everything beyond the next carriage return is also correct. Only the mess in the middle needs straightening out. The entire text file is reformatted after a margin altering [A], after loading, after printing, and any other time that something really major happens. |h Completely reformatting a long text file may take you several seconds. The upshot is that, before a screen update, all of LOFILE and all of HIFILE have end of screen line markers that are properly placed to end each line on a whole word. |h The cursor usually stays on the middle line of the active screen. Should the screen overflow, everything will scroll up one line. Should it underflow, everything will back down one line. During insertions, characters get turnstiled as far as they have to in order to reach the next carriage return. To update the full screen, the screen pointer pair $88,89 backs up 12 lines, which is usually 12 inverse ASCII characters from the top of LOFILE. |h Characters are removed from LOFILE and put on the screen up to your cursed location. Immediately beyond LOCURS, the pointer is moved to HICURS, and the code continues filling in characters from HIFILE until 12 more lines are completed. |h The flashing you see on the cursed character is purely your imagination at work. For the service routine that awaits a keystroke patiently flips the cursed character on the screen between low and high ASCII. Sometimes that character is left as an inverse low-ASCII marker. An example is the cursor on the nonactive side of the split screen. |h Note that |/to the large and empty no man's land between LOCURS and HICURS is |/to bypassed|/tx . The lowest character in HIFILE ends up at the cursed location. Note also that the alternate character set will get used here, which has no flashing characters available. Low ASCII characters appear as inverse text. ) cl grestore % page adjust % bowwow startnewpage %%%%%%%%%%%%%% page 144 %%%%%%%%%%%%%%%%%%%% setpagefonts /txtwide normtextwide store /curtit (Tearing into ProDos Applewriter Version 2. 0) store /yinc 1.15 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill /tabs [-3 -1.5 ] store /yadj {/ypos ypos 0.4 sub store} store (\n\n\ncstretch is now ) cstretch 10 string cvs mergestr == 10.5 24.5 24 14 0.8 2.3 (|6SCREEN UPDATES) (|/yadj |5|t1. Before any screen update, low ASCII markers |t|tare placed at the end of each text file screen. |h |t2. Everything before the cursor on the screen |t|tcomes from |/setburp |3LOFILE|1. |h |t3. The cursed character and everything beyond |t|t comes from |/setburp |3HIFILE|5.) burpbox normleft normtop (|5 |h Only the active half of the screen is updated on a split screen. The inactive half of the screen remains static, remembering things the way they were. |h If the wraparound flag $El is not active, characters will get put on the screen wall to wall without regard for word breaks. Only a 79 character line gets used because room must be left for the optional column 80 carriage return display. |h A user prompt is sometimes needed at the bottom of the active screen. To print a prompt on the screen, three lines are erased, and the prompt is placed on the middle line. Prompts are normally read as needed out of the reference file area. Service subs are built into the screen code for the live cursor screen motions, line motions, line clearing, and scrolling. |h Another summary\274 ) cl normleft 22 ( |5Things get more complex if you are using a right margin wider than 78 columns. |h In this case, not all of the screen line can be displayed. A special stash is used to calculate the offset needed between the previous end of screen line marker and the actual screen starting text character. This offset is automatically added when finding text file characters to go on the screen. |h As long as the cursor stays near the middle of the screen, no change is made in the offset. If the cursor gets left of the twelfth character, offset is decremented, giving an apparent horizontal scrolling of one character to the left. Should the cursor end up right of the sixty eighth character, the offset is incremented, giving you an apparent horizontal scrolling of one character to the right. |h The display will start with its left margin LM value in column zero, which will produce an apparent what-you-see-is-what-you-get display, as long as the screen width is less than 78 characters total. For the most exact display, be sure to use |/to [|jtab|j]\/tx rather than PM |/to values for all of your paragraphs|/tx . Note that all screen lines will be justified flush left even if a wide left margin is used. |h Note also that breaks on whole words only are required on lines wider than 78 characters. |h ) cl grestore % pageadj startnewpage %%%%%%%%%%%%%%%%%%%%%%% page 145 %%%%%%%%%%%%%%%%%%%%%%% setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.15 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill normleft normtop (|5 |h We now know something about how ProDOS works, how the monitor can be used, where the characters come from, how they are managed, and just how the screen update works. |h Next are the\274 |0|t|t|/setburp Individual Control Commands|1 |h|/black Let's run down the control command list, seeing roughly what each command does. For more detail, check Listing C.8 or your own disassembly listing and cross reference list. |h |a[@]|b is really a |a[delete]|b, recoded to $80 from its default value of $FF. This command will unconditionally knock out LOFILE's uppermost character and replacing it by using a $00 marker. The command then backs LOCURS up one character. |h |a[A] |bis the command to alter the screen margins. If the characters per line are less than 78, the left screen margin is set to appear in column zero. If the characters per line are more than 78, the left screen line is first set to center the cursor if possible. As the cursor gets moved within 12 characters of either the left or right margin, horizontal scrolling will be activated. Screen lines are marked by setting the last character to high ASCII. |h |a[B]|b moves all the characters from LOFILE to HIFILE, placing the cursor at the beginning of the text. When finished, LOFILE will be completely empty, and HIFILE will hold the text being processed. |h |a[C]|b changes the case flag, initially from none to U or later from U to L or back from L to U. When characters are entered, this flag is checked. If active, uppercase or lowercase is forced as chosen. The flag is reset on all cursor motions except the left and right arrows. These arrows let you capitalize or lowercase as many characters in a row as you want. Only real letters are changed. |h |a[D]|b toggles the data direction flag between < and > . If a [W] or [X] is specified with a data direction of >, words or paragraphs are restored. If < is the data direction when [W ] or [X] are specified, words or paragraphs are deleted. The data direction flag also will set the direction of a search or search and replace. |h |a[E]|b moves all the characters from HIFILE to LOFILE, placing the cursor at the end of the text. When completed, HIFILE is completely empty, and LOFILE holds all of the text. |h |a[F]|b does either a search or a search and replace. Delimiters are interpreted, substituting special ones if used. Then the text is searched using the $98, 99 pointer pair. If you want to make a replacement, text is moved from HIFILE to a work buffer and the replacement is made. Various options substitute for fake carriage returns, allow repeats for all occurrences, let you use wild cards, and provide any length capabilities |h |a[G]|b either sets up or reads the glossary. If a valid read, the glossary flag is set. If set, characters are gotten from the glossary work file until the next carriage return. At that time, the glossary flag is cleared. If the flag is a *, the glossary is emptied by placing a zero at the glossary start location $1BOO. If the flag is a ?, the end of the glossary is found and the new definition is entered that ends with a carriage return and a $00. The glossary has a nest that works like a subroutine and remembers up to eight of the return pointers. This nesting picks back up on the caller when the callee is finished. ) cl grestore % pageadj startnewpage %%%%%%%%%%%%%%%%%%%%%%% page 146 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.15 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill normleft normtop (|5 |h |a[H]|b is the left arrow. When it is the only key pressed, it backs up one location by moving one character from LOFILE to HIFILE. When used with [closed apple], the left arrow (H) does an express-by-word backspace, continually backing up until the first space is found. With [open apple], the left arrow saves a character to the swallow buffer instead of HIFILE and increments the round and round swallow buffer pointer $AC. |h |a[I]|b moves the cursor to a tab. The present position since the last carriage return is first calculated. A test then gets made to see whether any valid tabs exist beyond the present position. If so, spaces are added to the top of LOFILE to move to the next tab position. If [closed apple] happens to be down, the cursor is moved without space padding so that the characters are tabbed over without being moved. Tabs are permitted anywhere. |h |a[J]|b is the down arrow. When it is the only key pressed, it moves characters from HIFILE to LOFILE, repeatedly frontspacing until one line is moved. Each succeeding line ends with a high ASCII marker. With [closed apple] and if enough text is left, the down arrow goes forward 12 whole lines. |h |a[K]|b is the up arrow. It moves characters from LOFILE to HIFILE, repeatedly backspacing until one line is moved. Each preceding line ends with a high ASCII marker. With [closed apple], the up arrow tries to go backward 12 whole lines if enough text is available. |h |a[L]|b is the load command. Loading can be from the text file, which is really a copy command, or from ProDOS. Loading from ProDOS is first done via a one sector, 5 1 2 byte buffer at $B900 in main RAM. After scanning for any needed delimiters, the characters are transferred to the top of the LOFILE text file area in auxiliary RAM. Text is entered just beyond the present screen position. Alternate delimiters provide for all occurrences, wild cards, and fake carriage returns. An option exists to load only to screen. |h |a[M]|b is the carriage return that ends each command. This command is not available for other uses, although you can fake a glossary carriage return with a \) and a search for a carriage return with a special delimiter, such as >. |a[N]|b is the new command. Because this command can be deadly, you are given a prompt that needs a Y answer. If you are serious about destroying your text file, this command adjusts the HIFILE and LOFILE pointers so that nothing is in either HIFILE or LOFILE and your cursor is sitting at the beginning of LOFILE. The old material is not erased, except for the first character. All that happens is that the first character gets replaced with an open-end-of-file $00 marker. |h |a[O]|b is the DOS access menu. The menu is displayed and a selection is gotten. On a catalog command, a GET. FILE. INFO is done for the directory. The catalog formatting is internal to Applewriter. Locking and unlocking are done by reading, then changing the attributes of a file. Renaming, deleting, setting prefixes, finding volumes on line, or making a subdirectory are done directly with their respective ProDOS commands. Initing a new disk is done by loading a separate formatting program, then jumping to that program. The formatter destructively overwrites the glossary, WPL, and any footnotes. The printer commands are a set of internal routines that let you set the baud rate, word length, stop bits, and parity on a Ile. This routine also defeats video echo and suppresses any carriage returns that may be generated by the interface hardware. |h ) cl grestore % pageadust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 147 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.15 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill normleft normtop (|5|h |h |a[P]|b updates the print/program file or carries out a WPL command. A valid two-character, print/program value is converted to hex and entered in the correct slot in the file. Absolute values are entered as such. Relative values are added to or subtracted from the old value. Two's complementing is used for subtraction. On TL and BL entries, the string is placed in the correct file. On UT, the underline token is saved. On NP, CP, and WPL commands, the selected command is completed. [Q] accesses the additional functions menu. Binary tab and print/program values are loaded or saved as called for, using the ProDOS MLI. All of these values go in their respective stashes in main memory. |h |a[Q]|b accesses the additional functions menu. Binary tab and print/program values will get loaded or saved as called for, using the ProDOS MLI. All of these values go in their stashes in main memory. Glossary or WPL loads and saves are done similarly. The carriage return toggle sets or clears a display flag. The status toggle is identical to [esc] and may be replaced with something useful. Connecting printer to modem gives you a limited way to type directly to your printer. More importantly and more usefully, this selection also lets you send or receive text files over a modem. A submenu on the [Q]-I selection lets you activate these modem features, such as recording incoming modem data or filtering control commands. The Quit option provides for an orderly exit to some other ProDOS system application program. Quitting includes reconnecting all disconnected video cards, and closing out current ProDOS activity in an orderly way. |h |a[R]|b toggles the replace mode flag $F5. When in the replace mode, a character is deleted from HIFILE before each character entry, then the new character is entered into the top of LOFILE as usual. The combination of deleting the cursed character and entering another character at the cursed position gives the illusion of replacing the old character. Replace mode is aborted on most cursor motions. |h |a[S]|b is the save command. On any save, the entire text is first moved to LOFILE. Then all or delimited portions of the text are moved to a sector buffer in main RAM at $B700. Full sectors are transferred to disk as they are filled. Should appending be needed, ProDOS markers are set to allow adding to the end of an existing file rather than overwriting. |h |a[T]|b sets or clears tabs. On a purge, the entire tab file is cleared to all zeros. On a Clear, only one pair of tab entries is set to zero. On a Set, 64 tabs are allowed. A tab status display is updated, causing set tabs to appear inverse and all cleared tabs to appear normal. Although the status display only goes to 240 columns, tabs themselves can exceed this number. |h |a[U]|b is the right arrow or frontspace. When it is the only key pressed, it moves the cursor forward one location by moving one character from HIFILE to LOFILE. With [closed apple}, the right arrow does an express-by-word frontspace, continually going forward until the first space is found. With [open apple], the right arrow retrieves a character from the swallow buffer instead of from HIFILE, placing the character in the top of LOFILE, and decrements the round and round swallow buffer pointer $AC. |h |a[V]|b toggles the verbatim flag $72. With this flag set, all control characters except [M] or [V ] are entered directly into the text file. This allows imbedded control characters for such things as special printing or typesetting commands. With the V flag cleared, control characters are used in their normal manner. ) cl grestore % pageadjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 148 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.15 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill normleft normtop (|5 |a[W]|b inserts or deletes a whole word. On < , a word is saved to the word and paragraph deletion buffer starting at the first open spot available. Characters are removed from the top of LOFILE and placed into this buffer until either a space or an empty file is found. On > , a word is recovered from the word deletion buffer, putting the characters in the top of LOFILE and stopping on a space. A round and round pointer pair $94,95 keeps track of positions in the deletion buffer. A deletion counter prevents buffer overflow. |h |a[X]|b is similar to [W] but [X] inserts or deletes an entire paragraph, keying on a carriage return rather than a space. On [W] and [X], if [closed apple] is used, the word or paragraph is saved to file but not deleted. This is most useful for copying short blocks of text. |h |a[Y]|b is the screen splitting switch. On a [Y], the split screen is set up, using only 12 lines per display rather than the usual 24. One side of the split screen is active at a time. The other side is a static display of the way things were. Pointer $F8 decides which side is active. On a [Y] with a split screen, control flips over to the other screen side by toggling $F8. On a [Y], the pointer is cleared, allowing the normal full screen display. |h |a[Z]|b toggles the wraparound flag at $El. Wraparound is always present in the text file since each screen line ends with a high ASCII marker. If this flag is active, the screen update code ends each line on these markers. If wraparound is not necessary, characters are put on screen as they occur, stopping at 79 screen characters. The character slot to the extreme right is always reserved for a possible carriage return symbol, whether or not it is used. Note that full word breaks must be used if more than 80 columns are active. |h |a[|j_|j]|b calculates the page/position display. This routine is cumbersome and slow but also is most useful. Because operation is too slow for real time, you must toggle [_] only when you want specific page/position information. The routine works by counting carriage returns and comparing them to the printable lines per page. The total carriage returns are divided by the printable lines per page. The result gives you the page, and the remainder gives you the position on the final page. The need for division causes the slowness. |h We aren't quite through with control commands because I have saved two of the heavies for last. As a reminder, we are scanning through the various features of this program to see roughly what they do. Much more detail is found in Listing C.8 and in your own torn disassembly and cross reference. Our first heavy is \274 |0|t|t |/setburp Printing|5 |h|/black Applewriter 2.0 printing routines are part of the machine-resident editing code rather than a separately loaded disk module. In Applewriter, you have a choice of four possible print destinations. You can print to a real printer to get a hard copy. Or print to a modem or a special Ile plug-in card. You can print to the screen to see exactly what your printed text will look like, or you can print directly to a disk text file. |h The last option gives you a document in final form, without any imbedded commands, that looks exactly like the document to be sent to the printer. Printing to pd8 is particularly useful when you are typesetting, need camera-ready copy, require multiple columns, want multiline headers or footers, or are transmitting between two different computer brands. If anything seems like it cannot be done with Applewriter, chances are that a trip through pd8 land will bail you out one way or another. Once you decide what you want, WPL can make results invisible and automatic. |h ) cl grestore % pageadjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 149 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 0 translate 1 1 scale % adjust for weak page fill normleft normtop (|5 One gotcha: Be sure to have a unique filename for your pd8 images! Otherwise pd8 files will get mixed up with your files that contain embedded commands and will royally foul the works. I often use a generic ZZZ for any temporary use of a pd8 file. Print destination is specified with the pd command. A pd0 outputs to the screen for WYSIWYG previews. A pdl dumps to a printer card in the selected slot. Rarely a pd2 or pd4 could be used to dump to a modem or some other special card. A pd8 dumps directly to the disk. |h Printing begins by moving everything to LOFILE with a [E] command. The printing pointer pair $90,91 then moves up through the text file by starting at $0801 and grabbing one character at a time. Pages are formatted using the print/program values, such as top margin, left margin, right margin, bottom margin, page numbers, etc. At the beginning of the first page, the pn page number is saved to the running page counter pair at $BE,BF. The default left and right margins are saved as well. This way, the top and bottom line formats will stay the same throughout the document. The top line, if used, is formatted and printed first. This is done by reading three delimited pieces out of the top line file and then moving them to a work area where the page number can be substituted. |h Each left, center, or right piece is moved to a line buffer that has been previously filled to all spaces. The left piece starts at the left. The center piece starts half way across minus half the length of the center text. The right piece begins shy of the right margin by its length. After the top line, the top margin padding is put down, followed by the body of the page. The body is formatted and printed one line at a time, allowing for paragraph margins or outdents on the first line in each paragraph. Each line begins by getting enough characters out of the text file to fill the line. |h As the characters come in, they are filtered for imbedded commands and for footnotes. lmbedded commands start with a carriage return followed by a period followed by two or more letters. If these commands are found, the printing will stop long enough to let the imbedded command do its thing. For instance, on an .lm + 5 command, printing halts momentarily. The left margin is retrieved, decimal five is added to it and then the left margin is replaced. The new left margin value will be picked up on the next line. |h Any command that Applewriter does not recognize is treated as printable characters. This leads to the shortline problem. We have seen a STRETCHIFIER patch described in Chapter 6 that cures this hassle. Characters are also filtered for footnotes, which begin with the I< command. If footnotes are found, they are stored in the footnote buffer at $1400, and the footnote flag $FE is set. This flag is incremented once for each footnote. |h The very first footnote knocks two counts off the available number of printed lines. Any additional footnotes knock off one extra line. This gives a space between the bottom body line and the first footnote line. At print time, any user separators (_) are automatically converted to NULL commands. That conversion works fine if you need NULLs for an old Epson. It is terrible if you need a user separator for a daisywheel HMI command, a modem activity command, or for expanded printing on some newer dot matrix printers. A fix for this is described in Chapter 6. ) cl grestore % pageadjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 150 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 -8 translate 1 1.15 scale % adjust for weak page fill normleft normtop (|5 |h At any rate, characters are gotten and filtered until enough whole words are entered to fit between the left and right margins. These characters are placed into your line formatting buffer at $lC00. That line is then justified. Should left justification be in use, nothing more is done. All of the words remain flush left. |h If center justification is in use, the length of the entered characters is subtracted from the line width. This new length is halved and then that number of spaces is used to off set the characters in the line buffer. If right justification is in use, the length of the character string is subtracted from the line width, and that number offsets the characters in the line buffer. In any of these three modes, you end up with the buffer holding the line justified in the correct position. |h Spaces are added as needed before the center justified and right justified text. Spaces are not needed beyond any text because the carriage return completes your entry. A row of printed spaces looks the same as the unprinted page, so trailing spaces are not needed. |h On the fill justification of a long line, the needed number of padding spaces is calculated. Text is then moved one space to the right, beginning with the first space and repeating as often as needed to force the fill justification. |h Microjustification is not available inside stock Applewriter. Instead you can use imbedded commands to tell an intelligent printer to microjustify for you. Naturally, if your printer has full microjustification available internally, your text will look much better than text justified by whole spaces. As we've seen, the enhanced Diablo 630 microjustifies beautifully. |h Regardless of the justification mode, all of the characters end in the correct place in the line justification buffer. When the justified line is output for printing, it is preceded by enough spaces to make the left margin. On first paragraph lines, the pm value is used to adjust the needed number of leading spaces. |h As the line is printed, the characters are filtered for the underline token. Should this token appear, it is replaced with a space, and an underline mode flag $E0 is toggled. Underlining is done by printing the underline character and then backing up one space and printing the character to be underlined. Such underlining will not work on certain very old or otherwise primitive dot matrix printers. |/to The printer must be able to recognize the |/to $88 ASCII backspace command for this type of underlining.|/tx |h As we have seen, |/to underline is best left to the printer|/tx . This is done by imbedding suitable commands to turn the printer's underliner on and off when needed. As many lines as are asked for are put in the body of the text. When finished, any footnotes are recovered from the footnote buffer and printed. ) cl gsave % for page adjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 151 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 -4 translate 1 1.05 scale % adjust for weak page fill normleft normtop (|5 They are followed by the bottom line padding, and, if used, the bottom line. Note that the stock program allows only a single top or bottom line. However, with some repeated trips through |/to .pd8|/tx land, you can have any number of top and bottom lines. You can also single space the headers and footers while double spacing your main text, as well as using even or odd headers. |h Good old |/to .pd8|/tx will also let you do space-and-a-half and similar tricks. Printing continues until all of LOFILE has been printed. At that point, a new file can be loaded and a new cp continue printing command can be given, picking up exactly where you left off. |h The same running page number and current margin settings are kept. On the single sheet option, printing halts at the bottom of the page long enough for you to change paper. |h By the way, if your Ile printer card does not defeat video echo, it will trash the screen and might slow things down, particularly at higher serial baud rates. Your Ile serial interface automatically defeats any screen echo when you set the printer interface with [O]-J. As a reminder, special patches may be needed for intelligent Ile printing cards. |h You will, of course, get the best printing with an intelligent printer or a typesetter that accepts imbedded commands and can do its own proportional spacing, boldface, italics, shadow printing, and microjustification. |h So much for printing. The real biggie is \274 |0|t|t |/setburp WPL|5 |h WPL is a supervisory language that looks like a cross between PASCAL and assembler. Its intended use is as an executive controller that will handle long and involved tasks for you. Obvious uses are printing a multiple file book chapter having the correct headings and footings, customizing a mailing to a separate address list, counting words, putting down menus, prompting operators, building an index, etc. But it's the non-obvious uses of WPL that boggle the mind. |h The amazing thing about WPL is how much is done with how little. The additional code needed is rather short and compact. I have used WPL to insert or remove the line numbers from assembly code and to picture process strings sent to a plotter. |h I have used WPL to trick a printer into doing camera-ready copy and to handle automatic formatting. I have also used WPL to create high level graphic images. I am convinced that |/to WPL is far more powerful at processing pictures|/tx than it is at words. Others have even written adventures in WPL. |h WPL interfaces beautifully with Postscript, the typesetting language that is used on the Laserwriter. We already saw how to use WPL to completely format a document for full bells and whistles superior quality printing. ) cl grestore % pageadjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 152 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 -1.5 translate 1 1.03 scale % adjust for weak page fill 12 43 26 8.1 0.65 (|6|h If you do not both thoroughly know and aggressively |kuse WPL, |kyou are passing up up at least 98 percent of all of the good stuff you can do with Applewriter!) beigebox 16.7 35 15 5.3 0.65 (|6 So get with it. Now!) beigebox /wplformat { gsave 1 2.2 translate font0 152 setwebtint 2 8 (GETFILE L ZORCH,D! <|jCR|j>) cl 204 setwebtint gsave 10.3 7.7 translate [0 0 0 -3 .5 1.5 1.3 3] fattailsn grestore gsave 23.5 7.7 translate [0 0 0 -3 .5 1.3 1.5 3] fattailsn grestore gsave 5 9.3 translate [0 0 0 3 .5 1.5 1.3 3] fattailns grestore gsave 17 9.3 translate [0 0 0 3 .5 1.5 1.3 3]fattailns grestore black 7.5 13.7 (|1The |/to LABEL|/tx when used goes here to identify this line for a WPL jump or subroutine.) cc 21 13.7 (|1The |/to OPERAND|/tx if used provides a filename or more opcode content.) cc 7 5 (|1 The |/to OPCODE|/tx |1 always follows the |jfirst space and |jis always treated as if it were a control character. The "L" shown acts as the [L] loading command. ) cc 21 5 (|1Lines always end with a |/to CARRIAGE RETURN|/tx . When the operand |jis not in use, |kyou might add a few comments.) cc grestore } store 10 10.5 29 19 (|2|k|kFig. 7.4. A WPL command line is similar to assembly source code.) /wplformat bluefig normleft normtop (|5 The message is whelming. WPL is super powerful and important. Without this language, Applewriter may have some second rate competition. With WPL, that's all she wrote\274) cl normleft 42.5 (|5 And your hidden secret message is\274) cl normleft 34.5 (|5 Figure 7.4 summarizes a WPL instruction. Each WPL instruction is one line long and ends with a carriage return. Lines are done normally in the order they are found in a WPL program although several important exceptions exist.) cl normleft 8 (|5 Each WPL line may begin with a label. The label must not have any spaces. If a label is used, it lets WPL find a certain line for possible jump or subroutine access. |h If a label is not used, |/to a space must be the first character on a WPL line|/tx . Either way, the first character after the first space in a WPL line gets treated as if that character were a ) cl gsave % reposition startnewpage %%%%%%%%%%%%%%%%%%%%%% page 153 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 -1.5 translate 1 1.03 scale % adjust for weak page fill normleft normtop (|5 control character. WPL then behaves just like you typed that control character from the keyboard. For instance, the WPL interpreter would see a line that is made up of a space followed by a B as a |/to [B]|/tx and would move the cursor to the beginning of the screen. |h Although WPL lets you use lots of spaces for pretty printing, you can run out of program room real fast if you try this. Thus, most non-trivial WPL programs are usually done in a compact and hard to read form. Nearly anything you can do at the keyboard, WPL can do for you, automatically, potently, and without errors. |h You can think of WPL as a high level language that is extremely good at editing any long strings of characters and acting on them plus being a disk and printer supervisor. |h So what is WPL and how does it work? To answer, we will first need a way to write a WPL program. Because |/to a WPL program is nothing but some processed words|/tx , you write your WPL program on Applewriter, just like any old text file, and save it to disk. |h One WPL command is called |/to do|/tx . To run your WPL program ZORCH, you simply enter |/to [P] |/to do ZORCH|/tx . That is all there is to it. The do code first clears all the various WPL flags and work areas. This code then loads the named program into a WPL program file starting at $1000. WPL length can be 1024 characters with footnotes or 2048 characters without. |h Note that |/to you can beat the 1K or 2K character limit so that your WPL program |/to can end up arbitrarily long|/tx You chain any number of WPL programs together end to end with do commands. |h You can also use one main WPL supervisory program to control several others. The others return back to the supervisor after carefully setting a variable or two to tell the supervisor where the program left off. Variables are preserved whenever WPL programs are chained or otherwise linked together. |h The do command also sets the WPL activity flag $DF so that keystrokes will be read from the WPL file rather than from the keyboard. |/to When the WPL flag is set, the first line |/to of the WPL program is read|/tx . If a label is present, it is passed over, and WPL finds the first character beyond the first space or string of spaces. |h This character is converted into a control command and gets processed just the way any control characters entered from the keyboard would be. Any remaining characters on the line are used as needed by the control command. Ferinstance, a filename might follow an L for |/to [L]|/tx oad, but a search and replace string might follow a F for|/to [F]|/tx ind. |h |/to The WPL lines are read one at a time|/tx , usually in sequential order. Each line terminates with a carriage return. Your final WPL line ends with the $00 marker, which stops WPL and returns control to the keyboard. WPL has jumps and subroutines. The WPL command go will start at the beginning of the WPL file and search for a label. On the jump command, that label is found and the program unconditionally jumps to that line and then continues. The WPL command |/to sr|/tx does almost the same thing for subroutine access. The only major difference is that a return address is remembered on a WPL stack at $1D00, along with a ) cl gsave % for page adjust startnewpage %%%%%%%%%%%%%%%%%%%%%% page 154 setpagefonts % prev page must be present /txtwide normtextwide store /yinc 1.21 store boiler gsave 0 -1.5 translate 1 1.03 scale % adjust for weak page fill normleft normtop (|5 stack pointer $92 that remembers where to return to. Returning is done whenever a RS command is found. Subroutines can be nested to a depth of 32. |h |/to WPL has three numeric variables|/tx named (x), (y), and (z). Each could range from 0 to 65535. Any time an (x) is found, the value assigned to (x) will be substituted, and the same goes for (y) or (z). You can set these numerics to any value, either absolute or relative. |h |/to You can easily test a numeric for zero|/tx . With some hassle, you can also test a numeric for most any nonzero value. For instance, psx45 places a decimal 45 into (x). psx7 sets (x) unconditionally to decimal seven. A command of psx + 7 adds seven to whatever was already in (x). |h Most importantly, the command psx-1 decrements a counter loop involving (x) by a single count. The numerics are really nothing but print/program values and are stashed in the print/program file, such as Im or ut. See Listing C.3 for the exact locations. |h |/to Substitutions are done at the time the WPL line is interpreted|/tx . WPL has string variables. Four of them are named $A through $D. These are stashed in the work files that start at $1|kE00. Just like the numerics, the strings are substituted for their symbols at the time the WPL is interpreted. |h Strings may be loaded from memory or disk with the |/to ls|/tx command that is assigned to an immediate value with the as command and compared with the |/to cs|/tx command. You can check Listings C.3 and C.8 for more details. |h During disk access, the |/to is|/tx load string command borrows an unused portion of the text file immediately above LOCURS out in no man's land. Because the $A-D strings are allowed to be at most 64 characters long, there is little danger of crashing into HICURS, except on a nearly full text file. |h String loader is done in the text file run to give all of the powerful loading options to WPL strings that the usual text loads receive. After use, the string above LOCURS is zeroed out so that this string does not end up becoming an unwanted part of your text file. |h |/to WPL has conditional execution.|/tx This is an absolutely essential feature of any computer language. The next WPL statement is skipped if a numeric reaches zero, if [F]ind cannot, if [L]oad will not, or if sc does not compare. The skipped statement is usually a jump, or a subroutine call, or a program quit. Thus you can make a test and cause WPL to pick two different routes, depending on the result of that test. |h |/to WPL interacts with the user.|/tx You can clear the screen or print fixed screen messages with your |/to ppr |/tx command. You can get a string from the user with a pin command. The display can be turned on with the pyd command and off with the pnd command. An off display computes much faster, besides holding the last prompt or message for you. |h A pep command in WPL enables the printer if its value is not zero. You use this command to print only the page you want in the middle of a document. To accomplish this, put an |/to .ep0|/tx at the start of your document and an |/to .epl|/tx where you want the printing to start. ) cl grestore % page adjust startnewpage %%%%%%%%%%%%%% page 286 %%%%%%%%%%%%%%%%%%%% /pagenum 285 store % start sequence ONE LESS THAN FIRST /tabs [-2] store setpagefonts boiler greenit % 0 50 showgrid 0 setwebtint 2.7 54.0 (|3Listing C.9-cont\274) cl 6.5 52.3 ( |t|9$3358-33A9 -- UPDATE TAB STATUS IMAGE |h|8 Fill the tab image $B600-B6FF with all dots. Write a 1, 2, 3\274 etc to each tenth position, using the 6502 in its |9DECIMAL(!)|8 mode. Write a suitable "fives" marker to each five slot, with a single quote for 5-95, an exclamation point for 105-195, and vertical bar for 205-235. Mark set tabs by scanning the tab address file. Complement the character in the tab image for each set tab. |t|9$33AA-33B2 -- INIT POINTERS AND FLAGS |h|8 Init LOFILE. Init HIFILE. Adjust screen margins. Fall through to next module. |t|9$33B3-33C5 -- INIT FLAGS |h|8 Set for normal data line. Use wraparound. Update entire screen; no bottom prompt. Do not display page/position. Set data direction to "<". Reset case and verbatum flags. |9|t$33C6-344E -- MAIN WORD PROCESSING ENTRY |h|8 Reset stack. Init flags. Reset busy flag. Turn screen on. Update HICURS pointer. Update LOCURS pointer. Reformat screen margins. Unsplit screen. If startup flag is set, then get and run startup WPL routine, and update print values. Either way, fall through to next module. |9|t$33Fl-344E -- MAIN WORD PROCESSING SERVICE LOOP |h|8 Set $FDmemory load flag. Set not copy $77 flag to not copy Clear load string flag $79 to allow user input. Clear $71 main memory source. If type ahead buffer is not empty, and if not slave modem mode, then update the screen. If WPL is not active, and if string flag $AD not set, then reset the string flag, get user response, and redo the loop. Read the keyboard. If an [esc] and if WPL is active and if not in a WPL subroutine, then quit WPL and repeat the main service loop. Get user character. Get help if open-apple or ?. Reject all NULL $00 characters. If a delete key, do the deletion. Otherwise, process character and repeat loop. |t|9$344F-348D -- FILTER CHARACTER |h|8 If WPL but not glossary, process character as if it were a control command. Bypass control testing if [V]. Force low ASCII and process as control command if control command. Reset case flag. Process carriage return as control command. Reset the page/position display flag $78. Send the character to both file and screen. Reformat screen markers. ) cl startnewpage %%%%%%%%%%%%%% page 287 %%%%%%%%%%%%%%%%%%%% boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 52.5 ( |t|9$348E-34C3 -- FILTER CONTROL COMMAND |h|8 Force control code and hold locally to $C2. Test reformat flag $CD and reformat screen if set. If an [esc] key, toggle the data display and exit. Turn replace flag $F5 off unless [R]. Zero mystery flag $ED. Set main utility pointer to start of control command prompt file. Scan the control prompt file, going one past each "[" seeking a match to current control character. If a match is found, remember twice its position in the list to the X register. If no match found, quit on end $00 marker. Use the X register position pointer to pick an address pair. Shove this pair on thestack, and do an RTS, using the forced sub return method to do an indirect jump to the intended control function. Note that the jump goes to the forced address |9PLUS ONE|8. |t|9$34F9-3528 -- SPLIT SCREEN SETUP |h|8 If WPL is not active, clear the bottom of the screen and put down the (Y] user prompt. Get user response and clear prompt. Forceupper case. If a "Y", turn split screens on.If a "N", turn split screens off. If a carriage return, swap screens only if [Y] is already active. |t|9$3529-3533 -- SWITCH TO OTHER SPLIT SCREEN |h|8 Abort if [Y] is not active. Switch screens by changing the "V" slot of $F8 from one to zero, or vice versa. Jump to screen pointer fixer. |t|9$3534-353F -- TURN SPLIT SCREEN ON |h|8 Force [Y) flag to split screen on, lowerscreen active. Set the split screen pointer $F9,FA to present LOCURS position Jump to screen pointer fixer. |t|9$3543-354E -- TURN SPLIT SCREEN OFF |h|8 Abort if WPL is active. Reset split screen flag to $00 for one full screen. Jump to recalculate the vertical screen. |t|9$354F-357D -- FIX SPLIT SCREEN POINTERS |h|8 Update the screen. Exit if split screen is off. Check which split screen is active, and calculate VPOS position, using $00 for the top screen and $QC for the bottom screen, twelve lines down. Save the static cursor position to $98,99. Save present LOCURS cursor position to $F9,FA. Move characters from HIFILE to LOFILE or vice versa as needed to get to the desired point in the file.Init LOFILE on underflow. ) cl startnewpage %%%%%%%%%%%%%% page 288 %%%%%%%%%%%%%%%%%%%% boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 52.0 1 sub ( |t|9$357E-3593 -- CALCULATE SCREEN WINDOW |h|8 If upper split screen, set window top at $00 and window bottom at $0C. If lower split screen, use $0C and $18. If full screen use $00 and $18. Set horizontal cursor to left. BASH tha vertical screen address. |t|9$3594-359£ -- TOGGLE DATA LINE DISPLAY |h|8 Advance the $ES data display flag to its next of three possible values, with $00 being no display, $80 being the usual HEM-LEN-POS display, and $CO being the tab display. |t|9$359F-35AD -- TOGGLE WRAPAROUND MODE |h|8 Abort with ding dong if the screen right margin is not set to 80 characters, since broken words are only allowed on a full screen display. If a full screen display, change the $El wraparound flag either from or to its $00 whole words, or its $FF broken words setting. |t|9$35AE-35BS -- TOGGLE CARRIAGE RETURN DISPLAY |h|8 Change the $74 carriage return flag from or to its $00 normal display or $FF show returns as an inverse "M".. |t|9$35B6-35BC -- TOGGLE VERBATIUM FLAG |h|8 Change the $72 [V]erbatium flag from or to its $00 normal use or its $FF imbed control characters directly. |t|9$35B0-35C2 -- PROMPT SCREEN BOTTOM ANO GET RESPONSE |h|8 Short code link to first prompt the screen bottom and then get the user response. |t|9$35C3-3508 -- FORMAT FILENAME ANO PRINT TO SCREEN |h|8 Clear and prompt screen bottom. Print the old filename to the screen. Get any user changes to the filename. Abort on a "'?" for catalog or a carriage return. If the "=" filename is to be used, scan the old filename to the first comma, and then copy the keybuffer beyond the comma. If a new filename, transfer the entire filename. Zero out the rest of the filename buffer. Bold the filename length to $E9. |t|9$360B-3623 -- CLEAR ANO PROMPT SCREEN BOTTOM |h|8 Abort if WPL is active. Clear bottom of screen. Print the selected control command prompt to screen, stopping on the first space. Then print a "·" to the screen. ) cl % /lastpage true store % do not omit! startnewpage %%%%%%%%%%%%%% page 289 %%%%%%%%%%%%%%%%%%%% boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 53.0 ( |t|9$3624-3637 -- SET CURSOR FOR BOTTOM WINDOW |h|8 Set HPOS to zero. Set VPOS to 9 lines from window top if split screen, or 21 lines from window top if full screen. Make room for three lines, usually a blank line, a prompt, and a second blank line. BASH VPOS. |t|9$3638-3646 -- CLEAR BOTTOM OF SCREEN |h|8 Set cursor for window bottom. Clear window if not WPL. Increment and BASH VPOS. |t|9$3648-366B -- SAVE TEXTFILE SETUP |h|8 Zero save/adjust flag $3647. Use auxiliary memory as file source by setting $71. Save the old filename to the "=" buffer. Print old filename to user prompt. Get any user changes to the filename. If a "?", then catalog disk and restore old filename, and try again. Abort on a carriage return. On any other filename, fall through to next module. |t|9$366C-36C9 -- SAVE ENTIRE TEXTFILE TO DISK |h|8 Set $AD flag to use old filename. Read the last character in the filename. If "+" then set the Append flag $E2 and zero the "+" out of the filename. If not, clear $E2. Copy LOCURS to $98,99, remembering present cursor location when finished saving. If adjust, bypass processing that follows. If save, filter filename for special delimiters. If found, process via next module. Move cursor to end, putting everything in LOFILE. Save file to disk. Update screen markers. Reset old string flag and adjust flag. Move characters from LOFILE to HIFILE to restore old cursor. |t|9$36CA-3726 -- SAVE PART OF TEXTFILE TO DISK. |h|8 Process special delimiters. Zero last delimiter. Save the present cursor position to auxiliary utility pointer. This transfers to the actual disk write routines as a starting address. Begin moving characters from HIFILE to LOFILE, one at a time.Compare each character against the first delimiter string character. If no match, keep scanning characters. If a match try to match next character in the delimiter string. Substitute carriage returns and bypass wildcards as needed. If no perfect match, abort by moving all the characters back to the original LOCORS position, and then restoring the old filename. If match found, write to disk, using $AE,AF to mark the start of save stuff, and $84,85 LOCURS to mark the end. Then update the screen markers, reset the string flag $AD, move everything back to the original LOCURS position, and restore the old filename. ) cl %/lastpage true store % do not omit! startnewpage %%%%%%%%%%%%%% page 290 %%%%%%%%%%%%%%%%%%%% boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 53.5 1 sub ( |t|9$3727-3747 -- SET FILENAME COUNT |h|8 Move the filename at $8700 into the filename hold at $1F00, carefully shifting everything one to the right to make room for the length count. Count only numerals, letters, commas, and periods, stopping on any control command or any other punctuation. Save the length count to $1FO0. |t|9$3784-377C -- WRITE TEXTFILE TO DISK SETUP |h|8 Force entire file to low ASCII. Abort if an adjust, rather than a save. Find length by subtracting LOCURS from the aux utility pointer $AE, AF. Open filename. If append, set mark via MLI. If not append, set end of file via MLI. Save as many sectors to disk with next module. Close file. |t|9$377D-37DC -- WRITE ONE SECTOR TO DISK |h|8 Read first character of the portion of the text file to be saved into $B900. Continue copying until no more characters needed or until buffer fills at 512 characters. On each buffer fill, write a new disk sector. Read aux or main memory per flag $71, using aux memory for normal save. Save length to data buffer. Exit via ProDOS error processor. |9|t$37DD-37F8 -- CLOSE FILES |h|8 Enter at $37DD to close all files. Enter at $37E5 to close one file. Poke file reference number to MLI buffer, using $00 for all files, and the number on any one file. Close files with a ProDOS Close MLI. Reset buffer to close all. |t|9$37F9-380B -- ProDOS GET EOF MLI |h|8 Find the length of the currently open file, reporting to the buffer at $380C. Load the registers with the possible 24 bit length result, with X = MSB (normally zero) Y = middle 8 bits, and A= LSB. |t|9$3811-3830 -- ProDOS SET MARK MLI |h|8 Copy the reference number from set mark to get EOF. Save new end-of-file marker from X register MSB (usually zero), Y register middle eight bits, and Accumulator LSB. Set mark MLI, for the new endpoint to the file. Used for Append. |t|9$3831-387C -- POSTFIX SLOT AND DRIVE SETUP |h|8 Abort if the first character in the filename is not a comma or period. Zero the slot and drive stashes at $38D3, 38D4. Read the filename. Force upper case. If a slash is found, hold distance to slash in $38D4, and fall through to next ) cl % /lastpage true store % do not omit! startnewpage %%%%%%%%%%%%%% page 291 %%%%%%%%%%%%%%%%%%%% boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 52.0 1 sub ( |8module. If nothing beyond comma or period, also fall through to next module. If D for drive, insert O for drive 1 or 1 for drive 2 into $38D3 MSB. If a .s for slot, force range to 0-7 and shift to put $38D3 into ProDOS DSSS 0000 format. |t|9$387D-38D5 -- POSTFIX SLOT AND DRIVE |h|8 Check the DSSS 0000 stash. If slot zero, force slot six instead. Get volume name from Prooos on-line MLI using this slot and drive. Truncate to sixteen characters max, loading into $B900 pathname buffer. If a postfix exists, append it onto the path name. Add a slash to the start of the pathname, and Then move the pathename to the $1FOO buffer. Count the characters in the pathname and save to $1FOO. |t|9$38D6-38ES -- FIND PATHNAME OF INTENDED SLOT AND DRIVE |h|8 Store the DSSS 0000 in the accumulator into the MLI buffer. Do ProDOS On-line MLI to load name of disk in target drive into path name buffer at $B900. Exit to error processor. |t|9$38E6-38FD -- OPEN TEXT FILE |h|8 Calculate filename length and save to $1FOO. Use $04 text file and reference number $01.Open file via ProDOS Open MLI. Transfer reference number other MLI links . Get EOF of current file and save to EOF stash at $3918 (low), $3919 (med), and $391A (high). |9|t$391B-3928 -- ProDOS SET EOF MLI |h|8 Reads the current open file and appends the current end position. Position must have been pre-poked into $3926 (low), $3927 (med), and $3928 (high). Exit to error proc. |t|9$3929-3949 -- PROCESS SPECIAL DELIMITERS |h|8 If the usual "/" delimiter that does not allow any fancy stuff, put an $01 into $EC, the any length stash, an $02 into $EB the fake carriage return stash, and an $03 into the $EA wildcard stash. If a special delimiter is used, put the next higher ASCII character into $EC, the next one after that into $EB, and the next one after that into $EA. For instance, a "<" delimiter will have an any length "=", a fake carriage return ">", and a wildcard "?". Note that four ASCII characters follow each other in sequential order. |t|9$394A-398D -- LOAD SETUP |h|8 Hold current LOCURS position in $BA, BB formatting pointer. Set the old string flag $AD to $FF. Set the memory load ) cl % /lastpage true store % do not omit! startnewpage %%%%%%%%%%%%%% page 292 %%%%%%%%%%%%%%%%%%%% /lastpage true store % do not omit! boiler greenit % 0 50 showgrid 0 setwebtint /tabs [-2] store 3 54.5 (|3Listing C.9-cont\274) cl 6.5 51.0 1 sub ( |8flag $71 to $FF for a load into auxiliary memory. Save old filename to the "=" file. Force normal case and load rather than append, and included delimiters. Print filename to user prompt and get any changes, saving new filename length to $E9 stash. Read the last filename character and compare it to UT, usually a "\" for screen-only load. If a screen only load, zero the symbol and set the screen-only flag $FD. If a question mark as the first character, do a catalog and try again. If a carriage return, fall thru to cleanup. If a legal filename, fall thru tothe next module. |t|9$398E-3A0E -- LOAD PROCESSING |h|8 Zero out the three delimiter stashes at $A2-A4. If the first character is a "#" for copy from memory, then set the copy from memory flag $77. Scan the filename for delimiters. If If found, then process special delimiters, and zero the final delimiter out of the filename. If delimiters exist, scan the filename and save positions to $A2-A4. If delimiters exist, check the final character for "A" or "N". If "A", set all occurance flag $D2. If "N", set exclude delimiters flag. Set up disk or memory read. If no delimiters, read directly to textfile from textfile or disk. If delimiters, fall thru to next module. |t|9$3A0F-3AAB -- LOAD WITH DELIMITERS |h|8 Get first character from $B900 buffer and hold to the line justify buffer. Read load string. If a wildcard, get next character. If a fake carriage return, substitute a real carriage return. Compare for a match. If no match, get next character. If a match and if delimiters to be included, then continue matching and put first delimiter into memory. Continue reading characters, watching for second delimiter if present. If third delimiter is present and delimiters are to be omitted, swallow end delimiter string from textfile to swallow buffer. If no third delimiter, read characters till end of file. If all occurance flag is set, repeat search for new first delimiter string as often as needed. Fall through to load cleanup module below. |t|9$3AAB-3ACA -- LOAD CLEANUP |h|8 Close file. If load to screen only, put down return prompt. Restore old filename if it exists in the "=" file. Reformat screen margins. ) cl /lastpage true store % do not omit! startnewpage startnewpage % EOF