home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / modem / mxo-amnz.mac < prev    next >
Encoding:
Text File  |  1994-09-02  |  22.1 KB  |  781 lines

  1.  
  2.     .Z80
  3.     ASEG
  4.  
  5. ; MXO-AMxx.ASM
  6. ; MEX overlay for the Ampro Little Board Computer
  7.  
  8. ; Version 1.2: 23 Jul 1988
  9. ;    added routine to allow this overlay to find original
  10. ;    bios under manually installed or nz-com system.
  11. ;                        al grabauskas
  12.  
  13. ; Version 1.1:  1 Oct 1986
  14. ;     ( added support for dropping DTR for those modems that
  15. ;       support it.  -Marc Wilson                            )
  16. ;
  17. ; Version 1.0: 28 Nov 1984  
  18.  
  19. REV    EQU    12        ; Overlay revision level
  20.  
  21.  
  22. ; This is a MEX overlay file for the Ampro Computer.  It is designed
  23. ; to work with the modem connected to serial port 'B'.  It also       
  24. ; requires the CTC and SIO parameter tables at the front of the
  25. ; Ampro bios, as well as the I/O initialization routine in the
  26. ; Ampro bios.  This is a non-standard bios call and if not present
  27. ; in the bios it must be duplicated in this overlay.
  28.  
  29. ; Note that all overlays may freely use memory up to 0CFFH.  If the
  30. ; overlay must work with the MEX Smartmodem overlay (MXO-SMxx.ASM),
  31. ; the physical modem overlay should terminate by 0AFFH.
  32.     
  33. ;------------------------------------------------------------
  34.  
  35. ; Misc equates
  36.  
  37. NO    EQU    0
  38. YES    EQU    0FFH
  39. TPA    EQU    100H
  40. CR    EQU    13
  41. LF    EQU    10
  42. TAB    EQU    9
  43.  
  44. ; Ampro definitions
  45.  
  46. IOINT    EQU    57        ; BIOS call of initialization routine
  47. SIOB    EQU    52H        ; Relative location in bios
  48. SIOB1    EQU    53H
  49. SIOB3    EQU    55H
  50. SIOB5    EQU    57H
  51. CT1    EQU    42H
  52.  
  53. ; port definitions
  54.  
  55. MODCTL    EQU    8CH        ; Modem control port B
  56. MODDAT    EQU    88H        ; Modem data port B
  57.  
  58. ; bit definitions
  59.  
  60. MDRCVB    EQU    01H        ; Modem receive bit (DAV)
  61. MDRCVR    EQU    01H        ; Modem receive ready
  62. MDSNDB    EQU    04H        ; Modem send bit
  63. MDSNDR    EQU    04H        ; Modem send ready bit
  64.  
  65. ; MEX service processor stuff ... MEX supports an overlay service
  66. ; processor, located at 0D00H (and maintained at this address from
  67. ; version to version).  If your overlay needs to call BDOS for any
  68. ; reason, it should call MEX instead; function calls below about
  69. ; 240 are simply passed on to the BDOS (console and list I/O calls
  70. ; are specially handled to allow modem port queueing, which is why
  71. ; you should call MEX instead of BDOS).  MEX uses function calls
  72. ; above about 244 for special overlay services (described below).
  73.  
  74. ; Some sophisticated overlays may need to do file I/O; if so, use
  75. ; the PARSFN MEX call with a pointer to the FCB in DE to parse out
  76. ; the name.  This FCB should support a spare byte immediately pre-
  77. ; ceeding the actual FCB (to contain user # information).  If you've
  78. ; used MEX-10 for input instead of BDOS-10 (or you're parsing part
  79. ; of a SET command line that's already been input), then MEX will
  80. ; take care of DU specs, and set up the FCB accordingly.  There-
  81. ; after all file I/O calls done through the MEX service processor
  82. ; will handle drive and user with no further effort necessary on
  83. ; the part of the programmer.
  84.  
  85. MEX    EQU    0D00H        ; Address of the service processor
  86. INMDM    EQU    255        ; Get char from port to A, CY=no more in 100 ms
  87. TIMER    EQU    254        ; Delay 100ms * reg B
  88. TMDINP    EQU    253        ; B=# secs to wait for char, cy=no char
  89. CHEKCC    EQU    252        ; Check for ^C from KBD, Z=present
  90. SNDRDY    EQU    251        ; Test for modem-send ready
  91. RCVRDY    EQU    250        ; Test for modem-receive ready
  92. SNDCHR    EQU    249        ; Send a character to the modem (after sndrdy)
  93. RCVCHR    EQU    248        ; Recv a char from modem (after rcvrdy)
  94. LOOKUP    EQU    247        ; Table search: see CMDTBL comments for info
  95. PARSFN    EQU    246        ; Parse filename from input stream
  96. BDPARS    EQU    245        ; Parse baud-rate from input stream
  97. SBLANK    EQU    244        ; Scan input stream to next non-blank
  98. EVALA    EQU    243        ; Evaluate numeric from input stream
  99. LKAHED    EQU    242        ; Get nxt char w/o removing from input
  100. GNC    EQU    241        ; Get char from input, cy=1 if none
  101. ILP    EQU    240        ; Inline print
  102. DECOUT    EQU    239        ; Decimal output
  103. PRBAUD    EQU    238        ; Print baud rate
  104.  
  105. CONOUT    EQU    2        ; Simulated BDOS function 2: console char out
  106. PRINT    EQU    9        ; Simulated BDOS function 9: print string
  107. INBUF    EQU    10        ; Input buffer, same structure as BDOS 10
  108.  
  109.     ORG    TPA        ; We begin
  110.  
  111.     DS    3        ; MEX has a JMP START here
  112.  
  113. ; The following variables are located at the beginning of the program
  114. ; to facilitate modification without the need of re-assembly. They will
  115. ; be moved in MEX 2.0.
  116.  
  117. PMODEM:    DB    NO        ; Yes=PMMI modem \ / These 2 locations are not
  118. SMODEM:    DB    YES        ; Yes=Smartmodem / \ referenced by MEX
  119. TPULSE:    DB    'T'        ; T=touch, P=pulse (not referenced by MEX)
  120. CLOCK:    DB    40        ; Clock speed x .1, up to 25.5 mhz.
  121. MSPEED:    DB    1        ; Sets display time for sending a file
  122.                 ; 0=110    1=300  2=450  3=600  4=710
  123.                 ; 5=1200 6=2400 7=4800 8=9600 9=19200
  124. BYTDLY:    DB    5        ; Default time to send character in
  125.                 ; Terminal mode file transfer (0-9)
  126.                 ; 0=0 delay, 1=10 ms, 5=50 ms, 9=90 ms
  127. CRDLY:    DB    5        ; End-of-line delay after CRLF in terminal
  128.                 ; Mode file transfer for slow BBS systems
  129.                 ; 0=0 delay, 1=100 ms, 5=500 ms, 9=900 ms
  130. COLUMS:    DB    5        ; Number of directory columns
  131. SETFL:    DB    YES        ; Yes=user-defined SET command
  132. SCRTST:    DB    YES        ; Yes=if home cursor and clear screen
  133.                 ; Routine at CLRSCRN
  134.     DB    0        ; Was once ACKNAK, now spare
  135. BAKFLG:    DB    NO        ; Yes=make .BAK file
  136. CRCDFL:    DB    YES        ; Yes=default to CRC checking
  137.                 ; No=default to Checksum checking
  138. TOGCRC:    DB    YES        ; Yes=allow toggling of Checksum to CRC
  139. CVTBS:    DB    NO        ; Yes=convert backspace to rub
  140. TOGLBK:    DB    YES        ; Yes=allow toggling of bksp to rub
  141. ADDLF:    DB    NO        ; No=no LF after CR to send file in
  142.                 ; Terminal mode (added by remote echo)
  143. TOGLF:    DB    YES        ; Yes=allow toggling of LF after CR
  144. TRNLOG:    DB    YES        ; Yes=allow transmission of logon
  145.                 ; Write logon sequence at location LOGON
  146. SAVCCP:    DB    YES        ; Yes=do not overwrite CCP
  147. LOCNXT:    DB    NO        ; Yes=local cmd if EXTCHR precedes
  148.                 ; No=not local cmd if EXTCHR precedes
  149. TOGLOC:    DB    YES        ; Yes=allow toggling of LOCNXTCHR
  150. LSTTST:    DB    YES        ; Yes=allow toggling of printer on/off
  151.                 ; In terminal mode. Set to no if using
  152.                 ; The printer port for the modem
  153. XOFTST:    DB    YES        ; Yes=allow testing of XOFF from remote
  154.                 ; While sending a file in terminal mode
  155. XONWT:    DB    NO        ; Yes=wait for XON after sending CR while
  156.                 ; Transmitting a file in terminal mode    
  157. TOGXOF:    DB    YES        ; Yes=allow toggling of XOFF testing
  158. IGNCTL:    DB    YES        ; Yes=do not send control characters
  159.                 ; Above CTL-M to CRT in terminal mode
  160.                 ; No=send any incoming CTL-char to CRT
  161. EXTRA1:    DB    0        ; For future expansion
  162. EXTRA2:    DB    0        ; For future expansion
  163. BRKCHR:    DB    '@'-40H        ; ^@ = Send a 300 ms. break tone
  164. NOCONN:    DB    'N'-40H        ; ^N = Disconnect from phone line
  165. LOGCHR:    DB    'L'-40H        ; ^L = Send logon
  166. LSTCHR:    DB    'P'-40H        ; ^P = Toggle printer
  167. UNSVCH:    DB    'R'-40H        ; ^R = Close input text buffer
  168. TRNCHR:    DB    'T'-40H        ; ^T = Transmit file to remote
  169. SAVCHR:    DB    'Y'-40H        ; ^Y = Open input text buffer
  170. EXTCHR:    DB    '^'-40H        ; ^^ = Send next character
  171.  
  172.     DS    2        ; Make addresses right
  173.  
  174. ; Low-level modem I/O routines: this will be replaced with
  175. ; a jump table in MEX 2.0 (you can insert jumps here to longer
  176. ; routines if you'd like ... I'd recommend NOT putting part of
  177. ; a routine in this area, then jumping to the rest of the routine
  178. ; in the non-fixed area; that will complicate the 2.0 conversion)
  179.  
  180. INCTL1:    IN    A,(MODCTL)    ; In modem control port
  181.     RET
  182.     DB    0,0,0,0,0,0,0    ; Spares if needed for non-PMMI
  183.  
  184. OTDATA:    OUT    (MODDAT),A    ; Out modem data port
  185.     RET
  186.     DB    0,0,0,0,0,0,0    ; Spares if needed for non=PMMI
  187.  
  188. INPORT:    IN    A,(MODDAT)    ; In modem data port
  189.     RET
  190.     DB    0,0,0,0,0,0,0    ; Spares if needed for non-PMMI
  191.  
  192. ; Bit-test routines.  These will be merged with the above
  193. ; routines in MEX 2.0 to provide a more reasonable format
  194.  
  195. MASKR:    AND    MDRCVB
  196.     RET            ; Bit to test for receive ready
  197. TESTR:    CP    MDRCVR
  198.     RET            ; Value of receive bit when ready
  199. MASKS:    AND    MDSNDB
  200.     RET            ; Bit to test for send ready
  201. TESTS:    CP    MDSNDR
  202.     RET            ; Value of send bit when ready
  203.  
  204. ; Unused area: was once used for special PMMI functions,
  205. ; Now used only to retain compatibility with MDM overlays.
  206. ; You may use this area for any miscellaneous storage you'd
  207. ; like but the length of the area *must* be 12 bytes.
  208.  
  209.     DS    12
  210.  
  211. ; Special modem function jump table: if your overlay cannot handle
  212. ; some of these, change the jump to "DS 3", so the code present in
  213. ; MEX will be retained.  Thus, if your modem can't dial, change the
  214. ; JMP PDIAL at DIALV to DS 3, and MEX will print a "not-implemented"
  215. ; diagnostic for any commands that require dialing.
  216.  
  217. ; DIALV  dials the digit in A. See the comments at PDIAL for specs.
  218.  
  219. ; DISCV  disconnects the modem
  220.  
  221. ; GOODBV is called just before MEX exits to CP/M.  If your overlay
  222. ;        requires some exit cleanup, do it here.
  223.  
  224. ; INMODV is called when MEX starts up; use INMODV to initialize the modem.
  225.  
  226. ; NEWBDV is used for phone-number baud rates and is called with a baud-rate
  227. ;        code in the A register, value as follows:
  228.  
  229. ;     A=0:   110 baud       A=1:   300 baud      A=2:   450 baud
  230. ;     A=3:   600 baud       A=4:   710 baud      A=5:  1200 baud
  231. ;     A=6:  2400 baud       A=7:  4800 baud      A=8: 19200 baud
  232.  
  233. ;        If your overlay supports the passed baud rate, it should store the
  234. ;     value passed in A at MSPEED (107H), and set the requested rate. If
  235. ;     the value passed is not supported, you should simply return (with-
  236. ;     out modifying MSPEED) -or- optionally request a baud-rate from the
  237. ;     user interactively.
  238.  
  239. ; NOPARV is called at the end of each file transfer; your overlay may simply
  240. ;     return here, or you may want to restore parity if you set no-parity
  241. ;     in the following vector (this is the case with the PMMI overlay).
  242.     
  243. ; PARITV is called at the start of each file transfer; your overlay may simply
  244. ;     return here, or you may want to enable parity detection (this is the
  245. ;     case with the PMMI overlay).
  246.  
  247. ; SETUPV is the user-defined command ... to use this routine to build your own
  248. ;     MEX command, set the variable SETFL (117H) non-zero, and add your SET
  249. ;     code.  You can use the routine presented in the PMMI overlay as a 
  250. ;     guide for parsing, table lookup, etc.
  251.  
  252. ; SPMENU is provided only for MDM compatibility, and is not used by MEX 1.0 for
  253. ;     any purpose (it will be gone in MEX 2).
  254.  
  255. ; VERSNV is called immediately after MEX prints its sign-on message at cold
  256. ;     startup -- use this to identify your overlay in the sign-on message
  257. ;     (include overlay version number in the line).
  258. ; BREAKV is provided for sending a BREAK (<ESC>-B in terminal mode).  If your
  259. ;     modem doesn't support BREAK, or you don't care to code a BREAK rou-
  260. ;     tine, you may simply execute a RET instruction.
  261.  
  262. LOGON:    DS    2        ; Needed for MDM compat, not ref'd by MEX
  263. DIALV:    DS    3        ; Dial digit in A (see info at PDIAL)
  264. DISCV:    JP    HANGUP        ; Disconnect the modem
  265. GOODBV:    DS    3        ; Called before exit to CP/M
  266. INMODV:    JP    NITMOD        ; Initialization. Called at cold-start
  267. NEWBDV:    JP    PBAUD        ; Set baud rate
  268. NOPARV:    JP    NOPAR        ; Set modem for no-parity
  269. PARITV:    JP    PARITY        ; Set modem parity
  270. SETUPV:    JP    SETCMD        ; SET cmd: jump to a RET if you don't write SET
  271. SPMENV:    DS    3        ; Not used with MEX
  272. VERSNV:    JP    SYSVER        ; Overlay's voice in the sign-on message
  273. BREAKV:    DS    3        ; Send a break
  274.  
  275. ; The following jump vector provides the overlay with access to special
  276. ; routines in the main program (retained and supported in the main pro-
  277. ; gram for MDM overlay compatibility). These should not be modified by
  278. ; the overlay.
  279.  
  280. ; Note that for MEX 2.0 compatibility, you should not try to use these
  281. ; routines, since this table will go away with MEX 2.0 (use the MEX
  282. ; service call processor instead).
  283.  
  284. ILPRTV:    DS    3        ; Replace with MEX function 9
  285. INBUFV:    DS    3        ; Replace with MEX function 10
  286. ILCMPV:    DS    3        ; Replace with table lookup funct. 247
  287. INMDMV:    DS    3        ; Replace with MEX function 255
  288. NXSCRV:    DS    3        ; Not supported by MEX (returns w/no action)
  289. TIMERV:    DS    3        ; Replace with MEX function 254
  290.  
  291. ; Clear/screen and clear/end-of-screen. Each routine must use the
  292. ; full 9 bytes alloted (may be padded with nulls).
  293.  
  294. ; These routines (and other screen routines that MEX 2.0 will sup-
  295. ; port) will be accessed through a jump table in 2.0, and will be
  296. ; located in an area that won't tie the screen functions to the
  297. ; modem overlay (as the MDM format does).
  298.  
  299. CLREOS:    LD    DE,EOSMSG
  300.     LD    C,PRINT
  301.     CALL    MEX
  302.     RET
  303.  
  304. EOSMSG:    DB    27,89,0,0,0,'$'
  305.  
  306. CLS:    LD    DE,CLSMSG    ; Null unless patched
  307.     LD    C,PRINT
  308.     CALL    MEX
  309.     RET
  310.  
  311. CLSMSG:    DB    26,00,0,0,0,'$'
  312.  
  313. NOPAR:    RET
  314.  
  315. PARITY:    RET
  316.  
  317. ;------------------------------------------------------------------
  318. ;
  319. ; This routine sets DTR and RTS low for 1 second to disconnect the phone.
  320. ; This code comes from I2AM-1D.ASM.
  321. ;
  322. ;HANGUP:
  323. ;    MVI    B,'S'-40H    ; X-off to stop host if needed
  324. ;    CALL    OUTDATA
  325. ;    MVI    B,1        ; Wait a moment to let it react
  326. ;       MVI     C,TIMER
  327. ;    CALL    MEX
  328. HANGUP:    LD    A,5
  329.     OUT    (MODCTL),A    ; Send to the status port
  330.     LD    A,068H        ; Turn off DTR, RTS, send break
  331.     OUT    (MODCTL),A
  332.     LD    B,10        ; Wait 1 second
  333.     LD    C,TIMER
  334.     CALL    MEX
  335.     LD    A,5
  336.     OUT    (MODCTL),A
  337.     LD    A,0EAH        ; Restore normal, 8 bits, RTS on, etc.
  338.     OUT    (MODCTL),A
  339.     RET
  340.  
  341. ;------------------------------------------------------------------
  342.  
  343. NITMOD:    LD    A,5        ; Initialize to 1200 baud.  No other
  344.                 ; Parameters changed... fall thru
  345.  
  346.     CALL    GRABBIOS    ; get bios address, whether nz-com
  347.                 ;   or not. returned in "biosaddr:"
  348.  
  349. PBAUD:    PUSH    HL        ; Don't alter anybody
  350.     PUSH    DE
  351.     PUSH    BC
  352.     LD    E,A        ; Code to DE
  353.     LD    D,0
  354.     LD    HL,BAUDTB    ; Offset into table
  355.     ADD    HL,DE
  356.     LD    A,(HL)        ; Fetch code
  357.     OR    A        ; 0? (means unsupported code)
  358.     SCF            ; Return error for STBAUD caller
  359.     JP    Z,PBEXIT    ; Exit if so
  360.     LD    (BSAVE1),A    ; Save it
  361.     LD    A,E        ; Get speed code back
  362.     LD    (MSPEED),A    ; Make it current
  363.     LD    HL,BAUDTX    ; Offset into second table
  364.     ADD    HL,DE
  365.     LD    A,(HL)        ; Get second value
  366.     LD    (BSAVE2),A    ; Save it also
  367.     LD    HL,(BIOSADDR)    ; Get location of bios
  368.     LD    L,CT1        ; Add 42 to reach CT1 in i/o table
  369.     LD    A,47H
  370.     LD    (HL),A
  371.     INC    HL        ; Move to next location
  372.     LD    A,(BSAVE1)    ; Get first table value
  373.     LD    (HL),A        ; Store it
  374.     LD    A,(BSAVE2)    ; Get second table value
  375.     LD    B,A        ; And save it
  376.     LD    L,SIOB1        ; Move ahead to siob+1 values
  377.     LD    A,(HL)        ; Get current value
  378.     AND    3FH
  379.     OR    B        ; Or it with second value
  380.     LD    (HL),A        ; Store it in work table
  381.     INC    HL
  382.     INC    HL
  383.     LD    A,(HL)        ; Get last value and make
  384.     OR    80H        ; Sure msb is set
  385.     LD    (HL),A        ; Put it back in working table
  386.     CALL    IOINIT        ; Do the initialization
  387.     SCF
  388.     CCF            ; Return no error for STBAUD
  389. PBEXIT:    POP    BC        ; All done
  390.     POP    DE
  391.     POP    HL
  392.     RET
  393.  
  394. IOINIT:    LD    A,IOINT        ; Offset into bios jump table
  395.     LD    HL,(BIOSADDR)    ; Address of bios in HL
  396.     LD    L,A        ; Add offset
  397.     JP    GOHL        ; And go there with auto return
  398.  
  399. ; table of baud rate divisors for supported rates
  400.  
  401. BAUDTB:    DB    0,208,139,208,0,104 ; 110,300,450,600,710,1200
  402.     DB    52,26,13,0    ; 2400,4800,9600,19200
  403.  
  404. BAUDTX:    DB    0,80H,80H,40H,0,40H
  405.     DB    40H,40H,40H,0
  406.  
  407. BSAVE1:    DB    0        ; Current setting from
  408. BSAVE2:    DB    0        ; Tables - uninitialized
  409.  
  410. ; Sign-on message
  411.  
  412. SYSVER:    LD    DE,SOMESG
  413.     LD    C,PRINT
  414.     CALL    MEX
  415.     RET
  416.  
  417. SOMESG:    DB    'Ampro Overlay Version '
  418.     DB    REV/10+'0'
  419.     DB    '.'
  420.     DB    REV MOD 10+'0'
  421.     DB    ' (nz-com compatible)'
  422.     DB    CR,LF,'$'
  423.  
  424. ; Newline on console
  425.  
  426. CRLF:    LD    A,CR
  427.     CALL    TYPE
  428.     LD    A,LF        ; Fall into TYPE
  429.  
  430. ; type char in A on console
  431.  
  432. TYPE:    PUSH    HL        ; Save 'em
  433.     PUSH    DE
  434.     PUSH    BC
  435.     LD    E,A        ; Align output character
  436.     LD    C,CONOUT    ; Print via MEX
  437.     CALL    MEX
  438.     POP    BC
  439.     POP    DE
  440.     POP    HL
  441.     RET
  442.  
  443. ; Data area
  444.  
  445. ;------------------------------------------------------------
  446.  
  447. ; The remainder of this overlay implements a very versatile
  448. ; SET command -- if you prefer not to write a SET for your
  449. ; modem, you may delete the code from here to the END statement.
  450.  
  451. ; Control is passed here after MEX parses a SET command.
  452.  
  453. SETCMD:    LD    C,SBLANK    ; Any arguments?
  454.     CALL    MEX
  455.     JP    C,SETSHO    ; If not, go print out values
  456.     LD    DE,CMDTBL    ; Parse command
  457.     CALL    TSRCH        ; From table
  458.     PUSH    HL        ; Any address on stack
  459.     RET    NC        ; If we have one, execute it
  460.     POP    HL        ; Nope, fix stack
  461. SETERR:    LD    DE,SETEMS    ; Print error
  462.     LD    C,PRINT
  463.     CALL    MEX
  464.     RET
  465.  
  466. SETEMS:    DB    CR,LF,'SET command error',CR,LF,'$'
  467.  
  468. ; SET command table ... note that tables are constructed of command-
  469. ; name (terminated by high bit=1) followed by word-data-value returned
  470. ; in HL by MEX service processor LOOKUP.  Table must be terminated by
  471. ; a binary zero.
  472.  
  473. ; Note that LOOKUP attempts to find the next item in the input stream
  474. ; in the table passed to it in HL ... if found, the table data item is
  475. ; returned in HL; if not found, LOOKUP returns carry set.
  476.  
  477. CMDTBL:    DB    '?'+80H        ; "set ?"
  478.     DW    STHELP
  479.     DB    'BAU','D'+80H    ; "set baud"
  480.     DW    STBAUD
  481.     DB    'BIT','S'+80H    ; "set bits"
  482.     DW    STBITS
  483.     DB    'PARIT','Y'+80H    ; "set parity"
  484.     DW    STPAR
  485.     DB    'STO','P'+80H    ; "set stop"
  486.     DW    STSTOP
  487.     DB    'SHAK','E'+80H    ; "set shake"
  488.     DW    STSHAK
  489.  
  490.     DB    0        ; <<=== table terminator
  491.  
  492. ; SET <no-args>: print current statistics
  493.  
  494. SETSHO:    LD    HL,SHOTBL    ; Get table of SHOW subroutines
  495. SETSLP:    LD    E,(HL)        ; Get table address
  496.     INC    HL
  497.     LD    D,(HL)
  498.     INC    HL
  499.     LD    A,D        ; End of table?
  500.     OR    E
  501.     RET    Z        ; Exit if so
  502.     PUSH    HL        ; Save table pointer
  503.     EX    DE,HL        ; Adrs to HL
  504.     CALL    GOHL        ; Do it
  505.     CALL    CRLF        ; Print newline
  506.     LD    C,CHEKCC    ; Check for console abort
  507.     CALL    MEX
  508.     POP    HL        ; It's done
  509.     JP    NZ,SETSLP    ; Continue if no abort
  510.     RET
  511.  
  512. GOHL:    JP    (HL)
  513.  
  514. ; table of SHOW subroutines
  515.  
  516. SHOTBL:    DW    BDSHOW
  517.     DW    BITSH
  518.     DW    PARSH
  519.     DW    STPSH
  520.     DW    SHKSH
  521.     DW    0        ; <<== table terminator
  522.  
  523. ; SET ?  processor
  524.  
  525. STHELP:    LD    DE,HLPMSG
  526.     LD    C,PRINT
  527.     CALL    MEX
  528.     RET
  529.  
  530. ; The help message
  531.  
  532. HLPMSG:    DB    CR,LF,'SET command, Ampro version:',CR,LF
  533.     DB    CR,LF,'  >SET BAUD 300, 450, 600, 1200, 2400, 4800, or 9600.'
  534.     DB    CR,LF,'  >SET BITS 5, 6, 7, or 8.'
  535.     DB    CR,LF,'  >SET PARITY ODD, EVEN, or NONE.'
  536.     DB    CR,LF,'  >SET STOP 1, or 2.'
  537.     DB    CR,LF,'  >SET SHAKE ON, or OFF.'
  538.     DB    CR,LF,CR,LF,'$'
  539.  
  540. ; SET BAUD processor
  541.  
  542. STBAUD:    LD    C,BDPARS    ; Function code
  543.     CALL    MEX        ; Let MEX look up code
  544.     JP    C,SETERR    ; Invalid code
  545.     CALL    PBAUD        ; No, try to set it
  546.     JP    C,SETERR    ; Not-supported code
  547. BDSHOW:    CALL    ILPRT        ; Display baud
  548.     DB    '  Baud rate: ',0
  549.     LD    A,(MSPEED)
  550.     LD    C,PRBAUD    ; Use MEX routine
  551.     CALL    MEX
  552.     RET
  553.  
  554. ; SET BITS processor
  555.  
  556. STBITS:    LD    DE,BITTBL    ; Load lookup table
  557.     CALL    TSRCH        ; Look for 7 or 8
  558.     JP    C,SETERR    ; If not found
  559.     LD    C,L        ; Save selection value
  560.     LD    HL,(BIOSADDR)    ; Get bios address
  561.     LD    L,SIOB3        ; Move to siob+3
  562.     LD    A,(HL)        ; Wr5 info 
  563.     AND    9FH        ; Mask
  564.     OR    C        ; Add selection
  565.     LD    (HL),A        ; Store it
  566.     LD    A,C        ; Get selection
  567.     RLA
  568.     LD    C,A        ; Shift selection left
  569.     LD    L,SIOB5        ; Move to siob+5
  570.     LD    A,(HL)        ; Wr3 info
  571.     AND    3FH        ; Mask
  572.     OR    C
  573.     LD    (HL),A        ; Store it
  574.     CALL    IOINIT        ; Do it.
  575.  
  576. BITSH:    CALL    ILPRT
  577.     DB    '  Data bits: ',0
  578.     LD    HL,(BIOSADDR)    ; Get bios location
  579.     LD    L,SIOB3        ; Move to siob+3
  580.     LD    A,(HL)        ; Get current value
  581.     AND    60H
  582.     CP    60H
  583.     JP    Z,BITSH8
  584.     CP    20H
  585.     JP    Z,BITSH7
  586.     CP    40H
  587.     JP    Z,BITSH6
  588.     CALL    ILPRT
  589.     DB    '5',0        ; Show a 5
  590.     RET
  591. BITSH6:    CALL    ILPRT
  592.     DB    '6',0        ; Show a 6
  593.     RET
  594. BITSH7:    CALL    ILPRT
  595.     DB    '7',0        ; Show a 7
  596.     RET
  597. BITSH8:    CALL    ILPRT
  598.     DB    '8',0
  599.     RET
  600.  
  601. BITTBL:    DB    '5'+80H
  602.     DW    00H
  603.     DB    '6'+80H
  604.     DW    40H
  605.     DB    '7'+80H
  606.     DW    20H
  607.     DB    '8'+80H
  608.     DW    60H
  609.     DB    0
  610. ;
  611. STPAR:    LD    DE,PARTBL
  612.     CALL    TSRCH
  613.     JP    C,SETERR
  614.     LD    C,L
  615.     LD    HL,(BIOSADDR)    ; Get bios address
  616.     LD    L,SIOB1        ; Go to siob+1
  617.     LD    A,(HL)
  618.     AND    0FCH
  619.     OR    C
  620.     LD    (HL),A
  621.     CALL    IOINIT
  622.  
  623. PARSH:    CALL    ILPRT
  624.     DB    '     Parity: ',0
  625.     LD    HL,(BIOSADDR)    ; Get bios address
  626.     LD    L,SIOB1
  627.     LD    A,(HL)
  628.     AND    03H        ; Mask
  629.     CP    01H        ; Check for none
  630.     JP    Z,PARSHO
  631.     CP    03H
  632.     JP    Z,PARSHE
  633.  
  634.     CALL    ILPRT
  635.     DB    'none',0
  636.     RET
  637.  
  638. PARSHO:    CALL    ILPRT
  639.     DB    'odd',0
  640.     RET
  641. PARSHE:    CALL    ILPRT
  642.     DB    'even',0
  643.     RET
  644.  
  645. PARTBL:    DB    'OD','D'+80H
  646.     DW    01H
  647.     DB    'EVE','N'+80H
  648.     DW    03H
  649.     DB    'NON','E'+80H
  650.     DW    00H
  651.     DB    0
  652.  
  653. STSTOP:    LD    DE,STPTBL
  654.     CALL    TSRCH
  655.     JP    C,SETERR
  656.     LD    C,L
  657.     LD    HL,(BIOSADDR)    ; Get bios address
  658.     LD    L,53H        ; Shift to bios+1
  659.     LD    A,(HL)
  660.     AND    0F3H
  661.     OR    C
  662.     LD    (HL),A
  663.     CALL    IOINIT
  664.  
  665. STPSH:    CALL    ILPRT
  666.     DB    '  Stop bits: ',0
  667.     LD    HL,(BIOSADDR)    ; Get bios address
  668.     LD    L,53H        ; Shift to bios+1
  669.     LD    A,(HL)
  670.     AND    0CH
  671.     CP    0CH
  672.     JP    Z,STPSH2
  673.     CALL    ILPRT
  674.     DB    '1',0
  675.     RET
  676. STPSH2:    CALL    ILPRT
  677.     DB    '2',0
  678.     RET
  679. STPTBL:    DB    '1'+80H
  680.     DW    04H
  681.     DB    '2'+80H
  682.     DW    0CH
  683.     DB    0
  684.  
  685. STSHAK:    LD    DE,SHKTBL    ; Get handshake table
  686.     CALL    TSRCH        ; Search it for parameter
  687.     JP    C,SETERR    ; If not found
  688.     LD    C,L        ; Temp store value in C
  689.     LD    HL,(BIOSADDR)    ; Get location of BIOS
  690.     LD    L,6DH        ; Location of HSB in bios
  691.     LD    (HL),C        ; Put new value in it
  692.  
  693. SHKSH:    CALL    ILPRT
  694.     DB    ' Hand Shake: ',0
  695.     LD    HL,(BIOSADDR)    ; Get bios location
  696.     LD    L,6DH        ; Location of HSB in bios
  697.     LD    A,(HL)        ; Get current value
  698.     CP    1
  699.     JP    Z,SHKSHY    ; Show a yes
  700.     CALL    ILPRT
  701.     DB    'off',0
  702.     RET
  703. SHKSHY:    CALL    ILPRT
  704.     DB    'on',0
  705.     RET
  706.  
  707. SHKTBL:    DB    'OF','F'+80H
  708.     DW    0
  709.     DB    'O','N'+80H
  710.     DW    1
  711.     DB    0
  712.  
  713. ;----------------------------------------------------------
  714.  
  715. ; Compare next input-stream item in table @DE; CY=1
  716. ; if not found, else HL=matched data item
  717.  
  718. TSRCH:    LD    C,LOOKUP    ; Get function code
  719.     JP    MEX        ; Pass to MEX processor
  720.  
  721. ; Print in-line message ... blows away C register
  722.  
  723. ILPRT:    LD    C,ILP        ; Get function code
  724.     JP    MEX        ; Go do it
  725.  
  726. ;------------------------------------------------------------
  727. ; This is a callable routine that locates the bios address
  728. ; whether nz-com is running or not and saves it in the word
  729. ; at "biosaddr:". It gets run once at mex initialization.
  730. ; All points in the code that used to get this address from
  731. ; location one now get it from the located and saved address.
  732.  
  733. GRABBIOS:
  734.     PUSH    HL        ; save time
  735.     PUSH    DE
  736.     PUSH    BC
  737.     PUSH    AF
  738.     LD    HL,(1)        ; this is SOME bios address..
  739.     LD    L,5AH        ; ptr to "NZ-COM" eyecatcher
  740.     LD    DE,NZCEYE    ; ptr to another copy of it
  741.     LD    B,6        ; length
  742.  
  743. NZCKLOOP:
  744.     LD    A,(DE)        ; get a char
  745.     CP    (HL)        ; compare to char at hl
  746.     JR    NZ,NONZC    ; no nz-com
  747.     INC    HL        ; bump ptr
  748.     INC    DE        ; bump ptr
  749.     DEC    B        ; decrement length
  750.     JR    NZ,NZCKLOOP    ; repeat if apropos
  751.  
  752.     LD    L,85H        ; offset to high byte of
  753.                 ;     the 1st auxjump ptr
  754.     LD    A,(HL)        ; get bios page
  755.     JR    RETBIOS        ; and return bios addr in biosaddr
  756.  
  757. NONZC:
  758.     LD    A,(2)        ; get original page number
  759.  
  760. RETBIOS:
  761.     LD    (BIOSADDR+1),A    ; save page
  762.     POP    AF        ; restore regs
  763.     POP    BC
  764.     POP    DE
  765.     POP    HL
  766.     RET
  767.  
  768. NZCEYE:
  769.     DB    'NZ-COM'    ; eyecather to match
  770.  
  771. BIOSADDR:
  772.     DW    3        ; just need to set page
  773.  
  774. ;------------------------------------------------------------
  775.  
  776. ; End of AMPRO MEX modem overlay
  777.  
  778. ;------------------------------------------------------------
  779.  
  780.     END
  781.