دانلود پروژه اسمبلی کلیک روی مربع های رنگی
در این پروژه چند مربع با رنگ های متفاوت نشان داده می شوند و کاربر می تواند با کلیک بر روی آنها رنگ قسمتی از صفحه را به رنگ قسمت کلیک شده درآورد.

در این پروژه چند مربع با رنگ های متفاوت نشان داده می شوند و کاربر می تواند با کلیک بر روی آنها رنگ قسمتی از صفحه را به رنگ قسمت کلیک شده درآورد.در واقع برنامه تشخیص میدهد که روی کدام قسمت کلیک شده است.
روند کار برنامه :
کار این برنامه به این صورت است که در یک حلقه ی دائمی هر دفعه مشخصات ماوس را چک می کند اگر کلیک چپ صورت گرفته بود به قسمتی میرود که تشخیص میدهد که در کدام قسمت کلیک شده است.اگر محل کلیک شده یکی از مربع ها باشد ، رنگ صفحه را به آن رنگ تغییر می دهد در غیر اینصورت کار خود را ادامه می دهد و منتظر کلیک بعدی می ماند.
اصل برنامه را می توانید در پایین صفحه دانلود کنید
اینم سورس کد برنامه که می توانید در emu8086 از آن بهره بگیرید:
;www.SourceCodes.ir
name "colors"
; kernel is loaded at 0800:0000 by micro-os_loader
org 100h
; skip the data and function delaration section:
jmp start
;======================================
clear_screen macro x1,x2,y1,y2,color
push ax ; store registers...
push ds ;
push bx ;
push cx ;
push di ;
; kernel is loaded at 0800:0000 by micro-os_loader
org 100h
; skip the data and function delaration section:
jmp start
;======================================
clear_screen macro x1,x2,y1,y2,color
push ax ; store registers...
push ds ;
push bx ;
push cx ;
push di ;
mov ax, 40h
mov ds, ax ; for getting screen parameters.
mov ah, 06h ; scroll up function id.
mov al, 0 ; scroll all lines!
mov bh, color ; attribute for new lines.
mov ch, x1 ; upper row.
mov cl, y1 ; upper col.
mov di, 20 ; rows on screen -1,
mov dh, x2; lower row (byte).
mov di, 4ah ; columns on screen,
mov dl, y2
dec dl ; lower col.
int 10h
mov ds, ax ; for getting screen parameters.
mov ah, 06h ; scroll up function id.
mov al, 0 ; scroll all lines!
mov bh, color ; attribute for new lines.
mov ch, x1 ; upper row.
mov cl, y1 ; upper col.
mov di, 20 ; rows on screen -1,
mov dh, x2; lower row (byte).
mov di, 4ah ; columns on screen,
mov dl, y2
dec dl ; lower col.
int 10h
pop di ; re-store registers...
pop cx ;
pop bx ;
pop ds ;
pop ax ;
endm
pop cx ;
pop bx ;
pop ds ;
pop ax ;
endm
click macro x1,y1,x2,y2
local s1
local s2
local s3
local s4
local exit
local exits
local s1
local s2
local s3
local s4
local exit
local exits
cmp curX,x1
jae s1
jmp exits
s1:
cmp curX,x2
jbe s2
jmp exits
s2:
cmp curY,y1
jae s3
jmp exits
s3:
cmp curY,y2
jbe s4
jmp exits
s4:
mov ax,1
push ax
jmp exit
exits:
mov ax,0
push ax
exit:
endm
jae s1
jmp exits
s1:
cmp curX,x2
jbe s2
jmp exits
s2:
cmp curY,y1
jae s3
jmp exits
s3:
cmp curY,y2
jbe s4
jmp exits
s4:
mov ax,1
push ax
jmp exit
exits:
mov ax,0
push ax
exit:
endm
start:
curX dw 0
curY dw 0
curB dw 0
; set data segment:
push cs
pop ds
mov ax, 1003h ; disable blinking.
mov bx, 0
int 10h
curX dw 0
curY dw 0
curB dw 0
; set data segment:
push cs
pop ds
mov ax, 1003h ; disable blinking.
mov bx, 0
int 10h
; hide text cursor:
mov ch, 32
mov ah, 1
int 10h
mov ah,00 ; set display mode function.
mov al,03 ; normal text mode 3
int 10h ; set it!
mov ch, 32
mov ah, 1
int 10h
mov ah,00 ; set display mode function.
mov al,03 ; normal text mode 3
int 10h ; set it!
reload:
clear_screen 1 5 15 25 80 ;red
clear_screen 7 11 15 25 100 ;red
clear_screen 1 5 30 40 130 ;red
clear_screen 7 11 30 40 145 ;red
clear_screen 1 5 45 55 180 ;red
clear_screen 7 11 45 55 200 ;red
clear_screen 1 5 60 70 40 ;red
clear_screen 7 11 60 70 50 ;red
; display mouse cursor:
mov ax, 1
int 33h
check_mouse_buttons:
mov ax, 3
int 33h
cmp bx, 1 ; agar click chap surat gerefte ast
je checkpoint
jmp check_mouse_buttons
checkpoint:
mov curB, bx
mov curX, cx
mov curY, dx
click 132,13,196,43 ; check click color1
pop ax
cmp ax,1
je color1
click 132,59,196,90 ; check click color2
pop ax
cmp ax,1
je color2
click 241,13,313,43 ; check click color3
pop ax
cmp ax,1
je color3
click 241,59,313,90 ; check click color4
pop ax
cmp ax,1
je color4
click 362,13,436,43 ; check click color5
pop ax
cmp ax,1
je color5
click 362,59,436,90 ; check click color6
pop ax
cmp ax,1
je color6
click 483,13,556,43 ; check click color7
pop ax
cmp ax,1
je color7
click 483,59,556,90 ; check click color8
pop ax
cmp ax,1
je color8
jmp check_mouse_buttons
color1:
clear_screen 15 25 0 79 85 ;red
jmp endcolor
color2:
clear_screen 15 25 0 79 105 ;red
jmp endcolor
color3:
clear_screen 15 25 0 79 135 ;red
jmp endcolor
color4:
clear_screen 15 25 0 79 150 ;red
jmp endcolor
color5:
clear_screen 15 25 0 79 185 ;red
jmp endcolor
color6:
clear_screen 15 25 0 79 205 ;red
jmp endcolor
color7:
clear_screen 15 25 0 79 45 ;red
jmp endcolor
color8:
clear_screen 15 25 0 79 55 ;red
jmp endcolor
mov curB, bx
mov curX, cx
mov curY, dx
click 132,13,196,43 ; check click color1
pop ax
cmp ax,1
je color1
click 132,59,196,90 ; check click color2
pop ax
cmp ax,1
je color2
click 241,13,313,43 ; check click color3
pop ax
cmp ax,1
je color3
click 241,59,313,90 ; check click color4
pop ax
cmp ax,1
je color4
click 362,13,436,43 ; check click color5
pop ax
cmp ax,1
je color5
click 362,59,436,90 ; check click color6
pop ax
cmp ax,1
je color6
click 483,13,556,43 ; check click color7
pop ax
cmp ax,1
je color7
click 483,59,556,90 ; check click color8
pop ax
cmp ax,1
je color8
jmp check_mouse_buttons
color1:
clear_screen 15 25 0 79 85 ;red
jmp endcolor
color2:
clear_screen 15 25 0 79 105 ;red
jmp endcolor
color3:
clear_screen 15 25 0 79 135 ;red
jmp endcolor
color4:
clear_screen 15 25 0 79 150 ;red
jmp endcolor
color5:
clear_screen 15 25 0 79 185 ;red
jmp endcolor
color6:
clear_screen 15 25 0 79 205 ;red
jmp endcolor
color7:
clear_screen 15 25 0 79 45 ;red
jmp endcolor
color8:
clear_screen 15 25 0 79 55 ;red
jmp endcolor
endcolor:
jmp check_mouse_buttons
هم اکنون می توانید سورس این پروژه را به صورت رایگان دانلود کنید
حجم فایل :17 KB
0
نظرات