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 / I2VI-2.AZM / I2VI-2.ASM
Assembly Source File  |  2000-06-30  |  14KB  |  500 lines

  1.  
  2. ; I2VI-2.ASM  -  Visual 1050 computer overlay for IMP  -  06/01/87
  3. ;
  4. ;             8251A I/O and ?? baudrate generator
  5. ;
  6. ; You will want to look this file over carefully. There are a number of
  7. ; options that you can use to configure the program to suit your taste.
  8. ; This file adapts the Visual 1050 computer to IMP.COM.
  9. ;
  10. ; Edit this file for your preferences then follow the "TO USE:" example
  11. ; shown below.
  12. ;
  13. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  14. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  15. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  16. ; (The ESC will automatically be typed with no CTL-character present.)
  17. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  18. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  19. ; looking at the function key table, typing CTL-Z in command mode, etc.
  20. ;
  21. ; Use the "SET" command to change the baudrate when desired.  The value
  22. ; at MSPEED controls the baudrate when the program is first called up.
  23. ;
  24. ;    TO USE: First edit this file filling in answers for your own
  25. ;        equipment.  Then assemble with ASM.COM or equivalent
  26. ;        assembler.  Then use MLOAD to merge into the main file:
  27. ;
  28. ;        MLOAD IMP.COM=IMP.COM,I2VI-x.HEX
  29. ;
  30. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  31. ;
  32. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  33. ;        IMP245 to use it.        - Irv Hoff
  34. ;
  35. ; 06/05/86  Written to work with IMP    - Irv Hoff
  36. ;
  37. ; 11/06/85  Use BDOS calls for interrupt-driven modem I/O to eliminate
  38. ;        need for nulls after CR in terinal mode at faster speeds.
  39. ;                    - Charlie Fenton
  40. ;
  41. ; 03/10/85 - Combined M7KP-2 and M7SY-3 for visual 1050.
  42. ;                    - Jim Offenbecher
  43. ;
  44. ;
  45. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  46. ;
  47. ;
  48. YES    EQU    0FFH
  49. NO    EQU    0
  50. ;
  51. ;
  52. ; Values shown are for a 8251A
  53. ;
  54. PORT    EQU    08CH    ; Your base port (data or status)
  55. MDCTL1    EQU    PORT+1    ; Modem control port
  56. MDDATP    EQU    PORT    ; Modem data port
  57. MDRCV    EQU    02H    ; Modem receive ready
  58. MDSND    EQU    01H    ; Modem send ready bit
  59. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  60. ;
  61. BRPORT    EQU    92H    ; Port for setting baud rate
  62. ;
  63. ;
  64. MDMODE    EQU    82H    ; Insures 8251A is out of mode with DTR high
  65. MDRSET    EQU    42H    ; Resets USART for additional commands
  66. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, x16
  67. MDSET2    EQU    0CEH    ; 2 stop bits, no parity, 8 bits, x16
  68. MDCOM    EQU    37H    ; Reset error flags, RCV, DTR, TX ready
  69. ;
  70. ;
  71. ;-----------------------------------------------------------------------
  72. ;
  73. ESC    EQU    '['-40H    ; ^[ = Escape
  74. BELL    EQU    'G'-40H    ; ^G = Bell character
  75. LF    EQU    'J'-40H    ; ^J = Linefeed
  76. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  77. CR    EQU    'M'-40H    ; ^M = Carriage return
  78. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  79. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  80. ;
  81. ;
  82. ;-----------------------------------------------------------------------
  83. ;
  84. ;
  85.     ORG    0100H
  86. ;
  87. ;
  88.     DS    3        ; Skip the data area below
  89. ;
  90. ;
  91. ; These routines and equates are at the beginning of the program so
  92. ; they can be patched by a monitor or overlay file without re-assembling
  93. ; the program.
  94. ;
  95. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  96.             ; 6=2400 7=4800 8=9600 9=19200 default
  97. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  98. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  99. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  100. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  101. RESVD1:     DB    NO    ; Reserved for special modems            108H
  102. RESVD2:     DB    NO    ; Reserved for special modems            109H
  103. ;
  104. ;
  105. CLEAR:     DB    1AH    ; Clear screen character (ESC not needed)    10AH
  106. CLOCK:     DB    37    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  107.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  108. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  109.             ;   default time to send character in ter-
  110.             ;   minal mode file transfer for slow BBS
  111. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  112.             ;   default time for extra wait after CRLF
  113.             ;   in terminal mode file transfer
  114. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  115. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  116. ;.....
  117. ;
  118. ;
  119. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  120.             ;   mode (normally added by remote echo)
  121. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  122. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  123. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  124. ;.....
  125. ;
  126. ;
  127. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  128. EXITCHR: DB    'E'    ; Exit character                115H
  129. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  130. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  131. LOGCHR:     DB    'L'    ; Send logon                    118H
  132. LSTCHR:     DB    'P'    ; Toggle printer                119H
  133. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  134. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  135. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  136. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  137. NODTR:     DB    NO    ; Yes if no DTR and need ATH0 to disconnect    11EH
  138. ;.....
  139. ;
  140. ;
  141. ; Handles in/out ports for data and status
  142. ;
  143. I$MDCTL1: IN    MDCTL1        ;                    11FH
  144.       RET            ; Spares if needed            121H
  145.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  146. ;
  147. I$MDTXE:  IN    MDCTL1        ; (Needed for SIO or DART register 1    129H
  148.       RET            ;                    12BH
  149.       DB    0,0,0,0,0,0,0    ;                    12CH
  150. ;
  151. I$MDDATP: JMP    BDOS3        ;                    133H
  152.       DB    0,0,0,0        ;                    136H
  153.       DB    0,0,0        ;                    13AH
  154. ;
  155. O$MDDATP: JMP    BDOS4        ;                    13DH
  156.       DB    0,0,0,0        ; OUT modem data port            140H
  157.       DB    0,0,0        ; Spares if needed            144H
  158. ;.....
  159. ;
  160. ;
  161. A$MDRCV:  ANI    MDRCV        ;                    147H
  162.       RET            ;                    149H
  163. ;
  164. C$MDRCV:  CPI    MDRCV        ;                    14AH
  165.       RET            ;                    14CH
  166. ;
  167. A$MDSND:  ANI    MDSND        ;                    14DH
  168.       RET            ;                    14FH
  169. ;
  170. C$MDSND:  CPI    MDSND        ;                    150H
  171.       RET            ;                    152H
  172. ;
  173. A$MDTXE:  ANI    MDTXE        ;                    153H
  174.       RET            ;                    155H
  175. ;
  176. C$MDTXE:  CPI    MDTXE        ;                    156H
  177.       RET            ;                    158H
  178. ;.....
  179. ;
  180. ;
  181. ; Special exit vector, used by some computers to reset interrupt vectors
  182. ;
  183. J$EXITVEC:RET            ;                    159H
  184.       DB    0,0        ;                    15AH
  185. ;.....
  186. ;
  187. ;
  188. ; Jump vectors needed by each overlay
  189. ;
  190. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  191. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  192. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  193. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  194. ;.....
  195. ;
  196. ;
  197. ; "AT" command strings, can be replaced in individual overlay if needed
  198. ;
  199. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  200. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  201. ;
  202. ;
  203. ; Next fourteen lines should not be changed by user overlay as these go
  204. ; to specific locations in the main program, not in the overlay.
  205. ;
  206. ;
  207. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  208. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  209. J$DIAL:      DS    3        ; Start of dialing routine        174H
  210. J$DSCONT: DS    3        ; Terminates modem use            177H
  211. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  212. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  213. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  214. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  215. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  216. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  217. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  218. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  219. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  220. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  221. J$NEW2:      DB    0,0,0        ; For future needs            198H
  222. ;.....
  223. ;
  224. ;
  225. ; For 2400 bps auto-stepdown units
  226. ;
  227. MANUAL:      DB    0        ; For manual selection flag        19BH
  228. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  229. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  230. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  231. ;.....
  232. ;
  233. ;
  234. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  235. ;
  236. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  237.       DB    'Version for Bondwell 2, modem port 40H' ;        1AAH
  238.       DB    CR,LF,0
  239.       RET
  240. ;.....
  241. ;
  242. ;
  243. ;-----------------------------------------------------------------------
  244. ;
  245. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  246. ;     end of your last routine should terminate by 0400H (601 bytes
  247. ;     available after start of SYSVER).
  248. ;
  249. ;-----------------------------------------------------------------------
  250. ;
  251. ; You can put in a message at this location which can be called up with
  252. ; (special character-L).  You can put in several lines.  End with a 0.
  253. ;
  254. LOGON:    DB    'Greetings from a Visual 1050 user... ',CR,0
  255. ;.....
  256. ;
  257. ;
  258. ;-----------------------------------------------------------------------
  259. ;
  260. ; This routine sets a 300 ms break tone
  261. ;
  262. SENDBRK:
  263.     MVI    A,3FH        ; DTR normal, send break tone
  264.     JMP    GOODBYE+2
  265. ;.....
  266. ;
  267. ;
  268. ; This routine sets DTR low for 300 ms to disonnect the phone
  269. ;
  270. GOODBYE:
  271.     MVI    A,3DH        ; Send break, turn off DTR
  272.     CALL    SETMCTL        ; Send to status port
  273.     MVI    B,3        ; Delay 300 ms to hang up phone
  274.     CALL    J$TIMER
  275.     MVI    A,MDCOM        ; Normal send/receive with DTR
  276.     CALL    SETMCTL        ; Send to status port
  277.     RET
  278. ;.....
  279. ;
  280. ;
  281. ; Visual initialization -- sets the 8251A for 8 bits, 1 stop pulse,
  282. ; DTR high, requires jumper to be set internally to 1200 baud then
  283. ; divides by 64 for 300, or by 16 for 1200 baud via "SET" command.  Set
  284. ; at present to default to 300 baud.
  285. ;
  286. INITMOD:MVI    A,3FH        ; Get byte to enable interrupts
  287.     OUT    09DH        ; Turn on interrupts
  288. ;
  289. ;
  290. ; The Visual 1050 provides a special function which returns the
  291. ; address of the byte where the BIOS keeps the current value of
  292. ; the modem control register.  We must modify this byte whenever
  293. ; we change the value of this register, or the BIOS will clobber
  294. ; it whenever it gets an interrupt from the modem port.
  295. ;
  296.     LXI    D,BIOSPB    ; Parameter block for BIOS call
  297.     MVI    C,50        ; Bdos function for direct BIOS call
  298.     CALL    5
  299.     SHLD    RSPAR        ; Save the returned address
  300. ;
  301.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  302.     OUT    MDCTL1
  303.     XTHL            ; Small delay to complete command
  304.     XTHL
  305.     MVI    A,MDRSET    ; Reset the 8251A for new command
  306.     OUT    MDCTL1
  307.     XTHL            ; Small delay to complete command
  308.     XTHL
  309.     MVI    A,MDSET1    ; Set stop pulse, no parity 8 bits, x16
  310.     OUT    MDCTL1
  311.     XTHL            ; Small delay to complete command
  312.     XTHL
  313.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  314.     OUT    MDCTL1
  315.     XTHL            ; Small delay to complete command
  316.     XTHL
  317. ;
  318.     LDA    MSPEED        ; Get the selected value
  319.     CPI    1        ; 300 bps
  320.     JZ    OK300
  321.     CPI    5        ; 1200 bps
  322.     JZ    OK1200
  323.     CPI    6        ; 2400 bps
  324.     JZ    OK2400
  325.     CPI    8        ; 9600 bps
  326.     JZ    OK9600
  327.     JMP    STUPR1        ; Else ask what is wanted
  328. ;.....
  329. ;
  330. ;
  331. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  332.     JNC    STUPR2
  333. ;
  334. STUPR1:    CALL    J$ILPRT
  335.     DB    'Input Baud Rate (300, 1200, 2400, 9600, 19200): ',0
  336.     LXI    D,BAUDBUF    ; Point to new input buffer
  337.     CALL    J$INBUF
  338.     CALL    J$CRLF
  339.     LXI    D,BAUDBUF+2
  340. ;
  341. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  342.     DB    '300',0
  343.     JNC    OK300        ; Go if got match
  344.     CALL    J$INLNCP
  345.     DB    '1200',0
  346.     JNC    OK1200
  347.     CALL    J$INLNCP
  348.     DB    '2400',0
  349.     JNC    OK2400
  350.     CALL    J$INLNCP
  351.     DB    '9600',0
  352.     JNC    OK9600
  353.     CALL    J$INLNCP
  354.     DB    '19200',0
  355.     JNC    OK19200
  356.     CALL    J$ILPRT        ; All matches failed, tell operator
  357.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  358.     JMP    STUPR1        ; Try again
  359. ;
  360. OK300:    MVI    A,1        ; MSPEED 300 baud value
  361.     LXI    H,BD300        ; Get 300 bps parameters in 'HL'
  362.     JMP    LOADBD        ; Go load them
  363. ;
  364. OK1200:    MVI    A,5
  365.     LXI    H,BD1200
  366.     JMP    LOADBD
  367. ;
  368. OK2400:    XRA    A
  369.     STA    MANUAL        ; Reset to maximum auto-speed
  370.     MVI    A,6
  371.     LXI    H,BD2400
  372.     JMP    LOADBD
  373. ;
  374. OK9600:    MVI    A,8
  375.     LXI    H,BD9600
  376.     JMP    LOADBD
  377. ;
  378. OK19200:MVI    A,9
  379.     LXI    H,BD19200
  380. ;
  381. LOADBD:    STA    MSPEED        ; Change time-to-send to match baud rate
  382.     MOV    A,L        ; Get baudrate byte
  383.     STA    LOAD1+1        ; Send to timer for new baudrate
  384.     MOV    A,H
  385.     OUT    MDCTL1        ; Modem status port (mode word)
  386.     MVI    A,MDCOM        ; DTR, RCV, XMT, error reset
  387.     CALL    SETMCTL        ; Modem status port
  388.     IN    BRPORT        ; Get what was there
  389.     ANI    0F3H        ; Clear out the old baud rates
  390. ;
  391. LOAD1:    ORI    0        ; Set new baudrate
  392.     OUT    BRPORT        ; New baud rate now set
  393.     RET
  394. ;.....
  395. ;
  396. ;
  397. ; Table of baudrate parameters
  398. ;
  399. BD300    EQU    4F00H        ; 4F divides by 64
  400. BD1200    EQU    4E00H        ; 4E divides by 16
  401. BD2400    EQU    4E04H
  402. BD9600    EQU    4E08H
  403. BD19200    EQU    4E10H
  404. ;
  405. BAUDBUF:DB    10,0,0,0,0,0
  406.     DB    0,0,0,0,0,0
  407. ;.....
  408. ;
  409. ;
  410. BIOSPB:    DB    30,3
  411. ;.....
  412. ;
  413. ;
  414. ; The following routines replace direct modem port I/O with BDOS calls.
  415. ; The Visual 1050 BIOS uses interrupt-driven I/O with ring buffers.
  416. ; This solves the problem of losing modem input while the console dis-
  417. ; play does a carriage return.
  418. ;
  419. ; Check for input character (receive ready)
  420. ;
  421. BDOS7:    PUSH    B        ; Save the registers
  422.     MVI    C,7        ; Bdos function number
  423.     JMP    BDOS78        ; Common routine for BDOS 7 and 8
  424. ;.....
  425. ;
  426. ;
  427. ; Check for output character (send ready)
  428. ;
  429. BDOS8:    PUSH    B        ; Save the registers
  430.     MVI    C,8        ; BDOS function number
  431. ;
  432. BDOS78:    PUSH    D
  433.     PUSH    H
  434.     CALL    5
  435.     POP    H        ; Restore the registers
  436.     POP    D
  437.     POP    B
  438.     ORA    A        ; BDOS returns A=0 if not ready
  439.     JZ    CLRZ        ; Return Z flag off if not ready
  440.     XRA    A        ; Set Z flag if ready
  441.     RET
  442. ;
  443. CLRZ:    INR    A        ; Clear Z flag (make a non-zero)
  444.     RET
  445. ;.....
  446. ;
  447. ;
  448. ; Input a character from modem via BIOS ring buffer
  449. ;
  450. BDOS3:    PUSH    B        ; Save the registers
  451.     PUSH    D
  452.     PUSH    H
  453.     MVI    C,3        ; Bdos function number
  454.     CALL    5
  455.     POP    H        ; Restore the registers
  456.     POP    D
  457.     POP    B
  458.     RET            ; Input character is in a
  459. ;.....
  460. ;
  461. ;
  462. ; Ouput a character to modem via BIOS ring buffer
  463. ;
  464. BDOS4:    PUSH    B        ; Save the registers
  465.     PUSH    D
  466.     PUSH    H
  467.     MVI    C,4        ; BDOS function number
  468.     MOV    E,A        ; Character to output must be in 'E'
  469.     CALL    5
  470.     POP    H        ; Restore the registers
  471.     POP    D
  472.     POP    B
  473.     RET
  474. ;.....
  475. ;
  476. ;
  477. ; The Visual 1050 BIOS keeps the current value of the modem control
  478. ; register in a special byte.  We must modify this byte whenever
  479. ; we change the value of this register, or the BIOS will clobber
  480. ; it whenever it gets an interrupt from the modem port.
  481. ;
  482. SETMCTL:PUSH    H
  483.     LHLD    RSPAR        ; Address of BIOS byte
  484.     MOV    M,A        ; Save new value there
  485.     OUT    MDCTL1        ; Output to modem control register
  486.     POP    H
  487.     RET
  488. ;.....
  489. ;
  490. ;
  491. RSPAR:    DS    2        ; Addr of BIOS copy of modem control reg
  492. ;.....
  493. ;
  494. ;                   end
  495. ;-----------------------------------------------------------------------
  496. ;
  497. ; NOTE: Must terminate by 0400H
  498. ;
  499.     END
  500.