home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / asp / part01 / README < prev   
Encoding:
Text File  |  1991-10-16  |  12.8 KB  |  380 lines

  1. *** Documentation for "asp v3.2, The .plan description language"
  2. (c) Alec Muffett, September 1991
  3.  
  4. As detailed in the demonstration programs (just type 'make'), this is
  5. "asp", Alec's Scrolling Program, a diddy little hack I put together to
  6. finish a war over who could make the longest, best, and prettiest
  7. ".plan" files, using only the printable ascii character set.
  8.  
  9. Asp is a simplistic description language for carriage-return based ascii
  10. animations, as commonly found in ".plan" files when you finger someone.
  11. It is simple to use, so large, smooth, neat animations can be built
  12. quickly and easily, and with a lot of room for imagination.
  13.  
  14. The language is crude, I haven't put together a decent lexical analyser,
  15. there is no real parser as such, to whit, it is a realio trulio hack, as
  16. stated before.
  17.  
  18. The language divides roughly into three sections: boring effects,
  19. special effects, and directives.  A good idea of how they work can be
  20. obtained from the demo files supplied with this distribution, but here's
  21. a little primer anyway:-
  22.  
  23. *** Primer
  24.  
  25. Asp works by reading a "asp program" which is full of "rules" and
  26. "data".  A "rule" line is made up of a series of "commands", all of
  27. which begin with a "." character.  With me so far ?
  28.  
  29. So, for example, a "rule" line might look like:-
  30.  
  31. .clear .p .p .show .p .p
  32.  
  33. Since the commands all begin with a dot, the rule line begins with a dot
  34. also.  Any line which begins with a dot in an asp program is assumed to
  35. be a "rule" line.  If a rule line is too long for convenience's sake, it
  36. may be broken with a backslash at the end of the line, in the same way
  37. as in C and shell scripts, eg:
  38.  
  39. .speed 2 \
  40. .object his -30 40 \
  41. .object dreams, -50 44 \
  42. .object computer -15 22 \
  43. .object he -2 58 \
  44. .object ? -250 61 \
  45. .object can 89 31 \
  46. .object have 100 35 \
  47. .object can 111 52 \
  48. .object A 150 20 \
  49. .object 't 200 55 \
  50. .anim .resetanim .p .p .p .nl
  51.  
  52. - is a single rule line.  When a valid rule line is encountered, it is
  53. stored in memory and becomes the "current rule".
  54.  
  55. Next, Data lines.  Any non-blank line which is not a rule line, is a
  56. "data line".  When a data line is encountered, asp applies all the
  57. commands specified in the current rule to the data line, and then moves
  58. onto the next data line. eg:
  59.  
  60. .show .nl
  61. Hello World!
  62.  
  63. Will print the line "Hello World!" (.show), and throw a linefeed (.nl).
  64.  
  65. Blank lines in an asp program are ignored, and so, on occasions, dummy
  66. data lines must be supplied to asp in order to get a rule to do
  67. anything.  The traditional dummy line consists of two hyphens on a line
  68. of their own, eg:
  69.  
  70. .p .p .p
  71. --
  72.  
  73. Invokes the Pause function (.p) three times.  If there were no dummy
  74. line before the next rule was specified, the command would be ignored.
  75. Note that the Pause function does not print anything on the standard
  76. output, so the appearance of the line is not changed.
  77.  
  78. Similarly, the command:
  79.  
  80. .p .p .p
  81. --
  82. --
  83. --
  84.  
  85. Invokes Pause nine times, three times for each dummy line.
  86.  
  87. Next, asp internals.  Asp pinches an idea from the curses library, in
  88. that it stores a copy of what the current output line looks like, and
  89. then prints only the differences between the current line and what you
  90. want it to look like.  This "optimised refresh" improves on how an asp
  91. program looks when you view it, and also on the size of the output file
  92. asp generates compared to other scrolling programs.
  93.  
  94. You should also note that asp does not begin processing of a program
  95. until it encounters the first "rule line".  Up to that point it behaves
  96. in the same way as the 'cat' program, copying the program to stdout.
  97. This allows you to embed a lot of plain text in your program before you
  98. start scrolling things about.
  99.  
  100. *** Undercoat
  101.  
  102. The above gives a fairly simple introduction to how asp works. Now for a
  103. description of commands in detail.
  104.  
  105. The asp commands break down into three rough types: Boring effects,
  106. Special effects, and Directives.  Some of these take arguments, which
  107. are either VALUES, BOOLEANS, or STRINGS.
  108.  
  109. Values are basically any integer quantity, positive or negative.
  110.  
  111. Booleans are the same as values, where 0=FALSE and Non-0=TRUE.
  112.  
  113. Strings are continuous sets of characters which do not contain
  114. whitespace (I haven't bothered in putting an escaping mechanism for
  115. spaces yet.)
  116.  
  117. There may be a problem if you specify a string as an argument to a
  118. command, and the string happens to begin with a dot - asp will, at some
  119. point, try to treat it as a command.  Don't worry about this, it will
  120. probably work out okay, and I'll fix it in due course.
  121.  
  122. Finally, please note that asp uses only columns 0->78 of the screen,
  123. because some terminals will wrap immediately you write a character into
  124. column 79, and this spoils the fun...
  125.  
  126. IMPORTANT: Asp does not expand TABs in asp programs.  Run your program
  127. through "expand" before feeding it into "asp".
  128.  
  129. *** Topcoat
  130.  
  131. Here is a list of asp directives and effects, their function and arguments:
  132.  
  133. -------------------------------
  134. DIRECTIVES AND BORING EFFECTS:-
  135. -------------------------------
  136.     .clear
  137.  
  138. Wipes the current line clear and refreshes it, so as to put a blank line
  139. on screen.
  140. -------------------------------
  141.     .wipe
  142.  
  143. Wipes the current line clear without refreshing it, so that the next
  144. command does not have to worry about the mess left by previous lines.
  145.  
  146. This command is probably best tagged onto the beginning of every rule
  147. where you do not want to have to specifically overstrike anything that
  148. was left by the previous rule & data.
  149. -------------------------------
  150.     .nl
  151.  
  152. Throws a newline.  Please note that the default action of asp once it
  153. has acquired a rule it to print EVERYTHING without newlines, so you must
  154. be explicit about where you want them.
  155. -------------------------------
  156.     .show
  157.  
  158. Does a .wipe and then prints the current line on screen.  This is the
  159. most basic of the output primitives, and you will probably use this a
  160. lot.
  161. -------------------------------
  162.     .p
  163.  
  164. Generates a pause in the display by firing approximately 2Kb of carriage
  165. returns at your screen (roughly 1 second at 9600 baud).  See also
  166. ".speed" below. 
  167. -------------------------------
  168.     .noop
  169.  
  170. Does bugger all.
  171. -------------------------------
  172.     .flush
  173.  
  174. Is a nice one.  It deletes the current rule from asp's memory, so it's
  175. behaviour is once again like 'cat' (check the 'Undercoat' section,
  176. above).  This means you can embed small bits of asp code in any text
  177. file, without having to modify the rest of the file to get it through
  178. the asp processor.  Do NOT forget to invoke ".flush" with a dummy data
  179. line, though:
  180.  
  181. This is a bit of cat'ted text.
  182. .speed 3 .spatter .p .p .p .nl
  183. This is a somewhat longer bit of asp'ed text
  184. .flush
  185. --
  186. This is another bit of cat'ted text.
  187.  
  188. - ok ?
  189. -------------------------------
  190.     .smooth BOOLEAN
  191.  
  192. Switches on 80-character smoothing mode.  This is useful where you are
  193. going to be scrolling small bits of text back and forth across the
  194. screen.  If you do not have smoothing on, asp will generate code which
  195. will make the object move faster towards the left hand side of the
  196. screen.  This is due to the optimised refresh code mentioned above.
  197.  
  198. If smoothing is swithched on (".smooth 1"), asp pads out (with carriage
  199. returns) each line that it prints in order to remedy this situation.
  200. This leads to smoother, neater animations.
  201. -------------------------------
  202.     .speed VALUE
  203.  
  204. This is a speed adjustment function which pads out each line that asp
  205. sends, in order to cope with fast terminals, and for special effects.
  206.  
  207. The default is ".speed 0" and as the speed value is increased, each line
  208. is padded with 'x' carriage returns (x = 8 * n, where 'n' is the
  209. argument to ".speed").  The higher the value, the slower it goes.
  210.  
  211. Be judicious with your use of .speed - remember, some people still work
  212. at under 1200 baud.
  213. -------------------------------
  214.     .background
  215.     .foreground
  216.  
  217. These are both commands which break the rules outlined above.  They both
  218. read the next line DIRECTLY BENEATH the command into special buffers for
  219. use during output.  It does not matter whether this line is blank or
  220. not, and indeed, a blank line will be necessary to reset the buffer to a
  221. blank when desired.
  222.  
  223. ".background" and ".foreground" load their following line into a
  224. background or foreground buffer respectively.  The buffer will then be
  225. used either be used as a backdrop or overlay mask for whatever is
  226. printed from then on.  This means that you don't have to worry about
  227. your landscapes getting corrupted, having to redraw them, and so on.
  228.  
  229. As an example, see the two occurances of ".background" in "demo2.asp"
  230. -------------------------------
  231. SPECIAL EFFECTS:-
  232. -------------------------------
  233.     .fade
  234.  
  235. Prints the message on the screen and fades it one character at a time.
  236. To get slower fades, whack the speed up either side of it, eg:
  237.  
  238. .show .p .p .speed 10 .fade .speed 0 .p
  239.     This piece of text should fade quite gradually into nothingness...
  240.  
  241. -------------------------------
  242.     .flash
  243.  
  244. Flashes all the text in a data line several times before moving onto the
  245. next. Does not overstrike text with whitespace, and can be used thusly:
  246.  
  247. .show
  248. "Beep Beep", went the little car's horn.
  249. .speed 20 .flash .speed 0
  250.  Beep Beep
  251.  
  252. -------------------------------
  253.     .layb
  254.     .layetm
  255.     .laymte
  256.     .layf
  257.  
  258. Prints the line by laying down one character at a time, backwards,
  259. ends-to-middle, middle-to-ends, or forwards, respectively.  See the
  260. demos for examples.
  261. -------------------------------
  262.     .tshow
  263.  
  264. Is like ".show" but does not call ".wipe", and it uses transparent
  265. whitespace, ie: whitespace in the data line does not overstrike any
  266. printable character that is already on screen.  eg:
  267.  
  268. .tshow .p
  269.                                  LIFE
  270.                                       ON
  271.                                          UNIX
  272.  
  273. -------------------------------
  274.     .letter1
  275.     .letter2
  276.     .letter3
  277.  
  278. Are effects macros based on the "let's-cycle-through-the-ascii-character-set"
  279. principle. See the demos for examples.
  280. -------------------------------
  281.     .scrollb
  282.     .scrollf
  283.  
  284. Scrolls the data line backwards or forwards (respectively) onto the
  285. screen, overstriking what is already there, eg:
  286.  
  287. .scrollb .p .p
  288. This message will scroll from right to left across the width of the screen
  289. This message will also scroll from right to left.
  290.  
  291. -------------------------------
  292.     .scrollob
  293.     .scrollof
  294.  
  295. Like .scroll[bf], but these commands scroll what it already there off of
  296. the screen, rather than overstriking it.  See the demos for examples.
  297.  
  298. .scrollob .p .p
  299. This message will scroll from right to left across the width of the screen
  300. This message will also scroll from right to left, without overstriking.
  301.  
  302. -------------------------------
  303.     .spatter
  304.     .wspatter
  305.  
  306. ".spatter" is the opposite of ".fade".  ".wspatter" is similar, but
  307. spatters whole words onto the screen, rather than characters.
  308. -------------------------------
  309.     .object STRING1 VALUE1 VALUE2
  310.     .anim
  311.     .resetanim
  312.  
  313. These are the three Asp animation primitives.
  314.  
  315. Basically, the idea of an animation is to build up a series of "objects"
  316. using the ".object" directive.  This specifies that you want to move
  317. "STRING1" from position VALUE1 to position VALUE2, where the value is
  318. between +/-37267 (or possibly larger), and position 0 is the left hand
  319. column of the screen, position 78 the right hand corner of the screen.
  320.  
  321. After specifying the series of objects to be animated, the animation is
  322. run by invoking the ".anim" command.  Once you are finished with the
  323. animation, you delete the objects from the screen by the ".resetanim"
  324. command.  Simple, eh ? Here's the lorry animation from demo1.asp:
  325.  
  326. .object oo-oP -15 80 .anim .resetanim .p
  327. --
  328.  
  329. Clever people will see that if you want to produce delays and odd timing
  330. effects, you merely have to start an object a long way away from it's
  331. destination.  eg: several lorries-
  332.  
  333. .object oo-oP -15 80 \
  334. .object oo-oP -21 80 \
  335. .object oo-oP -27 80 \
  336. .object oo-oP -33 80 \
  337. .object oo-oP -39 80 \
  338. .object ooo-----ooP -45 80 \
  339. .anim .resetanim .p
  340. --
  341.  
  342. Because their nature is that of a sort of "compound command", several
  343. animations can be built into a single rule and then fired off upon
  344. multiple data lines.  Add a few extra dummy lines to the animation above
  345. to get a whole convoy.  (see also the "flying arrows" in demos 3 & 5).
  346.  
  347. For the technically minded, asp animations run in an entirely separate
  348. buffer from the rest of asp.  The buffer lies in the second position
  349. thus:-
  350.  
  351.                 USER VIEW
  352.                     |
  353.                     V
  354.                 FOREGROUND BUFFER
  355.                 ANIMATIONS BUFFER
  356.                RULE BUFFER (STDLINE)
  357.                 BACKGROUND BUFFER
  358.  
  359. Hence, what you do in an animation cannot affect the rule buffer (ie:
  360. where your data lines end up after being processed by a rule), nor the
  361. foregrounds and backgrounds.
  362.  
  363. *** Usage
  364.  
  365. Now for the easy bit: for your file "aspprog.asp";
  366.  
  367.         asp aspprog.asp > $HOME/.plan
  368.  
  369. or, if you must use tabs
  370.  
  371.         expand < aspprog.asp | asp > $HOME/.plan
  372.  
  373. Bugs, reports, suggestions, patches to the address below...
  374.  
  375.                         alec 8-)
  376. --
  377. INET: aem@aber.ac.uk      JANET: aem@uk.ac.aber      BITNET: aem%aber@ukacrl
  378. UUCP: ...!mcsun!ukc!aber!aem         ARPA: aem%uk.ac.aber@nsfnet-relay.ac.uk
  379. SNAIL: Alec Muffett, Computer Unit, Llandinam UCW, Aberystwyth, UK, SY23 3DB
  380.