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 / I2DA-2.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  414 lines

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