Assembler - grafická knihovna

Kategorie >>Programování>> Assembler - grafická knihovna


;pouziva definice z _def.inc
;
;
;Init_VESA_Mode Macro modik
;Init_NoVESA_Mode Macro modi
;Init_TEXT_Mode Macro modi
;getVideoPage macro
;getVideoMode macro
;Init_320x200 Macro
;putP macro
;PIXEL macro x,y,barva
;initVRAM macro ;[es:di]=[A000h:0000]
;CLrscr_320x200 macro BARVIK ;320x200x256 ,v al barva
;CircleP PROC near
;Circle Macro ci_x,ci_y,ci_radius,ci_color
;circle_stred Macro si_x,si_y,si_radius,si_color
;Copy_ALL_Video_Mem Macro policko ;do pole prekopioruje 320x200 bodu
;Paste_All_Video_Mem Macro policko ;na obrazovku prekopioruje 320x200 bodu
;
;
;
;
;

;---------------------------------------------
Init_VESA_Mode Macro modik
mov ah,4fh ;nastav vObrázekesa mod
mov al,02h ;
mov bx,modik
int 10h
endM

;---------------------------------------------
Init_NoVESA_Mode Macro modi
xor ah,ah
mov al,modi
int 10h
endM

;---------------------------------------------
Init_TEXT_Mode Macro modi
xor ah,ah
mov al,2
int 10h
endM

;--------------------------------------------
getVideoPage macro
mov ah,0fh
int 10h
mov video_page,bh

endm

;--------------------------------------------
getVideoMode macro
mov ah,0fh
int 10h
mov video_mode,ax
endm


;--------------------------------------------
Init_320x200 Macro
mov ax,13h ;320 x 200 x 256b
int 10h
endM

;--------------------------------------------





putP macro
;[es:di]ukazuje na ->[0a000h:0000]
;di = y
;dx = x
;al = barva
;320 = shl 1 o 8pozic + shl 1 o 6 pozic
;mem_POS = shl y,8 + shl y,6 + X
;jedu v ramci 0..319 = 320 pozic X,

mov bx,di
shl di,8
shl bx,6
add di,bx
add di,dx
stosb

endm

;_________________________________________________________
get_m_pozadi MACRO mx1,my1
mov si,0a000h ;z DS:DI zde obr -> pole
mov ds,si

mov di,@data
mov es,di
mov di,offset m_pozadi

mov si,my1
mov bx,si
shl si,8
shl bx,6 ;Y radka *2^6+radka * 2^8 :)))
add si,bx
add si,mx1 ;ted mam teda polohu bodu stredu -> tam je point mysi
sub si,5 ;-5 .. 0 .. 5 = 10 bodu bude mit kursor
mov cx,10
rep movsb
endM
;_________________________________________________________
SEt_m_CURSOR MACRO mx1,my1
mov di,0a000h ;z DS:DI zde obr -> pole
mov es,di

mov si,@data
mov ds,si
mov si,offset m_cursor

mov di,my1
mov bx,di
shl di,8
shl bx,6 ;Y radka *2^6+radka * 2^8 :)))
add di,bx
add di,mx1 ;ted mam teda polohu bodu stredu -> tam je point mysi
sub di,5 ;-5 .. 0 .. 5 = 10 bodu bude mit kursor
mov cx,10
rep movsb
endM
;_________________________________________________________
SEt_m_pozadi MACRO mx1,my1
mov di,0a000h ;z DS:DI zde obr -> pole
mov es,di

mov si,@data
mov ds,si
mov si,offset m_pozadi

mov di,my1
mov bx,di
shl di,8
shl bx,6 ;Y radka *2^6+radka * 2^8 :)))
add di,bx
add di,mx1 ;ted mam teda polohu bodu stredu -> tam je point mysi
sub di,5 ;-5 .. 0 .. 5 = 10 bodu bude mit kursor
mov cx,10
rep movsb
endM

;--------------------------------------------

PIXEL macro x,y,barva
;[es:di]ukazuje na ->[0a000h:0000]
;dx = x
;al = barva
;320 = shl 1,8 + shl 1,6
;mem_POS = shl y,8 + shl y,6 + X
;jedu v ramci 0..319 = 320 pozic X,
initVRAM
mov di,y
mov bx,di
shl di,8
shl bx,6
add di,bx
ADD DI,X
MOV AL,barva
stosb

endm
;______________________________________________________

GET_PIXEL macro x,y,barva

MOV SI,0A000H
MOV DS,SI

mov Si,y
mov bx,Si
shl Si,8
shl bx,6
add Si,bx
ADD SI,X
LODSB
mov barva,al

endm


;--------------------------------------------
initVRAM macro ;[es:di]=[A000h:0000]
mov di,0A000h
mov es,di
xor di,di
endM



