home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / IMP / I2C8-2.AZM / I2C8-2.ASM
Assembly Source File  |  2000-06-30  |  15KB  |  469 lines

  1.  
  2. ; I2C8-2.ASM - Commodore C128 overlay for IMP - 06/01/87
  3. ;
  4. ; This Commodore C128 overlay for IMP supports the Commodore 1670 modem,
  5. ; the Hayes Smartmodem 1200 or any similar modem using the Hayes "AT"
  6. ; command set, the Prometheus 1200 modem or any Racal-Vadic autodial
  7. ; modem.
  8. ;
  9. ; NOTE: Modems for the Commodore C128 plug into the "user's port".  The
  10. ;    Commodore 1670 modem plugs in directly.  Other brands of modems
  11. ;    can be used, but an adapter interface is needed to convert that
  12. ;    port to a RS232 type connector.  This is called a 1011A adapter
  13. ;    by Commodore.  The Omni-Tronics firm makes such an adapter which
  14. ;    comes with a RS-232 cable to plug into the modem.
  15. ;
  16. ;        The Commodore 1670 does not support DTR
  17. ;        so if using that modem, be sure to use:
  18. ;
  19. ;            NODTR  EQU  YES
  20. ;
  21. ;        in the equates below.  This substitutes
  22. ;        the "pause +++ pause ATH0" command for
  23. ;        dropping DTR.  If using a modem that
  24. ;        does support DTR, you can instead use:
  25. ;
  26. ;            NODTR  EQU  NO
  27. ;
  28. ;        since dropping DTR for 1/2 second is far
  29. ;        faster than the "pause +++ pause ATH0".
  30. ;        Also not all external modems support the
  31. ;        Hayes AT commands, etc.  The DTR/+++ is
  32. ;        used to remotely disconnect the modem
  33. ;        from the telephone line.
  34. ;
  35. ; NOTE: The times quoted for file transfer will likely be less than what
  36. ;    will be observed when using the C128 computer.    This is mostly
  37. ;    due to the way the information is sent to the disk and then ver-
  38. ;    ified.    As a result, it takes around 7-8 seconds to dump only 4k
  39. ;    to the Commodore 1571 disk system.  (Most disk systems take only
  40. ;    5-6 seconds to dump 16k.)  Consequently, this Commodore overlay
  41. ;    has a line at the very end which sets byte 0BFFH to dump every
  42. ;    4k (32 record intervals), so it will finish prior to a 10-second
  43. ;    time-out error.  (The 1541 disks are slower yet and that byte
  44. ;    may need to be changed to dump at 2k intervals if using the 1541
  45. ;    disk drive, to prevent timeout errors.)
  46. ;
  47. ;    The printer command has been disabled - due to the way the 1200
  48. ;    bps modem "bit-banging" has been implemented into the Commodore
  49. ;    C128, the printer can not be used at the same time the modem is
  50. ;    being used.
  51. ;
  52. ;    IMPORTANT:  IF YOU GOT THE "I2NM-n.ASM" FILE FOR CHANG-
  53. ;            ING THE PHONE NUMBER LIBRARY, AT THIS TIME
  54. ;            GO CHANGE THE LABEL "XFRSIZE" FROM 16 TO 4
  55. ;            SO IF/WHEN YOU USE THAT PROGRAM, IT WILL SET
  56. ;            THE 0BFF BYTE CORRECTLY FOR THE COMMODORE
  57. ;            TO DUMP TO DISK EACH 4K.  (IF YOU DO THAT
  58. ;            WHILE READING THIS, YOU WON'T FORGET IT.)
  59. ;
  60. ;                    - Notes by Irv Hoff W6FFC
  61. ;
  62. ;-----------------------------------------------------------------------
  63. ;
  64. ; You will want to look this file over carefully. There are a number of
  65. ; options that you can use to configure the program to suit your taste.
  66. ; This file adapts the Commodore C128 (with external modem) to IMP.COM.
  67. ;
  68. ; Edit this file for your preferences then follow the "TO USE:" example
  69. ; shown below.
  70. ;
  71. ; Many terminals will clear the screen with a CTL-Z.  If yours does, put
  72. ; a 1AH at CLEAR: (010AH).  Many terminals use two characters, the first
  73. ; normally an ESC.  For example, ESC *.  In this case put '*' at CLEAR:
  74. ; (The ESC will automatically be typed with no CTL-character present.)
  75. ; If you don't know what your terminal uses, put a 0 at CLEAR: and IMP
  76. ; will scroll up 24 blank lines to clear the CRT for things like MENU,
  77. ; looking at the function key table, typing CTL-Z in command mode, etc.
  78. ;
  79. ; Use the "SET" command to change the baudrate when desired.  The value
  80. ; at MSPEED controls the baudrate when the program is first called up.
  81. ;
  82. ;    NOTE:  The Commodore C128 does not have an authentic serial
  83. ;        port and thus can only run 1200 bps maximum speed.
  84. ;
  85. ;    TO USE: First edit this file filling in answers for your own
  86. ;        equipment.  Then assemble with ASM.COM or equivalent
  87. ;        assembler.  Then use MLOAD to merge into the main file:
  88. ;
  89. ;        MLOAD IMP.COM=IMP.COM,I2C8-x.HEX
  90. ;
  91. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  92. ;
  93. ; 06/01/87  Improved the GOODBYE routine, added BREAK routine, needs
  94. ;        IMP245 to use it.  (Not fully implemented for this computer
  95. ;        as yet.)                - Irv Hoff
  96. ;
  97. ; 12/12/85  Written to work with IMP, based on work done for MDM740 for
  98. ;        the C128 by Von Ertwine.          - Irv Hoff
  99. ;
  100. ; =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =   =
  101. ;
  102. ;
  103. YES    EQU    0FFH        ; Some assemblers cannot use NOT NO or
  104. NO    EQU    0        ;   0FFFFH for "YES", notably ASM.COM.
  105. ;
  106. ;
  107. ; C128 data
  108. ;
  109. PORT    EQU    6
  110. MEMRY    EQU    0FD4EH
  111. MDCTL1    EQU    MEMRY+1
  112. SNDDAT    EQU    MEMRY+2
  113. RCVDAT    EQU    MEMRY+3
  114. MDRCV    EQU    01H        ; Modem receive ready
  115. MDSNDB    EQU    80H        ; bit to test for send
  116. MDSNDR    EQU    00H        ; value when send ready
  117. MDTXE    EQU    00H
  118. ;
  119. ;
  120. ;-----------------------------------------------------------------------
  121. ;
  122. ESC    EQU    '['-40H    ; ^[ = Escape
  123. BELL    EQU    'G'-40H    ; ^G = Bell character
  124. LF    EQU    'J'-40H    ; ^J = Linefeed
  125. NEXTRY    EQU    'K'-40H    ; ^K = Try next phone number, abort this try
  126. CR    EQU    'M'-40H    ; ^M = Carriage return
  127. CLEARSC    EQU    'Z'-40H    ; ^Z = Clears screen, command mode only
  128. EOFCHAR    EQU    'Z'-40H    ; ^Z = End of file
  129. ;
  130. ;
  131. ;-----------------------------------------------------------------------
  132. ;
  133. ;
  134.     ORG    0100H
  135. ;
  136. ;
  137.     DS    3        ; Skip the data area below
  138. ;
  139. ;
  140. ; These routines and equates are at the beginning of the program so
  141. ; they can be patched by a monitor or overlay file without re-assembling
  142. ; the program.
  143. ;
  144. MSPEED:     DB    5    ; 0=110 1=300 2=450 3=600 4=710 5=1200        103H
  145.             ; 6=2400 7=4800 8=9600 9=19200 default
  146. HS2400:     DB    NO    ; Yes=2400 bps highest speed            104H
  147. HS1200:     DB    YES    ; Yes=1200 bps highest speed            105H
  148. RACAL:     DB    NO    ; Yes=Racal-Vadic 1200V or 2400V or 2400PA    106H
  149. PROMODM: DB    NO    ; Yes=Prometheus ProModem 1200 bps        107H
  150. RESVD1:     DB    NO    ; Reserved for special modems            108H
  151. RESVD2:     DB    NO    ; Reserved for special modems            109H
  152. ;
  153. ;
  154. CLEAR:     DB    1AH    ; Clear screen character (ESC not needed)    10AH
  155. CLOCK:     DB    12    ; Special clock speed, set for C128 at 1200 bps 10BH
  156.             ; 20=2 MHh, 37=3.68 MHz, 40=4 MHz, etc.
  157. BYTDLY:     DB    2    ; 0=0 delay  1=10ms  5=50 ms - 9=90 ms        10CH
  158.             ;   default time to send character in ter-
  159.             ;   minal mode file transfer for slow BBS
  160. CRDLY:     DB    2    ; 0=0 delay 1=100 ms 5=500 ms - 9=900 ms    10DH
  161.             ;   default time for extra wait after CRLF
  162.             ;   in terminal mode file transfer
  163. NOFCOL:     DB    5    ; Number of directory columns shown        10EH
  164. TCHPUL:     DB    'T'    ; T=tone, P=Pulse (Hayes 2400 modems)        10FH
  165. ;.....
  166. ;
  167. ;
  168. ADDLFD:     DB    NO    ; Yes=add LF after CR to send file in terminal    110H
  169.             ;   mode (normally added by remote echo)
  170. CONVRUB: DB    YES    ; Yes=convert rub to backspace            111H
  171. CRCDFLT: DB    YES    ; Yes=default to CRC checking            112H
  172. IGNRCTL: DB    YES    ; Yes=CTL-chars above ^M not displayed        113H
  173. ;.....
  174. ;
  175. ;
  176. EXTCHR:     DB    '['-40H    ; ESC = preceeds local control character    114H
  177. EXITCHR: DB    'E'    ; Exit character                115H
  178. FILESND: DB    'F'    ; Send file when in terminal mode        116H
  179. NOCONCT: DB    'N'    ; Disconnect from phone line            117H
  180. LOGCHR:     DB    'L'    ; Send logon                    118H
  181. LSTCHR:     DB    NO    ; Toggle printer (unavailable to C128 users)    119H
  182. UNSAVCH: DB    'R'    ; Close input text buffer            11AH
  183. SAVECHR: DB    'Y'    ; Open input text buffer            11BH
  184. CLEARS:     DB    'Z'    ; Clears screen, terminal mode            11CH
  185. BRKCHR:     DB    'Q'    ; Send a break tone                11DH
  186. NODTR:     DB    YES    ; Yes if no DTR and need ATH0 to disconnect    11EH
  187. ;.....
  188. ;
  189. ;
  190. ; Handles in/out ports for data and status
  191. ;
  192. I$MDCTL1: LDA    MDCTL1        ; Get status byte to A-reg.        11FH
  193.       RET            ;                    121H
  194.       DB    0,0,0,0,0,0    ; Spares if needed            122H
  195. ;
  196. I$MDTXE:  LDA    MDCTL1        ; (Needed for SIO or DART register 1    129H
  197.       RET            ;                    12BH
  198.       DB    0,0,0,0,0,0    ;                    12CH
  199. ;
  200. I$MDDATP: LDA    RCVDAT        ; Get the character            133H
  201.       JMP    GETDAT        ;                    136H
  202.       DB    0,0,0,0        ;                    139H
  203. ;
  204. O$MDDATP: STA    SNDDAT        ; Output the character            13DH
  205.       JMP    OUTDAT        ;                    140H
  206.       DB    0,0,0,0        ; Spares if needed            143H
  207. ;.....
  208. ;
  209. ;
  210. A$MDRCV:  ANI    MDRCV        ;                    147H
  211.       RET            ;                    149H
  212. ;
  213. C$MDRCV:  CPI    MDRCV        ;                    14AH
  214.       RET            ;                    14CH
  215. ;
  216. A$MDSND:  ANI    MDSNDB        ;                    14DH
  217.       RET            ;                    14FH
  218. ;
  219. C$MDSND:  CPI    MDSNDR        ;                    150H
  220.       RET            ;                    152H
  221. ;
  222. A$MDTXE:  ANI    MDTXE        ;                    153H
  223.       RET            ;                    155H
  224. ;
  225. C$MDTXE:  CPI    MDTXE        ;                    156H
  226.       RET            ;                    158H
  227. ;.....
  228. ;
  229. ;
  230. ; Special exit vector, used by some computers to reset interrupt vectors
  231. ;
  232. J$EXITVEC:JMP    SET300        ; Put C128 back to 300 baud clock    159H
  233. ;.....
  234. ;
  235. ;
  236. ; Jump vectors needed by each overlay
  237. ;
  238. J$GOODBYE:JMP    GOODBYE        ; Disconnects modem by dropping DTR    15CH
  239. J$INITMOD:JMP    INITMOD        ; Initializes modem, autosets baudrate    15FH
  240. J$STUPR:  JMP    STUPR        ; SET routine to change baudrate    162H
  241. J$SYSVR:  JMP    SYSVR        ; Signon message            165H
  242. ;.....
  243. ;
  244. ;
  245. ; "AT" command strings, can be replaced in individual overlay if needed
  246. ;
  247. J$STRNGA: JMP    SPLSTR        ; 1200 bps "AT" string            168H
  248. J$STRNG1: DS    3        ; 2400 bps "AT" string            16BH
  249. ;
  250. ;
  251. ; Next fourteen lines should not be changed by user overlay as these go
  252. ; to specific locations in the main program, not in the overlay.
  253. ;
  254. ;
  255. J$CMDSPL: DS    3        ; Allows entry of baudrate on CMD line    16EH
  256. J$CRLF:      DS    3        ; Turns up one new line on display    171H
  257. J$DIAL:      DS    3        ; Start of dialing routine        174H
  258. J$DSCONT: DS    3        ; Terminates modem use            177H
  259. J$GOLST:  DS    3        ; Printer routine, needed by Apple //e    17AH
  260. J$ILPRT:  DS    3        ; Prints an inline string, 0 to end    17DH
  261. J$INBUF:  DS    3        ; Stores a keybd string for comparison    180H
  262. J$INLNCP: DS    3        ; Inline "compare strings" routine    183H
  263. J$INMDM:  DS    3        ; Max .1 sec wait for modem character    186H
  264. J$RCVRSP: DS    3        ; For 3801 I/O use (TV-803)        189H
  265. J$SNDCHR: DS    3        ; Sends a character to the modem    18CH
  266. J$SNDSTR: DS    3        ; Sends a string to the modem, $ to end 18FH
  267. J$TIMER:  DS    3        ; .1 second timer (amount in 'B' reg.)    192H
  268. J$BREAK:  JMP    SENDBRK        ; Break routine             195H
  269. J$NEW2:      DB    0,0,0        ; For future needs            198H
  270. ;.....
  271. ;
  272. ;
  273. ; For 2400 bps auto-stepdown units
  274. ;
  275. MANUAL:      DB    0        ; For manual selection flag        19BH
  276. J$300:      JMP    OK300        ; Sets baudrate to 300 baud        19CH
  277. J$1200:      JMP    OK1200        ; Sets baudrate to 1200 bps        19FH
  278. J$2400:      JMP    OK2400        ; Sets baudrate to 2400 bps        1A2H
  279. ;.....
  280. ;
  281. ;
  282. LOGPTR:      DW    LOGON        ; Pointer to display LOGON message    1A5H
  283. ;
  284. SYSVR:      CALL    J$ILPRT        ; Display the following line        1A7H
  285.       DB    'Commodore C128 Version' ;                1AAH
  286.       DB    CR,LF,0
  287.       RET
  288. ;.....
  289. ;
  290. ;
  291. ;-----------------------------------------------------------------------
  292. ;
  293. ; NOTE:  You can change the SYSVER message to be longer or shorter.  The
  294. ;     end of your last routine should terminate by 0400H (601 bytes
  295. ;     available after start of SYSVER).
  296. ;
  297. ;-----------------------------------------------------------------------
  298. ;
  299. ; You can put in a message at this location which can be called up with
  300. ; (special character-L).  You can put in several lines.  End with a 0.
  301. ;
  302. LOGON:    DB    'C128 running CP/M 3.0',CR,LF,0
  303. ;
  304. ;-----------------------------------------------------------------------
  305. ;
  306. ;
  307. ; This routine allows a 300 ms break tone to be sent.
  308. ;
  309. SENDBRK:
  310.     RET
  311. ;.....
  312. ;
  313. ;
  314. ; This routine sets DTR low for 300 ms to disonnect the phone
  315. ;
  316. GOODBYE:
  317.     LXI    B,0DD01H    ; Dataport B
  318.     DB    0EDH,78H    ; Input A (Z80 instruction)
  319.     ANI    0F9H
  320.     DB    0EDH,79H    ; Output the new value, to disconnect
  321.     MVI    B,3        ; For 300 ms.
  322.     CALL    J$TIMER
  323.     LXI    B,0DD01H    ; Reset back to normal
  324.     DB    0EDH,78H
  325.     ORI    6
  326.     DB    0EDH,79H
  327.     RET
  328. ;.....
  329. ;
  330. ;
  331. ; Sets 8251 to 8 bits, DTR, RCV and TX ready
  332. ;
  333. INITMOD:MVI    A,1        ; Set to 8 bits, no parity
  334.     STA    MEMRY        ; Configure byte in BIOS
  335.     LDA    MSPEED        ; Get the selected value
  336.     CPI    1        ; 300 bps
  337.     JZ    OK300
  338.     CPI    5        ; 1200 bps
  339.     JZ    OK1200
  340.     JMP    STUPR1        ; Else ask what is wanted
  341. ;.....
  342. ;
  343. ;
  344. ; Initialize the port, baudrate is now in the B-reg. find where it goes
  345. ; and put it there.
  346. ;
  347. INIT1:    PUSH    B        ; Temporarily store the baudrate value
  348.     LHLD    0000H+1        ; Get BIOS address
  349.     LXI    D,57        ; CP/M JMP device table
  350.     DAD    D        ; Index into BIOS
  351.     CALL    INIT2        ; Jumps to address now in HL
  352.                 ; returns with HL=char device tbl start
  353.     LXI    D,PORT*8+7    ; Offset to RS232 baud rate
  354.     DAD    D        ; Point to RS232 baud rate byte
  355.                 ;   Byte now in HL
  356.     POP    B        ; Get the baudrate value back
  357.     MOV    M,B        ; Store the requested baud rate
  358. ;
  359. ;
  360. ; Have now stored desired baudrate, find the address in BIOS where the
  361. ; port will be initialized, put the correct port into the 'C' register
  362. ; and then initialize that port to baud rate just set, finished.
  363. ;
  364.     LHLD    0000H+1        ; Get BIOS address
  365.     LXI    D,60        ; CP/M init address
  366.     DAD    D        ; Index into BIOS
  367.     MVI    C,PORT        ; Tell it what port to initialize
  368. ;
  369. ;
  370. ; Jumps to HL address, performs that routine, then returns to original
  371. ; area that called this area.
  372. ;
  373. INIT2:    PCHL            ; Jump to that routine then return
  374. ;.....
  375. ;
  376. ;
  377. ; We found there was a character, got it, but have to manually reset the
  378. ; flag to zero saying we did get the character.
  379. ;
  380. GETDAT:    PUSH    H        ; Save the current address just in case
  381.     LXI    H,MDCTL1    ; Address of status byte
  382.     DB    0CBH,86H    ; Reset the 0 bit of the HL status byte
  383.     POP    H        ; Restore the original address
  384.     RET            ; Return with the character
  385. ;.....
  386. ;
  387. ;
  388. ; Output character has been stored in the BIOS memory location, now set
  389. ; the flag showing there is a charcter ready.
  390. ;
  391. OUTDAT:    PUSH    H        ; Save any current address, if needed
  392.     LXI    H,MDCTL1    ; Address of the status byte
  393.     DB    0CBH,0FEH    ; Set bit 7 of the HL status byte
  394.     POP    H        ; Get the original address back
  395.     RET            ; All done
  396. ;.....
  397. ;
  398. ;
  399. STUPR:    CALL    J$CMDSPL    ; Gives us CMDBUF+6
  400.     JNC    STUPR2
  401. ;
  402. STUPR1:    CALL    J$ILPRT
  403.     DB    'Input Baud Rate (300, or 1200): ',0
  404.     LXI    D,BAUDBUF    ; Point to new input buffer
  405.     CALL    J$INBUF
  406.     CALL    J$CRLF
  407.     LXI    D,BAUDBUF+2
  408. ;
  409. STUPR2:    CALL    J$INLNCP    ; Compare BAUDBUF+2 with chars. below
  410.     DB    '300',0
  411.     JNC    OK300        ; Go if got match
  412.     CALL    J$INLNCP
  413.     DB    '1200',0
  414.     JNC    OK1200
  415.     CALL    J$ILPRT        ; All matches failed, tell operator
  416.     DB    '++ Incorrect entry ++',CR,LF,BELL,CR,LF,0
  417.     JMP    STUPR1        ; Try again
  418. ;
  419. OK300:    MVI    A,1        ; MSPEED 300 baud value
  420.     MVI    B,BD300        ; Get 300 baud parameters in 'HL'
  421.     JMP    LOADBD        ; Go load them
  422. ;
  423. OK1200:    MVI    A,5
  424.     MVI    B,BD1200
  425.     JMP    LOADBD
  426. ;
  427. OK2400:    JMP    OK1200        ; C128 does not support 2400 bps
  428. ;
  429. LOADBD:    STA    MSPEED        ; Change time-to-send to match baudrate
  430.     JMP    INIT1
  431. ;.....
  432. ;
  433. ;
  434. ; TABLE OF BAUDRATE PARAMETERS
  435. ;
  436. BD300    EQU    6        ; Divisor for 300 baud
  437. BD1200    EQU    8        ; Divisor for 1200 bps
  438. ;
  439. BAUDBUF:DB    10,0,0,0,0,0
  440.     DB    0,0,0,0,0,0
  441. ;.....
  442. ;
  443. ;
  444. SET300:    MVI    B,BD300
  445.     JMP    INIT1
  446. ;.....
  447. ;
  448. ;
  449. ; Initialization string - the '#' character is a 100 ms. delay, at least
  450. ; four should be used after a CR following a commnd.
  451. ;
  452. SPLSTR:    DB    'ATV0',CR,'####','ATE1Q0X1',CR,'####','$'
  453. ;
  454. ;
  455. ; This sets the size of the disk dump.    Most Commodore systems write to
  456. ; disk so slowly that 4k is a good figure to use to insure finishing
  457. ; prior to a 10-second timeout at the other end (which causes them to
  458. ; resend the last transmission again, etc.)
  459. ;
  460.     ORG    0BFFH
  461. ;
  462.     DB    20H        ; 20h=4k, 40h=8k, 80h=16k disk dumps
  463. ;.....
  464. ;
  465. ;
  466. ; NOTE: Must terminate by 0400H
  467. ;
  468.     END
  469.