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

  1.  
  2. ; I2A2-3.ASM - Apple //c overlay file for IMP - 06/01/87
  3. ;
  4. ;        6551 with built-in baudrate generator
  5. ;
  6. ; This overlay file adapts Apple //c computers with various CP/M cards
  7. ; and external 300/1200 or 300/1200/2400 bps modems to IMP.COM.  It sup-
  8. ; ports the following configurations:
  9. ;
  10. ; CP/M adapter cards:
  11. ; ------------------
  12. ;    ALS CP/M 3.0 adapter card
  13. ;    Applied Engineering Z80+ or Z80C
  14. ;    Microsoft Softcard Z80 equivalent
  15. ;    PCPI Applicard
  16. ;
  17. ;-----------------------------------------------------------------------
  18. ;
  19. ; You will want to look this file over carefully.  There are a number of
  20. ; options that you can use to configure the program to suit your taste.
  21. ;
  22. ; Edit this file for your preferences then follow the "TO USE:" example
  23. ; shown below.
  24. ;
  25. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  26. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  27. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  28. ; (The ESC will automatically be typed with no CTL-character present.)
  29. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  30. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  31. ; looking at the function key table, typing CTL-Z in command mode, etc.
  32. ;
  33. ; Use the "SET" command to change the baudrate when desired.  The value
  34. ; at MSPEED controls the baudrate when the program is first called up.
  35. ;
  36. ;    TO USE: First edit this file filling in answers for your own
  37. ;        equipment.  Then assemble with ASM.COM or equivalent
  38. ;        assembler.  Then use MLOAD to merge into the main file:
  39. ;
  40. ;        MLOAD IMP.COM=IMP.COM,I2A2-x.HEX
  41. ;
  42. ;                    - Notes by Irv Hoff W6FFC
  43. ;
  44. ; =   =  =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  45. ;
  46. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  47. ;        IMP245 to use it.        - Irv Hoff
  48. ;
  49. ; 06/06/86  Added SNDCTL2 and SNDCLT3 routines for the Applicard.
  50. ;                    - Irv Hoff
  51. ;
  52. ; 03/22/86  Written for the Apple //c    - Irv Hoff
  53. ;
  54. ; =   =  =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  55. ;
  56. YES    EQU    0FFH
  57. NO    EQU    0
  58. ;
  59. ;
  60. ;====================== CUSTOMIZATION EQUATES ==========================
  61. ;
  62. ; CP/M adapter cards for Apple //c
  63. ;
  64. ALSCARD       EQU    NO           ; Yes if using ALS CP/M card
  65. APPLIED       EQU    NO           ; Yes if using Applied Engineering Z80
  66. APPLICARD  EQU    YES           ; Yes if using PCPI Applicard CP/M card
  67. MICROSOFT  EQU    NO           ; Yes if Microsoft Softcard CP/M card
  68. ;
  69. ;-----------------------------------------------------------------------
  70. ;
  71. PORT    EQU    0E0A8H
  72. MDDATP    EQU    PORT        ; Data port
  73. MDCTL1    EQU    PORT+1        ; Status port
  74. MDCTL2    EQU    PORT+2        ; Command port
  75. MDCTL3    EQU    PORT+3        ; Control port
  76. MDRCV    EQU    08H        ; Modem receive bit
  77. MDSND    EQU    10H        ; Modem send bit
  78. MDTXE    EQU    10H        ; Modem send buffer empty bit
  79. ;
  80. ;
  81. ;-----------------------------------------------------------------------
  82. ;
  83. ; General equates
  84. ;
  85. ESC    EQU    '['-40H        ; ^[ = Escape
  86. BELL    EQU    'G'-40H        ; ^G = Bell character
  87. LF    EQU    'J'-40H        ; ^J = Linefeed
  88. NEXTRY    EQU    'K'-40H        ; ^K = Try next phone number now
  89. CR    EQU    'M'-40H        ; ^M = Carriage return
  90. CLEARSC    EQU    'Z'-40H        ; ^Z = Clear screen, command mode only
  91. EOFCHAR    EQU    'Z'-40H        ; ^Z = End of file
  92. ;
  93. ;
  94. ;-----------------------------------------------------------------------
  95. ;
  96. ;
  97.     ORG    0100H
  98. ;
  99.     DS    3    ; Skip the data area below
  100. ;
  101. ;
  102. ; These routines and equates are at the beginning of the program so
  103. ; they can be patched by a monitor or overlay file without re-assembling
  104. ; the program.
  105. ;
  106. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  107.             ; 6=2400 7=4800 8=9600 9=19200 default
  108. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  109. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  110. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  111. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  112. RESVD1:     DB    NO    ; Reserved for special modems            108H
  113. RESVD2:     DB    NO    ; Reserved for special modems            109H
  114. ;
  115. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  116. ;
  117.       IF    APPLICARD
  118. CLOCK:     DB    6    ; Clock speed in MHz, 25.5 MHz max.        10BH
  119.             ; NOTE:  DO NOT MULTIPLY BY 10 FOR APPLICARD
  120.       ENDIF        ; APPLICARD
  121. ;
  122.       IF    NOT APPLICARD
  123. CLOCK:     DB    40    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  124.       ENDIF        ; NOT APPLICARD
  125. ;
  126.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  127. BYTDLY:     DB    9    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  128.             ;   default time to send character in ter-
  129.             ;   minal mode file transfer for slow BBS
  130. CRDLY:     DB    9    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  131.             ;   default time for extra wait after CRLF
  132.             ;   in terminal mode file transfer
  133. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  134. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  135. ;.....
  136. ;
  137. ;
  138. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  139.             ;   mode (normally added by remote echo)
  140. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  141. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  142. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  143. ;.....
  144. ;
  145. ;
  146. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  147. EXITCHR: DB    'E'    ; Exit character                115H
  148. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  149. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  150. LOGCHR:     DB    'L'    ; Send logon                    118H
  151. LSTCHR:     DB    'P'    ; Toggle printer                119H
  152. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  153. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  154. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  155. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  156. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  157. ;.....
  158. ;
  159. ;
  160. ; Handles in/out ports for data and status
  161. ;
  162. I$MDCTL1: JMP    RCVCTL1        ; In modem control port         11FH
  163.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  164. ;
  165. I$MDTXE:  JMP    RCVCTL1        ;                    129H
  166.       DB    0,0,0,0,0,0,0    ;                    12CH
  167. ;
  168. I$MDDATP: JMP    RCVDATP        ;in modem data port            133H
  169.       DB    0,0,0,0,0,0,0    ;                    146H
  170. ;
  171. O$MDDATP: JMP    SNDDATP        ; Out modem data port            13DH
  172.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  173. ;.....
  174. ;
  175. ;
  176. A$MDRCV:  ANI    MDRCV        ;                    147H
  177.       RET            ;                    149H
  178. ;
  179. C$MDRCV:  CPI    MDRCV        ;                    14AH
  180.       RET            ;                    14CH
  181. ;
  182. A$MDSND:  ANI    MDSND        ;                    14DH
  183.       RET            ;                    14FH
  184. ;
  185. C$MDSND:  CPI    MDSND        ;                    150H
  186.       RET            ;                    152H
  187. ;
  188. A$MDTXE:  ANI    MDTXE        ;                    153H
  189.       RET            ;                    155H
  190. ;
  191. C$MDTXE:  CPI    MDTXE        ;                    156H
  192.       RET            ;                    158H
  193. ;.....
  194. ;
  195. ;
  196. ; Special exit vector, used by some computers to reset interrupt vectors
  197. ;
  198. J$EXITVEC:RET            ;                    159H
  199.       DB    0,0        ;                    15AH
  200. ;.....
  201. ;
  202. ;
  203. ; Jump vectors needed by each overlay
  204. ;
  205. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  206. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  207. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  208. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  209. ;.....
  210. ;
  211. ;
  212. ; "AT" command strings, can be replaced in individual overlay if needed
  213. ;
  214. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  215. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  216. ;
  217. ;
  218. ; Next fourteen lines should not be changed by user overlay as these go
  219. ; to specific locations in the main program, not in the overlay.
  220. ;
  221. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  222. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  223. J$DIAL:      DS    3        ; Start of dialing routine        174H
  224. J$DSCONT: DS    3        ; Terminates modem use            177H
  225. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  226. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  227. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  228. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  229. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  230. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  231. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  232. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  233. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  234. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  235. J$NEW2:      DB    0,0,0        ; For future needs            198H
  236. ;.....
  237. ;
  238. ;
  239. ; For 2400 bps auto-stepdown units
  240. ;
  241. MANUAL:      DB    0        ; For manual selection flag        19BH
  242. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  243. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  244. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  245. ;.....
  246. ;
  247. ;
  248. LOGPTR:    DW    LOGON        ; Pointer to display LOGON message    1A5H
  249. ;
  250. SYSVR:    CALL    J$ILPRT        ; Display the following line        1A7H
  251. ;
  252.     DB    'Apple ][ and '    ;
  253. ;
  254.      IF    ALSCARD
  255.     DB    'ALS CP/M Card'
  256.      ENDIF            ; ALSCARD
  257. ;
  258.      IF    APPLICARD
  259.     DB    'Applicard'
  260.      ENDIF            ; APPLICARD
  261. ;
  262.      IF    APPLIED
  263.     DB    'Applied Engineering'
  264.      ENDIF            ; APPLIED
  265. ;
  266.      IF    MICROSOFT
  267.     DB    'CP/M 2.2 Card'
  268.      ENDIF            ; MICROSOFT
  269. ;
  270.     DB    CR,LF
  271. ;
  272.     DB    ' Z80C ',CR,LF
  273.     DB    0
  274.     RET
  275. ;.....
  276. ;
  277. ;
  278. ;-----------------------------------------------------------------------
  279. ;
  280. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  281. ;     end of your last routine should terminate by 0400H (601 bytes
  282. ;     available after start of SYSVER).
  283. ;
  284. ;-----------------------------------------------------------------------
  285. ;
  286. ; You can put in a message at this location which can be called up with
  287. ; (special character-L).  You can put in several lines.  End with a 0.
  288. ;
  289. LOGON:    DB    'Hello there from a happy computer user',CR,0
  290. ;
  291. ;-----------------------------------------------------------------------
  292. ;
  293. ; This routine sets a 300 ms break tone
  294. ;
  295. SENDBRK:
  296.     MVI    A,0FH        ; DTR normal, send break tone
  297.     JMP    GOODBYE+2    ; Send the break tone
  298. ;.....
  299. ;
  300. ;
  301. ; This routine sets DTR low for 300 ms to disconnect the modem.
  302. ;
  303. GOODBYE:
  304.     MVI    A,0EH        ; Turn off DTR and send break
  305.     CALL    SNDCTL2
  306.     MVI    B,3        ; Delay 300 ms to hang up phone
  307.     CALL    J$TIMER
  308.     MVI    A,0BH        ; Set DTR, Rx, Irq
  309.     CALL    SNDCTL2
  310.     XTHL            ; Short delay to complete command
  311.     XTHL
  312.     RET
  313. ;.....
  314. ;
  315. ;
  316. ;=========================== INITMOD ===================================
  317. ;
  318. ;
  319. INITMOD: IF    ALSCARD
  320.     LHLD    1        ; Initialize our local jumps to the BIOS
  321.     LXI    D,60H
  322.     DAD    D
  323.     SHLD    APREAD+1
  324.     INX    H
  325.     INX    H
  326.     INX    H
  327.     SHLD    APWRITE+1
  328.     RET
  329.      ENDIF            ; ALSCARD
  330. ;.....
  331. ;
  332. ;
  333.     MVI    A,0BH        ; Set DTR, Rx, Irq
  334.     CALL    SNDCTL2
  335.     XTHL            ; Short delay to complete command
  336.     XTHL
  337. ;
  338.     LDA    MSPEED        ; Get the selected value
  339.     CPI    1        ; 300 bps
  340.     JZ    OK300
  341.     CPI    5        ; 1200 bps
  342.     JZ    OK1200
  343.     CPI    6        ; 2400 bps
  344.     JZ    OK2400
  345.     CPI    8        ; 9600 bps
  346.     JZ    OK9600
  347.     JMP    STUPR1        ; Else ask what is wanted
  348. ;.....
  349. ;
  350. ;
  351. INITMOD1:
  352.     MOV    A,B        ; Get the baudrate back
  353.     CALL    SNDCTL3        ; Store default baudrate
  354.     XTHL            ; Short delay to complete command
  355.     XTHL
  356.     RET
  357. ;.....
  358. ;
  359. ;
  360. ; If none of the above cards
  361. ;
  362.     RET            ; From 'CALL INITMOD'
  363.     RET
  364. ;.....
  365. ;
  366. ;
  367. ;========================== APPLE I/O ==================================
  368. ;
  369.      IF    APPLIED    OR MICROSOFT
  370. SNDCTL1:STA    MDCTL1
  371.     RET
  372. ;
  373. SNDDATP:STA    MDDATP
  374.     RET
  375. ;
  376. RCVCTL1:LDA    MDCTL1
  377.     RET
  378. ;
  379. RCVDATP:LDA    MDDATP
  380.     RET
  381. ;.....
  382. ;
  383. ;
  384. RCVCTL3: LDA    MDCTL3
  385.      RET
  386. ;
  387. SNDCTL2: STA    MDCTL2
  388.      RET
  389. ;
  390. SNDCTL3: STA    MDCTL3
  391.      RET
  392.       ENDIF            ; APPLIED OR MICROSOFT
  393. ;.....
  394. ;
  395. ;
  396.       IF    ALSCARD
  397. SNDCTL1: PUSH    H
  398.      LXI    H,MDCTL1
  399.      JMP    POKE
  400. ;
  401. SNDDATP: PUSH    H
  402.      LXI    H,MDDATP
  403. ;
  404. POKE:     PUSH    D
  405.      PUSH    B
  406.      CALL    APWRITE
  407.      POP    B
  408.      POP    D
  409.      POP    H
  410.      RET
  411.       ENDIF            ; ALSCARD
  412. ;.....
  413. ;
  414. ;
  415.       IF    ALSCARD
  416. RCVCTL1: PUSH    H
  417.      LXI    H,MDCTL1
  418.      JMP    PEEK
  419. ;
  420. RCVDATP: PUSH    H
  421.      LXI    H,MDDATP
  422. ;
  423. PEEK:     PUSH    D
  424.      PUSH    B
  425.      CALL    APREAD
  426.      POP    B
  427.      POP    D
  428.      POP    H
  429.      RET
  430. ;.....
  431. ;
  432. ;
  433. ; These are the jump locations to the ALS BIOS
  434. ;
  435. APREAD:     JMP    $-$
  436. APWRITE: JMP    $-$
  437.       ENDIF            ; ALSCARD
  438. ;.....
  439. ;
  440. ;
  441.       IF    APPLICARD    ;
  442. RDBYTE     EQU    0FFE0H        ; Read 1 byte frin Aooke (A = byte)
  443. WRBYTE     EQU    0FFE3H        ; Write 1 byte to Apple (C = byte)
  444. RDWORD     EQU    0FFE6H        ; Read 2 bytes from Apple (DE = word)
  445. WRWORD     EQU    0FFE9H        ; Write 2 bytes to Apple (DE = word)
  446. PEEK1     EQU    6        ; Command
  447. POKE1     EQU    7        ; Command
  448. ;
  449. SNDCTL1: PUSH    D
  450.      LXI    D,MDCTL1
  451.      JMP    POKE
  452. ;
  453. SNDDATP: PUSH    D
  454.      LXI    D,MDDATP
  455. ;
  456. POKE:     PUSH    B
  457.      MOV    B,A
  458.      MVI    C,POKE1
  459.      CALL    WRBYTE
  460.      CALL    WRWORD
  461.      MOV    C,B
  462.      CALL    WRBYTE
  463.      POP    B
  464.      POP    D
  465.      RET
  466. ;...
  467. ;
  468. ;
  469. RCVCTL1: PUSH    D
  470.      LXI    D,MDCTL1
  471.      JMP    PEEK
  472. ;
  473. RCVDATP: PUSH    D
  474.      LXI    D,MDDATP
  475. ;
  476. PEEK:     PUSH    B
  477.      MVI    C,PEEK1
  478.      CALL    WRBYTE
  479.      CALL    WRWORD
  480.      CALL    RDBYTE
  481.      POP    B
  482.      POP    D
  483.      RET
  484. ;.....
  485. ;
  486. ;
  487. SNDCTL2:PUSH    D
  488.     LXI    D,MDCTL2
  489.     JMP    POKE
  490. ;
  491. SNDCTL3:PUSH    D
  492.     LXI    D,MDCTL3
  493.     JMP    POKE
  494.       ENDIF            ; APPLICARD
  495. ;.....
  496. ;
  497. ;
  498. ;-----------------------------------------------------------------------
  499. ;
  500. ; Use the 'SET' command to select a desired baud rate
  501. ;
  502. STUPR    EQU    $
  503.     CALL    J$CMDSPL    ; Gives us CMDBUF+6
  504.     JNC    STUPR2
  505. ;
  506. STUPR1:    CALL    J$ILPRT
  507.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  508.     LXI    D,BAUDBUF    ; Point to new input buffer
  509.     CALL    J$INBUF
  510.     CALL    J$CRLF
  511.     LXI    D,BAUDBUF+2
  512. ;
  513. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  514.     DB    '300',0
  515.     JNC    OK300        ; Go if got match
  516.     CALL    J$INLNCP
  517.     DB    '1200',0
  518.     JNC    OK1200
  519.     CALL    J$INLNCP
  520.     DB    '2400',0
  521.     JNC    OK2400
  522.     CALL    J$INLNCP
  523.     DB    '9600',0
  524.     JNC    OK9600
  525.     CALL    J$ILPRT        ; All matches failed, tell operator
  526.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  527.     JMP    STUPR1        ; Try again
  528. ;
  529. OK300:    MVI    A,1        ; MSPEED 300 baud value
  530.     MVI    B,BD300        ; Get 300 baud value for 2651 in 'B'
  531.     JMP    LOADBD        ; Go load everything
  532. ;
  533. OK1200:    MVI    A,5
  534.     MVI    B,BD1200
  535.     JMP    LOADBD
  536. ;
  537. OK2400:    XRA    A
  538.     STA    MANUAL
  539.     MVI    A,6
  540.     MVI    B,BD2400
  541.     JMP    LOADBD
  542. ;
  543. OK9600:    MVI    A,8
  544.     MVI    B,BD9600
  545. ;
  546. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  547.     JMP    INITMOD1    ; Reset to new baudrate
  548. ;.....
  549. ;
  550. ;
  551. ; Table of baud rate parameters
  552. ;
  553. BD300    EQU    22
  554. BD1200    EQU    24
  555. BD2400    EQU    26
  556. BD9600    EQU    30
  557. ;
  558. BAUDBUF:DB    10,0,0,0,0,0
  559.     DB    0,0,0,0,0,0
  560. ;.....
  561. ;
  562. ;
  563. ;-----------------------------------------------------------------------
  564. ; NOTE: Must terminate prior to 0400H
  565.