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-3.INS < prev    next >
Text File  |  2000-06-30  |  8KB  |  353 lines

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