home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / communications / te_protocol.txt < prev    next >
Text File  |  2006-10-19  |  92KB  |  2,290 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                            TEXAS INSTRUMENTS
  7.  
  8.                    TERMINAL EMULATOR PROTOCOL MANUAL
  9.  
  10.                              May 18, 1981
  11.  
  12.            IMPORTANT NOTICE REGARDING TECHNICAL DATA
  13.  
  14.  
  15. TEXAS INSTRUMENTS MAKES NO WARRANTY, EITHER EXPRESSED OR IMPLIED,
  16. INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF
  17. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
  18. THIS LITERATURE OR ANY INFORMATION DERIVED THEREFROM AND MAKES
  19. ALL MATERIAL AVAILABLE SOLELY ON AN "AS IS" BASIS.
  20.  
  21.  
  22. IN NO EVENT SHALL TEXAS INSTRUMENTS BE LIABLE TO ANYONE FOR
  23. SPECIAL, COLLATERAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN
  24. CONNECTION WITH OR ARISING OUT OF THE PURCHASE OR USE OF THIS
  25. LITERATURE AND THE SOLE AND EXCLUSIVE LIABILITY OF TEXAS
  26. INSTRUMENTS, REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED
  27. THE PURCHASE PRICE OF THIS BOOK.  MOREOVER, TEXAS INSTRUMENTS
  28. SHALL NOT BE LIABLE FOR ANY CLAIM OF ANY KIND WHATSOEVER BY ANY
  29. OTHER PARTY AGAINST THE USER OF THIS LITERATURE.
  30.  
  31.                        Table Of Contents
  32.  
  33.                            SECTION 1
  34.  
  35.                          INTRODUCTION
  36.  
  37. PURPOSE . . . . . . . . . . . . . . . . . . . . . . . . . .  1.1
  38. AUDIENCE. . . . . . . . . . . . . . . . . . . . . . . . . .  1.2
  39. CONVENTIONS . . . . . . . . . . . . . . . . . . . . . . . .  1.3
  40.  
  41.                            SECTION 2
  42.  
  43.                     THE TI-99/4 ENVIRONMENT
  44.  
  45. INTRODUCTION. . . . . . . . . . . . . . . . . . . . . . . . 2.1
  46. VIDEO CONTROL . . . . . . . . . . . . . . . . . . . . . . . 2.2
  47. GRAPHICS MODE . . . . . . . . . . . . . . . . . . . . . . . 2.2.1
  48. TEXT MODE . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2
  49. SOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3
  50. SOUND LIST. . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1
  51. SOUND LIST CONTROL BLOCK. . . . . . . . . . . . . . . . . . 2.3.2
  52. SPEECH. . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4
  53. SPEECH DICTIONARY . . . . . . . . . . . . . . . . . . . . . 2.4.1
  54. TEXT-TO-SPEECH. . . . . . . . . . . . . . . . . . . . . . . 2.4.2
  55. DISK FILES. . . . . . . . . . . . . . . . . . . . . . . . . 2.5
  56. FIXED LENGTH RECORD FILES . . . . . . . . . . . . . . . . . 2.5.1
  57. VARIABLE LENGTH RECORD FILES. . . . . . . . . . . . . . . . 2.5.2
  58. BASIC PROGRAM IMAGE FILES . . . . . . . . . . . . . . . . . 2.5.3
  59. BASIC FORMAT DATA FILES . . . . . . . . . . . . . . . . . . 2.5.4
  60. DISK DIRECTORY. . . . . . . . . . . . . . . . . . . . . . . 2.5.5
  61. END OF FILE DETECTION . . . . . . . . . . . . . . . . . . . 2.5.6
  62.  
  63.                            SECTION 3
  64.  
  65.                           CODED DATA
  66.  
  67. REASONS FOR ENCODING DATA  . . . . . . . . . . . . . . . . . 3.1
  68. DATA CODING . . . . . . .  . . . . . . . . . . . . . . . . . 3.2
  69.  
  70.                            SECTION 4
  71.  
  72.                    EMULATOR CONTROL FORMATS
  73.  
  74. CONTROL CHARACTERS. . . . . . . . . . . . . . . . . . . . . 4.1
  75. SPECIAL ESCAPE SEQUENCES. . . . . . . . . . . . . . . . . . 4.2
  76. EXTENDED WRITES . . . . . . . . . . . . . . . . . . . . . . 4.3
  77. OPER >20 - DEFINE CHARACTERS. . . . . . . . . . . . . . . . 4.3.1
  78. OPER >21 - LOAD SOUND TABLES. . . . . . . . . . . . . . . . 4.3.2
  79. OPER >22 - PLAY SOUND TABLE . . . . . . . . . . . . . . . . 4.3.3
  80. OPER >23 - STOP SOUND . . . . . . . . . . . . . . . . . . . 4.3.4
  81. OPER >24 - SELECT CHARACTER BANK. . . . . . . . . . . . . . 4.3.5
  82. OPER >25 - DEFINE COLOR SETS. . . . . . . . . . . . . . . . 4.3.6
  83. OPER >26 - SPEAK AND DISPLAY TEXT . . . . . . . . . . . . . 4.3.7
  84. OPER >27 - SPEAK TEXT WITHOUT DISPLAY . . . . . . . . . . . 4.3.8
  85. OPER >28 - BREAK ALLOPHONES . . . . . . . . . . . . . . . . 4.3.9
  86. OPER >29 - LOOK UP WORDS. . . . . . . . . . . . . . . . . . 4.3.10
  87. OPER >2A - BREAK WORDS ASSOCIATED WITH NUMBERS. . . . . . . 4.3.11
  88. OPER >2B - CHANGE SCREEN COLOR. . . . . . . . . . . . . . . 4.3.12
  89. OPER >2C - RETURN STATUS. . . . . . . . . . . . . . . . . . 4.3.13
  90. OPER >2D - TRANSMIT COMMAND . . . . . . . . . . . . . . . . 4.3.14
  91.  
  92.                            SECTION 5
  93.  
  94.                          FILE TRANSFER
  95.  
  96. LRC ERROR DETECTION . . . . . . . . . . . . . . . . . . . . 5.1
  97. TRANSMISSION BLOCKS AND RECORDS . . . . . . . . . . . . . . 5.2
  98. TRANSMIT COMMAND FORMAT . . . . . . . . . . . . . . . . . . 5.3
  99. TRANSMISSION RECORD FORMATS . . . . . . . . . . . . . . . . 5.4
  100. ACK RECORD FORMAT . . . . . . . . . . . . . . . . . . . . . 5.5
  101. NAK RECORD FORMAT . . . . . . . . . . . . . . . . . . . . . 5.6
  102. FILE TRANSFER FROM REMOTE TO HOST . . . . . . . . . . . . . 5.7
  103. FILE TRANSFER FROM HOST TO REMOTE . . . . . . . . . . . . . 5.8
  104.  
  105.                            APPENDIX
  106.  
  107. DEFAULT CHARACTER SET . . . . . . . . . . . . . . . . . . . A
  108. EXAMPLE OF EMULATOR TO HOST FILE TRANSFER . . . . . . . . . B
  109. EXAMPLE OF HOST TO EMULATOR FILE TRANSFER . . . . . . . . . C
  110.  
  111.                            SECTION 1
  112.  
  113.                           INTRODUCTION
  114.  
  115.  
  116. 1.1   PURPOSE
  117.  
  118.       This manual provides a complete description of the
  119. communication protocol usad by the terminal emulator packages
  120. (starting with Terminal Emulator II).  It describes the steps
  121. needed to display text, create and display graphics and create
  122. and execute sound and speech on the TI-99/4 using the terminal
  123. emulator protocols.
  124.  
  125.  
  126. 1.2   AUDIENCE
  127.  
  128.       This manual is designed for programmers of host systems
  129. charged with writing software to interface with the terminal
  130. emulator packages.
  131.  
  132.  
  133. 1.3   CONVENTIONS
  134.  
  135.       The following conventions will be observed:
  136.  
  137.       1. Hex numbers will be denoted with a greater than symbol
  138.          (>).   For example hex 20 will be written as >20.
  139.  
  140.       2. Bits will be numbered from left to right.   For  example
  141.          the bit numbering for a byte would be:
  142.  
  143.         +-+-+-+-+-+-+-+-+
  144.         |0|1|2|3|4|5|6|7|
  145.         +-+-+-+-+-+-+-+-+
  146.  
  147.                            SECTION 2
  148.  
  149.                     THE TI-99/4 ENVIRONMENT
  150.  
  151.  
  152. 2.1   INTRODUCTION
  153.  
  154.       Effective use of the terminal emulator protocols requires a
  155. working knowledge of the TI-99/4.  This section provides
  156. information about video control, sound, speech and file access
  157. needed to implement the protocols on a host system.  Later
  158. sections describe the actual format of the protocols.
  159.  
  160.  
  161. 2.2   VIDEO CONTROL
  162.  
  163.       The terminal emulator supports the graphics and text modes
  164. of video operations.  The graphics mode will be explained
  165. followed by the differences between graphics and text modes.
  166.  
  167.  
  168. 2.2.1 GRAPHICS MODE.  The TI-99/4 supports 256 different
  169. characters for screen display.  The characters are identified by
  170. numeric codes >0 to >FF.  Codes in the range >20 to >7E are
  171. supplied a default definition by the terminal emulator.  For
  172. example, code >41 is defaulted to the letter A.  (See appendix A
  173. for a complete list of defaults.)  The user can redefine any of
  174. the 256 characters by using the protocols (see section 4.3.1).
  175.  
  176.  
  177.                                NOTE
  178.  
  179.            Any  of  the  256  characters  can be given a
  180.            definition by the user.   However, not all the
  181.            characters can be displayed by  the  emulator
  182.            package. Charactars >00, >0A, >0C, >1B, >80,
  183.            >8A,   >8C  and >9B cannot be displayed by the
  184.            emulator in graphics mode.
  185.  
  186.  
  187. 2.2.1.1 The Screen Display.  In graphics mode the screen is
  188. divided into 24 lines with 32 characters on each line.  Thus,
  189. there are a total of 768 character positions on the screen.  The
  190. lines are numbered from 0 to 23 and the columns are numbered from
  191. 0 to 31.
  192.  
  193.      The terminal emulator maintains a logical cursor position on
  194. the screen. The cursor symbol is not displayed while in graphics
  195. mode.  The next character received will be placed on the screen
  196. at the position identified by the cursor.  The cursor is then
  197. advanced to the next screen postion.  To display a character at
  198. the given cursor position the character code is transmitted to
  199. the TI-99/4.  For example, to display the default character
  200. specified by code >41 (the letter A) on the screen, the host
  201. system would transmit the >41 to the emulator.
  202.  
  203.      The protocol lets the user position the cursor on the
  204. screen.  Thus the host could display one character at line 10
  205. column 6 and the next character at line 0 column 0.  (See section
  206. 4.2).
  207.  
  208. 2.2.1.2 Character Banks.  Standard data transmission allows for
  209. 7 bits of data and 1 bit to check for parity.  Because of the
  210. parity bit the maximum number that can be transmitted to the TI-
  211. 99/4 is >7F.  Using standard transmissions the host cannot
  212. display characters in the range >80 to >FF.
  213.  
  214.      To overcome this limitation the terminal emulator has
  215. divided the characters into two banks for display purposes.  Bank
  216. 1 (or the lower bank) contains the characters >0 to >7F and bank
  217. 2 (or the upper bank) contains the characters >80 to >FF.  By
  218. default  the  terminal  emulator  will  use  bank  1  to  display
  219. characters.  The protocols, however, contain a command sequence
  220. to let the host switch between banks.
  221.  
  222.      When the emulator is using the upper bank, >80 is added to
  223. the received character code before the code is placed on the
  224. screen.  For example, suppose the user wants to display >41, >B0
  225. and >41.  Since the emulator defaults to the lower bank the user
  226. transmits >41 for the first character.  The character >B0 is in
  227. the upper bank (>80 to >FF) so the host must send the command
  228. sequence to switch banks.  The host can send either >B0 or >30
  229. (>B0 - >80) for the second character.  Since the parity bit is
  230. always removed by the emulator, the byte will be >30 when the
  231. emulator is ready to display it.
  232.  
  233.  
  234.                               NOTE
  235.  
  236.           Some host systems may put limitations on  the
  237.           transmission of characters in the range >80
  238.           to >FF.   Be certain the  constraints  of the
  239.           host  system  are  understood  when designing
  240.           programs.   Regardless of  what   transmissions
  241.           the  host  allows, all bytes in the range >80
  242.           to >FF will be converted to the range  >0   to
  243.           >7F when the parity bit is removed.
  244.  
  245.  
  246. Since the emulator is now operating on the upper bank, >80 will
  247. be added to the received  byte  and  >B0   (>30  +  >80)  will  be
  248. displayed.
  249.  
  250.      The final character to send is >41 which is in the lower
  251. bank (>0 to >7F).  The user must send the control sequence to
  252. switch banks so the emulator will once again be operating on the
  253. lower bank.  The character can then be transmitted.  (See section
  254. 4.3.5).
  255.  
  256. 2.2.1.3 Character Definition.  There are 768 character positions
  257. on a standard graphics screen.  Each pattern position is composed
  258. of an 8-by-8 grid of dots called pixels.  Each pixel in the
  259. character grid can be either "on" or "off".  A character
  260. definition simply defines the status (on or off) of each of the
  261. 64 pixels in a character grid.
  262.  
  263.      To define a character using the terminal emulator protocols
  264. the user specifies the code of the character to be defined (>0 to
  265. >FF) and eight bytes of hex data.  There are a total of 64 bits
  266. in the eight bytes of data.  Each of the bits corresponds to one
  267. of the pixels in the charactar grid.  The eight bits in byte one
  268. refer to the first row of eight pixels, the eight bits in byte
  269. two refer to the second row of 8 pixels and so on.
  270.  
  271.      If a bit in  the  character  definition  contains  a  1  the
  272. corresponding pixel is turned on.  If a bit contains a 0 the
  273. corresponding pixel is turned off.  Figure 2-1 is an example of
  274. the hex data required to define the letter T.  (See section
  275. 4.3.1).
  276.  
  277.                 Character Grid                 Hex  Data
  278.  
  279.        Row 1    1 1 1 1 1 1 1 1         Byte 1    FF
  280.        Row 2    1 1 1 1 1 1 1 1         Byte 2    FF
  281.        Row 3    0 0 0 1 1 0 0 0         Byte 3    18
  282.        Row 4    0 0 0 1 1 0 0 0         Byte 4    18
  283.        Row 5    0 0 0 1 1 0 0 0         Byte 5    18
  284.        Row 6    0 0 0 1 1 0 0 0         Byte 6    18
  285.        Row 7    0 0 0 1 1 0 0 0         Byte 7    18
  286.        Row 8    0 0 0 1 1 0 0 0         Byte 8    18
  287.  
  288.                 Figure 2-1  LETTER T DEFlNITION
  289.  
  290.  
  291. 2.2.1.4  Defining  Character  Color.   The  TI-99/4  supports  16
  292. different colors on the video display.  However any given
  293. character can only contain two colors called the foreground color
  294. and the background color.  The colors are denoted by numeric
  295. codes ranging from >0 to >F.  Table 2-1 lists the colors and hex
  296. codes supported by the emulator.
  297.  
  298.                     Table 2-1 COLOR CODES
  299.  
  300.                     Hex               Color
  301.  
  302.                     >0              Transparent
  303.                     >1              Black
  304.                     >2              Medium Green
  305.                     >3              Light Green
  306.                     >4              Dark Blue
  307.                     >5              Light Blue
  308.                     >6              Dark Red
  309.                     >7              Cyan
  310.                     >8              Medium Red
  311.                     >9              Light Red
  312.                     >A              Dark Yellow
  313.                     >B              Light Yellow
  314.                     >C              Dark Green
  315.                     >D              Magenta
  316.                     >E              Gray
  317.                     >F              White
  318.  
  319.  
  320.      Each pixel in the character grid on the video can be either
  321. the foreground or the background color.  The bits in the
  322. character definition specify the color.  If the bit contains a  1
  323. the corresponding pixel uses the foreground color (the pixel is
  324. "on").  If the bit contains a 0 the corresponding pixel uses the
  325. background color (the pixel is "off").
  326.  
  327.      For color control the 256 characters are divided into 32
  328. groups called color sets.  Each color set contains eight
  329. characters.   Table 2-2 gives the color sets.
  330.  
  331.                       Table 2-2 COLOR SETS
  332.  
  333.                Color Set               Characters
  334.  
  335.                   > 0                   >00 to >07
  336.                   > 1                   >08 to >0F
  337.                   > 2                   >10 to >17
  338.                   > 3                   >18 to >1F
  339.                   > 4                   >20 to >27
  340.                   > 5                   >28 to >2F
  341.                   > 6                   >30 to >37
  342.                   > 7                   >38 to >3F
  343.                   > 8                   >40 to >47
  344.                   > 9                   >48 to >4F
  345.                   > A                   >50 to >57
  346.                   > B                   >58 to >5F
  347.                   > C                   >60 to >67
  348.                   > D                   >68 to >6F
  349.                   > E                   >70 to >77
  350.                   > F                   >78 to >7F
  351.                   >10                   >80 to >87
  352.                   >11                   >88 to >8F
  353.                   >12                   >90 to >97
  354.                   >13                   >98 to >9F
  355.                   >14                   >A0 to >A7
  356.                   >15                   >A8 to >AF
  357.                   >16                   >B0 to >B7
  358.                   >17                   >B8 to >BF
  359.                   >18                   >C0 to >C7
  360.                   >19                   >C8 to >CF
  361.                   >1A                   >F0 to >D7
  362.                   >1B                   >D8 to >DF
  363.                   >1C                   >E0 to >E7
  364.                   >1D                   >E8 to >EF
  365.                   >1E                   >F0 to >F7
  366.                   >1F                   >F8 to >FF
  367.  
  368.  
  369.      All characters in a given color set are assigned the same
  370. foreground and background colors.  For example, assume character
  371. >23 has a foreground color of black and a background color of
  372. cyan.  Then all characters in color set >4  (characters  >20  to
  373. >27) will have the same foreground and background colors.  The
  374. only way characters can have different colors is for them to be
  375. from different color sets.
  376.  
  377.      One byte is required to define the color for a color set.
  378. Numbering bits 0 to 7 from left to right, bits 0-3 contain the
  379. foreground color and bits 4-7 contain the background color.  For
  380. example, assume color set >B is to have a foreground color of
  381. black and a background color of cyan.  From Table 2-1 we know
  382. black has a color code of >1 and cyan has a color code of >7.
  383. The byte required to define the color would be >17.
  384.  
  385.      The host system can define the foreground and background
  386. colors for the characters using the protocols.  The host must
  387. supply  the  color  set  identifer  (>0  to  >1F) followed by the
  388. desired foreground and background colors.   (See section 4.3.6).
  389.  
  390. 2.2.1.5 Defining Screen Color.  The TI-99/4 also lets a user
  391. assign a color to the entire screen.  This includes the area at
  392. the top and bottom of the screen, called the border, where
  393. characters cannot be placed.  The screen color is the color
  394. displayed when transparent (color code >0) is used as a character
  395. color.  The protocols supports a command sequence that lets the
  396. host define the screen color.  (See section 4.3.12).
  397.  
  398.  
  399. 2.2.2 TEXT MODE.  Text mode differs from graphics mode in the
  400. following ways:
  401.  
  402.     1. Each line on the screen is 40  characters   long.    Thus
  403.        there are 960 character positions on the display.
  404.  
  405.     2. Each character grid  on   the  screen  consists  of  six
  406.        columns and eight rows of pixels for a total of 48
  407.        pixels per character.   Eight bytes of  data  are  still
  408.        required   to  define  the  grid. However,  the last two
  409.        bits in each byte are ignored by the system.
  410.  
  411.     3. All characters are limited to the same foreground and
  412.        background  colors.   A special command sequence is used
  413.        to change the colors.   The same command  sequence  will
  414.        change   the  screen  color   (refer to 2.2.1.5) when the
  415.        emulator is in graphics mode.
  416.  
  417.     4. Characters >00 to >1F, >7F, >80 to >9F and >FF will not
  418.        be displayed while in text mode.
  419.  
  420. The protocol has a special command sequence used to switch
  421. between text and graphics modes.   (See section 4.2).
  422.  
  423.  
  424. 2.3 SOUND
  425.  
  426.      The TI-99/4 supports three sound generators and one noise
  427. generator.  The terminal emulator protocols let the host system
  428. control the generators.  The generators can be used to create
  429. music and sound effects.
  430.  
  431.  
  432. 2.3.1 SOUND LIST.  The volume and frequency of the generators
  433. are controlled by a memory resident table called a sound list.
  434. The sound list is composed of  variable  length  control  blocks.
  435. The general format of a control block is:
  436.  
  437. +------+----+----+
  438. |LENGTH|DATA|TIME|
  439. +------+----+----+
  440.  
  441. LENGTH is a one byte field that specifies the number of bytes
  442. contained in DATA.  DATA is a variable length area that controls
  443. the volume and frequency output of the generators.  TIME is a one
  444. byte field that specifies the time interval the TI-99/4 is to
  445. wait before it starts processing the next control block.  The
  446. timer is in 60ths of a second.
  447.  
  448.      For example, assume that the user has defined ten bytes of
  449. generator control information (a complete explanation of this
  450. area is below).  The TI-99/4 is to process a block with the ten
  451. bytes of data and pause for 1/2 second.  The length byte (LTH)
  452. would contain >A to specify that ten bytes of control information
  453. follows (DATA).  Next would come the actual control information.
  454. And finally the timer byte (TIME) would contain a >1E to specify
  455. that a pause of 1/2 second (30/60ths of a second) is to occur
  456. before processing the next control block.  The sound will remain
  457. constant until the next control block is processed.  The actual
  458. sound list would be:
  459.  
  460. +--+--+--+--+--+--+--+--+--+--+--+--+
  461. |0A|B0|B1|B2|B3|B4|B5|B6|B7|B8|B9|1E|
  462. +--+--+--+--+--+--+--+--+--+--+--+--+
  463.  
  464.      A sound list on the TI-99/4 can be terminated in two ways.
  465. One option is to stop processing the sound lists completely.  To
  466. do this the timer byte of the last control block within the list
  467. must contain a zero.  The control block associated with the zero
  468. timer byte will be processed.
  469.  
  470.  
  471.                               NOTE
  472.  
  473.           Once a generator has  been  started  it    will
  474.           continue to output sound at a constant volume
  475.           and  frequency  until  a  control  block in a
  476.           sound list modifies the settings.  Unless the
  477.           programmer wants a sound  to  continue  at  a
  478.           constant   volume  and  frequency, the control
  479.           block that terminates the sound list (control
  480.           block with a timer byte of zero) should   turn
  481.           off all generators by setting all volumes to
  482.           off.
  483.  
  484.      The other termination option is to use the last entry in a
  485. sound list to branch to the start of the same sound list or to
  486. the start of another sound list.  Using this method the host can
  487. produce continuous sound with a limited amount of control data.
  488. To link to another sound list (or to the start of the same list)
  489. specify a length byte of zero followed by the two byte address of
  490. the next sound list.  The protocols have a command sequence to
  491. turn off all sound generators.  This provides a means of stopping
  492. continuous sound.   (See section 4.3.4).
  493.  
  494.      The emulator package has set aside 16 table areas in memory
  495. to hold sound lists.  The tables are numbered >0 to >F.  Each
  496. table is 128 bytes in length and the areas are contiguous in
  497. memory.  The first table (number 0) is at address >1100, the
  498. second table (number 1) is at >1180 and so on.  The host can use
  499. the protocols to store data in the tables.   (See section 4.3.2).
  500.  
  501.      A sound list may be larger than 128 bytes.  If it is larger
  502. than 128 bytes it will use part of the next table in sequence to
  503. hold the excass.  For example, assume table >3 is loaded with a
  504. 224 byte sound list.  Then all of table >3 is used and 96 (224   -
  505. 128) bytes of table >4 are also used.  If the user tried to load
  506. another sound list into table >4 he would destroy the last 96
  507. bytes of the sound list loaded in table >3.
  508.  
  509.      Assume the host wants to place a sound list in table >2 and
  510. link it to play music continuously.  The host constructs the
  511. sound list and loads it into table >2.  The last control block in
  512. the list would contain a length byte of zero followed by address
  513. >1200 (memory address of sound table >2).
  514.  
  515.  
  516. 2.3.2 SOUND LIST CONTROL BLOCK.  The control block specifies
  517. three items of information:  volume level for sound and noise
  518. generators; frequency for sound generators and frequency for the
  519. noise generator.  The information can be specified in any
  520. sequence and for any number of generators.
  521.  
  522. 2.3.2.1 Volume Level.  Eight bits of information are required to
  523. control volume levels.  The bits are numbered 0 to 7 from left to
  524. right.   The format of the bits is:
  525.  
  526.      1. bit 0 - Must be set to 1.
  527.  
  528.      2. bits 1-2 - Denotes the  generator  to  control.    Valid
  529.         entries are:
  530.  
  531.         a. 00 - Sound generator 0.
  532.  
  533.         b. 01 - Sound generator 1.
  534.  
  535.         c. 10 - Sound generator 2.
  536.  
  537.         d. 11 - Noise generator.
  538.  
  539.     3. bit 3 - Set to 1 to indicate volume control.
  540.  
  541.     4. bits 4-7 - Volume setting to use.   Possible values (in
  542.        binary)   range  from 0000 to 1111. 0000 is the highest
  543.        volume, 1000 is a medium  volume  and  1111   turns  the
  544.        generator off.
  545.  
  546.  
  547.       For  example  to turn generator 1 to the highest volume the
  548. volume level byte would be:  1 01 1 0000.  To turn the  generator
  549. 0   to  a  medium  volume  the volume level byte would be: 1 00 1
  550. 1000.  To turn generator 3 (noise generator) off the volume level
  551. byte would be:  1 11 1 1111.
  552.  
  553. 2.3.2.2   Sound  Generator  Frequency  Control.   Two  bytes  are
  554. required  to  control  the fequency of the sound generators.   The
  555. bits are numbered 0 to 15 from left to right.
  556.  
  557.       The frequency is converted to a value called tha  frequency
  558. count.    The  count is then specified in the control byte instead
  559. of the original frequency.   The count is always specified as   ten
  560. bits  of  data.    The  formula used for the conversion is COUNT
  561. 111860 / FREQUENCY.   For example, the count for  a  frequency  of
  562. 110  Hz  would  be 111860 / 110 which is 1016.9.  Since the count
  563. must be an integer this rounds to 1017.
  564.  
  565.  
  566.                               NOTE
  567.  
  568.           The frequency range  allowed   is 110  Hz   to
  569.           55,938 Hz, or a count of 1017 to 2.
  570.  
  571.  
  572.       The format of the frequency bytes is:
  573.  
  574.     1. bit 0 - must be set to 1.
  575.  
  576.     2. bits 1-2 - Generator to work with.  Valid entries are:
  577.  
  578.        a. 00 - Sound generator 0.
  579.  
  580.        b. 01 - Sound generator 1.
  581.  
  582.        c. 10 - Sound generator 2.
  583.  
  584.                               NOTE
  585.  
  586.          The noise generator (bit setting 11) is not a
  587.           valid entry.
  588.  
  589.  
  590.     3. bit 3 - Set to 0 to indicate frequency control.
  591.  
  592.     4. bits 4-7 - The LAST four bits of the count.
  593.  
  594.     5. bits 8-9 - Set to 00.
  595.  
  596.     6. bits 10-15 - The FIRST six bits of the count.
  597.  
  598.  
  599.     As an example assume that generator 1 is to be set to a
  600. frequency of 5,676 Hz.  First the frequency must be converted to
  601. the count.  Using the formula specified in 2.3.2.2 gives:  COUNT
  602. = 111860 / 5676 = 19.7.  The count is then rounded to 20.  Next
  603. the count must be converted to 10 bits.  This gives:  000001
  604. 0100.  Remember, the last 4 bits (0100) go into bits 4-7 and the
  605. first 6 bits (000001) go into bits 10-15.
  606.  
  607.     The full 16 bits required to set the frequency for the above
  608. example is:
  609.  
  610. 1 10 0 0100 00 000001
  611.  
  612. 2.3.2.3 Noise Frequency Control.  Eight bits are required to
  613. control the frequency of the noise generator.  The bits are
  614. numbered 0 to 7 from left to right.  The format of the byte is:
  615.  
  616.     1. bit 0 - Must be set to 1.
  617.  
  618.     2. bits 1-2 - Generator to work with.   MUST be set   to   11
  619.        for the noise generator.
  620.  
  621.     3. bit 3 - Set to 0 to indicate frequency control.
  622.  
  623.     4. bit 4 - Must be set to 0. -
  624.  
  625.     5. bit 5 - Type of noise indicator.   0 = White noise, 1
  626.        Periodic noise.
  627.  
  628.     6. bits 6-7 - Quality of noise.  Valid entries are 00, 01,
  629.        10 and 11.   If 11 is used the noise is dependent on the
  630.        frequency specified for generator 3.
  631.  
  632.      Different "qualities" of noise can be produced by varying
  633. bits 6-7.  The best approach is to try the different values
  634. allowed and observe the results.  Experiment with bits 6-7 as 00,
  635. 01  and  10.   Also  set bits 6-7 to 11, try different counts for
  636. generator 3 and observe the different "qualities" of noise.
  637.  
  638.  
  639. 2.4  SPEECH
  640.  
  641.      Dictionary speech and text-to-speech are two forms of speech
  642. supported by the emulator protocols.  A speech synthesizer must
  643. be connectad to the TI-99/4 before either form of speech can be
  644. used.
  645.  
  646.  
  647. 2.4.1 SPEECH DICTIONARY.  The speech peripheral that attaches to
  648. the TI-99/4 has a list of words it can speak called the speech
  649. dictionary.  These words are created by recording the words and
  650. converting the recording to linear predictive code.  The data is
  651. then stored in the peripharal.  The speech peripheral manual
  652. contains a complete list of the words in the dictionary.  The
  653. protocols let the host speak the words from the dictionary.
  654.  
  655.  
  656. 2.4.2 TEXT-TO-SPEECH.  The emulator also supports the text-to-
  657. speech capability which can be used in two ways.  One method is
  658. to use protocol commands and transmit text strings to the
  659. emulator.  The emulator will use rules of grammar to convert the
  660. text string to allophones.  The allophones will then be spoken.
  661. Any text string can be spoken using text-to-speech.
  662.  
  663.      The other method is to use protocol commands to transmit the
  664. allophones themselves to the emulator.  The terminal emulator
  665. command module manual explains allophones.  (See sections 4.3.7
  666. to 4.3.11).
  667.  
  668.  
  669. 2.5  DISK FILES
  670.  
  671.      The diskettes used by the TI-99/4 are divided into sectors.
  672. Each sector is 256 bytes in length.  Disk space is allocated to
  673. files by whole sectors.  A file that is 257 bytes long is
  674. allocated two disk sectors.  Only one byte out of the second
  675. sector will be used.
  676.  
  677.      The TI-99/4 supports three types of disk files.   They are:
  678.  
  679.      1. Fixed Length Record.
  680.  
  681.      2. Variable Length Record.
  682.  
  683.      3. Basic Program Image.
  684.  
  685.  
  686. 2.5.1 FIXED LENGTH RECORD FILES.  At file creation time the user
  687. specifies the length of the data records.  All records in the
  688. file have the same length.  File management will group the
  689. records into disk sectors.
  690.  
  691.      For example, assume a file has been created with 80 byte
  692. records. Each disk sector will contain three records.  The three
  693. records  use  240  bytes   (3  times  80)  of the 256 bytes in the
  694. sector.   The remaining 16 bytes of the sector are not used.
  695.  
  696.  
  697. 2.5.2 VARIABLE LENGTH RECORD FILES.  At file creation time the
  698. user specifies a maximum length for the data records.  The format
  699. of the data on disk is one byte containing the actual length of
  700. the data followed by the data.  The maximum length allowed is >FE
  701. (254 decimal).  File management will put as many records as
  702. possible in a disk sector.  A length of >FF denotes the end of
  703. data in a sector.
  704.  
  705.      For example, a user has created a variable length file with
  706. a maximum record size of 250 bytes.  The user has already written
  707. one record to the file containing 200 bytes of data.  The format
  708. of the disk sector is:
  709.  
  710. +--+-----------------+---------------+
  711. |C8|200 bytes of data|55 unused bytes|
  712. +--+-----------------+---------------+
  713.  
  714. Thus 201 bytes of the sector (one  byte  for  >C8  (decimal  200)
  715. denoting the record length and 200 bytes for the data) have been
  716. used.
  717.  
  718.      Next, the user writes a 47 byte record to the file.  The
  719. format of the sector is now.
  720.  
  721. +--+-----------------+--+----------------+--------------+
  722. |C8|200 bytes of data|2F|47 bytes of data|7 unused bytes|
  723. +--+-----------------+--+----------------+--------------+
  724.  
  725. Now 249 bytes of the sector (201 bytes for the first record, one
  726. byte for >2F (47 decimal) denoting the length of the second
  727. record and 47 bytes for the second record's data) have been used.
  728.  
  729.       Finally, the user writes a 50 byte record to the file.  File
  730. management requires 51 bytes to write the record to disk (one
  731. byte for the length and 50 bytes for the data).  The current
  732. sector, however, only has 7 unused bytes remaining.  The end of
  733. sector marker (>FF) is placed in the current sector and the third
  734. record is written to the next sector.  The disk sector after the
  735. write is:
  736.  
  737. +--+-----------------+--+----------------+--+--------------+
  738. |C8|200 bytes of data|2F|47 bytes of data|FF|6 unused bytes|
  739. +--+-----------------+--+----------------+--+--------------+
  740.  
  741.  
  742. 2.5.3 BASIC PROGRAM IMAGE FILES.  File management starts with
  743. the first sector in a program file and completely fills each
  744. sector with data until all program data is saved.  The last
  745. sector in the file may not be completely full.  File management
  746. maintalns a pointer to the first unused byte in the last sector
  747. of a program file.  No special symbols (such as >FF for the
  748. variable length file) are used to mark the end of the sector in a
  749. program file.
  750.  
  751.       Assume the user are going to save a BASIC program that is
  752. 400 bytes long to disk.  Sector bytes are numbered from 0 to 255
  753. (a total of 256 bytes on the sector).  The first sector will be
  754. completely filled.  The file will occupy 144 bytes of the second
  755. sector.  The remaining 112 bytes of the second sector will be
  756. unused.  The pointer to the byte after the last used byte in
  757. sector two will be 144 (>90).   The format of the sectors will be:
  758.  
  759.             +----------------------+
  760. Sector 1 -  |256 data bytes (0-255)|
  761.             +----------------------+
  762.             +----------------------+--------------------+
  763. Sector 2 -  |144 data bytes (0-143)|112 unused (144-255)|
  764.             +----------------------+--------------------+
  765.  
  766.  
  767. 2.5.4 BASIC FORMAT DATA FILES.  When a BASIC program accesses
  768. the disk, file management obtains a record from disk and passes
  769. the record to the BASIC interpreter.  The interpreter must know
  770. the format of the data within the record.  Currently BASIC
  771. supports display and internal data formats.  Refer to the User's
  772. Reference Manual for additional information about data formats.
  773.  
  774.  
  775.                               NOTE
  776.  
  777.             The data format is a requirment of BASIC, not
  778.             file management.   The following rules must be
  779.  
  780.           observed  only  for  files  that  are  to  be
  781.           accessed by BASIC programs.
  782.  
  783.  
  784. 2.5.4.1 Multiple Items in a Record.  With BASIC it is possible
  785. to create records with more than one data item in each.  When
  786. semi-colons (;) or commas (,) are used to separate variables in a
  787. PRINT statment, the variables are written to the same record.
  788. For example, the BASIC sentence:
  789.  
  790. PRINT #1:A$;B$
  791.  
  792. would first put A in the record.  Next B would be placed in the
  793. record after A.  Since B is not followed by a semi-colon the
  794. record would then be given to file management.
  795.  
  796.      To read more than one item from a  record  a  comma   (,)  is
  797. used.   For example,  the BASIC sentence:
  798.  
  799. INPUT #1:A,B
  800.  
  801. would take the first item from the record and place the item in
  802. the variable A.  The second item would be removed from the same
  803. record and placed in variable B.
  804.  
  805.  
  806.                               NOTE
  807.  
  808.            If  only  one  item of data is in the record,
  809.            the BASIC  interpreter  will  read  the  next
  810.            record from the file to fill variable B.
  811.  
  812.  
  813. 2.5.4.2 Display Format.  Display format is designed to act as if
  814. the data were coming from or going to the screen.  Multiple data
  815. items in the same record must be separated by a comma.  For
  816. example, the data record:
  817.  
  818. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  819. |D|I|S|P|L|A|Y| |D|A|T|A|,|2| |I|T|E|M|S|
  820. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  821.  
  822. would contain two items.  "DISPLAY DATA" is the first item in the
  823. record.   The comma  (,)  marks  the  end of the first item.   "2
  824. ITEMS" is the second item in the record.  The BASIC sentence
  825. required to create the record is:
  826.  
  827. PRINT #1:"DISPLAY DATA";",";"2 ITEMS"
  828.  
  829.                               NOTE
  830.  
  831.           The user must manually place the comma (,) in
  832.           the  data.   The system will not automatically
  833.           insert a comma batween data items.
  834.  
  835.  
  836.       If a comma is not in the data, the record consists of one
  837. item.   For example:
  838.  
  839. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  840. |D|I|S|P|L|A|Y| |D|A|T|A| |1| |I|T|E|M|
  841. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  842.  
  843. would be a record with only one item.  Either of the following
  844. BASIC sentences would creata the record:
  845.  
  846. PRINT #1:"DISPLAY  DATA";" 1 ITEM"
  847. PRINT #1:"DISPLAY DATA 1 ITEM"
  848.  
  849.  
  850.       Display format data can be in either fixed length or
  851. variable length records.  The above examples are fixed length
  852. records (they do not contain a record length byte).  An example
  853. of a variable length record with two items is:
  854.  
  855. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  856. |14|D|I|S|P|L|A|Y| |D|A|T|A|,|2| |I|T|E|M|S|
  857. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  858.  
  859. The >14 is one byte of hex data specifying the number of bytes in
  860. the record.
  861.  
  862.  
  863.                               NOTE
  864.  
  865.           Fixed    length   records   are   not   always
  866.           completely filled with  data.    For  example,
  867.           assume   the  word "TWO" is written to a fixed
  868.           length record 80 bytes long.   Only the  first
  869.           three bytes of the record would contain valid
  870.           data.    The remaining  77  bytes  would  be
  871.           unused.  Unused bytes of fixed length display
  872.           format  records  must  be  filled  with   >20
  873.           characters.
  874.  
  875. 2.5.4.3 Internal Format.  With internal format files each item
  876. in the record has its own length indicator.  Commas are not used
  877. to separate items within a record as in display format files.  An
  878. example of a fixed length record, internal format with two items
  879. is:
  880.  
  881. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+
  882. |0D|I|N|T|E|R|N|A|L| |D|A|T|A|07|2| |I|T|E|M|S|
  883. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+
  884.  
  885. The >0D is one byte of hex data specifying there are  decimal   13
  886. bytes of data in the first item.  The >07 is one byte of data
  887. specifying there are seven bytes of data in the second item.  An
  888. example of a fixed length record, internal format with one item
  889. is:
  890.  
  891. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  892. |14|I|N|T|E|R|N|A|L| |D|A|T|A| |1| |I|T|E|M|
  893. +--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  894.  
  895. The >14 is one byte of hex data specifying decimal 20 bytes of
  896. data in the first item.
  897.  
  898.      The length indicators for internal format data should not be
  899. confused with the length indicators for variable length data
  900. records.  One is used by the BASIC interpreter, the other by file
  901. management.  Examples of variable length records with internal
  902. format data are:
  903.  
  904. +--+--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+
  905. |16|0D|I|N|T|E|R|N|A|L| |D|A|T|A|07|2| |I|T|E|M|S|
  906. +--+--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+
  907. +--+--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+
  908. |15|14|I|N|T|E|R|N|A|L| |D|A|T|A|  |1| |I|T|E|M|
  909. +--+--+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+
  910.  
  911. The first byte of each record is the hex number specifying the
  912. amount of data in the record.  This byte is used by file
  913. management.
  914.  
  915.  
  916.                               NOTE
  917.  
  918.           Fixed    length   records   are   not   always
  919.           completely filled with  data.    For  example,
  920.           assume   the  word "TWO" is written to a fixed
  921.           length record 80 bytes long.   Only the  first
  922.           three bytes of the record would contain valid
  923.           data.    The  remaining  77  bytes  would  be
  924.           unused.    Unused  bytes of   fixed    length
  925.           internal format  records must be filled with
  926.           >00 characters.
  927.  
  928.  
  929. 2.5.5 DISK DIRECTORY.  Each diskette contains a disk directory
  930. that specifies the type and location of files currently on the
  931. disk.  Each file on the disk has an entry in the disk directory.
  932. Eight bytes of the disk directory entry are important to the
  933. protocols.  Bits are numbered 0 to 7 from left to right.  The
  934. bytes are:
  935.  
  936.      1. Byte 1-2 - Total number of sectors in the file.
  937.  
  938.      2. Byte 3 - File flags.
  939.  
  940.         a. Bit 0  - Type  of  record.   0 =   Fixed length
  941.            records, 1 = Variable length records.
  942.  
  943.         b. Bits 1-3 - Not used.
  944.  
  945.         c. Bit 4 -  Protect  flag.  0   =  Not delete/write
  946.            protected, 1 = Delete/write protected.
  947.  
  948.         d. Bit 5 - Not used.
  949.  
  950.         e. Bit 6 - BASIC  file  information. 0  =  Display
  951.            format,  1  =   Internal format. This bit is not
  952.            used by file management.
  953.  
  954.         f. Bit 7 - Type of file. 0 = Data file,  1 = Program
  955.            image.
  956.  
  957.      3. Byte 4 - Number of records per disk sector.    Not used
  958.         with variable length or program image files.
  959.  
  960.      4. Byte 5 - End of  file  offset.  Not used  with  fixed
  961.         length  records. For  variable length files points to
  962.         the end of sector marker (>FF) for the last  sector in
  963.         the  file.  For  example,  if the EOF offset is >C0, at
  964.         offset >C0 in the last sector of the  file  you  would
  965.         find the end of sector marker (>FF). For program image
  966.         files  points   to the byte after the last data byte in
  967.         the sector. For example,  if the EOF offset is >C0, at
  968.         offset >C0  in the last sector of the file would be the
  969.         first unused byte of   the  sector.    Offset >BF  would
  970.         contain the last byte of data in the sector.
  971.  
  972.      5. Byte  6  -  Record  size.   For  fixed length  records
  973.         contains the actual record length. For variable length
  974.         records  contains the maximum record size allowed. Not
  975.         used for program image files.
  976.  
  977.      6. Bytes 7-8 - Total number of records in the  file  with
  978.         the  order of the bytes reversed. Not used for program
  979.         image files.   For  example, if  a  file  contains  423
  980.         records (>01A7) the entry would be >A701.
  981.  
  982.  
  983. 2.5.6 END OF FILE DETECTION.  Each of the three disk file types
  984. has its own method for detecting an end of file conditioin.  The
  985. methods are:
  986.  
  987.     1. Program Image - Bytes 1-2 of the disk directory specify
  988.        the total number of disk sectors in the file. Maintain
  989.        a  count   of the number of sectors processed. Continue
  990.        processing until the count equals the number of sectors
  991.        in the file. Remember, a program image  file  may  use
  992.        only part of the last disk sector. When processing the
  993.        last   sector  use the end of file offset, specified in
  994.        byte 5 of the disk directory, to determine the  number
  995.        of bytes actually used.
  996.  
  997.     2. Fixed Length Records - Bytes 7-8 of the disk directory
  998.        specify the total number of fixed length records in the
  999.        file.   Maintain  a  count of  the  number  of records
  1000.        processed.   Continue processing until the count equals
  1001.        the number of records in the file.
  1002.  
  1003.    3.  Variable  Length  Records  -  Bytes  1-2  of the  disk
  1004.        directory  specify the total number of disk sectors in
  1005.        the file. Maintain a count of the  number  of  sectors
  1006.        processed.  Continue processing until the count equals
  1007.        the number of sectors in the file.
  1008.  
  1009.                            SECTION 3
  1010.  
  1011.                            CODED DATA
  1012.  
  1013.  
  1014. 3.1   REASONS FOR ENCODING DATA
  1015.  
  1016.       The terminal emulator package cannot accept the full range
  1017. of >0 to >FF as data in one byte.  One bit of each byte is
  1018. reserved for parity.  This limits the maximum data range for a
  1019. byte to >0 through >7F.
  1020.  
  1021.       Some values are also reserved as control characters for
  1022. communications systems.  Transmission of data in the range >0 to
  1023. >1F can have varying results from system to system.
  1024.  
  1025.       The valid range for data transmission then is limited to >20
  1026. through >7F.  Some of the special features of the emulator, such
  1027. as sound, graphics and file transfer, require transmission of
  1028. eight bit bytes.  This means some data must be encoded so that
  1029. transmitted bytes fall within the >20 to >7F range.
  1030.  
  1031.  
  1032. 3.2   DATA CODING
  1033.  
  1034.       Each coded byte of data contains six actual data bits.  The
  1035. bits are numbered 0 to 7 from left to right.  Bit 0 is reserved
  1036. for parity and can be ignored during encoding.  Bit 1 is always
  1037. set to 1 to ensure the byte will not be in the range >0 to >1F.
  1038. Bits 2 to 7 contain the actual data.
  1039.  
  1040.       Only six bits of actual data are allowed per coded byte.
  1041. This method maps three bytes of normal data to four bytes of
  1042. coded data.   The mapping is:
  1043.  
  1044.                  BYTE 1    BYTE 2      BYTE 3      BYTE 4
  1045.  
  1046.   Normal Data  xxxx xxxx   yyyy yyyy   zzzz zzzz
  1047.   Coded Oata   01xx xxxx   01xx yyyy   01yy yyzz   01zz zzzz
  1048.  
  1049.       As an example, assume >1B >85 >F4 >01 is to be encoded.  The
  1050. binary representation of the four bytes is:
  1051.  
  1052. 0001  1011 1000 0101 1111 0100 0000 0001.
  1053.  
  1054. The binary representation of the coded data is:
  1055.  
  1056. 0100 0110 0111 1000 0101 0111 0111 0100 0100 0000 0101 0000.
  1057.  
  1058. The hex data after encoding is >46 >78 >57 >74 >40 >50.
  1059.  
  1060.  
  1061.                               NOTE
  1062.  
  1063.           The emulator package does not validate bit 1
  1064.           for a binary   1.    If  the  host  system  has
  1065.           problems with transmitting a >7F the system
  1066.           can reset bit 1 to 0 converting the >7F to a
  1067.           >3F.  Bit 1 should always be set to 1 if the
  1068.           transmitted byte would be in the range >00 to
  1069.           >1F with bit 1 set to 0.  The emulator always
  1070.           sets bit 1 to   1  when  transmitting  encoded
  1071.           data to the host.
  1072.  
  1073.                              SECTION 4
  1074.  
  1075.                      EMULATOR CONTROL FORMATS
  1076.  
  1077.       Control characters, escape sequences and extended writes are
  1078. the three methods of passing control information to the emulator.
  1079.  
  1080.  
  1081. 4.1   CONTROL CHARACTERS
  1082.  
  1083.       Certain  one byte  codes  in  the range >0 to >1F have been
  1084. reserved as control bytes.   When the emulator is in the text mode
  1085. and a control code is received, the emulator will perform a pre-
  1086. defined function.  Control codes supported are:
  1087.  
  1088.       1. SOH (>01) - Home the cursor.   When >01 is received the
  1089.         cursor   is  moved   to the upper left hand corner of the
  1090.         display.
  1091.  
  1092.       2. BEL (>07) - Produce a "beep" sound from the TI-99/4.
  1093.  
  1094.       3. BS (>08) - Backspace the cursor one character position.
  1095.         Place a space (>20) in the position the cursor occupied
  1096.         before the backspace occured.    As  an  example  assume
  1097.         that " " denotes the cursor and the current line is:
  1098.  
  1099.         ABCD
  1100.  
  1101.         Two  backspace  bytes  are received.   The new line will
  1102.         be:
  1103.  
  1104.         AB
  1105.  
  1106.       4. LF (>0A) - Advance the cursor to the next line without
  1107.         changing   the column  position.    For  example,  if the
  1108.         cursor is at column 12 line 4 and a  >0A  is  received,
  1109.         the cursor will be positioned to column 12 line 5.
  1110.  
  1111.       5. CR (>0D) - Return the cursor to the  beginning  of the
  1112.         current line.   The cursor character will disappear from
  1113.         the display until another character is received.
  1114.  
  1115.                              NOTE
  1116.  
  1117.           A    carriage    return    (>0D)   will   not
  1118.             automatically generate a line feed (>0A).
  1119.  
  1120.  
  1121.  
  1122.     6. FF (>0C) - Clear the screen and place the cursor in the
  1123.        upper left hand corner of the display.
  1124.  
  1125.  
  1126.                              NOTE
  1127.  
  1128.           The above  control  characters  are  only   in
  1129.           effect  when the  computer   is in text mode.
  1130.           While in graphics mode codes >00, >0C and >0A
  1131.           will be ignored.   The  other  codes  will  be
  1132.           displayed.
  1133.  
  1134.  
  1135. 4.2 SPECIAL ESCAPE SEQUENCES
  1136.  
  1137.     Escape sequences pass information to the emulator in both
  1138. text and graphic modes.  All escape sequences have >1B as their
  1139. first byte.  When >1B is received the emulator expects the next
  1140. byte to be a special operation code defining the action to be
  1141. performed.   Supported escape sequence operation codes are:
  1142.  
  1143.     1. >59 - Set the logical cursor  address. The  operation
  1144.        code  followed  by two  bytes specifing the column and
  1145.        line number for the cursor. The  position  bytes  are
  1146.        specified relative to >20. For example >1B >59 >30 >25
  1147.        sets the cursor to column >10 (>30 - >20) and line >5
  1148.        (>25 - >20).
  1149.  
  1150.     2. >3A - Locks the keyboard on the computer. Keys pressed
  1151.        are not trasmitted until the keyboard is unlocked. The
  1152.        complete sequence is >1B >3A
  1153.  
  1154.     3. >3B - Unlocks   the  keyboard  on   the  computer. The
  1155.        complete sequence is >1B >3B.
  1156.  
  1157.     4. >47 - Begin an extended write. A complete  explanation
  1158.        of extended writes is glven in section 4.3.
  1159.  
  1160.     5. >48 - Home the cursor.   Position   the  cursor  in the
  1161.        upper left hand corner of the display.  This sequence
  1162.        will not clear the video display.  The complete
  1163.        sequence is >1B >48.
  1164.  
  1165.     6. >53 - System reset.  Used to abort the file transfer.
  1166.        If file transfer is in progress the system exits the
  1167.        transfer and returns to normal processing.  The
  1168.        complete sequence is >1B >53.
  1169.  
  1170.     7. >79 - Place the computer in graphics mode.  The command
  1171.        will clear the screen and place the logical cursor in
  1172.        the upper left hand corner of the display.  A cursor
  1173.        character is not displayed in graphics mode.  The
  1174.        complete sequence is >1B >79.
  1175.  
  1176.  
  1177.                             NOTE
  1178.  
  1179.         The hardware requires about   90  milliseconds
  1180.         to switch modes.  If any data is received
  1181.         during the switching period garbage will
  1182.         appear on the screen.
  1183.  
  1184.    8. >7A - Place the computer in text mode.  The command
  1185.       will clear the screen and place the cursor in the upper
  1186.       left hand corner of the display.  The complete sequence
  1187.       is >1B >7A.
  1188.  
  1189.  
  1190.                              NOTE
  1191.  
  1192.         The hardware required about 90 milliseconds
  1193.         to switch modes.  If any data is received
  1194.         during the switching period garbage will
  1195.         appear on the screen.
  1196.  
  1197.   9. >38 - Red buffer.  Notifies the host that the remote
  1198.      has processed the transmit command (extended write >2D)
  1199.      and is redy to receive the file transfer.  The
  1200.      complete sequence is >1B >38.
  1201.  
  1202.      If the byte following the >1B is not one of the above codes
  1203. the escape sequence is terminaed and the received byte is
  1204. ignored.
  1205.  
  1206.  
  1207. 4.3 EXTENDED WRITES
  1208.  
  1209.      The general format of the extended write is:
  1210.  
  1211. +--+--+--+--+--+----+----+--+--+
  1212. |1B|47|7F|1B|28|OPER|DATA|1B|29|
  1213. +--+--+--+--+--+----+----+--+--+
  1214.  
  1215. The >1B >47 >7F is the sequence which signals an extended write
  1216. is about to begin.  The >1B >28 indicates that the operation code
  1217. is contained in the next byte.
  1218.  
  1219.      OPER is a one byte extended write operation code specifying
  1220. the write being performed.  DATA is the data associated with the
  1221. extended write.  The format of DATA depends on the write
  1222. operation code.  The sequence >1B >29 signals the end of the
  1223. extended write.
  1224.  
  1225.      Once an extended write has started (>1B >47 >7F >1B >28 has
  1226. been received) the only way to terminate the write processing is
  1227. with the sequence >1B >29.  Any bytes between >1B >28 and >1B >29
  1228. are considered part of the write and will not be processed in the
  1229. normal manner.   Supported operations are listed below.
  1230.  
  1231.  
  1232. 4.3.1 OPER >20 - DEFINE CHARACTERS.  Command sequence to define
  1233. one or more consecutive characters.  The first two bytes specify
  1234. the code of the first character to be defined.  The remainder of
  1235. the data is the information required to define the character(s)
  1236. (see section 2.2.1.3).  Valid character codes are >00 to >FF.
  1237. The command requires the one byte character code be sent as two
  1238. bytes.  Bits 0-3 of the character code bytes are always 0010 (or
  1239. >2).  Bits 0-3 of the code byte are copied to bits 4-7 of the
  1240. first character code byte.  Bits 4-7 of the code byte are copied
  1241. to bits 4-7 of the second character code byte.  For example,
  1242. character code >57 would be converted to >25 >27 in the command.
  1243.  
  1244.      The data defining the character (all bytes between the
  1245. character code and >1B >29) must be encoded as specified in
  1246. section 3.
  1247.  
  1248.      Assume the host wants to define character >8A as a T and
  1249. character >8B as a L.  Since the >8A and >8B are consecutive
  1250. codes they can be defined with one extended write command.  The
  1251. command format calls for the code of the first character to be
  1252. expressed as two bytes.  In this example the two bytes would be
  1253. >28 >2A.
  1254.  
  1255.      Next the eight bytes defining each code must be determined.
  1256. From the example in section 2.2.1.3 we know the eight bytes
  1257.  
  1258. required   to  define  the  T are >FF >FF >18 >18 >18 >18 >18 >18
  1259. Using the technique described in the example we find the data
  1260. needed to define the L is >C0 >C0 >C0 >C0 >C0 >C0 >FF >FF.
  1261.  
  1262.      The 16 bytes of data (eight bytes needed to define T and
  1263. eight bytes needed to define L) must be encoded using the method
  1264. described in section 3.   The data after encoding is:
  1265.  
  1266. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
  1267. |7F|7F|7C|58|46|41|60|58|46|41|63|40|70|4C|43|40|70|4C|43
  1268. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
  1269. +--+--+--+
  1270. |7F|7F|70|
  1271. +--+--+--+
  1272.  
  1273.      The complete command sequence required to define character
  1274. >8A as a T and >8B as an L would be:
  1275.  
  1276. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
  1277. |1B|47|7F|1B;28|20|28|2A|7F|7F|7C|58|46|41|60|58|46|41|63
  1278. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
  1279. +--+--+--+--+--+--+--+--+--+--+--+--+--+
  1280. |40|70|4C|43|40|70|4C|43|7F|7F|70|1B|29|
  1281. +--+--+--+--+--+--+--+--+--+--+--+--+--+
  1282.  
  1283.  
  1284. 4.3.2 OPER >21 - LOAD SOUND TABLES.  Load a table with a sound
  1285. list.  Refer to section 2.3 for information on sound lists.  The
  1286. first byte is the sound table number + >20.  The remainder of the
  1287. data is the encoded sound list.
  1288.  
  1289.      The emulator supports sound tables >0 to >F.  Valid entries
  1290. for the table number in the command are >20 to >2F.   For example,
  1291. to specify sound table >A the first byte would be >2A (>A + >20).
  1292.  
  1293.      The sound tables are 128 bytes in length and contiguous in
  1294. memory.  Sound lists can be longer than 128 bytes.  For example,
  1295. assume a 200 byte sound list is to be loaded into table 0.  Table
  1296. 0 would contain 128 bytes of the list and table 1 would contain
  1297. the remaining 72 bytes.  Since part of table 1 is being used for
  1298. the first sound list, the next list would have to be loaded into
  1299. table 2.
  1300.  
  1301.  
  1302. 4.3.3 OPER >22 - PLAY SOUND TABLE.  Play the sound list in the
  1303. sound table specified by the table number.  The first byte is the
  1304. table number + >20.  For example, to specify sound table >A is to
  1305. be played the first byte would be >2A (>A + >20).  The complete
  1306. command required to play a sound list in table >A is:
  1307.  
  1308. +--+--+--+--+--+--+--+--+--+
  1309. |1B|47|7F|1B|28|22|2A|1B|29|
  1310. +--+--+--+--+--+--+--+--+--+
  1311.  
  1312.  
  1313. 4.3.4 OPER >23 - STOP SOUND.  Stop playing sound lists.  No
  1314. information is required other than the operation code (>23).  The
  1315. command will turn off all sound generators.  The complete command
  1316. required to stop sound is:
  1317.  
  1318. +--+--+--+--+--+--+--+--+
  1319. |1B|47|7F|1B|28|23|1B|29|
  1320. +--+--+--+--+--+--+--+--+
  1321.  
  1322.  
  1323. 4.3.5 OPER >24 - SELECT CHARACTER BANK.  Select the character
  1324. bank to be used for display.  Refer to section 2.2.1.2 for
  1325. details on character banks.  The first byte specifies the bank to
  1326. use.  The code >47 (an ASCII L) selects the "lower" bank
  1327. (character codes >0 to >7F) and >55 (an ASCII U) selects the
  1328. "upper" bank (character codes >80 to >FF).  The complete command
  1329. required to select the upper bank is:
  1330.  
  1331. +--+--+--+--+--+--+--+--+--+
  1332. |1B|47|7F|1B|28|24|55|1B|29|
  1333. +--+--+--+--+--+--+--+--+--+
  1334.  
  1335.  
  1336. 4.3.6 OPER >25 - DEFINE COLOR SETS.  Define the foreground and
  1337. background colors to be used for one or more consecutive color
  1338. sets.  Refer to section 2.2.1.4 for details on color sets.  The
  1339. first byte is the set number of the first color set to be defined
  1340. +  >20.  The remaining data are the foreground/background color
  1341. codes.  The color code bytes must be encoded as specified in
  1342. section 3.
  1343.  
  1344.      Each byte after the set number specifies a foreground and a
  1345. background color.  Bits 0-3 of each byte specify the foreground
  1346. color of a color set.  Bits 4-7 of each byte specify the
  1347. background color of a color set.  For example, to specify a
  1348. foreground color of black and a background color of cyan the byte
  1349. would be >17.  The 1 is the color code for black (2.2.1.4) and
  1350. the 7 is the color code for cyan.
  1351.  
  1352.      Assume color set >1A is to have a foreground color of black
  1353. and a background color of cyan.  Set >1B is to have a foreground
  1354. color of dark red and a background color of light yellow.  Set
  1355. >1C is to have a foreground color of dark blue and a background
  1356. color of gray.  Since the three sets are consecutive, one
  1357. extended write can be used to define the colors.  The command
  1358.  
  1359. calls for the first byte to be the first set number to define +
  1360. >20.  In this example the byte would be >3A (>1A + >20).  Using
  1361. table 2-1 we find the color byte for the set >1A is >17, the
  1362. color byte for set >1B is >6B and the byta for set >1C is >4E.
  1363.  
  1364.      The bytes required to define the colors of the three sets
  1365. are >17 >6B >4E.  The three bytes must be encoded as described in
  1366. section 3.  The data after encoding is >45 >76 >6D >4E.  The
  1367. complete command required to define color sets >1A to >1C would
  1368. be:
  1369.  
  1370. +--+--+--+--+--+--+--+--+--+--+--+--+--+
  1371. |1B|47|7F|1B|28|25|3A|45|76|6D|4E|1B|29|
  1372. +--+--+--+--+--+--+--+--+--+--+--+--+--+
  1373.  
  1374.  
  1375. 4.3.7 OPER >26 - SPEAK AND DISPLAY TEXT.  Display the text data
  1376. contained within the extended write and speak the data after the
  1377. write terminatas.  The text data must be upper case letters.  For
  1378. example, the complete command needed to have the emulator speak
  1379. and display the phrase "HOW ARE YOU" is:
  1380.  
  1381. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1382. |1B|47|7F|1B|28|26|48|4F|57|20|41|52|45|20|59|4F|55|1B|29|
  1383. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1384.  
  1385.  
  1386.                               NOTE
  1387.  
  1388.           The  host  must  not transmit to the emulator
  1389.           while the emulator is  speaking.    Below  are
  1390.           two methods which could be used to determine
  1391.           when speech has terminated.
  1392.  
  1393.              1. The host should estimate the amount
  1394.                  of  time  required  to  speak  the
  1395.                  string  transmitted to  the remote
  1396.                  (the rate of speech will vary 10 to
  1397.                  15 per cent depending on the speech
  1398.                  synthesizer).    The   host  should
  1399.                  pause   for   that  estimated time
  1400.                  interval.
  1401.  
  1402.                 2. The user on the remote should be
  1403.                  instructed  to  press  enter  when
  1404.                  speaking is completed. If the host
  1405.                  receives  enter   (>0D)   from the
  1406.                  remote, the speech is completed and
  1407.                  transmissions can continue.
  1408.  
  1409. 4.3.8   OPER  >27  -  SPEAK TEXT WITHOUT DISPLAY.   Speak the text
  1410. data contained within the extended write.  The  only  difference
  1411. between this write and extended write >26 is that the text is not
  1412. displayed   to the screen using this write. Only upper case words
  1413. can be spoken using this command. The complete command needed to
  1414. have the emulator speak the phrase "HOW ARE YOU"  is:
  1415.  
  1416. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1417. |1B|47|7F|1B|28|27|48|4F|57|20|41|52|45|20|59|4F|55|1B|29|
  1418. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1419.  
  1420.  
  1421. 4.3.9  OPER >28 - SPEAK ALLOPHONES.    Speak the  allophone  data
  1422. contained within the extended write command.   Refer to the manual
  1423. supplied   with   the   terminal   emulator  command  module  for  a
  1424. description of allophones.   The allophone data must be encoded as
  1425. described in section 3.
  1426.  
  1427.  
  1428. 4.3.10  OPER >29 - LOOK UP WORDS. Equate the number specified in
  1429. the command to the supplied text data.   Find the text data in the
  1430. speech dictionary. If the word is not in the dictionary the
  1431. command will be ignored.
  1432.  
  1433.      The first  byte in   the command is the number for the text
  1434. data. The valid range for the byte is >20 to >7F. The rest of
  1435. the data contains the word the number is to be associated with
  1436. The complete command required to associate the number >3A with
  1437. the word "HELLO" us:
  1438.  
  1439. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1440. |1B|47|7F|1B|28|29|3A|48|45|4C|4C|4F|1B|29|
  1441. +--+--+--+--+--+--+--+--+--+--+--+--+--+--+
  1442.  
  1443. 4.3.11   OPER >2A - SPEAK WORDS ASSOCIATED WITH NUMBERS.  Each
  1444. byte of data in the command is number that has been equated to
  1445. text using extended wite >29.  Speak the words associated with
  1446. the numbers.  Remember, extended write >29 must be used to
  1447. associate the words with the numbers.  Valid number ranges are
  1448. >20 to >7F.
  1449.  
  1450.      Assume extended write >29 was used to associate >20 with
  1451. "HELLO", >35 with "HOW", >47 with "ARE" and >2A with "YOU".  The
  1452. complete command required to speak the sentence "HELLO HOW ARE
  1453. YOU" is:
  1454.  
  1455. +--+--+--+--+--+--+--+--+--+--+--+--+
  1456. |1B|47|7F|1B|28|2A|20|35|47|2A|1B|29|
  1457. +--+--+--+--+--+--+--+--+--+--+--+--+
  1458.  
  1459.  
  1460. 4.3.12   OPER >2B - CHANGE SCREEN COLOR.   Change the screen color
  1461. in graphics mode.   This includes the border at the top and bottom
  1462. of the screen.  If the emulator is in text mode this  write  will
  1463. set the foreground and background colors.  Refer to section 2.2.2
  1464. for more information.
  1465.  
  1466.  
  1467.                               NOTE
  1468.  
  1469.           The  screen  color  is   the  color  used when
  1470.           transparent is defined as a color to be used
  1471.           for   characters.     For  example,    assume
  1472.           character X has a foreground color of black
  1473.           and  a background color of transparent.   With
  1474.           the screen color set to cyan character X will
  1475.           be displayed as black and cyan.   Changing the
  1476.           screen color to red displays character X as
  1477.           black and red.
  1478.  
  1479.  
  1480.      The data consists of two bytes specifing the color.   Bits 0-
  1481. 3 of both bytes contains 0010 (or >2).  When in graphics mode
  1482. bits 4-7 of the first byte contains  the  color  of  the  screen.
  1483. Table  2-1  gives   the  valid  color  codes.    The second byte is
  1484. ignored in graphics mode.   For example,  to set the  screen  color
  1485. to cyan in graphics mode the complete command would be:
  1486.  
  1487. +--+--+--+--+--+--+--+--+--+--+
  1488. |1B|47|7F|1B|28|2B|27|20|1B|29|
  1489. +--+--+--+--+--+--+--+--+--+--+
  1490.  
  1491.      In  text  mode  bits  4-7  of   the  first  byte contains the
  1492. foreground color and bits 4-7 of the second byte contains the
  1493. background color.  For example, to set the foreground color to
  1494. black and the background color to cyan in text mode the complete
  1495. command would be:
  1496.  
  1497. +--+--+--+--+--+--+--+--+--+--+
  1498. |1B|47|7F|1B|28|2B|21|27|1B|29|
  1499. +--+--+--+--+--+--+--+--+--+--+
  1500.  
  1501.  
  1502.                               NOTE
  1503.  
  1504.           Escape sequences specified in section 4.2 are
  1505.           used  to  switch  between  text  and  graphic
  1506.           modes.
  1507.  
  1508.  
  1509. 4.3.13  OPER >2C - RETURN  STATUS.   Return  the  status  of   the
  1510. terminal emulator module.   The format of the reply is:
  1511.  
  1512. +--+--+--+-------+------+----+----+--+--+
  1513. |01|1B|28|VERSION|SCREEN|MODE|WRAP|1B|28|
  1514. +--+--+--+-------+------+----+----+--+--+
  1515.  
  1516. Each parameter requires one byte.   The parameters are:
  1517.  
  1518.     1. VERSION - Version of  the  emulator  being  used.   The
  1519.        emulator version number is added to >20.  For example,
  1520.        Terminal Emulator II would return >22 (>20 + >2).
  1521.  
  1522.     2. SCREEN - Screen width  selected  by   the  user.    Valid
  1523.        entries are 34, 36, 3S or 40 (>22, >24, >26 or >28).
  1524.  
  1525.     3. MODE - Display mode currently in effect.
  1526.  
  1527.        a. >47 - Emulator is in graphics mode.
  1528.  
  1529.        b. >54 - Emulator is in text mode.
  1530.  
  1531.     4. WRAP - Line wrap option currently in effect.
  1532.  
  1533.        a. >46 - Wrap is off.   The  emulator  uses  logical
  1534.            line lengths of 80 bytes to display the data.
  1535.  
  1536.        b. >4E - Wrap is on.  The emulator uses logical line
  1537.           length selected by the user to display the data.
  1538.  
  1539.  
  1540. 4.3.14    OPER  >2D   -  TRANSMIT  COMMAND.  Initiates  the  file
  1541. transfer.   The format of the command is explained in section 5.
  1542.  
  1543.                            SECTION 5
  1544.  
  1545.                          FILE TRANSFER
  1546.  
  1547.  
  1548. The terminal emulator supports the transfer of files between
  1549. computer systems.  The protocol provides for full error detection
  1550. during the transfer.
  1551.  
  1552.  
  1553. 5.1  LRC ERROR DETECTION
  1554.  
  1555.      The emulator uses the Longitudinal Redundancy Check (LRC)
  1556. method of error detection.  During the file transfer the sender
  1557. calculates an LRC byte for each record transmitted.  The LRC byte
  1558. is transmitted as the last byte of the record.  The LRC must be
  1559. greater than >21.  If the calculated LRC is less than >21 then
  1560. >21 is added to the value before transmission.  The format of the
  1561. transmission is:
  1562.  
  1563. +------+---+
  1564. |Record|LRC|
  1565. +------+---+
  1566.  
  1567.      The LRC is calculated by performing successive exclusive or
  1568. operations (XOR) on all tha bytes in the record.  If the result
  1569. is less than >21 then >21 is added to the LRC.  As an example
  1570. assume that the record to be transmitted is 4 bytes long and
  1571. consists of >54 >45 >53 >54.  To calculate the LRC we would first
  1572. XOR >54 and >45.
  1573.  
  1574.          >54      0101 0100
  1575.          >45      0100 0101
  1576.  
  1577. Result - >11      0001 0001
  1578.  
  1579. The result of >54 XOR >45 is >11.  Next we XOR >11 and >53 giving
  1580. >42.  Finally we XOR >42 and >54 giving >16.  Since the XOR of
  1581. the record is less than >21 we must add >21.  The LRC byte is >37
  1582. (>16 + >21).   The transmission for our example would be:
  1583.  
  1584. +--+--+--+--+--+
  1585. |54|45|53|45|37|
  1586. +--+--+--+--+--+
  1587.  
  1588. 5.2  TRANSMISSION BLOCKS AND RECORDS
  1589.  
  1590.      The protocol divides the file being transferred into blocks.
  1591. The blocks are further sub-divided into records.  The size of the
  1592. blocks and records depend on the file being transmitted.  Table
  1593. 5-1 gives the various record sizes and number of records per
  1594. block for the different files.
  1595.  
  1596.                Table 5-1   TRANSMISSION RECORD SIZE
  1597.  
  1598.            Data Encoded   Logical    Transfer     Transfer
  1599.   Device   for Transfer Record Size Record Size Records/Block
  1600. +--------+-------------+-----------+-----------+-------------+
  1601. |  DISK   |    No      |     1-256 |    64     |     4       |
  1602. |  DISK   |    Yes     |     1-256 |    69     |     5       |
  1603. |CASSETTE|     No      |     1-128 |    64     |     4       |
  1604. |CASSETTE|     No      |   129-192 |    64     |     3       |
  1605. |CASSETTE|     Yes     |     1-128 |    57     |     6       |
  1606. |CASSETTE|     Yes     |   129-192 |    64     |     4       |
  1607. +--------+-------------+-----------+-----------+-------------+
  1608.  
  1609.  
  1610. As an example of the use of the table, assume we are transfering
  1611. a disk file.  The data does not need to be encoded (all bytes in
  1612. the file are in the range >20 to >7F) and the logical record size
  1613. is 95.  For column one we have "disk", for column two we have
  1614. "no" and column three does not affect disk files.  Thus we use
  1615. row one to get the block information.  For this example each
  1616. transmission record will contain 64 bytes of data and there will
  1617. be four transmission records in each block.
  1618.  
  1619.      Assume we are going to transfer a file from cassette.  The
  1620. data does need to be encoded (some bytes are in the range >00 to
  1621. >1F or >80 to >FF) and the  logical  record  size  is 100.   For
  1622. column one we have "cassette", for column two we have "yes" and
  1623. for column three we have 1-128.  Thus, we use row five to get the
  1624. block information.  For this example, each transmission record
  1625. would contain 57 bytes of data and there would be six
  1626. transmission records in each block.
  1627.  
  1628.      Each block has a block number assoicated with it.  The block
  1629. number is a two byte value that starts at >2020.  The first block
  1630. in the file has a number of >2020, the second block has a number
  1631. of >2021 and so on.  The maximum value allowed in a block number
  1632. byte is >7E.  Block >7E in the file has a block number of >207E.
  1633. Block >7F in the file however has a block number of >2120.
  1634.  
  1635.      Each block is divided into records.  The number of records
  1636. in a block is given in Table 5-1.  The record number is a one
  1637. byte value that starts at >20.  The record number resets to >20
  1638. for each data block transmitted.
  1639.  
  1640.  
  1641. 5.3 TRANSMIT COMMAND FORMAT
  1642.  
  1643.     Extended write >2D is the transmit command.  It is used to
  1644. notify the receiving system that a file transfer is to occur and
  1645. to pass parameters to the receiver.  The format of the command
  1646. is:
  1647.  
  1648. +--+--+--+--+--+--+----+--+--+---+
  1649. |1B|47|7F|1B|28|2D|DATA|1B|29|LRC|
  1650. +--+--+--+--+--+--+----+--+--+---+
  1651.  
  1652. The DATA part of the transmit command must be encoded as
  1653. described in section 3.   The format of the data is:
  1654.  
  1655.     1. Byte 1 - Denotes the type  of file  being  transfered.
  1656.        Valid codes are:
  1657.  
  1658.        a. >43 - File is coming from cassette.
  1659.  
  1660.        b. >44 - File is coming from disk.
  1661.  
  1662.     2. Bytes 2-9 - Disk directory information. Bytes 2-6  and
  1663.        8-9 only have meaning if byte 1 contains a >44. Byte 7
  1664.        always  has  meaning.    Refer to  section  2.5.5 for a
  1665.        completa description of the eight bytes. Remember,  the
  1666.        disk directory   information   in  the transmit  command
  1667.        starts at byte 2.   The format of the eight bytes is:
  1668.  
  1669.        a. Bytes 2-3 - Number of sectors in the file.
  1670.  
  1671.        b. Byte 4 - File flags.   Refer to section 2.5.5  for
  1672.           more information about the flags.
  1673.  
  1674.        c. Byte 5 - Number of records per sector.   Not  used
  1675.           for fixed length records or program image files.
  1676.  
  1677.        d. Byte 6 - End of file offset.
  1678.  
  1679.        e. Byte 7 - Record size.   Byte  7  is  required  for
  1680.           both disk and cassette data files.
  1681.  
  1682.        f. Byte 8-9 - Number of records in file, with bytes
  1683.           reversed.   Not used for program image files.
  1684.  
  1685.     3. Bytes 10-11 - Data record  size.    Length  of  DATA in
  1686.        transmission record.
  1687.  
  1688.     4. Byte 12 - Number of transmitted records per block.
  1689.  
  1690.     5. Byte 13 - Emulator version number.  Terminal  Emulator
  1691.        II is version number >01.
  1692.  
  1693.     6. Byte 14 - Delay interval in increments of 5 seconds.
  1694.        This  is the number of 5 second intervals the receiver
  1695.        is to wait for  transmission  from the  sender  before
  1696.        assuming  data  loss has occured. For example, if this
  1697.        byte contains 4 the receiver is to wait 20  seconds (4
  1698.        times  5)   for transmission  from  the  sender. If no
  1699.        transmission is received a NAK record is to be sent to
  1700.        the host.
  1701.  
  1702.     7. Byte 15 - Type of  error  checking.  Current  versions
  1703.        only  support   LRC error checking. Byte 15 must be set-
  1704.        to >4C for LRC checking.
  1705.  
  1706.     8. Byte 16 - Type of data coding.   Valid entries are:
  1707.  
  1708.        a. >36 -  Coded  file  data.    Data   is  encoded  as
  1709.            described in section 3.
  1710.  
  1711.        b. >37 - ASCII file  data.    No  encoding   is  done.
  1712.           Data   must  be  in   the  range  >20  to  >7F  or
  1713.           unpredictable results will occur:
  1714.  
  1715.     9. Byte 17 - Type of data record  retransmission to  use.
  1716.        Current  versions  will   only  support >4E  as a valid
  1717.        entry.
  1718.  
  1719.  
  1720. 5.4 TRANSMISSION RECORD FORMATS
  1721.  
  1722.     There are three transmission record formats:  one for the
  1723. first record, one for all records except the first and last
  1724. records and one for the last record.  The format of the first
  1725. data record is:
  1726.  
  1727. +--+--+--+---+--+---+--+--+----+--+---+
  1728. |02|01|1D|BLK|1E|REC|1B|28|DATA|17|LRC|
  1729. +--+--+--+---+--+---+--+--+----+--+---+
  1730.  
  1731. The bytes >02 and >01 signal the start of a data record.  Byte
  1732. >1D signals that the two following bytes will contain the block
  1733. number.  BLK is a two byte area specifing the block number of the
  1734. record being transmitted.  Section 5.2 describes the block
  1735. number.
  1736.  
  1737.       Byte >1E signals that the next byte will be the record
  1738. number.  REC is a one byte area specifing the record number of
  1739. the record being transmitted.  Section 5.2 describes the record
  1740. number.  Remember, the number of records in a block is specified
  1741. in the transmit command.
  1742.  
  1743.       Bytes >1B and >28 signal the beginning of the data portion
  1744. of the first record.  DATA contains the file data.  The length of
  1745. the transmitted DATA (not the length of data before encoding) is
  1746. specified in the transmit command.  The transmit command also
  1747. tells if the data has been coded or not.  If the transmit command
  1748. specifies encoding, only DATA will be coded, not the other bytes
  1749. in the transmission.
  1750.  
  1751.  
  1752.                               NOTE
  1753.  
  1754.           If the data is coded it is coded as a block,
  1755.           not   as   a  record.    To  decode   the  data
  1756.           correctly, the entire block must be decoded.
  1757.  
  1758.  
  1759.       A >17 specifies the end of the data record.  The LRC byte
  1760. always follows the >17 code.
  1761.  
  1762.       The data record format for all records between the first and
  1763. last records is:
  1764.  
  1765. +--+--+--+---+--+---+----+--+---+
  1766. |02|01|1D|BLK|1E|REC|DATA|17|LRC|
  1767. +--+--+---+---+--+---+---+--+---+
  1768.  
  1769. The only difference between this format and the first one is that
  1770. this format does not contain the >1B >28 before DATA.
  1771.  
  1772.       The data record format for the last record in the file is:
  1773.  
  1774. +--+--+--+---+--+---+----+--+--+--+---+
  1775. |02|01|1D|BLK|1E|REC|DATA|1B|29|03|LRC|
  1776. +--+--+--+---+--+---+----+--+--+--+---+
  1777.  
  1778. The only difference between the previous format and this one is
  1779. this format ends in an >1B >29 >03.  These three bytes tell the
  1780. remote system that this is the last record in the file transfer.
  1781.  
  1782.  
  1783. 5.5 ACK RECORD FORMAT
  1784.  
  1785.       An ACK record is sent for each data record correctly
  1786. received.   The format of the record is:
  1787.  
  1788. +--+--+---+--+---+--+--+--+--+--+---+
  1789. |01|1D|BLK|1E|REC|1B|29|06|1B|29|LRC|
  1790. +--+--+---+--+---+--+--+--+--+--+---+
  1791.  
  1792. The BLK field is a two byte field containing the block number of
  1793. the received record.  The REC field is a one byte field
  1794. containing the record number of the received record.  A >06 is
  1795. the ASCII ACK code.
  1796.  
  1797.  
  1798. 5.6   NAK RECORD FORMAT
  1799.  
  1800.       A NAK record is sent whenever an error is detected in a
  1801. transmission.   The format of the record is:
  1802.  
  1803. +--+--+---+--+---+--+--+--+--+--+--+---+
  1804. |01|1D|BLK|1E|REC|1B|28|15|ID|1B|29|LRC|
  1805. +--+--+---+--+---+--+--+--+--+--+--+---+
  1806.  
  1807. BLK is a two byte area containing the block number the sender of
  1808. the NAK was expecting.  REC is a one byte area containing the
  1809. record number the sender was expecting.  A >15 is the ASCII NAK
  1810. code.  The ID field is one byte that specifies the type of record
  1811. being NAK'D.  A >30 indicates the NAK is for a data record, a >31
  1812. indicates the NAK is for a response record (a NAK or ACK record).
  1813.  
  1814.       The sender should maintain a count of the number of NAKs
  1815. sent while trying to transfer a record.  If more than five NAKs
  1816. are encountered for any single record the sender should abort the
  1817. transfer.  When the emulator is sending the file it will allow up
  1818. to five NAKs.  When the emulator is receiving the file it will
  1819. allow up to eight NAKs.
  1820.  
  1821.  
  1822. 5.7   FILE TRANSFER FROM REMOTE TO HOST
  1823.  
  1824.       Appendix B provides an implementation example of remote to
  1825. host file transfer.
  1826.  
  1827.       The protocols use the transmit command (extended write >2D)
  1828. to signal a file transfer is about to occur and to pass
  1829. parameters to the host.  Section 5.3 describes the transmit
  1830. command.  Hosts that echo the bytes they receive must know in
  1831.  
  1832. advance that the file transfer is about to start.  The echo must
  1833. be turned off before the transmit command is received.
  1834.  
  1835.       The host calculates an LRC byte for the write (as described
  1836. in 5.1) and compares the calculated value to the received LRC
  1837. value.  If they do not match the host sends a system reset (>1B
  1838. >53) terminating the transfer.
  1839.  
  1840.       Once the host determines the transmit command was received
  1841. without error a read buffer command (>1B >38) is transmitted to
  1842. the remote.  The read buffer informs the remote that the host has
  1843. received and processed the transmit command and is ready to start
  1844. the file transfer.  The remote then begins sending transmission
  1845. records to the host.  Section 5.4 describes the format of data
  1846. records.
  1847.  
  1848.       The error checking is the same for all received
  1849. transmissions (data records and ACK/NAK responses).  First the
  1850. LRC of the record must be calculated.  If the calculated LRC does
  1851. not match the received value a NAK is sent to the remote using
  1852. the expected block and record numbers.  The host then waits for
  1853. the remote to resend the record.
  1854.  
  1855.       Provided the LRC bytes match, the host checks the block
  1856. number of the record against the expected block number.  If the
  1857. block number does not match the expected value a system reset is
  1858. sent (>1B >53).  The host exits the file transfer and returns to
  1859. normal processing.
  1860.  
  1861.       Next the host checks the expected record number against the
  1862. received record number.  If the numbers do not match the host
  1863. sends a NAK using the expected block and record numbers.  The
  1864. host then waits for the remote to retransmit the record.
  1865.  
  1866.       If no errors are detected the host processes the data
  1867. record.  The expected record number is incremented to the next
  1868. data record.  If this is the last record in a block, the block
  1869. number is incremented to the next block and the record number is
  1870. set to >20.  An ACK is sent for the record just received and the
  1871. host waits for the next record.
  1872.  
  1873.       After the last record is received without errors and the
  1874. host sends an ACK, the remote will send an end of file record.
  1875. The EOF record is an ACK with a block number of >7E7E and a
  1876. record number of >7E.  The EOF ACKs will be refered to by number.
  1877. The EOF ACK the remote sends to the host after the last record is
  1878. ACK-1.
  1879.  
  1880.       The host does normal error checking on ACK-1.  If no errors
  1881. are detectad the host sends the same ACK (ACK-2) back to the
  1882.  
  1883. remote.  If the remote does not receive ACK-2 correctly it will
  1884. send a NAK back to the host.  If the remote does receive ACK-2 it
  1885. will send the same ACK (ACK-3) back to the host.
  1886.  
  1887.      The host is now awaiting ACK-3 from the remote.  Four things
  1888. can happen.
  1889.  
  1890.     1. The host can receive a NAK from   the  remote.    If the
  1891.        host does receive a NAK it will resend ACK-2 and
  1892.        continue to wait for ACK-3.
  1893.  
  1894.     2. The host can receive ACK-3 from the remote. If the ACK
  1895.        is received the host   is   to  exit  file transfer  and
  1896.        return to normal processing.
  1897.  
  1898.     3. The host can receive a  transmission  from the  remote
  1899.        with  an error. If an error occurs the host is to exit
  1900.        the file transfer and return to normal processing.
  1901.  
  1902.     4. The host can time out waiting for a response.    If the
  1903.        host does time out it is to exit the file transfer and
  1904.        return to normal processing.
  1905.  
  1906.  
  1907.      While reading bytes from the remote the host constantly
  1908. checks for a system reset (>1B >53).  If the reset is detected
  1909. the host terminates the file transfer and returns to normal
  1910. processing.
  1911.  
  1912.      The transmit command specifies a time interval to the host.
  1913. The interval is the maximum time to wait for a byte from the
  1914. remote.  If the time limit is exceeded without receiving a byte
  1915. the host assumes the transmission was lost and sends a NAK using
  1916. the expected block and record numbers.
  1917.  
  1918.      The transmit command specifies how the data is sent.  Files
  1919. with variable length records or files with data in the range >0
  1920. to >1F or >80 to >FF are encoded as described in section 3.  If
  1921. the host is to manipulate the file it must be decoded.  The
  1922. remote encodes a block of data at a time.  The host must decode
  1923. the data a block at a time.  It cannot decode the records
  1924. independently of one another.
  1925.  
  1926.  
  1927. 5.8  FILE TRANSFER FROM HOST TO REMOTE
  1928.  
  1929.      Transmissions received by the host cannot be echoed.  Echo
  1930. must be turned off before the file transfer can begin.  Appendix
  1931. C provides an implementation example of host-to-remote file
  1932. transfer.
  1933.  
  1934.      When transferring a file to a TI-99/4 disk file the host
  1935. must construct a 256 byte disk sector.  The sector is transmitted
  1936. as one transmission block.  Transfer to cassette does not require
  1937. a knowledge of how the file is stored on the cassette.  The
  1938. records are moved directly into the transmission block.
  1939.  
  1940.      The host must construct and send the transmit command
  1941. (extended write >2D) to the remote.  The extended write is used
  1942. to notify the remote a file transfer is to occur and to pass
  1943. parameters to the remote.  Section 5.3 describes the information
  1944. contained in the write.  The host calculates an LRC byte for the
  1945. transmit command and attaches the LRC to the end of the command.
  1946.  
  1947.      After the extended write is transmitted to the remote the
  1948. host waits for the read buffer command (>1B >38).  The read
  1949. buffer notifies the host that the remote has processed the
  1950. extended write and is ready to receive the file transfer.  The
  1951. host does not time out waiting for the read buffer.
  1952.  
  1953.      After the read buffer is received, the host gets a block of
  1954. data.  If the transmit command specified the data is to be
  1955. encoded, the host encodes the entire block using the method
  1956. described in section 3.  Any file with data in the range >0 to
  1957. >1F or >80 to >FF must be encoded.  Also files with variable
  1958. length records must be encoded.
  1959.  
  1960.      The host divides the block into data records.  The length of
  1961. the data record is specified in the transmit command.  The host
  1962. transmits the block a record at a time.  An LRC byte is
  1963. calculated for each record and attached as the last byte of the
  1964. record.  After the record is transmitted the host waits for a
  1965. reply from the remote.  If the host waits longer than the time
  1966. specified in the transmit commmand the host assumes the response
  1967. has been lost and sends a NAK to the remote using the block and
  1968. record number of the transmitted record.
  1969.  
  1970.      The host performs extensive error checking on the responses.
  1971. First the host calculates an LRC byte for the response.  If the
  1972. calculated LRC does not match the received LRC the host sends a
  1973. NAK using the block and record number of the last record
  1974. transmitted.  If the LRC is correct the host compares the
  1975. received block number to the block number of the last record
  1976. transmitted.  If the block numbers do not match the host sends a
  1977. system reset (>1B >53) and exits the file transfer.  If the block
  1978. numbers match the host compares the received record number to the
  1979. record number of the last record transmitted.  If the record
  1980. numbers do not match the host sends a NAK using the block and
  1981. record numbers of the last record transmitted.
  1982.  
  1983.      If there are no errors in the response the host checks for
  1984. an ACK or a NAK response.  If the remote sent a NAK the host
  1985. retransmits the last record and then waits for a response.  If
  1986. the remote sent an ACK the host transmits the next record.
  1987.  
  1988.      After the host has processed the response for the last
  1989. record in the transfer it sends an end of file record.  The EOF
  1990. record is an ACK with a block number of >7E7E and a record number
  1991. of >7E.  The ACKs will be refered to by number.  The EOF ACK is
  1992. ACK-1.
  1993.  
  1994.      After sending ACK-1 the host waits for a response.  When the
  1995. response is received it goes through the normal error checking.
  1996. If an error is detected a NAK is sent with block and record
  1997. numbers of >7E.  If no errors are detected and the response is a
  1998. NAK the host retransmits ACK-1 and waits for a response.  If the
  1999. response is an ACK (ACK-2) the host transmits an ACK (ACK-3)
  2000. using block and record numbers of >7E and exits the file
  2001. transfer.
  2002.  
  2003.      The host constantly checks the input for a system reset (>1B
  2004. >53).  If a system reset is detected the host exits the file
  2005. transfer and returns to normal processing.
  2006.  
  2007.      The host specifies a time interval in the transmit command.
  2008. The interval is the maximum time the remote is to wait for a byte
  2009. from the host.  The host should use the same interval as the
  2010. maximum time it will wait for a byte from the remote.  If the
  2011. time limit is exceeded without receiving a byte the host assumes
  2012. the transmission was lost.  It sends a NAK using the block and
  2013. record numbers of the last data record transmitted.
  2014.  
  2015.                            APPENDIX A
  2016.  
  2017.                       DEFAULT CHARACTER SET
  2018.  
  2019.      The   terminal  emulator  supplies  a  default character set.
  2020. When the emulator switches to text mode the default character set
  2021. is loaded.
  2022.  
  2023. Hex code           Character           Hex Code           Character
  2024.    20                Space               30                   0
  2025.    21                   !                31                   1
  2026.    22                   "                32                   2
  2027.    23                   #                33                   3
  2028.    24                   $                34                   4
  2029.    25                   %                35                   5
  2030.    26                   &                36                   6
  2031.    27                   '                37                   7
  2032.    28                   (                38                   8
  2033.    29                   )                39                   9
  2034.    2A                   *                3A                   :
  2035.    2B                   +                3B                   ;
  2036.    2C                   ,                3C                   <
  2037.    2D                   -                3D                   =
  2038.    2E                   .                3E                   >
  2039.    2F                   /                3F                   ?
  2040.  
  2041.  
  2042. Hex code           Charactar           Hex Code           Character
  2043.     40                 @                  60                 !
  2044.     41                 A                  61                 a
  2045.     42                 B                  62                 b
  2046.     43                 C                  63                 c
  2047.     44                 D                  64                 d
  2048.     45                 E                  65                 e
  2049.     46                 F                  66                 f
  2050.     47                 G                  67                 g
  2051.     48                 H                  68                 h
  2052.     49                 I                  69                 i
  2053.     4A                 J                  6A                 j
  2054.     4D                 K                  6B                 k
  2055.     4C                 L                  6C                 l
  2056.     4D                 M                  6D                 m
  2057.     4E                 N                  6E                 n
  2058.     4F                 O                  6F                 o
  2059.     50                 P                  70                 p
  2060.     52                 R                  72                 r
  2061.     53                 S                  73                 s
  2062.     54                 T                  74                 t
  2063.     55                 U                  75                 u
  2064.     56                 V                  76                 v
  2065.     57                 W                  77                 w
  2066.     58                 X                  78                 x
  2067.     59                 Y                  79                 y
  2068.     5A                 Z                  7A                 z
  2069.     5B                 [                  7B                 {
  2070.     5C                 \                  7C                 |
  2071.     5D                 ]                  7D                 }
  2072.     5E                                    7E
  2073.     5F                 -
  2074.  
  2075.                            APPENDIX B
  2076.  
  2077.             EXAMPLE OF EMULATOR TO HOST FILE TRANSFER
  2078.  
  2079.  
  2080.     This appendix lists one method for implementing the emulator
  2081. to host file transfer on the host.  It is intended only as an
  2082. example of the file transfer on the host.
  2083.  
  2084.     1. Turn off echo of lncoming characters.
  2085.  
  2086.     2. Wait for transmit command.
  2087.  
  2088.     3. Transmit command received.
  2089.  
  2090.        a. Check LRC byte for error.  If  error  send  reset
  2091.           command and exit file transfer.
  2092.  
  2093.        b. No error, set expected block number to >2020 and
  2094.           expected  record number to >20.  Send read buffer
  2095.           command.
  2096.  
  2097.     4. Wait for response.
  2098.  
  2099.        a. Start timer.
  2100.  
  2101.        b. If timer expires send NAK  using expected block
  2102.           and record numbers.   Go to step 4.
  2103.  
  2104.        c. If system reset received exit file tranfer.
  2105.  
  2106.     5. Response received.
  2107.  
  2108.     6. Check LRC byte for error.    If  error  send  NAK  using
  2109.        expected block and record number.   Go to step 4.
  2110.  
  2111.     7. Check received block number against expected block
  2112.        number.   If not equal send system reset. Exit  the file
  2113.        transfer.
  2114.  
  2115.     8. NAK Recaived.   Resend the  response  for the  received
  2116.        record number.   Go to step 4.
  2117.  
  2118.     9. Record received.
  2119.  
  2120.        a. Check received record number against expected
  2121.           record  number.    If not  equal send  NAK using
  2122.           expected block and record numbers. Go to step 4.
  2123.  
  2124.        b. Extract  data   from   record   and   save  into
  2125.           accumulation area.
  2126.  
  2127. 10. Send ACK using expected block and record numbers.
  2128.  
  2129. 11. Increment the expected record number.  If this  is   the
  2130.     last record in the block:
  2131.  
  2132.     a. If data is encoded then decode the data.
  2133.  
  2134.     b. Save data to disk.
  2135.  
  2136.     c. Increment  expected  block  number.  Set  record
  2137.        number to >20.
  2138.  
  2139. 12. If not the last record in the transmission go  to  step
  2140.     4.
  2141.  
  2142. 13. End of transmission logic.   Wait for response.
  2143.  
  2144.     a. Start timer.
  2145.  
  2146.     b. If timer expires send NAK using block number of
  2147.        >7E7E and record number of >7E.
  2148.  
  2149.     c. If system reset received exit the file transfer.
  2150.  
  2151. 14. Response received.
  2152.  
  2153. 15. Check LRC byte for error.   If  error  send  NAK  using
  2154.     block  number of >7E7E and record number of >7E.   Go to
  2155.     step 13.
  2156.  
  2157. 16. NAK  received.    Resend  the  ACK  for   the  last  data
  2158.     transmission.   Go to step 13.
  2159.  
  2160. 17. ACK received.
  2161.  
  2162.     a. Check received block number for  >7E7E.  If  not
  2163.        equal send system reset. Exit the file transfer.
  2164.  
  2165.     b. Check received record number  for  >7E.  If  not
  2166.        equal send  NAK  using block number of >7E7E and
  2167.        record number of >7E.  Go to step 13.
  2168.  
  2169. 18. Send ACK using block number of >7E7E and record number
  2170.     >7E.
  2171.  
  2172. 19. Wait for response.
  2173.  
  2174.     a. Start timer.
  2175.  
  2176.     b. If timer expires exit the file transfer.
  2177.  
  2178. 20. Response received.
  2179.  
  2180.     a. If response has an error   in   it  exit the  file
  2181.        transfer.
  2182.  
  2183.     b. If response is a NAK send ACK using block number
  2184.        of  >7E7E and  record number of >7E.  Go to step
  2185.        19.
  2186.  
  2187. 21. Exit the file transfer.
  2188.  
  2189.                            APPENDIX C
  2190.  
  2191.            EXAMPLE OF HOST TO EMULATOR FILE TRANSFER
  2192.  
  2193.  
  2194.       This appendix contains one method for implementing the host
  2195. to emulator file transfer on the host.   It is intended only as an
  2196. example of the file transfer on the host.
  2197.  
  2198.     1. Turn off echo of incoming characters.
  2199.  
  2200.     2. Construct transmit command.
  2201.  
  2202.     3. Send transmit command to remote.
  2203.  
  2204.     4. Wait for responses.
  2205.  
  2206.        a. If system reset received exit the file transfer.
  2207.  
  2208.        b. If anything other than a read buffer  command is
  2209.          received send a system reset and exit the file
  2210.           transfer.
  2211.  
  2212.     5. Set current block number to >2020.
  2213.  
  2214.     6. Read a block from disk.   If end of file encountered  go
  2215.        to step 17.
  2216.  
  2217.     7. Set current record number to >20.
  2218.  
  2219.     8. If data needs to be encoded then encode the block
  2220.  
  2221.     9. Break the block into transmission records.
  2222.  
  2223.     10. Send a transmission record.
  2224.  
  2225.     11. Wait for response.
  2226.  
  2227.        a. Start timer.
  2228.  
  2229.        b. If timer  expires   then  send  a  NAK  using the
  2230.           current block and record numbers.   Go to step 11.
  2231.  
  2232.        c. If system reset received exit the file transfer.
  2233.  
  2234.     12. Response received.
  2235.  
  2236. 13.  Check LRC of the response.  If error send NAK using the
  2237.      current block and record numbers.  Go to step 11.
  2238.  
  2239. 14.  Check received block number against the current block
  2240.      number.  If they are not equal send a system reset and
  2241.      exit the file transfer.
  2242.  
  2243. 15.  NAK received.  Go to step 10 (this resends the record).
  2244.  
  2245. 16.  ACK received.
  2246.  
  2247.      a. Increment current record number.
  2248.  
  2249.      b. If  all  records   in  current  block transmitted
  2250.        increment current block number.   Go to step 6.
  2251.  
  2252.      c. Go to step 10 (this  sends next  record  in  the
  2253.        block).
  2254.  
  2255. 17.  End of transmission logic.  Send ACK with block number
  2256.      of >7E7E and record number of >7E.
  2257.  
  2258. 18.  Wait for response.
  2259.  
  2260.      a. Start timer.
  2261.  
  2262.      b. If timer expires then send NAK with block number
  2263.        of  >7E7E  and  record number of >7E. Go to step
  2264.        18.
  2265.  
  2266.      c. If sytem reset received exit the file transfer.
  2267.  
  2268. 19.  Response received.
  2269.  
  2270. 20.  Check LRC of the response.  If error send NAK using a
  2271.      block number of >7E7E and a record number of >7E.  Go
  2272.      to step 18.
  2273.  
  2274. 21.  Check the received block number against >7E7E.  If they
  2275.      are not equal send a system reset and exit the file
  2276.      transfer.
  2277.  
  2278. 22.  Check the received record number against >7E.  If they
  2279.      are not equal send a NAK using a block number of >7E7E
  2280.      and a record number of >7E.   Go to step 18.
  2281.  
  2282. 23.  NAK received. Go to step 17 (this resends the ACK).
  2283.  
  2284. 24.  ACK received.
  2285.  
  2286.      a. Send an ACK using a block number of >7E7E and a
  2287.         record number of >7E.
  2288.  
  2289.      b. Exit the file transfer.
  2290.