home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / mcgatpu / screen.asm < prev    next >
Encoding:
Assembly Source File  |  1991-04-05  |  3.6 KB  |  112 lines

  1. ;
  2. ; Name :                 ScreenOrigin
  3. ;
  4. ; Function:              Set screen origin on EGA an VGA
  5. ;
  6. ; Caller:                TURBO PASCAL
  7. ;
  8. ;
  9. ;                        void ScreenOrigin(x,y);
  10. ;                              int x,y  /*pixel x,y coordinates*/
  11. ;
  12.                         .model tpascal
  13.                         .data
  14. crt_mode                equ    49h
  15. addr_6845               equ    63h
  16. points                  equ    85h
  17. bios_flags              equ    89h
  18. extrn                   bytesperrow:word
  19.                         .code
  20.                        public screenorigin
  21.  
  22. screenorigin    proc   far  argx:word, argy:word
  23.  
  24.                        mov    ax,40h
  25.                        mov    es,ax                ;ES->Video Bios data area
  26.                        mov    cl,es:[crt_mode]
  27.                        mov    ax,argx
  28.                        mov    bx,argy
  29.                        cmp    cl,7
  30.                        ja     l01
  31.                        je     l02
  32.                        test   byte ptr es:[bios_flags],1
  33.                        jnz    l02
  34.                        jmp    short l03
  35.  
  36. ; setup for graphics modes (8 pixels per byte)
  37.  
  38. l01:                   mov     cx,8
  39.                        div     cl
  40.                        mov     cl,ah
  41.                        xor     ah,ah
  42.                        xchg    ax,bx
  43.                        mul     word ptr bytesperrow
  44.                        jmp     short l05
  45.  
  46. ;setup for vga alpha and ega mono alpha mode
  47. ; (9 pixels per byte)
  48.  
  49. l02:                   mov     cx,9
  50.                        div     cl
  51.                        dec     ah
  52.                        jns     l04
  53.                        mov     ah,8
  54.                        jmp     short l04
  55.  
  56. ;setup for ega color alpha modes (8 pixels per byte)
  57.  
  58. l03:                   mov     cx,8
  59.                        div     cl
  60. l04:                   mov     cl,ah
  61.                        xor     ah,ah
  62.                        xchg    ax,bx
  63.                        div     byte ptr es:[points]
  64.                        xchg    ah,ch
  65.                        mul     word ptr bytesperrow
  66.                        shr     ax,1
  67. l05:                   call    setorigin
  68.                        ret
  69. screenorigin           endp
  70.  
  71. setorigin              proc near
  72.                        add     bx,ax
  73.                        mov     dx,es:[addr_6845]
  74.                        add     dl,6
  75.  
  76. ; update Start Address High and Low registers
  77.  
  78. l20:                   in     al,dx
  79.                        test   al,8
  80.                        jz     l20
  81. l21:                   in     al,dx
  82.                        test   al,1
  83.                        jnz    l21
  84.                        cli
  85.                        sub    dl,6
  86.                        mov    ah,bh
  87.                        mov    al,0ch
  88.                        out    dx,ax
  89.                        mov    ah,bl
  90.                        inc    al
  91.                        out    dx,ax
  92.                        sti
  93.                        add    dl,6
  94. l22:                   in     al,dx
  95.                        test   al,8
  96.                        jz     l22
  97.                        cli
  98.                        sub    dl,6
  99.                        mov    ah,ch
  100.                        mov    al,8
  101.                        out    dx,ax
  102.                        mov    dl,0c0h
  103.                        mov    al,13h or 20h
  104.                        out    dx,al
  105.                        mov    al,cl
  106.                        out    dx,al
  107.                        sti
  108.                        ret
  109. setorigin              endp
  110.                        end
  111.  
  112.