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-1.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  15KB  |  461 lines

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