Nuevas NORMAS para el foro

Curso Hacker
Bienvenido(a), Visitante. Favor de ingresar o registrarse.
¿Perdiste tu email de activación? - Julio 26, 2008, 09:00:56
Boton Buscar
Inicio Ayuda Ingresar Registrarse
Visita: Articulos - Juegos Gratis - Da Foros

Comunidad Underground Hispana  |  Programacion  |  Programación  |  ASM (Moderador: The Shadow)  |  Tema: [W] Sencillo dibujo con el estandard Vesa 0 Usuarios y 1 Visitante están viendo este tema. « anterior próximo »
Páginas: [1] Ir Abajo Imprimir
Autor Tema: [W] Sencillo dibujo con el estandard Vesa  (Leído 118 veces)
The Shadow
Moderadores
Colaborador
*****
Desconectado Desconectado

Mensajes: 754


Fucking mnemonic c0d1n6!

shadow@el-hacker.org
Ver Perfil Email
« en: Marzo 22, 2008, 01:48:41 »

Codigo fuente en lenguaje ensamblador. Se ensambla con el a86, que hace un dibujo usando el estandard vesa. Es un programa sencillo para observar el funcionamiento de graficos en alta resolucion.

Código:
inicio:
       ;buscar un modo de video soportado con 64k colores
xor cx,cx
mov cx,2
        l1:
        mov ax,cx
        inc cx
        cmp ax,5
        jnc >l3
        call setvideomode
        test ax,ax
        jz l1
        mov dx,63
        call mandeldibu  ;hacer un dibujo
        l2:
        ret
        l3:  ;return message error
        mov bx,1  ;std output
        mov ah,40h ;dos write function
        mov dx,mesage
        mov cx,endmesage-mesage
        int 21h
        ret

mandeldibu:
        mov ax,[w xmax]
        mov cx,[w ymax]
        pusha
        finit
        mov si,mandeldata2
        mov bp,sp
        fild [w xmax] ;xmax
        fdivr [d si+8]  ;lado_x
        fstp [d bp]  ;x_escala
        fild [w ymax] ;ymax
        fdivr [d si+12]  ;lado_y
        fstp [d bp+4]  ;y_escala
        l1:
        finit
        fild [w si+16]
        fild [w bp+14] ;x
        fmul [d bp]    ;x_escala
        fadd [d si]  ;izq
        fild [w bp+12] ;y
        fmul [d bp+4]
        fadd [d si+4]
        fldz
        fldz
        mov cx,[bp+10] ;63
        l3:
        fld 1
        fmul 2
        fld 1
        fmul 2
        fld 1
        fsub 1
        fcomp 7
        fstsw ax
        sahf
        jnb >l4
        fsub
        fadd 4
        fchs
        fxch 2
        fmulp
        fadd 0
        fadd 2
        loop l3
        l4:
        mov bx,[bp+14]
        shl bx,6
        mov bl,64
        sub bl,cl
        mov dl,cl
        shl dl,3
        add dl,64
        shl bl,3
        add bh,bl
        add bl,bl
        call setcolor
        mov cx,[bp+14]
        mov ax,[bp+12]
        call setpixel
        dec [w bp+14]
        jns l1
        mov ax,[w xmax]
        mov [w bp+14],ax
        dec [w bp+12]
        jns l1
        popa
        ret

setvideomode: ;videomode en ax
        pusha
        mov bp,sp
        sub sp,256  ;bufer para la bios vesa
shl ax,3
        mov bx,videomodes64k
        add bx,ax
        mov es,ss
        mov di,sp
        mov cx,[bx]
        db 102
        push [bx+2]
        mov ax,4f01  ;obtener informacion del modo de video
        int 10h
        cmp ax,4fh
        je >l2
        l1:
        ;funcion no soportada u otro error
        mov sp,bp
        popa
        xor ax,ax
        ret
l2:
mov bx,cx
        mov ax,4f02
        int 10h  ;fijar el modo de video
        cmp ax,4fh
jne l1
        mov ax,[di+2] ;windows "a,b"
        and ax,505h
cmp al,5 ;window "a" es de escritura
jne l1
        cmp [w di+6],64 ;window size si 64k
jne l1
        cmp [w di+8],0a000h ;video segment
jne l1
        pop [w xmax]
        pop [w ymax]
        db 102  ;prefijo de 32 bits
        push [di+12]
        db 102
        pop [fcvesa+1]
        push [w di+16]
        pop [w bytesporlinea]
        push [w di+8]
pop es
        mov cx,[di+4] ;granularidad ,debe ser una potencia de 2
        xor ax,ax
        shl cx,9
        l1:
        shl cx,1
        jz >l2
        inc al
        jmp l1
        l2:
        mov [cs:fcvesa-1],al
        l3:
        mov [b ACPAG],0
        mov sp,bp
        popa
        ret

setcolor:
        ;dl azul
        ;bl verde
        ;bh rojo
        ;retorna bx
     and bx,0f8fch
     shr dl,3
     xchg dl,bl
     xor dh,dh
     shl dx,3
     or bx,dx
     ret

setpixel:  ;x en cx,y en ax,color en bx
           mul [w bytesporlinea]
           add cx,cx
           add ax,cx
           adc dl,0
           mov di,ax
           cmp [b ACPAG],dl
           jne >l1
           mov [es:di],bx
           ret
           l1:
           ;vesabank  cambia el banco de memoria de video
           push bx
           mov [b ACPAG],dl
           xor bx,bx ;selecciona ventana 'A' ,que debe ser de escritura
           sal dx,0fh  ;cvar
           fcvesa:
           call 0ffffffffh ;cvar
           pop bx
           mov [w es:di],bx
           ret

mandeldata2:
dd -2.0 ; izq
dd  2.0 ; arb
dd  4.0 ; lado_x
dd -4.0 ; lado_y
dw  8   ; limite
videomodes64k:
dw 11ah,1279,1023,0
dw 117h,1023,767,0
dw 114h,799,599,0
dw 111h,639,479,0
dw 10eh,319,199,0
xmax: dw 0
ymax: dw ?
bytesporlinea: dw ?
acpag: db ?  ;numero del banco de memoria

mesage: db "no se encontro ningun modo de video valido"
db 10,13
endmesage:

Autor:     Octavio Vega Fernández
Fuente: LWP
« Última modificación: Marzo 28, 2008, 05:11:03 por The Shadow » En línea


Para ver los enlaces debes ser usuario Crear Usuario o Hacer Sesion





Para ver los enlaces debes ser usuario Crear Usuario o Hacer Sesion
Reglamento del Foro
     Linux  Registered User #473016
Páginas: [1] Ir Arriba Imprimir 
Comunidad Underground Hispana  |  Programacion  |  Programación  |  ASM (Moderador: The Shadow)  |  Tema: [W] Sencillo dibujo con el estandard Vesa « anterior próximo »
Ir a:  


Ranking-Hits
Powered by SMF 1.1.5 | SMF © 2006-2007, Simple Machines LLC