12.07.2015 Views

wu'ed in haste; fried, stewed at leisure

wu'ed in haste; fried, stewed at leisure

wu'ed in haste; fried, stewed at leisure

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

mov cx.8 :CL - # of bits by which to shiftsub cx.Cbpl.1ntensityBits : ErrorAcc to get <strong>in</strong>tensity (8 level: <strong>in</strong>stead of 16 because we work only: with the high byte of ErrorAcc)mov ch.byte ptr [bpl.NumLevels ;mask used to flip all bits an <strong>in</strong>dec ch : <strong>in</strong>tensity , weight<strong>in</strong>gproduc<strong>in</strong>g: result (1 - <strong>in</strong>tensity weight<strong>in</strong>g)mov bp.BaseColor[bp] :***stack frame not available***;***from now on ***xchg bp.ax ;BP - ErrorAdj. AL - BaseColor.: AH - scr<strong>at</strong>ch register: Draw all rema<strong>in</strong><strong>in</strong>g pixels.YMajorLoop:add dx.bp :calcul<strong>at</strong>e error for next pixeljnc NoXAdvance :not time to step <strong>in</strong> X yet:the error accumul<strong>at</strong>or turned over,;so advance the X coordadd si .bx :add XDir to the pixel po<strong>in</strong>terNoXAdvance:add si.SCREEN-WIDTH-IN-BYTES ;Y-major, so always advance Y; The IntensityBits most significant bits of ErrorAcc give us the <strong>in</strong>tensity; weight<strong>in</strong>g for this pixel. and the complement of the weight<strong>in</strong>g for the: paired pixel.mov ah.dh :msb of ErrorAccshr ah.cl :Weight<strong>in</strong>g - ErrorAcc >> IntensityShift:add ah.al : BaseCol or + Weight<strong>in</strong>gmov [si 1 ,ah :DrawPixel(X. Y. BaseColor + Weight<strong>in</strong>g):mov ah.dh :msb of ErrorAccshr ah.cl :Weight<strong>in</strong>g - ErrorAcc >> IntensityShift:xor ah.ch :Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMaskadd ah.al :BaseColor + (Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMask)mov [si+bx] ,ah :DrawPixel(X+XDir. Y.: BaseColor + (Weight<strong>in</strong>g A Weight<strong>in</strong>gComplementMask));dec di :--Del taYjnz YMajorLoopjmp Done :we're done with this l<strong>in</strong>e: It's an X-major l<strong>in</strong>e.align 2XMajor:: Calcul<strong>at</strong>e the 16-bit fixed-po<strong>in</strong>t fractional part of a pixel th<strong>at</strong> Y advances: each time X advances 1 pixel, trunc<strong>at</strong><strong>in</strong>g the result to avoid overrunn<strong>in</strong>g: the endpo<strong>in</strong>t along the X axis.sub ax.ax :make DeltaY 16.16 fixed-po<strong>in</strong>t DX:AX value <strong>in</strong>790 Chapter 42div cx :AX - (DeltaY

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!