home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue4 / programming / 5.seq < prev    next >
Encoding:
Text File  |  1992-04-27  |  9.5 KB  |  248 lines

  1. ddd00000ff00fe0080888000a3f
  2. ^7*********************************************************************
  3. ^7*                                                                   *
  4. ^7*                                                                   *
  5. ^7*  ^2P r o g r a m   P a r l o u r   3   -   AMOS Communications      ^7*
  6. ^7*                                                                   *
  7. ^7*                                                                   *
  8. ^7*********************************************************************
  9.  
  10. ^2                            By Ben Ashley
  11.  
  12. ^6 Welcome  to  yet  another  issue  of  TA, and another installment of
  13. ^6Program Parlour.  Again, something different this time, and something
  14. ^6useful  to  all  people  who  either own 2 Amiga's and a serial link,
  15. ^6and/or a modem.
  16.  
  17. ^6 What you exactly do with the serial extension is up to you.  Writing
  18. ^6SERIAL-LINK  games is quite easy, whilst writing Terminal software is
  19. ^6a  little  more  difficult,  and  BBS  software, is even worse.  I'll
  20. ^6provide  as  much  information  as  I  can on all 3 of these types of
  21. ^6communications software.
  22.  
  23. ^2                    The Serial-Linkup Experience
  24.  
  25. ^6 You  don't  have  to  be  very intelligent to understand this.  Very
  26. ^6simply, its easy.
  27.  
  28. ^6 Imagine  you  want to create a game with 2 bobs, one at the top, one
  29. ^6at  the bottom, and they can fire at each other.  Bob 1 is controlled
  30. ^6on Amiga 1, and Bob2 is controlled, by another person on Amiga 2.
  31.  
  32. ^6 If  you  can  imagine  the  general variables, ( X,Y,X2,Y2 ), then a
  33. ^6routine like this would work fine....
  34.  
  35. ^2Do
  36. ^2        Gosub WAIT
  37. ^2        Serial Send 0,Str$(X) : Gosub WAIT
  38. ^2        X2=Val(Serial Input$(0)) : Gosub WAIT
  39. ^2        Serial Send 0,Str$(Y) : Gosub WAIT
  40. ^2        Y2=Val(Serial Input$(0)) : Gosub WAIT
  41. ^2        Bob 1,X,Y,1
  42. ^2        Bob 2,X2,Y2,2
  43. ^2Loop
  44. ^2'       
  45. ^2WAIT:
  46. ^2While Serial Check(0)=0 : Wend
  47. ^2Return
  48.  
  49. ^6 That  basically  displays  both  players  on  both  screens, if that
  50. ^6program was being run on both computers.
  51.  
  52.  
  53. ^2                       The Terminal Experience
  54.  
  55. ^6 I'm  not  going to give you whole listings on terminal software, but
  56. ^6I'll  give  you one of the best routines you'll find, concerning AMOS
  57. ^6Communications ( Probably the only routine ).
  58.  
  59. ^6 The  following  routine,  is SO versatile, you could log on to a BBS
  60. ^6with it, and do almost everything but file transfer!
  61.  
  62.  
  63. ^2                        The Routine Explained
  64.  
  65. ^6Well, basically.....
  66.  
  67. ^401.Start a Do...Looop
  68. ^402.     Get any keyboard inputs, into TEX$
  69. ^403.     Check to see if there are any keypress..
  70. ^404.            Make V$=TEX$
  71. ^405.            Make J=1
  72. ^406.     End the If
  73. ^407.     Check to see if J=1
  74. ^408.            Reset J, to 0
  75. ^409.            Send the String V$ to the serial port
  76. ^410.            Wait until the Serial Channel is Free Again
  77. ^411.     End the If
  78. ^412.     Set I$ to anything coming in over the Serial Channel
  79. ^413.     If There IS something coming through over the line..
  80. ^414.            Add I$ to J$.  J$ is used for Connecting checks, etc.
  81. ^415.            Check to see if the CONNECT string has been received.
  82. ^416.                    Reset j$
  83. ^417.                    Set The CONNECT string to one.
  84. ^4                                                 (Useful for BBS's)
  85. ^418.         End The If
  86. ^419.            Set up a For...Next... Loop, to the length of I$.
  87. ^420.                    Check to see if Any Carriage return/Line Feed
  88. ^4                                                               codes
  89. ^421.                            Reset J$
  90. ^422.                    End the If
  91. ^423.            Next....
  92. ^424.         Again, set up a NEW loop, for the length of I$
  93. ^425.                    Is there a FORM FEED character code in there?
  94. ^426.                            Clear the Output/Input Screen
  95. ^427.                    End The IF
  96. ^428.            Next....        
  97. ^429.            Make sure no control codes. ( More later )
  98. ^430.                    Output Anything Which has come in
  99. ^431.            End the If
  100. ^432.     End the IF
  101. ^433.Finish The Loop
  102.  
  103.  
  104. ^1                            BASIC ROUTINE
  105.  
  106.  
  107. ^201. Do
  108. ^202.    TEX$=Inkey$
  109. ^203.    If TEX$<>""
  110. ^204.       V$=TEX$
  111. ^205.       J=1
  112. ^206.    End If 
  113. ^207.    If J=1
  114. ^208.       J=0
  115. ^209.       Serial Send 0,V$
  116. ^210.       While Serial Check(0)=0 : Wend
  117. ^211.    End If 
  118. ^212.    I$=Serial Input$(0)
  119. ^213.    If I$<>""
  120. ^214.       J$=J$+I$
  121. 1^25.       If Right$(J$,7)="CONNECT" and Not(CONNECT=1)
  122. 1^26.          J$=""
  123. ^217.          CONNECT=1
  124. ^218.       End If 
  125. ^219.       For F=1 To Len(I$)
  126. ^220.          If Mid$(I$,F,1)=Chr$(13) or(Mid$(I$,F,1)=Chr$(10))
  127. ^221.             J$=""
  128. ^222.          End If 
  129. ^223.       Next F
  130. ^224.       For J=1 To Len(I$)
  131. ^225.          If Mid$(I$,J,1)=Chr$(12)
  132. ^226.             Cls 0
  133. ^227.          End If 
  134. ^228.       Next J
  135. ^229.       If CODE=0
  136. ^230.          Print I$; 
  137. ^231.       End If 
  138. ^232.    End If 
  139. ^233. Loop
  140.  
  141. ^4 The  connect  variable,  is very useful, when making COMMS packages.
  142. ^4Basically, if someone has connected to your modem, then this variable
  143. ^4will be set to one.  An easy check eh?
  144.  
  145. ^4 Host  machines, send control codes to tell the terminal program what
  146. ^4to  do.   Here are some of the useful ones you'll need to know.  2 of
  147. ^4them are already in the listing above...
  148.  
  149. ^1  CHR$(code)     -    ^2Function
  150.  
  151. ^1      07         -    ^2Bell                   ^4(Sound, or sample)
  152. ^1      10         -    ^2Linefeed               ^4(Used with CR)
  153. ^1      12         -    ^2FormFeed               ^4(Just clear Screen)
  154. ^1      13         -    ^2Carriage Return        ^4(Used with LF)
  155. ^1      27         -    ^2Escape Code            ^4(Used with ANSI)
  156.  
  157. ^4 All  this  is fine, if you're doing Terminal/BBS software.  But when
  158. ^4it  comes  to games, none of this is needed.  You just write your own
  159. ^4transfer  routines.   Its  very  easy with games, as you know what is
  160. ^4going  to be sent, and when, all the time.  A Serial Link game, could
  161. ^4have as little as 10 lines worth of actual serial TX/RX.
  162.  
  163. ^4 When  writing terminal software though, things get worse.  You don't
  164. ^4always  know  what`s going  to be sent, so you have to analyze what's
  165. ^4coming  in.  Is it a control code?  Is it ANSI?  Things like this get
  166. ^4very  confusing.   Although,  in 33 lines, you can do most things, in
  167. ^4reality, you need many more, to make it usable.
  168.  
  169. ^4 My  COMMS  program,  Bcomm, uses the EXACT routine above, although a
  170. ^4few  things  are  added  here  and there.  But, it is over 3000 lines
  171. ^4long.   Why?   Well,  because of ALL of the available options.  These
  172. ^4days,  a  comms  package  cannot  be just ok.  It has to be something
  173. ^4special.   The  good  point  about BCOMM, is the fact that it is user
  174. ^4friendly,  and  it  looked  good.   BCOMM  has  over  120  variables,
  175. ^4including about 10 dimension arrays.
  176.  
  177. ^2                         The HOST Experience
  178.  
  179. ^4 Next  up,  and  the  most difficult to produce, is BBS software.  In
  180. ^4reality, it is quite simple, but if you want it to compete with other
  181. ^4BBS's which are on-line now, it has to be absolutely excellent.
  182.  
  183. ^4 Luckily though, you don't just have to beat other boards'  software.
  184. ^4It's what is contained on the BBS which is the most important.  Users
  185. ^4don't want to be hanging around reading title text, which goes on for
  186. ^4pages  and  pages.   The  quicker  they  get into the BBS itself, the
  187. ^4better.
  188.  
  189. ^4 The  actual  coding  of  the  BBS, is much the same as the terminal,
  190. ^4except  that  it's  on a bigger scale.  It must provide the user with
  191. ^4easy  access.  You MUST have a Hard Disk to even think about starting
  192. ^4a  BBS.  Because it HAS to be able to handle the vast amounts of data
  193. ^4coming  in  from  around  the world.  Well, actually, it depends.  If
  194. ^4your  BBS is not often contacted you'll get away with a small HD, but
  195. ^4if  it's  a  well  used board, the last message a logged-on user will
  196. ^4want to see, is HD FULL!  So, make sure you're equipt.
  197.  
  198. ^4 I'm  about  to soon start writing a BBS editor.  It will essentially
  199. ^4be  BCOMM  v2.0.  And I had an excellent tip from Paul Roffrey, SYSOP
  200. ^4of  Amiga  Connection.   He  said the best way to go about it, was to
  201. ^4write  the  BBS  as  a  DATABASE, and then add all of the serial bits
  202. ^4later on.
  203.  
  204.  
  205. ^1I can be contacted at:
  206. ^2                      331 London Road
  207. ^2                      Stoneygate
  208. ^2                      Leicester
  209. ^2                      LE2 3NE
  210.  
  211. ^2  Or Telephone: ( 0533 ) 705630
  212.  
  213. ^1Or, should you have a modem, I can be reached on:
  214.  
  215. ^1                       01 For Amiga
  216. ^2                       Amiga Connection
  217. ^1                       Amiga Information
  218. ^2                       Digital Information Exchange
  219. ^1                       Voyager
  220. ^2                       Kneptune
  221. ^1                       The Pig Pen
  222.  
  223. ^4Just Mail me, as `Ben Ashley'.
  224.  
  225. ^1Please feel free to contact me if you have any problems, or even if you
  226. ^1have any AMOS problems at all!
  227.  
  228.  
  229. ^3                   ******** N O T I C E *********
  230.  
  231. ^6 I  am  now  an  official member of TECHNICAL FRED SOFTWARE.  ODYSSEY
  232. ^6SOFTWARE is still going, but sort-of-like, UNDER Technical Fred.
  233.  
  234. ^4-----------------------------------------------------------------------
  235.  
  236. ^1 If  all  you  wanted to do, was to mail the SYSOP, or leave messages
  237. ^1then  this  is  fine.   File  Transfering  is  more difficult, and is
  238. ^1covered in the next issue of TOTALLY AMOS......
  239.  
  240. ^2(  A  brilliant  excuse  to  buy  the  next  issue  of  course  !   )
  241.  
  242. ^4----------------------------------------------------------------------
  243.  
  244. ^2             Written by Ben Ashley, of ODYSSEY SOFTWARE 1992
  245.  
  246. ^4---------------------------------------------------------------------
  247. /
  248.