title vgablt.asm ; Basically exercises _BitBlt procedure from prog087.asm ; but we include the file vgabox.asm for drawing boxes, ; in order to first create an interesting pattern... ; But there is the problem of data moving over itself as shown in this ; example -- the solution: write a wrapper program ; to call this many times. ; uses graphics mode 12h .model small if1 include ..\..\mac\basic.mac endif .data ;**************** old data from vgabox.asm *********************** xx0 dw 100 ;(xx0,yy0)=top left corner of (first) box yy0 dw 50 width_ equ 50 ; dimensions of boxes height equ 24 no_boxes equ 18 ; number of boxes ccolor dw 1 ; color of first box xoffset equ 25 yoffset equ 12 xx1 dw ? ; (xx1,yy1)=bottom right corner of boxes yy1 dw ? ;**************** new data for BitBlt *********************** old_x dw 150 old_y dw 5 ; (old_x,old_y) is the old NE corner new_x dw 5 new_y dw 150 ; (new_x,new_y) is new NE corner blk_x dw 300 blk_y dw 200 ; (blk_x,blk_y) are dimensions of move fcn dw 0 ; logical function: 0=copy, 1=and, 2=or, 3=xor (?) .code main proc initdata ; macro ; mov ah,0 ; set screen mode mov al,12h ; mode 12h int 10h ; display_it 'Using mode 12h to display 16 boxes in 16 default colors' newline display_it 'Can you explain the phenomenon of this BitBlt operation?' newline ; mov cx,no_boxes repeat: push cx ; cx is messed up by someone, so must save it mov ax,xx0 ; begin update xx1 add ax,width_ mov xx1,ax ; xx1 = xx0+width mov ax,yy0 ; begin update yy1 add ax,height mov yy1,ax ; yy1 = yy0+width save ; setting up arguments call _solid_box ; before calling _solid_box add sp,10 ; i.e., restore add xx0,xoffset add yy0,yoffset inc ccolor pop cx loop repeat ; save call _BitBlt add sp,14 ; restore ; pause "press any key to terminate" ; restore mode mov ah,0 mov al,3 int 10h ; exitdos main endp ; ;&&&&&&&&&&&&&&&&&&&&& prog085.asm below &&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; ;************************************************************************ ; solid_box(x0,y0,x1,y1,color) fill a rectangle defined by * ; upper-left 'x0,y0', and lower-right 'x1,y1' * ; with the specified color 'Color'. * ; Each pixel on the display corresponds to one bit in memory. * ; Thus one byte represents 8 different pixles. * ; A rectangle, in general, will consist of three vertical * ; strips. The midle strip will be composed entirely from pixels * ; forming a complete byte. The left strip has pixels only in * ; last few bits of a byte, and right strip only in first few bits * ; This routine will draw each strip in a separate loop. * ;************************************************************************ x0 EQU [BP+4] y0 EQU [BP+6] x1 EQU [BP+8] y1 EQU [BP+10] Color EQU [BP+12] ; PUBLIC _Solid_Box _Solid_Box PROC NEAR PUSH BP MOV BP,SP PUSH DI ;Preserve segment registers PUSH SI PUSH DS PUSH ES ;--- Rearrange corners so that x0