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 / I2A3-3.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  14KB  |  464 lines

  1.  
  2. ; I2AP3-3.ASM - Apple /// overlay file for IMP - 06/01/87
  3. ;
  4. ;        6551 I/O with built-in baudrate generator
  5. ;
  6. ;
  7. ; This overlay file adapts the Apple /// SoftCard /// CP/M 2.21 to IMP
  8. ; and external modems.    Note that only speeds up to 2400 baud are al-
  9. ; lowed since the CP/M-6502 overhead is too great for any faster commun-
  10. ; ications.  (I tried 4800 & 9600 but lost too many characters and file
  11. ; transfers just did'nt work.)
  12. ;
  13. ; For those that are interested, this overlay uses the Device Function
  14. ; and Status calls built into the BIOS of 2.21 for the express purpose
  15. ; of dealing with SOS Drivers directly.  For details, refer to the Soft-
  16. ; card /// CP/M 2.21 Technical Description and also the Standard Device
  17. ; Drivers Manual.
  18. ;
  19. ;
  20. ; Edit this file for your preferences then follow the "TO USE:" example
  21. ; shown below.
  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,I2A3-x.HEX
  31. ;
  32. ;
  33. ;    NOTE TO APPLE /// USERS:
  34. ;
  35. ;        This overlay assumes that you have configured
  36. ;        your DRIVER.SOS file to include the .RS232
  37. ;        driver (Version 1.30) to the RD1: and PU1:
  38. ;        devices.  You may also use the serial driver
  39. ;        for the Serial Card /// in any slot without
  40. ;        changes to this overlay.  Just assign the
  41. ;        driver to RD1: & PU1:  Also note that you may
  42. ;        NOT have an active printer assigned to the LIST
  43. ;        device if it uses the same port as the modem.
  44. ;
  45. ;-----------------------------------------------------------------------
  46. ;
  47. ; 06/01/87 - Added Break routine.  Exit and    - Douglas Thom
  48. ;         disconnect now drop DTR.
  49. ; 10/27/85 - Modified to drop DTR.        - Steve Smith
  50. ; 09/13/85 - Written for IMP244.        - Douglas Thom
  51. ;
  52. ;-----------------------------------------------------------------------
  53. ;
  54. YES    EQU    0FFH
  55. NO    EQU    0
  56. ;
  57. ;-----------------------------------------------------------------------
  58. ;
  59. ESC    EQU    '['-40H    ; ^[ = Escape
  60. BELL    EQU    'G'-40H    ; ^G = Bell character
  61. LF    EQU    'J'-40H    ; ^J = Linefeed
  62. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  63. CR    EQU    'M'-40H    ; ^M = Carriage return
  64. CLEARSC    EQU    'Z'-40H    ; ^Z = Clear screen, command mode only
  65. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  66. ;
  67. ;
  68. ;==================== CUSTOMIZATION EQUATES ============================
  69. ;
  70. MDRCV    EQU    1        ; Bit to test for receive
  71. MDSND    EQU    0        ; Bit to test for send
  72. MDTXE    EQU    0        ; Modem send buffer empty
  73. ;
  74. ;-----------------------------------------------------------------------
  75. ;
  76.     ORG    0100H
  77. ;
  78.     DS    3    ; Skip the data area below
  79. ;
  80. ; These routines and equates are at the beginning of the program so they
  81. ; can be patched by a monitor or overlay file without re-assembling the
  82. ; program.
  83. ;
  84. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  85.             ; 6=2400 7=4800 8=9600 9=19200 default
  86. HS2400:     DB    YES    ; Yes=2400 bps highest speed            104H
  87. HS1200:     DB    NO    ; Yes=1200 bps highest speed            105H
  88. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  89. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  90. RESVD1:     DB    NO    ; Reserved for special modems            108H
  91. RESVD2:     DB    NO    ; Reserved for special modems            109H
  92. ;
  93. CLEAR:     DB    28    ; Clear screen character (ESC not needed)    10AH
  94. ;
  95. CLOCK:     DB    4    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  96.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  97.             ; 4 for Apple ///
  98. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  99.             ; Default time to send character in ter-
  100.             ; minal mode file transfer for slow BBS
  101. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  102.             ; Default time for extra wait after CRLF
  103.             ; in terminal mode file transfer
  104. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  105. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  106. ;
  107. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  108.             ; mode (normally added by remote echo)
  109. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  110. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  111. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  112. ;
  113. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  114. EXITCHR: DB    'E'    ; Exit character                115H
  115. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  116. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  117. LOGCHR:     DB    'L'    ; Send logon                    118H
  118. LSTCHR:     DB    'P'    ; Toggle printer                119H
  119. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  120. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  121. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  122. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  123. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  124. ;.....
  125. ;
  126. ; Handles in/out ports for data and status
  127. ;
  128. I$MDCTL1: JMP    RCVCTL1        ; In modem control port         11FH
  129.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  130. ;
  131. I$MDTXE:  JMP    RCVCTL2        ;                    129H
  132.       DB    0,0,0,0,0,0,0    ;                    12CH
  133. ;
  134. I$MDDATP: JMP    RCVDATP        ; in modem data port            133H
  135.       DB    0,0,0,0,0,0,0    ;                    146H
  136. ;
  137. O$MDDATP: JMP    SNDDATP        ; Out modem data port            13DH
  138.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  139. ;
  140. A$MDRCV:  ANI    MDRCV        ;                    147H
  141.       RET            ;                    149H
  142. ;
  143. C$MDRCV:  CPI    MDRCV        ;                    14AH
  144.       RET            ;                    14CH
  145. ;
  146. A$MDSND:  ANI    MDSND        ;                    14DH
  147.       RET            ;                    14FH
  148. ;
  149. C$MDSND:  CPI    MDSND        ;                    150H
  150.       RET            ;                    152H
  151. ;
  152. A$MDTXE:  ANI    MDTXE        ;                    153H
  153.       RET            ;                    155H
  154. ;
  155. C$MDTXE:  CPI    MDTXE        ;                    156H
  156.       RET            ;                    158H
  157. ;
  158. ; Special exit vector, used by some computers to reset interrupt vectors
  159. ;
  160. J$EXITVEC:JMP    EXITPRG
  161. ;
  162. ; Jump vectors needed by each overlay
  163. ;
  164. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  165. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  166. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  167. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  168. ;
  169. ; "AT" command strings, can be replaced in individual overlay if needed
  170. ;
  171. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  172. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  173. ;
  174. ; Next fourteen lines should not be changed by user overlay as these go
  175. ; to specific locations in the main program, not in the overlay.
  176. ;
  177. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  178. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  179. J$DIAL:      DS    3        ; Start of dialing routine        174H
  180. J$DSCONT: DS    3        ; Terminates modem use            177H
  181. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  182. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  183. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  184. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  185. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  186. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  187. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  188. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  189. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  190. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  191. J$NEW2:      DB    0,0,0        ; For future needs            198H
  192. ;
  193. ; For 2400 bps auto-stepdown units
  194. ;
  195. MANUAL:      DB    0        ; For manual selection flag        19BH
  196. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  197. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  198. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  199. ;
  200. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  201. ;
  202. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  203.       DB    'Apple /// CP/M 2.21 (RS232 Port)  '    ;        1AAH
  204. ;
  205.       DB    CR,LF,0
  206.       RET
  207. ;
  208. ;-----------------------------------------------------------------------
  209. ;
  210. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  211. ;     end of your last routine should terminate by 0400H (601 bytes
  212. ;     available after start of SYSVER).
  213. ;
  214. ;-----------------------------------------------------------------------
  215. ;
  216. ; You can put in a message at this location which can be called up with
  217. ; (special character-L).  You can put in several lines.  End with a 0.
  218. ;
  219. LOGON:    DB    'Hello, from an Apple /// user',CR,0
  220. ;
  221. ;================== Apple /// Specific Routines ========================
  222. ;
  223. PUNCH    EQU    0DA12H        ; BIOS vector for Punch routine
  224. READER    EQU    0DA15H        ; BIOS vector for Reader routine
  225. ZDVMGR    EQU    0DA36H        ; BIOS vector for Device Manager Call
  226. DVSTAT    EQU    0DA3FH        ; BIOS vector for Device Status Call
  227. DVFUNC    EQU    0DA42H        ; BIOS vector for Device Function Call
  228. DEVTAB    EQU    0DF00H        ; Device table location
  229. BUFFER    EQU    0E400H        ; Control Buffer
  230. DEVICE    EQU    00004H        ; Logical Device number
  231. IOBYTE    EQU    00003H        ; IOBYTE location
  232. ;.....
  233. ;
  234. ;
  235. ; This routine sends a 466 ms break signal.  Refer to the Apple ///
  236. ; Standard Device Drivers Manual (page 127) for details on the
  237. ; command.
  238. ;
  239. SENDBRK:
  240.     DB    0D9H        ; Use Z80 alt. registers to save...
  241.     LXI    H,BUFFER    ; Point to Buffer
  242.     MVI    M,2        ; Break time (233ms * 2)
  243.     LDA    CONFIG        ; Get Device Configuration Number
  244.     MOV    C,A        ; put it in 'C' register
  245.     MVI    B,3        ; Transmit Break
  246.     CALL    DVFUNC        ; Device Function call (6502)
  247.     DB    0D9H        ; Restore Registers
  248.     RET            ; Return to caller...
  249. ;.....
  250. ;
  251. ;
  252. ; This routine sets DTR low for 300 ms to disconnect the phone
  253. ;
  254. GOODBYE:
  255.     MVI    A,7        ; SOS Device close command
  256.     CALL    DVMGR        ; To set DTR low
  257.     MVI    B,3        ; Wait for 300 ms
  258.     CALL    J$TIMER
  259.     MVI    A,6        ; SOS Device open command
  260.     CALL    DVMGR        ; To open the .RS232 driver again
  261.     CALL    ZRESET        ; Reset driver to bring DTR back up
  262.     JMP    SPDCHK        ; Restore modem speed
  263. ;.....
  264. ;
  265. ;
  266. INITMOD:
  267.     LDA    DEVTAB+DEVICE    ; Get CP/M Configuration Number
  268.     STA    CONFIG        ; Save it for future use
  269.     MOV    C,A
  270.     MVI    B,1        ; Get .RS232 Parmeters
  271.     CALL    DVSTAT        ; Do it....
  272.     LXI    H,BUFFER+1    ; Point to Baud Rate
  273.     MOV    A,M        ; Save it way for future use
  274.     STA    OLDBAUD
  275.     LDA    IOBYTE        ; Get current IO Byte
  276.     STA    IOSAVE        ; Save it away for lager
  277.     ORI    3        ; Force Console to CO4:
  278.     STA    IOBYTE
  279.     MVI    A,6        ; Open .RS232 driver
  280.     CALL    DVMGR
  281. ;
  282. SPDCHK:    LDA    MSPEED        ; Get Baud Rate value
  283.     CPI    1        ; Is it 300 baud
  284.     JZ    OK300
  285.     CPI    5        ; Is it 1200 baud
  286.     JZ    OK1200
  287.     CPI    6        ; Is it 2400 baud
  288.     JZ    OK2400
  289.     JMP    STUPR1        ; Else ask for Speed
  290. ;.....
  291. ;
  292. ;
  293. DVMGR:    DB    0D9H        ; Save Registers in Alt Z80 Registers
  294.     STA    0E8C0H        ; SOS Command location
  295.     LDA    CONFIG        ; Get CP/M Configuration
  296.     STA    0E8C1H        ; Pass to SOS Device Manager
  297.     CALL    ZDVMGR        ; Do SOS command
  298.     DB    0D9H        ; Restore Registers
  299.     RET
  300. ;.....
  301. ;
  302. ;
  303. EXITPRG:
  304.     LDA    IOSAVE        ; Return to CO1:
  305.     STA    IOBYTE
  306.     LDA    OLDBAUD        ; Restore original Baudrate
  307.     MOV    B,A        ; Stuff it in 'B'
  308.     CALL    LOADBD        ; Do it...
  309.     MVI    A,7        ; Close up RS232 driver
  310.     CALL    DVMGR        ; do it....
  311.     RET
  312. ;.....
  313. ;
  314. ;
  315. RCVCTL1:
  316.     PUSH    B        ; Test Modem Input Status
  317.     PUSH    D
  318.     PUSH    H
  319.     MVI    B,3        ; Status code 3 (Retrieve Driver Buffer)
  320.     LDA    CONFIG        ; Get Driver Number
  321.     MOV    C,A
  322.     CALL    DVSTAT        ; Do Device Status Call
  323.     LHLD    BUFFER+6    ; Look at Buffer Size
  324.     MOV    A,L
  325.     ORA    H
  326.     JZ    INRDY        ; Buffer is not empty....
  327.     MVI    A,01H        ; Buffer is empty...
  328. ;
  329. INRDY:    POP    H        ; Restore Registers
  330.     POP    D
  331.     POP    B
  332.     RET
  333. ;.....
  334. ;
  335. ;
  336. RCVCTL2:
  337.     MVI    A,0        ; TBE always true....
  338.     RET
  339. ;.....
  340. ;
  341. ;
  342. RCVDATP:
  343.     PUSH    B        ; Read in a Character
  344.     PUSH    D
  345.     PUSH    H
  346.     CALL    READER
  347.     POP    H
  348.     POP    D
  349.     POP    B
  350.     RET
  351. ;.....
  352. ;
  353. ;
  354. SNDDATP:
  355.     PUSH    B        ; Send out a Character
  356.     PUSH    D
  357.     PUSH    H
  358.     MOV    C,A
  359.     CALL    PUNCH
  360.     POP    H
  361.     POP    D
  362.     POP    B
  363.     RET
  364. ;.....
  365. ;
  366. ;
  367. ZRESET:    DB    0D9H        ; Use Z80 alt. registers (Save Regs)
  368.     LDA    CONFIG
  369.     MOV    C,A
  370.     MVI    B,0        ; Device function reset
  371.     CALL    DVFUNC
  372.     DB    0D9H        ; Restore Registers
  373.     RET
  374. ;.....
  375. ;
  376. ;
  377. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  378.     JNC    STUPR2
  379. ;
  380. STUPR1:    CALL    J$ILPRT        ; Print following Message
  381.     DB    'Input Baud Rate (300, 1200, 2400): ',0
  382.     LXI    D,BAUDBUF    ; Point to new input buffer
  383.     CALL    J$INBUF
  384.     CALL    J$CRLF
  385.     LXI    D,BAUDBUF+2
  386. ;
  387. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with Chars. below
  388.     DB    '300',0
  389.     JNC    OK300        ; Go if Match
  390.     CALL    J$INLNCP
  391.     DB    '1200',0
  392.     JNC    OK1200
  393.     CALL    J$INLNCP
  394.     DB    '2400',0
  395.     JNC    OK2400
  396.     CALL    J$ILPRT        ; All matches failed, tell user
  397.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  398.     JMP    STUPR1
  399. ;.....
  400. ;
  401. ;
  402. OK300:    MVI    A,1        ; Load MSPEED 300 baud value
  403.     MVI    B,BD300        ; Get Baudrate Value
  404.     JMP    LOADBD
  405. ;
  406. OK1200:    MVI    A,5        ; Load MSPEED 1200 baud value
  407.     MVI    B,BD1200    ; Get Baudrate Value
  408.     JMP    LOADBD
  409. ;
  410. OK2400:    XRA    A
  411.     STA    MANUAL        ; Reset to maximum auto-speed
  412.     MVI    A,6        ; Load MSPEED 2400 baud value
  413.     MVI    B,BD2400    ; Get Baudrate Value
  414. ;.....
  415. ;
  416. ;
  417. LOADBD:    STA    MSPEED        ; Save Modem Speed
  418.     MOV    A,B
  419.     STA    A3BD        ; Stuff Baud into Driver...
  420.     LXI    B,14        ; Move 14 bytes
  421.     LXI    H,RS232        ; Move Control Parameters into
  422.     LXI    D,BUFFER    ; Device Driver Buffer
  423.     DB    0EDH,0B0H    ; LDIR instruction
  424.     LDA    CONFIG        ; Get Configuration Number
  425.     MOV    C,A
  426.     MVI    B,1        ; Set Control Parmeters
  427.     CALL    DVFUNC        ; do it....
  428.     RET
  429. ;.....
  430. ;
  431. ;
  432. IOSAVE:        DB    0    ; Temp storage for IOBYTE
  433. CONFIG:        DB    0    ; Configuration Number
  434. OLDBAUD:    DB    8    ; Storage for Original Baudrate
  435. ;.....
  436. ;
  437. ;
  438. RS232:    DB    0FH        ; Buffer size
  439. A3BD:    DB    8        ; 2400 bps baud rate value
  440.     DB    0,0,0,0,0
  441.     DB    013H,011H
  442.     DB    0DFH,084H
  443.     DB    050H,0,080H
  444. ;.....
  445. ;
  446. ;
  447. ; Table of baudrate values
  448. ;
  449. BD300    EQU    6        ; 300 baud
  450. BD1200    EQU    8        ; 1200 bps
  451. BD2400    EQU    10        ; 2400 bps
  452. ;
  453. BAUDBUF:
  454.     DB    10,0,0,0,0,0
  455.     DB    0,0,0,0,0,0
  456. ;.....
  457. ;
  458. ;                   end
  459. ;-----------------------------------------------------------------------
  460. ;
  461. ; NOTE: Must terminate by 0400H
  462. ;
  463.     END
  464.