home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / ASM / ASMLIB40.ZIP / ASM4DEMO.ZIP / GPTEST.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-10-06  |  3.5 KB  |  236 lines

  1. include    asm.inc
  2.  
  3. altf    equ    0121h
  4. altb    equ    0130h
  5.  
  6. extrn    gcenter:proc, gcenterx:proc
  7. extrn    gprintup:proc, gprintdown:proc
  8. extrn    gprintupx:proc, gprintdown:proc
  9. extrn    hgraph:proc, gprint:proc
  10. extrn    fillbox:proc, htext:proc
  11. extrn    fillpattern:proc, getkey:proc
  12. extrn    gcolor:proc, resetview:proc, gclear:proc
  13. extrn    toupper:proc
  14. extrn    graphmode:proc, textmode:proc
  15.  
  16. .data
  17. extrn    drawmode:byte
  18. x    dw 0,0,719,347
  19.  
  20. gc    db 'GCenter',0
  21. gcx    db 'GCenterX',0
  22. gpu    db 'GPrintUP',0
  23. gpux    db 'GPrintUPX',0
  24. gpd    db 'GPrintDOWN',0
  25.  
  26. p0    db ' Drawmode 0; XOR foreground with screen ',0
  27. p1    db ' Drawmode 1; print character with background ',0
  28. p2    db ' Drawmode 2; print character without background ',0
  29. n1    db ' Drawmode -1; print character with background, reverse video ',0
  30. n2    db ' Drawmode -2; print character without background, reverse video ',0
  31. bottom    dw 2 dup (0)
  32.  
  33. aligned    db 'test alignment',0
  34. pattern    db 4 dup (10101010b,01010101b)
  35.     db 0
  36. prnmode        db 1
  37. prncolor    db 7,0
  38. cflag        db 1
  39.  
  40. .code
  41. public    gptest
  42. gptest    proc
  43.     pushf
  44.     push    bp
  45.     push    ax
  46.     push    bx
  47.     push    cx
  48.     push    dx
  49.     push    di
  50.     push    si
  51.     push    ds
  52.     push    es
  53.     call    graphmode
  54.     call    resetview
  55.     mov    ax,es:6[bx]
  56.     sub    ax,14
  57.     mov    bottom+2,ax
  58.     mov    ax,es:4[bx]
  59.     mov    x+4,ax
  60.     mov    prnmode,1
  61.     mov    cflag,0
  62. again:
  63.     call    gclear
  64.     mov    ax,1
  65.     call    gcolor
  66.     mov    drawmode,1
  67.     lea    bx,pattern
  68.     call    fillpattern
  69.     call    resetview
  70.     mov    ax,es:4[bx]
  71.     inc    ax
  72.     shr    ax,1
  73.     mov    x,ax
  74.     lea    bx,x
  75.     call    fillbox
  76.  
  77.     mov    ax,word ptr prncolor
  78.     call    gcolor
  79.  
  80.     call    print_center
  81.     call    print_sides
  82.     call    print_updown
  83.  
  84.     mov    x,0
  85.     mov    x+2,0
  86.  
  87. read_next_key:
  88.     call    getkey
  89.     cmp    ax,altf
  90.     jne    r0
  91.     mov    cflag,0        ; falls into altb test, which fails
  92.                 ; test for extended character bumps it
  93.                 ; back to read_next_key
  94. r0:    cmp    ax,altb
  95.     jne    r1
  96.     mov    cflag,1
  97. r1:    shr    ah,1
  98.     jc    read_next_key
  99.     cmp    al,'+'
  100.     je    plus
  101.     cmp    al,'-'
  102.     je    minus
  103.     cmp    ax,27
  104.     je    exit
  105.     cmp    al,'0'
  106.     jb    read_next_key
  107.     cmp    al,'9'
  108.     jbe    new_color
  109.     call    toupper
  110.     cmp    al,'A'
  111.     jb    read_next_key
  112.     cmp    al,'F'
  113.     ja    read_next_key
  114.     sub    al,'A'-58
  115.  
  116. new_color:
  117.     sub    al,'0'
  118.     cmp    cflag,1
  119.     je    new_back
  120.     mov    prncolor,al
  121.     jmp    again
  122. new_back:
  123.     mov    prncolor+1,al
  124.     jmp    again
  125.  
  126. plus:    inc    prnmode
  127.     cmp    prnmode,2
  128.     jg    fix1
  129.     jmp    again
  130. fix1:    mov    prnmode,2
  131.     jmp    read_next_key
  132.  
  133. minus:    dec    prnmode
  134.     cmp    prnmode,-2
  135.     jl    fix2
  136.     jmp    again
  137. fix2:    mov    prnmode,-2
  138.     jmp    read_next_key
  139. exit:    call    textmode
  140.     pop    es
  141.     pop    ds
  142.     pop    si
  143.     pop    di
  144.     pop    dx
  145.     pop    cx
  146.     pop    bx
  147.     pop    ax
  148.     pop    bp
  149.     popf
  150.     ret
  151. gptest    endp
  152.  
  153. print_center    proc near
  154.     mov    al,drawmode
  155.     mov    drawmode,1
  156.     mov    ah,prnmode
  157.     lea    dx,bottom
  158.     lea    si,p0
  159.     or    ah,ah
  160.     jz    pc
  161.     jg    pc0
  162.     lea    si,n1
  163.     inc    ah
  164.     jz    pc
  165.     lea    si,n2
  166.     jmp    short pc
  167. pc0:    lea    si,p1
  168.     dec    ah
  169.     jz    pc
  170.     lea    si,p2
  171. pc:    call    gcenter
  172.     mov    drawmode,al
  173.     mov    al,prnmode
  174.     mov    drawmode,al
  175.     mov    dx,bx
  176.     lea    si,gc
  177.     call    gcenter
  178.     add    word ptr [bx+2],15
  179.     lea    si,gcx
  180.     call    gcenterx
  181.     ret
  182. print_center    endp
  183.  
  184. print_sides    proc near
  185.     mov    x,0
  186.     mov    x+2,32
  187.     lea    dx,x
  188.     lea    si,aligned
  189.     mov    cx,10
  190. ps1:    mov    ax,cx
  191.     call    gprint
  192.     mov    cx,ax
  193.     inc    x
  194.     add    x+2,15
  195.     loop    ps1
  196.  
  197.     mov    x+2,32
  198.     mov    ax,x+4
  199.     shr    ax,1
  200.     add    ax,2
  201.     mov    x,ax
  202.  
  203.     mov    cx,10
  204. ps2:    mov    ax,cx
  205.     call    gprint
  206.     mov    cx,ax
  207.     inc    x
  208.     add    x+2,15
  209.     loop    ps2
  210.  
  211.     ret
  212. print_sides    endp
  213.  
  214. print_updown    proc near
  215.     lea    di,gpux
  216.     mov    ax,bottom+2
  217.     shr    ax,1
  218.     mov    x+2,ax
  219.     mov    ax,x
  220.     shr    ax,1
  221.     add    x,ax
  222.     lea    si,gpu
  223.     call    gprintup
  224.     add    x,9
  225.     xchg    si,di
  226.     call    gprintupx
  227.     shl    ax,1
  228.     sub    x,ax
  229.     call    gprintupx
  230.     sub    x,9
  231.     xchg    si,di
  232.     call    gprintup
  233.     ret
  234. print_updown    endp
  235.     end
  236.