print macro string
mov ah,09h
lea dx,string
int 21h
endm
gotoxy macro x,y
mov ah,02h
mov dl,x
mov dh,y
mov bh,0
int 10h
endm
data segment
; add your data here!
color db ?
x dw ?
y dw ?
i db 1
xl dw ?
xr dw ?
yl dw ?
yr dw ?
xnum db ?
ynum db ?
strxy db "XY :",'$'
cselect db "color_select>>",'$'
allow db ?
xline db ' $'
yline db ' $'
;xline label byte
; maxx dw 3
; lenx dw ?
; bufferx dw 3 dup('$')
;
;
; yline label byte
; maxy dw 3
; leny dw ?
; buffery dw 3 dup('$')
ends
stack segment
dw 128 dup(0)
ends
code segment
start proc far
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
call Grafic
mov cx,4
mov dx,24
mov color,1
mov x,15
mov y,30
;============== Palet color ===========
l2:
l1:
call setpixel
inc cx
cmp cx,x
jne l1
mov cx,4
inc dx
cmp dx,y
jne l2
mov cx,4
add dx,3
add y,8
inc color
cmp color,16
jne l2
;================ draw borders=========
mov cx,3
mov dx,23
mov color,14
mov x,16
sub y,8
mov bx,0
mov bl,17
lc1:
lc2:
call setpixel
inc cx
cmp cx,x
jne lc2
mov cx,4
add dx,8
inc i
cmp bl,i
jne lc1
mov cx,3
mov dx,23
ld2:
inc dx
call setpixel
cmp dx,y
jne ld2
mov cx,16
mov dx,23
le2:
inc dx
call setpixel
cmp dx,y
jne le2
;================ MOUSE ==================
call Show_mouse
call new
gotoxy 12,20
print strxy
gotoxy 12,21
print cselect
loop1:
mov ax,dx
call converty
mov ax,cx
call convertx
call Check_mouse
cmp bx,1
je set
cmp bx,2
je read
cmp bx,3
je clr
cmp bx,4
je end
jmp loop1
read:
call readpixel
mov color,al
call color_select
jmp loop1
set:
;shr cx,1
call location
cmp allow,0
je put
jmp loop1
put:
;shr cx,1
call setpixel
jmp loop1
clr:
call new
jmp loop1
end:
ret
ends
endp ; set entry point and stop the assembler.
;==============================================
; Procedure
;==============================================
Grafic proc
mov ah, 0
mov al, 13h
int 10h
ret
endp
;---------------------------------
setpixel proc
mov al,color
mov ah,0ch
int 10h
ret
endp
;---------------------------------
Show_mouse proc
mov ax, 1
int 33h
ret
endp
;---------------------------------
Check_mouse proc
mov ax, 3
int 33h
ret
endp
;---------------------------------
readpixel proc
shr cx,1
add cx,2
mov ah,0dh
mov bh,0
int 10h
ret
endp
;---------------------------------
location proc
mov xl,100
mov xr,250
mov yl,50
mov yr,150
mov allow,0
cmp cx,xl
jb locate
cmp cx,xr
jg locate
cmp dx,yl
jb locate
cmp dx,yr
jg locate
jmp return
locate:
mov allow,1
return:
ret
endp
;---------------------------------
new proc
;.............. background ...............
mov color,15
mov cx,100
mov dx,50
mov x,251
mov y,151
lp2:
lp1:
call setpixel
inc cx
cmp cx,x
jne lp1
mov cx,100
inc dx
cmp dx,y
jne lp2
;............... BORDER ...................
mov cx,99
mov dx,49
mov x,251
mov y,151
mov color,1
l11:
mov ah,0ch
mov bh,0
mov al,color
int 10h
inc cx
cmp cx,x
jne l11
mov cx,99
mov dx,151
l12:
mov ah,0ch
mov bh,0
mov al,color
int 10h
inc cx
cmp cx,x
jne l12
mov cx,99
mov dx,49
mov y,151
l13:
mov ah,0ch
mov bh,0
mov al,color
int 10h
inc dx
cmp dx,y
jne l13
mov cx,251
mov dx,49
mov y,151
l14:
mov ah,0ch
mov bh,0
mov al,color
int 10h
inc dx
cmp dx,y
jne l14
ret
endp
convertx proc
mov xline[0],' '
mov xline[1],' '
mov xline[2],' '
mov xline[3],'$'
lea si,xline
add si,2
mov bx,10
for:
div bl
add ah,30h
mov [si],ah
mov ah,0
dec si
cmp ax,0
ja for
gotoxy 16,20
print xline
;=========
mov ah,02h
mov dl,','
int 21h ;print kama
;====================
ret
endp
converty proc
mov yline[0],' '
mov yline[1],' '
mov yline[2],' '
mov yline[3],'$'
lea si,yline
add si,2
mov bx,10
for2:
div bl
add ah,30h
mov [si],ah
mov ah,0
dec si
cmp ax,0
ja for2
gotoxy 20,20
print yline
ret
endp
color_select proc
mov cx,550
mov dx,167
mov x,560
mov y,175
lc:
call setpixel
inc cx
cmp cx,x
jne lc
mov cx,550
inc dx
cmp dx,y
jne lc
ret
endp
;...........................................................
سلام وقتتون خوش
این برنامه ای هست که تا اینجا روش کار کردم مثل محیط point راستش سعی کردم ولی نتونستم قسمت مربع و خط شو پیاده سازی کنم میشه شما کداشو برام بزارید .
باتشکر
طایم