PDA

View Full Version : آموزش: برنامه گرفتن رشته از كاربر و تغيير رنگ متن و پشت ضمينه آن و چشمك زدن متن



xman_1365_x
چهارشنبه 13 بهمن 1389, 02:12 صبح
مدتي قبل اينو براي كسي نوشتم كه البته هزينه اي پرداخت نكرد :لبخند: گفتم بزارم دوستان ديگه هم استفاده كنند شايد برنامه هاي ديگه هم كه نوشتم بزارم البته بعضا تعداد خطوط بالاي 1000 خط هست كه از حوصله من خارج هست توضيح كد ها
يك برنامه كار با گرافيك براتون ميزارم،فكر كنم توضيحش كافيه و نيازي به توضيح بيشتر نيست
كار اين كد اينه كه كرسر رو تقريبا به وسط صفحه ميبره و رشته اي با طول 10 از كاربر ميگيره بعد
رنگ متن رو قرمز و پشت ضمينه متن رو آبي ميكنه (ضمنا در داس ميشه با تغيير bx متن رو به حالت چشمك زن برد كه اين حالت در ويندوز امكان پذير نيست).
عكس از اجراي برنامه
http://www.irupload.ir/images/48845411529435902050.jpg (http://www.irupload.ir/)
و در نهايت سورس


name "begin-VGA"
; this example prints out "begin-VGA!"
; by writing directly to video memory.
; in vga memory: first byte is ascii character, byte that follows is character attribute.
; if you change the second byte, you can change the color of
; the character even after it is printed.
; character attribute is 8 bit value,
; high 4 bits set background color and low 4 bits set foreground color.
; hex bin color
;
; 0 0000 black
; 1 0001 blue
; 2 0010 green
; 3 0011 cyan
; 4 0100 red
; 5 0101 magenta
; 6 0110 brown
; 7 0111 light gray
; 8 1000 dark gray
; 9 1001 light blue
; a 1010 light green
; b 1011 light cyan
; c 1100 light red
; d 1101 light magenta
; e 1110 yellow
; f 1111 white
.model small
.stack 128
.Data
.code
main proc far
.STARTUP

;set video mode.
mov ax, 3 ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3)
int 10h ; do it!
; cancel blinking and enable all 16 colors:
;BL = write mode:
;0: enable intensive colors.
;1: enable blinking (not supported by the emulator and windows command prompt).
mov ax, 1003h
mov bx, 0
int 10h

; set segment register:
mov ax, 0b800h
mov ds, ax

mov di,1980 ;cursor position
mov cx,10 ;Get count characters
for1:
mov ah,7
int 21h
mov [di],al
add di,2
loop for1
; color all characters:
mov cx, 10 ; number of characters.
mov di,1981 ; start from byte after one input
for: mov [di], 00010100b ; light red(1100) on blue(0001)
add di, 2 ; skip over next ascii code in vga memory.
loop for
; wait for any key press:
mov ah, 0
int 16h
mov ah,4ch
int 21h
main endp
end main