.model small .386 .stack 100h .data .code mov ax,0013h int 10h mov ax,0001h int 33h ; install mhandle as mouse handler mov ax,cs mov es,ax mov dx,offset mhandle mov cx,00000011b mov ax,000ch int 33h ; install mouse handler ; mov ax,0a000h mov es,ax mov di,0 mov cx,16000 mov eax,01010101h lp0: mov es:[di],eax add di,4 loop lp0 ; dec cx, cmp cx,0, jne lp0 mov ah,1 ; key delay int 21h mov ax,0003h int 10h mov ax,4c00h int 21h mhandle: ; bx is the button state ; cx is x coord, dx is ycoord push ax push dx mov ax,0a000h mov es,ax ; be save and bx,00000001b cmp bx,0 je skip0 dec dx shr cx,1 ; divide by 2 mov al,4 mov bx,20 call drawcube jmp skip0 mov ax,320 mul dx add ax,cx mov bx,ax mov al,4 ; draw red point mov es:[bx],al skip0: pop dx pop ax retf ; drawcube takes cx,dx of left top corner, plus color in al, and width in bx (<256) drawcube: push di push cx push ax mov ax,0a000h mov es,ax ; be safe mov ax,320 mul dx add ax,cx mov di,ax ; starting coord pop ax mov ch,bl ; height in ch outer: mov cl,bl ; width in cl inner: mov es:[di],al inc di dec cl cmp cl,0 jne inner add di,320 sub di,bx ; can't subtract bl directly dec ch cmp ch,0 jne outer pop cx pop di ret ; drawcube done end