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 / ENTERPRS / CPM / TERMS / M7-C1670.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  12KB  |  491 lines

  1.  
  2.     title    'M7-C1670 (MDM) 1670 or HAYES overlay for C128     31 Oct 85'
  3.  
  4. ; M7-C1670.ASM -- Commodore 128 overlay file for MDM7xx.
  5. ;
  6. ; overlay setup by Von Ertwine for C128 using 1670 modem
  7. ; or the 1011A (RS232 converter)
  8. ;    10/31/85
  9. ;
  10. ;    build new system by using to following:
  11. ;
  12. ;    MAC M7-C1670 $pz-s
  13. ;    MLOAD MDM7x0.com=MDM7x0.COM,M7-C1670.HEX
  14. ;
  15. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  16.  
  17.     page
  18.  
  19. $*MACRO        ; only show code produced by MAC not MACRO expansion
  20.  
  21.  
  22. ;
  23. eom        equ    00h        ; end of message
  24. bell        equ    07h        ; bell
  25. lf        equ    0Ah        ; linefeed
  26. cr        equ    0Dh        ; carriage return
  27. esc        equ    1Bh        ; escape
  28.  
  29. no        equ    0
  30. yes        equ    not(no)
  31.  
  32.     page
  33. ;
  34. ;    C128 info
  35. ;
  36. dev$no:        equ    6
  37. XxD$config:    equ    0fd4Eh
  38. ;        bit 7    0=no parity    1=parity
  39. ;        bit 6    0=mark/space    1=odd/even
  40. ;        bit 5    0=space/even    1=mark/odd
  41. ;        bit 1    0=1 stop bit    1=2 stop bits
  42. ;        bit 0    0=7 data bits    1=8 data bits
  43. RS232$status:    equ    XxD$config+1
  44. ;        bit 7    1=send data, 0=no data
  45. ;        bit 6    1=sending data now
  46. ;        bit 5    1=recv que active
  47. ;        bit 4    1=parity error
  48. ;        bit 3    1=framing error
  49. ;        bit 2    not used
  50. ;        bit 1    receiving data now
  51. ;        bit 0    data byte ready
  52. xmit$data:    equ    RS232$status+1
  53. recv$data:    equ    xmit$data+1
  54. ;
  55. MODRCVB:    EQU    01H        ; bit to test for receive
  56. MODRCVR:    EQU    01H        ; value when receive ready
  57. MODSNDB:    EQU    80H        ; bit to test for send
  58. MODSNDR:    EQU    00H        ; value when send ready        
  59.  
  60. data$port$a    equ    0DD00h
  61. ;        bit 2    TxD Data (output)
  62.  
  63. data$port$b    equ    data$port$a+1
  64. data$port$b$dir    equ    data$port$b+2
  65. ;        bit 7    Data Set Ready (input)
  66. ;        bit 6    Clear to Send (input)
  67. ;        bit 5    Place Phone On Hook (active low output)
  68. ;        bit 4    Carrier Detect (active low input)
  69. ;        bit 3    Ring Indicator (active low input)
  70. ;        bit 2    Data Terminal Ready (active hi output)
  71. ;        bit 1    Request to Send (active hi output)
  72. ;        bit 0    Received Data (input)
  73.  
  74.     page
  75. ;
  76. setb    macro    ?N,?R
  77.     db    0cbh,?N*8+?R+0C0h
  78.     endm
  79.  
  80. res    macro    ?N,?R
  81.     db    0cbh,?N*8+?R+80h
  82.     endm
  83.  
  84. @chk    macro    ?DD
  85.     if (?DD GT 7Fh) and (?DD LT 0FF80h)
  86.     'Displacement Error'
  87.     endif
  88.     endm
  89.  
  90. jr    macro    ?N
  91.     db    18h,?N-$-1
  92.     @chk    ?N-$
  93.     endm
  94.  
  95. jrz    macro    ?N
  96.     db    28h,?N-$-1
  97.     @chk    ?N-$
  98.     endm
  99.  
  100. jrnz    macro    ?N
  101.     db    20h,?N-$-1
  102.     @chk    ?N-$
  103.     endm
  104.  
  105. jrc    macro    ?N
  106.     db    38h,?N-$-1
  107.     @chk    ?N-$
  108.     endm
  109.  
  110. jrnc    macro    ?N
  111.     db    30h,?N-$-1
  112.     @chk    ?N-$
  113.     endm
  114.  
  115. inp    macro    ?R
  116.     db    0EDh,?R*8+40h
  117.     endm
  118.  
  119. outp    macro    ?R
  120.     db    0EDh,?R*8+41h
  121.     endm
  122.  
  123.     page
  124.  
  125.         ORG    100H
  126.  
  127.         DS    3    ;(for  "JMP   START" instruction)
  128. ;
  129. PMMIMODEM:    DB    NO    ;yes=PMMI S-100 Modem            103H
  130. SMARTMODEM:    DB    yes    ;yes=HAYES Smartmodem, no=non-PMMI    104H
  131. TOUCHPULSE:    DB    'T'    ;T=touch, P=pulse (Smartmodem-only)    105H
  132. CLOCK:        DB    11    ;clock speed in MHz x10, 25.5 MHz max.    106H
  133.                 ;20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  134. MSPEED:        DB    5    ;0=110 1=300 2=450 3=600 4=710 5=1200    107H
  135.                 ;6=2400 7=4800 8=9600 9=19200 default
  136. BYTDLY:        DB    5    ;0=0 delay  1=10ms  5=50 ms - 9=90 ms    108H
  137.                 ;default time to send character in ter-
  138.                 ;minal mode file transfer for slow BBS.
  139. CRDLY:        DB    5    ;0=0 delay 1=100 ms 5=500 ms - 9=900 ms 109H
  140.                 ;default time for extra wait after CRLF
  141.                 ;in terminal mode file transfer
  142. NOOFCOL:    DB    5    ;number of DIR columns shown        10AH
  143. SETUPTST:    DB    YES    ;yes=user-added Setup routine        10BH
  144. SCRNTEST:    DB    yes    ;Cursor control routine         10CH
  145. ACKNAK:        DB    YES    ;yes=resend a record after any non-ACK    10DH
  146.                 ;no=resend a record after a valid NAK
  147. BAKUPBYTE:    DB    yes    ;yes=change any file same name to .BAK    10EH
  148. CRCDFLT:    DB    YES    ;yes=default to CRC checking        10FH
  149. TOGGLECRC:    DB    YES    ;yes=allow toggling of CRC to Checksum    110H
  150. CONVBKSP:    DB    no    ;yes=convert backspace to rub        111H
  151. TOGGLEBK:    DB    YES    ;yes=allow toggling of bksp to rub    112H
  152. ADDLF:        DB    YES    ;no=no LF after CR to send file in    113H
  153.                 ;terminal mode (added by remote echo)
  154. TOGGLELF:    DB    YES    ;yes=allow toggling of LF after CR    114H
  155. TRANLOGON:    DB    YES    ;yes=allow transmission of logon    115H
  156.                 ;write logon sequence at location LOGON
  157. SAVCCP:        DB    no    ;yes=do not overwrite CCP        116H
  158. LOCONEXTCHR:    DB    NO    ;yes=local command if EXTCHR precedes    117H
  159.                 ;no=external command if EXTCHR precedes
  160. TOGGLELOC:    DB    YES    ;yes=allow toggling of LOCONEXTCHR    118H
  161. LSTTST:        DB    no    ;yes=printer available on printer port    119H
  162. XOFFTST:    DB    YES    ;yes=check for XOFF from remote    while    11AH
  163.                 ;sending a file in terminal mode
  164. XONWAIT:    DB    NO    ;yes=wait for XON after CR while    11BH
  165.                 ;sending a file in terminal mode
  166. TOGXOFF:    DB    YES    ;yes=allow toggling of XOFF checking    11CH
  167. IGNORCTL:    DB    no    ;yes=CTL-chars above ^M not displayed    11DH
  168. EXTRA1:        DB    0    ;for future expansion            11EH
  169. EXTRA2:        DB    0    ;for future expansion            11FH
  170. BRKCHR:        DB    'V'-40H    ;^V(^@) = Send a 300 ms. break tone    120H
  171. NOCONNCT:    DB    'N'-40H    ;^N = Disconnect from the phone line    121H
  172. LOGCHR:        DB    'L'-40H    ;^L = Send logon            122H
  173. LSTCHR:        DB    'P'-40H    ;^P = Toggle printer            123H
  174. UNSAVE:        DB    'R'-40H    ;^R = Close input text buffer        124H
  175. TRANCHR:    DB    'T'-40H ;^T = Transmit file to remote        125H
  176. SAVECHR:    DB    'Y'-40H    ;^Y = Open input text buffer        126H
  177. EXTCHR:        DB    'O'-40H    ;^O(^^) = Send next character        127H
  178. ;
  179. ;
  180.         DS    2    ; used by PMMI                    128H
  181. IN$MODCTL1:            ; get the status bits            12AH
  182.     lda    RS232$status
  183.     ret
  184. ;
  185. ; TABLE OF BAUDRATE PARAMETERS
  186. ;
  187. BAUD$TABLE:
  188.     db    0    ; 0    110    (not used)
  189.     db    6    ; 1    300
  190.     db    0    ; 2    450    (not used)
  191.     db    7    ; 3    600
  192.     db    0    ; 4    710    (not used)
  193.     db    8    ; 5    1200
  194. ;
  195. ;
  196. ;
  197. OUT$MODDATP:                ;out modem data port        134H
  198.     sta    xmit$data
  199.     push    h
  200.     lxi    h,RS232$status
  201.     jmp    out$c128$cont
  202.  
  203. IN$MODDATP:                ;in modem data port        13EH
  204.     lda    recv$data
  205.     push    h
  206.     lxi    h,RS232$status
  207.     jmp    in$c128$cont
  208.  
  209. ANI$MODRCVB:    ANI    MODRCVB    ! RET    ;bit to test for receive ready    148H
  210. CPI$MODRCVR:    CPI    MODRCVR ! RET    ;value of receive bit when rdy    14BH
  211. ANI$MODSNDB:    ANI    MODSNDB    ! RET    ;bit to test for send ready    14EH
  212. CPI$MODSNDR:    CPI    MODSNDR    ! RET    ;value of send bit when ready    151H
  213.  
  214. ;    PMMI Modem Vectors (not used by C128)
  215. ;        DS    6        ;                154H
  216. ;
  217. ;    used for C128 (no PMMI modem)  (6 bytes)
  218. ;
  219. out$c128$cont:                ;                154H
  220.     setb    7,m
  221.     db    21h            ; LXI    H,(res 0,m)
  222. ;
  223. in$c128$cont:                ;                157H
  224.     res    0,m
  225.     pop    h
  226.  
  227. OUT$MODCTL1:    ret ! nop ! nop        ;out modem control port     15AH
  228. OUT$MODCTL2:    ret ! nop ! nop        ;out modem status port        15DH
  229.  
  230. ;
  231. LOGONPTR:    DW    LOGON        ;for user message.        160H
  232. jmp$dial    ds    3        ;                162H
  233. jmp$disconnect    ds    3        ;                165H
  234. JMP$GOODBYE:    JMP    GOODBYE        ;                168H
  235. JMP$INITMOD:    JMP    INITMOD        ;go to user written routine    16BH
  236.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    16EH
  237.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    171H
  238.         RET  !    NOP  !    NOP    ;(by-passes PMMI routine)    174H
  239. JMP$SETUPR:    JMP    SETUPR        ;                177H
  240. JMP$SPCLMENU:    JMP    SPCLMENU    ;                17AH
  241. JMP$SYSVER:    JMP    SYSVER        ;                17DH
  242. JMP$BREAK:    JMP    SENDBRK        ;                180H
  243. ;
  244. ;
  245. ; Do not change the following six lines.
  246. ;
  247. JMP$ILPRT:    DS    3        ;                183H
  248. JMP$INBUF:    DS    3        ;                186H
  249. JMP$INLNCOMP:    DS    3        ;                189H
  250. JMP$INMODEM    DS    3        ;                18CH
  251. JMP$NXTSCRN:    DS    3        ;                18FH
  252. JMP$TIMER:    DS    3        ;                192H
  253. ;
  254. ;
  255. ; Clear sequences -- CLREOS is clear to end of screen, CLRSCRN is clear
  256. ; entire screen.  Last entry must be 0.  Any other 0's act as NOP's.
  257. ;
  258. CLREOS:
  259.     CALL    JMP$ILPRT        ;                195H
  260.     DB    esc,'Y',eom
  261. SPCLMENU:
  262.     ret
  263.     db    0,0            ;                19DH
  264. ;
  265. CLRSCRN:
  266.     CALL    JMP$ILPRT        ;                19EH
  267.     DB    'Z'-40h,eom
  268.     ret
  269.     db    0,0,0            ;                1A6H
  270.  
  271. ;
  272. ;
  273. ;
  274. SYSVER:
  275.     CALL    JMP$ILPRT        ;                1A7H
  276.     DB    'C-128 Ver. for 1670 or 1011A ',cr,lf,eom
  277.     RET
  278. ;.....
  279. ;
  280. ;
  281. ;-----------------------------------------------------------------------
  282. ;
  283. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  284. ;     end of your last routine should terminate by 0400H (601 bytes
  285. ;     available after start of SYSVER) if using the Hayes Smartmodem
  286. ;     or by address 0C00H (2659 bytes) otherwise.
  287. ;
  288. ;-----------------------------------------------------------------------
  289. ;
  290. ;.....
  291. ;
  292. ;    
  293. ; C128 initialization -- set baudrate.
  294. ;
  295. INITMOD:
  296.     mvi    a,1            ; set default to 8 bits no parity
  297.     sta    XxD$config
  298.     call    set$default        ; set default to 1200 baud
  299.     lxi    b,data$port$b$dir
  300.     mvi    a,6h
  301.     outp    a
  302.     mvi    c,low(data$port$b)
  303.     inp    a
  304.     ori    6            ; set DTR bit (active hi)
  305.     outp    a
  306.     ret
  307. ;
  308. ; This routine sends a 300 ms. break tone and sets DTR low for the same
  309. ; length of time to disconnect some modems such as the Bell 212A, etc.    
  310. ;
  311. GOODBYE:                  ; TURN OFF DTR
  312.     push    b
  313.     lxi    b,data$port$b
  314.     inp    a
  315.     ani    not(6)            ; clear DTR and CTS bits
  316.     outp    a
  317.     call    sendbrk            ; send 300ms break
  318.     inp    a
  319.     ori    6            ; set DTR and CTS bits
  320.     outp    a
  321.     pop    b
  322.     mvi    a,6            ; set BAUD RATE back to 300
  323.     jmp    reset$baud        ; ..so the system runs faster
  324.                     ; call/ret
  325. ;
  326. ;
  327. ; This routine allows a 300 ms. break tone to be sent to reset some
  328. ; time-shar computers.
  329. ;
  330. SENDBRK: 
  331.     di                ; system will run faster without
  332.     push    b            ; ..interrupts
  333.     lxi    b,data$port$a
  334.     inp    a
  335.     ani    0FBh            ; send a break tone will be cleared 
  336.     outp    a            ; ..when interrupts turned on
  337.     mvi    b,3            ; WAIT at least 300 MS.
  338.     call    jmp$timer        ; ..(system running fast)
  339.     pop    b
  340.     ei                ; re-enable interrupts. will 
  341.     ret                ; ..clear break.
  342. ;
  343. ; Setup routine to allow changing modem speed with the SET command.
  344. ;
  345. SETUPR:
  346.     CALL    JMP$ILPRT        ; the 1011A is an RS232 card
  347.     DB    'Device Type (1670,1011A) ',0
  348.     call    read$buffer
  349.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2 
  350.     DB    '1011',0
  351.     jnc    set$1011        ; Cy=0 if match
  352.     CALL    JMP$INLNCOMP        ; compare to  BAUDBUF+2 
  353.     DB    '1670',0
  354.     jrc    setupr
  355. set$T$P:
  356.     call    JMP$ILPRT
  357.     db    'Touch or Pulse (T,P) ',0
  358.     call    read$buffer
  359.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2 
  360.     DB    'T',0
  361.     lxi    h,'T'*256+YES
  362.     jrnc    set$rate
  363.     CALL    JMP$INLNCOMP        ; compare to  BAUDBUF+2
  364.     DB    'P',0
  365.     jrc    set$T$P
  366. set$pluse:
  367.     lxi    h,'P'*256+YES
  368. set$rate:
  369.     shld    SMARTMODEM        ; L=smartmodem, H=touch/pluse
  370.     mvi    a,1
  371.     sta    XxD$config        ; set 8 bits no parity
  372. set$rate$loop:
  373.     CALL    JMP$ILPRT
  374.     DB    'Baud Rate (300,1200) ',0
  375.     call    read$buffer
  376.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2 
  377.     DB    '300',0
  378.     lxi    h,17+100h        ; clock=1.7, mspeed=1
  379.     JRNC    set$baud        ;
  380.     CALL    JMP$INLNCOMP
  381.     DB    '600',0
  382.     lxi    h,15+300h        ; clock=1.5, mspeed=3
  383.     JRNC    set$baud
  384.     CALL    JMP$INLNCOMP
  385.     DB    '1200',0
  386.     JRC    set$rate$loop
  387. set$default:
  388.     lxi    h,11+500h        ; clock=1.1, mspeed=5
  389. ;
  390. set$baud:
  391.     shld    CLOCK            ; L=CLOCK, H=MSPEED
  392.     mov    e,h
  393.     MVI    D,0
  394.     LXI    H,BAUD$TABLE
  395.     DAD    D
  396.     MOV    A,M            ; get BAUD RATE byte
  397. reset$baud:
  398.     push    psw
  399.     mvi    e,3ch            ; offset to jmp devtbl
  400.     call    vector$1        ; rets HL=char device table start
  401.     lxi    d,dev$no*8+7        ; offset to RS232 baud rate
  402.     dad    d            ; point to RS232 baud rate byte
  403.     pop    psw
  404.     mov    m,a            ; change baud rate
  405.  
  406.     mvi    c,dev$no        ; init RS232 baud rate
  407.     mvi    e,3fh            ; offset to jmp ?cinit
  408. vector$1:
  409.     lhld    01
  410.     mov    l,e
  411. ipchl:    pchl                ; (call/ret)
  412.  
  413.  
  414.  
  415. set$1011:
  416.     lxi    h,'P'*256+NO
  417.     call    set$rate
  418. set$num$bits:
  419.     CALL    JMP$ILPRT
  420.     DB    'Number Bits (7,8) ',0
  421.     call    read$buffer
  422.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  423.     DB    '7',0
  424.     mvi    l,0
  425.     JRNC    set$7            ; MATCH found
  426.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  427.     DB    '8',0
  428.     JRC    set$num$bits        ; wait for valid input
  429.     inr    l            ; L=1
  430. set$7:
  431. bad$parity:
  432.     CALL    JMP$ILPRT
  433.     DB    'Parity  (None,Odd,Even,Mark,Space) ',0
  434.     call    read$buffer
  435.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  436.     DB    'N',0
  437.     mvi    a,00000000b
  438.     JRNC    set$parity        ;
  439.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  440.     DB    'O',0
  441.     mvi    a,11100000b
  442.     JRNC    set$parity        ;
  443.     CALL    JMP$INLNCOMP        ; compare to  BAUDBUF+2
  444.     DB    'E',0
  445.     mvi    a,11000000b
  446.     JRNC    set$parity        ;
  447.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  448.     DB    'M',0
  449.     mvi    a,10100000b
  450.     JRNC    set$parity        ;
  451.     CALL    JMP$INLNCOMP        ; compare to BAUDBUF+2
  452.     DB    'S',0
  453.     JRC    bad$parity        ;
  454.     mvi    a,10000000b
  455. set$parity:
  456.     ora    l            ; add in the number of bits
  457.     sta    XxD$config
  458.     ret
  459.  
  460.  
  461.  
  462. read$buffer:
  463.     LXI    D,BAUDBUF        ; point to new input buffer
  464.     CALL    JMP$INBUF
  465.     inx    d
  466.     inx    d
  467.     ret
  468. ;
  469. ;
  470. ;
  471. BAUDBUF:
  472.     DB    10,0
  473.     DS    10
  474.  
  475. ; You can put in a message at this location which can be called up with
  476. ; CTL-O if TRANLOGON has been set TRUE.  You can put in several lines if
  477. ; desired.  End with a 0.
  478. ;
  479. ;
  480. LOGON:
  481.     DB    ' C128 running MDM under CP/M 3.0 ',CR,LF,0
  482. ;
  483.  
  484. ;
  485. ;
  486. ; NOTE:  MUST TERMINATE PRIOR TO 0400H (with Smartmodem)
  487. ;                 0C00H (without Smartmodem)
  488. ;
  489.       END
  490. ;
  491.