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 / IMP / I2BT-4.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  403 lines

  1.  
  2. ; I2BT-4.ASM  -  Beehive TOPPER overlay for IMP  -  06/01/87
  3. ;
  4. ;              Z80 DART and Z80 CTC
  5. ;
  6. ; This overlay file adapts the Beehive Topper computer to IMP.
  7. ;
  8. ; You will want to look this file over carefully. There are a number of
  9. ; options that you can use to configure the program to suit your taste.
  10. ; This file places particular emphasis on using the Beehive TOPPER
  11. ; computer with the Z80 DART main serial port and the Z80 CTC baud rate
  12. ; generator.  Note that in the TOPPER the Z80 CTC conrols the RX speed
  13. ; and the TX speed from different CTC port addresses.  This allows the
  14. ; TOPPER to operate the RX and the TX at different baud rates, in this
  15. ; insert both will be SET at the same baud rate.
  16. ;
  17. ;
  18. ; Edit this file for your preferences then follow the "TO USE:" example
  19. ; shown below.
  20. ;
  21. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  22. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  23. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  24. ; (The ESC will automatically be typed with no CTL-character present.)
  25. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  26. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  27. ; looking at the function key table, typing CTL-Z in command mode, etc.
  28. ;
  29. ; Use the "SET" command to change the baudrate when desired.  The value
  30. ; at MSPEED controls the baudrate when the program is first called up.
  31. ;
  32. ;    TO USE: First edit this file filling in answers for your own
  33. ;        equipment.  Then assemble with ASM.COM or equivalent
  34. ;        assembler.  Then use MLOAD to merge into the main file:
  35. ;
  36. ;        MLOAD IMP.COM=IMP.COM,I2BT-x.HEX
  37. ;
  38. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  39. ;
  40. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  41. ;        IMP245 to use it.            - Irv Hoff
  42. ;
  43. ; 07/21/86  Rewrote the baudrate area        - Irv Hoff
  44. ; 03/09/86  Added support for 19200 baud    - Dennis Recla
  45. ; 11/26/85  Written to work with IMP        - Dennis Recla
  46. ;
  47. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  48. ;
  49. ;
  50. YES    EQU    0FFH
  51. NO    EQU    0
  52. ;
  53. ;
  54. PORT    EQU    098H    ; Your base port (data or status)
  55. MDCTL1    EQU    PORT+2    ; Modem control port
  56. MDDATP    EQU    PORT    ; Modem data port
  57. MDRCV    EQU    01H    ; Modem receive ready
  58. MDSND    EQU    04H    ; Modem send ready bit
  59. MDTXE    EQU    01H    ; Modem send buffer empty, holding buffer empty
  60. ;
  61. BRPRX    EQU    090H    ; Baud rate generator port RX
  62. BRPTX    EQU    091H    ; Baud rate generator port TX
  63. ;
  64. ;
  65. ;-----------------------------------------------------------------------
  66. ;
  67. ESC    EQU    '['-40H    ; ^[ = Escape
  68. BELL    EQU    'G'-40H    ; ^G = Bell character
  69. LF    EQU    'J'-40H    ; ^J = Linefeed
  70. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  71. CR    EQU    'M'-40H    ; ^M = Carriage return
  72. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  73. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  74. ;
  75. ;
  76. ;-----------------------------------------------------------------------
  77. ;
  78. ;
  79.     ORG    0100H
  80. ;
  81. ;
  82.     DS    3    ; Skip the data area below
  83. ;
  84. ;
  85. ; These routines and equates are at the beginning of the program so
  86. ; they can be patched by a monitor or overlay file without re-assembling
  87. ; the program.
  88. ;
  89. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  90.             ; 6=2400 7=4800 8=9600 9=19200 default
  91. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  92. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  93. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  94. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  95. RESVD1:     DB    NO    ; Reserved for special modems            108H
  96. RESVD2:     DB    NO    ; Reserved for special modems            109H
  97. ;
  98. ;
  99. CLEAR:     DB    'E'    ; Clear screen character (ESC not needed)    10AH
  100. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  101.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  102. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  103.             ;   default time to send character in ter-
  104.             ;   minal mode file transfer for slow BBS
  105. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  106.             ;   default time for extra wait after CRLF
  107.             ;   in terminal mode file transfer
  108. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  109. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  110. ;.....
  111. ;
  112. ;
  113. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  114.             ;   mode (normally added by remote echo)
  115. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  116. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  117. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  118. ;.....
  119. ;
  120. ;
  121. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  122. EXITCHR: DB    'E'    ; Exit character                115H
  123. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  124. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  125. LOGCHR:     DB    'L'    ; Send logon                    118H
  126. LSTCHR:     DB    'P'    ; Toggle printer                119H
  127. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  128. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  129. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  130. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  131. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  132. ;.....
  133. ;
  134. ;
  135. ; Handles in/out ports for data and status
  136. ;
  137. I$MDCTL1: MVI    A,10H        ; Register 0, reset interrupts        11FH
  138.       OUT    MDCTL1        ;                    121H
  139.       IN    MDCTL1        ; Get the status            123H
  140.       RET            ;                    125H
  141.       DB    0,0,0        ; Spares if needed            126H
  142. ;
  143. I$MDTXE:  MVI    A,11H        ; For read register 1            129H
  144.       OUT    MDCTL1        ;                    12BH
  145.       IN    MDCTL1        ; Get status of read register 1     12DH
  146.       RET            ;                    12FH
  147.       DB    0,0,0        ;                    130H
  148. ;
  149. I$MDDATP: IN    MDDATP        ;                    133H
  150.       RET            ;                    135H
  151.       DB    0,0,0,0,0,0,0    ; Spares if needed            136H
  152. ;
  153. O$MDDATP: OUT    MDDATP        ;                    13DH
  154.       RET            ; OUT modem data port            13FH
  155.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  156. ;.....
  157. ;
  158. ;
  159. A$MDRCV:  ANI    MDRCV        ;                    147H
  160.       RET            ;                    149H
  161. ;
  162. C$MDRCV:  CPI    MDRCV        ;                    14AH
  163.       RET            ;                    14CH
  164. ;
  165. A$MDSND:  ANI    MDSND        ;                    14DH
  166.       RET            ;                    14FH
  167. ;
  168. C$MDSND:  CPI    MDSND        ;                    150H
  169.       RET            ;                    152H
  170. ;
  171. A$MDTXE:  ANI    MDTXE        ;                    153H
  172.       RET            ;                    155H
  173. ;
  174. C$MDTXE:  CPI    MDTXE        ;                    156H
  175.       RET            ;                    158H
  176. ;.....
  177. ;
  178. ;
  179. ; Special exit vector, used by some computers to reset interrupt vectors
  180. ;
  181. J$EXITVEC:RET            ;                    159H
  182.       DB    0,0        ;                    15AH
  183. ;.....
  184. ;
  185. ;
  186. ; Jump vectors needed by each overlay
  187. ;
  188. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  189. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  190. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  191. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  192. ;.....
  193. ;
  194. ;
  195. ; "AT" command strings, can be replaced in individual overlay if needed
  196. ;
  197. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  198. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  199. ;
  200. ;
  201. ; Next fourteen lines should not be changed by user overlay as these go
  202. ; to specific locations in the main program, not in the overlay.
  203. ;
  204. ;
  205. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  206. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  207. J$DIAL:      DS    3        ; Start of dialing routine        174H
  208. J$DSCONT: DS    3        ; Terminates modem use            177H
  209. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  210. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  211. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  212. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  213. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  214. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  215. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  216. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  217. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  218. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  219. J$NEW2:      DB    0,0,0        ; For future needs            198H
  220. ;.....
  221. ;
  222. ;
  223. ; For 2400 bps auto-stepdown units
  224. ;
  225. MANUAL:      DB    0        ; For manual selection flag        19BH
  226. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  227. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  228. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  229. ;.....
  230. ;
  231. ;
  232. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  233. ;
  234. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  235.       DB    'Version for Beehive TOPPER computers' ;        1AAH
  236.       DB    CR,LF,0
  237.       RET
  238. ;.....
  239. ;
  240. ;
  241. ;-----------------------------------------------------------------------
  242. ;
  243. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  244. ;     end of your last routine should terminate by 0400H (601 bytes
  245. ;     available after start of SYSVER).
  246. ;
  247. ;-----------------------------------------------------------------------
  248. ;
  249. ; You can put in a message at this location which can be called up with
  250. ; (special character-L).  You can put in several lines.  End with a 0.
  251. ;
  252. LOGON:    DB    'This is a Beehive TOPPER computer... ',CR,LF,0
  253. ;
  254. ;-----------------------------------------------------------------------
  255. ;
  256. ; This routine sets a 300 ms break tone
  257. ;
  258. SENDBRK:
  259.     MVI    A,5
  260.     OUT    MDCTL1        ; Send to the status port
  261.     MVI    A,0F8H        ; DTR normal, send break tone
  262.     JMP    GOODBYE1    ; Go send the break tone
  263. ;.....
  264. ;
  265. ;
  266. ; This routine sets DTR low for 300 ms to disconnect the modem.
  267. ;
  268. GOODBYE:
  269.     MVI    A,5
  270.     OUT    MDCTL1        ; Send to the status port
  271.     MVI    A,78H        ; Turn off DTR and send break tone
  272. ;
  273. GOODBYE1:
  274.     OUT    MDCTL1
  275.     MVI    B,3        ; Delay 300 ms
  276.     CALL    J$TIMER
  277.     MVI    A,5
  278.     OUT    MDCTL1
  279.     MVI    A,0E8H        ; Restore normal, 8 bits, DTR on, etc.
  280.     OUT    MDCTL1
  281.     RET
  282. ;.....
  283. ;
  284. ;
  285. ; Topper initialization -- sets CTC timer 00H for send and receive
  286. ; baudrate.
  287. ;
  288. ;
  289. INITMOD:
  290.     MVI    A,00H        ; Select register
  291.     OUT    MDCTL1
  292.     MVI    A,18H        ; Throw out of mode
  293.     OUT    MDCTL1
  294.     MVI    A,01H        ; Select register 1
  295.     OUT    MDCTL1
  296.     MVI    A,00H        ; Clear all interupts
  297.     OUT    MDCTL1
  298.     MVI    A,04H        ; Select register
  299.     OUT    MDCTL1
  300.     MVI    A,44H        ; Set ASCII parameters X16 clock
  301.     OUT    MDCTL1
  302.     MVI    A,03H        ; Select register
  303.     OUT    MDCTL1
  304.     MVI    A,0C1H        ; Enable receive
  305.     OUT    MDCTL1
  306.     MVI    A,05H        ; Select register
  307.     OUT    MDCTL1
  308.     MVI    A,0EAH        ; Enable send, DTR, RTS
  309.     OUT    MDCTL1
  310. ;
  311.     LDA    MSPEED        ; Get the selected value
  312.     CPI    1        ; 300 bps
  313.     JZ    OK300
  314.     CPI    5        ; 1200 bps
  315.     JZ    OK1200
  316.     CPI    6        ; 2400 bps
  317.     JZ    OK2400
  318.     CPI    8        ; 9600 bps
  319.     JZ    OK9600
  320.     CPI    9        ; 19200 bps
  321.     JZ    OK19200
  322.     JMP    STUPR1        ; Else ask what is wanted
  323. ;.....
  324. ;
  325. ;
  326. ; Sets the modem speed via the SET command.
  327. ;
  328. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  329.     JNC    STUPR2
  330. ;
  331. STUPR1:    CALL    J$ILPRT
  332.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  333.     LXI    D,BAUDBUF    ; Point to new input buffer
  334.     CALL    J$INBUF
  335.     CALL    J$CRLF
  336.     LXI    D,BAUDBUF+2
  337. ;
  338. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  339.     DB    '300',0
  340.     JNC    OK300        ; Go if got match
  341.     CALL    J$INLNCP
  342.     DB    '1200',0
  343.     JNC    OK1200
  344.     CALL    J$INLNCP
  345.     DB    '2400',0
  346.     JNC    OK2400
  347.     CALL    J$INLNCP
  348.     DB    '9600',0
  349.     JNC    OK9600
  350.     CALL    J$ILPRT        ; All matches failed, tell operator
  351.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  352.     JMP    STUPR1        ; Try again
  353. ;
  354. OK300:    MVI    A,1        ; MSPEED 300 baud value
  355.     LXI    H,BD300        ; Get 300 bps parameters in 'HL'
  356.     JMP    LOADBD        ; Go load them
  357. ;
  358. OK1200:    MVI    A,5
  359.     LXI    H,BD1200
  360.     JMP    LOADBD
  361. ;
  362. OK2400:    XRA    A
  363.     STA    MANUAL        ; Reset to maximum auto-speed
  364.     MVI    A,6
  365.     LXI    H,BD2400
  366.     JMP    LOADBD
  367. ;
  368. OK9600:    MVI    A,8
  369.     LXI    H,BD9600
  370.     JMP    LOADBD
  371. ;
  372. OK19200:MVI    A,9
  373.     LXI    H,BD19200
  374. ;
  375. LOADBD:    STA    MSPEED        ; Change time-to-send to match baud rate
  376.     MOV    A,H        ; Command word
  377.     OUT    BRPTX        ; Output to TX CTC port
  378.     OUT    BRPRX        ; Output to RX CTC port
  379.     MOV    A,L        ; Baudrate
  380.     OUT    BRPTX        ; Output to TX CTC port
  381.     OUT    BRPRX        ; Output to RX CTC port
  382.     RET
  383. ;.....
  384. ;
  385. ;
  386. ; Table of baud rate parameters
  387. ;
  388. BD300    EQU    0720H        ; 9600/300 (first half is CTC command)
  389. BD1200    EQU    4740H        ; 76800/1200
  390. BD2400    EQU    4720H        ; 76800/2400
  391. BD9600    EQU    4708H        ; 76800/9600
  392. BD19200    EQU    4704H        ; 76800/19200
  393. ;
  394. BAUDBUF:DB    10,0,0,0,0,0
  395.     DB    0,0,0,0,0,0
  396. ;
  397. ;                   end
  398. ;-----------------------------------------------------------------------
  399. ;
  400. ; NOTE: Must terminate prior to 0400H
  401. ;
  402.     END
  403.