home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / TATT.AZM / TATT.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  7.0 KB  |  328 lines

  1. ;----------------------------------------------------------------
  2. ; This is a test program which uses all the attributes and all
  3. ; the functions available in the ASMLIB library. This allows the
  4. ; user to quickly try out a terminal definition fully before 
  5. ; integrating it into the rest of his programs.
  6. ;
  7. ; This program will
  8. ; Erase screen, display terminal id and a menu to...
  9. ; 1) Test cursor positioning and enable / disable
  10. ; 2) Test all the video attributes
  11. ; 3) Test erase to end of line and erase to end of screen screen
  12. ; 4) Offer to do any or all tests again.
  13. ;
  14. ;            Written      R.C.H.        30/11/83
  15. ;            Last Update  R.C.H.        04/01/84
  16. ;----------------------------------------------------------------
  17. ;
  18. ;
  19.     extrn    prolog,coe,dispatch,inline,quit,setatt,tname,cst
  20.     extrn    clear,crlf,cie,caps,bell,cleol,cleop,pcount,idhl
  21.     extrn    pstr,setxy,delay,xyinline,pmenu,cursor,curon,curoff
  22. ;
  23. left    equ    01            ; Used by cursor positioning
  24. up    equ    02            ; for direction sensing
  25. right    equ    03
  26. down    equ    04
  27. ;
  28.     maclib    z80
  29. ;
  30.     call    prolog
  31. start:
  32.     call    clear
  33.     call    xyinline        ; position the cursor
  34.     db    21,04,'Terminal Test Program$'
  35.     call    xyinline
  36.     db    18,05,'Current terminal is $'
  37. ;
  38.     call    tname
  39.     xchg
  40.     mvi    b,6
  41.     call    pcount
  42.     lxi    d,menu
  43.     call    pmenu
  44. ;
  45. start1:
  46.     call    cie
  47.     call    caps
  48.     cpi    03            ; control c exit now
  49.     jz    quit            ; abort, quick
  50.     cpi    '1'
  51.     jz    test$att        ; test video attributes
  52.     cpi    '2'
  53.     jz    test$cursor
  54.     cpi    '3'
  55.     jz    test$erase
  56.     cpi    '4'
  57.     jz    logon
  58.     cpi    'Q'
  59.     jz    exit
  60.     jmp    start
  61. ;
  62. exit:
  63.     mvi    a,0f8h
  64.     call    coe
  65.     jmp    quit
  66. ;
  67. logon:
  68.     call    inline
  69.     db    0dh,0ah,0ah,'What Channel ? $'
  70.     call    idhl
  71.     mov    a,l            ; get low byte
  72.     ori    0f8h            ; mask in selector byte offset
  73.     call    coe            ; Log onto an MPC-6 channel
  74.     jmp    start            ; Display menu etc
  75. ;
  76. finish:
  77.     call    xyinline
  78.     db    0,23,'Press a key to continue :$'
  79.     call    cie
  80.     cpi    03
  81.     jz    quit            ; control c to exit now
  82.     jmp    start
  83. ;
  84. ;----------------------------------------------------------------
  85. ; Test a terminals video attributes by positioning the cursor
  86. ; against the left hand edge and printing string in reverse
  87. ; video. If the attribute gobbles a screen position then the string
  88. ; will be positioned one space away from the right hand edge.
  89. ;----------------------------------------------------------------
  90. ;
  91. test$att:
  92.     call    clear            ; erase the screen
  93.     lxi    d,02            ; x = 0, y = line 2
  94.     call    cursor            ; position it
  95. ; half intensity
  96.     mvi    a,1
  97.     call    setatt
  98.     call    inline
  99.     db    'This is printed in 1/2 intensity$'
  100.     xra    a
  101.     call    setatt
  102. ; Blinking characters
  103.     lxi    d,05            ; x = 0 y = 5
  104.     call    cursor            ; position the cursor
  105.     mvi    a,2
  106.     call    setatt
  107.     call    inline
  108.     db    'This is printed as blinking characters$'
  109.     xra    a
  110.     call    setatt
  111. ; Reverse video
  112.     lxi    d,7            ; x = 0 y = 7
  113.     call    cursor
  114.     mvi    a,3
  115.     call    setatt
  116.     call    inline
  117.     db    'This is printed as reverse characters$'
  118.     xra    a
  119.     call    setatt
  120. ; Underlined code
  121.     lxi    d,9
  122.     call    cursor
  123.     mvi    a,4
  124.     call    setatt
  125.     call    inline
  126.     db    'This is printed as underlined characters$'
  127.     xra    a
  128.     call    setatt
  129.     jmp    finish            ; return to the program start again
  130. ;
  131. ;----------------------------------------------------------------
  132. ; The following tests the screen clear functions, clear to end 
  133. ; of line and clear to end of page.
  134. ;----------------------------------------------------------------
  135. ;
  136. test$erase:
  137.     call    clear            ; erase the screen
  138.     mvi    b,23            ; do all lines
  139. ;
  140. ; Fill the screen by sending 24 full lines of 'X' characters
  141. ;
  142. fill1:
  143.     push    b
  144.     mvi    b,79
  145. fill2:
  146.     mvi    a,'X'
  147.     call    coe
  148.     call    xonof
  149.     djnz    fill2
  150. ;
  151.     call    crlf
  152.     call    xonof
  153.     pop    b
  154.     djnz    fill1
  155. ;
  156.     call    xyinline
  157.     db    5,3,'Erase to end of line$'
  158.     call    cleol
  159.     lxi    d,1000
  160.     call    delay
  161. ;
  162.     call    xyinline
  163.     db    5,7,'Erase to end of page$'
  164.     call    cleop
  165.     lxi    d,1000
  166.     call    delay            ; wait a second
  167.  
  168.     jmp    finish
  169. ;
  170. ;----------------------------------------------------------------
  171. ; This section tests the cursor positioning by displaying a pattern
  172. ; on the screen. This is all done with cursor positioning and 
  173. ; looks just ok. If the cursor positioning is a bit off then there
  174. ; is a horrible mess on the screen.
  175. ;----------------------------------------------------------------
  176. ;
  177. test$cursor:
  178.     call    clear
  179.     call    curoff                ; disable the cursor
  180.     lxi    d,02800h            ; x = 40, y = 0
  181.     mvi    b,23                ; do all lines
  182. tc1:
  183.     call    cursor                ; set up
  184.     inr    e                ; go down the screen
  185.     mvi    a,'|'
  186.     call    coe                ; display
  187.     call    xonof            ; do a little handshaking
  188.     djnz    tc1
  189. ;
  190.     lxi    d,12                ; x = 0, y = 12
  191.     mvi    b,79                ; do all columns
  192. ;
  193. tc2:
  194.     call    cursor
  195.     inr    d                ; go right across the screen
  196.     mvi    a,'-'
  197.     call    coe
  198.     call    xonof            ; do a little handshaking
  199.     djnz    tc2
  200. ;
  201. ; Put an X in the middle now
  202.     lxi    d,280Ch                ; x = 40, y = 12
  203.     call    cursor
  204.     mvi    a,'+'
  205.     call    coe
  206.     call    xonof            ; do a little handshaking
  207. ; now do a spiral around the center of the screen
  208. ; DE -> center of the ecreen still at this point
  209. ; Use A as the spiral side length
  210. ; Use B as the counter of spiral sides. 24 = a full page
  211. ; Use C as the spiral direction (l,r,u,d) 
  212. ;    
  213.     mvi    c,1            ; side size
  214.     mvi    b,23            ; do a whole page
  215.     mvi    a,left            ; direction to draw
  216. ;
  217. spiral$loop:
  218.     call    draw$side        ; draw a side
  219.     inr    a            ; next direction
  220.     inr    c            ; increment side size counter
  221.     cpi    5            ; no more sides ??
  222.     jrnz    spiral$loop1
  223.     mvi    a,left            ; at the start again
  224. spiral$loop1:
  225.     djnz    spiral$loop
  226.     jmp    finish            ; all done
  227. ;
  228. ;---- Draw a side of the spiral according to direction and length
  229. ;
  230. draw$side:
  231.     push    psw
  232.     push    b
  233.     mov    b,c            ; load the side size counter
  234. ; Decide which way we are going
  235.     cpi    left            
  236.     jrz    go$left
  237.     cpi    right
  238.     jrz    go$right
  239.     cpi    up
  240.     jrz    go$up
  241.     jr    go$down
  242. ;
  243. ; Go up the screen. Decrement the Y screen address (E) only
  244. go$up:
  245. ;
  246. go$up1:
  247.     dcr    e
  248.     call    cursor            ; go up by bumping the y address
  249.     mvi    a,'I'
  250.     call    coe
  251.     call    xonof            ; do a little handshaking
  252.     djnz    go$up1
  253.     jr    draw$side$end
  254. ;
  255. ; Go left by decrementing the X direction
  256. go$left:
  257.     mov    a,b
  258.     add    a
  259.     mov    b,a            ; double it
  260. go$left1:
  261.     dcr    d
  262.     call    cursor
  263.     mvi    a,'='
  264.     call    coe
  265.     call    xonof            ; do a little handshaking
  266.     djnz    go$left1
  267.     jr    draw$side$end
  268. ;
  269. ; go right across the screen by incrementing the x value
  270. go$right:
  271.     mov    a,b
  272.     add    a
  273.     mov    b,a
  274. go$right1:
  275.     inr    d
  276.     call    cursor
  277.     mvi    a,'='
  278.     call    coe
  279.     djnz    go$right1
  280.     jr    draw$side$end
  281. ;
  282. ; Go down the screen by incrementing the y address
  283. go$down:
  284. ;
  285. go$down1:
  286.     inr    e
  287.     call    cursor
  288.     mvi    a,'I'
  289.     call    coe
  290.     call    xonof            ; do a little handshaking
  291.     djnz    go$down1
  292. ;
  293. ; Restore registers and return to master loop
  294. draw$side$end:
  295.     pop    b
  296.     pop    psw
  297.     ret
  298. ;
  299. ;----====````====----
  300. ;
  301. xonof:
  302.     call    cst
  303.     rz
  304.     call    cie
  305.     cpi    19             ; Control s ??
  306.     rnz
  307. ;
  308. xwait:
  309.     call    cie
  310.     cpi    17            ; Control Q ??
  311.     rz
  312.     call    bell
  313.     jr    xwait
  314. ;
  315. ;----------------------------------------------------------------
  316. ;
  317. menu:
  318.     db    22,08,'Test Options are$'
  319.     db    17,10,'1) Test Video Attributes$'
  320.     db    17,11,'2) Test Cursor positioning$'
  321.     db    17,12,'3) Test screen erase functions$'
  322.     db    17,13,'4) Log Onto an MPC-6 channel$'
  323.     db    17,14,'Q) Quit to CP/M$'
  324.     db    12,16,'--->?$'
  325.     db    0ffh
  326. ;
  327.     end
  328.