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 / MEX / MXH-AP55.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  26KB  |  914 lines

  1.  TITLE    'MEX Overlay for Apple ][ / SSC / Smartmodem'
  2. ;
  3. ;  MXH-AP55.ASM
  4. ;
  5. REV    EQU    55        ; 3 May 1987
  6. ;
  7. ; This overlay is specific for the following hardware:
  8. ;
  9. ;    Apple ][ +/e  with PCPI Applicard
  10. ;    Apple Super Serial Card
  11. ;
  12. ; Important Note:
  13. ;    Rev 5.5 introduces the Interrupt/Buffer concept.  This requires
  14. ; the use of an Applicard driver, in this case RINGBUF.DVR.  Operation
  15. ; in this mode eliminates the infamous character loss on scroll problem
  16. ; up to 2400 baud. SET INTerrupt control has been added to this official
  17. ; release to allow bypassing the INT mode if the INT/Buffer is found to
  18. ; be buggy or as I found, I had two SuperSerial cards in, 1 with and 1 w/0
  19. ; interrupts and this was a problem. (By the way I used the 2nd card for
  20. ; a network I/O). In any event, it's handy have the set feature and the
  21. ; default can be CLONEed in.               -Jim
  22. ;------------------------------------------------------------------
  23. ; REVISION HISTORY:
  24. ;------+---------+----------------+--------------------------------
  25. ; Rev. |  Date     |     Author      |      Description
  26. ;------+---------+----------------+--------------------------------
  27. ; 5.5  | 3 May 87| Bob Sass/      | - added support for RINGBUF.DVR
  28. ;      |     |    Jim Lill  |   See note above, Tested with //e
  29. ;------+---------+----------------+--------------------------------
  30. ; 5.4  |16 Apr 87| Jim Lill      | -speeded up calls to the Modem
  31. ;      |     |          |  Port by recoding PEEK and POKE and
  32. ;      |     |          |  changing CALLs to JMPs. Picked
  33. ;      |     |          |  up 19 bytes.
  34. ;------------------------------------------------------------------
  35. ; 5.3  |13 Dec 86| Jim Lill      | -added SET WAIT code for use with
  36. ;      |     |          |  MXO-SM14 and cleaned up SET displays
  37. ;------+---------+----------------+--------------------------------
  38. ; 5.2  | 1 Nov 86| Jim Lill      | -eliminated Modem specific section
  39. ;      |     |          |  requires use of Modem overlay
  40. ;      |     |          |  such as MXO-SM14 or MXM-2413
  41. ;      |     |          |  This seems to solve a timing problem
  42. ;      |     |          |  that occurred when loading 2413
  43. ;      |     |          |  over AP51
  44. ;------+---------+----------------+--------------------------------
  45. ; 5.1  | 5 Apr 86| Jim Lill      | -changed CLSMSG and EOSMSG
  46. ;      |     |          | -added INITBAUD equate for setting
  47. ;      |     |          |  MSPEED and baud in INITPORT
  48. ;------+---------+----------------+--------------------------------
  49. ; 5.0  |1 Apr 86 | Jim Lill      | created adaption, includes DCD
  50. ;      |     |          | and a spot for RNG detect.
  51. ;------+---------+----------------+--------------------------------
  52. ; IMPORTANT NOTE:
  53. ;    This overlay is based on MXO-AP50.ASM by Henry Middlebrook
  54. ;    Refer to it for additional info. The changes in this overlay
  55. ;    could be easily adapted to other Middlebrook work like AP34
  56. ;    To find changes, search for "MEXplus"
  57. ;
  58. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59.  
  60. YES        EQU    0FFH
  61. NO        EQU    0
  62.  
  63. ;---------------------------------------------------------------------
  64. ; Options....
  65.  
  66. INITBAUD    EQU    5    ;Initial Baud Rate
  67.                 ; 0=110   5=1200
  68.                 ; 1=300   6=2400
  69.                 ;   450   7=4800
  70.                 ; 3=610   8=9600
  71.                 ; 4=710   9=19200
  72. Z80XTAL        EQU    73    ;set to Z80 CPU crystal MHz
  73.                 ;times correction factor
  74.                 ;e.g: 6Mhz * 12.16666= 73
  75. WAIT        EQU    YES    ;set to YES if you use the
  76.                 ;SET WAIT command and MXO-SM14 etc
  77. WAITSEC        EQU    45    ;default wait time
  78. ;---------------------------------------------------------------------
  79. BELL        EQU    07H    ;bell
  80. CR        EQU    0DH    ;carriage return
  81. ESC        EQU    1BH    ;escape
  82. LF        EQU    0AH    ;linefeed
  83. TAB        EQU    09H    ;tab
  84. ;
  85. ;----------------------------------------------------------------------
  86. ;    Apple Super Serial Card equates
  87. ;    -------------------------------
  88. ;
  89. SSCSLOT        EQU    2            ;Slot of Super Serial Card
  90. MODDATP        EQU    0C088H + (SSCSLOT*10H)    ;data port of ACIA
  91. MODSTAP        EQU    0C089H + (SSCSLOT*10H)    ;status port of ACIA
  92. MODCTLP        EQU    0C08BH + (SSCSLOT*10H)    ;control port of ACIA
  93. MODCMDP        EQU    0C08AH + (SSCSLOT*10H)    ;command port of ACIA
  94. ;
  95. ;
  96. RDBYTE        EQU    0FFE0H    ;Read a Byte from Apple (A = BYTE)
  97. WRBYTE        EQU    0FFE3H    ;Write a Byte to Apple (C = BYTE)
  98. RDWORD        EQU    0FFE6H    ;Read 2 Bytes from Apple (DE = BYTES)
  99. WRWORD        EQU    0FFE9H    ;Write 2 Bytes to Apple (DE = BYTES)
  100. RDNBYTS        EQU    0FFECH    ;Read N Bytes (DE = COUNT, HL = BUFFER)
  101. WRNBYTS        EQU    0FFEFH    ;Write N Bytes (DE = COUNT, HL = BUFFER)
  102. ;
  103. PEEK1BYTE    EQU    6    ;Command to Peek 1 Byte in the Apple
  104. POKE1BYTE    EQU    7    ;Command to Poke 1 Byte to the Apple
  105. ;
  106. ; New DCD routine equate MEXplus
  107. ;
  108. CTSMSK        EQU    00100000B    ;mask to test for carrier
  109. ;
  110. ; Status bit equates for SSC serial port
  111. ;
  112. MDSNDB        EQU    10H
  113. MDSNDR        EQU    10H
  114. MDRCVB        EQU    08H
  115. MDRCVR        EQU    08H
  116. ;
  117. ; Equates for PSW (Parity, Stop Bit, Word Length) used by SSC ACIA
  118. ;  In these bytes the high nibble is the Word Length mask, the low
  119. ;  nibble is the Parity mask for the ACIA PSWFIX routine.
  120. ;
  121. P8N1        EQU    010H    ;8 NONE 1
  122. P7E1        EQU    036H    ;7 EVEN 1
  123. P7O1        EQU    032H    ;7 ODD 1
  124. P7N1        EQU    030H    ;7 NONE 1
  125. ;
  126. BRKMSK        EQU    0CH    ;mask byte for BREAK function
  127. DISCB        EQU    0AH    ;command byte for ACIA to drop DTR
  128. ;
  129. ;----------------------------------------------------------------------
  130. ;
  131. ;    MEX Service Processor Calls
  132. ;
  133. MEX    EQU    0D00H    ;address of the service processor
  134. INMDM    EQU    255    ;get char from port to A, CY=no more in 100 ms
  135. TIMER    EQU    254    ;delay 100ms * reg B
  136. TMDINP    EQU    253    ;B=# secs to wait for char, cy=no char
  137. CHEKCC    EQU    252    ;check for ^C from KBD, Z=present
  138. SNDRDY    EQU    251    ;test for modem-send ready
  139. RCVRDY    EQU    250    ;test for modem-receive ready
  140. SNDCHR    EQU    249    ;send a character to the modem (after sndrdy)
  141. RCVCHR    EQU    248    ;recv a char from modem (after rcvrdy)
  142. LOOKUP    EQU    247    ;table search: see CMDTBL comments for info
  143. PARSFN    EQU    246    ;parse filename from input stream
  144. BDPARS    EQU    245    ;parse baud-rate from input stream
  145. SBLANK    EQU    244    ;scan input stream to next non-blank
  146. EVALA    EQU    243    ;evaluate numeric from input stream
  147. LKAHED    EQU    242    ;get nxt char w/o removing from input
  148. GNC    EQU    241    ;get char from input, cy=1 if none
  149. ILP    EQU    240    ;inline print
  150. DECOUT    EQU    239    ;decimal output
  151. PRBAUD    EQU    238    ;print baud rate
  152. PRNTBL    EQU    237    ;print command table in columns (HL=addr)
  153. PRID    EQU    236    ;print MEX ID string on console
  154. ;
  155. CONOUT    EQU    2    ;simulated BDOS function 2: console char out
  156. PRINT    EQU    9    ;simulated BDOS function 9: print string
  157. INBUF    EQU    10    ;input buffer, same structure as BDOS 10
  158. ;
  159. ;
  160. ;======================================================================
  161. ;
  162.     ORG    100H    ;we begin
  163. ;
  164. ; changed jumps for MEXplus
  165. ;
  166.     DB    0C3H    ;flags a LOADable file (for 8080)
  167.     DS    2    ;MEX has a JMP START here
  168. ;
  169. ; The following variables are located at the beginning of the program
  170. ; to facilitate modification without the need of re-assembly. They will
  171. ; be moved in MEX 2.0.
  172. ;
  173. PMODEM:    DB    YES    ;\ / These two locations are            103H
  174. SMODEM:    DB    NO    ;/ \ not referenced by MEX.            104H
  175. TPULSE:    DB    'T'    ;Tone/Pulse (used only in Smodem overlay)    105H
  176. CLOCK:    DB    Z80XTAL    ;CPU speed                    106H
  177. MSPEED:    DB    INITBAUD;sets display time for sending a file        107H
  178.             ;uses INITBAUD equate, changes during
  179.             ;use via PBAUD routine
  180. BYTDLY:    DB    1    ;default time to send character in        108H
  181.             ;terminal mode file transfer (0-9)
  182.             ;0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  183. CRDLY:    DB    1    ;end-of-line delay in terminal            109H
  184.             ;mode file transfer for slow BBS systems
  185.             ;0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  186. COLUMS:    DB    5    ;number of directory columns            10AH
  187. SETFL:    DB    YES    ;yes=user-defined SET command            10BH
  188. SCRTST:    DB    YES    ;yes=if home cursor and clear screen        10CH
  189.             ;routine at CLRSCRN
  190.     DB    0    ;was once ACKNAK, now spare            10DH
  191. BAKFLG:    DB    NO    ;yes=make .BAK file                10EH
  192. CRCDFL:    DB    YES    ;yes=default to CRC checking            10FH
  193.             ;no=default to Checksum checking
  194. TOGCRC:    DB    YES    ;yes=allow toggling of Checksum to CRC        110H
  195. CVTBS:    DB    NO    ;yes=convert backspace to rub            111H
  196. TOGLBK:    DB    YES    ;yes=allow toggling of bksp to rub        112H
  197. ADDLF:    DB    NO    ;no=no LF after CR to send file in        113H
  198.             ;terminal mode (added by remote echo)
  199. TOGLF:    DB    YES    ;yes=allow toggling of LF after CR        114H
  200. TRNLOG:    DB    NO    ;yes=allow transmission of logon        115H
  201.             ;write logon sequence at location LOGON
  202. SAVCCP:    DB    YES    ;yes=do not overwrite CCP            116H
  203. LOCNXT:    DB    NO    ;yes=local cmd if EXTCHR precedes        117H
  204.             ;no=not local cmd if EXTCHR precedes
  205. TOGLOC:    DB    YES    ;yes=allow toggling of LOCNXTCHR        118H
  206. LSTTST:    DB    YES    ;yes=allow toggling of printer on/off        119H
  207.             ;in terminal mode. Set to no if using
  208.             ;the printer port for the modem
  209. XOFTST:    DB    YES    ;yes=allow testing of XOFF from remote        11AH
  210.             ;while sending a file in terminal mode
  211. XONWT:    DB    NO    ;yes=wait for XON after sending CR while    11BH
  212.             ;transmitting a file in terminal mode
  213. TOGXOF:    DB    YES    ;yes=allow toggling of XOFF testing        11CH
  214. IGNCTL:    DB    NO    ;yes=do not send control characters        11DH
  215.             ;above CTL-M to CRT in terminal mode
  216.             ;no=send any incoming CTL-char to CRT
  217. EXTRA1:    DB    WAITSEC    ;passes wait time to modem overlay
  218. EXTRA2:    DB    0    ;for future expansion                11FH
  219. BRKCHR:    DB    '@'-40H    ;^@ = Send a 300 ms. break tone         120H
  220. NOCONN:    DB    'N'-40H    ;^N = Disconnect from phone line        121H
  221. LOGCHR:    DB    'L'-40H    ;^L = Send logon                122H
  222. LSTCHR:    DB    'P'-40H    ;^P = Toggle printer                123H
  223. UNSVCH:    DB    'R'-40H    ;^R = Close input text buffer            124H
  224. TRNCHR:    DB    'T'-40H    ;^T = Transmit file to remote            125H
  225. SAVCHR:    DB    'Y'-40H    ;^Y = Open input text buffer            126H
  226. EXTCHR:    DB    '^'-40H    ;^^ = Send next character            127H
  227. ;
  228.     DS    2    ;unused in this overlay
  229. ;
  230. ; Jump table accessed by MEX to write/read serial port
  231. ;
  232. IN$MODSTAP:    JMP    RD$MODSTAP    ;read ACIA status port        12AH
  233.         DS    7
  234. OUT$MODDATP:    JMP    WR$MODDATP    ;send character to ACIA     134H
  235.         DS    7
  236. IN$MODDATP:    JMP    RD$MODDATP    ;read character from ACIA    13EH
  237.         DS    7
  238. ;
  239. ; Bit-test routines.  These will be merged with the above
  240. ; routines in MEX 2.0 to provide a more reasonable format
  241. ;
  242. MASKR:        ANI    MDRCVB ! RET    ;bit to test for receive ready    148H
  243. TESTR:        CPI    MDRCVR ! RET    ;value of rcv. bit when ready    14BH
  244. MASKS:        ANI    MDSNDB ! RET    ;bit to test for send ready    14EH
  245. TESTS:        CPI    MDSNDR ! RET    ;value of send bit when ready    151H
  246. ;---------------------------------------------------------------------------
  247. ; MEXplus changes:
  248. ;  - was unused area. >>> MUST total 12bytes <<<
  249. ;  - now used for the Ringing and Carrier Detect jumps
  250. ;
  251. DCDTEST:    JMP    DCDVEC        ;jump to carrier-detect routine 154H
  252. RNGTEST:    JMP    RNGVEC        ;jump to ring detect routine    157H
  253.                     ;
  254.         DS    6        ;remainder of space
  255. ;
  256. ;---------------------------------------------------------------------------
  257. ;
  258. LOGON:        DS    2        ;not used by MEX        160H
  259. DIALV:        DS    3        ;used by Modem overlay        162H
  260. DISCV:        JMP    DISCON        ;drops DTR to hang-up fast!    165H
  261. GOODBV:        JMP    GOODBYE        ;called before exit to CPM    168H
  262. INMODV:        JMP    INITPORT    ;go to user written routine    16BH
  263. NEWBDV:        JMP    PBAUD        ;changes baud with phone #    16EH
  264. NOPARV:        RET  !    NOP  !    NOP    ;set modem for no-parity    171H
  265. PARITV:        RET  !    NOP  !    NOP    ;set modem parity        174H
  266. SETUPV:        JMP    SETCMD        ;                177H
  267. SPMENV:        DS    3        ;not used by MEX        17AH
  268. VERSNV:        JMP    SYSVER        ;                17DH
  269. BREAKV:        JMP    SENDBRK        ;                180H
  270. ;
  271. ; The following jump vector provides the overlay with access to special
  272. ; routines in the main program (retained and supported in the main pro-
  273. ; gram for MDM overlay compatibility). These should not be modified by
  274. ; the overlay.
  275. ;
  276. ; Note that for MEX 2.0 compatibility, you should not try to use these
  277. ; routines, since this table will go away with MEX 2.0 (use the MEX
  278. ; service call processor instead).
  279. ;
  280. ILPRTV:        DS    3    ;replace with MEX function 9        183H
  281. INBUFV:        DS    3    ;replace with MEX functin 10        186H
  282. ILCMPV:        DS    3    ;replace with table lookup funct 247    189H
  283. INMDMV:        DS    3    ;replace with MEX function 255        18CH
  284. NXSCRV:        DS    3    ;not supported by MEX            18FH
  285. TIMERV:        DS    3    ;replace with MEX function 254        192H
  286. ;
  287. ; Clear/screen and clear/end-of-screen. Each routine must use the
  288. ; full 9 bytes alloted (may be padded with nulls).
  289. ;
  290. ;
  291. CLREOS:        LXI    D,EOSMSG    ;                195H
  292.         MVI    C,PRINT
  293.         CALL    MEX
  294.         RET
  295. ;
  296. CLS:        LXI    D,CLSMSG    ;                19EH
  297.         MVI    C,PRINT
  298.         CALL    MEX
  299.         RET
  300. ;
  301. ;        *** END OF FIXED FORMAT AREA ***
  302. ;--------------------------------------------------------------------------
  303. ; Make sure MEXplus has all of its' reserved area..
  304. ;
  305.         ORG    0200H
  306.  
  307. ;--------------------------------------------------------------------------
  308. ;        Overlay  Fixed    Messages  Area
  309. ;
  310. ; these codes changed to match PCPI CONFIGSV values for Televideo 950
  311. ;
  312. ;
  313. EOSMSG:    DB    ESC,89,0,0,'$'        ;clear to end of screen message
  314. ;
  315. CLSMSG:    DB    ESC,42,0,0,'$'        ;clear screen message
  316. ;
  317. VERMSG:    DB    CR,LF,'MEX for Apple ][ / PCPI / SSC',CR,LF
  318.     DB    ' Version: ',REV/10+'0','.'
  319.     DB    REV MOD    10+'0'
  320.     DB    CR,LF,LF,'$'
  321.     DB    0,'Overlay by Middlebrook/Lill',0,'$'
  322. ;
  323. ;----------------------------------------------------------------------
  324. ; These routines are specific to the Apple ][+ with Applicard.    The
  325. ; routines read modem hardware (Apple Super Serial Card ACIA) directly
  326. ; from the Applicard.
  327. ;
  328. ; Read the Command Port of ACIA
  329. ;
  330. RD$MODCMDP:    PUSH    D
  331.         LXI    D,MODCMDP
  332.         JMP    PEEK
  333. ;
  334. ; Write to the Command Port of ACIA
  335. ;
  336. WR$MODCMDP:    PUSH    D
  337.         LXI    D,MODCMDP
  338.         JMP    POKE
  339. ;
  340. ; Write to the Control Port of the ACIA
  341. ;
  342. WR$MODCTLP:    PUSH    D
  343.         LXI    D,MODCTLP
  344.         JMP    POKE
  345. ;
  346. ; Read the Control Port of the ACIA
  347. ;
  348. RD$MODCTLP:    PUSH    D
  349.         LXI    D,MODCTLP
  350.         JMP    PEEK
  351.  
  352. ;.................................
  353. ;
  354. ; Read Data Port of ACIA
  355. ;
  356.  
  357. RD$MODDATP:
  358.         LDA    INTFLG        ;get the INT flag
  359.         ORA    A        ;test it
  360.         JZ    NONINTDATP    ;it not set jump to non-irq read
  361. INTDATP:    PUSH    B        ;
  362.         MVI    C,0F1H        ;Device 28 (read)
  363.         CALL    WRBYTE
  364.         CALL    RDBYTE
  365.         POP    B
  366.         RET
  367.  
  368. NONINTDATP:    PUSH    D        ;non-irq read
  369.         LXI    D,MODDATP
  370.         JMP    PEEK
  371. ;.................................
  372. ;
  373. ; Read the Status Port of the ACIA
  374. ;
  375. RD$MODSTAP:
  376.         LDA    INTFLG        ;see if in INT mode
  377.         ORA    A        ;
  378.         JZ    NONINTSTAP    ;if not use non-INT
  379.  
  380. INTSTAP:    PUSH    B        ;INT method
  381.         MVI    C,0F3H        ;Device 28 (other)
  382.         CALL    WRBYTE
  383.         MVI    C,1
  384.         CALL    WRBYTE
  385.         CALL    RDBYTE
  386.         POP    B
  387.         RET
  388.  
  389. NONINTSTAP:    PUSH    D        ;non-INT method
  390.         LXI    D,MODSTAP
  391.         JMP    PEEK
  392. ;...............................
  393. ;
  394. ; Write to the Serial Data Port of the ACIA
  395. ;
  396. WR$MODDATP:    PUSH    D
  397.         LXI    D,MODDATP
  398.         JMP    POKE
  399. ;.............................
  400. ;
  401. ; Peek at 1 byte from Apple 6502 address space
  402. ; ENTRY: DE = Address in Apple
  403. ; EXIT: A = Data
  404. ;
  405. PEEK:    PUSH    B
  406.     MVI    C,PEEK1BYTE
  407.     CALL    WRBYTE
  408.     CALL    WRWORD
  409.     CALL    RDBYTE
  410.     POP    B
  411.     POP    D
  412.     RET
  413. ;
  414. ; Poke 1 byte to Apple 6502 address space
  415. ; ENTRY: DE = Address in Apple
  416. ; EXIT: A = Data
  417. ;
  418. POKE:    PUSH    B
  419.     MOV    B,A
  420.     MVI    C,POKE1BYTE
  421.     CALL    WRBYTE
  422.     CALL    WRWORD
  423.     MOV    C,B
  424.     CALL    WRBYTE
  425.     POP    B
  426.     POP    D
  427.     RET
  428. ;
  429. ;----------------------------------------------------------------------
  430. ; The new stuff for MEXplus
  431. ;
  432. ; Data Carrier Detect Routine
  433. ;
  434. DCDVEC:        CALL    RD$MODSTAP    ;read SSC status port
  435.         ANI    CTSMSK        ;isolate carrier bit
  436.         JNZ    NOCARR        ;0=carrier detected
  437.         CMA            ;make it 0ffh
  438.         RET            ;
  439. NOCARR:        XRA    A        ;make it 0
  440.         RET            ;
  441. ;
  442. ; Ring Detect Routine
  443. ;
  444. RNGVEC:        JMP    DCDVEC        ;overlay doesn't know
  445. ;
  446. ;----------------------------------------------------------------------
  447. ;
  448. ; This routine sends a timed Break to modem from SSC card.
  449. ;
  450. SENDBRK:CALL    RD$MODCMDP    ;get current command status
  451.     STA    CMDSV
  452.     ORI    BRKMSK        ;mask to make ACIA send BREAK
  453.     CALL    WR$MODCMDP    ;send command
  454.     MVI    B,5
  455.     MVI    C,TIMER        ;wait 500 msecs
  456.     CALL    MEX
  457.     LDA    CMDSV        ;get old command state
  458.     JMP    WR$MODCMDP    ;put it back
  459. ;
  460. ;.....
  461.  
  462. ; You can add your own routine here to set DTR low and/or send a break
  463. ; tone to disconnect when exiting to CPM.
  464. ;
  465. GOODBYE:
  466.     LDA    INTFLG        ;get the INT flag
  467.     ORA    A        ;is it set?
  468.     JZ    BYE        ;jump if not
  469.     CALL    INTOFF
  470. BYE:    RET
  471. ;................................
  472. ;
  473. ;  Turn off 6502 interrupts.
  474. ;
  475. INTOFF:    MVI    C,0F3H        ;Device 28 (other)
  476.     CALL    WRBYTE
  477.     MVI    C,20
  478.     CALL    WRBYTE
  479.     CALL    RDBYTE
  480.     RET
  481. ;.................................
  482. ;
  483. ;  Turn On 6502 Interrupts
  484. ;
  485. INTON:    MVI    C,0F3H        ;Device 28 (other)
  486.     CALL    WRBYTE
  487.     MVI    C,21
  488.     CALL    WRBYTE
  489.     CALL    RDBYTE
  490.     RET
  491. ;.....
  492. ;
  493. INITPORT:            ;set up the default port conditions
  494.  
  495. ; The following is used to initialize memory locations to eight data bits,
  496. ; no parity, one stop bit, and baud=INITBAUD
  497.  
  498.     LDA    INTFLG        ;get the INT flag
  499.     ORA    A        ;test it
  500.     JZ    SETIT        ;go set-up for non-INT
  501.  
  502.     MVI    A,09H        ;no parity, w/INT
  503.     JMP    SETIT        ;go do it
  504.  
  505. NONINT:    MVI    A,0BH        ;no parity, w/o INT
  506.  
  507. SETIT:    STA    PARSV        ;save it
  508.     MVI    A,10H        ;default 8 Data, 1 Stop Bits for ACIA
  509.     STA    WRDSV        ;save it
  510.     MVI    A,INITBAUD    ;set to initial baud equate
  511.     JMP    PBAUD        ;let PBAUD setup ACIA (PBAUD will call
  512.                 ;CHNGPORT below to actually setup ACIA)
  513. ;..............................
  514. ;
  515. ; This is the secondary entry used by the overlay to set baud,
  516. ; parity, and stop bit parameters of ACIA.
  517. ;
  518. CHNGPORT:
  519.     LDA    INTFLG        ;get the INT flag
  520.     ORA    A        ;test it
  521.     JZ    NOTINT        ;go do non-INT stuff
  522.     CALL    INTON        ;turn int on
  523.     LDA    PARSV        ;get current parity byte
  524.     ORI    09H        ;req'd for int
  525.     JMP    DOIT        ;go set up w/int
  526. NOTINT:    CALL    INTOFF        ;turn int off
  527.     LDA    PARSV        ;get current parity byte
  528.     ORI    0BH        ;w/o int
  529. DOIT:    STA    CMDSV        ;save byte for other uses
  530.     CALL    WR$MODCMDP    ;send to command port
  531.     PUSH    H
  532.     LXI    H,BAUDSV
  533.     LDA    WRDSV
  534.     ORA    M
  535.     STA    CTLSV        ;...and save for other uses
  536.     POP    H
  537.     JMP    WR$MODCTLP    ;now send to control port
  538. ;
  539. CMDSV:    DB    0        ;temporary storage
  540. CTLSV:    DB    0        ;temporary storage
  541. ;
  542. ;.....
  543. ;
  544. ; This routine drops DTR to force modem to disconnect.    Does NOT do
  545. ; any initialization.
  546. ;
  547. DISCON:    CALL    RD$MODCMDP    ;get current command status
  548.     STA    CMDSV        ;save it
  549.     MVI    A,DISCB        ;get disconnect byte (drops DTR)
  550.     CALL    WR$MODCMDP    ;send to ACIA
  551.     MVI    B,10
  552.     MVI    C,TIMER        ;wait 1 second
  553.     CALL    MEX
  554.     LDA    CMDSV        ;get back command status
  555.     CALL    WR$MODCMDP    ;put it back in ACIA register
  556.     MVI    B,10
  557.     MVI    C,TIMER        ;wait another second
  558.     JMP    MEX
  559. ;.....
  560. ;
  561. ; This routine changes the modem baud rate with phone list entry
  562. ;
  563. ; Set baud-rate code in A (if supported by your modem overlay).  PMMI
  564. ; supports only five rates, which are validated here. NOTE: this routine
  565. ; (ie, the one vectored through NEWBDV) should update MSPEED with the
  566. ; passed code, but ONLY if that rate is supported by the hardware.
  567. ;
  568. PBAUD:    PUSH    H        ;don't alter anybody
  569.     PUSH    D
  570.     PUSH    B
  571.     MOV    E,A        ;code to DE
  572.     MVI    D,0
  573.     LXI    H,BAUDTB    ;offset into table
  574.     DAD    D
  575.     MOV    A,M        ;fetch code
  576.     ORA    A        ;0 means unsupported code
  577.     JZ    PBEXIT        ;exit if so
  578.     STA    BAUDSV        ;good rate, save it for CHNGPORT
  579.     CALL    CHNGPORT    ;set baud (and PSW)
  580.     MOV    A,E        ;get speed code back
  581.     STA    MSPEED        ;make it current
  582.     JMP    PBEXIT + 1    ;jump error flag set
  583. PBEXIT:    STC            ;set return error for STBAUD caller
  584.     POP    B        ;all done
  585.     POP    D
  586.     POP    H
  587.     RET
  588. ;
  589. ; Table of baud rate parameters for supported rates
  590. ;
  591. BAUDSV:    DB    0            ;current baud byte
  592. BAUDTB:    DB    03H,06H,0,07H,0        ;110,300,450,610,710
  593.     DB    08H,0AH,0CH,0EH,0FH    ;1200,2400,4800,9600,19200
  594. ;.....
  595. ;
  596. ; Sign-on message
  597. ;
  598. SYSVER:    LXI    D,VERMSG
  599.     MVI    C,PRINT
  600.     JMP    MEX
  601. ;.....
  602. ;
  603. ; Newline on console
  604. ;
  605. CRLF:    MVI    A,CR
  606.     CALL    TYPE
  607.     MVI    A,LF        ;fall into TYPE
  608. ;
  609. ; type char in A on console
  610. ;
  611. TYPE:    PUSH    H        ;save 'em
  612.     PUSH    D
  613.     PUSH    B
  614.     MOV    E,A        ;align output character
  615.     MVI    C,CONOUT    ;print via MEX
  616.     CALL    MEX
  617.     POP    B
  618.     POP    D
  619.     POP    H
  620.     RET
  621. ;
  622. ;----------------------------------------------------------------------
  623. ;
  624. ; The remainder of this overlay implements a very versatile SET command
  625. ; -- if you prefer not to write a SET for your modem, you may delete the
  626. ; code from here to the END statement. Control is passed here after
  627. ; MEX parses a SET command.
  628. ;
  629. ;
  630. SETCMD:    MVI    C,SBLANK    ;any arguments?
  631.     CALL    MEX
  632.     JC    SETSHO        ;if not, go print out values
  633.     LXI    D,CMDTBL    ;parse command
  634.     CALL    TSRCH        ;from table
  635.     PUSH    H        ;any address on stack
  636.     RNC            ;if we have one, execute it
  637.     POP    H        ;nope, fix stack
  638. SETERR:    LXI    D,SETEMS    ;print error
  639.     MVI    C,PRINT
  640.     JMP    MEX
  641. ;
  642. SETEMS:    DB    CR,LF,'SET command error',CR,LF,'$'
  643. ;
  644. ; SET command table ... note that tables are constructed of command-
  645. ; name (terminated by high bit=1) followed by word-data-value returned
  646. ; in HL by MEX service processor LOOKUP.  Table must be terminated by
  647. ; a binary zero.
  648. ;
  649. ; Note that LOOKUP attempts to find the next item in the input stream
  650. ; in the table passed to it in HL ... if found, the table data item is
  651. ; returned in HL; if not found, LOOKUP returns carry set.
  652. ;
  653. CMDTBL:    DB    '?'+80H            ;"set ?"
  654.     DW    STHELP
  655.     DB    'BAU','D'+80H        ;"set baud"
  656.     DW    STBAUD
  657.     DB    'WP','S'+80H        ;"set PSW"
  658.     DW    STPSW
  659.     DB    'TON','E'+80H        ;'set TONE/PULSE byte to 'T'
  660.     DW    STTONE
  661.     DB    'PULS','E'+80H        ;'set TONE/PULSE byte to 'P'
  662.     DW    STPULSE
  663.     DB    'WAI','T'+80H        ;'set WAIT'
  664.     DW    SETDLY
  665.     DB    'IN','T'+80H        ;'set INT'
  666.     DW    SETINT
  667.     DB    0            ;<<=== table terminator
  668. ;
  669. ; SET <no-args>: print current statistics
  670. ;
  671. SETSHO:    LXI    H,SHOTBL    ;get table of SHOW subroutines
  672. SETSLP:    MOV    E,M        ;get table address
  673.     INX    H
  674.     MOV    D,M
  675.     INX    H
  676.     MOV    A,D        ;end of table?
  677.     ORA    E
  678.     RZ            ;exit if so
  679.     PUSH    H        ;save table pointer
  680.     XCHG            ;adrs to HL
  681.     CALL    GOHL        ;do it
  682.     CALL    CRLF        ;print newline
  683.     MVI    C,CHEKCC    ;check for console abort
  684.     CALL    MEX
  685.     POP    H        ;it's done
  686.     JNZ    SETSLP        ;continue if no abort
  687.     RET
  688. ;
  689. GOHL:    PCHL
  690. ;
  691. ; Table of SHOW subroutines
  692. ;
  693. SHOTBL:
  694.     DW    BDSHOW        ;displays current baud
  695.     DW    PSWSHOW        ;displays current PSW
  696.     DW    TPSHOW        ;displays current TPULSE byte (0105H)
  697.     DW    DLYSHO        ;displays current wait time
  698.     DW    INTSHO        ;displays current INT status
  699.     DW    CRLF
  700.     DW    0        ;<<== table terminator
  701. ;
  702. ; SET ?  processor
  703. ;
  704. STHELP:    CALL    CLS            ;clear screen
  705.     LXI    D,HLPMSG
  706.     MVI    C,PRINT
  707.     JMP    MEX
  708. ;
  709. ; The help message
  710. ;
  711. HLPMSG:    DB    CR,LF,'SET Commands available are:',CR,LF,LF
  712.     DB    'SET BAUD  <110, 300, 600, 1200, 2400, 4800,'
  713.     DB    ' 9600, or 19200>',CR,LF
  714.     DB    'SET WPS   <8N1, 7E1, 7O1, or 7N1> -- Word Length,'
  715.     DB    ' Parity, Stop Bits',CR,LF
  716.     DB    'SET TONE  (Sets flag for TONE  dialing)',CR,LF
  717.     DB    'SET PULSE (Sets flag for PULSE dialing)',CR,LF
  718. IF WAIT
  719.     DB    'SET WAIT "n" Seconds for Modem Result',CR,LF
  720. ENDIF
  721.  
  722.     DB    'SET INTerrupts <ON> or <OFF>',CR,LF
  723.     DB    CR,LF,LF,'$'
  724. ;
  725. ; SET BAUD processor
  726. ;
  727. STBAUD:    MVI    C,BDPARS    ;function code
  728.     CALL    MEX
  729.     JC    SETERR        ;invalid code
  730.     CALL    PBAUD        ;try to set it
  731.     JC    SETERR        ;unsupported code
  732. BDSHOW:    CALL    ILPRT        ;display baud
  733.     DB    'BAUD:',TAB,TAB,TAB,0
  734.     LDA    MSPEED
  735.     MVI    C,PRBAUD    ;use MEX routine
  736.     JMP    MEX
  737. ;
  738. ; SET PSW processor
  739. ;
  740. STPSW:    MVI    C,SBLANK
  741.     CALL    MEX
  742.     JC    SETERR        ;SET PSW should have had argument
  743.     LXI    D,PSWTBL    ;look for PSW match in table
  744.     CALL    TSRCH
  745.     JC    SETERR        ;not there, so report error
  746.     CALL    FIXPSW        ;routine to set PARSV and WRDSV
  747.     CALL    CHNGPORT    ;now fix ACIA registers
  748. ;
  749. PSWSHOW:
  750.     CALL    ILPRT
  751.     DB    '(W)ord(P)arity(S)top:',TAB,0
  752.     LDA    PSWSET
  753.     CPI    P8N1
  754.     JNZ    PSW1
  755.     CALL    ILPRT
  756.     DB    '8N1',0
  757.     RET
  758. PSW1:    CPI    P7E1
  759.     JNZ    PSW2
  760.     CALL    ILPRT
  761.     DB    '7E1',0
  762.     RET
  763. PSW2:    CPI    P7O1
  764.     JNZ    PSW3
  765.     CALL    ILPRT
  766.     DB    '7O1',0
  767.     RET
  768. PSW3:    CPI    P7N1
  769.     JNZ    PSW4
  770.     CALL    ILPRT
  771.     DB    '7N1',0
  772.     RET
  773. PSW4:    CALL    ILPRT
  774.     DB    '<< ERROR >>',0
  775.     RET
  776. ;
  777. ;
  778. PSWSET:    DB    010H        ;storage and default (8N1)
  779. PARSV:    DB    0BH        ;storage and default (no parity)
  780. WRDSV:    DB    010H        ;storage and default (8 data, 1 stop bits)
  781. ;
  782. FIXPSW:    MOV    A,L        ;PSW byte from table
  783.     STA    PSWSET        ;save it
  784.     ANI    0F0H        ;mask for word length bits
  785.     STA    WRDSV        ;put in storage
  786.     LDA    PSWSET        ;get back PSW byte
  787.     ANI    0FH        ;mask for parity bits
  788.     RLC            ;first shift into upper nibble..
  789.     RLC            ;...away we go...
  790.     RLC            ;.....and go...
  791.     RLC            ;......and done
  792.     ORI    0BH        ;mask needed for ACIA command register
  793.     STA    PARSV        ;put in storage
  794.     RET
  795. ;
  796. PSWTBL:    DB    '8N','1'+80H
  797.     DW    P8N1        ;filled in with equ's
  798.     DB    '7E','1'+80H
  799.     DW    P7E1        ; - ditto -
  800.     DB    '7O','1'+80H
  801.     DW    P7O1        ; - ditto -
  802.     DB    '7N','1'+80H
  803.     DW    P7N1        ; - ditto -
  804.     DB    0        ;<<==== table terminator
  805. ;
  806. ;.....
  807. ;
  808. ; These routines set TPULSE flag at 0105H to either 'T' or 'P' so that
  809. ; MODEM (specifically MXO-SM13.ASM) overlay will dial in TONE or PULSE
  810. ; mode.  The settings are mutually exclusive.
  811. ;
  812. STTONE:    MVI    A,'T'        ;get T flag
  813.     STA    TPULSE        ;put into proper place
  814.     JMP    TPSHOW        ;display dial mode
  815. ;
  816. STPULSE:
  817.     MVI    A,'P'        ;get P flag
  818.     STA    TPULSE
  819. ;
  820. TPSHOW:    CALL    ILPRT
  821.     DB    'DIAL:',TAB,TAB,TAB,0
  822.     LDA    TPULSE
  823.     CPI    'T'
  824.     JNZ    TP1
  825.     CALL    ILPRT
  826.     DB    'Tone',0
  827.     RET
  828. TP1:    CPI    'P'
  829.     JNZ    TP2
  830.     CALL    ILPRT
  831.     DB    'Pulse',0
  832.     RET
  833. TP2:    CALL    ILPRT
  834.     DB    '<< ERROR >>',0
  835.     RET
  836. ;
  837. ;-------------------------------------------------
  838. ; SET WAIT processor
  839.  
  840. IF WAIT
  841.  
  842. SETDLY:    MVI    C,EVALA
  843.     CALL    MEX
  844.     MOV    A,H
  845.     ORA    A
  846.     JNZ    SETERR
  847.     MOV    A,L
  848.     STA    EXTRA1
  849.  
  850. DLYSHO:    CALL    ILPRT
  851.     DB    'WAIT:',TAB,TAB,TAB,0
  852.     LDA    EXTRA1
  853.     MOV    L,A
  854.     MVI    H,0
  855.     MVI    C,DECOUT
  856.     CALL    MEX
  857.     CALL    ILPRT
  858.     DB    ' Seconds',0
  859.     RET
  860.  
  861. ENDIF
  862. ;......
  863. ;
  864. ; SET INT Processor controls interrupt mode
  865. ;
  866. SETINT:
  867.     LXI    D,INTTBL    ;point to argument table
  868.     CALL    TSRCH        ;look for match with allowed arguments
  869.     JC    SETERR        ;process error if found
  870.     MOV    A,L        ;
  871.     STA    INTFLG        ;
  872.  
  873. INTSHO:
  874.     CALL    ILPRT        ;show current status
  875.     DB    'INTerrupt:',TAB,TAB,0
  876.     LDA    INTFLG        ;get current mode word
  877.     ORA    A        ;
  878.     JNZ    INT        ;skip if it is
  879.     CALL    ILPRT        ;
  880.     DB    'OFF',0        ;
  881.     JMP    CHNGPORT    ;
  882.                 ;
  883. INT:    CALL    ILPRT        ;print it
  884.     DB    'ON',0        ;
  885.     JMP    CHNGPORT    ;
  886. ;
  887. ;INT argument table
  888. ;
  889. INTTBL:    DB    'OF','F'+80H
  890.     DB    0,0
  891.     DB    'O','N'+80H
  892.     DB    0FFH,0
  893.     DB    0
  894. ;
  895. INTFLG:    DB    no
  896.  
  897. ;..............................
  898. ;
  899. ; Compare next input-stream item in table @DE; CY=1 if not found,
  900. ; else HL = matched data item
  901. ;
  902. TSRCH:    MVI    C,LOOKUP    ;get function code
  903.     JMP    MEX        ;pass to MEX processor
  904. ;
  905. ; Print in-line message ... blows away C register
  906. ;
  907. ILPRT:    MVI    C,ILP        ;get function code
  908.     JMP    MEX        ;go do it
  909. ;
  910. ;
  911. ;    >>>>   End of MXH-APnn     <<<<
  912.  
  913.  
  914.