home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / !BONUS / GAMES / TETR141.ZIP / HELP / TETRHELP.ENG < prev    next >
Text File  |  1996-01-29  |  79KB  |  1,474 lines

  1.                      TETRHEX, version 1.40 (24/01/1996)                     
  2.                      ¯¯¯¯¯¯¯ 
  3.  
  4. This text contains the whole TETRHEX documentation.  It can be obtained in 3
  5. different ways:  directly by reading the file TETRHELP.ENG,  by choosing the
  6. item "Help about TETRHEX" (Help key)  in TETRHEX,  or by typing "tetrhex -h"
  7. in a shell.  In case  it is the second way,  here are the used keys:  up and
  8. down  arrows (1 line),  with  Ctrl  (4 lines),  with  Shift  (1 page),  with
  9. Ctrl-Shift (4 pages),  Clr-Home  (begining of the document),  Shift-Clr-Home
  10. (end of the document), Esc (quit).
  11.  
  12.   TETRHEX is a SHAREWARE game. If you want the complete version (without any
  13. limitation),  you must get registered  by sending me 50 FF or 20 DM (or more
  14. if you want) to the following address:
  15.  
  16.       Vincent Lefèvre
  17.       24 rue Louis Blanc
  18.       31400 Toulouse
  19.       FRANCE
  20.  
  21.   Don't forget to give me your name and your address!
  22.  
  23.   If you have  Internet access,  I recommend  that  you contact me first  by
  24. e-mail:
  25.  
  26.       vlefevre@ens.ens-lyon.fr
  27.  
  28.   The last unregistered version is available at:
  29.  
  30.       http://www.ens-lyon.fr/~vlefevre/tetrhex/index_eng.html
  31.  
  32.  
  33. Contents
  34. ¯¯¯¯¯¯¯¯ 
  35.     0. Standard Disclaimer
  36.  
  37.     1. Introduction
  38.  
  39.     2. System Requirements
  40.  
  41.     3. Compatibility
  42.         3.1. Floppy Disk or Removable Hard Disk
  43.         3.2. Screen Blaster Card
  44.         3.3. Blow-Up
  45.         3.4. Let 'em Fly
  46.         3.5. Winx (version 2.2)
  47.         3.6. NVDI (versions 2.5 and 3)
  48.         3.7. SpeedoGDOS (version 4.xx)
  49.         3.8. Outside (Virtual Memory)
  50.         3.9. LED Panel
  51.         3.10. Idle (Screen Saver)
  52.         3.11. System Other Than TOS
  53.  
  54.     4. Starting and Configuring TETRHEX
  55.  
  56.     5. TETRHEX Game
  57.         5.1. Main Menu
  58.         5.2. Help
  59.         5.3. Player Name
  60.         5.4. Game
  61.         5.5. Highest Scores Display
  62.  
  63.     6. Rule Files
  64.         6.1. Data Occuring During a Game
  65.         6.2. Actions
  66.         6.3. Signals
  67.         6.4. Game Phases
  68.         6.5. Special Variables
  69.         6.6. Color Codes
  70.         6.7. PAUSE Modes
  71.         6.8. Rule File Structure
  72.         6.9. RUL Language
  73.  
  74.     7. Messages
  75.  
  76.     8. Technical Notes
  77.         8.1. Program Flags
  78.         8.2. Error Codes
  79.         8.3. Moving the Window
  80.         8.4. Palette Modification
  81.  
  82.     9. Limitations of the Unregistered Version
  83.  
  84.  
  85.     0. Standard Disclaimer
  86.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  87.   I cannot be held responsible  for any damage caused by this software.  Use
  88. is entirely at your own risk.
  89.  
  90.  
  91.     1. Introduction
  92.        ¯¯¯¯¯¯¯¯¯¯¯¯ 
  93.   TETRHEX is a game, or rather a group of Tetris-like or Columns-like games,
  94. being played on a hexagonal board,  with hexagonal cells.  Its main features
  95. are:
  96.  
  97.   _ You can  modify existing rule files  and create your own rules  in a    
  98.     TETRHEX-specific  language.  3  rules  are  provided  with  TETRHEX:    
  99.     Tetrhex, Hexcolumns and Tet'light.
  100.  
  101.   _ Special pieces, that make the game more interesting.
  102.  
  103.   _ TETRHEX uses GEM functions,  except for some displays.  Therefore it    
  104.     is compatible with many system programs (in the AUTO folder):  NVDI,    
  105.     SpeedoGDOS, Screen Blaster card, Outside, MiNT/MultiTOS, ...
  106.  
  107.   _ TETRHEX can display outline fonts if SpeedoGDOS or NVDI 3 is active.    
  108.     You can choose the fonts.  TETRHEX  automatically  selects  the most    
  109.     suitable font height, according to the font and the text to display.
  110.  
  111.   _ Many  options;  configuration  on  2 levels  as  Unix-like  options:    
  112.     permanent (in a file) and at the start.
  113.  
  114.   _ You  can play  on the whole screen  or  in a GEM window  (AES 4.1 is    
  115.     supported: the window can be iconified).
  116.  
  117.   _ You can use TETRHEX as an accessory.
  118.  
  119.   _ List of languages to use in order of preference, particularly useful    
  120.     because of the help in rule files.  By default,  the language of the    
  121.     system is preferably used.
  122.  
  123.   _ The hexagonal board has a variable size (4 different sizes).
  124.  
  125.   _ TETRHEX can save up to 255 scores for each rule and each size of the    
  126.     hexagonal board.
  127.  
  128.   _ You can give  a group of relocatable routines  enabling  TETRHEX  to    
  129.     communicate with the outside.  Possible applications  (some routines    
  130.     don't exist yet):  playing with the Joypad (instead of the keyboard)    
  131.     or even  playing using your voice  (thanks to the DSP),  having .MOD    
  132.     modules played in the background at given moments, putting images in    
  133.     the background, making the computer play, rule file debuggers, ...
  134.  
  135.  
  136.     2. System Requirements
  137.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  138.   TETRHEX  has been written  for Falcon,  but should be able  to run  on any
  139. Atari (or other TOS-based computer)  having a 680x0 with x ≥ 2  and a Falcon
  140. compatible  (i.e.  interlaced planes)  graphic mode  256 colors ≥ 640 * 480,
  141. possibly with a substitute operating system (TOS/GEM compatible).
  142.  
  143.   On a Falcon, TETRHEX can run with any type of color screen.  However a VGA
  144. monitor is recommended;  for on a RGB screen, TETRHEX must run in interlaced
  145. mode.
  146.  
  147.   TETRHEX needs about 300 KB free RAM (ST RAM or TT RAM). One of the  timers
  148. A and D  is  required  (cf section "Starting and Configuring TETRHEX");  the
  149. default timer is the timer D.
  150.  
  151.  
  152.     3. Compatibility
  153.        ¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  154.   Unlike most games, TETRHEX is generally compatible with the programs being
  155. in the AUTO folder.  However sometimes there may be some problems.  Idem for
  156. the hardware.  The list of tested software/hardware and encountered problems
  157. is given below.
  158.  
  159.   In whole screen mode,  if  you aren't  in an adequate resolution,  TETRHEX
  160. automatically tries to change the resolution.  The main problem is that some
  161. AUTO programs don't allow this. Either you have to remove these programs, or
  162. you have to switch to an adequate resolution before starting TETRHEX.  Note:
  163. the order  of  the programs  in  the AUTO folder  is  very  important;  some
  164. information given below may be more or less correct, according to the order.
  165.  
  166.         3.1. Floppy Disk or Removable Hard Disk
  167.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  168.   If the rule file  has been loaded  from a floppy disk  or a removable hard
  169. disk (SyQuest), you mustn't change the disk if the list of the scores can be
  170. modified  (this is generally the case),  particurlarly if the new disk has a
  171. file with the same name and the same path.
  172.  
  173.         3.2. Screen Blaster Card
  174.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  175.   TETRHEX  never  tries  to change  the resolution,  otherwise  the computer
  176. bombs.  In order to know whether the Screen Blaster card is active, the OSBL
  177. cookie  is searched for.  Note:  this cookie  can be removed  only  after  a
  178. complete reboot  (Ctrl-Alt-Rshift-Delete);  therefore  the resolution change
  179. may be refused whereas the card isn't active (after a partial reboot).
  180.   Like with other programs / cards  that enhances  the resolution,  in whole
  181. screen mode, only the centered 640 * 480 part of the screen is used.
  182.  
  183.         3.3. Blow-Up
  184.              ¯¯¯¯¯¯¯ 
  185.   In whole screen mode,  TETRHEX bombs  if the Y-resolution isn't a multiple
  186. of 16. I don't know why.
  187.  
  188.         3.4. Let 'em Fly
  189.              ¯¯¯¯¯¯¯¯¯¯¯ 
  190.   If the "Send Redraw" option is selected,  there is a display problem after
  191. the file selector is called:  in GEM window mode,  a redraw message  is sent
  192. (this  just  wastes  time);  in whole screen mode,  the part  under the file
  193. selector is cleared (it's more embarrassing).  Thus it is recommended not to
  194. select  the "Send Redraw" option  if  you  need  to load  other  rule files,
  195. particularly in whole screen mode.
  196.  
  197.         3.5. Winx (version 2.2)
  198.              ¯¯¯¯ 
  199.   There's  no  problem.  In GEM window mode,  you can  untop  the window  by
  200. clicking on the title bar.
  201.  
  202.         3.6. NVDI (versions 2.5 and 3)
  203.              ¯¯¯¯ 
  204.   It is impossible  to change the resolution,  but  in general  the computer
  205. doesn't bomb (it bombs if LED Panel is installed).
  206.   It is recommended to select the "TOS compatibility" option  if you need to
  207. load  other rule files.  Otherwise  you'll  have  the same problem  as  with
  208. Let 'em Fly with the "Send Redraw" option (cf above).
  209.   With NVDI 3  you can use  outline fonts.  But don't use them  in the help:
  210. that completely bugs.
  211.  
  212.         3.7. SpeedoGDOS (version 4.xx)
  213.              ¯¯¯¯¯¯¯¯¯¯ 
  214.   If  SpeedoGDOS  is installed  (this is recommended,  except  if NVDI 3  is
  215. installed), you can use outline fonts.
  216.   It is impossible to change the resolution, but the computer doesn't bomb.
  217.   If some outline text has been underlined (in the help),  filled rectangles
  218. aren't displayed any longer: you have to quit. This seems to come from a bug
  219. from SpeedoGDOS.
  220.  
  221.         3.8. Outside (Virtual Memory)
  222.              ¯¯¯¯¯¯¯ 
  223.   There's no problem. Flags about the TT-RAM may be set.
  224.  
  225.         3.9. LED Panel
  226.              ¯¯¯¯¯¯¯¯¯ 
  227.   In order  to avoid  display conflicts,  LED Panel  can be desactivated  in
  228. whole screen mode. LED Panel is reactivated when TETRHEX ends.
  229.  
  230.         3.10. Idle (Screen Saver)
  231.               ¯¯¯¯ 
  232.   When  the protection  is activated,  TETRHEX memory blocks  may be altered
  233. (tests with Idle 2.2).
  234.  
  235.         3.11. System Other Than TOS
  236.               ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  237.   Memory protection  mustn't be used  if video memory  is protected  against
  238. read/write.
  239.   A rule file  loaded  by TETRHEX  mustn't be  modified  if the list  of the
  240. highest scores can be modified,  because TETRHEX wouldn't be aware of it and
  241. the file structure could become bad.
  242.  
  243.  
  244.     4. Starting and Configuring TETRHEX
  245.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  246.   TETRHEX  can be  started  either  by double-clicking on its icon  from the
  247. desktop, or from a shell (for instance Gemini shell).  Unix-like options can
  248. be  given.  TETRHEX  creates  a string  composed  of  the configuration file
  249. TETRHEX.CFG (if it exists),  followed by the command line options  (if there
  250. are ones); an example will be given after the list of options. Note: to have
  251. the possibility to enter options after double-clicking on the icon, you must
  252. replace the extension .PRG by the extension .GTP  (.TTP equivalent for a GEM
  253. program).  The options  start  with the '-' character  and are separated  by
  254. blanks  (space and control characters,  i.e.  characters whose ASCII code is
  255. ≤ 32).  The command line mustn't have more than 125 characters; if there are
  256. too many options, store them in a file and use the -o option.  If the syntax
  257. of the whole string isn't correct, the program immediately ends (and returns
  258. an non-zero error code). Here are the options:
  259.  
  260.   -b <Ir> <Ig> <Ib> <Dr> <Dg> <Db>
  261.     Colors of the hexagonal board. This option is followed by 6 numbers,    
  262.     between 0 and 255.  The first 3 numbers  are the intensities  of the    
  263.     red, green and blue components of the frame.  The last 3 numbers are    
  264.     values to substract from the intensities to display the next part of    
  265.     the frame towards the background.  These values multipled by 3  must    
  266.     be respectively  less or equal to the first 3 values,  because there    
  267.     are  3 background planes.  The 6 default numbers are  240, 240, 240,    
  268.     48, 48, 48.  If the conditions  aren't consistent,  the option isn't    
  269.     taken into account.
  270.   -cd <R> <G> <B>
  271.     [Color Date] Color of the date. This option is followed by 3 numbers    
  272.     between  0 and 255:  the intensities  of the  red,  green  and  blue    
  273.     components. If a number is out of range, the corresponding intensity    
  274.     isn't changed. If after all the "-cd" options the intensities are 0,    
  275.     then the 3 intensities are set to 255 (white).
  276.   -ch <R> <G> <B>
  277.     [Color Help] Color of the help text. Cf "-cd" option.
  278.   -ci <number>
  279.     [Color Icon] Index of the color of the icon (as of AES 4.1), between    
  280.     0 and 15.
  281.   -cp <number>
  282.     [Color Pause]  Index  of the color  of  "-- PAUSE --"  (window pause    
  283.     mode), between 0 and 15.
  284.   -ct <R> <G> <B>
  285.     [Color Time] Color of the time. Cf "-cd" option.
  286.   -da
  287.     [Display All] The date and the time are displayed (like "-dy -ds").
  288.   -dd
  289.     [Display Date] The date is displayed without the year.
  290.   -dn
  291.     [Display Nothing] Neither the date nor the time is displayed.
  292.   -ds
  293.     [Display Seconds] The time is displayed with the seconds.
  294.   -dt
  295.     [Display Time] The time is displayed without the seconds.
  296.   -dy
  297.     [Display Year] The date is displayed with the year.
  298.   -e[+/-]
  299.     [Error display]  Error messages may be sent  to the standard output.    
  300.     You should use this option only in the following cases: you're under    
  301.     MultiTOS and you have a console,  and/or TETRHEX doesn't work as you    
  302.     want to and you'd like to know the reason.
  303.   -f+ <number>
  304.     Number  to add  to the numbers  of the outline fonts  to obtain  the    
  305.     index (used by the VDI). Default value: 0.  According the SpeedoGDOS    
  306.     version,  it's  usually  0 or 5000.  In  the following options  "-f?
  307.     <number>",  the number must be preceded by a '+'  if it's an outline
  308.     font.
  309.   -fe <number>
  310.     [Font mEnu] Number of the font used to display "Menu".
  311.   -fg <number>
  312.     [Font Game] Number of the font used in the game.
  313.   -fh <number>
  314.     [Font Help] Number of the font used to display the help text.
  315.   -fm <number>
  316.     [Font Menu] Number of the font used in the menus.
  317.   -fn <number>
  318.     [Font Name] Number of the font used to display the rule name.
  319.   -fo <number>
  320.     [Font game Over] Number of the font used to display "game over".
  321.   -fp <number>
  322.     [Font Pause] Number of the font used to display "-- PAUSE --".
  323.   -fr <number>
  324.     [Font Register]  Number of the font  used to display  the text under    
  325.     "Shareware".
  326.   -fs <number>
  327.     [Font Score] Number of the font used to display the scores.
  328.   -ft <number>
  329.     [Font Tetrhex] Number of the font used to display "TETRHEX x.xx".
  330.   -fw <number>
  331.     [Font shareWare] Number of the font used to display "Shareware".
  332.   -gdos
  333.     TETRHEX behaves as if SpeedoGDOS were installed  (useful if the GDOS    
  334.     flag isn't correct).
  335.   -h or -help
  336.     Help: the help file is written to the standard output.
  337.   -i off
  338.     Internal speaker off.  N.B.:  the speaker won't be switched on again    
  339.     at the end of the program.
  340.   -i on
  341.     Internal speaker on.  N.B.:  the speaker won't be switched off again
  342.     at the end of the program.
  343.   -l <param>
  344.     Language preferences.  There  are  as many parameters  as  you  want    
  345.     (possibly none). Each parameter is either a nonnegative number, that    
  346.     indicates  the language  in an absolute way  (cf below),  or the '?'    
  347.     character,  that  indicates  the language  given  by the _AKP cookie    
  348.     (language used by the system),  or the '*' character, that indicates    
  349.     one or several languages close to the one used by the system  (there    
  350.     are only 3 language groups: {0, 3}, {1, 8} and {2, 7}).  The default    
  351.     parameter string is "* 0 3".
  352.     Country codes:  0: USA, 1: Germany, 2: France, 3: United Kingdom, 4:    
  353.     Spain,  5: Italy, 6: Sweden, 7: Switzerland (French), 8: Switzerland    
  354.     (German), 9: Turkey, 10: Finland, 11: Norway, 12: Denmark, 13: Saudi    
  355.     Arabia, 14: Holland, 15: Czechoslovakia, 16: Hungary.
  356.   -ma
  357.     [Memory Allocate]  The memory block  containing the background image    
  358.     will never be freed  (except when the program ends),  so  this image    
  359.     will never be calculated again.
  360.   -mf
  361.     [Memory Free]  The memory block containing the background image will    
  362.     always  be freed  after the image is displayed,  and  the background    
  363.     image  will always  be calculated again  when it is  to be displayed    
  364.     again.
  365.   -n <number>
  366.     Length of an edge of the hexagonal board (between 6 and 9).
  367.   -o <file>
  368.     [Options] The list of the remaining options is replaced by the file;    
  369.     this allows to have several configuration files.
  370.   -p <string>
  371.     [Player]  The string  contains  the player name  between  simple  or    
  372.     double quotes.  If the string is empty (default string),  the player    
  373.     will have to enter his name  if his score is high enough to enter in    
  374.     the list of the highest scores.
  375.   -r <file>
  376.     [Rule] Rule file (.RUL extension) to load by default.
  377.   -s <file>
  378.     Message file (.MSG extension),  allowing TETRHEX to communicate with    
  379.     other programs (cf section "Messages").
  380.   -ta
  381.     [Timer A]  The timer A  will  be  used  (whether  the Lshift key  is    
  382.     pressed or not).
  383.   -td
  384.     [Timer D]  The timer D  will  be  used  (whether  the Lshift key  is    
  385.     pressed or not).
  386.   -u[+/-]
  387.     The list of the highest scores mustn't be modified.
  388.   -vhc <n0> <n1> <n2> <n3> <n4> <n5> <n6> <n7>
  389.     [Video Hex Color]  Intensities  of  the  8  levels  to  display  the    
  390.     hexagons. The first number corresponds to the darkest level, and the    
  391.     last one to the brightest level. For instance, for a yellow hexagon,    
  392.     the intensities of the red and green components  will have the value    
  393.     given by the option, and the intensity of the blue component will be    
  394.     0. The default values are: $30, $60, $78, $90, $A8, $C8, $D8, $F8.
  395.   -vhw <n0> <n1> <n2> <n3> <n4> <n5> <n6> <n7>
  396.     [Video Hex White]  Intensities  to  add  to  each component  of  the    
  397.     corresponding level  (given by the "-vhc" option).  If,  for  one or    
  398.     several components, the sum is greater than 255, then it is set back    
  399.     to 255.  The default values are:  $00, $00, $00, $00, $10, $20, $50,    
  400.     $80.
  401.   -vl[+/-]
  402.     [Video LED Panel]  LED Panel  is switched  off  in whole screen mode    
  403.     (nothing  is  done  in GEM window mode).  LED Panel  status  will be    
  404.     restored at the end of the program.
  405.   -vr[+/-]
  406.     [Video Resolution]  The resolution mustn't be changed;  if it is not    
  407.     correct, an error is returned.
  408.   -vs[+/-]
  409.     [Video Synchro]  Synchronization with the VBL interruption  for some    
  410.     displays,  particularly for the outline fonts display;  in this last    
  411.     case, this option is useful only if the display is fast enough. It's    
  412.     the case of NVDI 3, but it isn't the case of SpeedoGDOS 4.
  413.   -wp <x0> <y0>
  414.     [Window Position] Position of the upper-left point of the window (in    
  415.     GEM window mode).  If this position  is out of range,  the window is    
  416.     placed at the default position.
  417.   -wpc
  418.     [Window Position: Centered]  The window  is centered  (in GEM window    
  419.     mode).
  420.   -ws
  421.     [Window Screen]  Whole screen mode.  This is the default option when    
  422.     the MiNT cookie isn't present.  This option  should be avoided  in a    
  423.     multitasking environment.
  424.   -wu[+/-]
  425.     [Window Update] In whole screen mode, the screen semaphore is always    
  426.     active. So the background processes (i.e. generally the accessories)    
  427.     can't display anything.
  428.   -ww
  429.     [Window Window] GEM window mode. This is the default option when the    
  430.     MiNT cookie is present.
  431.  
  432.   The numbers are in the decimal base, except if they are preceded by a '$',
  433. where they are  in the hexadecimal base.  For the  "-u", "-vl", "-vr", "-vs"
  434. and "-wu" options, a following '-' means that the option is deselected;  the
  435. possible '+' means that the option is selected. Instead of giving options in
  436. the command line, you can drag an option file, a rule file or a message file
  437. to TETRHEX icon.  This operation respectively corresponds  to the "-o", "-r"
  438. and "-s" options.  Some options  have  opposite effects  (ta/td,  -vr+/-vr-,
  439. -vs+/-vs-, ...); only the last one in the string is taken into account.
  440.  
  441.   For instance, if the file TETRHEX.CFG contains the string "-ww -wpc -n 6",
  442. and the parameters are  "-ws -vs",  then  the game will run  in whole screen
  443. mode,  with video synchronization  and a hexagonal board  whose edges have 6
  444. hexagons.
  445.  
  446.   At the start,  if  the Lshift key  is pressed,  the timer A  will be  used
  447. (except if the "-td" option is given) instead of the timer D  (useful if the
  448. serial port is used while TETRHEX is running).
  449.  
  450.   With a module player accessory or/and a message file, you can have modules
  451. played in the background;  the timer D  (default timer)  must be chosen  for
  452. TETRHEX.  But  on a  Falcon 030  without  an  accelerator board,  you'll get
  453. interferences each time the palette is changed, i.e. during the presentation
  454. and when the screen changes.
  455.  
  456.   You can use TETRHEX as an accessory.  To do that,  copy TETRHEX.PRG/GTP to
  457. the root folder of the boot partition  (C:\ in general)  and rename it  into
  458. TETRHEX.ACC;  copy also the rule files,  TETRHEX.CFG and TETRHEX.LNG  to the
  459. same place.  Warning!  there  remain  two big problems:  a memory management
  460. problem  (the computer  may crash,  in particular,  don't start  or quit  an
  461. application while you're playing);  another problem is the fact that TETRHEX
  462. uses a current path for the rule files,  but under the TOS, the current path
  463. isn't local  to the application,  so that a saved score  may cause an error.
  464. For the moment,  when there is an error, you can't use the TETRHEX accessory
  465. any longer.  This possibility to use TETRHEX as an accessory is new  and may
  466. be improved later.
  467.  
  468.   N.B.:  the  rule file  TETRHEX.RUL  must  be  in  the same folder  as  the
  469. application TETRHEX.PRG/GTP/ACC.
  470.  
  471.  
  472.     5. TETRHEX Game
  473.        ¯¯¯¯¯¯¯¯¯¯¯¯ 
  474.   After starting TETRHEX,  a window is immediately displayed  if the game is
  475. to run in a GEM window.  In whole screen mode, first TETRHEX tries to change
  476. the resolution if need be,  except if the "-vr" option is selected,  but may
  477. fail  because  of  some  AUTO programs  (cf  "Compatibility");  then a short
  478. presentation starts, while the background image is computed;  hit any key to
  479. go to the main menu.
  480.  
  481.   At every time  you can free  the memory allocated for the background image
  482. by typing Ctrl-F,  or,  if you are in GEM window mode,  by clicking anywhere
  483. with the right button of the mouse.
  484.  
  485.   In GEM window mode,  you can quit whenever you want  by closing the window
  486. (click on the closer). As of AES 4.1, you can iconify the window by clicking
  487. on the iconifier, or untop the window by clicking on the title bar.  You can
  488. also  move  the window,  but it will always  remind entirely  on the screen.
  489. Note: during a game, the window will only move between two pieces.  If it is
  490. is untopped, the window is cleared and the string "-- PAUSE --" is displayed
  491. in the center:  the window is said to be in pause mode (there are 2 kinds of
  492. pause mode:  the window pause mode  and  the game pause mode;  cf subsection
  493. "Game").
  494.  
  495.         5.1. Main Menu
  496.              ¯¯¯¯¯¯¯¯¯ 
  497.   Each  item  of  the  main  menu  can  be  chosen  either  by  hitting  the
  498. corresponding key  or by clicking  on the item  (possible only in GEM window
  499. mode).  The list of the items is given below.  The name of the rule file  is
  500. displayed. The player name is also displayed if there is one.
  501.  
  502.   _ Item "help about TETRHEX"  (Help key):  this file  is displayed.  If    
  503.     nothing is displayed,  you have to modify the file TETRHEX.LNG:  add    
  504.     (or modify) the HELP line corresponding to the right language; after    
  505.     "HELP:", write the name of this file (path relative to the program +    
  506.     file name).
  507.   _ Item "help about the rule"  (Shift-Help key):  help about the loaded    
  508.     rule. If nothing is displayed, this means that there is no help.
  509.   _ Item "load a rule" (Undo key):  a file selector is displayed so that    
  510.     you can choose  a rule file.  This item can be selected  only if the    
  511.     resolution was not changed.
  512.   _ Item "player name" (N key): this item allows the player to enter his    
  513.     name  (cf subsection "Player Name").  This item is displayed only if    
  514.     the -u option is not active.
  515.   _ Item "play" (Return key): cf subsection "Game".
  516.   _ Item "high scores"  (keys F1  to F20):  the  scores  are  displayed.    
  517.     Clicking  on  this item  is  equivalent  to hitting  the F1 key.  Cf    
  518.     subsection "Highest Scores Display".
  519.   _ Item "bottom" (Ctrl-Tab key):  untop the window;  this is equivalent    
  520.     to clicking  on the title bar.  This item  is displayed  only in GEM    
  521.     window mode.
  522.   _ Item "quit"  (Ctrl-Q key):  quit  TETRHEX;  this  is  equivalent  to    
  523.     closing the window.
  524.  
  525.   By typing Ctrl + one of the 4 top keys of the numeric pad  ("(", ")", "/",
  526. "*") you change the size of the hexagonal board: the k-th key corresponds to
  527. edges having k+5 hexagons.
  528.  
  529.         5.2. Help
  530.              ¯¯¯¯ 
  531.   In both the general help and the help about a rule,  the keys are:  up and
  532. down arrows to do a 1-line scroll;  with the Shift key (left or right),  you
  533. go to the previous or the next page. If the Ctrl key is pressed, the move is
  534. multipled by 4. Hit the Clr-Home key to go to the beginning of the text; hit
  535. Shift-Clr-Home  to go to the end of the text.  Hit Esc  to quit the help and
  536. to come back to the main menu.
  537.  
  538.         5.3. Player Name
  539.              ¯¯¯¯¯¯¯¯¯¯¯ 
  540.   The player name  is used  when a score  is saved.  It can be entered  in 3
  541. different ways: as an option at the start, from the main menu, or at the end
  542. of a game if the score is to be saved. If there's only one player, the first
  543. two ways are better.  If there are several players, the third way is better.
  544. Only the last two ways will be considered here.
  545.  
  546.   A filled rectangle is displayed at the upper-left corner in order that you
  547. enter your name.  You can enter only non-control characters.  You can delete
  548. the last character with the Backspace key. Hit Esc to delete the whole name.
  549. With  the right arrow,  you  can  undelete  the last  deleted character  (or
  550. possibly an old character  which had the same position).  With the up arrow,
  551. you can undelete  all the deleted characters.  Hit Return or Enter to valid.
  552. You can cancel this operation and return an empty name by typing Ctrl-C.
  553.  
  554.   Once  the entry  is validated  (with Return or Enter)  or  canceled  (with
  555. Ctrl-C),  the mini-buffer used to undelete characters isn't cleared,  except
  556. the first character,  so that you can retrieve  the last entered name at the
  557. next entry (after entering the first character).
  558.  
  559.   If the name is entered  from the main menu  and an empty name is returned,
  560. there won't be  a player name:  if a score is to be saved,  the player  will
  561. have to enter his name at the end of the game.
  562.  
  563.   If the name is entered at the end of a game,  you can't validate  an empty
  564. name  (with Return or Enter).  However the player can cancel the entry  with
  565. Ctrl-C and the score won't be saved.
  566.  
  567.         5.4. Game
  568.              ¯¯¯¯ 
  569.   The rules depend on the rule file; read the corresponding help (Shift-Help
  570. from the main menu)  to know them.  But rules have common points,  which are
  571. given here.
  572.  
  573.   The game is played  on a hexagonal board whose edges have 6 to 9 hexagonal
  574. cells.  Either a cell is empty or it contains a hexagon, which comes from an
  575. piece.  A hexagon has one of the 6 following colors: red, green, blue, cyan,
  576. magenta, yellow. Moreover it may contain a pattern, whose meaning depends on
  577. the rule file.  A piece contains 1 to 4 hexagons; the shape, the probability
  578. to appear, etc... depend on the rule file.  Pieces appear at the top, in the
  579. center, and go down. Their speed also depends on the rule file. When a piece
  580. can't go down  any longer,  it enters  the board,  and some hexagons  may be
  581. destroyed  (possibly in several stages).  When a hexagon  is destroyed,  the
  582. upper hexagons  (in the same column)  go down one cell.  Generally  the game
  583. ends when the next piece can't appear.
  584.  
  585.   Up to  8 numbers  can be displayed  in the right part  of the window:  the
  586. score, the level, etc... Their definition (text, number of digits, position,
  587. etc...) entirely depends on the rule file.
  588.  
  589.   The next piece  can be displayed (radar) or not:  this also depends on the
  590. rule file. When the next piece is displayed, it is centered at the top.
  591.  
  592.   In the game pause mode,  the string  "-- PAUSE --"  is  displayed  in  the
  593. upper-left part.  In GEM window mode,  if the window is untopped,  you enter
  594. the window pause mode.  When the window is topped back,  you enter  the game
  595. pause mode  if the rule file  accepts it  (more precisely,  a PAUS signal is
  596. sent, cf section "Rule Files"),  in order to avoid that the game immediately
  597. continues.
  598.  
  599.         5.5. Highest Scores Display
  600.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  601.   The highest scores  can be displayed  in groups of 10.  When you hit an Fn
  602. key (1 ≤ n ≤ 20, F(n+10) = Shift-Fn),  the scores from the rank 10n-9 to the
  603. rank 10n are displayed. Hit Esc to come back to the main menu.
  604.  
  605.   Note 1:  the scores depend on the size of the hexagonal board.  To display
  606. the scores that correspond to a given size,  first select this size from the
  607. main menu (cf subsection "Main Menu").
  608.  
  609.   Note 2:  although they can be saved,  the scores  from the rank 201 to the
  610. rank 255 can't be displayed in TETRHEX.
  611.  
  612.  
  613.     6. Rule Files
  614.        ¯¯¯¯¯¯¯¯¯¯ 
  615.   One of the most  interesting  features  of TETRHEX  is  the possibility of
  616. creating one's own rules  (and modifying the existing rules).  Hence TETRHEX
  617. allows  to have  various games  and similar games  with  different levels of
  618. difficulty.  The rules are stored in separate files (extension .RUL), called
  619. rule files. This section describes what these files contain, and their exact
  620. structure.
  621.  
  622.         6.1. Data Occuring During a Game
  623.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  624.   This section  shortly  describes  the data  that occurs in the game,  i.e.
  625. the data contained in a rule file  and those only used at run-time.  It also
  626. describes  the different phases of the game  (which will be dealt with again
  627. in the other subsections), staying quite general.
  628.  
  629.   In its header, a rule file contains some data linked to the rule, but that
  630. don't change the way the game occurs, like the rule name, the fonts used for
  631. the rule,  the colors,  the number of scores.  The rule file also contains a
  632. help  (possibly  in several languages),  and  at the end,  the list  of  the
  633. highest scores for each size of the hexagonal board.
  634.  
  635.   A rule can be defined so that it runs for a fixed size of the board or for
  636. a variable size from 6 to 9 hexagons in an edge.  A variable size is better,
  637. but a fixed size may be needed if some sizes aren't suitable.
  638.  
  639.   The rules have some common points, given in the subsection "Game", section
  640. "TETRHEX Game",  which clearly don't have to be defined in a rule file.  The
  641. following data remain to be determined: the shape of the piece, the patterns
  642. on the hexagons, the numbers that will be displayed,  the signals (cf below)
  643. and  the behavior  during  the game.  One  of the sections  of the rule file
  644. contains  all the possible shapes,  each shape being identified  in the part
  645. "behavior" by a number. Idem for the patterns. The definition of the numbers
  646. contains  the text that will be displayed  near the number,  the position of
  647. this text  relative  to the position  of the number,  the size and the color
  648. of  the text  and  the number,  the number  of  digits  of  the number;  the
  649. modification of these numbers, which is directly linked to the behavior,  is
  650. described later.
  651.  
  652.   The behavior is described with the language RUL, specific to TETRHEX. It's
  653. an interpreted language  dealing with expressions  in the prefixed notation;
  654. however  there  are  also  some control commands  (branches).  An expression
  655. always represents a 32-bit signed integer.  2 additional data structures are
  656. used:  an array of 64 variables and a stack of 32-bit integers whose size is
  657. given in the header of the rule file.  Some of the variables  have a special
  658. meaning (cf subsection "Special Variables"), the other may freely be used by
  659. the programmer; a special variable is associated with each displayed number.
  660. At the beginning of the game,  all the variables  are initialized to 0,  and
  661. the stack is empty.
  662.  
  663.   In a game, one plays with an input peripherial (keyboard, mouse, joystick,
  664. ...),  and according to what one does with the peripherial  (action from the
  665. player), something or other occurs in the game (game action). In most games,
  666. there's almost no difference between the 2 kinds of actions: sometimes there
  667. is no difference at all;  sometimes, if one plays with the keyboard, one can
  668. choose the keys;  sometimes  one can also choose between  the keyboard,  the
  669. mouse and the joystick... but this remains limited.
  670.  
  671.   In TETRHEX,  an intermediate element called signal  is used,  so we have 2
  672. conversions,  which one can control.  The data that come from the considered
  673. peripherials  are first converted  into signals  by TETRHEX or  by a message
  674. file. Then the signal is converted into a game action by the rule file.  The
  675. user can intervene in the first conversion by giving a message file;  if the
  676. conversion  is performed by TETRHEX,  then only the keyboard  is considered,
  677. and the keys are defined  in the rule file.  The programmer of the rule file
  678. intervenes in the second conversion.
  679.  
  680.   A signal  is  internally  (i.e. in RUL programs)  identified  by a nonzero
  681. byte, i.e. by an integer between 1 and 255,  and externally (i.e. in message
  682. files) by a long word (32 bits).  An action is identified by a signed 32-bit
  683. integer.
  684.  
  685.   The game  is composed  of several phases.  There's an initialization phase
  686. (phase 0)  at the very beginning of the game  (after the variables have been
  687. initialized  to 0);  this phase  is used  in order to initialize  some data:
  688. variables  (particularly  some displayed numbers),  speed of the piece fall,
  689. etc...  Before a new piece  appears  or when the radar  is activated  (if it
  690. hasn't been activated  twice  before  another piece  has appeared),  a phase
  691. determining this piece  (phase A)  is called:  the piece  must be defined by
  692. setting some special variables  (cf subsection "Special Variables").  During
  693. the piece fall  or  a pause,  phase B  is called  to  convert  signals  into
  694. actions.  When a piece  can't fall any longer,  it sinks into the board  and
  695. phase C is called;  this phase allows to destroy hexagons (in one or several
  696. stages), and to update some data (score, level, ...). Note: data can also be
  697. updated in phase A.  Finally, when the player has lost,  a termination phase
  698. (phase S) is called: it returns the score of the player. There exist 2 other
  699. phases,  linked  to the window pause mode;  these phases  are  described  in
  700. subsection "Pause Modes".
  701.  
  702.   It  is  possible  to  branch  a variable  to the timer.  This variable  is
  703. decreased at each second (1 Hz frequency).
  704.  
  705.         6.2. Actions
  706.              ¯¯¯¯¯¯¯ 
  707.   There are 2 kinds of actions:  simple actions,  i.e. after which the piece
  708. isn't changed, that are identified by positive values, and actions that make
  709. directly  go  to phase C or phase S (abort), identified  by negative values.
  710. When  an action  is not possible,  it is not performed.  The list of actions
  711. defined in this version of TETRHEX is given below.  Some of the actions that
  712. make  directly go  to phase C  store  an additional integer  into V[18]  (as
  713. indicated in the list below). Note: in future versions of TETRHEX, there may
  714. be new actions.
  715.  
  716.   _ 0: no action.
  717.   _ 1: a cell downwards.
  718.   _ 2: a cell downwards to the left (i.e. 8 o'clock).
  719.   _ 3: a cell downwards to the right (i.e. 4 o'clock).
  720.   _ 4: left or direct rotation (counterclockwise).
  721.   _ 5: right or indirect rotation (clockwise).
  722.   _ 6: a cell to the left, at the same height.
  723.   _ 7: a cell to the right, at the same height.
  724.   _ 8: pause / end of pause.
  725.   _ 9: radar on / off.
  726.   _ 10: send a message (cf section "Messages", message $0206).
  727.   _ -1: abort. Go to phase S (no phase C).
  728.   _ -2:  drop:  the piece is dropped.  The number of performed DOWNs  is    
  729.     stored into V[18],  which corresponds to the number of covered cells    
  730.     + 1, since the last DOWN is used to stop the piece.
  731.   _ -3:  explosion: all the hexagons that are on the hexagonal board are    
  732.     destroyed.  The number  of destroyed hexagons  (those of the current    
  733.     piece included) is stored into V[18].
  734.   _ -4: the current piece is destroyed.
  735.  
  736.   Note: when a piece is at the top of the board, actions 6 and 7 behave like
  737. actions 2 and 3.
  738.  
  739.         6.3. Signals
  740.              ¯¯¯¯¯¯¯ 
  741.   The signals  are  entirely  defined  in the rule file.  However  there are
  742. standard signals,  you'd better respect,  since they may be used  in message
  743. files.  The rule file also gives the mapping internal identifiers / external
  744. identifiers and the default keys,  a key being identified by its position on
  745. the keyboard (scancode) and the state of the special keys.
  746.  
  747.   The list of the standard signals, defined by the external identifiers, but
  748. ordered  according to the internal identifiers,  is given below.  You should
  749. take  the same internal identifiers,  even though  this isn't important  for
  750. the moment.  The keys chosen in the rule files provided with TETRHEX  (it is
  751. advised to take the same keys) and the corresponding actions are also given.
  752. It is important to perform the same actions. Note: here the term "action" is
  753. different from the one considered in the previous section; however there's a
  754. direct correspondence for most actions.
  755.  
  756.   $01 : DOWN : A.............. a cell downwards (action 1).
  757.   $02 : LFDN : Insert......... a cell downwards to the left (action 2).
  758.   $03 : RGDN : Clr-Home....... a cell downwards to the right (action 3).
  759.   $04 : ROTL : Down arrow..... left rotation (action 4).
  760.   $05 : ROTR : Up arrow....... right rotation (action 5).
  761.   $06 : LEFT : <--............ a cell to the left (action 6).
  762.   $07 : RGHT : -->............ a cell to the right (action 7).
  763.   $08 : DROP : Space bar...... drop (action -2).
  764.   $09 : STOP : Ctrl-Esc....... abort (action -1).
  765.   $0A : PAUS : Undo........... pause mode (action 8).
  766.   $0B : CONT : Return......... end of pause mode (action 8).
  767.   $0C : NEXT : + (numpad)..... next level (code + action 0).
  768.   $0D : PREV : - (numpad)..... previous level (code + action 0).
  769.   $0E : RDAR : Help........... radar on / off (action 9).
  770.  
  771.   Note:  depending on the rule,  only an action 0  may  be  associated  with
  772. some signals.  For instance,  the previous level  or the pause mode  may  be
  773. forbidden...
  774.  
  775.         6.4. Game Phases
  776.              ¯¯¯¯¯¯¯¯¯¯¯ 
  777.   The game is composed of 7 phases, each phase corresponding to a subroutine
  778. written in RUL:
  779.   _ Phase 0:  initialization phase,  called at the very beginning of the    
  780.     game.
  781.   _ Phase A: the next piece is determined by storing values into some of    
  782.     the variables V[0] to V[8] (cf subsection "Special Variables"). This    
  783.     phase  may be called  while there is already  a moving piece  on the    
  784.     board, due to the activation of the radar;  in this case,  variables    
  785.     V[0] to V[8]  are saved  by TETRHEX  before the call,  and  restored    
  786.     after the call (for they may still be useful): the programmer of the    
  787.     rule file don't need to worry about that.
  788.   _ Phase B:  signals  are converted  into actions.  The internal signal    
  789.     identifier  is  in  V[9].  The subroutine  must  return  the  action    
  790.     identifier.  Note:  data about the current piece  can be known  with    
  791.     command $7C (cf subsection "RUL Language").
  792.   _ Phase C: in this phase, some hexagons can be destroyed; the score is    
  793.     generally updated.  V[9] contains the identifier of the last action:    
  794.     useful  if some actions  (among the negative ones)  yield  points...    
  795.     V[18] may contain an additional integer (cf subsection "Actions").
  796.   _ Phase P (Pause):  beginning of the window pause mode  (cf subsection    
  797.     "Pause Modes").
  798.   _ Phase Q (Quit pause):  end  of the window pause mode  (cf subsection    
  799.     "Pause Modes").
  800.   _ Phase S  (Score):  termination  phase.   The  final  score  must  be    
  801.     returned.
  802.  
  803.         6.5. Special Variables
  804.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  805.   V[0] contains the identifier of the current shape  (from 1 to 255).  Let h
  806. be the number of hexagons of this shape.  For  1 ≤ k ≤ h,  V[k] contains the
  807. color of the k-th hexagon (cf subsection "Color Codes"), and V[k+4] contains
  808. the pattern identifier of the k-th hexagon (from 1 to 255).  For  h < k ≤ 4,
  809. V[k] and V[k+4]  may be freely used,  but they may be altered in phase A  by
  810. TETRHEX.  The variables defining the piece must be assigned in phase A,  and
  811. mustn't be modified in phases B, C, P and Q.
  812.  
  813.   V[9] contains the internal signal identifier  (from 1 to 255)  in phase B,
  814. and the action identifier in phase C.  This variable  may be modified by the
  815. routines RUL.
  816.  
  817.   Let n be  the number of displayed numbers  to the right of the board.  For
  818. 1 ≤ k ≤ n,  V[k+9]  contains  the  k-th  displayed value.  If  the value  is
  819. negative,  then  0 is displayed;  if it is  higher than  M(k) = 10^d(k) - 1,
  820. where  d(k)  is the maximum number  of displayed digits  of the k-th number,
  821. then M(k) is displayed. For n < k ≤ 8, V[k] may be freely used.
  822.  
  823.   V[18] may contain an additonal integer in phase C. For k > 18, V[k] may be
  824. freely used.
  825.  
  826.         6.6. Color Codes
  827.              ¯¯¯¯¯¯¯¯¯¯¯ 
  828.   The hexagons  that  compose  the pieces  can have  one  of the 6 different
  829. colors, coded from 1 to 6:
  830.   _ 1 (001): blue.
  831.   _ 2 (010): green.
  832.   _ 3 (011): cyan = green + blue.
  833.   _ 4 (100): red.
  834.   _ 5 (101): magenta = red + blue.
  835.   _ 6 (110): yellow = red + green.
  836.  
  837.         6.7. Pause Modes
  838.              ¯¯¯¯¯¯¯¯¯¯¯ 
  839.   There  are  2 kinds of pauses:  the game pause mode  and  the window pause
  840. mode.
  841.  
  842.   Game pause mode:  this pause mode is activated by the action +8  (normally
  843. when a PAUS signal is sent),  and it is desactivated by the action +8 again.
  844. The other actions may be activated,  but except the action +8 (end of pause)
  845. and the action -1 (abort), they have no effect.  Warning! even in game pause
  846. mode,  any signal  may be received;  the programmer  must test  whether he's
  847. in  pause  mode  or  not  before  performing  operations,  like  a  variable
  848. modification.
  849.  
  850.   Window pause mode:  this pause mode is activated when the window is in the
  851. background (in GEM window mode).  Contrary to the game pause mode, here this
  852. pause mode is forced: one can't avoid it. At this moment, phase P is called;
  853. in this phase, the possible variable branched to the timer may be unbranched
  854. (not compulsory).  Then  the game  is  totally  stopped  (no signal  can  be
  855. received), but the timer is still active.  When the window comes back to the
  856. foreground,  this  pause mode  is quitted,  except  in some particular cases
  857. (e.g. insufficient memory);  if  there's  any problem,  an alert message  is
  858. displayed.  Phase Q is called;  if a variable  had been unbranched  from the
  859. timer, it may be branched again.  Then the PAUS signal is sent if it exists,
  860. so that the game doesn't go on immediately.  Warning!  the window pause mode
  861. may be activated at any moment.
  862.  
  863.         6.8. Rule File Structure
  864.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  865.   Note:  the order of definition of  the patterns,  the shapes,  the signals
  866. and the numbers is important,  the identifier associated with the considered
  867. element is automatically assigned by the position in the list.
  868.  
  869.   _ Header.  Addresses are relative to the beginning of the file. Colors    
  870.     have the format (0, R, G, B):  the first byte is zero,  and the next    
  871.     3 bytes  contain  the values of the  red, green and blue  components    
  872.     between 0 and 255.
  873.      . 1 long word: $52554C33 ("RUL3"). This long word indicates that it    
  874.        is a rule file, version 3.
  875.      . 1 long word: color of "-- PAUSE --", in the game pause mode.
  876.      . 1 long word: color of "game over".
  877.      . 1 long word: color of "Your name:" and the name  (when the player    
  878.        is asked to enter his name).
  879.      . 1 long word: color of the rule name.
  880.      . 1 word: default height  of the rule name.
  881.      . 24 bytes: rule name followed by a zero byte.
  882.      . 1 word:  identifier of the outline font  used to display the rule    
  883.        name,  or 0 if the font is chosen by the user (i.e. determined by    
  884.        the option -fn).
  885.      . 1 word:  identifier of the outline font used to display the names    
  886.        of the displayed numbers  during the game,  or 0  if the font  is    
  887.        chosen by the user (i.e. determined by the option -fg).
  888.      . 1 byte: number of patterns (between 1 and 255).
  889.      . 1 byte: number of shapes (between 1 and 255).
  890.      . 1 byte: number of signals (between 1 and 255).
  891.      . 1 byte: number n  of cells  in  an edge  of  the  hexagonal board    
  892.        (between 6 and 9), or 0 if it is variable.
  893.      . 1 byte: number of scores (between 0 and 255) for n = 6.
  894.      . 1 byte: number of scores (between 0 and 255) for n = 7.
  895.      . 1 byte: number of scores (between 0 and 255) for n = 8.
  896.      . 1 byte: number of scores (between 0 and 255) for n = 9.
  897.      . 1 byte: maximum number of scores (between 0 and 255) for n = 6.
  898.      . 1 byte: maximum number of scores (between 0 and 255) for n = 7.
  899.      . 1 byte: maximum number of scores (between 0 and 255) for n = 8.
  900.      . 1 byte: maximum number of scores (between 0 and 255) for n = 9.
  901.      . 1 long word: size of the stack.
  902.      . 1 long word: address of the definition of the signals.
  903.      . 1 long word: address of the definition of the displayed numbers.
  904.      . 1 long word: address of phase 0.
  905.      . 1 long word: address of phase A.
  906.      . 1 long word: address of phase B.
  907.      . 1 long word: address of phase C.
  908.      . 1 long word: address of phase P.
  909.      . 1 long word: address of phase Q.
  910.      . 1 long word: address of phase S.
  911.      . 1 long word: address of the help text. 0 if there's no help text.
  912.      . 1 long word: address of the highest scores  (points to the end of    
  913.        the file if there's no score).
  914.  
  915.   _ Definition of the patterns.  Each hexagon  is composed of 288 pixels    
  916.     having an intensity between 0 and 7  (0: black, 4: background color,    
  917.     7: highest intensity).  An array of 288 3-bit numbers  is associated    
  918.     with each pattern,  which takes 108 bytes.  The patterns  are stored    
  919.     the one after the other.
  920.  
  921.   _ Definition of the shapes.  This definition doesn't depend on the one    
  922.     of the patterns.  The pieces  must be connected.  A configuration of    
  923.     the shape  is defined  so that it is relative to a reference hexagon    
  924.     (which  doesn't  necessarily  belong to the piece),  whose  absolute    
  925.     position  will  be  given  in  the game.  Such  a  configuration  is    
  926.     identified  by  a 4-byte array  (long word),  so that  the k-th byte    
  927.     represents  the  relative  position  of  the  k-th  hexagon  to  the    
  928.     reference hexagon; if the shape has fewer than 4 hexagons, the other    
  929.     bytes must be zero.  The byte identifying the relative position of a    
  930.     hexagon is defined as follows:  the byte is 0  if it's the reference    
  931.     hexagon;  its value  is between  1 and 6  if it is  adjacent  to the    
  932.     reference hexagon:  1 if it is below,  then one turns  counterclock-    
  933.     wise; its value is between 7 and 18 if its distance to the reference    
  934.     hexagon is 2: 7 if it is below, then one turns counterclockwise.
  935.      . For each shape:
  936.         . 1 byte: number n of hexagons (between 1 and 4).
  937.         . 1 byte: 0 if the shape can't turn, negative if the shape turns    
  938.           around the reference hexagon,  positive  if the shape turns in    
  939.           another way.  In the last case,  this byte contains the number    
  940.           of  different positions,  between  1  and  6  (note:  normally    
  941.           different from 1).
  942.         . 1 word: offset of the list of the positions for this shape  if    
  943.           the previous byte is positive (nonzero); otherwise, 0.
  944.         . 4 bytes: initial relative positions of the hexagons.
  945.      . Possible list of the relative positions (cf above), in any order,    
  946.        a list of positions being an array of arrays of 4 bytes.
  947.  
  948.   _ Definition of the signals  (standard  signals  included).  For  each    
  949.     signal:
  950.      . 1 long word:  external  signal identifier,  generally  4 letters.    
  951.        This long word must be strictly positive.
  952.      . 1 word:  scancode of the default key  corresponding to the signal    
  953.        (the  most significant  byte  contains  the state  of the special    
  954.        keys).
  955.      . 1 word: 0 (reserved).
  956.  
  957.   _ Definition  of  the  displayed  numbers.   Colors  have  the  format    
  958.     (0, R, G, B). For each number, a text ("Score", "Level", etc...) and    
  959.     a value  are displayed.  If the value is negative,  0  is displayed.    
  960.     There is a minimum number of displayed digits;  some non-significant    
  961.     0's  are  possibly  displayed.  There  is  also  a maximum number of    
  962.     displayed digits;  if the value is too high,  then the highest value    
  963.     that can be displayed is displayed (digits = 9).  Note:  the numbers    
  964.     are vertically displayed, in the same order they have been defined.
  965.      . 1 word: number n (between 0 and 8) of displayed numbers.
  966.      . Array of n words:  addresses  of the definitions of the displayed    
  967.        numbers, relative to the address of the array.
  968.      . For each number:
  969.         . 1 byte: maximum number of displayed digits (between 1 and 8).
  970.         . 1 byte: minimum number of displayed digits (between 1 and 8).
  971.         . 1 byte: text height in pixels (between 16 and 127).
  972.         . 1 byte: number height in pixels (between 16 and 127).
  973.         . 1 long word: color of the text.
  974.         . 1 long word: color of the non-significant 0's.
  975.         . 1 long word: color of the significant digits.
  976.         . 1 byte: position of the text,  relative to the position of the    
  977.           number: 0 if the text must be displayed above the number, 1 if    
  978.           it must be displayed to the left,  -1  if it must be displayed    
  979.           to the right.
  980.         . For each language (there must be at least one language):
  981.            . 1 byte: length n (between 1 and 127) of the text.
  982.            . 1 byte: language code.
  983.            . n bytes: text.
  984.         . 1 byte: 0, indicating there's no language any more.
  985.  
  986.   _ Rule: RUL subroutines. The 7 phases may be interlaced. Cf subsection    
  987.     "RUL Language".
  988.  
  989.   _ Help text (optional).
  990.      . For each language:
  991.         . 1 long word:  offset  of the next language  (or  the long word    
  992.           that indicates the end of this part).
  993.         . 1 byte: language code.
  994.         . 1 byte: underline character  (0 if there's no such character).    
  995.           Cf below.
  996.         . 1 byte (reserved).  Its value isn't important in this version;    
  997.           but  for  the  compatibility  of  the rule file  with  a later    
  998.           version of TETRHEX, its value must be 0. A nonzero value could    
  999.           indicate additional data.
  1000.         . Text in the language given above, followed by a zero byte. The    
  1001.           characters  must have  an ASCII code ≥ 32,  except the ends of    
  1002.           line (CR/LF).  The text  can be directly sent  to the standard    
  1003.           output;  thus  it must already be formatted.  It  can  also be    
  1004.           displayed in TETRHEX window  (item "Help about TETRHEX" in the    
  1005.           main menu;  in  this case,  the text width  (i.e.  the maximum    
  1006.           width of a line of text) will be seeked,  and the lines having    
  1007.           this  width  will  be  justified.  The  advised  width  is  76    
  1008.           characters.  Due  to  this justification,  the lines  won't be    
  1009.           displayed  without a modification:  there  exist  2 characters    
  1010.           that  have  a special behavior:  the space  and  the underline    
  1011.           character  (defined before the text).  A sequence of spaces at    
  1012.           the beginning of a line yields an indentation:  the proportion    
  1013.           of the number of spaces  to  the text width  in characters  is    
  1014.           equal  to the proportion of the indentation width  to the text    
  1015.           width in pixels; idem for a sequence of spaces at the end of a    
  1016.           justified line. A sequence of spaces inside a line is replaced    
  1017.           with  a  unique  space.  The lines  composed  of  only  spaces    
  1018.           and  underline  characters,  called  underline lines,  are not    
  1019.           displayed:  they  are  taken  into account  for the display of    
  1020.           the previous line;  a sequence  of underline characters  in an    
  1021.           underline line  underlines  the above sequence  of  characters    
  1022.           except  the extreme spaces.  If the line  doesn't end  with an    
  1023.           underline character,  then  an empty line  is displayed  below    
  1024.           (it's the case of the underline lines ending with a space, the    
  1025.           lines only composed of spaces and the empty lines). N.B.: each    
  1026.           line must end with a CR/LF, included the last one. One mustn't    
  1027.           have  several consecutive  true underline lines  ("true" means    
  1028.           that  the line  contains  at least  an  underline  character),    
  1029.           otherwise the computer may bombs.
  1030.      . 1 long word: 0.
  1031.  
  1032.   _ Array  of the highest scores  (possibly empty).  First  one has  the    
  1033.     scores  for 6 hexagons,  then  for  7, 8 and 9 hexagons.  Each score    
  1034.     takes 32 bytes:
  1035.      . 24 bytes: player name + zero byte.
  1036.      . 1 long word: score (in hexadecimal).
  1037.      . 1 long word: date and time (XBIOS format).
  1038.  
  1039.         6.9. RUL Langage
  1040.              ¯¯¯¯¯¯¯¯¯¯¯ 
  1041.   RUL is a language of 8-bit codes composing expressions in prefix notation.
  1042. An expression  always  represents  a 32-bit signed integer.  There are  also
  1043. transparent  control instructions  (branches),  i.e.  they  only modify  the
  1044. program counter:  they don't modify  the result  of the last expression  (in
  1045. particular for a return from function,  cf below),  moreover they don't form
  1046. an expression, i.e. they don't modify the expression stack.
  1047.  
  1048.   The expressions are evaluated as soon as they are read.  As a consequence,
  1049. when an operation  has  several operands,  the first operands  are evaluated
  1050. before the last ones. The first expression is denoted "x", the second one is
  1051. denoted "y", and the third one is denoted "z" (character enclosed with angle
  1052. brackets), except when there's an opposite indication.
  1053.  
  1054.   Some expressions return a boolean, encoded by a 32-bit integer as follows:
  1055. "false" is encoded by 0, and "true" is encoded by -1. This encoding has been
  1056. chosen  so that the bitwise instructions AND, OR and NOT  are equivalent  to
  1057. the boolean instructions.
  1058.  
  1059.   Each  cell  of  the  hexagonal board  is  identified  by  a nonzero 32-bit
  1060. integer. The integer 0 identifies the non-existing cells. The other integers
  1061. mustn't be used in commands having a cell identifier as an argument. There's
  1062. another means of identifying a cell:  with a couple (column, height).  Let n
  1063. be  the number of cells  in an edge of the board,  the columns  are numbered
  1064. from -(n-1) to (n-1);  the height  is the number of cells that are below (in
  1065. the same column).  An array of 8 bits called marks,  initialized to 0 at the
  1066. beginning of the game,  is associated with each cell of the board;  when the
  1067. bit b has the value 1, one says that the cell has the mark b.
  1068.  
  1069.   The offsets  (for the branches)  are  16-bit words,  except  for the 8-bit
  1070. conditional branch.  The branch address  is relative  to the address  of the
  1071. offset.
  1072.  
  1073.   Warning!  when a command whose operands have bad values is performed (like
  1074. a division by 0),  the result  is undetermined  or the computer bombs.  When
  1075. this means something, the operations are performed modulo 2^32 (for instance
  1076. the addition).
  1077.  
  1078. Here is the meaning of the codes:
  1079.   _ $80 to $FF: constant x - $C0 (from -64 to 63).
  1080.   _ $00 to $3F: variable V[x].
  1081.   _ $40 <expr> <expr>: addition x + y.
  1082.   _ $41 <expr> <expr>: subtraction x - y.
  1083.   _ $42 <expr> <expr>: multiplication x * y.
  1084.   _ $43 <expr> <expr>: integer division  x / y.  The quotient is defined    
  1085.     as follows:  the absolute value of the quotient  is the floor of the    
  1086.     absolute value of the real quotient.
  1087.   _ $44 <expr> <expr>: left shift  x << y.  The number of shifts must be    
  1088.     between 0 and 63.
  1089.   _ $45 <expr> <expr>: right shift x << y.  The number of shifts must be    
  1090.     between 0 and 63.
  1091.   _ $46 <expr> <byte>: 8-bit  relative  branch  if  the  result  of  the    
  1092.     expression is different from zero (transparent instruction).
  1093.   _ $47 <expr> <expr>: modulo.  One must have y > 0.  The returned value    
  1094.     is the integer congruent to x modulo y, between 0 and y-1.  Warning!    
  1095.     this operation is different from the C modulo (%) for x < 0.
  1096.   _ $48 <word>: 16-bit signed constant.
  1097.   _ $49 <long word>: 32-bit signed constant.
  1098.   _ $4A <expr> <expr>: x == y.
  1099.   _ $4B <expr> <expr>: x != y.
  1100.   _ $4C <expr> <expr>: x < y.
  1101.   _ $4D <expr> <expr>: x > y.
  1102.   _ $4E <expr> <expr>: x <= y.
  1103.   _ $4F <expr> <expr>: x >= y.
  1104.   _ $50 <offset>:  function  call,  i.e.  branch  to  a subroutine  that    
  1105.     returns a value.
  1106.   _ $51: return from function. The value of the function is the value of    
  1107.     the last expression.
  1108.   _ $52 <offset>: relative branch (transparent instruction).
  1109.   _ $53 <expr> <offset>:  branch  if  the result  of  the expression  is    
  1110.     different from zero (transparent instruction).
  1111.   _ $54 <expr>: bitwise NOT.
  1112.   _ $55 <expr> <expr>: bitwise AND.
  1113.   _ $56 <expr> <expr>: bitwise OR.
  1114.   _ $57 <expr> <expr>: bitwise XOR.
  1115.   _ $58: 16-bit signed random value.
  1116.   _ $59: 32-bit signed random value.
  1117.   _ $5A <expr>: V[x] (x must be between 0 and 63).
  1118.   _ $5B <expr> <expr>:  affectation.  The  concerned  variable  and  the    
  1119.     operation that will be performed are given by the value of the first    
  1120.     expression:  if 0 ≤ x ≤ 63,  then  V[x] = y;  if -64 ≤ x ≤ -1,  then    
  1121.     V[x+64] += y; if 64 ≤ x ≤ 127, then V[x-64] -= y. The returned value    
  1122.     is the new value of the variable.
  1123.   _ $5C <expr>: data about the next piece.  If the radar isn't active, 0    
  1124.     is always returned. In the opposite case, if 0 ≤ x ≤ 8, the returned    
  1125.     value  is  the value  of the variable V[x]  after  the last call  of    
  1126.     phase A,  i.e.  V[x]  when the next piece appears,  and  if x < 0 or    
  1127.     x > 8,  the returned value is -1.  Thus an operand like -1 allows to    
  1128.     test whether the radar is active or not.
  1129.   _ $5D: true iff the game mode pause is active.
  1130.   _ $5E <expr>:  if x ≥ 0, the variable V[x] is branched to the timer if    
  1131.     it is not already branched  (the variable  will be decreased at each    
  1132.     second);  if  another variable  was  branched  to the timer,  it  is    
  1133.     automatically unbranched.  If  x < 0,  the variable  branched to the    
  1134.     timer (if there is one) is unbranched. The returned value is x.
  1135.   _ $5F <expr>:  approximate time between two successive descents of the    
  1136.     piece, in milliseconds, between 1 and 8191. The returned value is x.
  1137.   _ $60 <expr> <byte n> <word>^n:  value  of an element  in an array  of    
  1138.     16-bit constants.  This instruction evaluates the expression,  reads    
  1139.     the byte n, takes the value modulo n,  and returns the corresponding    
  1140.     element of the array extended to 32 bits,  the indices being between    
  1141.     0 and n-1.
  1142.   _ $61 <expr> <byte n> <long word>^n:  idem, but for an array of 32-bit    
  1143.     constants.
  1144.   _ $62 <expr> <byte n> <offset>^n:   kind  of  CASE;   relative  branch    
  1145.     depending on the value of the expression.
  1146.   _ $63 <expr>: push the value of the expression, which is returned.
  1147.   _ $64: top of stack (the value isn't pulled).
  1148.   _ $65: pull a value, which is returned.
  1149.   _ $66 <expr>: absolute value.
  1150.   _ $67 <expr>: square. The argument must be a 16-bit word.
  1151.   _ $68: 15-bit random value (positive or zero integer).
  1152.   _ $69: 31-bit random value (positive or zero integer).
  1153.   _ $6A <expr> <expr>: min(x,y).
  1154.   _ $6B <expr> <expr>: max(x,y).
  1155.   _ $6C <expr> <expr> <expr>: double comparision.  If y ≤ x ≤ z,  then 0    
  1156.     is returned; if x < y ≤ z, then -1 is returned; if y ≤ z < x, then 1    
  1157.     is returned. If y > z, the result is undetermined.
  1158.   _ $6D: send a message (cf section "Messages", message $0207).  If data    
  1159.     need to be transmitted, the stack has to be used,  and the data will    
  1160.     have to be pulled.  The result  is the value returned by the message    
  1161.     file.
  1162.   _ $6E <x> <m>:  destruction  of the hexagons  in the cells  having the    
  1163.     mark m.  If m < 0,  all the hexagons are destroyed.  One must always    
  1164.     have m ≤ 7. Note: the first expression is useless; it's here just to    
  1165.     have the same format as the command $6F.
  1166.   _ $6F <x> <m>:  destruction  with  loop  of the hexagons  in the cells    
  1167.     having the mark m,  where 0 ≤ m ≤ 7,  i.e.  if at least a hexagon is    
  1168.     destroyed,  then this instruction is evaluated again.  The result of    
  1169.     the first expression  is ignored,  but this expression is to set the    
  1170.     marks m.
  1171.   _ $70:  number of cells  in an edge of the hexagonal board  (between 6    
  1172.     and 9).
  1173.   _ $71 <c> <h>:  identifier of the cell  being in column c  and  having    
  1174.     height h. If the cell isn't in the board (non-existing cell), then 0    
  1175.     is returned.
  1176.   _ $72 <x>: height of the cell x (undetermined if x = 0).
  1177.   _ $73 <x>: column of the cell x (undetermined if x = 0).
  1178.       Note:  the next 4 commands  allow to perform operations on sets of    
  1179.     cells  (recursivity  is  allowed,  what  is useful  for instance  to    
  1180.     search for connected componants or for other kinds of route).  These    
  1181.     operations  always return  the value of the expression  for the last    
  1182.     element, that is always the non-existing cell (0).  For each cell of    
  1183.     the set (the non-existing cell included), the current cell is stored    
  1184.     into V[n],  and the expression e is evaluated.  For each case below,    
  1185.     the set is given without the non-existing cell.
  1186.   _ $74 <n> <x> <e>: set = all cells adjacent to cell x and containing a    
  1187.     hexagon.
  1188.   _ $75 <n> <x> <e>: set = all existing cells adjacent to cell x.
  1189.   _ $76 <n> <e>: set = all cells containing a hexagon.
  1190.   _ $77 <n> <e>: set = all existing cells.
  1191.   _ $78 <x> <m>: true iff cell x has the mark m (m must be between 0 and    
  1192.     7).
  1193.   _ $79 <x> <m>:  if  0 ≤ m ≤ 15,  the mark  (m modulo 8)  of cell x  is    
  1194.     inverted; if m < 0, all the marks of cell x are inverted.  If m ≤ 7,    
  1195.     the value x  is returned;  if  8 ≤ m ≤ 15,  a boolean indicating the    
  1196.     state of the mark m - 8 is returned.
  1197.   _ $7A <x> <m>: idem, but the mark is cleared instead of being inverted    
  1198.     (bit = 0).
  1199.   _ $7B <x> <m>:  idem,  but the mark  is set  instead of being inverted    
  1200.     (bit = 1).
  1201.   _ $7C <n>:  if n < 0, number of hexagons (between 1 and 4) in the last    
  1202.     (or current)  piece;  if  n = 0,  identifier  of the cell containing    
  1203.     the reference hexagon  of the last  (or current)  piece;  if  n > 0,    
  1204.     identifier  of the cell containing the n-th hexagon  of the last (or    
  1205.     current)  piece;  warning!  n mustn't be  higher  than the number of    
  1206.     hexagons of the piece.
  1207.   _ $7D <x>: identifier of the pattern on the hexagon in cell x if there    
  1208.     is any,  0 if the cell is empty,  -1 if the cell  doesn't exist (0).    
  1209.     The test "> 0"  allows to know  whether  there is  a hexagon  in the    
  1210.     cell,  the test "!= 0" allows to know whether the cell exists and is    
  1211.     empty.
  1212.   _ $7E <x>: idem, for the color of the hexagon instead of the pattern.
  1213.   _ $7F <x> <d>:  identifier of a cell  adjacent to cell x  if x exists,    
  1214.     non-existing cell  if  x is the non-existing cell;  d indicates  the    
  1215.     direction.  One considers  the value of d modulo 6  (for there are 6    
  1216.     possible directions). $7F <x> 0: adjacent cell downwards, $7F <x> 1:    
  1217.     downwards to the right, $7F <x> 2: upwards to the right,  $7F <x> 3:    
  1218.     upwards, $7F <x> 4: upwards to the left, $7F <x> 5: downwards to the    
  1219.     left.
  1220.  
  1221.  
  1222.     7. Messages
  1223.        ¯¯¯¯¯¯¯¯ 
  1224.   N.B.:  this section is useful only to those who have a registered version,
  1225. since in the unregistered version one can't send messages.
  1226.  
  1227.   The system  of  messages  allows  TETRHEX  to  communicate  with  external
  1228. routines,  which can communicate  with other processes.  Originally messages
  1229. aimed to send and receive AES messages; but one can do much more.
  1230.  
  1231.   At the start,  TETRHEX is given external routines, grouped in files called
  1232. "message files".  A message file  consists of a routine  composed of several
  1233. subroutines.  TETRHEX may be given several message files; they form a chain,
  1234. the last  loaded file  (i.e.  the last file  in the option string)  has  the
  1235. highest  priority  (cf below).  At  some moments,  TETRHEX  sends  a message
  1236. (type + data),  which corresponds to a routine call,  a subroutine is chosen
  1237. according to the message type,  and a result is returned;  the send/transmit
  1238. protocol  is described below.  Since there must be at least one routine,  in
  1239. particular  when the user don't give any message file,  TETRHEX  contains an
  1240. internal message file  called  terminal file,  which  always  has  the least
  1241. priority.
  1242.  
  1243.   Send/transmit protocol  (in assembly 680x0):  TETRHEX  or  a routine  of a
  1244. message file may send a message as follows:  D0.W contains the message type,
  1245. and  A0 is  a pointer  to a structure,  composed of a long word  that is the
  1246. address  of the routine  of the message file  that has  the highest priority
  1247. (address of the file + 4)  and other possible data  depending on the message
  1248. type.  The routine  returns a result  in D0.L,  whose meaning depends on the
  1249. message type;  the other registers  aren't  altered.  When  a routine  of  a
  1250. message file  receives  a message,  it  processes  the message  if  possible
  1251. (according  to the message type),  otherwise  it  transmits  the message  to
  1252. the next message file;  even if the message  has been processed,  it  may be
  1253. transmitted  to the next message file  (this depends on the process).  N.B.:
  1254. the processing routine mustn't modify registers D1 to D7 and A0 to A7; hence
  1255. the modified registers  must be saved  at the beginning  and restored at the
  1256. end. The transmission is performed as follows: D0.W, A0 and (A0).L must have
  1257. the values  given at the call;  the address  of the routine of the next file
  1258. is stored  at the address  of the current file,  i.e.  at the address of the
  1259. current routine - 4;  the address of the routine to call being known, either
  1260. a branch  or a call to a subroutine  (to be able  to modify  the result)  is
  1261. performed.  The terminal file always returns 0 and doesn't do anything else;
  1262. thus  the process of a message  should return 0  if and only if  nothing has
  1263. been done.
  1264.  
  1265. Types of the currently defined messages:
  1266.   _ $0000: unspecified (depends on the message file).
  1267.   _ $0001: initialization.  This message  is sent  just after appl_init.    
  1268.     4(A0).W contains the identifier of application TETRHEX (used to send    
  1269.     AES messages to TETRHEX). 6(A0).B: error display flag (0 if the "-e"    
  1270.     option isn't active, -1 if it is active);  the message file may send    
  1271.     characters to the standard output file  only if this flag is active.    
  1272.     If no error occurs,  this message  must be  transmitted  to the next    
  1273.     message file  (a zero value  will be returned by the terminal file).    
  1274.     Otherwise the initialization must be interrupted and a nonzero value    
  1275.     must be returned; TETRHEX ends and returns the less significant word    
  1276.     as the return code.
  1277.   _ $0002: end of program.  Message sent just before appl_exit.  It must    
  1278.     always be transmitted to the next message file.
  1279.   _ $0003: beginning of the presentation.  This message is never sent if    
  1280.     there is no presentation, i.e. in GEM window mode.
  1281.   _ $0004: menu display;  the background image  isn't displayed yet.  If    
  1282.     a nonzero number  is returned,  the background image  is immediately    
  1283.     freed, which allows to change it (cf message $0006).
  1284.   _ $0005: menu displayed (wait for an event).
  1285.   _ $0006: request for the computation  of the background image.  If the    
  1286.     result is 0, the image will be computed by TETRHEX.  In the opposite    
  1287.     case,  the image is computed  by the message file  and the result is    
  1288.     the address of the image.  The image,  on which  the hexagonal board    
  1289.     will  be  displayed  (by TETRHEX),  is composed of  7 non-interlaced    
  1290.     planes (VDI format) 624 * 416,  the pixel values being between 0 and    
  1291.     95,  i.e. the most significant two bits  aren't both 1.  The palette    
  1292.     (96 long words)  is stored  just after the image.  N.B.:  the memory    
  1293.     block  containing the new background image  must be reserved  by the    
  1294.     routine of the message file,  but it will be freed  only by TETRHEX,    
  1295.     either automatically  (if there isn't much memory left),  or  due to    
  1296.     the user request  (Ctrl-F  or  right click),  or with a message  (cf    
  1297.     message $0004).
  1298.   _ $0007: new loaded rule file.  4(A0).L  contains  the address  of the    
  1299.     rule file.  This message  is sent by TETRHEX  just after a rule file    
  1300.     has been loaded.  It is the case for the first loaded rule file, and    
  1301.     the message is sent between $0001/$0003 and $0004.
  1302.   _ $0008: help about TETRHEX.  This message  is sent  only if  the help    
  1303.     actually exists.
  1304.   _ $0009: help about the rule file.  This message  is sent  only if the    
  1305.     help actually exists.
  1306.   _ $000A: entry of the player name.
  1307.   _ $000B:  beginning  of the game.  Message sent  before phase 0 of the    
  1308.     rule has been evaluated.
  1309.   _ $000C: display of the highest scores.
  1310.   _ $0100: window pause mode. Message sent after the possible evaluation    
  1311.     of phase P of the rule.
  1312.   _ $0101: end of window pause mode.  Message sent  before  the possible    
  1313.     evaluation of phase Q of the rule.
  1314.   _ $0200: unspecified (depends on the message file).  Message linked to    
  1315.     the game.
  1316.   _ $0201: beginning of the game.  4(A0).L: game stack pointer. 8(A0).L:    
  1317.     pointer to the game variables.  12(A0).L:  pointer to the rule file.    
  1318.     Message sent after the evaluation of phase 0 of the rule.
  1319.   _ $0202: game over. 4(A0).L: score.  Message sent after the evaluation    
  1320.     of phase S  of the rule  and before the memory reserved for the game    
  1321.     (variables, stack, ...) has been freed.
  1322.   _ $0203: next piece.  The data about this piece aren't stored into the    
  1323.     structure (A0)  because they can be read through the game variables.    
  1324.     This message is sent before the piece has been displayed.
  1325.   _ $0204: a piece has just been displayed.
  1326.   _ $0205: action. 4(A0).L: action identifier. This message is sent just    
  1327.     after phase B of the rule  has been evaluated  and the numbers  have    
  1328.     been updated (display), and before the action is executed.
  1329.   _ $0206: message sent by the action +10.  4(A0).L: game stack pointer.    
  1330.     The data have been stored into the game stack.  The top of the stack    
  1331.     contains  the number  of  pushed data  (N.B.:  this long word  isn't    
  1332.     included in the data);  these data  will be pulled by TETRHEX  after    
  1333.     the call.
  1334.   _ $0207: message sent by the RUL interpreter (cf command $6D). 4(A0).L    
  1335.     contains the game stack pointer.
  1336.   _ $0208: message sent  just before phase A of the game.  If the result    
  1337.     isn't 0, phase A won't be executed and message $0209 won't be sent.
  1338.   _ $0209: message sent just after phase A of the game.
  1339.   _ $0300: read a signal. 4(A0).L: code of the key (state of the special    
  1340.     keys + scancode + ASCII code) if a key has been hit, otherwise 0. If    
  1341.     no signal is detected and if the key isn't taken into account by the    
  1342.     message file,  0 must be returned  (TETRHEX  will take  the key into    
  1343.     account and will transmit the possible signal to phase B of the rule    
  1344.     file). If no signal is detected and if the key doesn't correspond to    
  1345.     any signal  or mustn't be taken into account,  a negative value must    
  1346.     be returned.  If a signal is detected (last case), due to the key or    
  1347.     for any other reason,  the external identifier of the signal must be    
  1348.     returned.
  1349.   _ $0301:  emulation  of a function key.  A value  between 1 and 20  is    
  1350.     returned to emulate the corresponding function key. Otherwise 0 must    
  1351.     be returned.
  1352.   _ $0302: emulation of an event in the main menu.  The returned value n    
  1353.     has  the following meaning:  0:  no event,  1:  help  about TETRHEX,    
  1354.     2: help  about the rule,  3: load a rule,  4: player name,  5: play,    
  1355.     6: highest scores, 7: background, 8: quit, 16 to 19: board with n-10    
  1356.     cells in an edge, -1 to -20: highest scores (function key F(-n)).
  1357.   _ $0303:  emulation  of an event  while  the player  enters  his name.    
  1358.     Meaning of the returned value n:  0: no event,  1 to 255: character,    
  1359.     which can be displayed or not  (3: ctrl-C, 8: backspace, 13: return,    
  1360.     27: escape), -1: right arrow, -2: up arrow.
  1361.   _ $0304: emulation of the Esc key at the end of the game. The returned
  1362.     value must be nonzero to come back to the main menu.
  1363.   _ $0400:  AES message  of type ≥ 128  received  by  TETRHEX.  4(A0).L:    
  1364.     pointer to the message buffer (cf evnt_mesag).
  1365.   _ $0401: hit key that isn't taken into account by TETRHEX, in the main    
  1366.     menu.  4(A0).W: state of the special keys (cf evnt_button). 6(A0).W:    
  1367.     code of the key,  i.e.  scancode of the key  in the most significant    
  1368.     byte and ASCII code in the least significant byte (cf evnt_keybd).
  1369.  
  1370.   Note 1:  in the game,  the stack  is descending,  i.e.  when one pushes an
  1371. integer,  4 is subtracted  from the stack pointer  (for the elements have 32
  1372. bits).  The stack pointer points  to the top of the stack,  i.e. to the last
  1373. pushed integer  when  the stack  isn't empty.  The initial stack pointer  is
  1374. given by message $0201; at this moment, the stack is empty.
  1375.  
  1376.   Note  2:   the  messages  of  type  $03xx   allow  to  perform  background
  1377. computations (with a non-preemptive operating system).
  1378.  
  1379.  
  1380.     8. Technical Notes
  1381.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  1382.   This section  is  aimed  at  those  who know  the TOS/GEM  quite well,  in
  1383. particular the programmers.
  1384.  
  1385.         8.1. Program Flags
  1386.              ¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  1387.   Note:  since the assembler I use can't set the program flags (PRGFLAGS) as
  1388. I want, I may forget to modify them in some versions of TETRHEX. These flags
  1389. are stored at the offset 0x16 of the program TETRHEX.GTP/PRG.
  1390.  
  1391.   You can modify the bits 0 to 2 with Dieter Fiebelkorn's CPX FileInfo.
  1392.  
  1393.   _ Bit 0 (fastload): you'd better set it to speed up the loading.
  1394.   _ Bit 1 (TT-RAM prg) and 2 (TT-RAM mem): you'd better set them.
  1395.   _ Bit 3: unused (clear it).
  1396.   _ Bits 4 and 5: you'd better clear them.
  1397.   _ Bits 6 to 15: unused (clear them).
  1398.  
  1399.         8.2. Error Codes
  1400.              ¯¯¯¯¯¯¯¯¯¯¯ 
  1401.   The list of the values  that can be returned  by TETRHEX  is given  below.
  1402. When  an error occurs,  it is indicated  by an alert box  in addition to the
  1403. returned code, if the AES has been initialized.
  1404.  
  1405.   _ 0: no error.
  1406.   _ 1: insufficient memory.
  1407.   _ 2: the resolution can't be changed.
  1408.   _ 3: bad processor (a 68020 at least is necessary).
  1409.   _ 4: a workstation can't be opened.
  1410.   _ 5: a window can't be created.
  1411.   _ 6: font problem.
  1412.   _ 7: rule file not found.
  1413.   _ 8: bad rule file format.
  1414.   _ 9: internal error.
  1415.   _ 10: bad option string.
  1416.   _ 11: bad language file format.
  1417.   _ 12: help file not found.
  1418.   _ 13: bad help format.
  1419.   _ 14: stack overflow.
  1420.   _ -1: system error.
  1421.  
  1422.         8.3. Moving the Window
  1423.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  1424.   With TOS 4, if one of the 2 lines at the bottom or one of the 2 columns at
  1425. the right of a window (used for the 3D effect)  is out of the screen  and if
  1426. the window  is moved to the inside of the screen,  then a redraw message  is
  1427. always sent  (GEM bug).  In order to avoid  this redraw,  it is forbidden to
  1428. these 2 lines and 2 columns  to get out of the screen;  but  as  they aren't
  1429. a part  of the window  for the AES,  one must take them into account  in the
  1430. computations.
  1431.  
  1432.         8.4. Palette Modification
  1433.              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  1434.   In whole screen mode,  the palette is modified many times by TETRHEX,  but
  1435. it is restored at the end.
  1436.  
  1437.   But in GEM window mode,  a problem arises,  since several applications (or
  1438. accessories)  may use different palettes.  The best  would be  to select the
  1439. palette  of the application  that  has  the foreground window,  i.e.  when a
  1440. window gets to the foreground, the palette is changed at the same time;  but
  1441. the AES  can't do that.  Thus  it's TETRHEX  that changes  the palette  when
  1442. the window  gets to the foreground;  when TETRHEX's window is untopped,  the
  1443. palette isn't modified by TETRHEX, since it can't know the new palette: it's
  1444. the application  having the topped window  that must change  the palette. If
  1445. all the applications  using a 256-color palette  behave like this,  problems
  1446. shouldn't arise  in general  (but the window mustn't be untopped  before the
  1447. palette is changed). Note: the first 16 colors are never modified by TETRHEX
  1448. (in GEM window mode)  and  mustn't  be  modified  by  any other application.
  1449. Obviously, when TETRHEX is quitted, the old palette isn't restored.
  1450.  
  1451.  
  1452.     9. Limitations of the Unregistered Version
  1453.        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 
  1454. The unregistered version has the following limitations:
  1455.   _ The rule can't be changed (the Undo key is disabled).
  1456.   _ The board size can't be changed.
  1457.   _ The scores are not saved.
  1458.   _ A game ends after about 5 minutes.
  1459.   _ After 10 games, TETRHEX automatically ends.
  1460.   _ Message files can't be used.
  1461.  
  1462.   The rule  and  the board size  must  be  chosen  at the start  (cf section
  1463. "Starting and Configuring TETRHEX").
  1464.  
  1465.   If you get registered,  you'll receive  a version  without any limitation,
  1466. but also some message files with the sources,  the source of a mini-compiler
  1467. allowing to create rule files much more easily,  and the documentation about
  1468. the format (ASCII).  You'll also receive  the source of the rule files  that
  1469. are provided with TETRHEX,  so that  you can modify them  and that  they are
  1470. used as examples.
  1471.  
  1472.  
  1473. Vincent Lefèvre
  1474.