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 / B5EQ-2.INS < prev    next >
Text File  |  2000-06-30  |  8KB  |  346 lines

  1. ; B5EQ-2.ASM - Insight Enterprises EQ-4 insert to BYE5 - 09/13/85
  2. ;
  3. ;        Z80 DART and 8116 baud rate generator
  4. ;
  5. ; This insert adapts BYE5 to the Insight Enterprises EQ-4 computer.
  6. , USING    THE Z80    DART AND SMC 8116 BAUD RATE GENERATOR.
  7. ;
  8. ;
  9. ;         Note:  This is an insert, not an overlay
  10. ;
  11. ;=   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  12. ;
  13. ; 09/13/85 - Corrected typos and masked interrupts during MDINIT
  14. ;                        - Chris Taylor
  15. ; 09/07/85 - First version of this file     - Chris Taylor
  16. ;
  17. ;=   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  18. ;
  19. ; Change the following information to match your equipment
  20. ;
  21. PORT    EQU    38H        ; Port modem is on
  22. BRPORT    EQU    37H        ; Baud rate generator port
  23. MDCTL1    EQU    PORT+1        ; Modem control port
  24. MDDATP    EQU    PORT        ; Modem data in port
  25. ;
  26. CON96    EQU    14*16        ; Console baudrate is 9600
  27. A300    EQU    5        ; Modem (DART Pair 'A') 300 baud
  28. A1200    EQU    7        ; 1200 bps
  29. A2400    EQU    10        ; 2400 bps
  30. ;
  31. ;
  32. ;-----------------------------------------------------------------------
  33. ;
  34. ;
  35. ; Check for carrier.  If not, return with zero flag set
  36. ;
  37. MDCARCK:MVI    A,10H        ; RESET status
  38.     OUT    MDCTL1
  39.     IN    MDCTL1        ; Get status
  40.     ANI    8        ; Check for carrier
  41.     RET
  42. ;.....
  43. ;
  44. ;
  45. ; Disconnect and wait for an incoming call
  46. ;
  47. MDINIT:    DI            ; Allow no interrupts during setup
  48.     MVI    A,0        ; Setup to write register 0
  49.     OUT    MDCTL1
  50.     MVI    A,18H        ; Channel reset
  51.     OUT    MDCTL1
  52.     CALL    NODTRX        ; Set 8bit, no parity and no DTR
  53.     MVI    A,1        ; Set for WR1
  54.     OUT    MDCTL1
  55.     XRA    A        ; Allow no interrupts from this DART
  56.     OUT    MDCTL1
  57.     EI            ; CONTINUE
  58.     PUSH    B
  59.     MVI    B,20        ; 2 second delay to drop any carrier
  60. ;
  61. OFFTI:    CALL    DELAY
  62.     DCR    B
  63.     JNZ    OFFTI        ; Loop until 2 seconds have elapsed
  64.     POP    B        ; Restore 'BC' pair
  65.     MVI    A,5        ; Write register 5
  66.     OUT    MDCTL1
  67.     MVI    A,0EAH        ; Turn DTR back on
  68.     OUT    MDCTL1
  69. ;
  70.      IF    IMODEM        ; If using intelligent modem
  71.     CALL    IMINIT
  72.      ENDIF
  73. ;
  74.     RET
  75. ;.....
  76. ;
  77. ;
  78. ; Input a character from the modem
  79. ;
  80. MDINP:    IN    PORT        ; Get a character
  81.     RET
  82. ;.....
  83. ;
  84. ;
  85. MDINST:    IN    MDCTL1        ; In modem control port
  86.     ANI    1        ; Character waiting
  87.     RZ            ; Return if none
  88.     ORI    0FFH        ; Otherwise set the proper flag
  89.     RET
  90. ;.....
  91. ;
  92. ;
  93. ; Send a character to the modem
  94. ;
  95. MDOUTP:    OUT    PORT
  96.     RET
  97. ;.....
  98. ;
  99. ;
  100. ; See if output is ready for next character
  101. ;
  102. MDOUTST:IN    MDCTL1        ; Get status
  103.     ANI    4        ; Ready?
  104.     RET
  105. ;.....
  106. ;
  107. ;
  108. ; Re-initialize modem and hang up the phone
  109. ;
  110. MDQUIT:     IF    IMODEM
  111.     CALL    IMQUIT
  112.      ENDIF
  113. ;
  114. ;
  115. ; Called by BYE main to turn off DTR
  116. ;
  117. MDSTOP:    MVI    A,5        ; Write register 5
  118.     OUT    MDCTL1
  119.     MVI    A,0        ; Turn off DTR
  120.     OUT    MDCTL1
  121.     RET
  122. ;.....
  123. ;
  124. ;
  125. ; This routine returns a 255 because we are unable to support the
  126. ; requested baud rate on this hardware.
  127. ;
  128. SETINV:    ORI    0FFH
  129.     RET
  130. ;.....
  131. ;
  132. ;
  133. SET300:    MVI    A,(CON96+A300)
  134.     JMP    SETBAUD
  135. ;
  136. SET1200:MVI    A,(CON96+A1200)
  137.     JMP    SETBAUD
  138. ;
  139. SET2400:MVI    A,(CON96+A2400)
  140. ;
  141. SETBAUD:OUT    BRPORT        ; Set requested baud rate
  142.     XRA    A        ; Say baud rate is OK
  143.     RET
  144. ;.....
  145. ;
  146. ;
  147. NODTRX:    LXI    H,DO8NOP
  148.     CALL    BLOCK$OUTPUT
  149.     RET
  150. ;.....
  151. ;
  152. ;
  153. ; HL points to block to output
  154. ;
  155. BLOCK$OUTPUT:
  156.     MVI    B,6        ; Get count
  157.     MVI    C,MDCTL1    ; Get port
  158.     DB    0EDH,0B3H    ; THIS IS THE Z80 OUTIR INSTRUCTION
  159.     RET            ; Return
  160. ;.....
  161. ;
  162. ;
  163. DO8NOP:    DB    3,0C1H        ; 8bit, recv enable
  164.     DB    4,44H        ; X16, 1 stop, no parity
  165.     DB    5,0        ; Turn DTR off
  166. ;.....
  167. ;
  168. ;
  169. ; Perform system and hardware dependent PRE-processing.  This routine is
  170. ; executed by the PATCH subroutine before the BIOS jump table is over-
  171. ; written, allowing BIOS intercept to operate as close to the initial
  172. ; signon display.
  173. ;
  174. MDPREP:    LXI    H,JTBLNEW    ; Get replacement table address
  175.     LXI    D,NEWJTBL    ; Address to overwrite
  176.     LXI    B,JTBLEN    ; Number of bytes to overwrite
  177.     DB    0EDH,0B0H    ; THIS IS THE Z80 LDIR INSTRUCTION
  178. ;
  179. ;
  180. ; Move the BIOS intercept routines into common memory
  181. ;
  182.     LXI    H,STCOMN    ; Start of interface routines
  183.     LXI    D,COMMN        ; Where in high memory to load
  184.     LXI    B,COMLEN    ; Length of common code
  185.     DB    0EDH,0B0H    ; THIS IS THE Z80 LDIR INSTRUCTION
  186. ;
  187. ;
  188. ; Get the BDOS base page and complete the SXBIOS replacement stack ad-
  189. ; dress.  We are using the BDOS copyright notice as a stack since BDOS
  190. ; is in common and the copyright notice is sufficient length for a stack.
  191. ;
  192.     LDA    BDOSBASE
  193.     STA    SXBIOS+1    ; Finish up the replacement stack adrs
  194.     RET
  195. ;.....
  196. ;
  197. ;
  198. ; SYSTEM/HARDWARE DEPENDENT POST-PROCESSING ROUTINE
  199. ;
  200. ; This routine is executed by the EXCPM routine before returning control
  201. ; to CP/M Plus when BYE5 terminates.
  202. ;
  203. MDPOSP:    RET
  204. ;.....
  205. ;
  206. ;
  207. ; The EQ4 operates in a banked environment.  BIOS calls may originate in
  208. ; any bank (0,1,2,or 3).  It is possible for bank 1 (where BYE resides)
  209. ; to be out of context (not selected) when a BIOS call is made.  Steps
  210. ; must be taken to be sure the BIOS jump table does NOT direct a BIOS
  211. ; call into bank 1 unless bank 1 is in context.  The following code will
  212. ; be moved into common memory where it is free to intercept BIOS calls
  213. ; from any bank.
  214. ;
  215. ; This code does the following:
  216. ;
  217. ;    - Save the caller's stack pointer
  218. ;    - Save the callers bank pointer
  219. ;    - Switch to bank 1
  220. ;    - Execute the BYE interface routine
  221. ;    - Execute the original BIOS routine as needed
  222. ;    - Recover caller's stack pointer
  223. ;    - Reset the memory bank to that of the caller
  224. ;    - Return control to the caller
  225. ;
  226. ;
  227. ;    The BDOS Copyright notice is used for the BIOS replacement stack.
  228. ;
  229. ;-----------------------------------------------------------------------
  230. ;
  231. ; NOTE: These addresses apply for EQ-4CBIOS rev 20A 8/30/83 ONLY
  232. ;
  233. @CBNK    EQU    0F8C7H        ; Address of current bank byte
  234. BNKSEL    EQU    0F7FEH        ; Entry point of BIOS bank select
  235. COMMN    EQU    0FF40H        ; Spare memory goes to 0FFFFH
  236. ;.....
  237. ;
  238. ;
  239. BANK1    EQU    1        ; Bank 1 mask
  240. ;
  241. STCOMN    EQU    $
  242. ;
  243. WBCOMN    EQU    COMMN+($-STCOMN) ; Warm boot
  244.     CALL    SWIN
  245.     JMP    MBOOT
  246. ;
  247. CSCOMN    EQU    COMMN+($-STCOMN) ; Console status
  248.     CALL    SWIN
  249.     CALL    MSTAT
  250.     JMP    SWOUT
  251. ;
  252. CICOMN    EQU    COMMN+($-STCOMN) ; Console input
  253.     CALL    SWIN
  254.     CALL    MINPUT
  255.     JMP    SWOUT
  256. ;
  257. COCOMN    EQU    COMMN+($-STCOMN) ; Console output
  258.     CALL    SWIN
  259.     CALL    MOUTPUT
  260.     JMP    SWOUT
  261. ;
  262. SWIN    EQU    COMMN+($-STCOMN) ; Bank switch in routine
  263.     POP    H        ; Get return address
  264.     DB    0EDH,073H
  265.     DW    SXSAVE
  266.     DB    0EDH,07BH
  267.     DW    SXBIOS
  268.     LDA    @CBNK        ; Get current bank from system
  269.     STA    RTBNK        ; Remember for switch back
  270.     MVI    A,1        ; Gonna switch to bank 1
  271.     CALL    BNKSEL        ; Do it
  272.     PUSH    H        ; Put return address on new stack
  273.     RET
  274. ;.....
  275. ;
  276. ;
  277. SWOUT    EQU    COMMN+($-STCOMN) ; Bank switch out routine
  278.     MOV    H,A        ; Save a reg (for console input call)
  279.     DB    0EDH,07BH
  280.     DW    SXSAVE
  281.     LDA    RTBNK        ; Return to the bank
  282.     CALL    BNKSEL
  283.     MOV    A,H        ; Restore a reg
  284.     RET
  285. ;.....
  286. ;
  287. ;
  288. SXSAVE    EQU    COMMN+($-STCOMN)
  289.     DS    2        ; Save area for caller's stack pointer
  290. ;
  291. SXBIOS    EQU    COMMN+($-STCOMN)
  292.     DW    0085H        ; End of copyright notice is bdos+85h
  293. ;
  294. RTBNK    EQU    COMMN+($-STCOMN)
  295.     DS    1
  296. ;
  297. COMLEN    EQU    $-STCOMN    ; Length of common memory interface code
  298. ;.....
  299. ;
  300. ;
  301. JTBLNEW:JMP    MCBOOT        ; Cold boot
  302.     JMP    WBCOMN        ; Warm boot
  303.     JMP    CSCOMN        ; Modem status test
  304.     JMP    CICOMN        ; Modem input routine
  305.     JMP    COCOMN        ; Modem  output routine
  306. ;
  307.      IF    NOT HARDLOG
  308.     JMP    COCOMN        ; Modem list device
  309.     JMP    COCOMN        ; Modem punch device
  310.     JMP    CICOMN        ; Modem reader device
  311.      ENDIF            ; Not hardlog
  312. ;
  313. JTBLEN    EQU    $-JTBLNEW
  314. ;.....
  315. ;
  316. ;
  317. ;-----------------------------------------------------------------------
  318. ;
  319. ; Here is some nice-to-know stuff for selecting the baud rate value for
  320. ; CON96, A300, A1200, and A2400
  321. ;
  322. ; DART pair    A / B
  323. ;
  324. ;SPEED$T
  325. ;    DB    0,0*16        ; 50 baud
  326. ;    DB    1,1*16        ; 75 baud
  327. ;    DB    2,2*16        ; 110 baud
  328. ;    DB    3,3*16        ; 134 baud
  329. ;    DB    4,4*16        ; 150 baud
  330. ;    DB    5,5*16        ; 300 baud
  331. ;    DB    6,6*16        ; 600 baud
  332. ;    DB    7,7*16        ; 1200 bps
  333. ;    DB    8,8*16        ; 1800 baud
  334. ;    DB    9,9*16        ; 2000 bps ( not supported )
  335. ;    DB    10,10*16    ; 2400 bps
  336. ;    DB    11,11*16    ; 3600 bps
  337. ;    DB    12,12*16    ; 4800 bps
  338. ;    DB    13,13*16    ; 7200 bps
  339. ;    DB    14,14*16    ; 9600 bps
  340. ;    DB    15,15*16    ; 19200 bps
  341. ;.....
  342. ;
  343. ;
  344. ;                   end
  345. ;-----------------------------------------------------------------------
  346.