home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PRO98SRC.ZIP / GTEK.BAS < prev    next >
BASIC Source File  |  1993-11-07  |  9KB  |  353 lines

  1. FUNCTION GTEKSetChannel%(csc?)
  2. ' Selects a channel on the card.  Returns TRUE if successful
  3. tries? = 50
  4. SetChannelWAIT:
  5. DECR Tries?
  6. IF Tries?=0 THEN EXIT FUNCTION
  7. !    mov    dx,GTEKBase??
  8. !    inc    dx
  9. !    in    al,dx        ; get status
  10. !    test    al, &H80    ; check ready bit 7
  11. !    jz    SetChannelWAIT    ; uh-oh, board not ready
  12. !    mov    al,csc?            ; put channel into AL
  13. !    out    dx,al        ; send command (csc) to card
  14. GTEKSetChannel% = %TRUE
  15. END FUNCTION
  16.  
  17. FUNCTION GTEKStatus? 
  18. ' Checks the status of the card.  Returns a status byte.
  19. tries? = 10
  20. StatusWAIT:
  21. DECR tries?
  22. IF tries?=0 THEN EXIT FUNCTION
  23. !    mov    dx,GTEKBase??   ; put command register address in DX
  24. !    inc    dx              ; point to data register
  25. !    in    al,dx        ; get status
  26. !    test    al, &H80    ; check ready bit 7
  27. !    jz    StatusWAIT    ; uh-oh, board not ready
  28. !    mov    al,&H08        ; force channel status update
  29. !    out    dx,al        ; send command to card
  30.  
  31. !    dec    dx              ; point to data register
  32. !    in    al,dx        ; get status byte
  33. !    mov    tries?,al    ; put status byte into byte variable
  34.  
  35. GTEKStatus? = tries?            ' return byte
  36.  
  37. END FUNCTION
  38.  
  39. FUNCTION GTEKPortInit%(Parameter$)
  40. ' set the current channel baud, parity, word and stop
  41. ' (i.e. 2400,N,8,1)
  42. SELECT CASE VAL(Parameter$)
  43.     CASE 300
  44.     pbyte? = &B01000000
  45.     CASE 1200
  46.     pbyte? = &B10000000
  47.     CASE 2400
  48.     pbyte? = &B10100000
  49.     CASE 4800
  50.     pbyte? = &B11000000
  51.     CASE 9600
  52.     pbyte? = &B11100000
  53.     CASE 19200
  54.     pbyte? = &B00100000
  55.     CASE ELSE
  56.     pbyte? = &B10100000 ' default to 2400 baud
  57. END SELECT
  58. REPLACE "," with "" in Parameter$
  59. P$ = UCASE$(MID$(Parameter$+",",len( str$(val(Parameter$)))))
  60. REPLACE "," with "" in P$
  61. SELECT CASE P$
  62.     CASE "N81"
  63.         pbyte? = pbyte? + &B00000011
  64.     CASE "E71"
  65.         pbyte? = pbyte? + &B00011010
  66.     CASE "E72"
  67.         pbyte? = pbyte? + &B00011110
  68.     CASE ELSE
  69.         pbyte? = pbyte? + &B00000011
  70. END SELECT
  71.  
  72. tries? = 10
  73. InitPortWAIT:
  74. DECR tries?
  75. IF tries?=0 THEN EXIT FUNCTION
  76. !    mov    dx,GTEKBase??   ; put command register address in DX
  77. !    inc    dx              ; point to data register
  78. !    in    al,dx        ; get status
  79. !    test    al, &H80    ; check ready bit 7
  80. !    jz    InitPortWAIT    ; uh-oh, board not ready
  81. !    mov    al,&H18        ; command to initialize port
  82. !    out    dx,al        ; send command to card
  83.  
  84. tries? = 10
  85. InitPortWAIT2:
  86. DECR tries?
  87. IF tries?=0 THEN EXIT FUNCTION
  88. !    mov    dx,GTEKBase??   ; put command register address in DX
  89. !    inc    dx              ; point to data register
  90. !    in    al,dx        ; get status
  91. !    test    al, &H80    ; check ready bit 7
  92. !    jz    InitPortWAIT2    ; uh-oh, board not ready
  93.  
  94. !    dec    dx        ; point to data register
  95. !     mov    al,pbyte?     ; put the parameters into al
  96. !    out     dx,al        ; and write it into the data register
  97.  
  98. GTEKPortInit% = %TRUE
  99.  
  100. END FUNCTION
  101.  
  102. SUB GTEKWriteByte(wbyte?)
  103. ' Write a byte to the port.
  104. tries? = 10
  105. WriteByteWAIT:
  106. DECR Tries?
  107. IF tries?=0 THEN wbyte? = 0:EXIT SUB
  108. !    mov    dx,GTEKBase??
  109. !    inc    dx
  110. !    in    al,dx        ; get status
  111. !    test    al, &H80    ; check ready bit 7
  112. !    jz    WriteByteWAIT    ; uh-oh, board not ready
  113. '!    dec    dx        ; point to data port
  114. '!    mov    al,wbyte?    ; byte to send is in al
  115. '!     out    dx,al        ; write byte to data port
  116. OUT GTEKBase??, wbyte?
  117. END SUB
  118.  
  119. FUNCTION GTEKReadByte?
  120. tries? = 10
  121. ReadByteWAIT:
  122. DECR Tries?
  123. IF Tries?=0 THEN EXIT FUNCTION
  124. !    mov    dx,GTEKBase??
  125. !    inc    dx
  126. !    in    al,dx        ; get status
  127. !    test    al, &H80    ; check ready bit 7
  128. !    jz    ReadByteWAIT    ; uh-oh, board not ready
  129.  
  130. IF (INP(GTEKBase??) AND 1) THEN GTEKReadByte? = INP(GTEKBase??)
  131.  
  132. '!    dec    dx        ; point to the data port
  133. '!    in    al,dx        ; read status byte
  134. '!    test    al,&H01        ; see if there is data waiting
  135. '!    jz    NoData        ; abandon if there is no data
  136. '!    in    al,dx        ; this is the data
  137. '!    mov    tries?,al    ; use the byte, since its there
  138. 'GTEKReadByte? = tries?
  139. 'NoData:
  140. END FUNCTION
  141.  
  142. FUNCTION GTEKStartBreak% 
  143. ' Transmit dataline goes to +12 volts until stop break is issued
  144. tries? = 10
  145. StartBreakWAIT:
  146. DECR tries?
  147. IF tries?=0 THEN EXIT FUNCTION
  148. !    mov    dx,GTEKBase??   ; put command register address in DX
  149. !    inc    dx              ; point to data register
  150. !    in    al,dx        ; get status
  151. !    test    al, &H80    ; check ready bit 7
  152. !    jz    StartBreakWAIT    ; uh-oh, board not ready
  153. !     mov    al,&H10
  154. !    out    dx,al
  155. GTEKStartBreak% = %TRUE
  156. END FUNCTION
  157.  
  158. FUNCTION GTEKEndBreak% 
  159. ' Restore transmit data line to -12 volts
  160. tries? = 10
  161. EndBreakWAIT:
  162. DECR tries?
  163. IF tries?=0 THEN EXIT FUNCTION
  164. !    mov    dx,GTEKBase??   ; put command register address in DX
  165. !    inc    dx              ; point to data register
  166. !    in    al,dx        ; get status
  167. !    test    al, &H80    ; check ready bit 7
  168. !    jz    EndBreakWAIT    ; uh-oh, board not ready
  169. !    mov    al, &H11
  170. !    out    dx,al
  171. GTEKEndBreak% = %TRUE
  172. END FUNCTION
  173.  
  174. FUNCTION GTEKAssertDTR% 
  175. ' Set DTR to high
  176. tries? = 10
  177. AssertDTRWAIT:
  178. DECR tries?
  179. IF tries?=0 THEN EXIT FUNCTION
  180. !    mov    dx,GTEKBase??   ; put command register address in DX
  181. !    inc    dx              ; point to data register
  182. !    in    al,dx        ; get status
  183. !    test    al, &H80    ; check ready bit 7
  184. !    jz    AssertDTRWAIT    ; uh-oh, board not ready
  185. !    mov    al,&H12
  186. !    out    dx,al
  187. GTEKAssertDTR% = %TRUE
  188. END FUNCTION
  189.  
  190. FUNCTION GTEKNegateDTR 
  191. ' Set DTR to low
  192. tries? = 10
  193. NegateDTRWAIT:
  194. DECR tries?
  195. IF tries?=0 THEN EXIT FUNCTION
  196. !    mov    dx,GTEKBase??   ; put command register address in DX
  197. !    inc    dx              ; point to data register
  198. !    in    al,dx        ; get status
  199. !    test    al, &H80    ; check ready bit 7
  200. !    jz    NegateDTRWAIT    ; uh-oh, board not ready
  201. !    mov    al,&H12
  202. !    out    dx,al
  203. GTEKNegateDTR% = %TRUE
  204. END FUNCTION
  205.  
  206. FUNCTION GTEKGetGlobalCTS? 
  207. ' returns a bit pattern of the CTS conditions of each line
  208. tries? = 10
  209. GetGlobalCTSWAIT:
  210. DECR tries?
  211. IF tries?=0 THEN EXIT FUNCTION
  212. !    mov    dx,GTEKBase??   ; put command register address in DX
  213. !    inc    dx              ; point to data register
  214. !    in    al,dx        ; get status
  215. !    test    al, &H80    ; check ready bit 7
  216. !    jz    GetGlobalCTSWAIT    ; uh-oh, board not ready
  217. !    mov    al,&H15
  218. !    out    dx,al
  219. !    dec    dx
  220. !    in    al,dx
  221. !    mov    tries?,al
  222. GTEKGetClobalCTS? = tries?
  223. END FUNCTION
  224.  
  225.  
  226. FUNCTION GTEKGetGlobalCD? 
  227. ' returns a bit pattern of the Carrier Detect conditions of each line
  228. tries? = 10
  229. GetGlobalCDWAIT:
  230. DECR tries?
  231. IF tries?=0 THEN EXIT FUNCTION
  232. !    mov    dx,GTEKBase??   ; put command register address in DX
  233. !    inc    dx              ; point to data register
  234. !    in    al,dx        ; get status
  235. !    test    al, &H80    ; check ready bit 7
  236. !    jz    GetGlobalCDWAIT    ; uh-oh, board not ready
  237. !    mov    al,&H14
  238. !    out    dx,al
  239. !    dec    dx
  240. !    in    al,dx
  241. !    mov    tries?,al
  242. GTEKGetClobalCD? = tries?
  243. END FUNCTION
  244.  
  245. FUNCTION GTEKGetModemStatus? 
  246. ' returns a bit pattern of the Carrier Detect conditions of each line
  247. tries? = 10
  248. GetModemStatusWAIT:
  249. DECR tries?
  250. IF tries?=0 THEN EXIT FUNCTION
  251. !    mov    dx,GTEKBase??   ; put command register address in DX
  252. !    inc    dx              ; point to data register
  253. !    in    al,dx        ; get status
  254. !    test    al, &H80    ; check ready bit 7
  255. !    jz    GetModemStatusWAIT    ; uh-oh, board not ready
  256. !    mov    al,&H16
  257. !    out    dx,al
  258. !    dec    dx
  259. !    in    al,dx
  260. !    mov    tries?,al
  261. GTEKGetModemStatus? = tries?
  262. END FUNCTION
  263.  
  264.  
  265. SUB GTEKPRINT(A$) 
  266. IF LEN(A$) THEN
  267.     FOR i% = 1 TO len(a$)
  268.         w? = ASCII(Mid$(A$,i%,1))
  269.         GTEKWriteByte w?
  270.     NEXT i%
  271. END IF
  272. END SUB
  273.  
  274.  
  275. FUNCTION GTEKINKEY$ 
  276.     i? = GTEKReadByte
  277.     IF i? THEN GTEKINKEY$ = CHR$(i?)
  278. END FUNCTION
  279.  
  280.  
  281. SUB GTEKXonXoffEnable
  282. 'Enable Xon/Xoff handshaking
  283. tries? = 10
  284. XonXoffEnableWAIT:
  285. DECR tries?
  286. IF tries?=0 THEN EXIT SUB
  287. !    mov    dx,GTEKBase??   ; put command register address in DX
  288. !    inc    dx              ; point to data register
  289. !    in    al,dx        ; get status
  290. !    test    al, &H80    ; check ready bit 7
  291. !    jz    XonXoffEnableWAIT    ; uh-oh, board not ready
  292. !    mov    al,&H19
  293. !    out    dx,al
  294. !    dec    dx
  295. !    mov    al,&B00001010
  296. !    out    dx,al
  297. END SUB
  298.  
  299. SUB GTEKDtrCtsEnable 
  300. ' Enable DTR/CTS handshaking
  301. tries? = 10
  302. DtrCtsEnableWAIT:
  303. DECR tries?
  304. IF tries?=0 THEN EXIT SUB
  305. !    mov    dx,GTEKBase??   ; put command register address in DX
  306. !    inc    dx              ; point to data register
  307. !    in    al,dx        ; get status
  308. !    test    al, &H80    ; check ready bit 7
  309. !    jz    DtrCtsEnableWAIT    ; uh-oh, board not ready
  310. !    mov    al,&H19
  311. !    out    dx,al
  312. !    dec    dx
  313. !    mov    al,&B00010100
  314. !    out    dx,al
  315. END SUB
  316.  
  317.  
  318. SUB GTEKXonXoffDisable 
  319. ' disable handshaking
  320. tries? = 10
  321. XonXoffDisableWAIT:
  322. DECR tries?
  323. IF tries?=0 THEN EXIT SUB
  324. !    mov    dx,GTEKBase??   ; put command register address in DX
  325. !    inc    dx              ; point to data register
  326. !    in    al,dx        ; get status
  327. !    test    al, &H80    ; check ready bit 7
  328. !    jz    XonXoffDisableWAIT    ; uh-oh, board not ready
  329. !    mov    al,&H19
  330. !    out    dx,al
  331. !    dec    dx
  332. !    mov    al,&B00000000
  333. !    out    dx,al
  334. END SUB
  335.  
  336. SUB GTEKDtrCtsDisable
  337. ' Disable handshaking.  This does the same thing as xonxoffdisable
  338. tries? = 10
  339. DtrCtsDisableWAIT:
  340. DECR tries?
  341. IF tries?=0 THEN EXIT SUB
  342. !    mov    dx,GTEKBase??   ; put command register address in DX
  343. !    inc    dx              ; point to data register
  344. !    in    al,dx        ; get status
  345. !    test    al, &H80    ; check ready bit 7
  346. !    jz    DtrCtsDisableWAIT    ; uh-oh, board not ready
  347. !    mov    al,&H19
  348. !    out    dx,al
  349. !    dec    dx
  350. !    mov    al,&B00000000
  351. !    out    dx,al
  352. END SUB
  353.