8086启动文件绘图框在程序集中闪烁

时间:2018-03-26 19:53:43

标签: assembly x86-16

我在320x200 * 256模式下画了一个盒子,看起来它们是闪烁的,有没有办法修复这个像素闪烁?我该怎么做才能解决这个问题,有没有关于这方面的好教程我只在谷歌这里找到了一些文档http://webpages.charter.net/danrollins/techhelp/0113.HTM这个http://stanislavs.org/helppc/int_10.html是否有任何一步一步的教程。

    [bits 16]
    [org 0x7c00]
start:
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov sp, 0x09000
    mov bp,sp
    mov ebx,13h
    mov eax,4f02h
    int 10h
    mov ax,2h
    mov  ebx,0xa000
    mov ecx,0
    mov es,ebx
    mov ebx,0
    xor edi,edi

j:
    mov ax,4h
    mov cx, 200
    mov dx,200
    mov bx,220
    call drawBox
    mov ax,1h
    mov cx, 100
    mov dx,140
    mov bx,140
    call drawBox
    mov ax,0x16
    mov cx, 150
    mov dx,90
    mov bx,200
    call drawBox
    mov ax,0x25
    mov cx, 20
    mov dx,20
    mov bx,80
    call drawBox
    mov ax,2h
    call fill
    jmp j
fill:
    mov [bp+202],word cx
    mov [bp+204],word bx
    mov [bp+200] ,word dx
    xor cx,cx
    xor dx,dx
    mov bx,200
    call drawBox
    mov cx,[bp+202] 
    mov bx,[bp+204]
    mov dx,[bp+200]

drawBox:
    mov [bp],word cx
    mov [bp+4],word dx
    .keepdrawing:
        call setXY
        inc cx
        cmp cx,bx
        je .reset
    jmp .keepdrawing
    .reset:
        mov cx,[bp]
        inc dx
        cmp dx,bx
        jge .done
    jmp .keepdrawing
    .done:
    mov cx,[bp]
    mov dx,[bp+4]
    ret
setXY: ;requires cx Xposition, dx Yposition
    mov [bp+16], word ax
    mov [bp+20], word dx
    xor ax,ax
    add ax,320
    mul dx;; dx = y posiion
    mov di,cx ; cx = x position
    add di,ax 
    mov ax,[bp+16]
    mov dx,[bp+20] 
    cmp ax,[es:di]
        je .done
        jne .put
    .put:
    mov [es:di],ax
    .done:
    ret
times (510 - ($-$$)) db 0x00
dw 0xAA55

0 个答案:

没有答案