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 / I2RY-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  13KB  |  498 lines

  1. ; I2RY-1.ASM - Royal Alphatronic PC IMP overlay (low speed) - 07/10/87
  2. ;
  3. ;        USES 8251A I/O and no baudrate generator
  4. ;
  5. ; You will want to look this file over carefully. There are a number of
  6. ; options that you can use to configure the program to suit your taste.
  7. ; This file adapts the Royal computer to the IMP modem program.  This
  8. ; model has no baudrate generator and changes the 8251 from "x16" for
  9. ; 1200 bps to "x64" for 300 bps.  The Royal must be jumpered for 1200
  10. ; bps for this method to work. (J101 4th from left)
  11. ;
  12. ; Edit this file for your preferences then follow the "TO USE:" example
  13. ; shown below.
  14. ;
  15. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  16. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  17. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  18. ; (The ESC will automatically be typed with no CTL-character present.)
  19. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  20. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  21. ; looking at the function key table, typing CTL-Z in command mode, etc.
  22. ;
  23. ; Use the "SET" command to change the baudrate when desired.  The value
  24. ; at MSPEED controls the baudrate when the program is first called up.
  25. ;
  26. ;    TO USE: First edit this file filling in answers for your own
  27. ;        equipment.  Then assemble with ASM.COM or equivalent
  28. ;        assembler.  Then use MLOAD to merge into the main file:
  29. ;
  30. ;        MLOAD IMP.COM=IMP.COM,I2RY-x.HEX
  31. ;
  32. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  33. ;
  34. ; 07/11/87  Adapted from I2SY-2.ASM for Royal Alphatronic PC
  35. ;                        - Paul Carmichael
  36. ;
  37. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  38. ;        IMP245 to use it.            - Irv Hoff
  39. ;
  40. ; 10/27/85  Initial IMP version         - Irv Hoff
  41. ;
  42. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  43. ;
  44. ;
  45. ; ROYAL EQUATES
  46. ;
  47. EOICMD    EQU    20H    ; Non-spec EIO for PIC
  48. RXINTV    EQU    0EF04H    ; Receive ready interruptvector
  49. LSTSTV    EQU    0D92DH    ; Lstst vector (bug in monitor)
  50. PICPRT0    EQU    70H    ; PIC base port
  51. PICPRT1    EQU    71H
  52. PICMSK0    EQU    0FDH    ; Enable receive ready interrupt
  53. PICMSK1    EQU    0FFH    ; Mask all interrupts
  54. RXBFSIZ    EQU    32    ; Receive buffer size
  55. XOFF    EQU    'S'-40H
  56. XON    EQU    'Q'-40H
  57. ;
  58. ;
  59. NO    EQU    0
  60. YES    EQU    NOT NO    ; (Some assemblers cannot use 0FFh)
  61. ;
  62. ;
  63. ; Valeus shown are for an 8251A
  64. ;
  65. PORT    EQU    40H    ; Your base port (data or status)
  66. MDCTL1    EQU    PORT+1    ; Modem control port
  67. MDDATP    EQU    PORT    ; Modem data port
  68. MDRCV    EQU    02H    ; Modem receive ready
  69. MDSND    EQU    01H    ; Modem send ready bit
  70. MDTXE    EQU    05H    ; Modem send buffer empty, holding buffer empty
  71. ;
  72. MDMODE    EQU    82H    ; Insures 8251 is out of mode with DTR high
  73. MDRSET    EQU    42H    ; Resets USERT for additional commands
  74. MDSET0    EQU    4FH    ; 1 stop bit, no parity, 8 bits, x64
  75. MDSET1    EQU    4EH    ; 1 stop bit, no parity, 8 bits, x16
  76. MDSET2    EQU    4CH    ; 2 stop bits, no parity, 8 bits, x16
  77. RDCOM    EQU    37H    ; Reset RTS, error flags, RCV, DRT, TX ready
  78. ;
  79. ;
  80. ;-----------------------------------------------------------------------
  81. ;
  82. ESC    EQU    '['-40H    ; ^[ = escape
  83. BELL    EQU    'G'-40H    ; ^G = bell character
  84. LF    EQU    'J'-40H    ; ^J = linefeed
  85. NEXTRY    EQU    'K'-40H    ; ^K = try next phone number, abort this try
  86. CR    EQU    'M'-40H    ; ^M = carriage return
  87. CLEARSC    EQU    'Z'-40H    ; ^Z = clears screen, command mode only
  88. EOFCHAR    EQU    'Z'-40H    ; ^Z = end of file
  89. ;
  90. ;
  91. ;-----------------------------------------------------------------------
  92. ;
  93. ;
  94.     ORG    103H
  95. ;
  96. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103h
  97.             ; 6=2400 7=4800 8=9600 9=19200 default
  98. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104h
  99. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105h
  100. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200v or 2400v or 2400pa    106h
  101. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107h
  102. RESVD1:     DB    NO    ; Reserved for special modems            108h
  103. RESVD2:     DB    NO    ; Reserved for special modems            109h
  104. ;
  105. ;
  106. CLEAR:     DB    'E'    ; Clear screen character (ESC not needed)    10Ah
  107. CLOCK:     DB    40    ; Clock speed in mhz x10, 25.5 MHz max.     10Bh
  108.             ; 20=2 MHz, 37=3.68 MHz, 40=4 MHz, etc.
  109. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10Ch
  110.             ; Default time to send character in ter-
  111.             ; Minal mode file transfer for slow bbs
  112. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10Dh
  113.             ; Default time for extra wait after crlf
  114.             ; In terminal mode file transfer
  115. NOFCOL:     DB    5    ; Number of directory columns shown        10Fh
  116. TCHPUL:     DB    'T'    ; T=tone, P=pulse (Hayes 2400 modems)        10Fh
  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-characters above ^M not displayed    113h
  124. ;.....
  125. ;
  126. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114h
  127. EXITCHR: DB    'E'    ; Exit character                115h
  128. FILESND: DB    'F'    ; Send file when in terminal mode        116h
  129. NOCONCT: DB    'N'    ; Disconnect from phone line            117h
  130. LOGCHR:     DB    'L'    ; Send logon                    118h
  131. LSTCHR:     DB    'P'    ; Toggle printer                119h
  132. UNSAVCH: DB    'R'    ; Close input text buffer            11Ah
  133. SAVECHR: DB    'Y'    ; Open input text buffer            11Bh
  134. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11Ch
  135. BRKCHR:     DB    'Q'    ; Send a break tone                11Dh
  136. NODTR:     DB    NO    ; Yes if no DTR and need ATH0 to disconnect    11Eh
  137. ;.....
  138. ;
  139. ; Handles in/out ports for data and status
  140. ;
  141.       ORG    11FH
  142. I$MDCTL1: IN    MDCTL1
  143.       RET
  144. ;
  145.       ORG    129H
  146. I$MDTXE:  IN    MDCTL1
  147.       RET
  148. ;
  149.       ORG    133H
  150. I$MDDATP: JMP    GETRX
  151. ;
  152.       ORG    13DH
  153. O$MDDATP: OUT    MDDATP
  154.       RET
  155. ;
  156.       ORG    147H
  157. A$MDRCV:  RET
  158. ;
  159.       ORG    14AH
  160. C$MDRCV:  JMP    RXRDY
  161. ;
  162.       ORG    14DH
  163. A$MDSND:  ANI    MDSND
  164.       RET
  165. ;
  166. C$MDSND:  CPI    MDSND
  167.       RET
  168. ;
  169. A$MDTXE:  ANI    MDTXE
  170.       RET
  171. ;
  172. C$MDTXE:  CPI    MDTXE
  173.       RET
  174. ;.....
  175. ;
  176.     ORG    159H
  177. ;
  178. ; Special exit vector, used by some computers to reset interrupt vectors
  179. ;
  180. J$EXITVEC:JMP    REXIT        ;                    159h
  181. ;.....
  182. ;
  183. ; JUMP VECTORS NEEDED BY EACH OVERLAY
  184. ;
  185. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15Ch
  186. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15Fh
  187. J$STUPR:  JMP    STUPR        ; Set routine to change baudrate    162h
  188. J$SYSVR:  JMP    SYSVR        ; Signon message            165h
  189. ;.....
  190. ;
  191. ; "AT" command strings, can be replaced in individual overlay if needed
  192. ;
  193. J$STRNGA: DS    3        ; 1200 bps "AT" string            168h
  194. J$STRNG1: DS    3        ; 2400 bps "AT" string            16Bh
  195. ;
  196. ;
  197. ; Next fourteen lines should not be changed by user overlay as these go
  198. ; to specific locations in the main program, not in the overlay.
  199. ;
  200. ;
  201. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16Eh
  202. J$CRLF:      DS    3        ; Turns up one new line on display    171h
  203. JR$DIAL:   DS    3        ; Start of dialing routine        174h
  204. J$DSCONT: DS    3        ; Terminates modem use            177h
  205. J$GOLST:  DS    3        ; Printer routine, needed by APPLE //e    17Ah
  206. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17Dh
  207. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180h
  208. J$INLNCP: DS    3        ; Inline "compare strings" routine    183h
  209. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186h
  210. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189h
  211. J$SNDCHR: DS    3        ; Sends a character to the modem    18Ch
  212. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18Fh
  213. J$TIMER:  DS    3        ; 1 second timer (amount in 'B' reg.)    192h
  214. J$BREAK:  JMP    SENDBRK        ; Break routine             195h
  215. J$NEW2:      DB    0,0,0        ; For future needs            198h
  216. ;.....
  217. ;
  218. ;
  219. ; For 2400 bps auto-stepdown units
  220. ;
  221. MANUAL:      DB    0        ; For manual selection flag        19Bh
  222. J$300:      JMP    OK300        ;                    19Ch
  223. J$1200:      JMP    OK1200        ;                    19Fh
  224. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2h
  225. ;.....
  226. ;
  227. ;
  228. LOGPTR:      DW    LOGON        ; Pointer to display logon message    1A5h
  229. ;
  230. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7h
  231.       DB    'Version for Royal Alphatronic PC'
  232.       DB    CR,LF,0
  233.       RET
  234. ;.....
  235. ;
  236. ;
  237. ;-----------------------------------------------------------------------
  238. ;
  239. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  240. ;     end of your last routine should terminate by 0400h (601 bytes
  241. ;     available after start of SYSVER).
  242. ;
  243. ;-----------------------------------------------------------------------
  244. ;
  245. ; You can put in a message at this location which can be called up with
  246. ; (special character-L).  You can put in several lines.  End with a 0.
  247. ;
  248. LOGON:    DB    'Hello!',CR,LF,0
  249. ;
  250. ;-----------------------------------------------------------------------
  251. ;
  252. ; This routine sets a 300 ms break tone
  253. ;
  254. SENDBRK:
  255.     MVI    A,3FH        ; DTR normal, send break tone
  256.     JMP    GOODBYE+2
  257. ;.....
  258. ;
  259. ;
  260. ; This routine sets DTR low for 300 ms to disonnect the phone
  261. ;
  262. GOODBYE:
  263.     MVI    A,3DH        ; Send break, turn off DTR
  264.     DI
  265.     OUT    MDCTL1        ; Send to status port
  266.     MVI    B,3        ; Delay 300 ms to hang up phone
  267.     CALL    J$TIMER
  268.     MVI    A,37H        ; Normal send/receive with DTR
  269.     OUT    MDCTL1        ; Send to status port
  270.     LXI    H,RXBUF
  271. ;
  272. R:    SHLD    RXPTR        ; Reset pointer
  273.     XRA    A
  274.     STA    RXCNT        ; Clear count
  275.     EI
  276.     RET
  277. ;.....
  278. ;
  279. ;
  280. ; Sets 8251 to 8 bits, DTR, RCV and TX ready
  281. ;
  282. INITMOD:
  283.     DI
  284.     CALL    INIT0        ; Go initialize the modem
  285.     LHLD    LSTSTV+1
  286.     SHLD    OLDVEC        ; Save old LsTst vector
  287.     LXI    H,LSTST
  288.     SHLD    LSTSTV+1    ; Insert new
  289.     XRA    A
  290.     STA    RXCNT        ; Clear buffer counter
  291.     LXI    H,RXBUF
  292.     SHLD    RXPTR        ; Preset pointer
  293.     LXI    H,RXISR
  294.     SHLD    RXINTV+1    ; Rxrdy service vector into table
  295.     MVI    B,8
  296.     MVI    A,EOICMD
  297. ;
  298. INITL1:    OUT    PICPRT0        ; EOI to PIC
  299.     DCR    B
  300.     JNZ    INITL1        ; 8 times
  301.     MVI    A,0C3H
  302.     STA    RXINTV
  303.     MVI    A,PICMSK0
  304.     OUT    PICPRT1        ; Enable rxrdy interrupt
  305.     EI
  306.     RET
  307. ;.....
  308. ;
  309. ;
  310. INIT0:    LDA    MSPEED        ; Get the selected value
  311.     CPI    1        ; 300 baud
  312.     JZ    OK300
  313.     CPI    5        ; 1200 bps
  314.     JZ    OK1200
  315.     JMP    STUPR1        ; Else ask what is wanted
  316. ;.....
  317. ;
  318. ;
  319. ;
  320. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  321.     JNC    STUPR2
  322. ;
  323. STUPR1:    CALL    J$ILPRT
  324.     DB    'INPUT BAUD RATE (300, 1200): ',0
  325.     LXI    D,BAUDBUF    ; Point to new input buffer
  326.     CALL    J$INBUF
  327.     CALL    J$CRLF
  328.     LXI    D,BAUDBUF+2
  329. ;
  330. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  331.     DB    '300',0
  332.     JNC    OK300        ; Go if got match
  333.     CALL    J$INLNCP
  334.     DB    '1200',0
  335.     JNC    OK1200
  336.     CALL    J$ILPRT        ; All matches failed, tell operator
  337.     DB    '++ INCORRECT ENTRY ++',CR,LF,BELL,CR,LF,0
  338.     JMP    STUPR1        ; Try again
  339. ;
  340. OK300:    MVI    A,1        ; MSPEED 300 baud value
  341.     MVI    B,MDSET0    ; Divide by 64 for 300 baud
  342.     JMP    LOADBD        ; Go set the baudrate
  343. ;
  344. OK1200:    MVI    A,5
  345.     MVI    B,MDSET1    ; Divide by 16 for 1200 bps
  346.     JMP    LOADBD        ; Go set the baudrate
  347. ;
  348. OK2400:    JMP    OK1200
  349. ;
  350. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  351.     MVI    A,MDMODE    ; Insure 8251 is out of mode
  352.     OUT    MDCTL1
  353.     XTHL            ; Small delay to complete command
  354.     XTHL
  355.     MVI    A,MDRSET    ; Reset the 8251a for new command
  356.     OUT    MDCTL1
  357.     XTHL            ; Small delay to complete command
  358.     XTHL
  359.     MOV    A,B        ; Set speed
  360.     OUT    MDCTL1
  361.     XTHL            ; Small delay to complete command
  362.     XTHL
  363.     MVI    A,MDCOM        ; Error reset, RCV, DTR, TX ready
  364.     OUT    MDCTL1
  365.     XTHL            ; Small delay to complete command
  366.     XTHL
  367.     RET
  368. ;.....
  369. ;
  370. ;
  371. REXIT:    DI
  372.     MVI    A,0C9H        ; Put return code into vector
  373.     STA    RXINTV
  374.     MVI    A,PICMSK1
  375.     OUT    PICPRT1        ; Mask all interrupts
  376.     LHLD    OLDVEC
  377.     SHLD    LSTSTV+1
  378.     XRA    A
  379.     STA    RXCNT
  380.     LXI    H,RXBUF
  381.     SHLD    RXPTR
  382.     EI
  383.     RET
  384. ;.....
  385. ;
  386. ;
  387. ; Receive ready service routine
  388. ;
  389. RXISR:    PUSH    PSW
  390.     PUSH    B
  391.     PUSH    D
  392.     PUSH    H        ; Save registers
  393.     IN    MDDATP
  394.     LHLD    RXPTR        ; Get buffer pointer
  395.     MOV    M,A        ; Put RX data to buffer
  396.     INX    H
  397.     SHLD    RXPTR
  398.     LDA    RXCNT
  399.     INR    A
  400.     CPI    RXBFSIZ        ; ? buffer full
  401.     STA    RXCNT
  402.     JC    RXISX        ; Skip next if not
  403.     MVI    A,0FFH
  404.     STA    XOFFL
  405.     MVI    A,XOFF
  406.     CALL    J$SNDCHR
  407. ;
  408. RXISX:    MVI    A,EOICMD
  409.     OUT    PICPRT0        ; EOI to PIC
  410.     POP    H
  411.     POP    D
  412.     POP    B
  413.     POP    PSW        ; Restore registers
  414.     EI
  415.     RET
  416. ;.....
  417. ;
  418. ;
  419. ; Get a character from RX buffer
  420. ;
  421. GETRX:    PUSH    B
  422.     PUSH    D
  423.     PUSH    H
  424. ;
  425. GETRX0:    DI
  426.     LDA    RXCNT
  427.     DCR    A        ; Decrement counter
  428.     STA    RXCNT        ; Store new value
  429.     LXI    H,RXBUF
  430.     MOV    C,A
  431.     MOV    A,M
  432.     STA    CHAR        ; Save character
  433.     JZ    GETRX1        ; Skip next if last character
  434.     MVI    B,0
  435.     XCHG
  436.     LXI    H,RXBUF+1
  437.     DB    0EDH
  438.     DB    0B0H        ; Move buffer down a byte
  439. ;
  440. GETRX1:    LDA    XOFFL
  441.     ORA    A
  442.     JZ    GETRXX        ; If XOFF flag not set leave
  443.     MVI    A,XON
  444.     CALL    J$SNDCHR
  445.     XRA    A
  446.     STA    XOFFL        ; Turn XON and clear flag
  447. ;
  448. GETRXX:    LHLD    RXPTR
  449.     DCX    H
  450.     SHLD    RXPTR        ; Adjust buffer pointer
  451.     LDA    CHAR        ; Recover character
  452.     POP    H
  453.     POP    D
  454.     POP    B
  455.     EI
  456.     RET
  457. ;.....
  458. ;
  459. ;
  460. RXRDY:    LDA    RXCNT        ; Get RX buffer counter
  461.     ORA    A        ; Anything there?
  462.     JZ    RXNRDY        ; Go not ready if not
  463.     XRA    A        ; Indicate ready
  464.     RET
  465. ;
  466. RXNRDY:    MVI    A,0FFH
  467.     ORA    A        ; Indicate not ready
  468.     RET
  469. ;.....
  470. ;
  471. ;
  472. LSTST:
  473.     IN    30H
  474.     IN    30H        ; For hardware
  475.     ANI    40H        ; ? busy
  476.     JZ    LSTRDY        ;
  477.     XRA    A
  478.     RET            ; Lister busy
  479. ;
  480. LSTRDY:    DCR    A
  481.     ORA    A
  482.     RET            ; Lister not busy
  483. ;.....
  484. ;
  485. ;
  486. XOFFL:    DB    0        ; Xoff flag
  487. CHAR:    DB    0        ; Temp character register
  488. RXPTR:    DW    0        ; Buffer pointer
  489. OLDVEC:    DW    0        ; Old LsTst vector
  490. BAUDBUF:DB    10,0,0,0,0,0    ; CONINP buffer
  491.     DB    0,0,0,0,0,0
  492. RXCNT:    DB    0        ; RX buffer counter
  493. RXBUF:    DS    RXBFSIZ        ; RX input buffer
  494. ;
  495. ;                   end
  496. ;-----------------------------------------------------------------------
  497.     END
  498.