; 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 ; ;***************************************************************************** ; ; PutGlassHC1 ; PutGlassHC2 ; PutGlassHC3 ; ; IDEAL INCLUDE 'graph.inc' ;GMASK1 equ 000fh ; GLASS MASK1 ;LEVEL1 equ 0008h ; ;GMASK2 equ 01E0h ; GLASS MASK2 ;LEVEL2 equ 0100h ; ;GMASK3 equ 3c00h ; GLASS MASK3 ;LEVEL3 equ 0000h ; GMASK1 equ 3c00h ; GLASS MASK1 LEVEL1 equ 0000h ; GMASK2 equ 3c00h ; GLASS MASK2 LEVEL2 equ 2000h ; GMASK3 equ 3c00h ; GLASS MASK3 LEVEL3 equ 4000h ; CODESEG ;----------------------------------------------------------------------------; ; SVGA - HC Put Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - WIDTH ; edx - HEIGHT ; esi - buf ptr ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; PUBLIC PutGlassHC1_ ALIGN 4 PROC PutGlassHC1_ ;;; adr = (y*640 +x) * 2 = y*256 + y*1024 + x*2 push ebp shl ecx, 8 add esi, ecx add edi, ecx shl ecx, 2 add esi, ecx add edi, ecx shl eax, 1 add esi, eax add edi, eax ; add X - coord to dest cld mov ebp, 640 sub ebp, ebx shl ebp, 1 ; x 2 bo 1 pixel to 2 bajty @@L00: mov ecx, ebx test edi, 3 ; czy podzielne przez 4 jz @@Lok ; TAK to skok lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK1 add ax, LEVEL1 stosw dec ecx @@Lok: push ecx shr ecx, 1 jz @@L02 @@L01: lodsd shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B ; and eax, 3def3defh and eax, ( GMASK1 SHL 16 ) + GMASK1 add eax, ( LEVEL1 SHL 16 ) + LEVEL1 stosd loop @@L01 @@L02: pop ecx test cl, 1 ; czy szerokosc parzysta ( podzielna / 2 ) jz @@Lsk lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK1 add ax, LEVEL1 stosw @@Lsk: add esi, ebp add edi, ebp dec edx jnz @@L00 pop ebp ret ENDP PutGlassHC1_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - WIDTH ; edx - HEIGHT ; esi - buf ptr ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; PUBLIC PutGlassHC2_ ALIGN 4 PROC PutGlassHC2_ ;;; adr = (y*640 +x) * 2 = y*256 + y*1024 + x*2 push ebp shl ecx, 8 add esi, ecx add edi, ecx shl ecx, 2 add esi, ecx add edi, ecx shl eax, 1 add esi, eax add edi, eax ; add X - coord to dest cld mov ebp, 640 sub ebp, ebx shl ebp, 1 ; x 2 bo 1 pixel to 2 bajty @@L00: mov ecx, ebx test edi, 3 ; czy podzielne przez 4 jz @@Lok ; TAK to skok lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK2 add ax, LEVEL2 stosw dec ecx @@Lok: push ecx shr ecx, 1 jz @@L02 @@L01: lodsd shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B ; and eax, 3def3defh and eax, ( GMASK2 SHL 16 ) + GMASK2 add eax, ( LEVEL2 SHL 16 ) + LEVEL2 stosd loop @@L01 @@L02: pop ecx test cl, 1 ; czy szerokosc parzysta ( podzielna / 2 ) jz @@Lsk lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK2 add ax, LEVEL2 stosw @@Lsk: add esi, ebp add edi, ebp dec edx jnz @@L00 pop ebp ret ENDP PutGlassHC2_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - WIDTH ; edx - HEIGHT ; esi - buf ptr ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; PUBLIC PutGlassHC3_ ALIGN 4 PROC PutGlassHC3_ ;;; adr = (y*640 +x) * 2 = y*256 + y*1024 + x*2 push ebp shl ecx, 8 add esi, ecx add edi, ecx shl ecx, 2 add esi, ecx add edi, ecx shl eax, 1 add esi, eax add edi, eax ; add X - coord to dest cld mov ebp, 640 sub ebp, ebx shl ebp, 1 ; x 2 bo 1 pixel to 2 bajty @@L00: mov ecx, ebx test edi, 3 ; czy podzielne przez 4 jz @@Lok ; TAK to skok lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK3 add ax, LEVEL3 stosw dec ecx @@Lok: push ecx shr ecx, 1 jz @@L02 @@L01: lodsd shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B ;;; and eax, 3def3defh and eax, ( GMASK3 SHL 16 ) + GMASK3 add eax, ( LEVEL3 SHL 16 ) + LEVEL3 stosd loop @@L01 @@L02: pop ecx test cl, 1 ; czy szerokosc parzysta ( podzielna / 2 ) jz @@Lsk lodsw shr eax, 1 ; dzielenie przez 2 - przyciemnianie ; R,G,B and ax, GMASK3 add ax, LEVEL3 stosw @@Lsk: add esi, ebp add edi, ebp dec edx jnz @@L00 pop ebp ret ENDP PutGlassHC3_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - WIDTH ; edx - HEIGHT ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; ; ; ; rezerwuje na stosie bufor na 640* 2 bajtow wczytuje do niego ; jedna linie obrabia w buforze a nastepnie wyrzuca ta linie na ekran ; ; dziala troche szybciej niz proc robiaca to po jednym pixelu ; PUBLIC PutGlassHCb_ ALIGN 4 PROC C PutGlassHCb_ ;; push ebp ;; mov ebp, esp LOCAL buf:BYTE:640*2 ; bufor na 1 linie LOCAL tmp:DWORD ;// 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 add edi, eax ; add X - coord to dest cld @@L00: mov tmp, edi mov esi, edi lea edi, buf mov ecx, ebx ; WIDTH test esi, 00000003 ; czy podzielne przez 4 jz @@Lok ; TAK to skok movsw dec ecx @@Lok: shr ecx, 1 rep movsd jnc @@L01 movsw @@L01: lea esi, buf ; mov edi, esi ;------------------------ mov ecx, ebx @@L02: mov ax, [ esi ] not eax mov [ esi ], ax add esi, 2 loop @@L02 ;------------------------ lea esi, buf mov edi, tmp mov ecx, ebx test edi, 00000003 ; czy podzielne przez 4 jz @@Lok1 ; TAK to skok movsw dec ecx @@Lok1: shr ecx, 1 rep movsd jnc @@L03 movsw @@L03: add edi, 640 * 2 shl ebx, 1 sub edi, ebx shr ebx, 1 dec edx jnz @@L00 ret ENDP PutGlassHCb_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - WIDTH ; edx - HEIGHT ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; PUBLIC PutGlassHCa_ PROC PutGlassHCa_ ;// 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 add edi, eax ; add X - coord to dest @@L00: mov esi, edi mov ecx, ebx @@L01: lodsw not eax stosw loop @@L01 add edi, 640 * 2 shl ebx, 1 sub edi, ebx shr ebx, 1 dec edx jnz @@L00 ret ENDP PutGlassHCa_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Shape Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ;ebx - WIDTH ; ;edx - HEIGHT ; esi - img ptr ; edi - video ptr ( addr ) ; ; modify: eax, ebx, ecx, edx, esi, edi, [ ebp - save on stack ] ; ; return: NONE ; PUBLIC PutShapeGlassHC1_ PROC PutShapeGlassHC1_ ;// 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 add edi, eax ; add X - coord to dest xor ebx, ebx xor edx, edx mov bx, [ esi ] mov dx, [ esi+2 ] add esi, 4 @@L00: mov ecx, ebx push ebx push edx @@L01: mov ax, [ esi ] mov dx, [ edi ] push ecx mov bl, dl mov bh, al and bl, 01fh and bh, 01fh shr bl, 1 ; przyciemnienie tresci pod szyba add bh, bl shr bh, 1 ; / 2 mov cl, bh shl cx, 11 shr eax, 5 shr edx, 5 mov bl, dl mov bh, al and bl, 01fh and bh, 01fh shr bl, 1 ; przyciemnienie tresci pod szyba add bh, bl shr bh, 1 ; / 2 mov cl, bh ror cx, 5 shr eax, 5 shr edx, 5 mov bl, dl mov bh, al and bl, 01fh and bh, 01fh shr bl, 1 ; przyciemnienie tresci pod szyba add bh, bl shr bh, 1 ; / 2 mov cl, bh ror cx, 6 mov [ edi ], cx pop ecx add esi, 2 add edi, 2 dec ecx jnz @@L01 pop edx pop ebx add edi, 640 * 2 shl ebx, 1 sub edi, ebx shr ebx, 1 dec edx jnz @@L00 ret ENDP PutShapeGlassHC1_ ;----------------------------------------------------------------------------; ; SVGA - HC Put Shape Glass for 640 x 480 mode ; ;----------------------------------------------------------------------------; ; parm: ; eax - X ; ecx - Y ; ebx - OPACITY ( 0 - 127 ) ; esi - img ptr ; edi - * ITScreenParam ; ; modify: eax, ebx, ecx, edx, esi, edi ; ; return: NONE ; PUBLIC PutShapeGlassHC PROC C PutShapeGlassHC LOCAL rScr:DWORD, gScr:DWORD, bScr:DWORD LOCAL rDelta:DWORD, gDelta:DWORD, bDelta:DWORD LOCAL opacity: DWORD, firstPixel: DWORD LOCAL scrWidth:DWORD, flag:DWORD mov opacity, ebx mov ebx, [ ( ITScreenParam edi ).width ] mov scrWidth, ebx mov edi, [ ( ITScreenParam edi ).ptr ] imul ecx, scrWidth add ecx, eax shl ecx, 1 add edi, ecx ; add X - coord to dest xor ebx, ebx xor edx, edx mov bx, [ esi ] mov dx, [ esi+2 ] add esi, 4 @@L00: mov ecx, ebx shr ecx, 1 push ebx push edx @@L01: mov eax, [ esi ] ; pobranie dwoch pixeli z imaga test eax, eax ; czy oba pixele czarne (transparentne) jz @@LnoAction push ecx mov edx, [ edi ] ; pobranie dwoch pixeli ze Screena test eax, 0000ffffh ; czy pierwszy pixel czarny jnz @@Lpixel1 mov firstPixel, edx ; przepisanie pierwszego pixela ze Screena and firstPixel, 0000ffffh shr eax, 16 shr edx, 16 jmp @@Lpixel2 ;;-------------------------- ;; obrobka pierwszego pixela @@Lpixel1: mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov bScr, ecx sub ecx, ebx mov bDelta, ecx shr eax, 5 shr edx, 5 mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov gScr, ecx sub ecx, ebx mov gDelta, ecx shr eax, 5 shr edx, 5 mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov rScr, ecx sub ecx, ebx mov rDelta, ecx mov ebx, rDelta imul ebx, opacity sar ebx, 7 ; / 128 sub rScr, ebx mov ebx, gDelta imul ebx, opacity sar ebx, 7 ; / 128 sub gScr, ebx mov ebx, bDelta imul ebx, opacity sar ebx, 7 ; / 128 sub bScr, ebx mov ebx, rScr shl ebx, 5 add ebx, gScr shl ebx, 5 add ebx, bScr mov firstPixel, ebx ;;-------------------------- shr eax, 6 shr edx, 6 test eax, 0000ffffh ; czy drugi pixel czarny jnz @@Lpixel2 mov [ edi ], bx jmp @@Lnopixel2 ;;-------------------------- ;; obrobka drugiego pixela @@Lpixel2: mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov bScr, ecx sub ecx, ebx mov bDelta, ecx shr eax, 5 shr edx, 5 mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov gScr, ecx sub ecx, ebx mov gDelta, ecx shr eax, 5 shr edx, 5 mov ebx, eax mov ecx, edx and ebx, 01fh and ecx, 01fh mov rScr, ecx sub ecx, ebx mov rDelta, ecx mov ebx, rDelta imul ebx, opacity sar ebx, 7 ; / 128 sub rScr, ebx mov ebx, gDelta imul ebx, opacity sar ebx, 7 ; / 128 sub gScr, ebx mov ebx, bDelta imul ebx, opacity sar ebx, 7 ; / 128 sub bScr, ebx mov ebx, rScr shl ebx, 5 add ebx, gScr shl ebx, 5 add ebx, bScr shl ebx, 16 add ebx, firstPixel mov [ edi ], ebx @@Lnopixel2: pop ecx @@LnoAction: add esi, 4 add edi, 4 dec ecx jnz @@L01 pop edx pop ebx mov ecx, scrWidth sub ecx, ebx shl ecx, 1 add edi, ecx dec edx jnz @@L00 ret ENDP PutShapeGlassHC END