home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BYE5 / B5C8-1E.INS < prev    next >
Text File  |  2000-06-30  |  8KB  |  268 lines

  1. ; B5C8-1E.INS - BYE5 insert for Commodore C128, external modem - 7/21/86
  2. ;
  3. ;  Modifications by David Giunti,  July 20, 1986
  4. ;    change MDCARCK to correct the actual PORT check
  5. ;      Note all the I/O in the C=128 is located in Bank 0, and can 
  6. ;      be read and written useing the Z80's IN and OUT with 16bit
  7. ;      pointers. 
  8. ;      
  9. ;    Added a CMA in the MDOUTST
  10. ;
  11. ;    I'm still not sure if MHZ should be 1 rather than 2, as this
  12. ;        .INS could not have worked without MDCARCK
  13. ;  July 21.  This .INS will work correctly with MHZ set to 2.  If 
  14. ;  you have an 80col monitor use Von Ertwine's CONFIG to set 40COL=OFF
  15. ;  as this gives a 10%+ system speed-up.  Get a copy of CCP+.LBR and use it.
  16. ;  July 26.   The TSTBAUD: routine requires that the Zero flag be set to 
  17. ;  know that the  baudrate was correctly set, and MDIN2: returns it set 
  18. ;  so rather than just comment out the code in the main BYE509 I'll add
  19. ;  some ugly code to set the Zero Flag manually. 
  20. ;
  21. ; .INS is now very ready for final test
  22. ;      Dave Giunti  
  23. ;======================Original Header============12/12/85===========
  24. ;    IMPORTANT:  When going through the options for
  25. ;            BYE5, be sure to set:
  26. ;
  27. ;                MHZ  EQU  1
  28. ;
  29. ;            regardless what you think it should
  30. ;            be set for.  The modem routines built
  31. ;            into the Commodore IOS use "bit-bang-
  32. ;            ing" interrupt control and this value
  33. ;            should be used.  (All this does is
  34. ;            control the number of loops used for
  35. ;            timing purposes.)
  36. ;
  37. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  38. ;
  39. ; 12/12/85  Written to work with BYE5        - Irv Hoff
  40. ; 07/21/86  modified version for BYE509 from work done by
  41. ;           Irv Hoff and George Peace                    - David Giunti
  42. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  43. ;
  44. ; C128 data
  45. ;
  46. PORT    EQU    6
  47. MEMRY    EQU    0FD4EH
  48. MDCTL1    EQU    MEMRY+1
  49. SNDDAT    EQU    MEMRY+2
  50. RCVDAT    EQU    MEMRY+3
  51. MDDCD    EQU    10H        ; Bit 4 to test for DCD
  52. MDRCV    EQU    01H        ; Bit 0 to test for receive ready
  53. MDSND    EQU    80H        ; Bit 7 to test for send
  54. ;
  55. CBNK    EQU    0FD1DH        ; Address of the current bank byte
  56. ;
  57. ;
  58. ; Table of baudrate parameters
  59. ;
  60. BD300    EQU    6        ; Divisor for 300 baud
  61. BD1200    EQU    8        ; Divisor for 1200 bps (The Commodore
  62.                 ;   C128 does not support faster speeds
  63.                 ;   in the CP/M-128 mode)
  64. ;
  65. ;-----------------------------------------------------------------------
  66. ;
  67. ; See if we still have a carrier - if not, return with the zero flag set
  68. ;
  69. MDCARCK:
  70. ;    LDA    0DD01H        ; Get status
  71. ;       this should be an IN like in MDINIT below to work correctly -dag
  72.     PUSH    B        ; save reg
  73.     LXI    B,0DD01H    ; point at data port B
  74.     DB    0EDH,78H    ; Input to A, pointed by BC
  75.     CMA            ; Invert the value for active low
  76.     ANI    MDDCD        ; Check DCD for carrier from modem
  77.     POP    B        ; restore B reg
  78.     RET
  79. ;.....
  80. ;
  81. ;
  82. ; Disconnect and wait for an incoming call.
  83. ;
  84. MDINIT:    LXI    B,0DD01H    ; Dataport B
  85.     DB    0EDH,78H    ; Input A (Z80 instruction)
  86.     ANI    0F9H
  87.     DB    0EDH,79H    ; Output the new value, to disconnect
  88.     MVI    B,20        ; 2 seconds to drop DTR
  89.  
  90. MDIN1:    CALL    DELAY        ; 0.1 second delay
  91.     DCR    B
  92.     JNZ    MDIN1        ; Keep waiting until carrier drops
  93.     LXI    B,0DD01H    ; Reset back to normal
  94.     DB    0EDH,78H
  95.     ORI    6
  96.     DB    0EDH,79H
  97.     MVI    A,1        ; Set to 8 bits, no parity
  98.     STA    MEMRY        ; Configure byte in BIOS
  99.     MVI    B,BD300        ; Initialize to 300 baud
  100. ;.....
  101. ;
  102. ;
  103. ; Initialize the port, baudrate is now in the B-reg. find where it goes
  104. ; and put it there.
  105. ;
  106. MDIN2:    PUSH    B        ; Temporarily store the baudrate value
  107.     LHLD    0000H+1        ; Get BIOS address
  108.     LXI    D,57        ; CP/M JMP device table
  109.     DAD    D        ; Index into BIOS
  110.     CALL    MDIN3        ; Jumps to address now in HL
  111.                 ; returns with HL=char device tbl start
  112.     LXI    D,PORT*8+7    ; Offset to RS232 baud rate
  113.     DAD    D        ; Point to RS232 baud rate byte
  114.                 ;   Byte now in HL
  115.     POP    B        ; Get the baudrate value back
  116.     MOV    M,B        ; Store the requested baud rate
  117. ;
  118. ;
  119. ; Have now stored desired baudrate, find the address in BIOS where the
  120. ; port will be initialized, put the correct port into the 'C' register
  121. ; and then initialize that port to baud rate just set, finished.
  122. ;
  123.     LHLD    0000H+1        ; Get BIOS address
  124.     LXI    D,60        ; CP/M init address
  125.     DAD    D        ; Index into BIOS
  126.     MVI    C,PORT        ; Tell it what port to initialize
  127.     CALL    MDIN3
  128. ;
  129.     xra    a        ; clears all bits in Acum, sets Zero flag -dag
  130. ;
  131. ;
  132. ; Jumps to HL address, performs that routine, then returns here
  133. ;
  134.      IF    IMODEM
  135.     CALL    IMINIT        ; Initialize smartmodem
  136.      ENDIF            ; IMODEM
  137. ;
  138.     RET
  139. ;...
  140. ;
  141. ;
  142. MDIN3:    PCHL            ; Jump to that routine then return
  143. ;.....
  144. ;
  145. ;
  146. ; Input a character from the modem port
  147. ;
  148. MDINP:    LDA    RCVDAT        ; Get character
  149. ;
  150. ;
  151. ; We found there was a character, got it, but have to manually reset the
  152. ; flag to zero saying we did get the character.
  153. ;
  154.     PUSH    H        ; Save the current address just in case
  155.     LXI    H,MDCTL1    ; Address of status byte
  156.     DB    0CBH,86H    ; Reset the 0 bit of the HL status byte
  157.     POP    H        ; Restore the original address
  158.     RET            ; Return with the character
  159. ;.....
  160. ;
  161. ;
  162. ; Check the status to see if a character is available.    if not, return
  163. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  164. ;
  165. ;  note that CMA is not required here because of the logical construction
  166. MDINST:    LDA    MDCTL1        ; Get status
  167.     ANI    MDRCV
  168.     RZ            ; No character, return
  169. ;...
  170. ;
  171. ;
  172. MDINST1:ORI    0FFH        ; We have a character, clear the flag
  173.     RET
  174. ;.....
  175. ;
  176. ;
  177. ; Send a character to the modem
  178. ;
  179. MDOUTP:    STA    SNDDAT        ; Output the character
  180. ;
  181. ;
  182. ; Output character has been stored in the BIOS memory location, now set
  183. ; the flag showing there is a charcter ready.
  184. ;
  185.     PUSH    H        ; Save any current address, if needed
  186.     LXI    H,MDCTL1    ; Address of the status byte
  187.     DB    0CBH,0FEH    ; Set bit 7 of the HL status byte
  188.     POP    H        ; Get the original address back
  189.     RET            ; All done
  190. ;.....
  191. ;
  192. ;
  193. ; See if the output is ready for another character
  194. ;
  195. MDOUTST:LDA    MDCTL1        ; Get the status bit
  196.     cma            ; invert bits for check -dag
  197.     ANI    MDSND        ; Check send ready bit
  198.     RET            ; If pin is high, not ready
  199. ;.....
  200. ;
  201. ;
  202. ; Renitialize the modem and hang up the phone by dropping DTR and
  203. ; leaving it inactive.
  204. ;
  205. MDQUIT:     IF    IMODEM
  206.     CALL    IMQUIT
  207.      ENDIF            ; IMODEM
  208. ;
  209. ;
  210. ; Called by the main program after caller types BYE
  211. ;
  212. MDSTOP:    MVI    B,BD300        ; Initialize to 300 baud
  213.     CALL    MDIN2        ; Set to 300 baud to speed up C128
  214.     LXI    B,0DD01H    ; Dataport B
  215.     DB    0EDH,78H    ; Input A (Z80 instruction)
  216.     ANI    0F9H        ; Keep DTR set low permanently
  217.     DB    0EDH,79H    ; Output the new value, to disconnect
  218.     RET
  219. ;.....
  220. ;
  221. ;
  222. ; The following routine sets the baudrte.  BYE5 asks for the maximum
  223. ; speed you have available.
  224. ;
  225. SET2400    EQU    0
  226. ;
  227. SETINV:    MVI    A,0FFH
  228.     ORA    A        ; Make sure the Zero flag isn't set
  229.     RET
  230. ;.....
  231. ;
  232. ;
  233. SET300:    MVI    B,BD300        ; Get 300 baud parameters in 'HL'
  234.     JMP    MDIN2
  235. ;
  236.  
  237. SET1200:MVI    B,BD1200
  238.     JMP    MDIN2
  239. ;.....
  240. ;
  241. ;
  242. ;-----------------------------------------------------------------------
  243. ;            CP/M v3.0 routines
  244. ;
  245. ; Perform system or hardware dependent PRE-processing.    The following
  246. ; code will be executed by the PATCH subroutine before the BIOS jump
  247. ; table is overwritten.
  248. ;
  249. MDPREP:    RET
  250. ;.....
  251. ;
  252. ;
  253. ; Perform system or hardware dependent POST-processing.
  254. ; The following code will be executed by the EXCPM routine before re-
  255. ; turning control to CP/M Plus when the BYE5 program is terminated.
  256. ;
  257. MDPOSP:    RET
  258. ;.....
  259. ;
  260. ;                   end
  261. ;-----------------------------------------------------------------------
  262. minated.
  263. ;
  264. MDPOSP:    RET
  265. ;.....
  266. ;
  267. ;                   end
  268. ;--------------------------------------