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 / B5LO-1.IQS / B5LO-1.INS
Text File  |  2000-06-30  |  10KB  |  315 lines

  1.  
  2. ; B5LO-1.INS - BYE5 insert for Lobo MAX-80 with CP/M+ - 08/17/85
  3. ;
  4. ;        Z80 SIO and 8116 baudrate generator
  5. ;
  6. ;
  7. ;          NOTE: This is an insert, not an overlay
  8. ;
  9. ;=   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  10. ;
  11. ; 08/17/85  Updated B+LO-1.INS for BYE5     - James Dunn
  12. ;
  13. ;=   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  14. ;
  15. ;
  16. ;The following define the address to use.
  17. ;
  18. SIODA    EQU    0F7E4H        ; Modem data window
  19. SIOCA    EQU    0F7E5H        ; Modem control window
  20. BAUDA    EQU    0F7D0H        ; Baud rate window
  21. ;
  22. ;
  23. ; The following are baud rates for BAUDA
  24. ;
  25. B300    EQU    05H        ; 300 bps
  26. B1200    EQU    07H        ; 1200 bps
  27. B2400    EQU    0AH        ; 2400 bps
  28. ;
  29. ;
  30. ;-----------------------------------------------------------------------
  31. ;
  32. ; See if there is a carrier.  If not, return with the zero flag set.
  33. ;
  34. MDCARCK:MVI    A,10H        ; Reset status
  35.     STA    SIOCA
  36.     LDA    SIOCA        ; Get status
  37.     ANI    8        ; Check for data carrier
  38.     RET            ; Return
  39. ;.....
  40. ;
  41. ;
  42. ; This routine will turn off the serial card and hang up the phone.
  43. ;
  44. MDINIT:    MVI    A,18H        ; Reset channel
  45.     STA    SIOCA
  46.     MVI    A,4        ; Setup to write register 4
  47.     STA    SIOCA
  48.     MVI    A,44H        ; 16x, 1 stop bit, no parity
  49.     STA    SIOCA
  50.     MVI    A,1        ; Setup to write register 1
  51.     STA    SIOCA
  52.     MVI    A,0        ; Value to write to register 1
  53.     STA    SIOCA
  54.     MVI    A,5        ; Setup to write register 5
  55.     STA    SIOCA
  56.     MVI    A,0        ; DTR off, RTS off
  57.     STA    SIOCA
  58.     PUSH    B        ; Save in case it's being used elsewhere
  59.     MVI    B,20        ; 2 second delay
  60. ;
  61. OFFTI:    CALL    DELAY        ; 0.1 second delay
  62.     DCR    B
  63.     JNZ    OFFTI        ; Keep looping until finished
  64.     POP    B        ; Restore bc
  65.     MVI    A,3        ; Setup to write register 3
  66.     STA    SIOCA
  67.     MVI    A,0C1H        ; 8 bits/char, RX enable
  68.     STA    SIOCA
  69.     MVI    A,5        ; Setup to write register 5
  70.     STA    SIOCA
  71.     MVI    A,0EAH        ; DTR on, 8 bits/char, TX enable, RTS on
  72.     STA    SIOCA
  73. ;
  74.      IF    IMODEM        ; If using a smartmodem
  75.     CALL    IMINIT        ; Go initialize smartmodem now
  76.      ENDIF            ; Imodem
  77. ;
  78.     RET            ; Return
  79. ;.....
  80. ;
  81. ;
  82. ; Input a character
  83. ;
  84. MDINP:    LDA    SIODA        ; Get character
  85.     RET            ; Return
  86. ;.....
  87. ;
  88. ;
  89. ; Check the status to see if a character is available.  Return with zero
  90. ; flag set if not.  If yes, use 0FFH to clear the flag.
  91. ;
  92. MDINST:    LDA    SIOCA        ; Get status
  93.     ANI    1        ; Got a character?
  94.     RZ            ; Return if none
  95.     ORI    0FFH        ; Otherwise, set the proper flag
  96.     RET            ; And return
  97. ;.....
  98. ;
  99. ;
  100. ; Send a character to the modem.
  101. ;
  102. MDOUTP:    STA    SIODA        ; Send it
  103.     RET            ; Return
  104. ;.....
  105. ;
  106. ;
  107. ; See if the outputa is ready for another character.
  108. ;
  109. MDOUTST:LDA    SIOCA
  110.     ANI    4        ; Mask it
  111.     RET            ; Return
  112. ;.....
  113. ;
  114. ;
  115. ; Reintialize the modem and hang up the phone by dropping DTR and
  116. ; leaving it inactive.
  117. ;
  118. MDQUIT:     IF    IMODEM        ; If using a smartmodem
  119.     CALL    IMQUIT        ; Tell it to shut down
  120.      ENDIF            ; Imodem
  121. ;
  122. ;
  123. ; Called by the main program after the caller types BYE
  124. ;
  125. MDSTOP:    MVI    A,5        ; Setup to write register 5
  126.     STA    SIOCA
  127.     MVI    A,0        ; DTR off, RTS off
  128.     STA    SIOCA
  129.     RET
  130. ;.....
  131. ;
  132. ;
  133. ; If you do not support a particular baud rate, put it here before
  134. ; SETINV:
  135. ;
  136. SETINV:    ORI    0FFH        ; Make sure zero flag is not set
  137.     RET            ; Return
  138. ;.....
  139. ;
  140. ;
  141. SET300:    MVI    A,B300        ; Load rate
  142.     JMP    SETBAUD
  143. ;
  144. SET1200:MVI    A,B1200        ; Load rate
  145.     JMP    SETBAUD
  146. ;
  147. SET2400:MVI    A,B2400        ; Load rate
  148.     JMP    SETBAUD
  149. ;
  150. SETBAUD:STA    BAUDA        ; Send first byte of command
  151.     MVI    A,10H        ; Reset ext/status interrupts
  152.     STA    SIOCA
  153.     XRA    A        ; Say rate is ok
  154.     RET            ; Return
  155. ;.....
  156. ;
  157. ;
  158. ;=======================================================================
  159. ;        Lobo MAX-80 CP/M Plus bank control area
  160. ;=======================================================================
  161. ;
  162. ;                        jjd - 14 Jul 85
  163. ; Ok, this is my current understanding of how and why BYE5 needs
  164. ; control over bank switching.    Character I/O goes through the
  165. ; BDOS and through the BIOS to the actual, machine dependent,
  166. ; character I/O routines.  The physical character I/O routines
  167. ; under Plus on the MAX-80 are in common, non-banked memory, around
  168. ; the F2xxH area.  Now, normally, character I/O goes from the
  169. ; user application program (like an RBBS or whatever) running in
  170. ; the TPA in bank 1, to the part of the BDOS in common memory, to
  171. ; the part of the BIOS in common memory.  When BYE is in control,
  172. ; the character I/O is captured as it is sent to the BIOS routines,
  173. ; and sent through the famous local/remote virtual "Y" connector.
  174. ; The BYE "Y" connector sits in the RSX.  This RSX is not used the
  175. ; way DRI intended, where it would filter BDOS calls, but rather, it
  176. ; is used to grab and save some memory for its console trapping code.
  177. ; Now comes the good news for we MAX-80 people.  Lobo decided to
  178. ; give us 32k of common memory.  I'm not sure if that really produces
  179. ; an efficient CP/M Plus machine, but it sure makes RSXing easy as
  180. ; compared to the Osborne Exec or the Morrow machine.  We can leave
  181. ; our BYE "Y" code right in the RSX.  George and Paul had to move
  182. ; their code onto a "safe" area in the common BDOS.
  183. ;
  184. ; So, by now you should be wondering why we MAXers should have to worry
  185. ; about bank switching at all.  Well, here's why.  Way back I said
  186. ; normally I/O from appl prgm via BDOS via BIOS, right, well, some I/O,
  187. ; like CP/M error messages, comes from bank 0, the banked portions of
  188. ; the BDOS and BIOS.  But, that's not the problem, directly.  These I/O
  189. ; calls go through the BIOS jump table at F200 and display ok.
  190. ; The problem is that when I/O originates from bank 0, and BYE
  191. ; gets control at each CONOUT call, it does its normal job of checking
  192. ; the current user/drive values at 00004H and comparing them with
  193. ; the values plugged in at 003DH and 003FH.  Right, you got it, these
  194. ; values are, of course, over in bank 1, not in bank 0.  Then to
  195. ; put the icing on the cake, when a drive or user check fails,
  196. ; BYE sets up to A0: does a JP 0000H to get a warm boot .....
  197. ; and we just went south on that one.
  198. ;
  199. ; So, we realize that even when we do character I/O from any bank, we
  200. ; need bank 1 current to check those magic values in the low page of
  201. ; bank 1, and to allow a warm boot via JP 0000H.  The code runs ok
  202. ; in the common memory, and the stack space is not lost.
  203. ; This is why I didn't bother with adjusting any stack pointers.
  204. ; Another solution which I think should work, would be to grab these
  205. ; magic values in the low page of bank 1, MAXUSER, WHEEL and MAXDRIV,
  206. ; and put them right into the RSX.
  207. ; This would also need the read/write at 0004H to be cancelled, and
  208. ; use only the SCB values.  I think this approach would work on the
  209. ; MAX, and might even work on other machines, if they have enough
  210. ; extra room?, not sure.
  211. ;
  212. ; Possible GOTCHAs ::  Ok, when bank switching, we have to switch
  213. ; back to the bank from hence we came.    When using the bios as
  214. ; supplied from Lobo, this value, named CBNK in the Lobo Source,
  215. ; and in the DRI CP/M 3 System Guide, is at address 0F2A5H.  See
  216. ; it at the end of the file XROOT.MAC as supplied from Lobo.
  217. ; Also, I call BNKSEL directly at F29FH.  Now these will work fine
  218. ; unless you modify any of the BIOS source by adding or removing
  219. ; bunches of code.  These values will change, and you will have to
  220. ; snoop around and find the new values.  If you can handle BIOS
  221. ; modification, you can handle this change.
  222. ;
  223. ; Also, during testing, I got strange results when I turned on the
  224. ; RSPEED equate.  I'm not sure why, so I am leaving it off...
  225. ; I probably wouldn't use it anyway.
  226. ;
  227. ;-----------------------------------------------------------------------
  228. ;
  229. ; Perform system or hardware dependent PRE-processing.
  230. ; The following code will be executed by the PATCH subroutine before the
  231. ; BIOS jump table is overwritten.  This will allow the BIOS intercept
  232. ; routines to operate as early as the initial signon message display.
  233. ;
  234. ;
  235. ; Replace the NEWJTBL BIOS routing table with our own
  236. ;
  237. MDPREP:    LXI    H,JTBLNEW    ; Get replacement table address
  238.     LXI    D,NEWJTBL    ; Get address to overwrite
  239.     LXI    B,JTBLEN    ; Get number of bytes to overwrite
  240.     DB    0EDH,0B0H    ; Z80 ldir instruction
  241.     RET
  242. ;.....
  243. ;
  244. ;
  245. ; Perform system or hardware dependent POST-processing.
  246. ; The following code will be executed by the EXCPM routine before re-
  247. ; turning control to CP/M Plus when the BYE5 program is terminated.
  248. ;
  249. MDPOSP:    RET
  250. ;.....
  251. ;
  252. ;
  253. WBCOMN:    CALL    SWIN        ; Warm boot
  254.     JMP    MBOOT
  255. ;.....
  256. ;
  257. ;
  258. CSCOMN:    CALL    SWIN        ; Console status
  259.     CALL    MSTAT
  260.     JMP    SWOUT
  261. ;.....
  262. ;
  263. ;
  264. CICOMN:    CALL    SWIN        ; Console input
  265.     CALL    MINPUT
  266.     JMP    SWOUT
  267. ;.....
  268. ;
  269. ;
  270. COCOMN:    CALL    SWIN        ; Console output
  271.     CALL    MOUTPUT
  272.     JMP    SWOUT
  273. ;.....
  274. ;
  275. ;
  276. CBNK    EQU    0F2A5H        ; Address of the current bank byte
  277. BNKSEL    EQU    0F29FH        ; Entry point of BIOS bank select
  278. RTBNK    DS    1        ; Place to store bank to return to
  279. ;
  280. SWIN:    PUSH    A        ; Bank switch in routine
  281.     LDA    CBNK        ; Get the bank we are switching from
  282.     STA    RTBNK        ; Store so we know where to switch back
  283.     MVI    A,1        ; We are going to switch to bank 1
  284.     CALL    BNKSEL        ; Switch to bank 1
  285.     POP    A        ; Restore 'A' and flags
  286.     RET
  287. ;.....
  288. ;
  289. ;
  290. SWOUT:    PUSH    A        ; Save 'A' and flags
  291.     LDA    RTBNK        ; Get the bank to return to
  292.     CALL    BNKSEL        ; Return to that bank
  293.     POP    A        ; Restore 'A' and flags
  294.     RET
  295. ;.....
  296. ;
  297. ;
  298. JTBLNEW:JMP    MCBOOT        ; Cold boot
  299.     JMP    WBCOMN        ; Warm boot
  300.     JMP    CSCOMN        ; Modem status test
  301.     JMP    CICOMN        ; Modem input routine
  302.     JMP    COCOMN        ; Modem output routine
  303. ;
  304.      IF    NOT HARDLOG
  305.     JMP    COCOMN        ; Modem list device
  306.     JMP    COCOMN        ; Modem punch device
  307.     JMP    CICOMN        ; Modem reader device
  308.      ENDIF            ; NOT HARDLOG
  309. ;
  310. JTBLEN    EQU    $-JTBLNEW
  311. ;.....
  312. ;
  313. ;                   end
  314. ;-----------------------------------------------------------------------
  315.