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 / I2AP-11.AZM / I2AP-11.ASM
Assembly Source File  |  2000-06-30  |  37KB  |  1,536 lines

  1. ; I2AP-11.ASM - Apple ][ overlay file for IMP - 06/01/87
  2. ;
  3. ;        BASIS = 6551 (built-in divisor)
  4. ;        APR   = 6850 (uses divide by 16 or by 64)
  5. ;        CCS   = 6850 (uses divide by 16 or by 64)
  6. ;        CPS   = 2651 (built-in divisor)
  7. ;        SSC   = 6551 (built-in divisor)
  8. ;        VERSA = 6850 (uses divide by 16 or by 64)
  9. ;        IIGS  = Special firmware interface (hardware independant)
  10. ;
  11. ; This overlay file adapts Apple II computers with various serial cards
  12. ; and external 2400 bps modems to IMP.COM.  It supports the following
  13. ; configurations:
  14. ;
  15. ;     NOTE:    If you have trouble disonnecting from the
  16. ;        phone line, you may not have a normal DTR
  17. ;        setup to turn off the modem.  In that case,
  18. ;        set the NODTR: option at 011E to YES, to
  19. ;        provide ATH0 to disonnect.  (This assumes
  20. ;        you have a Hayes-compatible type modem with
  21. ;        "AT" command set.)
  22. ;
  23. ;
  24. ; CP/M adapter cards:
  25. ; ------------------
  26. ;    ALS CP/M 3.0 adapter card
  27. ;    Applied Engineering Z80+ or Z80C
  28. ;    Microsoft Softcard Z80 equivalent
  29. ;    PCPI Applicard
  30. ;    BASIS 108 System (German Apple)
  31. ;
  32. ; Serial cards
  33. ; ------------
  34. ;    a) ALS Dispatcher card
  35. ;     * b) Apricorn serial card (see note below about baudrate) - 6850
  36. ;    c) CCS 7710 serial card (see note below about baudrate) - 6850
  37. ;    d) Apple Supera Serial Comcard - 6551
  38. ;    e) Mountain Hardware CPS Multifunction card  -    2651
  39. ;    f) Apple SSC communications interface  -  6551
  40. ;    g) SSM serial interface -
  41. ;    h) Prometheus Versacard with software baud select - 6850
  42. ;    i) Apple IIgs modem or printer port -- hardware independant
  43. ;
  44. ;     * The 6850 has no baudrate generator.  It relies on the user
  45. ;    setting a dip switch to the maximum speed he wants to use.
  46. ;    The program then uses the 6850 in the "divide by 16" mode
  47. ;    to get that speed.  It can then change to "divide by 64"
  48. ;    to get the only other speed available.    This type system
  49. ;    normally limits the user to 1200 and 300 baud.    If you
  50. ;    set the dip switches for 2400, then you could only get
  51. ;    2400 and 600, eliminating both 1200 and 300 baud.  Using
  52. ;    either the Apricorn or CCS 7710 board just about precludes
  53. ;    the user from wanting to obtain a new modem with 2400 bps.
  54. ;    gives "divide by 16" and 10 gives "divide by 64".
  55. ;
  56. ;-----------------------------------------------------------------------
  57. ;
  58. ; You will want to look this file over carefully.  There are a number of
  59. ; options that you can use to configure the program to suit your taste.
  60. ;
  61. ; Edit this file for your preferences then follow the "TO USE:" example
  62. ; shown below.
  63. ;
  64. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  65. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  66. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  67. ; (The ESC will automatically be typed with no CTL-character present.)
  68. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  69. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  70. ; looking at the function key table, typing CTL-Z in command mode, etc.
  71. ;
  72. ; Use the "SET" command to change the baudrate when desired.  The value
  73. ; at MSPEED controls the baudrate when the program is first called up.
  74. ;
  75. ;    TO USE: First edit this file filling in answers for your own
  76. ;        equipment.  Then assemble with ASM.COM or equivalent
  77. ;        assembler.  Then use MLOAD to merge into the main file:
  78. ;
  79. ;        MLOAD IMP.COM=IMP.COM,I2AP-x.HEX
  80. ;
  81. ;                    - Notes by Irv Hoff W6FFC
  82. ;
  83. ;-----------------------------------------------------------------------
  84. ;              MC6850 ACIA I/O information
  85. ;
  86. ;     NOTE:    If using a serial card with the Motorola
  87. ;        MC6850 ACIA, this chip does not have a DTR
  88. ;        output.  It does have a RTS (request to send)
  89. ;        option which we have used to substitute for
  90. ;        the missing DTR.  This comes out on pin 4
  91. ;        of the RS-232 DB-25 pin connector.  Hook that
  92. ;        to the modem's pin 20.    Be sure then to have
  93. ;        the DTR toggle switch on the modem itself in
  94. ;        the "remote DTR voltage" position.  For Hayes
  95. ;        modems this is switch 1 (should be "up".)  The
  96. ;        normal Hayes configuration are switches 3,5,8
  97. ;        down, 1,2,4,6,7 up.
  98. ;
  99. ;        If you have any trouble disconnecting, then set
  100. ;        the NODTR: option in the list below to YES and
  101. ;        it will then use ATH0 to disconnect.  This may
  102. ;        take 3-4 seconds.
  103. ;
  104. ; The CCS 7710 serial card is set up as DCE rather than the more usual
  105. ; DTE, and requires a special cable.....the following cable configura-
  106. ; ion is necessary to work with this overlay -----
  107. ;
  108. ;
  109. ;        2        3
  110. ;        3        2
  111. ;        5        4
  112. ;        8        20
  113. ;        7        7
  114. ;        20        5
  115. ;
  116. ; Hayes 1200 switch 6 must be down...(DCD true)
  117. ;                        - Norman Beeler
  118. ;
  119. ;----------------------------------------------------------------------
  120. ;                 VERSAcard
  121. ;
  122. ; To use SET with the Prometheus VERSAcard a small hardware change must
  123. ; be made, since the VERSAcard only supports baud rate selection via DIP
  124. ; switches.  This change will allow the VERSAcard to be switched between
  125. ; 300 and 1200 baud via software.  A wire should be attached from Pin
  126. ; #12 on U16 (IC marked 8126) on the VERSAcard into Annunciator #3 (Pin
  127. ; #12) on the Apple game port.    This will allow switch #4 on s2 of the
  128. ; VERSAcard to be toggled by setting or clearing annunciator #3. The de-
  129. ; fault baud rate is set at MSPEED Below either (300 or 1200).
  130. ;
  131. ; Note: This method could be extended to all other VERSAcard baud rates
  132. ;    and by using Annunciators 0,1,2 but 300 and 1200 are really
  133. ;    needed for a modem program. The DIP switches on the VERSAcard
  134. ;    should be set as follows:
  135. ;
  136. ; On switch bank #2:
  137. ;            S2 - ON
  138. ;            S3 - OFF
  139. ;            S4 - OFF
  140. ;            S5 - OFF
  141. ;
  142. ;
  143. ;     NOTE:    If you have trouble disonnecting from the
  144. ;        phone line, you may not have a normal DTR
  145. ;        setup to turn off the modem.  In that case,
  146. ;        set the NODTR: option at 011E to YES, to
  147. ;        provide ATH0 to disonnect.  (This assumes
  148. ;        you have a Hayes-compatible type modem with
  149. ;        "AT" command set.)
  150. ;
  151. ;
  152. ;     _________________
  153. ;    |          |
  154. ;    | 7 6 5 4 3 2 1 0 |   6850 ACIA for serial I/O
  155. ;    |_________________|
  156. ;
  157. ;      CR1 CR0     Function
  158. ;       0   0     1
  159. ;    *  0   1    16    (for 1200 bps)
  160. ;    +  1   0    64    (changes to 300 baud)
  161. ;       1   1    Master reset
  162. ;    CR4 CR3 CR2
  163. ;     0   0     0     7 bits, even parity, 2 stop bits
  164. ;     0   0     1     7 bits,    odd parity, 2 stop bits
  165. ;     0   1     0     7 bits, even parity, 1 stop bit
  166. ;     0   1     1     7 bits,    odd parity, 1 stop bit
  167. ;     1   0     0     8 bits,     no parity, 2 stop bits
  168. ;      * 1   0     1     8 bits,     no parity, 1 stop bit
  169. ;     1   1     0     8 bits, even parity, 1 stop bit
  170. ;     1   1     1     8 bits,    odd parity, 1 stop bit
  171. ;
  172. ;      CR6 CR5
  173. ;       0   0     RTS low,  Xmit interrupt disabled
  174. ;       0   1     RTS low,  Xmit interrupt enabled
  175. ;    *  1   0     RTS high, Xmit interrupt disabled
  176. ;       1   1     RTS low,  Xmit interrupt disabled, break sent
  177. ;
  178. ;        CR7
  179. ;         0         Interrupts disabled
  180. ;    *    1         Enables recieve buffer full, overrun, low-to-high
  181. ;               transition on the data carrier detect.
  182. ;
  183. ;                    - Notes by Irv Hoff W6FFC
  184. ;
  185. ;----------------------------------------------------------------------
  186. ;
  187. ;                IIgs Modem port
  188. ;
  189. ;    The Apple //gs modem port has a special firmware interface sort of
  190. ;    based on the Pascal firmware interface. The Pascal interface supplies
  191. ;    the basic read/write routines, and the extended command hook provides
  192. ;    the means to toggle the DTR line, and the ability to enable/disable
  193. ;    Ctrl-A commands. Ctrl-A commands provide the ability to change baud
  194. ;    rates, and send break tones. Unfortunatly, this implementation forces
  195. ;    the use of 6502 function calls, not just peeks and pokes to 6502
  196. ;    space. The author has implemented this only for the PCPI Applicard,
  197. ;    however, it probably wouldn't be too tough to addapt. As a starting
  198. ;    point for Microsoft owners, perhaps one could run the 6502 routines
  199. ;    where they reside in the IMP.COM file itself, rather that moving them
  200. ;    somewhere else.
  201. ;
  202. ;    This implementation uses techniques that Apple has "guaranteed" to
  203. ;    remain compatable.
  204. ;
  205. ;                        - Nick Sayer
  206. ;
  207. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  208. ;
  209. ; 11/04/88  Added IIgs serial port support routines. ONLY for PCPI...
  210. ;    v11
  211. ;
  212. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  213. ;    v9     IMP245 to use it.  (Set for ESC Q at present.)
  214. ;                    - Irv Hoff
  215. ;
  216. ;    v8                 - Irv Hoff
  217. ;
  218. ; 02/27/86  Fixed several sections so the BASIS 108 option would work
  219. ;    v7     correctly.            - Irv Hoff
  220. ;
  221. ; 01/17/85  Added the Applied Engineering Z80 card.  Added the Apricorn
  222. ;    v6     serial card, fixed a problem with the CCS serial card so the
  223. ;        program would assemble correctly.  Note added to tell about
  224. ;        the CCS and Apricorn being limited to 300/1200 bps, if 2400
  225. ;        bps is needed, likely will want a different serial card.
  226. ;                    - Irv Hoff
  227. ;
  228. ; 09/27/85  Fixed compile errors for CCS serial option, added DTR sup-
  229. ;    v5     port, modem cable description (for CCS board, only).
  230. ;                    - Norman Beeler
  231. ;
  232. ; 09/22/85  Corrected SSC INITMOD1 routine - changed JMP to CALL.
  233. ;    v4                 - Douglas Thom
  234. ;
  235. ; 09/15/85  Added SET300 in CPS INITMOD to fix cold boot problem.
  236. ;    v3                 - Norman Beeler
  237. ;
  238. ; 08/27/85  Added to support the BASIS 108
  239. ;    v2                 - Clay Walker
  240. ;
  241. ; 07/17/85  Written to work with IMP    - Irv Hoff
  242. ;    v1
  243. ;
  244. ; =   =  =   =     =   =     =   =     =   =     =   =     =   =     =   =     =   =
  245. ;
  246. ;
  247. YES    EQU    0FFH
  248. NO    EQU    0
  249. ;
  250. ;
  251. ;====================== CUSTOMIZATION EQUATES ==========================
  252. ;
  253. SLOT    EQU    2        ; Slot of serial interface
  254. SLOTOFF    EQU    16*SLOT        ; Serial card slot offset
  255.      IF    IIGS
  256. SLOTOF2    EQU    256*SLOT    ; Firmware offset
  257.      ENDIF
  258. ;
  259. ;
  260. ; CP/M adapter cards for Apple ][
  261. ;
  262. ALSCARD       EQU    NO        ; Yes if using ALS CP/M card
  263. APPLIED       EQU    NO        ; Yes if using Applied Engineering Z80
  264. PCPI       EQU    YES        ; Yes if using PCPI Applicard CP/M card
  265. BASIS       EQU    NO        ; Yes if BASIS 108
  266. MICROSOFT  EQU    NO        ; Yes if Microsoft Softcard CP/M card
  267. ;
  268. ;
  269. ; Serial I/O cards for Apple ][
  270. ;
  271. ALSDSP    EQU    NO        ; Yes for ALS Dispatcher
  272. APR    EQU    NO        ; Yes for Apricorn serial card
  273. COMCARD    EQU    NO        ; Yes for Apple Comcard
  274. CPS    EQU    NO        ; Yes for CPS card
  275. SSC    EQU    NO        ; Yes for Super Serial Card
  276. SSM    EQU    NO        ; Yes for SSM serial card
  277. VERSA    EQU    NO        ; Yes for Prometheus VERSAcard
  278. IIGS    EQU    YES        ; Yes for IIgs serial port
  279. ;
  280. CPSPRT    EQU    NO        ; Yes if using CPS parallel printer port
  281. ;
  282. ;
  283. ;-----------------------------------------------------------------------
  284. ;
  285.      IF    ALSCARD    OR PCPI
  286. MAPOFF    EQU    0        ; No memory remapping for either
  287.      ENDIF            ; ALSCARD OR PCPI
  288. ;
  289.      IF    APPLIED    OR MICROSOFT
  290. MAPOFF    EQU    2000H        ; Microsoft strikes again
  291.      ENDIF            ; APPLIED OR MICROSOFT
  292. ;
  293. ;
  294. ;-----------------------------------------------------------------------
  295. ;
  296.      IF    BASIS
  297. MDDATP    EQU    0E098H        ; Data Port
  298. MDCTL1    EQU    0E099H        ; Status Port
  299. MDCTL2    EQU    0E09AH        ; Command Port
  300. MDCTL3    EQU    0E09BH        ; Control Port
  301. MDRCV    EQU    08H        ; Same as SSC (6551 ACIA)
  302. MDSND    EQU    10H        ;  "
  303. MDTXE    EQU    10H        ;  "
  304.      ENDIF            ; BASIS
  305. ;
  306. ;
  307. ;-----------------------------------------------------------------------
  308. ;
  309.      IF    APR
  310. MDCTL1    EQU    0C08EH+SLOTOFF+MAPOFF ; Status port of Apricorn
  311. MDDATP    EQU    0C08FH+SLOTOFF+MAPOFF ; Data port of Apricorn
  312.      ENDIF            ; APR
  313. ;
  314. ;
  315. ;-----------------------------------------------------------------------
  316. ;
  317.      IF    CCS
  318. MDCTL1    EQU    0C080H+SLOTOFF+MAPOFF ; Status port of CCS 7710
  319. MDDATP    EQU    0C081H+SLOTOFF+MAPOFF ; Data port of CCS 7710
  320.      ENDIF            ; CCS
  321. ;
  322. ;
  323. ;-----------------------------------------------------------------------
  324. ;
  325.      IF    ALSDSP OR COMCARD OR VERSA
  326. MDCTL1    EQU    0C08EH+SLOTOFF+MAPOFF ; Status port of Comcard
  327.      ENDIF            ; ALSDSP OR COMCARD OR VERSA
  328. ;
  329. ;
  330. ;-----------------------------------------------------------------------
  331. ;
  332.      IF    CPS
  333. MDCPST    EQU    0C0F9H+SLOT*100H+MAPOFF    ; Printer status port
  334. MDDATP    EQU    0C0FAH+SLOT*100H+MAPOFF    ; Data port of CPS card
  335. MDCTL1    EQU    0C0FBH+SLOT*100H+MAPOFF    ; Status port of CPS card
  336. MDCTL2    EQU    0C0FCH+SLOT*100H+MAPOFF    ; Second CPS status port
  337. MDCPRT    EQU    0C0FDH+SLOT*100H+MAPOFF    ; Printer data port
  338. MDCR    EQU    0C0FEH+SLOT*100H+MAPOFF    ; Control port of CPS card
  339. MDRCV    EQU    2        ; Bit to test for receive
  340. MDSND    EQU    1        ; Bit to test for send
  341. MDTXE    EQU    5        ; Modem send buffer empty
  342.      ENDIF            ; CPS
  343. ;
  344. ;
  345. ;-----------------------------------------------------------------------
  346. ;
  347.      IF    SSC
  348. MDDATP    EQU    0C088H+SLOTOFF+MAPOFF ; SSC data port
  349. MDCTL1    EQU    0C089H+SLOTOFF+MAPOFF ; SSC status port
  350. MDCTL2    EQU    0C08AH+SLOTOFF+MAPOFF ; SSC mode port
  351. MDCTL3    EQU    0C08BH+SLOTOFF+MAPOFF ; SSC control port
  352. MDRCV    EQU    08H        ; Bit to test for received data
  353. MDSND    EQU    10H        ; Bit to test for ready to send
  354. MDTXE    EQU    10H        ; Modem send buffer empty
  355.      ENDIF            ; SSC
  356. ;
  357. ;
  358. ;-----------------------------------------------------------------------
  359. ;
  360.      IF    SSM
  361. MDCTL1    EQU    0C084H+SLOTOFF+MAPOFF ; Status port of SSM
  362. MDDATP    EQU    0C085H+SLOTOFF+MAPOFF ; Data port of SSM
  363.      ENDIF            ; SSM
  364. ;
  365. ;
  366. ;-----------------------------------------------------------------------
  367. ;
  368.      IF    NOT IIGS AND NOT SSC AND NOT CPS AND NOT BASIS
  369. MDRCV    EQU    1        ; Bit to test for receive
  370. MDSND    EQU    2        ; Bit to test for send
  371. MDTXE    EQU    2        ; Modem send buffer empty
  372.      ENDIF            ; NOT SSC AND NOT CPS
  373. ;
  374. ;
  375. ;-----------------------------------------------------------------------
  376. ;
  377.      IF    VERSA
  378. AN3CLR    EQU    0C05EH+MAPOFF    ; Clear annunciator #3
  379. AN3SET    EQU    0C05FH+MAPOFF    ; Set        "        #3
  380.      ENDIF            ; VERSA
  381. ;
  382. ;-----------------------------------------------------------------------
  383. ;
  384.      IF    IIGS
  385. MDRCV    EQU    1        ; Bit to test for receive char ready
  386. MDSND    EQU    4        ; Bit to test for send ready
  387. MDTXE    EQU    4        ; Bit to test for send buf empty
  388.      ENDIF
  389. ;
  390. ;
  391. ;-----------------------------------------------------------------------
  392. ;
  393. ; General equates
  394. ;
  395. ESC    EQU    '['-40H        ; ^[ = Escape
  396. BELL    EQU    'G'-40H        ; ^G = Bell character
  397. LF    EQU    'J'-40H        ; ^J = Linefeed
  398. NEXTRY    EQU    'K'-40H        ; ^K = Try next phone number now
  399. CR    EQU    'M'-40H        ; ^M = Carriage return
  400. CLEARSC    EQU    'Z'-40H        ; ^Z = Clear screen, command mode only
  401. EOFCHAR    EQU    'Z'-40H        ; ^Z = End of file
  402. ;
  403. ;
  404. ;-----------------------------------------------------------------------
  405. ;
  406. ;
  407.     ORG    0100H
  408. ;
  409.     DS    3    ; Skip the data area below
  410. ;
  411. ;
  412. ; These routines and equates are at the beginning of the program so
  413. ; they can be patched by a monitor or overlay file without re-assembling
  414. ; the program.
  415. ;
  416. MSPEED:     DB    6    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  417.             ; 6=2400 7=4800 8=9600 9=19200 default
  418. HS2400:     DB    YES    ; Yes=2400 bps highest speed            104H
  419. HS1200:     DB    NO    ; Yes=1200 bps highest speed            105H
  420. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  421. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  422. RESVD1:     DB    NO    ; Reserved for special modems            108H
  423. RESVD2:     DB    NO    ; Reserved for special modems            109H
  424. ;
  425. CLEAR:     DB    '*'    ; Clear screen character (ESC not needed)    10AH
  426. ;
  427.       IF    PCPI
  428. CLOCK:     DB    6    ; Clock speed in MHz, 25.5 MHz max.        10BH
  429.             ; NOTE:  DO NOT MULTIPLY BY 10 FOR APPLICARD
  430.       ENDIF        ; PCPI
  431. ;
  432.       IF    NOT PCPI
  433. CLOCK:     DB    20    ; Clock speed in MHz x10, 25.5 MHz max.     10BH
  434.       ENDIF        ; NOT PCPI
  435.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  436. BYTDLY:     DB    9    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  437.             ;   default time to send character in ter-
  438.             ;   minal mode file transfer for slow BBS
  439. CRDLY:     DB    9    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  440.             ;   default time for extra wait after CRLF
  441.             ;   in terminal mode file transfer
  442. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  443. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  444. ;.....
  445. ;
  446. ;
  447. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  448.             ;   mode (normally added by remote echo)
  449. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  450. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  451. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  452. ;.....
  453. ;
  454. ;
  455. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  456. EXITCHR: DB    'E'    ; Exit character                115H
  457. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  458. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  459. LOGCHR:     DB    'L'    ; Send logon                    118H
  460. LSTCHR:     DB    'P'    ; Toggle printer                119H
  461. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  462. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  463. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  464. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  465. NODTR:     DB    NO    ; YES if no DTR and need ATH0 to disconnect    11EH
  466. ;.....
  467. ;
  468. ;
  469. ; Handles in/out ports for data and status
  470. ;
  471. I$MDCTL1: JMP    RCVCTL1        ; In modem control port         11FH
  472.       DB    0,0,0,0,0,0,0    ; Spares if needed            122H
  473. ;
  474. I$MDTXE:  JMP    RCVCTL1        ;                    129H
  475.       DB    0,0,0,0,0,0,0    ;                    12CH
  476. ;
  477. I$MDDATP: JMP    RCVDATP        ;in modem data port            133H
  478.       DB    0,0,0,0,0,0,0    ;                    146H
  479. ;
  480. O$MDDATP: JMP    SNDDATP        ; Out modem data port            13DH
  481.       DB    0,0,0,0,0,0,0    ; Spares if needed            140H
  482. ;.....
  483. ;
  484. ;
  485. A$MDRCV:  ANI    MDRCV        ;                    147H
  486.       RET            ;                    149H
  487. ;
  488. C$MDRCV:  CPI    MDRCV        ;                    14AH
  489. ;
  490. A$MDSND:  ANI    MDSND        ;                    14DH
  491.       RET            ;                    14FH
  492. ;
  493. C$MDSND:  CPI    MDSND        ;                    150H
  494.       RET            ;                    152H
  495. ;
  496. A$MDTXE:  ANI    MDTXE        ;                    153H
  497.       RET            ;                    155H
  498. ;
  499. C$MDTXE:  CPI    MDTXE        ;                    156H
  500.       RET            ;                    158H
  501. ;.....
  502. ;
  503. ;
  504. ; Special exit vector, used by some computers to reset interrupt vectors
  505. ;
  506. J$EXITVEC:RET            ;                    159H
  507.       DB    0,0        ;                    15AH
  508. ;.....
  509. ;
  510. ;
  511. ; Jump vectors needed by each overlay
  512. ;
  513. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  514. J2$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  515. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  516. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  517. ;.....
  518. ;
  519. ;
  520. ; "AT" command strings, can be replaced in individual overlay if needed
  521. ;
  522. J$STRNGA: DS    3        ; 1200 bps "AT" string            168H
  523. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  524. ;
  525. ;
  526. ; Next fourteen lines should not be changed by user overlay as these go
  527. ; to specific locations in the main program, not in the overlay.
  528. ;
  529. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  530. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  531. J$DIAL:      DS    3        ; Start of dialing routine        174H
  532. J$DSCONT: DS    3        ; Terminates modem use            177H
  533. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  534. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  535. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  536. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  537. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  538. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  539. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  540. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  541. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  542. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  543. ;.....
  544. ;
  545. ;
  546. ; For 2400 bps auto-stepdown units
  547. ;
  548. MANUAL:      DB    0        ; For manual selection flag        19BH
  549. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  550. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  551. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  552. ;.....
  553. ;
  554. ;
  555. LOGPTR:    DW    LOGON        ; Pointer to display LOGON message    1A5H
  556. ;
  557. SYSVR:    CALL    J$ILPRT        ; Display the following line        1A7H
  558.      IF    BASIS
  559.     DB    'Basis 108 with built in serial port ',CR,LF    ;    1AAH
  560.     DB    0
  561.     RET
  562.      ENDIF            ; BASIS
  563. ;
  564.      IF    NOT BASIS
  565.     DB    'Apple ][ with '
  566.      ENDIF            ; NOT BASIS
  567. ;
  568.      IF    ALSCARD
  569.     DB    'ALS CP/M Card'
  570.      ENDIF            ; ALSCARD
  571. ;
  572.      IF    PCPI
  573.     DB    'PCPI Applicard'
  574.      ENDIF            ; PCPI
  575. ;
  576.      IF    APPLIED
  577.     DB    'Applied Engineering'
  578.      ENDIF            ; APPLIED
  579. ;
  580.      IF    MICROSOFT
  581.     DB    'CP/M 2.2 Card'
  582.      ENDIF            ; MICROSOFT
  583. ;
  584.     DB    CR,LF,'  and '
  585. ;
  586.      IF    VERSA
  587.     DB    'VERSAcard'
  588.      ENDIF            ; VERSA
  589. ;
  590.      IF    ALSDSP
  591.     DB    'ALS Dispatcher'
  592.      ENDIF            ; ALSDSP
  593. ;
  594.      IF    APR
  595.     DB    'Apricorn serial card'
  596.      ENDIF            ; APR
  597.      IF    CCS
  598.     DB    'CCS 7710 Card'
  599.      ENDIF            ; CCS
  600. ;
  601.      IF    COMCARD
  602.     DB    'Comcard'
  603.      ENDIF            ; COMCARD
  604. ;
  605.      IF    CPS
  606.     DB    'CPS card - serial function'
  607.      ENDIF            ; CPS
  608. ;
  609.      IF    SSC
  610.     DB    'Super Serial Card'
  611.      ENDIF            ; SSC
  612. ;
  613.      IF    SSM
  614.     DB    'SSM Serial Interface'
  615.      ENDIF            ; SSM
  616. ;
  617.      IF    IIGS
  618.     DB    'IIgs Modem Port'
  619.      ENDIF
  620. ;
  621.      IF    NOT    BASIS
  622.     DB    ' in slot ',SLOT+30H,CR,LF
  623.     DB    0
  624.     RET
  625.      ENDIF            ; NOT BASIS
  626. ;.....
  627. ;
  628. ;
  629. ;-----------------------------------------------------------------------
  630. ;
  631. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  632. ;     end of your last routine should terminate by 0400H (601 bytes
  633. ;     available after start of SYSVER).
  634. ;
  635. ;-----------------------------------------------------------------------
  636. ;
  637. ; You can put in a message at this location which can be called up with
  638. ; (special character-L).  You can put in several lines.  End with a 0.
  639. ;
  640. LOGON:    DB    'Hello from a happy computer user',CR,0
  641. ;
  642. ;-----------------------------------------------------------------------
  643. ;
  644. ; This routine sends a break tone for 300 ms
  645. ;
  646. SENDBRK:
  647.      IF    CPS
  648.     MVI    A,80H        ; Open command
  649.     CALL    SNDMDCR
  650.     MVI    A,3FH        ; Keeps DTR, sends break tone
  651.      ENDIF            ; CPS
  652. ;
  653.      IF    BASIS OR SSC
  654.     MVI    A,0FH
  655.     JMP    GOODBYE+2
  656.      ENDIF            ; BASIS OR SSC
  657. ;
  658.      IF    APR OR CCS OR VERSA
  659.     CALL    RCVCTL1        ; Get the current status and speed
  660.     STA    SBTEMP        ; Store it for now
  661.     MVI    A,0F5H        ; Set break tone
  662.     JMP    GOODBYE1    ; Send the 300 ms break tone
  663.      ENDIF            ; APR OR CCS OR VERSA
  664. ;
  665.      IF    IIGS
  666.     CALL    CMDENA        ; Enable Ctrl-A commands
  667.     MVI    A,01H        ; Ctrl-A
  668.     CALL    GSSEND        ; Send it out
  669.     MVI    A,'S'        ; Ctrl-A + S is send-break command
  670.     CALL    GSSEND        ; Send it out
  671.     JMP    CMDDIS        ; Disable Ctrl-A commands and return
  672.      ENDIF
  673. ;
  674.     RET            ; Any others, exit with no break tone
  675. ;.....
  676. ;
  677. ;
  678. SBTEMP:    DB    0        ; Temporary storage to remember speed
  679. ;.....
  680. ;
  681. ;
  682. ; This routine sets DTR low for 300 ms to disconnect the phone
  683. ;
  684.      IF    APR OR CCS OR VERSA
  685. GOODBYE:
  686.     CALL    RCVCTL1        ; Get the current status and speed
  687.     STA    SBTEMP        ; Store it for now
  688.     MVI    A,0D5H        ; Turn off DTR
  689. ;
  690. GOODBYE1:
  691.     CALL    SNDCTL1        ; Send to the Modem
  692.     MVI    B,3        ; Delay 300 ms to hang up phone
  693.     CALL    J$TIMER
  694.     LDA    SBTEMP        ; Get original status and speed back
  695.     CALL    SNDCTL1
  696.     MVI    A,0B5H        ; Turn everything back on
  697.     CALL    SNDCTL1
  698.     XTHL            ; Short delay to complete command
  699.     XTHL
  700.     RET
  701.       ENDIF            ; APR OR CCS OR VERSA
  702. ;
  703.      IF    SSC OR BASIS
  704. GOODBYE:
  705.     CALL    SNDCTL2
  706.     MVI    B,3        ; Delay 300 ms to hang up phone
  707.     CALL    J$TIMER
  708.     MVI    A,0BH        ; Set DTR, Rx, Irq
  709.     CALL    SNDCTL2
  710.     XTHL            ; Short delay to complete command
  711.     XTHL
  712.     RET
  713.      ENDIF            ; SSC or BASIS
  714. ;
  715.      IF    CPS
  716. GOODBYE:
  717.     MVI    A,80H        ; Open command
  718.     CALL    SNDMDCR
  719.     MVI    A,1DH        ; RTS, DTR off, send break
  720. ;
  721. GOODBYE1:
  722.     CALL    SNDCTL1
  723.     MVI    B,3        ; Delay 300 ms to hang up phone
  724.     CALL    J$TIMER
  725.     MVI    A,37H        ; RTS, ERR reset errors, Rx, DTR, Tx
  726.     CALL    SNDCTL1
  727.     MVI    A,0        ; Close command
  728.     CALL    SNDMDCR
  729.     MVI    B,5        ; Short delay to complete command
  730.     CALL    J$TIMER
  731.     RET
  732.      ENDIF            ; CPS
  733. ;
  734.      IF    IIGS
  735. GOODBYE:
  736.     MVI    A,0FFH        ; Lower DTR
  737.     CALL    CMDDTR        ; Set DTR status
  738.     MVI    B,3
  739.     CALL    J$TIMER        ; Delay 300 ms
  740.     MVI    A,00H        ; Bring DTR back
  741.     CALL    CMDDTR        ; Set DTR status
  742.     RET
  743.      ENDIF
  744. ;
  745. ;
  746. ; If none of the above, then set NODTR to YES to disconnect with ATH0
  747. ;
  748.      IF    NOT IIGS
  749.     CALL    J$ILPRT
  750.     DB    CR,LF,'++ DOES NOT DROP DTR, USE "BYE" ++',BELL,CR,LF,0
  751.     RET            ; Just in case was none of these
  752.      ENDIF
  753. ;.....
  754. ;
  755. ;
  756. ;=========================== INITMOD ===================================
  757. ;
  758. ;
  759.      IF    ALSCARD
  760. INITMOD:
  761.     LHLD    1        ; Initialize our local jumps to the BIOS
  762.     DAD    D
  763.     SHLD    APREAD+1
  764.     INX    H
  765.     INX    H
  766.     INX    H
  767.     SHLD    APWRITE+1
  768.     RET
  769.      ENDIF            ; ALSCARD
  770. ;.....
  771. ;
  772. ;
  773.      IF    APR OR CCS
  774. INITMOD:
  775.     LDA    MSPEED        ; Get the selected value
  776.     CPI    1        ; 300 bps
  777.     JZ    OK300
  778.     CPI    5        ; 1200 bps
  779.     JZ    OK1200
  780.     CPI    6        ; 2400 bps
  781.     JZ    OK2400
  782.     CPI    8        ; 9600 bps
  783.     JZ    OK9600
  784.     JMP    STUPR1        ; Else ask what is wanted
  785. ;
  786. INITMOD1:
  787.     MOV    A,B        ; Get the baudrate back, 8 bits 1 stop
  788.     CALL    SNDCTL1        ; ACIA control register
  789.     XTHL            ; Short delay to complete command
  790.     XTHL
  791.     RET
  792.      ENDIF            ; APR OR CCS
  793. ;.....
  794. ;
  795. ;
  796. ; The following may be used to initialize the Mountain Hardware CPS
  797. ; Multifunction Card.
  798. ;
  799.      IF    CPS
  800. INITMOD:
  801.     CALL    OK300        ; Necessary for cold boot
  802.     CALL    CPSPRINT    ; Install special CPS printer routine
  803.     LDA    MSPEED        ; Get the selected value
  804.     CPI    1        ; 300 bps
  805.     JZ    OK300
  806.     CPI    5        ; 1200 bps
  807.     JZ    OK1200
  808.     CPI    6        ; 2400 bps
  809.     JZ    OK2400
  810.     CPI    8        ; 9600 bps
  811.     JZ    OK9600
  812.     JMP    STUPR1        ; Else ask what is wanted
  813. ;.....
  814. ;
  815. ;
  816.     MVI    A,80H        ; Open command
  817.     CALL    SNDMDCR
  818.     MVI    A,4EH        ; 1 stop, 8 bits, 16x
  819.     CALL    SNDDATP
  820.     MOV    A,B        ; Get the baudrate back
  821.     CALL    SNDDATP
  822.     MVI    A,37H        ; RTS, ERR reset errors, Rx, DTR, Tx
  823.     CALL    SNDCTL1
  824.     XRA    A        ; Close command
  825.     CALL    SNDMDCR
  826.     MVI    B,5        ; 1/2 second delay for CPS board
  827.     CALL    J$TIMER
  828.     RET
  829.      ENDIF            ; CPS
  830. ;.....
  831. ;
  832. ;
  833.      IF    BASIS OR SSC
  834. INITMOD:
  835.     MVI    A,0BH        ; Set DTR, Rx, Irq
  836.     CALL    SNDCTL2
  837.     XTHL            ; Short delay to complete command
  838.     XTHL
  839. ;
  840.     LDA    MSPEED        ; Get the selected value
  841.     CPI    1        ; 300 bps
  842.     JZ    OK300
  843.     CPI    5        ; 1200 bps
  844.     JZ    OK1200
  845.     CPI    6        ; 2400 bps
  846.     JZ    OK2400
  847.     CPI    8        ; 9600 bps
  848.     JZ    OK9600
  849.     JMP    STUPR1        ; Else ask what is wanted
  850. ;.....
  851. ;
  852. ;
  853. INITMOD1:
  854.     MOV    A,B        ; Get the baudrate back
  855.     CALL    SNDCTL3        ; Store default baudrate
  856.     XTHL            ; Short delay to complete command
  857.     XTHL
  858.     RET
  859.      ENDIF            ; BASIS OR SSC
  860. ;.....
  861. ;
  862. ;
  863. ; The following routine initializes the VERSAcard to the default baud
  864. ; rate which is set at MSPEED above.  If MSPEED is set to something
  865. ; other than 300 or 1200 this routine does not alter the annunciator
  866. ; settings.
  867. ;
  868.      IF    VERSA
  869. INITMOD:
  870. ;
  871. INITMOD1:
  872.     LDA    MSPEED        ; Set annunciators to known state
  873.     CPI    1        ; Is it 300 ?
  874.     JZ    OK300
  875.     CPI    5        ; Is it 1200 ?
  876.     JZ    OK1200
  877.     RET
  878.      ENDIF            ; VERSA
  879. ;.....
  880. ;
  881. ;
  882.      IF    IIGS
  883. INITMOD:
  884.     CALL    GSINIT        ; Init via 6502 routines
  885. ;
  886.     LDA    MSPEED        ; Get the selected value
  887.     CPI    1        ; 300 bps
  888.     JZ    OK300
  889.     CPI    5        ; 1200 bps
  890.     JZ    OK1200
  891.     CPI    6        ; 2400 bps
  892.     JZ    OK2400
  893.     CPI    8        ; 9600 bps
  894.     JZ    OK9600
  895.     JMP    STUPR1        ; Else ask what is wanted
  896. INITMOD1:
  897.     PUSH    H
  898.     PUSH    D
  899.     PUSH    B
  900.     CALL    CMDENA        ; Enable Ctrl-A commands
  901.     MVI    A,81H        ; Send a Ctrl-A
  902.     CALL    GSSEND        ; Send it
  903.     POP    B        ; Get Char back
  904.     PUSH    B        ; And save it again
  905.     MOV    A,B
  906.     RAR
  907.     RAR
  908.     RAR
  909.     RAR
  910.     CALL    SENDHX
  911.     POP    B
  912.     PUSH    B
  913.     MOV    A,B
  914.     CALL    SENDHX
  915.     MVI    A,'B'
  916.     CALL    GSSEND        ; Ctrl-A + # + B is baud command
  917.     CALL    CMDDIS        ; Disable Ctrl-A cmds and return
  918.     POP    B
  919.     POP    D
  920.     POP    H
  921.     RET
  922. SENDHX:    ANI    0FH
  923.     ORI    0B0H        ; Make it a number
  924.     JMP    GSSEND        ; Send it and ret
  925.      ENDIF
  926. ;.....
  927. ;
  928. ; If none of the above cards
  929. ;
  930.     MVI    A,0FFH        ; These systems do not support DTR
  931.     RET            ; From 'CALL INITMOD'
  932. ;.....
  933. ;
  934. ;
  935. ; The routine that checks to see if the printer is ready does not work
  936. ; with the CPS card.  This routine changes it.    It overwrites the area
  937. ; in the main program that normally checks printer status from a BDOS
  938. ; call with our own status checks.
  939. ;
  940. CPSPRINT:
  941.      IF    CPS AND    CPSPRT    ; If printer uses CPS printer port
  942.     CALL    J$GOLST        ; Get GOLIST+1 in 'HL'
  943.     LXI    B,PRCHECK    ; Put routine at GOLIST+1
  944.     MOV    M,C
  945.     INX    H
  946.     MOV    M,D
  947.     XCHG            ; Now get GOLIST+15 into 'HL' from 'DE'
  948.     LXI    B,PRINTCHAR    ; Put routine at GOLIST+15
  949.     MOV    M,C
  950.     INX    H
  951.     MOV    M,D
  952.     RET
  953. ;.....
  954. ;
  955. ;
  956. ; Substitute routines for status checks and printing:
  957. ;
  958. PRCHECK:CALL    RCVCPST        ; Read the status port
  959.     ANI    40H        ; Mask off unused bits
  960.     RET
  961. ;.....
  962. ;
  963. ;
  964. PRINTCHAR:
  965.     MOV    A,C        ; Move character to 'A' register
  966.     JMP    SNDCPRT        ; Send it to the printer
  967.      ENDIF            ; CPS AND CPSPRT
  968. ;
  969.     RET            ; In case CPSPRT was set to 'NO'
  970. ;.....
  971. ;
  972. ;
  973. ;========================== APPLE I/O ==================================
  974. ;
  975.      IF    APPLIED    OR BASIS OR MICROSOFT
  976. SNDCTL1:STA    MDCTL1
  977.     RET
  978. ;
  979. SNDDATP:STA    MDDATP
  980.     RET
  981. ;
  982. RCVCTL1:LDA    MDCTL1
  983.     RET
  984. ;
  985.     RET
  986.      ENDIF            ; APPLIED OR BASIS OR MICROSOFT
  987. ;.....
  988. ;
  989. ;
  990.       IF    CPS AND    (APPLIED OR MICROSOFT)
  991. SNDCPRT: STA    MDCPRT
  992.      RET
  993. ;
  994. SNDMDCR: STA    MDCR
  995.      RET
  996. ;
  997. RCVCPST: LDA    MDCPST
  998.      RET
  999.       ENDIF            ; CPS AND (APPLIED OR MICROSOFT)
  1000. ;.....
  1001. ;
  1002. ;
  1003.       IF    BASIS OR SSC AND (APPLIED OR MICROSOFT)
  1004. RCVCTL2: LDA    MDCTL2
  1005.      RET
  1006. ;
  1007. RCVCTL3: LDA    MDCTL3
  1008.      RET
  1009. ;
  1010. SNDCTL2: STA    MDCTL2
  1011.      RET
  1012. ;
  1013. SNDCTL3: STA    MDCTL3
  1014.      RET
  1015.       ENDIF            ; BASIS OR SSC AND (APPLIED OR MICROSOFT)
  1016. ;.....
  1017. ;
  1018. ;
  1019.       IF    VERSA AND (APPLIED OR MICROSOFT)
  1020. RCVAN3C: LDA    AN3CLR
  1021.      RET
  1022. ;
  1023. RCVAN3S: LDA    AN3SET
  1024.      RET
  1025.      ENDIF            ; VERSA AND (APPLIED OR MICROSOFT)
  1026. ;.....
  1027. ;
  1028. ;
  1029.       IF    ALSCARD
  1030. SNDCTL1: PUSH    H
  1031.      LXI    H,MDCTL1
  1032.      JMP    POKE
  1033. ;
  1034. SNDDATP: PUSH    H
  1035.      LXI    H,MDDATP
  1036. ;
  1037. POKE:     PUSH    D
  1038.      PUSH    B
  1039.      POP    B
  1040.      POP    D
  1041.      POP    H
  1042.      RET
  1043.       ENDIF            ; ALSCARD
  1044. ;.....
  1045. ;
  1046. ;
  1047.       IF    ALSCARD
  1048. RCVCTL1: PUSH    H
  1049.      LXI    H,MDCTL1
  1050.      JMP    PEEK
  1051. ;
  1052. RCVDATP: PUSH    H
  1053.      LXI    H,MDDATP
  1054. ;
  1055. PEEK:     PUSH    D
  1056.      PUSH    B
  1057.      CALL    APREAD
  1058.      POP    B
  1059.      POP    D
  1060.      POP    H
  1061.      RET
  1062. ;.....
  1063. ;
  1064. ;
  1065. ; These are the jump locations to the ALS BIOS
  1066. ;
  1067. APREAD:     JMP    $-$
  1068. APWRITE: JMP    $-$
  1069.       ENDIF            ; ALSCARD
  1070. ;.....
  1071. ;
  1072. ;
  1073.       IF    ALSCARD    AND CPS
  1074. SNDCPRT: PUSH    H
  1075.      LXI    H,MDCPRT
  1076.      JMP    POKE
  1077. ;
  1078. SNDMDCR: PUSH    H
  1079.      LXI    H,MDCR
  1080.      JMP    POKE
  1081. ;
  1082. RCVCPST: PUSH    H
  1083.      LXI    H,MDCPST
  1084.      JMP    PEEK
  1085.       ENDIF            ; ALSCARD AND CPS
  1086. ;.....
  1087. ;
  1088. ;
  1089.       IF    ALSCARD    AND SSC
  1090. RCVCTL3: PUSH    H
  1091.      LXI    H,MDCTL3
  1092.      JMP    PEEK
  1093. SNDCTL2: PUSH    H
  1094.      LXI    H,MDCTL2
  1095.      JMP    POKE
  1096. ;
  1097. SNDCTL3: PUSH    H
  1098.      LXI    H,MDCTL3
  1099.      JMP    POKE
  1100.       ENDIF            ; ALSCARD AND SSC
  1101. ;.....
  1102. ;
  1103. ;
  1104.       IF    ALSCARD    AND VERSA
  1105. RCVAN3C: PUSH    H
  1106.      LXI    H,AN3CLR
  1107.      JMP    PEEK
  1108. ;
  1109. RCVAN3S: PUSH    H
  1110.      LXI    H,AN3SET
  1111.      JMP    PEEK
  1112.       ENDIF            ; ALSCARD AND VERSA
  1113. ;.....
  1114. ;
  1115. ;
  1116.       IF    PCPI AND NOT IIGS
  1117. RDBYTE     EQU    0FFE0H        ; Read 1 byte from Apple (A = byte)
  1118. WRBYTE     EQU    0FFE3H        ; Write 1 byte to Apple (C = byte)
  1119. RDWORD     EQU    0FFE6H        ; Read 2 bytes from Apple (DE = word)
  1120. WRWORD     EQU    0FFE9H        ; Write 2 bytes to Apple (DE = word)
  1121. PEEK1     EQU    6        ; Command
  1122. POKE1     EQU    7        ; Command
  1123. ;
  1124. POKE:     PUSH    B
  1125.      MOV    B,A
  1126.      MVI    C,POKE1
  1127.      CALL    WRBYTE
  1128.      CALL    WRWORD
  1129.      MOV    C,B
  1130.      CALL    WRBYTE
  1131.      POP    B
  1132.      POP    D
  1133.      RET
  1134. ;
  1135. PEEK:     PUSH    B
  1136.      MVI    C,PEEK1
  1137.      CALL    WRBYTE
  1138.      CALL    WRWORD
  1139.      CALL    RDBYTE
  1140.      POP    B
  1141.      POP    D
  1142.      RET
  1143. ;
  1144. ;.....
  1145. SNDCTL1: PUSH    D
  1146.      LXI    D,MDCTL1
  1147.      JMP    POKE
  1148. ;
  1149. SNDDATP: PUSH    D
  1150.      JMP    POKE
  1151. ;
  1152. RCVCTL1: PUSH    D
  1153.      LXI    D,MDCTL1
  1154.      JMP    PEEK
  1155. ;
  1156. RCVDATP: PUSH    D
  1157.      LXI    D,MDDATP
  1158.      JMP    PEEK
  1159. ;
  1160.      ENDIF            ; PCPI AND NOT IIGS
  1161. ;
  1162. ;.....
  1163. ;
  1164. ;
  1165.       IF    PCPI AND CPS
  1166. SNDCPRT: PUSH    D
  1167.      LXI    D,MDCPRT
  1168.      JMP    POKE
  1169. ;
  1170. SNDMDCR: PUSH    D
  1171.      LXI    D,MDCR
  1172.      JMP    POKE
  1173. ;
  1174. RCVCPST: PUSH    D
  1175.      LXI    D,MDCPST
  1176.      JMP    PEEK
  1177.       ENDIF            ; PCPI AND CPS
  1178. ;.....
  1179. ;
  1180. ;
  1181.       IF    PCPI AND SSC
  1182. RCVCTL3: PUSH    D
  1183.      LXI    D,MDCTL3
  1184.      JMP    PEEK
  1185. ;
  1186. SNDCTL2: PUSH    D
  1187.      LXI    D,MDCTL2
  1188.      JMP    POKE
  1189. ;
  1190. SNDCTL3: PUSH    D
  1191.      LXI    D,MDCTL3
  1192.      JMP    POKE
  1193.       ENDIF            ; PCPI AND SSC
  1194. ;.....
  1195. ;
  1196. ;
  1197.       IF    PCPI AND VERSA
  1198. RCVAN3C: PUSH    D
  1199.      LXI    H,AN3CLR
  1200.      JMP    PEEK
  1201. ;
  1202. RCVAN3S: PUSH    D
  1203.      LXI    H,AN3SET
  1204.       ENDIF            ; PCPI AND VERSA
  1205. ;.....
  1206. ;
  1207. ;
  1208.      IF    PCPI AND IIGS
  1209. RDBYTE:    EQU    0FFE0H        ; Read 1 byte from Apple (A = byte)
  1210. WRBYTE:    EQU    0FFE3H        ; Write 1 byte to Apple (C = byte)
  1211. RDWORD:    EQU    0FFE6H        ; Read 2 bytes from Apple (DE = word)
  1212. WRWORD:    EQU    0FFE9H        ; Write 2 bytes to Apple (DE = word)
  1213. WRLOTS:    EQU    0FFEFH        ; FROM (HL), SEND NUM BYTES IN DE TO HOST
  1214. POKLOT:    EQU    2
  1215. CALL1:    EQU    3
  1216. PEEK1:    EQU    6        ; Command
  1217. POKE1:    EQU    7        ; Command
  1218. ;
  1219. POKE:    MOV    B,A
  1220.     MVI    C,POKE1
  1221.     CALL    WRBYTE
  1222.     CALL    WRWORD
  1223.     MOV    C,B
  1224.     CALL    WRBYTE
  1225.     RET
  1226. ;
  1227. PEEK:    MVI    C,PEEK1
  1228.     CALL    WRBYTE
  1229.     CALL    WRWORD
  1230.     CALL    RDBYTE
  1231.     RET
  1232. ;
  1233. CALL65:    MVI    C,CALL1
  1234.     CALL    WRBYTE
  1235.     CALL    WRWORD
  1236.     RET
  1237. ;
  1238. GSINIT:                ; Initialize and move 6502 code in
  1239. ;
  1240.     CALL    LOADIT
  1241. ;
  1242. RESUME:    EQU    $
  1243.     ORG    5120H        ; Hope it works...
  1244. ;
  1245. LOADIT:    LXI    D,0C00DH+SLOTOF2
  1246.     CALL    PEEK
  1247.     STA    INITPT
  1248. ;
  1249.     LXI    D,0C00FH+SLOTOF2
  1250.     CALL    PEEK
  1251.     STA    WRITPT
  1252. ;
  1253.     LXI    D,0C00EH+SLOTOF2
  1254.     CALL    PEEK
  1255.     STA    READPT
  1256. ;
  1257.     LXI    D,0C012H+SLOTOF2
  1258.     CALL    PEEK
  1259.     STA    EXTPT
  1260. ;
  1261.     MVI    C,POKLOT    ; Going to put the 6502 code in place
  1262.     CALL    WRBYTE
  1263.     LXI    D,0300H        ; Put it at 300H
  1264.     CALL    WRWORD
  1265.     LXI    D,END65-ST65+1    ; Length
  1266.     CALL    WRWORD
  1267.     LXI    H,ST65
  1268.     LXI    D,END65-ST65+1
  1269.     CALL    WRLOTS        ; Put it in place
  1270. ;
  1271.     RET
  1272. ;
  1273. ST65:
  1274.     DB    04CH,013H,003H    ;     JMP    INIT
  1275.     DB    04CH,01AH,003H    ;     JMP    READ
  1276.     DB    04CH,024H,003H    ;     JMP    WRITE
  1277.     DB    04CH,02FH,003H    ;     JMP    SETDTR
  1278.     DB    04CH,03EH,003H    ;     JMP    SETCMD
  1279.     DB    04CH,06AH,003H    ;     JMP    STATUS
  1280.     DS    1        ; DATA    DFS    1
  1281.     DB    0A2H,0C0H+SLOT    ; INIT    LDX    #Cn
  1282.     DB    0A0H,SLOTOFF    ;    LDY    #n0
  1283.     DB    04CH
  1284. INITPT    DS    1        ;
  1285.     DB    0C0H+SLOT    ;    JMP    CARD_INIT
  1286.     DB    0ADH,012H,003H    ; WRITE    LDA    DATA
  1287.     DB    0A2H,0C0H+SLOT    ;    LDX    #Cn
  1288.     DB    0A0H,SLOTOFF    ;    LDY    #n0
  1289.     DB    04CH
  1290. WRITPT    DS    1
  1291.     DB    0C0H+SLOT    ;    JMP    CARD_WRIT
  1292.     DB    0A2H,0C0H+SLOT    ; READ    LDX    #Cn
  1293.     DB    0A0H,SLOTOFF    ;    LDY    #n0
  1294.     DB    020H
  1295. READPT    DS    1
  1296.     DB    0C0H+SLOT    ;    JSR    CARD_READ
  1297.     DB    08DH,012H,003H    ;    STA    DATA
  1298.     DB    060H        ;    RTS
  1299.     DB    0ADH,012H,003H    ;SETDTR    LDA    DATA
  1300.     DB    08DH,07EH,003H    ;    STA    DTRBYT
  1301.     DB    0A9H,07AH    ;    LDA    #>DTRBUF
  1302.     DB    0A2H,003H    ;    LDX    #<DTRBUF
  1303.     DB    0A0H,000H    ;    LDY    #00
  1304.     DB    04CH
  1305. EXTPT    DS    1
  1306.     DB    0C0H+SLOT    ;EXTJMP    JMP    CARD_EXT
  1307.     DB    0A9H,000H    ;SETCMD    LDA    #00
  1308.     DB    08DH,081H,003H    ;    STA    CMDSPOT
  1309.     DB    0A9H,080H    ;    LDA    #>CMDBUF
  1310.     DB    0A2H,003H    ;    LDX    #<CMDBUF
  1311.     DB    0A0H,000H    ;    LDY    #00
  1312.     DB    020H,03BH,003H    ;    JSR    EXTJMP
  1313.     DB    0ADH,086H,003H    ;    LDA    CMDBYT
  1314.     DB    02CH,012H,003H    ;    BIT    DATA
  1315.     DB    010H,003H    ;    BPL    SKIP
  1316.     DB    029H,07FH    ;    AND    #7F
  1317.     DB    02CH        ;    DFB    $2CH    ;SKIP 2 BYTES
  1318.     DB    009H,080H    ; SKIP    ORA    #80
  1319.     DB    08DH,086H,003H    ;    STA    CMDBYT
  1320.     DB    0A9H,001H    ;    LDA    #01
  1321.     DB    08DH,081H,003H    ;    STA    CMDSPOT
  1322.     DB    0A9H,080H    ;    LDA    #>CMDBUF
  1323.     DB    0A2H,003H    ;    LDX    #<CMDBUF
  1324.     DB    0A0H,000H    ;    LDY    #00
  1325.     DB    04CH,03BH,003H    ;    JMP    EXTJMP
  1326.     DB    0A9H,088H    ;STATUS    LDA    #>STATBUF
  1327.     DB    0A2H,003H    ;    LDX    #<STATBUF
  1328.     DB    0A0H,000H    ;    LDY    #0
  1329.     DB    020H,03BH,003H    ;    JSR    EXTJMP
  1330.     DB    0ADH,08CH,003H    ;    LDA    STATBYT
  1331.     DB    08DH,012H,003H    ;    STA    DATA
  1332.     DB    060H        ;    RTS
  1333.     DB    003H,00BH    ;    DFB    03,0B
  1334.     DS    4        ;    DFS    4
  1335.     DB    003H,001H    ;    DFB    03,01
  1336.     DS    6        ;    DFS    6
  1337.     DB    003H,006H    ;    DFB    03,06
  1338.     DS    4        ;    DFS    4
  1339. END65:    DS    1
  1340. ;
  1341.     ORG    RESUME
  1342. ;
  1343.     LXI    D,INIT65
  1344.     CALL    CALL65
  1345.     RET
  1346. ;
  1347. INIT65:    EQU    0300H
  1348. WRIT65:    EQU    0303H
  1349. READ65:    EQU    0306H
  1350. SDTR65:    EQU    0309H
  1351. SCMD65:    EQU    030CH
  1352. STAT65:    EQU    030FH
  1353. DATA65:    EQU    0312H
  1354. ;
  1355. RCVDATP:            ; Read a character
  1356.     PUSH    B
  1357.     PUSH    D
  1358.     PUSH    H
  1359.     LXI    D,READ65
  1360.     CALL    CALL65
  1361.     LXI    D,DATA65
  1362.     CALL    PEEK
  1363.     POP    H
  1364.     POP    D
  1365.     POP    B
  1366.     RET
  1367. SNDDATP:            ; Write a character, or a command byte
  1368. GSSEND: PUSH    B
  1369.     PUSH    D
  1370.     PUSH    H
  1371.     LXI    D,DATA65
  1372.     CALL    POKE
  1373.     CALL    CALL65
  1374.     POP    H
  1375.     POP    D    
  1376.     POP    B
  1377.     RET
  1378. RCVCTL1:            ; Get status byte
  1379.     PUSH    B
  1380.     PUSH    D
  1381.     PUSH    H
  1382.     LXI    D,STAT65
  1383.     CALL    CALL65
  1384.     LXI    D,DATA65
  1385.     CALL    PEEK
  1386.     POP    H
  1387.     POP    D
  1388.     POP    B
  1389.     RET
  1390. CMDENA:                ; Enable Ctrl-A cmds in out stream
  1391.     MVI    A,0FFH
  1392.     LXI    D,DATA65
  1393.     CALL    POKE
  1394.     LXI    D,SCMD65
  1395.     JMP    CALL65
  1396. CMDDIS:                ; Disable Ctrl-A cmds in out stream
  1397.     MVI    A,000H
  1398.     LXI    D,DATA65
  1399.     CALL    POKE
  1400.     LXI    D,SCMD65
  1401.     JMP    CALL65
  1402. CMDDTR:                ; Bit 7 of A is new DTR state
  1403.     LXI    D,DATA65
  1404.     CALL    POKE
  1405.     LXI    D,SDTR65
  1406.     JMP    CALL65
  1407. ;
  1408.      ENDIF
  1409. ;
  1410. ;
  1411. ;-----------------------------------------------------------------------
  1412. ;
  1413. ; Use the 'SET' command to select a desired baud rate
  1414. ;
  1415. STUPR    EQU    $
  1416. ;
  1417.      IF    ALSDSP OR COMCARD OR SSM
  1418.     RET
  1419.      ENDIF            ; ALSDSP OR COMCARD OR SSM
  1420. ;
  1421.      IF    NOT ALSDSP OR NOT COMCARD OR NOT SSM
  1422.     CALL    J$CMDSPL    ; Gives us CMDBUF+6
  1423.     JNC    STUPR2
  1424. ;
  1425. STUPR1:    CALL    J$ILPRT
  1426.     DB    'Input Baud Rate (300, 1200, 2400, 9600): ',0
  1427.     LXI    D,BAUDBUF    ; Point to new input buffer
  1428.     CALL    J$INBUF
  1429.     CALL    J$CRLF
  1430.     LXI    D,BAUDBUF+2
  1431. ;
  1432. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  1433.     DB    '300',0
  1434.     JNC    OK300        ; Go if got match
  1435.     CALL    J$INLNCP
  1436.     DB    '1200',0
  1437.     JNC    OK1200
  1438.     DB    '2400',0
  1439.     JNC    OK2400
  1440.     CALL    J$INLNCP
  1441.     DB    '9600',0
  1442.     JNC    OK9600
  1443.     CALL    J$ILPRT        ; All matches failed, tell operator
  1444.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  1445.     JMP    STUPR1        ; Try again
  1446. ;
  1447.      IF    NOT (ALSDSP OR VERSA)
  1448. OK300:    MVI    A,1        ; MSPEED 300 baud value
  1449.     MVI    B,BD300        ; Get 300 baud value for 2651 in 'B'
  1450.     JMP    LOADBD        ; Go load everything
  1451. ;
  1452. OK1200:    MVI    A,5
  1453.     MVI    B,BD1200
  1454.     JMP    LOADBD
  1455. ;
  1456. OK2400:    XRA    A
  1457.     STA    MANUAL
  1458.     MVI    A,6
  1459.     MVI    B,BD2400
  1460.     JMP    LOADBD
  1461. ;
  1462. OK9600:    MVI    A,8
  1463.     MVI    B,BD9600
  1464. ;
  1465. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  1466.     JMP    INITMOD1    ; Reset to new baudrate
  1467.      ENDIF            ; NOT (ALSDSP OR VERSA)
  1468. ;.....
  1469. ;
  1470. ;
  1471.      IF    ALSDSP
  1472. OK300:
  1473. OK1200:
  1474. OK2400:
  1475. OK9600:    RET
  1476.      ENDIF            ; ALSDSP
  1477. ;
  1478.      IF    VERSA
  1479. OK300:    CALL    RCVAN3C        ; Clear Annunciator #3 for 300 baud
  1480.     MVI    A,1        ; Set MSPEED for 300 baud
  1481.     STA    MSPEED        ; For 300 baud
  1482.     RET
  1483. ;
  1484. OK1200:    CALL    RCVAN3S        ; Set Annunciator #3 for 1200 baud
  1485.     MVI    A,5        ; Set MSPEED for 1200 bps
  1486.     STA    MSPEED        ; For 1200 baud
  1487.     RET
  1488. ;
  1489. OK2400:    JMP    OK1200        ; Does not support 2400 bps
  1490. ;
  1491. OK9600:    JMP    OK1200        ; Does not support 9600 bps
  1492. ;.....
  1493. ;
  1494. ;
  1495. ; Table of baud rate parameters
  1496. ;
  1497.      IF    APR OR CCS
  1498. BD300    EQU    16H        ; Divide by 64 (set by last 2 bits 10)
  1499. BD1200    EQU    15H        ; Divide by 16 (set by last 2 bits 01)
  1500. BD2400    EQU    00H        ; See note at the top for other speeds
  1501. BD9600    EQU    00H
  1502.      ENDIF            ; APR OR CCS
  1503. ;
  1504.      IF    CPS
  1505. BD300    EQU    35H
  1506. BD1200    EQU    37H
  1507. BD2400    EQU    3AH
  1508. BD9600    EQU    3EH
  1509.      ENDIF            ; CPS
  1510. ;
  1511.      IF    SSC OR BASIS
  1512. BD300    EQU    16H
  1513. BD1200    EQU    18H
  1514. BD2400    EQU    1AH
  1515. BD9600    EQU    1EH
  1516.      ENDIF            ; SSC
  1517. ;
  1518.      IF    IIGS
  1519. BD300    EQU    06H
  1520. BD1200    EQU    08H
  1521. BD2400    EQU    010H
  1522. BD9600    EQU    014H
  1523.      ENDIF
  1524. ;
  1525. BAUDBUF:DB    10,0,0,0,0,0
  1526.     DB    0,0,0,0,0,0
  1527. ;
  1528.      ENDIF            ; NOT ALSDSP OR NOT COMCARD OR NOT SSM
  1529. ;.....
  1530. ;
  1531. ;
  1532. ;-----------------------------------------------------------------------
  1533. ; NOTE: Must terminate prior to 0400H
  1534. ;
  1535.     END
  1536.