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 / ZMODEM / ZMO-1805.Z80 < prev    next >
Text File  |  2000-06-30  |  18KB  |  836 lines

  1.     .TITLE    'ZMP Overlay for Hitachi HD64180 version 1.0'
  2.     NAME    SB180
  3. ;  PROGRAM: ZMO-1805.Z80
  4. ;  AUTHOR:  Bill Biersdorf
  5. ;  VERSION: 1.5
  6. ;  DATE:  14 Sept, 1988
  7. ;-----------------------------------------------------------------------
  8. ;    This overlay is set up for a SB180-FX computer
  9. ;        HD64180 ASCII port 0.
  10. ; This file is a BETA-TEST version, known only to work on 9 MHz 'FX.
  11. ; Assemble with ZAS.
  12. ;-----------------------------------------------------------------------
  13. ; 89/04/12 - Modified to ZMP v1.5        - George Conover
  14. ; 89/03/15 - Removed the beginning remarks to make the file
  15. ;            smaller. If you need the remarks there are in the
  16. ;            file ZMP-BLNK.Z80             - George Conover
  17. ; 89/03/02 - Modified to ZMP v1.4        - George Conover
  18. ; 88/10/10 - Modified to ZMP v1.3        - Ron Murray
  19. ; 88/09/15 - Modified to ZMP v1.2        - Ron Murray
  20. ; 88/10/13 - First version of this file        - Bill Biersdorf
  21. ;
  22. ;    Written by -
  23. ;      Ron Murray, c/o Z-Node 62, 061-9-450-0200, Perth, Western Australia.
  24. ;-----------------------------------------------------------------------
  25. ; B.2.4    Beta-test version 2            03/02/89  George Conover
  26. ;    -- Updated to ZMP14
  27. ;    -- Tested with Micromint SB180 cpu speed 6.1 Mhz
  28. ;
  29. ; Modified to v1.3 standard Ron Murray 13/10/88
  30. ;
  31. ; B.2    Beta-test version 2            09/27/88  Bill Biersdorf
  32. ;    -- added conditionals for clock speeds
  33. ;    -- added equate 'dtrfx' for latch DTR on the 'FX
  34. ;    -- character framing may work on non-FX, not sure
  35. ;
  36. ; B.1    Beta-test version 1            09/24/88  Bill Biersdorf
  37. ;    -- works with 9 MHz SB180-FX
  38. ;    -- no provisions for stop bit, word length, or paity change
  39. ;
  40. ;-----------------------------------------------------------------------
  41. NO    DEFL    0
  42. YES    DEFL    NOT NO        ;
  43. ; This file is assembled with ZAS
  44.  
  45.      .XLIST            ;
  46.      .SALL            ; Suppress macro listing
  47.      .HD64            ; Use HD64180 opcodes
  48.      MACLIB    Z3BASE        ; ZCPR3 equates
  49.      .LIST            ;
  50. ;
  51. ; Select-a-speed        ; NOTE: set only ONE of the following
  52. ;                ;   to YES
  53. ;
  54. CPU12    DEFL    NO        ; 12.288 MHz HD64180
  55. CPU9    DEFL    NO        ; 9.216 MHz HD64180
  56. CPU6    DEFL    YES        ; 6.144 MHz HD64180
  57. ;
  58. ; Control latch DTR
  59. ;
  60. DTRFX    DEFL    NO        ; Otherwise just use RTS code
  61. ;
  62. ; User-set variables:
  63. ;
  64. IPORT    EQU    08H        ; MODEM data in port
  65. OPORT    EQU    06H        ; MODEM data out port
  66. CPORT    EQU    00H        ; MODEM control port
  67. MSTAT    EQU    04H        ; MODEM status port
  68. BPORT    EQU    02H        ; MODEM baudrate port
  69. MDRCV    EQU    80H        ; Receive ready bit
  70. MDSND    EQU    02H        ; Send ready bit
  71. ;
  72.      IF    CPU12
  73. CLKSPD    EQU    12
  74.      ENDIF
  75. ;
  76.      IF    CPU9
  77. CLKSPD    EQU    9
  78.      ENDIF
  79. ;
  80.      IF    CPU6
  81. CLKSPD    EQU    6        ; Processor clock speed in MHz
  82.      ENDIF
  83. ;
  84.  
  85. ;Set the following two equates to the drive and user area which will contain
  86. ;   ZMP's .OVR files, .CFG file, .FON file and .HLP file. Set both to zero
  87. ;   (null) to locate them on the drive from which ZMP was invoked.
  88.  
  89. OVERDRIVE    EQU    0    ; Drive to find overlay files on ('A'-'P')
  90. OVERUSER    EQU    0    ; User area to find files
  91.  
  92. ;------------------------------------------------------------------------------
  93.  
  94.  
  95. ; NOT user-set variables
  96.  
  97. USERDEF    EQU    0145H        ; origin of this overlay
  98.                 ; This address should not change with
  99.                 ; subsequent revisions.
  100. MSPEED    EQU    03CH        ; location of current baud rate.
  101. OVSIZE    EQU    0400H        ; Max size of this overlay
  102. ;
  103. ;
  104. ESC    EQU    1BH
  105. CR    EQU    0DH
  106. LF    EQU    0AH
  107. BDOS    EQU    5
  108.  
  109.     ORG    USERDEF
  110. ;
  111. ;Jump table for the overlay: do NOT change this
  112. ;
  113. JUMPTAB:JP    SCRNPR        ; Screen print
  114.     JP    MRD        ; Modem read with timeout
  115.     JP    MCHIN        ; Get a character from modem
  116.     JP    MCHOUT        ; Send a character to the modem
  117.     JP    MORDY        ; Test for tx buffer empty
  118.     JP    MIRDY        ; Test for character received
  119.     JP    SNDBRK        ; Send break
  120.     JP    CURSADD        ; Cursor addressing
  121.     JP    CLS        ; Clear screen
  122.     JP    INVON        ; Highlight (inverse video) on
  123.     JP    INVOFF        ; Highlight (inverse video) off
  124.     JP    HIDE        ; Hide cursor
  125.     JP    SHOW        ; Show cursor
  126.     JP    SAVECU        ; Save cursor position
  127.     JP    RESCU        ; Restore cursor position
  128.     JP    MINT        ; Service modem interrupt
  129.     JP    INVEC        ; Initialise interrupt vectors
  130.     JP    DINVEC        ; De-initialise interrupt vectors
  131.     JP    MDMERR        ; Test uart flags for error
  132.     JP    DTRON        ; Turn DTR (and RTS) ON
  133.     JP    DTROFF        ; Turn DTR (and RTS) OFF
  134.     JP    INIT        ; Initialise uart
  135.     JP    WAIT        ; Wait seconds
  136.     JP    MSWAIT        ; Wait milliseconds
  137.     JP    USERIN        ; user-defined entry routine
  138.     JP    USEROUT        ; user-defined exit routine
  139.     JP    GETVARS        ; get system variables
  140.       JP    SETPORT        ; Set port (0 or 1)
  141.  
  142. ; Spare jumps for compatibility with future versions
  143.     JP    SPARE        ; spare for later use
  144.     JP    SPARE        ; spare for later use
  145.     JP    SPARE        ; spare for later use
  146.     JP    SPARE        ; spare for later use
  147.     JP    SPARE        ; spare for later use
  148.     JP    SPARE        ; spare for later use
  149.  
  150. ;
  151. ; Main code starts here
  152. ;
  153. ;
  154. ; Main code starts here
  155. ;
  156. CODEBGN;
  157. ;
  158. ; Screen print function
  159. ;
  160. SCRNPR:
  161. ;
  162. ; <== Insert your own code here
  163. ;
  164.     CALL    PRINT
  165.     DB    CR,LF
  166.     DB    'Screen-print function not supported.',CR,LF,LF
  167.     DB    0
  168. ;
  169. ; <== End of your own code
  170. ;
  171. SPARE:    RET
  172.  
  173. ; Disable and Enable PUBLIC ZRDOS directories
  174.  
  175. ; Set the Z3ENV equate to the address of your environment
  176. ; descriptor, then set the relevant bits in PUBDRV and PUBDIR
  177. ; in accordance with this table:
  178.  
  179. ;           drive byte (126)                 user byte (127)
  180. ;           ----------------                 ---------------
  181. ; bit:      7 6 5 4 3 2 1 0                  7 6 5 4 3 2 1 0
  182. ;           | | | | | | | |                  | | | | | | | |
  183. ; drive:    H G F E D C B A      user #:     8 7 6 5 4 3 2 1
  184.  
  185. ;Z3ENV    EQU    0FE00H        ; adjust as required
  186. PUBDRV    EQU    00000001B    ; drive A set PUBLIC
  187. PUBDIR    EQU     00000111B    ; users 1, 2, and 3 set PUBLIC
  188.  
  189. ; User-defined entry routine: leave empty if not needed
  190. USERIN:
  191.     LD    HL,Z3ENV+126    ; point HL at PUBLIC assignment buffer
  192.     XOR    A        ; zero accumulator
  193.     LD    (HL),A        ; store zero to first byte of buffer
  194.     INC    HL        ; point to second byte of buffer
  195.     LD    (HL),A        ; zero it too
  196.     RET
  197.  
  198. ; User-defined exit routine: leave empty if not needed
  199. USEROUT:
  200.     LD    HL,Z3ENV+126    ; point HL at PUBLIC assignment buffer
  201.     LD    A,PUBDRV    ; get drive code in A
  202.     LD    (HL),A        ; set first byte to PUBLIC drive
  203.     INC    HL        ; point to second byte of buffer
  204.     LD    A,PUBDIR    ; get user code in A
  205.     LD    (HL),A        ; set second byte to PUBLIC user
  206.     RET
  207. ;
  208. ; Get a character from the modem: return in HL
  209. ; It is not necessary to test for status
  210. ;
  211. MCHIN:    PUSH    BC
  212. ;
  213. ; <== Insert your own code here
  214. ;
  215.     IN0    A,(IPORT)    ; To get the character in A
  216. ;
  217. ; <== End of your own code
  218. ;
  219.     LD    L,A        ; Put in HL
  220.     LD    H,0
  221.     OR    A        ; Set/clear Z
  222.     POP    BC
  223.     RET
  224. ;
  225. ; Send a character to the modem
  226. ;
  227. MCHOUT:    LD    HL,2        ; Get the character
  228.     ADD    HL,SP
  229.     LD    A,(HL)        ; In A
  230. ;
  231. ; <== Insert your own code here
  232. ;
  233.     OUT0    (OPORT),A
  234. ;
  235. ; <== End of your own code
  236. ;
  237.     RET            ; Done
  238. ;
  239. ; Test for output ready: return YES (1) in HL if ok
  240. ;
  241. MORDY:
  242. ;
  243. ; <== Insert your own code here
  244. ;
  245.     LD    HL,00H        ; Assume not ready for now
  246.     IN0    A,(MSTAT)
  247.     IN0    A,(MSTAT)    ; Do twice for valid DCD
  248.     AND    MDSND
  249.     JR    Z,MORDY1    ; Still not ready
  250.     INC    HL        ; Ready, so set HL
  251. ;
  252. MORDY1:
  253. ;
  254. ; <== End of your own code
  255. ;
  256.     LD    A,L        ; Set/clear Z
  257.     OR    A
  258.     RET
  259. ;
  260. ; Test for character at modem: return YES (1) in HL if so
  261. ;
  262. MIRDY:
  263. ;
  264. ; <== Insert your own code here
  265. ;
  266.     LD    HL,00H        ; Assume not ready for now
  267.     IN0    A,(MSTAT)
  268.     IN0    A,(MSTAT)    ; Do twice for valid DCD
  269.     AND    MDRCV
  270.     JR    Z,MIRDY1    ; Still not ready
  271.     INC    HL        ; Ready, so set HL
  272. ;
  273. MIRDY1:
  274. ;
  275. ; <== End of your own code
  276. ;
  277.     LD    A,L        ; Set/clear Z
  278.     OR    A
  279.     RET
  280. ;
  281. ; Send a break to the modem: leave empty if your system can't do it
  282. ;
  283. SNDBRK:
  284. ;
  285. ; <== Insert your own code here, tTo go to 'break' level
  286. ;
  287. ; <== End of your own code
  288. ;
  289.     LD    HL,300
  290.     CALL    WAITHLMS    ; Wait 300 ms
  291. ;
  292. ; <== Insert your own code here, to restore
  293. ;
  294. ; <== End of your own code
  295. ;
  296.     RET
  297. ;
  298. ; Test UART flags for error: return YES (1) in HL if error
  299. ;
  300. MDMERR:
  301. ;
  302. ; <== Insert your own code here
  303. ;
  304.     LD    HL,00H        ; Not yet implemented
  305. ;
  306. ; <== End of your own code
  307. ;
  308.     LD    A,L        ; Set/clear Z
  309.     OR    A
  310.     RET
  311. ;
  312. ; Turn DTR (and RTS) ON. (reset)
  313. ;
  314. DTRON:
  315. ;
  316. ; <== Insert your own code here
  317. ;
  318.  
  319.     IN0    A,(CPORT)
  320.     AND    0EFH        ; RTS on
  321.     OUT0    (CPORT),A
  322. ;
  323.      IF    DTRFX
  324.     CALL    DTRSTAT        ; Pull control latch
  325.     LD    A,10111111B    ; Mask off DTR bit
  326.     AND    B        ; And it out
  327.     LD    B,A
  328.     LD    A,0FFH        ; Set up for write
  329.     LD    HL,(1)        ; Get address of BIOS
  330.     LD    L,3FH        ; Add offset for control latch
  331.     LD    DE,DTRDONE
  332.     PUSH    DE        ; Save return vector
  333.     JP    (HL)        ; Go to the latch routine
  334.      ENDIF
  335. ;
  336.      IF    NOT DTRFX    ;
  337.     RET
  338.      ENDIF
  339. ;
  340. ; <== End of your own code
  341. ;
  342. ; Turn DTR (and RTS) OFF. (set)
  343. ;
  344. DTROFF:
  345. ;
  346. ; <== Insert your own code here
  347. ;
  348.     IN0    A,(CPORT)
  349.     OR    10H        ; RTS off
  350.     OUT0    (CPORT),A
  351. ;
  352.      IF    DTRFX
  353.     CALL    DTRSTAT        ; Pull control latch
  354.     LD    A,01000000B    ; Mask off DTR bit
  355.     OR    B        ; Or it in
  356.     LD    B,A
  357.     LD    A,0FFH        ; Set up for write
  358.     LD    HL,(1)        ; Get address of BIOS
  359.     LD    L,3FH        ; Add offset for control latch
  360.     LD    DE,DTRDONE
  361.     PUSH    DE        ; Save return vector
  362.     JP    (HL)        ; Go to the latch routine
  363.      ENDIF
  364. ;
  365.      IF    NOT DTRFX    ;
  366.     RET
  367.      ENDIF
  368. ;
  369. ; <== End of your own code
  370. ;
  371. DTRDONE:RET
  372. ;
  373. ; Needed to prevent changes to other control latch registers.
  374. ;
  375.      IF    DTRFX
  376. DTRSTAT:XOR    A
  377.            LD    HL,(1)        ; Get address of BIOS
  378.     LD    L,3FH        ; Add offset of control latch
  379.     JP    (HL)        ; Go get status
  380.      ENDIF
  381. ;
  382. ; Initializ the UART
  383. ;
  384. INIT:    LD    HL,2        ; Get parameters
  385.     ADD    HL,SP
  386.     EX    DE,HL
  387.     CALL    GETPARM        ; In HL
  388.     LD    (BRATE),HL    ; Baud rate
  389.     CALL    GETPARM
  390.     LD    (PARITY),HL    ; Parity
  391.     CALL    GETPARM
  392.     LD    (DATA),HL    ; Data bits
  393.     CALL    GETPARM
  394.     LD    (STOP),HL    ; Stop bits
  395. ;
  396. ; <== Insert your own code here
  397. ;
  398.     CALL    INITSIO
  399.     CALL    SETBAUD        ; Go set baud
  400. ;;    CALL    SETPRTY     ; "  "     parity
  401. ;;    CALL    SETSTOP     ; "  "     stop bits
  402. ;;    CALL    WLENGTH     ; "  "     word length
  403. ;
  404.     CALL    PRINT
  405.     DB    CR,LF,0
  406.     RET            ; Continue
  407. ;
  408. ; Using values below
  409. ;
  410. INITSIO:
  411.     IN0    A,(CPORT)
  412.     AND    0EFH        ; RTS on
  413.     OR    68H        ; Enable xmit, receive; clear errors
  414.     OUT0    (CPORT),A
  415.     RET
  416. ;
  417. SETBAUD:LD    A,(BRATE)    ; Get BRATE into A
  418.     LD    E,A        ; And DE
  419.     LD    D,0
  420.     LD    HL,DIVISORS    ; Get offset into baudrate divisor table
  421.     ADD    HL,DE
  422.     LD    A,(HL)        ; Fetch code
  423.     OR    A        ; 00h means upsupported code
  424.     JR    Z,SBEXIT    ; Exit if bad
  425.     OUT0    (BPORT),A    ; Else set baud
  426.     LD    A,(BRATE)    ; Tell zmp it's ok
  427.     LD    (MSPEED),A
  428. ;
  429. SBEXIT:    RET
  430. ;
  431. DIVISORS:
  432. ;
  433.      IF    CPU12        ; 12.288 MHz clock
  434.     DB    00H,0EH,00H    ; 0 = 110 baud    1 = 300 baud    2 = 450 baud
  435.     DB    0DH,00H,06H    ; 3 = 600 baud    4 = 710 baud    5 = 1200 baud
  436.     DB    05H,04H,03H    ; 6 = 2400 baud 7 = 4800 baud    8 = 9600 baud
  437.     DB    02H        ; 9 = 19200 baud
  438.      ENDIF
  439. ;
  440.      IF    CPU9        ; 9.216 MHz clock
  441.     DB    00H,26H,00H    ; 0 = 110 baud    1 = 300 baud    2 = 450 baud
  442.     DB    25H,00H,24H    ; 3 = 600 baud    4 = 710 baud    5 = 1200 baud
  443.     DB    23H,22H,21H    ; 6 = 2400 baud 7 = 4800 baud    8 = 9600 baud
  444.     DB    20H        ; 9 = 19200 baud
  445.      ENDIF
  446. ;
  447.      IF    CPU6        ; 6.144 MHz clock
  448.     DB    00H,0DH,00H    ; 0 = 110 baud    1 = 300 baud    2 = 450 baud
  449.     DB    06H,00H,05H    ; 3 = 600 baud    4 = 710 baud    5 = 1200 baud
  450.     DB    04H,03H,02H    ; 6 = 2400 baud 7 = 4800 baud    8 = 9600 baud
  451.     DB    01H        ; 9 = 19200 baud
  452.      ENDIF
  453. ;
  454.     DB    0,0,0        ; 10 = 38400 baud  11 = 57600 baud
  455. ;                ; 12 = 76800 baud
  456. ;
  457. ; Parity is controlled by bit 1 of CPORT and bit 4 of BPORT as follows:
  458. ;
  459. ;                BPORT       CPORT
  460. ;           Parity    Bit 4       Bit 1
  461. ;             Off      -         0
  462. ;             Odd      1         1
  463. ;             Even      0         1
  464. ;
  465. SETPRTY:
  466. ;;    ld    a,(parity)    ; get parity into A
  467. ;;    cp    'E'
  468. ;;    jr    z,prevn     ; even
  469. ;;    cp    'O'
  470. ;;    jr    z,prodd     ; odd
  471. ;;
  472. ;;                ; else assume none
  473. ;;proff:    in0    a,(cport)
  474. ;;    and    0fdh        ; reset bit 1
  475. ;;    push    af        ; save
  476. ;;    in0    a,(bport)
  477. ;;    jr    prnxt
  478. ;;
  479. ;;prevn:    in0    a,(cport)
  480. ;;    or    02h        ; set bit 1
  481. ;;    push    af        ; save
  482. ;;    in0    a,(bport)
  483. ;;    and    0efh        ; reset bit 4
  484. ;;    jr    prnxt
  485. ;;
  486. ;;prodd:    in0    a,(cport)
  487. ;;    or    02h        ; set bit 1
  488. ;;    push    af        ; save
  489. ;;    in0    a,(bport)
  490. ;;    or    10h        ; set bit 4
  491. ;;
  492. ;;prnxt:
  493. ;;    out0    (bport),a    ; set for (even) or (odd)
  494. ;;    pop    af
  495. ;;    out0    (cport),a    ; set for (even/odd) or (none)
  496. ;;    call    initsio     ; reset the UART
  497.  
  498.     RET
  499.  
  500. ;        The number of stop bits is controlled by bit
  501. ;        0 of CPORT, as follows:
  502. ;
  503. ;            Stop bits       Bit 0
  504. ;            1         0
  505. ;            2         1
  506. ;
  507. ;;;SETSTOP:
  508. ;;;    LD    A,(STOP)    ; get stopbits into A
  509. ;;;    CP    2
  510. ;;;    JR    Z,STOP2        ; two
  511. ;
  512. ;;;STOP1:    IN0    A,(CPORT)
  513. ;;;    AND    0FEH        ; reset bit 0
  514. ;;;    JR    SSNXT
  515. ;
  516. ;;;STOP2:    IN0    A,(CPORT)
  517. ;;;    OR    01H        ; set bit 0
  518. ;
  519. ;;;SSNXT:    OUT0    (CPORT),A
  520. ;;;    CALL    INITSIO        ; reset the UART
  521. ;
  522.     RET
  523. ;
  524. ; The number of bits per character is controlled by bit 2 of CPORT as
  525. ; follows:
  526. ;
  527. ;            BPC     Bit 2
  528. ;             7          0
  529. ;             8          1
  530. ;
  531. ;;;WLENGTH:
  532. ;;;    LD    A,(DATA)    ; get word length
  533. ;;;    CP    7
  534. ;;;    JR    Z,WLEN7        ; 7
  535. ;                ; assume 8
  536. ;;;WLEN8:    IN0    A,(CPORT)
  537. ;;;    OR    04H        ; set bit 2
  538. ;;;    JR    WLNXT
  539. ;
  540. ;;;WLEN7:    IN0    A,(CPORT)
  541. ;;;    AND    0FBH        ; reset bit 2
  542. ;
  543. ;;;WLNXT:    OUT0    (CPORT),A
  544. ;;;    CALL    INITSIO        ; reset the UART
  545. ;
  546. ; <== End of your own code
  547. ;
  548.     RET
  549. ;
  550. BRATE:    DS    2        ; Baud rate:
  551.                 ; 0 = 110 baud    1 = 300 baud    2 = 450 baud
  552.                 ; 3 = 600 baud    4 = 710 baud    5 = 1200 baud
  553.                 ; 6 = 2400 baud 7 = 4800 baud    8 = 9600 baud
  554.                 ; 9 = 19200 baud
  555. PARITY:    DS    2        ; Parity (will be 'N', 'E' or 'O')
  556. DATA:    DS    2        ; Data bits (will be 7 or 8)
  557. STOP:    DS    2        ; Stop bits (will be 1 or 2)
  558. ;
  559. ; Set the port. ZMP supplies either 0 or 1 as a parameter.
  560. ;
  561. setport:
  562.     ld    hl,2        ; get port number
  563.     add    hl,sp
  564.     ex    de,hl
  565.     call    getparm        ; in HL (values are 0 and 1)
  566.  
  567.                 ; <== Insert your own code here
  568.  
  569.                 ; <== End of your own code
  570.     ret
  571. ;
  572. ;-----------------------------------------------------------------------
  573. ;
  574. ; Video terminal sequences: these are for VT-100 -- Modify as you
  575. ; wish
  576. ;
  577. ;Cursor addressing:
  578. ;
  579. CURSADD:    LD    HL,2        ; Get parameters
  580.     ADD    HL,SP
  581.     EX    DE,HL
  582.     CALL    GETPARM        ; In HL
  583.         INC     HL
  584.     LD    (ROW),HL    ; Row
  585.     CALL    GETPARM
  586.         INC     HL
  587.     LD    (COL),HL    ; Column
  588. ;
  589. ; <== Insert your own code here, Using values in row and col
  590. ;
  591.     CALL    PRINT
  592.     DB    ESC,'[',0    ; Cursor leadin
  593.     LD    HL,(ROW)    ; Row first
  594.     CALL    NOUT        ; output in decimal
  595.     LD    A,';'        ; follow with semicolon
  596.     CALL    COUT        ; print it
  597.     LD    HL,(COL)    ; Same for column
  598.     CALL    NOUT
  599.     LD    A,'H'        ; terminate with 'move cursor' command
  600.     CALL    COUT        ; print it
  601. ;
  602. ; <== end of your own code
  603. ;
  604.     RET
  605. ;
  606. ROW:    DS    2        ; Row
  607. COL:    DS    2        ; Column
  608. ;
  609. ; Clear screen:
  610. ;
  611. CLS:
  612.     CALL    PRINT
  613.     DB    ESC,'[2J'    ;clear whole screen
  614.     DB    ESC,'[H',0    ;HOME
  615.     RET
  616. ;
  617. ; Highlight on:
  618. ;
  619. INVON:
  620.     CALL    PRINT
  621.     DB    ESC,'[0;1m',0
  622.     RET
  623. ;
  624. ; Highlight off:
  625. ;
  626. INVOFF:
  627.     CALL    PRINT
  628.     DB    ESC,'[0m',0
  629.     RET
  630. ;
  631. ; Turn off cursor:
  632. ;
  633. HIDE:
  634.     RET
  635. ;
  636. ; Turn on cursor:
  637. ;
  638. SHOW:
  639.     RET
  640. ;
  641. ; Save cursor position:
  642. ;
  643. SAVECU:
  644.     CALL    PRINT
  645.     DB    ESC,'7',0
  646.     RET
  647. ;
  648. ; Restore cursor position:
  649. ;
  650. RESCU:
  651.     CALL    PRINT
  652.     DB    ESC,'8',0
  653.     RET
  654. ;
  655. ;-----------------------------------------------------------------------
  656. ;
  657. ; Service modem interrupt:
  658. ;
  659. MINT:    RET            ; My system doesn't need this
  660. ;
  661. ; Initialise interrupt vectors:
  662. ;
  663. INVEC:    RET            ; Ditto
  664. ;
  665. ; De-initialise interrupt vectors:
  666. ;
  667. DINVEC:    RET            ; Ditto
  668. ;
  669. ;------------------- End of user-defined code --------------------------
  670. ;         Do not change anything below here
  671. ;
  672. ; Modem character test for 100 ms
  673. ;
  674. MRD:    PUSH    BC        ; Save BC
  675.     LD    BC,100        ; Set limit
  676. ;
  677. MRD1:    CALL    MIRDY        ; Char at modem?
  678.     JR    NZ,MRD2        ; Yes, exit
  679.     LD    HL,1        ; Else wait 1ms
  680.     CALL    WAITHLMS
  681.     DEC    BC        ; Loop till done
  682.     LD    A,B
  683.     OR    C
  684.     JR    NZ,MRD1
  685.     LD    HL,0        ; None there, result=0
  686.     XOR    A
  687. ;
  688. MRD2:    POP    BC
  689.       RET
  690. ;
  691. ;    This routine prints the number in HL on the screen in decimal.
  692. ;    Uses all ACs.
  693.  
  694. NOUT:    LD    BC,-10        ; Get some useful constants.
  695. NOUT1:    LD    DE,-1
  696.  
  697. NOUT2:    ADD    HL,BC        ; Subtract as many 10s as possible.
  698.     INC    DE        ; Count them.
  699.     JP    C,NOUT2        ; If some left keep going.
  700.     PUSH    HL        ; Save remainder - 10
  701.     EX    DE,HL        ; Swap the remainder and the quotient.
  702.     LD    A,H        ; Get the number of 10s found.
  703.     OR    L        ; Check for quotient non zero
  704.     CALL    NZ,NOUT1    ; If non zero, recurse.
  705.     POP    HL        ; Get the remainder - 10
  706.     LD    A,L        ; In a
  707.     ADD    A,'0'+10    ; Make the number printable and add the 10 back
  708.     JP    COUT        ; output the digit and return
  709. ;
  710. ; Inline print routine: destroys A and HL
  711. ;
  712. PRINT:    EX    (SP),HL        ; Get address of string
  713. ;
  714. PLOOP:    LD    A,(HL)        ; Get next
  715.     INC    HL        ; Bump pointer
  716.     OR    A        ; Done if zero
  717.     JR    Z,PDONE
  718.     CALL    COUT        ; Else print
  719.     JR    PLOOP        ; And loop
  720. ;
  721. PDONE:    EX    (SP),HL        ; Restore return address
  722.     RET            ; And quit
  723. ;
  724. ; Output a character in A to the console
  725. ;
  726. COUT:    PUSH    BC        ; Save registers
  727.     PUSH    DE
  728.     PUSH    HL
  729.     LD    E,A        ; Character to E
  730.     LD    C,2
  731.     CALL    BDOS        ; Print it
  732.     POP    HL
  733.     POP    DE
  734.     POP    BC
  735.     RET
  736. ;
  737. ; Wait(seconds)
  738. ;
  739. WAIT:    LD    HL,2
  740.     ADD    HL,SP
  741.     EX    DE,HL        ; Get delay size
  742.     CALL    GETPARM
  743. ;                ; Fall thru to...
  744. ; Wait seconds in HL
  745. ;
  746. WAITHLS:PUSH    BC        ; Save BC
  747.     PUSH    DE        ; DE
  748.     PUSH    IX        ; And IX
  749.     LD    IX,0        ; Then point IX to 0
  750. ;                ;   so we don't upset memory-mapped I/O
  751. ;
  752. ; Calculate values for loop constants. Need to have two loops to avoid
  753. ; 16-bit overflow with clock speeds above 9 MHz.
  754. ;
  755. OUTERVAL EQU    (CLKSPD/10)+1
  756. ;
  757. INNERVAL EQU    (6667/OUTERVAL)*CLKSPD
  758. ;
  759. WAIT10:    LD    B,OUTERVAL
  760. ;
  761. WAIT11:    LD    DE,INNERVAL
  762. ;
  763. WAIT12:    BIT    0,(IX)        ; Time-wasters
  764.     BIT    0,(IX)
  765.     BIT    0,(IX)        ; 20 T-states each
  766.     BIT    0,(IX)
  767.     BIT    0,(IX)
  768.     BIT    0,(IX)
  769.     DEC    DE
  770.     LD    A,E
  771.     LD    A,D
  772.     OR    E
  773.     JR    NZ,WAIT12    ; 150 T-states per inner loop
  774.     DJNZ    WAIT11        ; Decrement outer loop
  775.     DEC    HL        ; Ok, decrement count in HL
  776.     LD    A,H
  777.     OR    L
  778.     JR    NZ,WAIT10
  779.     POP    IX        ; Done -- restore IX
  780.     POP    DE        ; DE
  781.     POP    BC        ; And BC
  782.     RET
  783. ;
  784. ; Wait milliseconds
  785. ;
  786. MSWAIT:    LD    HL,2
  787.     ADD    HL,SP
  788.     EX    DE,HL        ; Get delay size
  789.     CALL    GETPARM
  790. ;
  791. ; Wait milliseconds in HL
  792. ;
  793. WAITHLMS:
  794.     PUSH    DE
  795. ;
  796. W1MS0:    LD    DE,39 *    CLKSPD
  797. ;
  798. W1MS1:    DEC    DE
  799.     LD    A,D
  800.     OR    E
  801.     JR    NZ,W1MS1
  802.     DEC    HL
  803.     LD    A,H
  804.     OR    L
  805.     JR    NZ,W1MS0
  806.     POP    DE
  807.     RET
  808. ;
  809. ; Get next parameter from (DE) into HL
  810. ;
  811. GETPARM:EX    DE,HL        ; Get address into HL
  812.     LD    E,(HL)        ; Get low
  813.     INC    HL
  814.     LD    D,(HL)        ; Then hihi
  815.     INC    HL        ; Bump for next
  816.     EX    DE,HL        ; Result in HL, address still in DE
  817.     RET
  818. ;
  819.  
  820. ;Get address of user-defined variables
  821.  
  822. GETVARS:
  823.     LD    HL,USERVARS
  824.     RET
  825.  
  826. USERVARS:
  827.     DW    OVERDRIVE    ; .OVR etc. drive/user
  828.     DW    OVERUSER
  829.  
  830.  
  831.      IF    ($-CODEBGN) GT OVSIZE    ;
  832. TOOBIG:    JP    ERRVAL        ; Overlay is too large
  833.      ENDIF
  834. ;
  835.     END
  836.