;--------------------------------------------

CLrscr_320x200 macro BARVIK ;320x200x256 ,v al barva
pushA
initVRAM
mov ah,barvik
mov al,ah
; mov ah,al ;ah,al .. ax pro word
mov cx,32000
rep stosw ;2b*32k= 64k x vlozit barvu
popA
endm



;___________________________________________________________________________________________

CircleP PROC near

mov ax,[circle_radius]
cmp ax,0
jne okidouki ;It'll be crap-on-screen if radius=0
jmp dontwrite ;zadnej radius je mi tak na hovno
okidouki:
shl ax,1
sub ax,3
neg ax
mov [circle_rval],ax
mov [circle_x1],0
mov ax,[circle_radius]
mov [circle_y1],ax
mov ax,0a000h
mov es,ax
@@repeat1:
mov ax,[circle_y1]
add ax,[circle_y]
cmp ax,199
ja @@not1
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_x1]
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not1
mov di,ax
mov al,[circle_color]
stosb
@@not1:
mov ax,[circle_y1]
add ax,[circle_y]
cmp ax,199
ja @@not2
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_x1]
neg dx
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not2
mov di,ax
mov al,[circle_color]
stosb
@@not2:
mov ax,[circle_y1]
neg ax
add ax,[circle_y]
cmp ax,199
ja @@not3
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_x1]
neg dx
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not3
mov di,ax
mov al,[circle_color]
stosb
@@not3:
mov ax,[circle_y1]
neg ax
add ax,[circle_y]
cmp ax,199
ja @@not4
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_x1]
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not4
mov di,ax
mov al,[circle_color]
stosb
@@not4:
mov ax,[circle_x1]
add ax,[circle_y]
cmp ax,199
ja @@not5
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_y1]
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not5
mov di,ax
mov al,[circle_color]
stosb
@@not5:
mov ax,[circle_x1]
add ax,[circle_y]
cmp ax,199
ja @@not6
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_y1]
neg dx
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not6
mov di,ax
mov al,[circle_color]
stosb
@@not6:
mov ax,[circle_x1]
neg ax
add ax,[circle_y]
cmp ax,199
ja @@not7
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_y1]
neg dx
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not7
mov di,ax
mov al,[circle_color]
stosb
@@not7:
mov ax,[circle_x1]
neg ax
add ax,[circle_y]
cmp ax,199
ja @@not8
mov bx,ax
shl ax,8
shl bx,6
add ax,bx
mov dx,[circle_y1]
add dx,[circle_x]
add ax,dx
cmp dx,319
ja @@not8
mov di,ax
mov al,[circle_color]
stosb
@@not8:
cmp [circle_rval],0
jnl @@notrval
mov ax,[circle_x1]
shl ax,2
add ax,6
add [circle_rval],ax
jmp @@ending
@@notRval:
mov ax,[circle_x1]
sub ax,[circle_y1]
shl ax,2
add ax,10
add [circle_rval],ax
dec [circle_y1]
@@ending:
inc [circle_x1]
mov ax,[circle_x1]
cmp ax,[circle_y1]
ja dontwrite
jmp @@repeat1
dontwrite:

RET
ENDP circleP


Circle Macro ci_x,ci_y,ci_radius,ci_color

pushA
mov ax,ci_x
mov circle_x,ax
mov ax,ci_y
mov circle_y,ax
mov ax,ci_radius
mov circle_radius,ax
mov al,ci_color
mov circle_color,al
call CircleP
popA
endM

;___________________________________________________________________________________________
circle_stred Macro si_x,si_y,si_radius,si_color
pushA
mov ax,si_x
mov circle_x,ax
mov ax,si_y
mov circle_y,ax
mov ax,si_radius
mov circle_radius,ax
mov al,si_color
mov circle_color,al
call CircleP
Pixel si_x,si_y,si_color
popA
endM



;___________________________________________________________________________________________
Copy_ALL_Video_Mem Macro policko
PushA
mov cx,64000
mov si,0a000h
mov ds,si
xor si,si


mov di,@data
mov es,di
mov di,offset policko
rep movsb ; z DS:SI -> ES:DI; opakoj CX krat
PopA
endM

;--------------------------------------------
Paste_All_Video_Mem Macro policko
PushA
mov cx,64000
mov di,0a000h
mov es,di
xor di,di


mov si,@data
mov ds,si
mov si,offset policko
rep movsb ; z DS:SI -> ES:DI; opakoj CX krat
PopA
endM




Vloženo: 23.02.2007 00:39
Přečteno:2172
Autor: David Mizera

Hlasů: 0 Hodnocení(jako ve škole): nehlasováno
 

Komentáře (0)

   -     Nový Komentář