|
|
||
|
|
||
|
|
||
Figure 19-7:
2D bitmap on left with 2-bit clipping plane on right
The same trick of using inverse logic can be used for expanding image clipping planes.
In the image on the left, no matter how it's encoded (8/16/24/32 bits), only a single bit in the clipping plane image on the right would be needed to represent a single pixel. If black=0 and white=1, then a sprite object could appear to pass in front of the fence as well as behind it but in front of the
; esi = sprite image pointer
; ebx = clipping plane
; ebp = background image pointer
; edi = destination image buffer pointer
mov edx,[ebx] ; Get clipping plane
mov ch,32 ; 32 pixels at a time
$L1: mov al,[esi] ; Source sprite image
inc esi ; Next sprite pixel pointer
mov cl,[ebp] ; Source background image
inc ebp ; Next src background pixel
test al,tcolor ; transparent color
je $T1 ; Jump if transparent pixel
shr edx,1 ; Get a masking bit into carry
setnc ah ; 1=background 0=foreground
dec ah ; 00=background ff=foreground
and cl,ah ; ff=keep bgnd 00=kill it
not ah ; Flip masking bits
and al,ah ; ff=keep sprite 00=kill it
or cl,al ; (XOR type) Blend pixels
$T1: mov [edi],cl ; Save new pixel to destination
inc edi ; Next dst working pixel
dec ch ; 1 less pixel in run
jnz $L1 ; Loop
|
|
||
|
|
||
|
|
||
This chapter reminds me of the old
Batman and Robin
show where in a fight scene we see sound effect words flash on screen such as "OOF," "KABONG," "ZING," "MASM," "ZOT," "TASM," "ZANG," "WASM," and "POW." These, by an amazing
There is a form of assembly that we should not forget: in-line assembly. Some people swear by it. I, on the other hand, swear at it! I rarely use it and only for some specific type of data conversion that I need to be fast without the penalty of a stack call to call a pure assembly function. It is akin to programming with one arm tied behind one's back. A lot of macro assembler functions are not available.
I have read book reviews in which advocates of non-MASM assemblers
You should always use the latest and greatest version of your favorite assembler because if you do not, your version could have
With the latest instruction sets there seem to be two assemblers at the forefront with recently introduced assembly instructions: MASM and NASM. No matter whose assembler you're using, I use the following as placeholders for the arguments being passed into the example code used in this book:
arg1 equ 8 ; Argument #1
arg2 equ (arg1+4) ; Argument #2
arg3 equ (arg2+4) ; Argument #3
arg4 equ (arg3+4) ; Argument #4
arg5 equ (arg4+4) ; Argument #5
arg6 equ (arg5+4) ; Argument #6
arg7 equ (arg6+4) ; Argument #7
arg8 equ (arg7+4) ; Argument #8
; void unzip(byte *pRaw, byte *pZip, uint nWidth);
public unzip
unzip proc near
push ebp
mov ebp,esp
push ebx
push esi
push edi
mov esi,[ebp+arg1] ; pRaw
mov edi,[ebp+arg2] ; pZip
mov ecx,[ebp+arg3] ; nWidth
;
;
;
pop edi
pop esi
pop ebx
pop ebp
ret
unzip endp
You will note that I used arg1 instead of 8 as shown below:
mov eax,[ebp+8]
As an alternative to the arg1 you could use a define to make the argument
pRaw = arg1 mov eax,[ebp+pRaw]
The following information is a brief overview and you should refer to your assembler's documentation for specific information.