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 / B5MH-5.IQS / B5MH-5.INS
Text File  |  2000-06-30  |  7KB  |  322 lines

  1. ; B5MH-5.INS - BYE5 insert for Morrow MD5, MD11, MD16, MD34 - 08/26/86
  2. ;
  3. ;        Z80 SIO and 8253 baudrate generator
  4. ;
  5. ;         This is an insert, not an overlay
  6. ;
  7. ; This insert adapts the Morrow computers using hard disk and CP/M+
  8. ; with bank memory to BYE5.
  9. ;
  10. ;
  11. ;=   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  12. ;
  13. ; 08/26/86  Changed SETINV routine.  Added comment of where to reinstall
  14. ;    v5     MDPREP and MDPOSP calls in the main program.
  15. ;                    - George Reding
  16. ;
  17. ; 07/18/86  Removed bank switching code for compatibility with BYE510
  18. ;    v4     or greater.         - Stuart Rose
  19. ;
  20. ; 10/10/85  Reorganized and simplified. - Ed Meyer
  21. ;    v3
  22. ;
  23. ; 08/25/85  Fixed BUG in the Morrow BIOS INTER-BANK routine.
  24. ;    v2                 - Paul Bartholomew
  25. ;
  26. ; 08/17/85  Updated for compatibility with BYE501.
  27. ;    v1                 - George Peace
  28. ;
  29. ;=   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  30. ;
  31. ; To get this to work correctly with a Morrow MD-HD, you must configure
  32. ; your cable in accord with the setting of jumpers inside your computer.
  33. ; Pins 2 and 3 may or may not need to be crossed. Carrier detect (pin 8)
  34. ; from the modem will connect to pin 8 (or pin 4) on the computer, in
  35. ; accord with the setting of the jumpers.
  36. ;
  37. ; ** Consult your MD-## Users Guide, Appendix D, figures D-5 and D-6. **
  38. ;
  39. ;-----------------------------------------------------------------------
  40. ;
  41. ;
  42. ; Set ONE of the following to YES, the other to NO
  43. ;
  44. PMPORT    EQU    NO        ; Yes, using "Printer/Modem" port
  45. AUXPORT    EQU    YES        ; Yes, using "Auxilliary" port
  46. ;
  47. PORT    EQU    060H        ; Port for local console output
  48. CONST    EQU    PORT+1        ; Local console status
  49. ;
  50. ;
  51.      IF    PMPORT
  52. BPORT    EQU    062H
  53. BAUDS    EQU    051H
  54. MODEW    EQU    07EH
  55.      ENDIF            ; PMPORT
  56.  
  57.      IF    AUXPORT
  58. BPORT    EQU    070H
  59. BAUDS    EQU    050H
  60. MODEW    EQU    03EH
  61.      ENDIF            ; AUXPORT
  62. ;
  63. ;
  64. ; The following define the port addresses to use.
  65. ;
  66. DPORT    EQU    BPORT        ; Data port
  67. MDCTL1    EQU    BPORT+1        ; Status/control port
  68. BRPORT    EQU    053H
  69. ;
  70. ;
  71. ; The following are MDCTL1 status masks
  72. ;
  73. MDRCV    EQU    1        ; Data available
  74. MDSND    EQU    4        ; Transmit buffer empty
  75. DCD    EQU    8        ; Data carrier detect
  76. ;
  77. ;-----------------------------------------------------------------------
  78. ;
  79. ;
  80. ; See if we still have a carrier - if not, return with the zero flag set
  81. ;
  82. MDCARCK:MVI    A,10H        ; Reset status
  83.     OUT    MDCTL1
  84.     IN    MDCTL1        ; Get status
  85.     ANI    DCD        ; Check for data carrier
  86.     RET            ; Return
  87. ;.....
  88. ;
  89. ;
  90. ; Disconnect and wait for an incoming call
  91. ;
  92. MDINIT:    MVI    A,18H        ; Reset channel
  93.     OUT    MDCTL1
  94.     MVI    A,4        ; Setup to write register 4
  95.     OUT    MDCTL1
  96.     MVI    A,44H        ; No parity, 1 stop, 16x
  97.     OUT    MDCTL1
  98.     MVI    A,1        ; Setup to write register 1
  99.     OUT    MDCTL1
  100.     MVI    A,0
  101.     OUT    MDCTL1
  102.     MVI    A,5        ; Setup to write register 5
  103.     OUT    MDCTL1
  104.     MVI    A,0        ; DTR, RTS both off
  105.     OUT    MDCTL1
  106.     PUSH    B        ; Save in case it's being used elsewhere
  107.     MVI    B,20        ; 2 second delay
  108. ;
  109. OFFTI:    CALL    DELAY        ; 0.1 second delay
  110.     DCR    B
  111.     JNZ    OFFTI        ; Keep looping until finished
  112.     POP    B        ; Restore bc
  113.     MVI    A,3        ; Setup to write register 3
  114.     OUT    MDCTL1
  115.     MVI    A,0C1H        ; 8 bits, enable receive
  116.     OUT    MDCTL1
  117.     MVI    A,5        ; Setup to write register 5
  118.     OUT    MDCTL1
  119.     MVI    A,0EAH        ; DTR, RTS, TX on, 8 bits
  120.     OUT    MDCTL1
  121.  
  122.      IF    IMODEM        ; If using intelligent modem
  123.     CALL    IMINIT        ; Go initialize modem now
  124.      ENDIF            ; IMODEM
  125. ;
  126.     RET            ; Return
  127. ;.....
  128. ;
  129. ;
  130. ; Input a character from the modem port
  131. ;
  132. MDINP:    IN    DPORT        ; Get character
  133.     RET            ; Return
  134. ;.....
  135. ;
  136. ;
  137. ; Check the status to see if a character is available.    If not, return
  138. ; with the zero flag set.  If yes, use 0FFH to clear the flag.
  139. ;
  140. MDINST:    IN    MDCTL1        ; Get status
  141.     ANI    MDRCV        ; Got a character?
  142.     RZ            ; Return if none
  143.     ORI    0FFH        ; Otherwise, set the proper flag
  144.     RET            ; And return
  145. ;.....
  146. ;
  147. ;
  148. ; Send a character to the modem
  149. ;
  150. MDOUTP:    OUT    DPORT        ; Send it
  151.     RET            ; Return
  152. ;.....
  153. ;
  154. ;
  155. ; See if the output is ready for another character
  156. ;
  157. MDOUTST:IN    MDCTL1
  158.     ANI    MDSND        ; Mask it
  159.     RET            ; Return
  160. ;.....
  161. ;
  162. ;
  163. ; Reinitialize the modem and hang up the phone by dropping DTR and
  164. ; leaving it inactive.
  165. ;
  166. MDQUIT:     IF    IMODEM        ; If using an intelligent modem
  167.     CALL    IMQUIT        ; Tell it to shut down
  168.      ENDIF            ; IMODEM
  169. ;
  170. ;
  171. ; Called by the main program after caller types BYE.
  172. ;
  173. MDSTOP:    MVI    A,5        ; Setup to write register 5
  174.     OUT    MDCTL1
  175.     MVI    A,0        ; Clear DTR, RTS causing shutdown
  176.     OUT    MDCTL1
  177.     RET
  178. ;.....
  179. ;
  180. ;
  181. ; The following routine sets the baudrate.  BYE5 asks for the maximum
  182. ; speed you have available.
  183. ;
  184. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  185.     RET
  186. ;.....
  187. ;
  188. ;
  189. SET300:    LXI    H,BD300
  190.     JMP    SETBAUD
  191. ;
  192. SET1200:LXI    H,BD1200
  193.     JMP    SETBAUD
  194. ;
  195. SET2400:LXI    H,BD2400
  196.     JMP    SETBAUD
  197. ;
  198. SETBAUD:MVI    A,MODEW
  199.     OUT    BRPORT
  200.     MOV    A,L
  201.     OUT    BAUDS
  202.     MOV    A,H
  203.     OUT    BAUDS
  204.     XRA    A        ; Say rate is ok
  205.     RET            ; Return
  206. ;.....
  207. ;
  208. ;
  209. ; The following are baud rates for BPORT -- they will have to be changed
  210. ; for your particular CTC.
  211. ;
  212. BD300    EQU    833
  213. BD1200    EQU    208
  214. BD2400    EQU    104
  215. BD9600    EQU    26
  216. ;.....
  217. ;
  218. ;
  219. ;Find address of INTER-BANK BUG in Morrow's BIOS
  220. ;
  221. FINDBUG:LDA    FNDBUG        ; See if we already found the address
  222.     ORA    A
  223.     JZ    FBUG0        ; No, go find it
  224.     LHLD    BUGADR        ; Yes, return with address
  225.     RET
  226. ;.....
  227. ;
  228. ;
  229. FBUG0:    LHLD    1
  230.     INX    H
  231.     MOV    E,M
  232.     INX    H
  233.     MOV    D,M
  234.     XCHG            ; Hl points to warm boot code
  235. ;
  236. ;
  237. ; The warm boot in common memory is as follows:
  238. ;
  239. ; loc  opcodes    mneumonics
  240. ; ---- -------    --------------------
  241. ; xxxx 21 yyyy    LD    HL,BNK-WBOOT ;WARM BOOT code in SYSTEM bank
  242. ; xxxx 18 zz    JR    INTER-BANK
  243. ;
  244. ; We will find the address of INTER-BANK and modify it to fix the BUG.
  245. ;
  246. ; The INTER-BANK code in COMMON memory is as follows:
  247. ;
  248. ; loc  opcodes    mneumonics
  249. ; ---- -------    --------------------
  250. ; xxxx 3A yyyy    LD    A,(SYSMTE-BANK-BITS)
  251. ; xxxx CB 47    BIT    0,A    ;Should be BIT 1,A (CB 4F)
  252. ;
  253. ;
  254. FBUG1:    MOV    A,M
  255.     CPI    18H        ; Look for JR to INTER-BANK
  256.     JZ    FBUG2
  257.     INX    H
  258.     JMP    FBUG1
  259. ;
  260. FBUG2:    INX    H
  261.     MOV    A,M        ; Get JR offset
  262.     INX    H
  263.     MOV    E,A
  264.     MVI    D,0
  265.     DAD    D        ; HL now points to INTER-BANK
  266. ;
  267. FBUG3:    MOV    A,M
  268.     CPI    0CBH        ; Look for bit opcode
  269.     JZ    FBUG4
  270.     INX    H
  271.     JMP    FBUG3
  272. ;
  273. FBUG4:    INX    H
  274.     SHLD    BUGADR
  275.     MVI    A,0FFH
  276.     STA    FNDBUG
  277.     RET
  278. ;.....
  279. ;
  280. ;
  281. FNDBUG:    DB    0
  282. BUGADR:    DW    0
  283. BUGVAL:    DB    0
  284. ;
  285. ;.....
  286. ;
  287. ; In the main program, CALL to MDPREP and MDPOSP should be at the
  288. ; following locations.    If not present, they may be re-installed.
  289. ; CALL MDPREP should be in the PATCH: routine, before CALL TBLADDR.
  290. ; CALL MDPOSP should be in the EXCPM: routine, before CALL RSXCLR.
  291. ;
  292. ;.....
  293. ;
  294. ; Perform system or hardware dependent PRE-processing.    The following
  295. ; code will be executed by the PATCH subroutine before the BIOS jump
  296. ; table is overwritten.  This will allow the BIOS intercept routines to
  297. ; operate as early as the initial signon message display.
  298. ;
  299. MDPREP:    CALL    FINDBUG        ; Get address of BIOS bug
  300.     MOV    A,M
  301.     STA    BUGVAL        ; Save old value
  302.     MVI    M,04FH        ; Change the bit 0,A to a bit 1,A
  303. ;
  304. ; OK, the BIOS BUG is now fixed.
  305. ;
  306.     RET
  307. ;.....
  308. ;
  309. ;
  310. ; Perform system or hardware dependent POST-processing.  The following
  311. ; code will be executed by the EXCPM routine before returning control to
  312. ; CP/M Plus when the BYE5 program is terminated.
  313. ;
  314. MDPOSP:    CALL    FINDBUG        ; Get address of BIOS bug
  315.     LDA    BUGVAL        ; Get old value
  316.     MOV    M,A        ; Un-fix the BIOS bug (make it a bit 0)
  317.     RET
  318. ;.....
  319. ;
  320. ;                   end
  321. ;-----------------------------------------------------------------------
  322.