home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols200 / vol287 / turbo2.lbr / RTDS15UP.LBR / DUALIO.MQC / DUALIO.MAC
Text File  |  1986-12-17  |  5KB  |  187 lines

  1.     TITLE    TURBODOS NULL CONSOLE DRIVER + MODEM DRIVER
  2. ;
  3. ;    dualio.mac
  4.  
  5. ;
  6. ; DUALIO, in existence mostly thanks to Steve Rasmussen of
  7. ; Intercontinental Microsystems with many mods by ESKAY
  8. ;
  9. ; For use with ICM's SPICPS module. For SPDCPS, see note in TSTDCD:.
  10. ; For other systems, see note at S0DCDE.
  11. ;
  12.     .Z80                ; zilog mnemonics
  13. ;
  14.     NAME    ('dualio')        ; module id
  15. ;
  16.     PUBLIC    CONBR            ; set conbr to public
  17.     PUBLIC    MODBR            ; set modbr to public
  18. ;
  19.     DSEG                ; locate in data segment
  20. ;
  21. FFCHR::    DB    0            ; form feed character (not used)
  22. INITC:    DB    0            ; initialization complete flag
  23. tomc::    db    0
  24. ;
  25.     COMMON    /?INIT?/        ; place into common segment
  26. ;
  27. consnit:DEC    (HL)                 ; set init complete flag
  28.     PUSH    DE                 ; save function number
  29.     PUSH    BC                 ; save chan number/character
  30. ;
  31. ; set console baud rate
  32. ;
  33.     LD    C,8FH                 ; baud rate code to c-reg 19.2 kbaud
  34. CONBR    EQU    $-1            ; pointer back to baud rate byte
  35.     LD    E,3                 ; set function number = 3
  36.     CALL    SERIAL##             ; set channel 1 baud rate
  37. ;
  38. ;set modem baud rate
  39. ;
  40.     LD      B,0            ; set to modem channel number
  41.     LD    C,07H                 ; baud rate code to c-reg 1200 baud
  42. MODBR    EQU    $-1            ; pointer back to baud rate byte
  43.     LD    E,3                 ; set function number = 3
  44.     CALL    SERIAL##             ; set channel 0 baud rate
  45. wtlp:    call    tstdcd            ; make sure no carrier while initing
  46.     jr    nz,wtlp
  47.     POP    BC                 ; restore channel number/character
  48.     POP    DE                 ; restore function number
  49.     RET
  50. ;
  51.     CSEG                ; locate in program area
  52. ;
  53. CONDR@::LD    HL,INITC        ; get initialization complete flag
  54.     LD    A,(HL)
  55.     OR    A                 ; initialization complete flag set ?
  56.     call    z,consnit
  57. ;
  58.     LD    A,E                 ; get function number
  59.     SUB    10                 ; function number = 10?
  60.     JP    Z,CONS10             ; if so, return error code since
  61.                      ; modem checking code to complex
  62.                     ; for fnction 10, detour through
  63.                     ; other functions 
  64. ;
  65.     INC    A                 ; function number = 9?
  66.     JP    Z,CONS9            ; if so enter routine
  67.     INC    A                 ; function number = 8?
  68.     JP    Z,CONS8            ; if so enter routine
  69.     LD    A,E                 ; get function number
  70.     CP    2                 ; function number = 2?
  71.     JP    Z,CONS2            ; if so enter rutine
  72.     CP    1                 ; function number = 1?
  73.     JP    Z,CONS1            ; if so enter rutine
  74.     or    a
  75.     jp    nz,serial##
  76.                     ; status check function 0
  77.     CALL    SERIAL##        ; test console status
  78.     OR    A            ; set flags
  79.     RET     NZ            ; return if char avail
  80.     call    tstdcd    ;carrier?
  81.     ret    z    ;no - return
  82.     LD    B,0            ; modem channel
  83.     LD    E,0            ; request status
  84.     CALL    SERIAL##        ; test modem status
  85.     OR    A            ; set flags
  86.     RET    
  87. ;
  88. CONS10:    XOR    A            ; zero a
  89.     RET                ; always return error code
  90.  
  91. ;
  92. CONS9:    CALL    DMS##                 ; begin lolite
  93.     DB    10,13,80H,0,0,0,0,0,0,0,0,0,0
  94.     RET
  95. ;
  96. CONS8:    CALL    DMS##                 ; end lolite
  97.     DB    10,13,80H,0,0,0,0,0,0,0,0,0,0
  98.     RET
  99. ;
  100. ; console and possible modem character output
  101. ;
  102. CONS2:    
  103.     CALL     TSTDCD            ; test for dcd4 - 0 if false  
  104.     JP    Z,SERIAL##        ; if not, enter serial routine
  105.     PUSH    BC            ; save channel number
  106.     PUSH    DE            ; save function number
  107.     LD    B,0            ; modem channel number
  108.     LD    E,2            ; send character to modem
  109.     CALL    SERIAL##
  110.      POP    DE            ; restore function number
  111.     POP    BC            ; restore channel number
  112.     JP    SERIAL##        ; output char to console
  113. ;
  114. ; console or possible modem character input 
  115. ;
  116. CONS1:    
  117.     CALL     TSTDCD            ; test for dcd4 - 0 if false  
  118.      JP    Z,SERIAL##        ; if not, enter serial routine
  119. ;
  120. DSPACH:    LD    B,1            ; console channel number
  121.     LD    E,0            ; test for character avail
  122.     CALL    SERIAL##        ; -1 = true, 0 = false
  123.     OR    A            ; set flags 
  124.     JR    NZ,CONSOLE        ; if char avail, get from console
  125.                     ; test modem for char
  126.     LD    B,0                ; modem channel number
  127.     LD    E,0            ; test for character avail
  128.     CALL    SERIAL##        ; -1 = true, 0 = false
  129.     OR    A            ; set flags 
  130.     JR    NZ,MODEM        ; if char avail, get from modem
  131.     ld    c,2
  132.     ld    de,0
  133.     call    xtntry##        ; courtesy dispatch
  134.     JR    DSPACH            ; loop till char available
  135. ;
  136. MODEM:    LD    B,0            ; load modem channel number
  137.     LD    E,1            ; get character 
  138.     xor    a
  139.     dec    a
  140.     ld    (tomc),a
  141.     CALL    SERIAL##        ; return to os
  142.     and    7fh
  143.     ld    (tomc),a
  144.     ret
  145. ;                
  146. CONSOLE:LD    B,1            ; load console channel number    
  147.     LD    E,1            ; get character 
  148.     JP    SERIAL##        ; return to os
  149. ;    
  150. ; test for data carrier detect
  151. TSTDCD:    ld    a,(remoff##)
  152.     or    a
  153.     ret    z
  154.     PUSH    BC            ; save channel number
  155.     PUSH    DE            ; save function number
  156.     LD    B,0            ; modem channel number
  157.     LD    E,6            ; request modem status
  158.     CALL    SERIAL##
  159.      POP    DE            ; restore function number
  160.     POP    BC            ; restore channel number
  161. ;    xor    20h        ; only for ICM's SPDCPS module!
  162.     AND    20H            ; set a to zero if no dcd
  163.     ret
  164. ;
  165. ; this routine called from SPICPS at every carrier transition.
  166. ; when carrier goes away, wait 3 seconds for carrier to return.
  167. ; If carrier not back within 3 secs, then crash to reboot.
  168. ; non-ICM systems must emulate this call!
  169. ;
  170. s0dcde::
  171.     or    a            ; carrier loss?
  172.     ret    nz
  173.     ld    a,(remoff##)
  174.     or    a
  175.     ret    z
  176.     di
  177.     halt
  178. ;
  179.     END                ; end of dualio.mac
  180.  
  181. 0            ; load modem channel number
  182.     LD    E,1            ; get character 
  183.     xor    a
  184.     dec    a
  185.     ld    (tomc),a