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 / C128 / B5C8-2.INS < prev    next >
Text File  |  2000-06-30  |  7KB  |  262 lines

  1. ; B5C8-2.INS - BYE5 insert for Commodore C128, external modem - 8/11/86
  2. ;
  3. ;        Note, this is an insert, not an overlay.
  4. ;        It will only work with BYE510 or higher.
  5. ;        When going through the options for
  6. ;        BYE5, set the clock speed:
  7. ;
  8. ;              MHZ  EQU  1
  9. ;
  10. ;        The modem routines built into the Com-
  11. ;        modore IOS use "bit-banging" interrupt
  12. ;        control and this value should be used.
  13. ;        (All this does is control the number of
  14. ;        loops used for timing purposes.)
  15. ;
  16. ;-----------------------------------------------------------------------
  17. ; TO INSTALL:
  18. ;
  19. ; You will need the following files from BYE5nn.LBR to properly imple-
  20. ; ment BYE5 on your C128 which uses CP/M 3.0:
  21. ;
  22. ;     BYE5nn.AQM   - The BYE5 source file for CP/M 2 or CP/M 3
  23. ;     B5-CPM3.AQM  - CP/M Plus program renamed to BYE.COM during install
  24. ;     B5-DRIV3.AQM - BYE5 RSX driver program called internally by BYE
  25. ;             to initialize the CP/M Plus RSX
  26. ;
  27. ; You will need the following file from B5-CLOCK.LBR if you want to use
  28. ; the clock support provided in BYE5:
  29. ;
  30. ;     B5C-CPM3.IQS - CP/M Plus clock insert
  31. ;
  32. ; Configuration information for BYE5 is available in BYE5.DQC (from
  33. ; BYE5nn.LBR).    Additional CP/M Plus-specific information and generation
  34. ; instructions are in B5-CPM3.DQC (also from BYE5nn.LBR).
  35. ;
  36. ;                        - notes by George Peace
  37. ;
  38. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  39. ;
  40. ; 07/21/86  Modified version for BYE510.  Changed MRCARCK to correct the
  41. ;        actual PORT check.    Added a CMA in MDOUTST.  Reset Zero-flag
  42. ;        in MDIN2: for baud rate change.    - David Giunti
  43. ;
  44. ; 12/12/85  Original version for BYE5        - Irv Hoff
  45. ;
  46. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  47. ;
  48. ; C128 data
  49. ;
  50. PORT    EQU    6
  51. MEMRY    EQU    0FD4EH
  52. MDCTL1    EQU    MEMRY+1
  53. SNDDAT    EQU    MEMRY+2
  54. RCVDAT    EQU    MEMRY+3
  55. MDDCD    EQU    10H        ; Bit 4 to test for DCD
  56. MDRCV    EQU    01H        ; Bit 0 to test for receive ready
  57. MDSND    EQU    80H        ; Bit 7 to test for send
  58. ;
  59. CBNK    EQU    0FD1DH        ; Address of the current bank byte
  60. ;
  61. ;
  62. ; Table of baudrate parameters
  63. ;
  64. BD300    EQU    6        ; Divisor for 300 baud
  65. BD1200    EQU    8        ; Divisor for 1200 bps (The Commodore
  66.                 ;   C128 does not support faster speeds
  67.                 ;   in the CP/M-128 mode)
  68. ;
  69. ;-----------------------------------------------------------------------
  70. ;
  71. ; See if we still have a carrier - if not, return with the zero flag set
  72. ;
  73. MDCARCK:
  74.     PUSH    B        ; save reg
  75.     LXI    B,0DD01H    ; point at data port B
  76.     DB    0EDH,78H    ; Input to A, pointed by BC
  77.     CMA            ; Invert the value for active low
  78.     ANI    MDDCD        ; Check DCD for carrier from modem
  79.     POP    B        ; restore B reg
  80.     RET
  81. ;.....
  82. ;
  83. ;
  84. ; Disconnect and wait for an incoming call.
  85. ;
  86. MDINIT:    LXI    B,0DD01H    ; Dataport B
  87.     DB    0EDH,78H    ; Input A (Z80 instruction)
  88.     ANI    0F9H
  89.     DB    0EDH,79H    ; Output the new value, to disconnect
  90.     MVI    B,20        ; 2 seconds to drop DTR
  91.  
  92. MDIN1:    CALL    DELAY        ; 0.1 second delay
  93.     DCR    B
  94.     JNZ    MDIN1        ; Keep waiting until carrier drops
  95.     LXI    B,0DD01H    ; Reset back to normal
  96.     DB    0EDH,78H
  97.     ORI    6
  98.     DB    0EDH,79H
  99.     MVI    A,1        ; Set to 8 bits, no parity
  100.     STA    MEMRY        ; Configure byte in BIOS
  101.     MVI    B,BD300        ; Initialize to 300 baud
  102. ;.....
  103. ;
  104. ;
  105. ; Initialize the port, baudrate is now in the B-reg. find where it goes
  106. ; and put it there.
  107. ;
  108. MDIN2:    PUSH    B        ; Temporarily store the baudrate value
  109.     LHLD    0000H+1        ; Get BIOS address
  110.     LXI    D,57        ; CP/M JMP device table
  111.     DAD    D        ; Index into BIOS
  112.     CALL    MDIN3        ; Jumps to address now in HL
  113.                 ; returns with HL=char device tbl start
  114.     LXI    D,PORT*8+7    ; Offset to RS232 baud rate
  115.     DAD    D        ; Point to RS232 baud rate byte
  116.                 ;   Byte now in HL
  117.     POP    B        ; Get the baudrate value back
  118.     MOV    M,B        ; Store the requested baud rate
  119. ;
  120. ;
  121. ; Have now stored desired baudrate, find the address in BIOS where the
  122. ; port will be initialized, put the correct port into the 'C' register
  123. ; and then initialize that port to baud rate just set, finished.
  124. ;
  125.     LHLD    0000H+1        ; Get BIOS address
  126.     LXI    D,60        ; CP/M init address
  127.     DAD    D        ; Index into BIOS
  128.     MVI    C,PORT        ; Tell it what port to initialize
  129.     CALL    MDIN3
  130.     XRA    A        ; Sets Zero flag
  131. ;
  132. ;
  133. ; Jumps to HL address, performs that routine, then returns here
  134. ;
  135.      IF    IMODEM
  136.     CALL    IMINIT        ; Initialize smartmodem
  137.      ENDIF            ; IMODEM
  138. ;
  139.     RET
  140. ;...
  141. ;
  142. ;
  143. MDIN3:    PCHL            ; Jump to that routine then return
  144. ;.....
  145. ;
  146. ;
  147. ; Input a character from the modem port
  148. ;
  149. MDINP:    LDA    RCVDAT        ; Get character
  150. ;
  151. ;
  152. ; We found there was a character, got it, but have to manually reset the
  153. ; flag to zero saying we did get the character.
  154. ;
  155.     PUSH    H        ; Save the current address just in case
  156.     LXI    H,MDCTL1    ; Address of status byte
  157.     DB    0CBH,86H    ; Reset the 0 bit of the HL status byte
  158.     POP    H        ; Restore the original address
  159.     RET            ; Return with the character
  160. ;.....
  161. ;
  162. ;
  163. ; Check the status to see if a character is available.    if not, return
  164. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  165. ;
  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
  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.