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 / I2GS-2.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  416 lines

  1.  
  2. ;    I2GS-2.ASM - Apple IIGS overlay file for IMP - 07/17/88
  3. ;
  4. ;    Internal Zilog 8530 SCC Serial Communications Controller
  5. ;
  6. ; This overlay file adapts Apple IIGS computers with a PCPI Applicard
  7. ; and external 300/1200 or 300/1200/2400 bps modems to IMP.COM.
  8. ;
  9. ;-----------------------------------------------------------------------
  10. ;
  11. ; You will want to look this file over carefully.  There are a number of
  12. ; options that you can use to configure the program to suit your taste.
  13. ;
  14. ; Edit this file for your preferences then follow the "TO USE:" example
  15. ; shown below.
  16. ;
  17. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  18. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  19. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  20. ; (The ESC will automatically be typed with no CTL-character present.)
  21. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  22. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  23. ; looking at the function key table, typing CTL-Z in command mode, etc.
  24. ;
  25. ; Use the "SET" command to change the baudrate when desired.  The value
  26. ; at MSPEED controls the baudrate when the program is first called up.
  27. ;
  28. ;    TO USE: First edit this file filling in answers for your own
  29. ;        equipment.  Then assemble with ASM.COM or equivalent
  30. ;        assembler.  Then use MLOAD to merge into the main file:
  31. ;
  32. ;        MLOAD IMP.COM=IMP.COM,I2GS-2.HEX
  33. ;
  34. ;                    - Notes by Irv Hoff W6FFC
  35. ;
  36. ; =   =  =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  37. ;
  38. ; 07/17/88  Written for the Apple IIGS    - John Wolf
  39. ;        Heavily modified from Irv Hoff's //c overlay
  40. ;
  41. ; =   =  =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  42. ;
  43. YES    EQU    0FFH
  44. NO    EQU    0
  45. ;
  46. ;====================== CUSTOMIZATION EQUATES ==========================
  47. ;
  48. PEEKCMD    EQU    06H
  49. POKECMD    EQU    07H
  50. RDBYTE    EQU    0FFE0H
  51. WRBYTE    EQU    0FFE3H
  52. WRWORD    EQU    0FFE9H
  53. ;
  54. SLOT1    EQU    NO        ; Yes for slot 1
  55. SLOT2    EQU    YES        ; Yes for slot 2
  56. ;
  57.      IF    SLOT1
  58. MDCMD    EQU    0C039H        ; Address of command port A
  59.      ENDIF
  60. ;
  61.      IF    SLOT2
  62. MDCMD    EQU    0C038H        ; Address of command port B
  63.      ENDIF
  64. ;
  65. MDDATP    EQU    MDCMD+2        ; Address of data port
  66. MDRXF    EQU    01H        ; Receive register full bit
  67. MDTXE    EQU    04H        ; Transmit register empty bit
  68. MDSND    EQU    04H        ; Same as TXE
  69. ;
  70. ;-----------------------------------------------------------------------
  71. ;
  72. ; General equates
  73. ;
  74. ESC    EQU    '['-40H        ; ^[ = Escape
  75. BELL    EQU    'G'-40H        ; ^G = Bell character
  76. LF    EQU    'J'-40H        ; ^J = Linefeed
  77. NEXTRY    EQU    'K'-40H        ; ^K = Try next phone number now
  78. CR    EQU    'M'-40H        ; ^M = Carriage return
  79. CLEARSC    EQU    'Z'-40H        ; ^Z = Clear screen, command mode only
  80. EOFCHAR    EQU    'Z'-40H        ; ^Z = End of file
  81. ;
  82. ;-----------------------------------------------------------------------
  83. ;
  84.     ORG    0100H
  85. ;
  86.     DS    3    ; Skip the data area below
  87. ;
  88. ; These routines and equates are at the beginning of the program so
  89. ; they can be patched by a monitor or overlay file without re-assembling
  90. ; the program.
  91. ;
  92. MSPEED:     DB    6    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  93.             ; 6=2400 7=4800 8=9600 9=19200 default
  94. ;
  95. HS2400:     DB    YES    ; Yes=2400 bps highest speed            104H
  96. HS1200:     DB    NO    ; Yes=1200 bps highest speed            105H
  97. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  98. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  99. RESVD1:     DB    NO    ; Reserved for special modems            108H
  100. RESVD2:     DB    NO    ; Reserved for special modems            109H
  101. ;
  102. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  103. CLOCK:     DB    6    ; Clock speed in MHz, 25.5 MHz max.        10BH
  104.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  105. BYTDLY:     DB    0    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  106.             ;   default time to send character in ter-
  107.             ;   minal mode file transfer for slow BBS
  108. CRDLY:     DB    5    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  109.             ;   default time for extra wait after CRLF
  110.             ;   in terminal mode file transfer
  111. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  112. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  113. ;
  114. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  115.             ;   mode (normally added by remote echo)
  116. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  117. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  118. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  119. ;
  120. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  121. EXITCHR: DB    'E'    ; Exit character                115H
  122. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  123. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  124. LOGCHR:     DB    'L'    ; Send logon                    118H
  125. LSTCHR:     DB    'P'    ; Toggle printer                119H
  126. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  127. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  128. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  129. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  130. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  131. ;
  132. ; Handles in/out ports for data and status
  133. ;
  134. I$MDRXF:  JMP    RCVCMD        ; Test for receive reg full        11FH
  135.       DB    0,0,0,0,0,0,0    ; Spares if needed            123H
  136. ;
  137. I$MDTXE:  JMP    RCVCMD        ; Test for transmit reg empty        129H
  138.       DB    0,0,0,0,0,0,0    ;                    12DH
  139. ;
  140. I$MDDATP: JMP    RCVDATP        ; In modem data port            133H
  141.       DB    0,0,0,0,0,0,0    ;                    147H
  142. ;
  143. O$MDDATP: JMP    SNDDATP        ; Out modem data port            13DH
  144.       DB    0,0,0,0,0,0,0    ;                    140H
  145. ;
  146. A$MDRXF:  ANI    MDRXF        ;                    147H
  147.       RET            ;                    149H
  148. ;
  149. C$MDRXF:  CPI    MDRXF        ;                    14AH
  150.       RET            ;                    14CH
  151. ;
  152. A$MDSND:  ANI    MDSND        ;                    14DH
  153.       RET            ;                    14FH
  154. ;
  155. C$MDSND:  CPI    MDSND        ;                    150H
  156.       RET            ;                    152H
  157. ;
  158. A$MDTXE:  ANI    MDTXE        ;                    153H
  159.       RET            ;                    155H
  160. ;
  161. C$MDTXE:  CPI    MDTXE        ;                    156H
  162.       RET            ;                    158H
  163. ;
  164. ; Special exit vector, used by some computers to reset interrupt vectors
  165. ;
  166. J$EXITVEC:RET            ;                    159H
  167.       DB    0,0        ;                    15AH
  168. ;
  169. ; Jump vectors needed by each overlay
  170. ;
  171. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  172. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  173. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  174. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  175. ;
  176. ; "AT" command strings, can be replaced in individual overlay if needed
  177. ;
  178. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  179. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  180. ;
  181. ; Next fourteen lines should not be changed by user overlay as these go
  182. ; to specific locations in the main program, not in the overlay.
  183. ;
  184. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  185. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  186. J$DIAL:      DS    3        ; Start of dialing routine        174H
  187. J$DSCONT: DS    3        ; Terminates modem use            177H
  188. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  189. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  190. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  191. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  192. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  193. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  194. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  195. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  196. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  197. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  198. J$NEW2:      DB    0,0,0        ; For future needs            198H
  199. ;
  200. ; For 2400 bps auto-stepdown units
  201. ;
  202. MANUAL:      DB    NO        ; YES if manual stepdown            19BH
  203. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  204. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  205. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  206. ;
  207. LOGPTR:    DW    LOGON        ; Pointer to display LOGON message    1A5H
  208. ;
  209. SYSVR:    CALL    J$ILPRT        ; Display the following line        1A7H
  210. ;
  211.     DB    'Apple IIGS and PCPI Applicard'
  212.     DB    CR,LF,0
  213.     RET
  214. ;
  215. ;-----------------------------------------------------------------------
  216. ;
  217. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  218. ;     end of your last routine should terminate by 0400H (601 bytes
  219. ;     available after start of SYSVER).
  220. ;
  221. ;-----------------------------------------------------------------------
  222. ;
  223. ; You can put in a message at this location which can be called up with
  224. ; (special character-L).  You can put in several lines.  End with a 0.
  225. ;
  226. LOGON:    DB    'Basselopes eat Poptarts (with butter!)',CR,0
  227. ;
  228. ;======================== BREAK/GOODBYE ===============================
  229. ;
  230. SENDBRK:MVI    A,5
  231.     CALL    SNDCMD
  232.     MVI    A,01111010B    ; DTR on, BRK on
  233.     JMP    GOBRK
  234. ;
  235. GOODBYE:MVI    A,5
  236.     CALL    SNDCMD
  237.     MVI    A,11111010B    ; DTR off, BRK on
  238. GOBRK:    CALL    SNDCMD        ; Set register 5
  239.     MVI    B,3
  240.     CALL    J$TIMER
  241.     MVI    A,5
  242.     CALL    SNDCMD
  243.     MVI    A,01101010B    ; DTR on, BRK off
  244.     JMP    SNDCMD        ; Set register 5
  245. ;
  246. ;=========================== INITMOD ===================================
  247. ;
  248. INITMOD:PUSH    H
  249.     LXI    H,BITS        ; Get table address
  250. LOOP:    MOV    A,M        ; Get reg number
  251.     ORA    A
  252.     JZ    DONE        ; Zero is end
  253.     CALL    SNDCMD
  254.     INX    H
  255.     MOV    A,M        ; Get reg value
  256.     CALL    SNDCMD
  257.     INX    H
  258.     JMP    LOOP
  259. DONE:    POP    H
  260.     LDA    MSPEED        ; Autoset baudrate
  261.     CPI    1
  262.     JZ    OK300
  263.     CPI    5
  264.     JZ    OK1200
  265.     CPI    6
  266.     JZ    OK2400
  267.     CPI    7
  268.     JZ    OK4800
  269.     CPI    8
  270.     JZ    OK9600
  271.     JMP    STUPR1        ; Bad value in overlay, ask
  272. ;
  273. BITS:     IF    SLOT1
  274.     DB    09,10000000B    ; Reset channel A
  275.      ENDIF
  276.      IF    SLOT2
  277.     DB    09,01000000B    ; Reset channel B
  278.      ENDIF
  279.     DB    11,11010000B    ; Set xtal on RTxC and Rx-Tx to BR gen
  280.     DB    12,2EH        ; Low byte of BR generator
  281.     DB    13,00H        ; High byte of baud
  282.     DB    14,00000001B    ; Enable BR generator
  283.     DB    15,00000000B    ; Kill interrupts
  284.     DB    01,00000000B    ; Kill Rx-Tx interrupts
  285.     DB    03,11000001B    ; Rx-8bit, Rx on
  286.     DB    04,01000100B    ; X16 clock, 1 stop, no parity
  287.     DB    05,01101010B    ; Tx-8bit, Tx on, DTR on, BRK off
  288.     DB    0
  289. ;
  290. ;========================== APPLE I/O ==================================
  291. ;
  292. SNDCMD:    PUSH    D
  293.     LXI    D,MDCMD
  294.     JMP    POKE
  295. ;
  296. SNDDATP:PUSH    D
  297.     LXI    D,MDDATP
  298. POKE:    PUSH    B
  299.     MOV    B,A
  300.     MVI    C,POKECMD
  301.     CALL    WRBYTE
  302.     CALL    WRWORD
  303.     MOV    C,B
  304.     CALL    WRBYTE
  305.     POP    B
  306.     POP    D
  307.     RET
  308. ;
  309. RCVCMD:    PUSH    D
  310.     LXI    D,MDCMD
  311.     JMP    PEEK
  312. ;
  313. RCVDATP:PUSH    D
  314.     LXI    D,MDDATP
  315. PEEK:    PUSH    B
  316.     MVI    C,PEEKCMD
  317.     CALL    WRBYTE
  318.     CALL    WRWORD
  319.     CALL    RDBYTE
  320.     POP    B
  321.     POP    D
  322.     RET
  323. ;
  324. ;============================ STUPR ====================================
  325. ;
  326. ; Use the 'SET' command to select a desired baud rate
  327. ;
  328. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  329.     JNC    STUPR2
  330. ;
  331. STUPR1:    CALL    J$ILPRT
  332.     DB    'Input Baud Rate (300, 1200, 2400, 4800, 9600): ',0
  333.     LXI    D,BAUDBUF    ; Point to new input buffer
  334.     CALL    J$INBUF
  335.     CALL    J$CRLF
  336.     LXI    D,BAUDBUF+2
  337. ;
  338. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  339.     DB    '300',0
  340.     JNC    OK300        ; Go if got match
  341.     CALL    J$INLNCP
  342.     DB    '1200',0
  343.     JNC    OK1200
  344.     CALL    J$INLNCP
  345.     DB    '2400',0
  346.     JNC    OK2400
  347.     CALL    J$INLNCP
  348.     DB    '4800',0
  349.     JNC    OK4800
  350.     CALL    J$INLNCP
  351.     DB    '9600',0
  352.     JNC    OK9600
  353.     CALL    J$ILPRT        ; All matches failed, tell operator
  354.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  355.     JMP    STUPR1        ; Try again
  356. ;
  357. OK300:    MVI    A,1
  358.     MVI    B,7EH        ; Baud value for 300 is actually 17EH
  359.     JMP    LOADBD        ; Taken care of in LOADBD
  360. ;
  361. OK1200:    MVI    A,5
  362.     MVI    B,5EH        ; Baud rate values same as Apple's
  363.     JMP    LOADBD
  364. ;
  365. OK2400:    MVI    A,6
  366.     MVI    B,2EH
  367.     JMP    LOADBD
  368. ;
  369. OK4800:    MVI    A,7
  370.     MVI    B,16H
  371.     JMP    LOADBD
  372. ;
  373. OK9600:    MVI    A,8
  374.     MVI    B,0AH
  375. ;
  376. LOADBD:    STA    MSPEED        ; Save baud rate
  377.     MVI    A,12
  378.     CALL    SNDCMD
  379.     MOV    A,B
  380.     CALL    SNDCMD
  381.     MVI    A,13
  382.     CALL    SNDCMD
  383.     LDA    MSPEED
  384.     CPI    1
  385.     JZ    ONE
  386.     XRA    A
  387. ONE:    JMP    SNDCMD
  388. ;
  389. BAUDBUF:DB    10,0,0,0,0,0
  390.     DB    0,0,0,0,0,0
  391. ;
  392. ;-----------------------------------------------------------------------
  393. ;
  394. ; Pinout and cabling for GS serial port
  395. ;      _________
  396. ;    /      \ /     \    Apple IIgs Serial port as seen from rear of
  397. ;   / (8) (7) (6) \    computer. Note: these ports are RS422, to
  398. ;  /           \    make them compatible with RS232 devices
  399. ; <  (5)   (4) (3)  >    pin 8 must connect to pin 4 (ground.)
  400. ;  \_          _/    This converts RS422 to RS423, the same
  401. ;   \|    (2) (1)  |/    as RS232 except for voltage (+-5 versus +-12.)
  402. ;    \ _________ /
  403. ;
  404. ; Pin 1 - Output handshake (DTR) Set with reg 5, mask=80H (inverted)
  405. ; Pin 2 - Input handshake (DCD, DSR or RING) Test with mask=20H
  406. ; Pin 3 - Transmit data- Connect to modem receive
  407. ; Pin 4 - Ground
  408. ; Pin 5 - Receive data- Connect to modem transmit
  409. ; Pin 6 - Transmit data+ Leave unconnected
  410. ; Pin 7 - Not connected
  411. ; Pin 8 - Receive data+ Must be connected to ground
  412. ;
  413. ;-----------------------------------------------------------------------
  414. ;
  415. ; Overlay must terminate before 400H
  416.