wu'ed in haste; fried, stewed at leisure
wu'ed in haste; fried, stewed at leisure
wu'ed in haste; fried, stewed at leisure
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
.modelsmall.code; Screen dimension globals, used <strong>in</strong> ma<strong>in</strong> program to scale.- ScreenWidthInPixels dw 320- ScreenHeightInPixels dw 200.codepublic -DrawWuL<strong>in</strong>e- DrawWuL<strong>in</strong>e proc nearpush bp ;preserve caller's stack framemov bp.sp ;po<strong>in</strong>t to local stack framepush si ;preserve C's register variablespush dipush ds ;preserve C's default d<strong>at</strong>a segmentcl d ;make str<strong>in</strong>g <strong>in</strong>structions <strong>in</strong>crement their po<strong>in</strong>ters; Make sure the l<strong>in</strong>e runs top to bottom.mov si.Cbpl.XOmov ax.Cbpl.YOcmp ax.[bp].Yl ;swap endpo<strong>in</strong>ts if necessary to ensure th<strong>at</strong>jna NoSwap ; YO EGMENTds .dx ;po<strong>in</strong>t DS to the screen segmentdx.SCREEN_WIDTH-IN-BYTESdx ;YO * SCREEN-WIDTH-IN-BYTES yields the offset; of the start of the row start the <strong>in</strong>itial; pixel is onsi ,ax ;po<strong>in</strong>t DS:SI to the <strong>in</strong>itial pixelal.byte ptr Cbp1.BaseColor ;color with which to draw[sil.aldraw the <strong>in</strong>itial pixelmovmovsubJnsnegnegDel taXSet:bx.1cx.[bp].Xlcx.[bpl.XODel taXSetcxbxXDir - 1; assume DeltaX >- 0;DeltaX; is it >- l?;yes. move left->right. all set;no. move right->left;make DeltaX positive;XDir - -1; Special-case horizontal, vertical, and diagonal l<strong>in</strong>es, which require no; weight<strong>in</strong>g because they go right through the center of every pixel.mov dx.Cbpl.Ylsub dx.Cbpl.YO ;DeltaY; is it O?jnz NotHorz ;no. not horizontal;yes. is horizontal, special caseand bx.bx ;draw from left->right?jns DoHorz ;yes. all setstd ;no. draw right->leftDoHorz:lea di.[bx+sil ;po<strong>in</strong>t DI to next pixel to drawmov ax.ds788 Chapter 42