home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / pcx / teglpcx / pcxega.asm < prev    next >
Encoding:
Assembly Source File  |  1991-10-21  |  5.2 KB  |  306 lines

  1.  
  2.         include grphdrvr.inc
  3.  
  4. ;******************************************************************************}
  5. ;                TEGL Windows ToolKit II                   }
  6. ;           Copyright (C) 1991, TEGL Systems Corporation            }
  7. ;                 All Rights Reserved.                   }
  8. ;******************************************************************************}
  9.  
  10.         .data
  11.  
  12.         extrn    ActiveTEGLMode        : dword
  13.  
  14.         .code
  15.  
  16. pcxheader  struc
  17.         manufacturer    db     ?
  18.         version     db     ?
  19.         encoding    db     ?
  20.         bitsperpixel    db     ?
  21.         xmin        dw     ?
  22.         ymin        dw     ?
  23.         xmax        dw     ?
  24.         ymax        dw     ?
  25.         HDPI        dw     ?
  26.         VDPI        dw     ?
  27.         colormap    db  48 dup(?)
  28.         reserved    db     ?
  29.         NPlanes     db     ?
  30.         pcxbpl        dw     ?
  31.         paletteinfo    dw     ?
  32.         HscreenSize    dw     ?
  33.         VscreenSize    dw     ?
  34.         filler        db  54 dup(?)
  35. pcxheader  ends
  36.  
  37.  
  38. egapcx4plane    PROC    far pcxbuff:dword,baseoffset:word,maxlines:word,maxwidth:word
  39.         public    egapcx4plane
  40.         local    pcxbpline:word,vertlines:word,bpline:word
  41.  
  42.         push    ds
  43.         push    si
  44.         push    es
  45.         push    di
  46.  
  47.         mov    dx,3ceh     ; dx := graphics controller i/o port
  48.  
  49.         mov    ax,3        ; ah := value for data rotate/function
  50.         out    dx,ax
  51.  
  52.         mov    ax,0805h    ; ah := 8 (read mode 1, write mode 0)
  53.         out    dx,ax        ; al := 5 (mode register)
  54.  
  55.         mov    ax,0007     ; ah := 0 (don't care for all maps;
  56.         out    dx,ax        ;   cpu reads always return 0ffh)
  57.                     ; al := 7 (color don't care reg number)
  58.  
  59.         mov    ax,0ff08h    ; ah := 0ffh (value for bit mask reg)
  60.         out    dx,ax        ; set up bit mask reg
  61.  
  62.         mov    dl,0c4h     ; dx := 3c4h (sequence i/o port)
  63.  
  64.  
  65.         mov    ax,@data
  66.         mov    es,ax
  67.         les    di,es:ActiveTEGLmode
  68.         mov    ax,es:[di].vbytesperline
  69.         mov    bpline,ax
  70.  
  71.  
  72.         lds    si,pcxbuff    ; get pcx buffer
  73.         mov    ax,baseoffset
  74.         shr    ax,1
  75.         shr    ax,1
  76.         shr    ax,1
  77.         shr    ax,1
  78.         add    ax,0a000h    ; hard wired for EGA
  79.         mov    es,ax
  80.         xor    di,di
  81.  
  82.         mov    ax,ds:[si].ymax
  83.         sub    ax,ds:[si].ymin
  84.         inc    ax
  85.         mov    vertlines,ax
  86.  
  87.         mov    ax,ds:[si].pcxbpl
  88.         mov    pcxbpline,ax
  89.  
  90.         mov    ax,maxwidth
  91.         shr    ax,1
  92.         shr    ax,1
  93.         shr    ax,1
  94.         mov    maxwidth,ax
  95.  
  96.         add    si,128
  97.         xor    cx,cx
  98.  
  99.         cld
  100. egapcx4_00:    mov    ax,0102h    ; ah := 1000b (value for map mask reg)
  101. egapcx4_01:    push    ax
  102.         push    di
  103.         xor    bx,bx        ; bytes on line
  104.         out    dx,ax
  105.  
  106. egapcx4_02:    lodsb            ; get 1 byte
  107.         mov    ah,al
  108.         and    ah,0c0h
  109.         cmp    ah,0c0h
  110.         je    egapcx4_03
  111.  
  112.         cmp    bx,maxwidth
  113.         jge    egapcx4_02a
  114.         stosb
  115. egapcx4_02a:    inc    bx
  116.         cmp    bx,pcxbpline
  117.         jl    egapcx4_02
  118.         jmp    short egapcx4_04
  119.  
  120.         ; count byte
  121. egapcx4_03:    and    al,03fh
  122.         mov    cl,al
  123.         lodsb            ; get data byte
  124.  
  125. egapcx4_03b:    cmp    bx,maxwidth
  126.         jge    egapcx4_03a
  127.         stosb
  128. egapcx4_03a:    inc    bx
  129.         loop    egapcx4_03b
  130.         cmp    bx,pcxbpline
  131.         jl    egapcx4_02
  132.  
  133. egapcx4_04:    pop    di
  134.         pop    ax
  135.  
  136.         shl    ah,1
  137.         test    ah,10h
  138.         jz    egapcx4_01
  139.  
  140. egapcx4_05:    add    di,bpline
  141.         normalize es,di,bx
  142.         normalize ds,si,bx
  143.  
  144.         dec    maxlines
  145.         jz    egapcx4_06
  146.  
  147.         dec    vertlines
  148.         jnz    egapcx4_00
  149.  
  150. egapcx4_06:    mov    ax,0f02h
  151.         out    dx,ax
  152.  
  153.         mov    dl,0ceh
  154.         mov    ax,003
  155.         out    dx,ax
  156.  
  157.         mov    ax,0005
  158.         out    dx,ax
  159.  
  160.         mov    ax,0f07h
  161.         out    dx,ax
  162.  
  163.         mov    ax,0ff08h
  164.         out    dx,ax
  165.  
  166.         pop    di
  167.         pop    es
  168.         pop    si
  169.         pop    ds
  170.  
  171.         ret
  172. egapcx4plane    ENDP
  173.  
  174.  
  175. egapcx1plane    PROC    far pcxbuff:dword,baseoffset:word,maxlines:word,maxwidth:word
  176.         public    egapcx1plane
  177.         local    pcxbpline:word,vertlines:word,bpline:word
  178.  
  179.         push    ds
  180.         push    si
  181.         push    es
  182.         push    di
  183.  
  184.         mov    dx,3ceh     ; dx := graphics controller i/o port
  185.  
  186.         mov    ax,0a05h    ; al :=  mode register number
  187.                     ; ah :=  write mode 2 (bits 0-1)
  188.                     ;     read mode 1 (bit 4)
  189.         out    dx,ax
  190.  
  191.  
  192.         mov    ax,3        ; ah := value for data rotate/function
  193.         out    dx,ax
  194.  
  195.         mov    ax,0007     ; ah := 0 (don't care for all maps;
  196.         out    dx,ax        ;   cpu reads always return 0ffh)
  197.                     ; al := 7 (color don't care reg number)
  198.  
  199. ;        mov    ax,0ff08h    ; ah := 0ffh (value for bit mask reg)
  200. ;        out    dx,ax        ; set up bit mask reg
  201.  
  202.         mov    ax,@data
  203.         mov    es,ax
  204.         les    di,es:ActiveTEGLmode
  205.         mov    ax,es:[di].vbytesperline
  206.         mov    bpline,ax
  207.  
  208.  
  209.         lds    si,pcxbuff    ; get pcx buffer
  210.         mov    ax,0a000h
  211.         mov    es,ax
  212.         mov    di,baseoffset
  213.  
  214.         mov    ax,ds:[si].ymax
  215.         sub    ax,ds:[si].ymin
  216.         inc    ax
  217.         mov    vertlines,ax
  218.  
  219.         mov    ax,ds:[si].pcxbpl
  220.         mov    pcxbpline,ax
  221.  
  222.         mov    ax,maxwidth
  223.         shr    ax,1
  224.         shr    ax,1
  225.         shr    ax,1
  226.         mov    maxwidth,ax
  227.  
  228.         add    si,128
  229.         xor    cx,cx
  230.  
  231.         cld
  232. egapcx1_00:    xor    bx,bx
  233.         push    di
  234.  
  235. egapcx1_01:    lodsb            ; get 1 byte
  236.         mov    ah,al
  237.         and    ah,0c0h
  238.         cmp    ah,0c0h
  239.         je    egapcx1_04
  240.  
  241.         cmp    bx,maxwidth
  242.         jge    egapcx1_01a
  243.  
  244.         mov    ah,al
  245.         mov    al,8
  246.         out    dx,ax
  247.         and    byte ptr es:[di],15
  248.         inc    di
  249.  
  250. egapcx1_01a:    inc    bx
  251.         cmp    bx,pcxbpline
  252.         jl    egapcx1_01
  253.         jmp    short egapcx1_02
  254.  
  255.         ; count byte
  256. egapcx1_04:    and    al,03fh
  257.         mov    cl,al
  258.         lodsb            ; get data byte
  259.  
  260.         mov    ah,al
  261.         mov    al,8
  262.         out    dx,ax
  263. egapcx1_03:    cmp    bx,maxwidth
  264.         jge    egapcx1_03a
  265.  
  266.         and    byte ptr es:[di],15
  267.         inc    di
  268.  
  269. egapcx1_03a:    inc    bx
  270.         loop    egapcx1_03
  271.  
  272.         cmp    bx,pcxbpline
  273.         jl    egapcx1_01
  274.  
  275. egapcx1_02:    pop    di
  276.  
  277. egapcx1_05:    add    di,bpline
  278. ;        normalize es,di,bx
  279.  
  280.         dec    maxlines
  281.         jz    egapcx1_06
  282.  
  283.         dec    vertlines
  284.         jnz    egapcx1_00
  285.  
  286. egapcx1_06:    mov    ax,0ff08h    ; default bit mask
  287.         out    dx,ax
  288.  
  289.         mov    ax,0005     ; default mode register
  290.         out    dx,ax
  291.  
  292.         mov    ax,0003     ; default data rotate/function select
  293.         out    dx,ax
  294.  
  295.         mov    ax,0f07h    ; default color don't care
  296.         out    dx,ax
  297.  
  298.         pop    di
  299.         pop    es
  300.         pop    si
  301.         pop    ds
  302.  
  303.         ret
  304. egapcx1plane    ENDP
  305.         end
  306.