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 / BEEHIVE / COMMS / IMP-ICE.ARC / I2AP.ASM next >
Assembly Source File  |  1990-09-20  |  12KB  |  427 lines

  1. ; I2AP-1A.ASM - Apple ][ overlay file for IMP - 07/27/85
  2. ;
  3. ; This overlay file adapts Apple // computers with PCPI Applicard character
  4. ; driver 2 connected to a serial device;
  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. ;
  9. ; Edit this file for your preferences then follow the "TO USE:" example
  10. ; shown below.
  11. ;
  12. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  13. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  14. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  15. ; (The ESC will automatically be typed with no CTL-character present.)
  16. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  17. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  18. ; looking at the function key table, typing CTL-Z in command mode, etc.
  19. ;
  20. ; Use the "SET" command to change the baudrate when desired.  The value
  21. ; at MSPEED controls the baudrate when the program is first called up.
  22. ;
  23. ;    TO USE: First edit this file filling in answers for your own
  24. ;        equipment.  Then assemble with ASM.COM or equivalent
  25. ;        assembler.  Then use MLOAD to merge into the main file:
  26. ;
  27. ;        MLOAD IMP.COM=IMP.COM,I2AP-x.HEX
  28. ;
  29. ; =  =    =  =  =  =  =  =  =  =    =  =  =  =  =  =  =  =    =  =  =  =  =  =
  30. ;
  31. ; 04/24/87 - Applicard driver support rewrite    - Ken Lau
  32. ; 07/17/85 - Written to work with IMP        - Irv Hoff
  33. ;
  34. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  35. ;
  36. ;
  37. YES    EQU    0FFH
  38. NO    EQU    0
  39. ;
  40. ;-----------------------------------------------------------------------
  41. ;
  42. DEVNO    EQU    2    ; Character driver device number (Applicard)
  43. ;
  44. ;-----------------------------------------------------------------------
  45. ;
  46. ESC    EQU    '['-40H    ; ^[ = Escape
  47. BELL    EQU    'G'-40H    ; ^G = Bell character
  48. LF    EQU    'J'-40H    ; ^J = Linefeed
  49. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  50. CR    EQU    'M'-40H    ; ^M = Carriage return
  51. CLEARSC    EQU    'Z'-40H    ; ^Z = Clear screen, command mode only
  52. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  53. ;
  54. ;
  55. ;=======================================================================
  56. ;
  57. ;
  58.     ORG    0100H
  59. ;
  60. ;
  61.     DS    3    ; Skip the data area below
  62. ;
  63. ;
  64. ; These routines and equates are at the beginning of the program so
  65. ; they can be patched by a monitor or overlay file without re-assembling
  66. ; the program.
  67. ;
  68. MSPEED:     DB    1    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  69.             ; 6=2400 7=4800 8=9600 9=19200 default
  70. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  71. HS1200:     DB    NO    ; Yes=1200 bps highest speed            105H
  72. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  73. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  74. RESVD1:     DB    NO    ; Reserved for special modems            108H
  75. RESVD2:     DB    NO    ; Reserved for special modems            109H
  76. ;
  77. ;
  78. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  79. ;
  80. ;
  81. CLOCK:     DB    2    ; Clock speed in MHz, 25.5 MHz max.        10BH
  82.             ; NOTE:  DO NOT MULTIPLY BY 10 FOR APPLICARD
  83. ;
  84. ;
  85.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  86. BYTDLY:     DB    9    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  87.             ;   default time to send character in ter-
  88.             ;   minal mode file transfer for slow BBS
  89. CRDLY:     DB    9    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  90.             ;   default time for extra wait after CRLF
  91.             ;   in terminal mode file transfer
  92. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  93. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  94. ;.....
  95. ;
  96. ;
  97. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  98.             ;   mode (normally added by remote echo)
  99. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  100. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  101. IGNRCTL: DB    NO    ; Yes=CTL-chars above ^M not displayed        113H
  102. ;.....
  103. ;
  104. ;
  105. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  106. EXITCHR: DB    'E'    ; Exit character                115H
  107. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  108. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  109. LOGCHR:     DB    'L'    ; Send logon                    118H
  110. LSTCHR:     DB    'P'    ; Toggle printer                119H
  111. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  112. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  113. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  114. SPARE1:     DB    0    ; For future development            11DH
  115. SPARE2:     DB    0    ; For future development            11EH
  116. ;.....
  117. ;
  118. ;
  119. ; Handles in/out ports for data and status
  120. ;
  121. I$MDCTL1: JMP    RCVCTL1        ; In modem control port         11FH
  122.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  123. ;
  124. I$MDTXE:  JMP    RCVCTL1        ;                    129H
  125.       DB    0,0,0,0,0,0,0    ;                    12CH
  126. ;
  127. I$MDDATP: JMP    RCVDATP        ;in modem data port            133H
  128.       DB    0,0,0,0,0,0,0    ;                    146H
  129. ;
  130. O$MDDATP: JMP    SNDDATP        ; Out modem data port            13DH
  131.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  132. ;.....
  133. ;
  134. ;
  135. A$MDRCV:  ANI    2        ;                    147H
  136.       RET            ;                    149H
  137. ;
  138. C$MDRCV:  CPI    2        ;                    14AH
  139.       RET            ;                    14CH
  140. ;
  141. A$MDSND:  ANI    1        ;                    14DH
  142.       RET            ;                    14FH
  143. ;
  144. C$MDSND:  CPI    1        ;                    150H
  145.       RET            ;                    152H
  146. ;
  147. A$MDTXE:  ANI    1        ;                    153H
  148.       RET            ;                    155H
  149. ;
  150. C$MDTXE:  CPI    1        ;                    156H
  151.       RET            ;                    158H
  152. ;.....
  153. ;
  154. ;
  155. ; Special exit vector, used by some computers to reset interrupt vectors
  156. ;
  157. J$EXITVEC:RET            ;                    159H
  158.       DB    0,0        ;                    15AH
  159. ;.....
  160. ;
  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. ;
  170. ;
  171. ; "AT" command strings, can be replaced in individual overlay if needed
  172. ;
  173. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  174. J$STRNG1: DS    3        ; 2400 bps "AT" string            16B:IMP
  175. ;
  176. ;
  177. ; Next fourteen lines should not be changed by user overlay as these go
  178. ; to specific locations in the main program, not in the overlay.
  179. ;
  180. ;
  181. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  182. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  183. J$DIAL:      DS    3        ; Start of dialing routine        174H
  184. J$DSCONT: DS    3        ; Terminates modem use            177H
  185. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  186. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  187. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  188. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  189. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  190. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  191. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  192. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  193. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  194. J$NEW1:      DB    0,0,0        ; For future needs            195H
  195. J$NEW2:      DB    0,0,0        ; For future needs            198H
  196. ;.....
  197. ;
  198. ;
  199. ; For 2400 bps auto-stepdown units
  200. ;
  201. MANUAL:      DB    0        ; For manual selection flag        19BH
  202. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  203. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  204. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  205. ;.....
  206. ;
  207. ;
  208. LOGPTR:    DW    LOGON        ; Pointer to display LOGON message    1A5H
  209. ;
  210. SYSVR:    CALL    J$ILPRT        ; Display the following line        1A7H
  211.     DB    'Apple // and '    ;
  212.     DB    'Applicard '
  213.     DB    'with device ', devno+30h,CR,LF
  214.     DB    0
  215.     RET
  216. ;
  217. ;-----------------------------------------------------------------------
  218. ;
  219. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  220. ;     end of your last routine should terminate by 0400H (601 bytes
  221. ;     available after start of SYSVER).
  222. ;
  223. ;-----------------------------------------------------------------------
  224. ;
  225. ; You can put in a message at this location which can be called up with
  226. ; (special character-L).  You can put in several lines.  End with a 0.
  227. ;
  228. LOGON:    DB    'Hello there from an Apple computer user',CR,0
  229. ;
  230. ;-----------------------------------------------------------------------
  231. ;
  232. ; This routine sets DTR low for 1 second to disconnect the phone
  233. ;
  234. GOODBYE    EQU    $
  235. ;
  236.     CALL    INITMOD1
  237.     LXI    H,GBSTR
  238.     CALL    J$SNDSTR
  239.     RET
  240.  
  241. GBSTR    DB    'ATH0',CR,'$'
  242. ;
  243. ;
  244. ;=========================== INITMOD ===================================
  245. ;
  246. ;
  247. INITMOD    JMP    INITMOD2    ; Patched to INIMOD3 after the first time
  248.  
  249. INITMOD2 LHLD    J$DIAL+1    ; Hook in NEWDIAL routine
  250.     SHLD    NEWDIALJ+1
  251.     LXI    H,NEWDIAL
  252.     SHLD    J$DIAL+1
  253.     LXI    H,INITMOD3    ; Patch INITMOD to not install hook again
  254.     SHLD    INITMOD
  255.  
  256. INITMOD3 JMP    OK300        ; 300 bps
  257.  
  258. INITMOD1 JMP    INITSER        ; Initialize driver (prepare to AT)
  259. ;
  260. ;
  261. ; Dial routine hook (to reset modem)
  262. NEWDIAL    CALL    INITMOD1
  263. NEWDIALJ JMP    0400H        ; to be patched
  264. ;
  265. ;========================== APPLE I/O ==================================
  266. ;-------- SIO --------
  267. ;Games serial driver. Mar 87. Ken Lau.
  268. ;Boot disk must have GAMESER.DVR installed.
  269. ;Main routines: initser, sistat, sostat, serin, serout
  270.  
  271. ;Input byte from Apple/Starcard port --> [A]
  272. AINP    IN    40h
  273.     RLC
  274.     JNC    AINP
  275.     IN    20h
  276.     RET
  277.  
  278. ;Output [A] --> Apple/Starcard port
  279. AOUT    PUSH    PSW
  280. AOUT1    IN    40h
  281.     RRC
  282.     JC    AOUT1
  283.     POP    PSW
  284.     OUT    0
  285.     RET
  286.  
  287. ;Initialize serial port
  288. initser    push    psw
  289.     mvi    a,devno*4+0C0h
  290.     call    aout
  291.     call    ainp    ;dummy
  292.     pop    psw
  293.     ret
  294.  
  295. ;Returns status of serial in port. NZ if data waiting. A corrupted
  296. sistat    mvi    a,devno*4+0C3h
  297.     call    aout
  298.     mvi    a,1
  299.     call    aout
  300.     call    ainp
  301.     ora    a
  302.     ret    
  303.  
  304. ;Returns status of serial out port. NZ if ready to send. A corrupted
  305. sostat    mvi    a,devno*4+0C3h
  306.     call    aout
  307.     mvi    a,0
  308.     call    aout
  309.     call    ainp
  310.     ora    a
  311.     ret
  312.  
  313. ;Send [A]
  314. serout    push    psw
  315. serout1    mvi    a,devno*4+0C2h
  316.     call    aout
  317.     pop    psw
  318.     jmp    aout
  319.  
  320. ;Receive byte --> [A]
  321. serin    mvi    a,devno*4+0C1h
  322.     call    aout
  323.     jmp    ainp
  324.  
  325. ;-------- END SIO --------
  326. ;
  327. SNDDATP    EQU    SEROUT
  328. ;
  329. RCVDATP    EQU    SERIN
  330. ;
  331. RCVCTL1    PUSH    B    ;FORM 'CONTROL PORT BYTE'.
  332.     CALL    SISTAT    ;BIT 1 = 1 IF SERIN RECEIVED
  333.     MOV    B,A    ;BIT 0 = 1 IF SEROUT EMPTY
  334.     JZ    RCVCTL2
  335.     MVI    B,2
  336. RCVCTL2    CALL    SOSTAT
  337.     JZ    RCVCTL3
  338.     MVI    A,1
  339. RCVCTL3    ORA    B
  340.     POP    B
  341.     RET
  342. ;
  343. ;
  344. ;-----------------------------------------------------------------------
  345. ;
  346. ;
  347. ; Use the 'SET' command to select a desired baud rate
  348. ;
  349. STUPR    CALL    J$CMDSPL    ; Gives up CMDBUF+6
  350.     JNC    STUPR2
  351. ;
  352. STUPR1:    CALL    J$ILPRT
  353.     DB    'Input Baud Rate (75, 300, 300 BELL, 1200, TURN LINE): ',0
  354.     LXI    D,BAUDBUF    ; Point to new input buffer
  355.     CALL    J$INBUF
  356.     CALL    J$CRLF
  357.     LXI    D,BAUDBUF+2
  358. ;
  359. STUPR2    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars below
  360.     DB    '75',0
  361.     JNC    OK75P
  362.     CALL    J$INLNCP
  363.     DB    '300 BELL',0
  364.     JNC    OK300BE
  365.     CALL    J$INLNCP
  366.     DB    '300',0
  367.     JNC    OK300        ; Go if match
  368.     CALL    J$INLNCP
  369.     DB    '1200',0
  370.     JNC    OK1200P
  371.     CALL    J$INLNCP
  372.     DB    'TURN LINE',0
  373.     JNC    OKTURN
  374.     CALL    J$ILPRT        ; All matches failed, tell operator
  375.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  376.     JMP    STUPR1
  377. ;
  378. OK75P    CALL    J$ILPRT
  379.     DB    'Transmit Modem speed is: 75 bps',CR,LF,'Receive ',0
  380. OK75    LXI    H,OK75AT
  381.     MVI    A,5
  382.     JMP    LOADBD
  383. OK75AT    DB    'AT*',81H,'2B',CR,'$'    ;AutoIce command
  384.  
  385. OK300    LXI    H,OK300AT
  386.     MVI    A,1
  387.     JMP    LOADBD
  388. OK300AT    DB    'AT*',81H,'6B',CR,'$'    ;AutoIce command
  389.  
  390. OK300BE    LXI    H,OK300BA
  391.     MVI    A,1
  392.     JMP    LOADBD
  393. OK300BA    DB    'AT*',81H,'5B',CR,'$'    ;AutoIce command
  394.  
  395. OK1200P    CALL    J$ILPRT
  396.     DB    'Receive Modem speed is: 75 bps',CR,LF,'Transmit ',0
  397. OK1200    LXI    H,OK1200A
  398.     MVI    A,5
  399.     JMP    LOADBD
  400. OK1200A    DB    'AT*',81H,'8B',CR,'$'    ;AutoIce command
  401.  
  402. OKTURN    LXI    H,OKTURNA
  403.     MVI    A,5
  404.     JMP    LOADBD
  405. OKTURNA    DB    'AT*',81H,'0B',CR,'$'    ;AutoIce command
  406.  
  407. OK2400
  408. OK4800
  409. OK9600    RET
  410.  
  411. LOADBD    STA    MSPEED    ; Change time-to-send to match baudrate
  412.     PUSH    H
  413.     CALL    INITMOD1
  414.     POP    H
  415.     CALL    J$SNDSTR
  416.     RET
  417. ;
  418. BAUDBUF    DB    10,0,0,0,0,0
  419.     DB    0,0,0,0,0,0
  420. ;
  421. ;-----------------------------------------------------------------------
  422. ;
  423. ; NOTE: Must terminate prior to 0400H
  424. ;
  425.     END
  426. 
  427. ;------------------------------------