; Copyright (c) 1997-2005 Andrzej Okrutny, http://www.ceti.pl/~anok/ ; All rights reserved. ; ; ; THIS SOFTWARE IS FREE FOR NON-COMMERCIAL USE. ; ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. ; ; ;***************************************************************************** ; ; SVGA - High Color, Linear Frame Buffer ; 16 bits per pixel ; ;***************************************************************************** ; ; SetPixelHC ; GetPixelHC ; ; SetPixelHCVW ; GetPixelHCVW ; ; LineHorHC ; LineVerHC ; ; LineHorHCVW ; LineVerHCVW ; ;;LOCALS ;;.386p ;;.MODEL FLAT IDEAL INCLUDE 'graph.inc' DATASEG EXTRN SVGABank: BYTE EXTRN _SetBankPTR: DWORD ; wskaznik do procedury CODESEG ;----------------------------------------------------------------------------; ; SVGA - HC Set Pixel for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; edx - color ; edi - video buff ptr (addr) ; ; modify: eax, ecx, edi ; ; return: NONE ; PUBLIC SetPixelHC_ PROC SetPixelHC_ ; adr = ( y*640 +x )* 2 = y*256 +y*1024 +x*2 shl ecx, 8 add edi, ecx shl ecx, 2 add edi, ecx shl eax, 1 ; x = x * 2 add edi, eax ; add X - coord to dest mov [ edi ], dx ret ENDP SetPixelHC_ ;----------------------------------------------------------------------------; ; SVGA - HC Get Pixel for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; edi - video buff ptr (addr) ; ; modify: eax, ecx, edi ; ; return: ax - color ; PUBLIC GetPixelHC_ PROC GetPixelHC_ ; adr = ( y*640 +x )* 2 = y*256 +y*1024 +x*2 shl ecx, 8 add edi, ecx shl ecx, 2 add edi, ecx shl eax, 1 ; x = x * 2 add edi, eax ; add X - coord to dest mov ax, [ edi ] ret ENDP GetPixelHC_ ;----------------------------------------------------------------------------; ; SVGA - HC Set Pixel - Variable Width ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; edx - color ; ebx - screen width ; edi - video buff ptr (addr) ; ; modify: eax, ebx, ecx, edi ; ; return: NONE ; PUBLIC SetPixelHCVW_ PROC SetPixelHCVW_ ; adr = ( y*scrWidth +x )* 2 = add ebx, ebx ; ebx *= 2 imul ecx, ebx shl eax, 1 ; x = x * 2 add edi, ecx add edi, eax ; add X - coord to dest mov [ edi ], dx ret ENDP SetPixelHCVW_ ;----------------------------------------------------------------------------; ; SVGA - HC Get Pixel - Variable Width ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - screen width ; edi - video buff ptr (addr) ; ; modify: eax, ebx, ecx, edi ; ; return: ax - color ; PUBLIC GetPixelHCVW_ PROC GetPixelHCVW_ ;; adr = ( y*scrWidth +x )* 2 add ebx, ebx ; ebx *= 2 imul ecx, ebx shl eax, 1 ; x = x * 2 add edi, eax ; add X - coord to dest mov ax, [ edi ] ret ENDP GetPixelHCVW_ ;----------------------------------------------------------------------------; ; SVGA - HC Line horizontal for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - LENGTH ; dx - color ; edi - scrParam ptr ; ; modify: eax, ecx, edi ; ; return: NONE ; PUBLIC LineHorHC_ PROC LineHorHC_ ; adr = ( y*640 +x )* 2 = y*256 +y*1024 +x*2 ;; shl ecx, 8 ;; add edi, ecx ;; shl ecx, 2 ;; add edi, ecx ;; shl eax, 1 ; x = x * 2 ;; add edi, eax ; add X - coord to dest imul ecx, [ (ITScreenParam edi).width ] add ecx, eax add ecx, ecx ; * 2 mov edi, [ (ITScreenParam edi).ptr ] add edi, ecx mov eax, edx ; rozszezenie koloru na dwie 16-stki shl eax, 16 mov ax, dx cld mov ecx, ebx test edi, 00000003h ; czy podzielny przez 4 jz @@Lok ; podzielny to skok stosw dec ecx @@Lok: shr ecx, 1 rep stosd jnc @@Lout stosw @@Lout: ret ENDP LineHorHC_ ;----------------------------------------------------------------------------; ; SVGA - HC Line Vertical for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - LENGTH ; dx - color ; edi - screen ptr ; ; modify: eax, ecx, esi, edi ; ; return: NONE ; PUBLIC LineVerHC_ PROC LineVerHC_ ; adr = y*640 +x = y*128 +y*512 +x test ebx, ebx ; jesli dlugosc lini 0 to out jz @@Lout ;; shl ecx, 8 ;; add edi, ecx ;; shl ecx, 2 ;; add edi, ecx ;; shl eax, 1 ; x = x * 2 ;; add edi, eax ; add X - coord to dest mov esi, [ (ITScreenParam edi).width ] imul ecx, esi add ecx, eax add ecx, ecx ; * 2 mov edi, [ (ITScreenParam edi).ptr ] add edi, ecx add esi, esi ; * 2 mov ecx, ebx @@L: mov [ edi ], dx add edi, esi ; 640*2 ; 640 -> Xres, 2 -> 2 byte per pixel dec ecx jnz @@L @@Lout: ret ENDP LineVerHC_ ;----------------------------------------------------------------------------; ; SVGA - HC Line horizontal - VariableWidth ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - LENGTH ; esi - screen Width ; dx - color ; edi - screen ptr ; ; modify: eax, ecx, edx, esi, edi ; ; return: NONE ; PUBLIC LineHorHCVW_ PROC LineHorHCVW_ ; adr = ( y*scrWidth +x )* 2 add esi, esi imul ecx, esi add edi, ecx shl eax, 1 ; x = x * 2 add edi, eax ; add X - coord to dest mov eax, edx ; rozszezenie koloru na dwie 16-stki shl eax, 16 mov ax, dx cld mov ecx, ebx test edi, 00000003h ; czy podzielny przez 4 jz @@Lok ; podzielny to skok stosw dec ecx @@Lok: shr ecx, 1 rep stosd jnc @@Lout stosw @@Lout: ret ENDP LineHorHCVW_ ;----------------------------------------------------------------------------; ; SVGA - HC Line Vertical - Variable Width ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - LENGTH ; esi - screen Width ; dx - color ; edi - screen ptr ; ; modify: eax, ecx, esi, esi, edi ; ; return: NONE ; PUBLIC LineVerHCVW_ PROC LineVerHCVW_ ; adr = (y*scrWidth +x) * 2 test ebx, ebx ; jesli dlugosc lini 0 to out jz @@Lout add esi, esi imul ecx, esi add edi, ecx shl eax, 1 ; x = x * 2 add edi, eax ; add X - coord to dest mov ecx, ebx @@L: mov [ edi ], dx add edi, esi ; esi = screen width * 2 dec ecx jnz @@L @@Lout: ret ENDP LineVerHCVW_ END