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 / MODEMS / MODEM7 / M7KP-X48.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  21KB  |  573 lines

  1.  
  2.  
  3. ;    M7KP-x48.ASM --    Kaypro overlay file for MDM730.    7/30/84
  4.  
  5. ; *********************************************************************
  6. ; 7/30/84    Allows optional assembly to facilitate 4800 baud
  7. ; M7KP-X48   direct Transfer of files to & from KAYPRO over 3 wires.
  8. ;            Assembles normally to M7KP2 if XFR48 is set to NO.
  9. ;
  10. ;        Also, can be assembled to connect to either Serial Printer Port
  11. ;        or to Modem Port, if you're using the -84 KP series
  12. ;        that have separate port.  Advantage to using printer
  13. ;        port, if it is not otherwise used, is that you do not
  14. ;        have to switch plugs at your modem port for direct transfer
  15. ;        and normal modem use.  NOTE:  If you're using an older KAYPRO, 
  16. ;        i.e., one with only one serial port, set PRINTPORT to NO.
  17. ;
  18. ;           How to wire depends on the computer to/from which
  19. ;           you want to transfer files.  Try it and see - you can't
  20. ;           hurt anything.  If it does not work, reverse wires to
  21. ;           pins 2 and 3 on one of the RS-232 plugs.
  22. ;
  23. ;           Basically, you connect:
  24. ;               Pin 7 to Pin 7
  25. ;               Pin 2 to pin 3 (or maybe to pin 2)
  26. ;               Pin 3 to pin 2 (or maybe to pin 3)
  27. ;
  28. ;           I made up one RS-232 with a cross-over switch (DPDT), like
  29. ;           below, to make it easier to match other systems:
  30. ;            |    |          |
  31. ;            |    |          |
  32. ;            |    |          |
  33. ;            2    3          7
  34. ;            |    |          |
  35. ;        ---------------------   |
  36. ;        |    |    |        |    |
  37. ;        |    /    \        |    |
  38. ;        |      /      \        |    |
  39. ;        |     / o    o \    |   |    
  40. ;        |    /      \  /    \   |    |
  41. ;        |   /     \/     \  |    |
  42. ;        |  o      /\      o |    |
  43. ;        |        /  \       |    7
  44. ;        |       /    \      |    |
  45. ;        |      o      o     |    |
  46. ;        |      |      |     |    |    
  47. ;               |-------------------|    |
  48. ;               |      |        |
  49. ;               2      3        7
  50. ;               |      |        |
  51. ;                |      |         |          
  52. ;
  53. ; *********************************************************************
  54. ; KP7-X48 is based on M7KP-2.
  55. ; M7KP-2 was to written to handle a specific problem, to
  56. ; communicate with certain time sharing systems.  It should not be
  57. ; considered a replacement for M7KP-1.ASM.  It has been written not to
  58. ; exceed 896 bytes, a constraint documented in M7KP-1.ASM.  Because of
  59. ; this, some code was taken out, (SET baudrate other than 300 or 1200).
  60. ;
  61. ; You will want to look this file over carefully.  There are a number of
  62. ; options that you can use to configure the program to suit your taste.
  63. ; This file adapts the Kaypro II computer to the modem program.  Much of
  64. ; the information contained here is not in the MDM722.ASM file.
  65. ;
  66. ; Edit this file for your preferences then follow the "TO USE:", example
  67. ; shown below.
  68. ;
  69. ; Use the "SET" command to change the baudrate, word length, number of
  70. ; stop bits, and parity when desired.  It starts out at 300 baud, 8 bit
  71. ; word length 1 stop bit, and no parity when the program is first invoked.
  72. ;
  73. ; TO USE: First edit this file filling in answers for your own
  74. ;        equipment.  Then assemble with ASM.COM or equivalent
  75. ;        assembler.   Use DDT to overlay the results of this
  76. ;        program to the original .COM file:
  77. ;
  78. ;        A>DDT MDM7nn.COM
  79. ;        DDT VERS 2.2
  80. ;        NEXT  PC
  81. ;        4900 0100        (might be bigger -- be careful)
  82. ;        -IM7KP-X48.HEX        (note the "I" command)
  83. ;        -R            ("R" loads in the .HEX file)
  84. ;        NEXT  PC
  85. ;        4900 0000        (or whatever)
  86. ;        -G0            (return    to CP/M)
  87. ;        A>SAVE 72 XFR48.COM    (you now have a modified .COM file
  88. ;            |         saved in XFR48.COM)
  89. ;            |
  90. ;           or whatever value
  91. ;           may be appropriate - the 72 relates to 4900 as
  92. ;           follows: Discard the last two digits from the
  93. ;           4900 (or similar) value.  If they were NOT 00,
  94. ;           use the first two digits as is.  If they were
  95. ;           00, reduce the first two by one (e.g., 49 becomes 48).
  96. ;           Now: 48 means 48 hex.  That is 4 16s, and 8 ones.
  97. ;                   (4*16)+8=72
  98. ;    
  99. ;                            E.O.Stork
  100. ;  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
  101. ; 02/18/84 - Changed SET routine to change baudrate, word length,
  102. ; M7KP-2     number of stop bits, and parity.    - Bill Duerr
  103. ;
  104. ;  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =  =
  105. ;
  106. ;
  107. YES:        EQU    0FFH
  108. NO:        EQU    0
  109. ;******************************************************************************
  110. PRINTPORT:    EQU    NO        ;usually false, true only if you want 
  111.                     ; to connect to serial printer port   
  112.                     ;Set this to NO is using a KAYPRO with
  113.                     ; only one serial port.
  114.  
  115. XFR48        EQU    YES        ;If YES, disables SET Command          *
  116.                     ; Set to NO if you want to use this
  117.                     ; overlay for normal operation 
  118. ;
  119.     IF PRINTPORT
  120. PORT:        EQU    0CH        ;0Ch for Ser.Print Port
  121. BAUDPORT    EQU    08h        ;08h for Ser.Print port
  122.     ENDIF ;printport
  123.     IF NOT PRINTPORT
  124. PORT:        EQU    04h        ;04h modem data port
  125. BAUDPORT    EQU    00h        ;00h modem port    ENDIF
  126.     ENDIF    ;if not printer port
  127. ;******************************************************************************
  128. ;
  129. BELL:        EQU    07H        ;bell
  130. CR:        EQU    0DH        ;carriage return
  131. ESC:        EQU    1BH        ;escape
  132. LF:        EQU    0AH        ;linefeed
  133. ;
  134. MODCTL1:    EQU    PORT+2        ;Modem control port
  135. MODDATP:    EQU    PORT        ;Modem data port
  136. MODCTL2:    EQU    PORT+2        ;Modem control port
  137. ;
  138. MODRCVB:EQU    01H    ;Your bit to test for receive   .... ...1
  139. MODRCVR:EQU    01H    ;Your value when receive ready  .... ...1
  140. ;                       ;Int pending                    .... ..1.
  141. MODSNDB:EQU    04H    ;Your bit to test for send      .... .1..
  142. MODSNDR:EQU    04H    ;Your value when send ready     .... .1..
  143. ;DCT:   EQU     80H     ;data carier detect             .... 1...
  144. ;                       ;sync hunt                      ...1 ....
  145. ;                       ;Clear to Send                  ..1. ....
  146. ;                       ;Tx underrun                    .1.. ....
  147. ;                       ;Break/Abort                    1... ....
  148. ;
  149. ; The following are used in setting up the Z80 SIO.
  150. ;
  151. ;                       ;all sent                       .... ...1
  152. ;                       ;parity error                   ...1 ....
  153. ;                       ;overrun error                  ..10 ....
  154. ;                       ;framing error                  .1.. ....
  155. ;                       ;end of frame (SDLC)            1... ....
  156. ;WRREG0
  157. ;                       ;write to register              .... .xxx
  158. ;                       ;reset flags                    ..xx x...
  159. RSTERR:    EQU    30H    ;reset parity and overrun flags    ..11 0...
  160. RSTINS:    EQU    18H    ;reset SIO - register 0         ..01 1...
  161. WRREG1:    EQU    0    ;no interrupts - register 1
  162. ;                       ;ext int enable                 .... ...1
  163. ;                       ;tx int enable                  .... ..1.
  164. ;                       ;rx int disable                 ...0 0...
  165. ;                       ;rx int on first character      ...0 1...
  166. ;                       ;int on all rx char/parity eff  ...1 0...
  167. ;                       ;int on all rx char             ...1 1...
  168. ;                       ;wait/ready on r/t              ..1. ....
  169. ;                       ;wait/ready function            .1.. ....
  170. ;                       ;wait/ready enable              1... ....
  171. ;
  172. ;            ;register 3 equates
  173. WRREG3:    EQU    0C1H    ;8 Rx bits, Rx enable
  174. RENABLE    EQU    1    ;Rx enable -            .... ...1
  175. ;                       ;sync character load inhibit -  .... ..1.
  176. ;                       ;address serch mode (SDLC) -    .... .1..
  177. ;                       ;Rx CRC enabel -                .... 1...
  178. ;                       ;Enter hunt phase               ...1 ....
  179. ;                       ;Auto enables                   ..1. ....
  180. MSKWD:    EQU    0C0H    ;word length mask -        xx.. ....
  181. ;                       ;receive five bit work -        00.. ....
  182. RSEVEN:    EQU    040H    ;receive seven bit word    -    01.. ....
  183. ;                       ;receive six bit word -         10.. ....
  184. REIGHT:    EQU    0C0H    ;receive eight bit word    -    11.. ....
  185. ;
  186. ;            ;register 4 equates
  187. WRREG4:    EQU    44H    ;16X baud rate,    1 stop bit, no parity
  188. MSKPA:    EQU    03H    ;mask for parity bits -        .... ..xx
  189. NONE:    EQU    00H    ;no parity -            .... ..00
  190. ODD:    EQU    01H    ;odd parity -            .... ..01
  191. EVEN:    EQU    03H    ;even parity -            .... ..11
  192. MSKST:    EQU    0CH    ;stop bit mask -        .... xx..
  193. ;                       ;sync modes enable -            .... 00..
  194. ONE:    EQU    04H    ;one stop bit  -        .... 01..
  195. ;                                ;1.5 STOP BITS -        .... 10..
  196. TWO:    EQU    0CH    ;two stop bits -        .... 11..
  197. ;                       ;sync modes -                   ..xx ....
  198. ;CLK01: EQU     00H     ;1X clock mode -                00.. ....
  199. CLK16:    EQU    40H    ;16X clock mode -               01.. ....
  200. ;CLK32: EQU     80H     ;32X clock mode -               10.. ....
  201. ;CLK64: EQU     c0H     ;64X clock mode -               11.. ....
  202. ;            ;register 5 equates
  203. WRREG5:    EQU    0EAH    ;8 Tx bits, Tx enable, RTS, DTR
  204. ;TXCRC  EQU     001H    ;Tx CRC enable                  .... ...1
  205. ;RTS    EQU     002H    ;Request to send                .... ..1.
  206. ;SLDC   EQU     004H    ;SDLC/CRC-16                    .... .1..
  207. TENABLE:EQU    008H    ;Tx enable            .... 1...
  208. ;BREAK  EQU     010H    ;Send break                     ...1 ....
  209. ;                       ;Transmit five bit word -       .00. ....
  210. TSEVEN:    EQU    020H    ;Transmit seven    bit word -    .01. ....
  211. ;                       ;Transmit six bit word -        .10. ....
  212. TEIGHT:    EQU    060H    ;Transmit eight    bit word -    .11. ....
  213. ;DTR    EQU     080H    ;Data terminal ready            1... ....
  214. DTRON:    EQU    08AH    ;Tx enable, RTS, DTR -        1... 1.1.
  215. DTROFF:    EQU    000H    ;DTR off, RTS off -        0... ..0.
  216. ;
  217.         ORG    100H
  218. ;
  219. ; Change the clock speed as needed for your system.
  220. ;
  221.         DS    3    ;(for  "JMP   START" instruction)
  222. ;
  223. PMMIMODEM:    DB    NO    ;yes=PMMI S-100    Modem            103H
  224. SMARTMODEM:    DB    YES    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  225. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  226. CLOCK:        DB    40    ;clock speed in    MHz x10, 25.5 MHz max.    106H
  227.                 ;20=2 MHh, 37=3.68 MHz,    40=4 MHz, etc.
  228. MSPEED:        DB    7    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  229.                 ;6=2400    7=4800 8=9600 9=19200 default
  230. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  231.                 ;default time to send character    in ter-
  232.                 ;minal mode file transfer for slow BBS.
  233. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms    109H
  234.                 ;default time for extra    wait after CRLF
  235.                 ;in terminal mode file transfer
  236. NOOFCOL:    DB    5    ;number    of DIR columns shown        10AH
  237. SETUPTST:    DB    YES    ;yes=user-added    Setup routine        10BH
  238. SCRNTEST:    DB    YES    ;Cursor    control    routine            10CH
  239. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  240.                 ;no=resend a record after a valid NAK
  241. BAKUPBYTE:    DB    NO    ;yes=change any    file same name to .BAK    10EH
  242. CRCDFLT:    DB    YES    ;yes=default to    CRC checking        10FH
  243. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  244. CONVBKSP:    DB    YES    ;yes=convert backspace to rub        111H
  245. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  246. ADDLF:        DB    NO    ;no=no LF after    CR to send file    in    113H
  247.                 ;terminal mode (added by remote    echo)
  248. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after    CR    114H
  249. TRANLOGON:    DB    NO    ;yes=allow transmission    of logon    115H
  250.                 ;write logon sequence at location LOGON
  251. SAVCCP:        DB    YES    ;yes=do    not overwrite CCP        116H
  252. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  253.                 ;no=external command if    EXTCHR precedes
  254. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  255. LSTTST:        DB    YES    ;yes=printer available on printer port    119H
  256. XOFFTST:    DB    NO    ;yes=chcks for XOFF from remote    while    11AH
  257.                 ;sending a file    in terminal mode
  258. XONWAIT:    DB    NO    ;yes=wait for XON after    CR while    11BH
  259.                 ;sending a file    in terminal mode
  260. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  261. IGNORCTL:    DB    NO    ;yes=CTL-chars above ^M    not displayed    11DH
  262. EXTRA1:        DB    0    ;for future expansion            11EH
  263. EXTRA2:        DB    0    ;for future expansion            11FH
  264. BRKCHR:        DB    '@'-40H    ;^@ = Send a 300 ms. break tone        120H
  265. NOCXNNCT:    DB    'N'-40H    ;^N = Disconnect from the phone    line    121H
  266. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  267. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  268. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  269. TRANCHR:    DB    'T'-40H    ;^T = Transmit file to remote        125H
  270. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  271. EXTCHR:        DB    '^'-40H    ;^^ = Send next    character        127H
  272. PULSERATE:    DS    1    ;                                       128H
  273. CHGBAUD        DS    1    ;                        129H
  274. ;
  275. IN$MODCTL1:    MVI    A,10H        ;channel 0, reset interrupts.    12AH
  276.         OUT    MODCTL1
  277.         IN    MODCTL1        ;get the status    bits
  278.         RET
  279.         DB    0,0,0
  280. ;
  281. OUT$MODDATP:    OUT    MODDATP    ! RET    ;out modem data    port        134H
  282.         DB    0,0,0,0,0,0,0
  283. IN$MODDATP:    IN    MODDATP    ! RET    ;in modem data port        13EH
  284.         DB    0,0,0,0,0,0,0
  285. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to    test for receive ready    148H
  286. CPI$MODRCVR:    CPI    MODRCVR    ! RET    ;value of receive bit when rdy    14BH
  287. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to    test for send ready    14EH
  288. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when    ready    151H
  289. IN$BAUDRP:    DS    3        ;IN baudrate port               154H
  290. OUT$BAUDRP:    DS    3        ;OUT baudrate port              157H
  291. OUT$MODCTL1:    OUT    MODCTL1    ! RET    ;out modem control port        15AH
  292. OUT$MODCTL2:    OUT    MODCTL2    ! RET    ;out modem status port        15DH
  293. ;
  294. LOGONPTR:    DW    LOGON        ;for user message.        160H
  295. JMP$DAIL:    DS    3        ;Use routine in    main program    162H
  296. JMP$DISCONNT:    DS    3        ;Use routine in    main program    165H
  297. JMP$GOODBYE:    JMP    GOODBYE        ;Routine in this overlay    168H
  298. JMP$INITMOD:    JMP    INITMOD        ;Initialization    in this    overlay    16BH
  299. JMP$NEWBAUD:    RET  !    NOP  !    NOP    ;Bypass    PMMI routine        16EH
  300. JMP$NOPARITY:    RET  !    NOP  !    NOP    ;Bypass    PMMI routine        171H
  301. JMP$PARITY:    RET  !    NOP  !    NOP    ;Bypass    PMMI routine        174H
  302. JMP$SETUPR:    JMP    SETUPR        ;Set command in    this overlay    177H
  303. JMP$SPCLMENU:    RET  !    NOP  !    NOP    ;Bypass    special    menu routine    17AH
  304. JMP$SYSVER:    JMP    SYSVER        ;Version message in this overlay17DH
  305. JMP$BREAK:    JMP    SENDBRK        ;Break    routine    in this    overlay    180H
  306. ;
  307. ;
  308. ; Do not change    the following six lines, the routine are in main program.
  309. ;
  310. JMP$ILPRT:    DS    3        ;Inline    print routine        183H
  311. JMP$INBUF    DS    3        ;Input buffer routine        186H
  312. JMP$INLNCOMP:    DS    3        ;Inline    compare    routine        189H
  313. JMP$INMODEM    DS    3        ;                18CH
  314. JMP$NXTSCRN:    DS    3        ;                18FH
  315. JMP$TIMER:    DS    3        ;Timer routine            192H
  316. ;
  317. ; Clear    sequences -- CLREOS is clear to    end of screen, CLRSCRN is clear
  318. ; entire screen.  Last entry must be 0.  Any other 0's act as NOP's.
  319. ;
  320. CLREOS:        CALL    JMP$ILPRT    ;                195H
  321.         DB    017H,0,0,0,0    ;                198H
  322.         RET            ;                19DH
  323. ;
  324. CLRSCRN:    CALL    JMP$ILPRT    ;                19EH
  325.         DB    01AH,0,0,0,0    ;                1A1H
  326.         RET            ;                1A6H
  327. ;
  328. ;
  329. SYSVER:        CALL    JMP$ILPRT    ;                1A7H
  330. IF NOT XFR48
  331.         DB    'M7KP-2 for Kaypro'    ;    1AAH
  332. ENDIF    ;if not XFR48
  333. IF    XFR48
  334.         DB    'M7XFR48 for Kaypro'
  335. ENDIF   ; if xfr48
  336.  
  337. IF PRINTPORT
  338.         DB    ' Printer Serial Port',0
  339. ENDIF
  340. IF NOT    PRINTPORT
  341.         DB    ' Serial Modem Port',0
  342. ENDIF
  343.  
  344.         RET
  345. ;
  346. ; NOTE:     You can change    the SYSVER message to be longer    or shorter.  The
  347. ;     end of    your last routine should terminate by 0380H (390 bytes
  348. ;     available after start of SYSVER) if using the Hayes Smartmodem
  349. ;     or by address 0B80H (2521 bytes) otherwise.
  350. ;
  351. ; You can put in a message at this location which can be called    up with
  352. ; CTL-L    if TRANLOGON has been set YES.    You can    put in several lines if
  353. ; desired.  End    with a 0.
  354. ;
  355. LOGON:      DB    'LOGON',CR,LF,0
  356. ;
  357. ;
  358. ; This routine allows a    300 ms.    break tone to be sent to reset some
  359. ; time-share computers.
  360. ;
  361. SENDBRK:  MVI    A,5        ;select    register 5
  362.       OUT    MODCTL1
  363.       MVI    A,0F8H        ;send a    break tone
  364.       JMP    GOODBYE1
  365. ;
  366. ; This routine sends a 300 ms. break tone and sets DTR low for the same
  367. ; length of time to disconnect some modems such    as the Bell 212A, etc.
  368. ;
  369. GOODBYE:  MVI    A,5        ;select    register 5
  370.       OUT    MODCTL1        ;send to the status port
  371.       MVI    A,DTROFF    ;turn off dtr
  372. ;
  373. GOODBYE1: OUT    MODCTL1
  374.       MVI    B,3        ;delay 300 ms.
  375.       CALL    JMP$TIMER
  376.       MVI    A,5        ;select    register 5
  377.       OUT    MODCTL1
  378.       LDA    REG5+1        ;has been set to word length, etc.
  379.       OUT    MODCTL1
  380.       RET
  381. ;
  382. ; Kaypro II initialization -- resets the SIO, sets the interrupt
  383. ; mode, the receive and transmit mode.
  384. ; Sets the baud rate to BAUDPORT (00 for dataport, 08 for printer port)
  385. ;
  386. INITMOD:MVI    A,0        ;select    register 0
  387.     OUT    MODCTL1
  388.     MVI    A,RSTINS    ;reset SIO - 18h
  389.     OUT    MODCTL1
  390. ;
  391.     MVI    A,1        ;select    register 1
  392.     OUT    MODCTL1
  393.     MVI    A,WRREG1    ;no interrupts
  394.     OUT    MODCTL1
  395. ;
  396.     MVI    A,3        ;select    register 3 - receive
  397.     OUT    MODCTL1
  398. REG3:    MVI    A,WRREG3    ;8 Rx bits, Rx enable
  399.     OUT    MODCTL1
  400. ;
  401.     MVI    A,4        ;select    register 4
  402.     OUT    MODCTL1
  403.     MVI    A,CLK16        ;16X baud rate
  404. PARIT:    ORI    NONE        ;type of parity
  405. STPLN:    ORI    ONE        ;number of stop bits
  406.     OUT    MODCTL1
  407. ;
  408.     MVI    A,5        ;select    register 5 - transmit
  409.     OUT    MODCTL1
  410. REG5:    MVI    A,WRREG5    ;8 Tx bits, Tx enable, no RTS, no DTR
  411.     OUT    MODCTL1
  412. ;
  413. SETBD:    
  414.   IF XFR48        ;set to 4800 baud if for direct transfer
  415.     MVI    A,0CH        ; 0Ch for 4800
  416.   ENDIF    ;xfr48
  417.   IF NOT XFR48
  418.     MVI    A,05H        ; 05h for 300 bps,07h for 1200 baud
  419.   ENDIF ;not xfr48
  420.     OUT    BAUDPORT    ;00 for data port, 08 for printer port
  421.     RET
  422. ;
  423. ; The following routine changes the baud rate, word length, stop bits
  424. ; and parity on the Z80 SIO from the command level.  Note the routine
  425. ; MUST modify the parameters used by the INITMOD routine.
  426. ;
  427.     IF    XFR48    ;do not support SET command in XFR48
  428. SETUPR:    
  429.     CALL    JMP$ILPRT
  430.     DB    9,7,'SET Command not supported in XFR48',0dh,0ah,0
  431.     RET
  432.     ENDIF ; xfr48
  433.  
  434.     IF NOT XFR48
  435. SETUPR:    PUSH    H
  436. AGAIN:    LXI    D,BAUDBUF    ;point to input    buffer for JMP$INLNCOMP
  437.     CALL    JMP$ILPRT
  438.     DB    1AH,'Baud Rate (300, 1200): ',0
  439.     CALL    JMP$INBUF
  440.     LXI    H,BAUDTB
  441. BAUDLP:    MOV    A,M        ;first character to check
  442.     ORA    A        ;is it null
  443.     JZ    NOTOK        ;no matches found
  444.     STA    BAUDCP        ;store in compare area
  445.     INX    H        ;point to next character
  446.     MOV    A,M        ;second character to check or null
  447.     STA    BAUDCP+1    ;store in comparea area
  448.     INX    H        ;point to MSPEED constant
  449.     LXI    D,BAUDBUF+2    ;compare baudbuf and baudcp
  450.     CALL    JMP$INLNCOMP    ;was valid baud specified
  451. BAUDCP:    DB    0,0,0        ;baudrate from table gets stored here
  452.     JNC    OK        ;match, go save it
  453.     INX    H        ;skip MSPEED
  454.     INX    H        ;and CTC constant
  455.     JMP    BAUDLP        ;and check next entry
  456. NOTOK:    CALL    WRONG        ;tell messed up
  457.     JNC    AGAIN2        ;null line entered bypass baud change
  458.     JMP    AGAIN        ;try again
  459. ;
  460. OK:    MOV    A,M        ;get MSPEED
  461.     STA    MSPEED        ;change    time-to-send to    match baudrate
  462.     INX    H        ;point to CTC constant
  463.     MOV    A,M        ;and get it
  464.     STA    SETBD+1        ;store in INITMOD routine
  465. ;
  466. AGAIN2:    LXI    D,BAUDBUF    ;point to input    buffer
  467.     CALL    JMP$ILPRT
  468.     DB    'Word Length (7, 8): ',0
  469.     CALL    JMP$INBUF
  470.     LXI    D,BAUDBUF+2
  471.     CALL    JMP$INLNCOMP    ;was eight bits    requested
  472.     DB    '8',0
  473.     MVI    A,REIGHT+RENABLE;receive eight bits  -  C1h
  474.     MVI    B,TEIGHT+DTRON    ;transmit eight    bits -  EAh
  475.     JNC    OK2
  476.     CALL    JMP$INLNCOMP    ;was seven bits requested
  477.     DB    '7',0
  478.     MVI    A,RSEVEN+RENABLE;receive seven bits  - 41h
  479.     MVI    B,TSEVEN+DTRON    ;transmit seven    bits - AAh
  480.     JNC    OK2
  481.     CALL    WRONG
  482.     JNC    AGAIN3        ;bypass word length change
  483.     JMP    AGAIN2
  484. ;
  485. OK2:    STA    REG3+1        ;store in MVI instruction
  486.     MOV    A,B        ;get transmit word length
  487.     STA    REG5+1        ;store in MVI instruction
  488. ;
  489. AGAIN3:    LXI    D,BAUDBUF    ;point to input    buffer for JMP$INLNCOMP
  490.     CALL    JMP$ILPRT
  491.     DB    'Stop Bits (1, 2): ',0
  492.     CALL    JMP$INBUF
  493.     LXI    D,BAUDBUF+2
  494.     CALL    JMP$INLNCOMP    ;was 1 stop bit    requested
  495.     DB    '1',0
  496.     MVI    A,ONE        ;1 stop    bit - 04h
  497.     JNC    OK3
  498.     CALL    JMP$INLNCOMP    ;was 2 stop bits requested
  499.     DB    '2',0
  500.     MVI    A,TWO        ;2 stop    bits - 0Ch
  501.     JNC    OK3
  502.     CALL    WRONG
  503.     JNC    AGAIN4        ;bypass stop bit mod
  504.     JMP    AGAIN3        ;go ask again
  505. ;
  506. OK3:    STA    STPLN+1        ;save stop bits    in MVI
  507. ;
  508. AGAIN4:    LXI    D,BAUDBUF    ;point to input    buffer for JMP$INLNCOMP
  509.     CALL    JMP$ILPRT
  510.     DB    'Parity (None, Even, Odd): ',0
  511.     CALL    JMP$INBUF
  512.     LXI    D,BAUDBUF+2
  513.     CALL    JMP$INLNCOMP    ;was no    parity requested
  514.     DB    'N',0        ;just check first character
  515.     MVI    A,NONE        ;no parity - 00h
  516.     JNC    OK4        ;go if got match
  517.     CALL    JMP$INLNCOMP    ;was even parity requested
  518.     DB    'E',0
  519.     MVI    A,EVEN        ;even parity - 03h
  520.     JNC    OK4
  521.     CALL    JMP$INLNCOMP    ;was odd parity    requested
  522.     DB    'O',0
  523.     MVI    A,ODD        ;odd parity - 01h
  524.     JNC    OK4
  525.     CALL    WRONG        ;no matches
  526.     JNC    GOSET        ;bypass parity changes
  527.     JMP    AGAIN4        ;try again
  528. ;
  529. OK4:    STA    PARIT+1        ;save in MVI
  530. ;
  531. ; now go modify the init routine to initialize the Kaypro to the values
  532. ; requested.
  533. ;
  534. GOSET:    POP    H        ;restore HL register
  535.     JMP    INITMOD        ;reset Z80 SIO (and return)
  536. ;
  537. WRONG:    CALL    JMP$INLNCOMP    ;was null string entered
  538.     DB    ' ',0
  539.     RNC            ;all is ok
  540.     CALL    JMP$ILPRT    ;all matches failed - tell operator
  541.     DB    ' Wrong!',CR,LF,BELL,0
  542.     STC            ;Set carry flag
  543.     RET
  544. ;
  545. ; Due to space constraints some baud rates have been commented out
  546. ;
  547. BAUDTB:    EQU    $        ;Valid baud rates
  548. ;                               ;BAUD  MSPEED   CTC
  549. ;BD110:    DB    '11',0,2    ; 110    0      02
  550. BD300:    DB    '3',0,1,5    ; 300    1      05
  551. ;BD600:    DB    '6',0,3,6    ; 600    3      06
  552. BD1200:    DB    '12',5,7    ;1200    5      07
  553. ;BD2400:DB    '24',6,10    ;2400    6      0A
  554. ;BD4800:DB    '48',7,12    ;4800    7      0C
  555. ;BD9600:DB    '96',8,14    ;9600    8      0E
  556. ;BD192:    DB    '19',8,15    ;19.2    9      0F
  557.     DB    0
  558. ;
  559.     ENDIF    ;not XFR48
  560.  
  561. BAUDBUF:
  562.     DB    10,0
  563.     DS    10
  564. ;
  565. ;---------------------------------------------------------------------
  566. ;
  567. ;
  568. ; NOTE:  MUST TERMINATE PRIOR TO 0380H (with Smartmodem)
  569. ;                 0B80H (without Smartmodem)
  570. ;
  571. ;---------------------------------------------------------------------
  572.     END
  573.