如何使绘图更好?

时间:2017-04-13 16:22:12

标签: assembly x86 tasm dosbox

我现在正在创建绘制应用程序。 我已经创建了绘图功能,但不幸的是,它并没有给我画画 我的所有像素都通过鼠标的移动。 (我为它添加了截图)

这是我的代码的一部分(仅限绘图功能):

  proc init
push ax

;graphical mode. 40x25. 256 colours. 320x200 pixels. 1 page.
mov ax, 0
mov al, 13h 
int 10h


pop ax
ret
endp init


proc cls
push ax
push bx
push cx
push dx


; scoll up for cleaning the screen
mov bx ,0
mov al, 200
mov ah, 6h
int 10h

pop dx
pop cx
pop bx
pop ax


ret
endp cls

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

; Set the pixel at given position to given color

; INPUT

; ax - x position

; bx - y position

; cx - color

;----------------------------------------------------------------
proc set_pixel


mov ah, 0ch
int 10h     ; set pixel. 


ret
endp set_pixel




proc draw_horizontal_line
;----------------------------------------------------------------

; Draw horizontal line

; INPUT


; bx - end column (cx)

; cx - column

; dx - row

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

@@wall:
call set_pixel
inc cx
cmp cx, bx
je @@done
jmp @@wall
@@done:
ret
endp draw_horizontal_line

proc draw_vertical_line
;----------------------------------------------------------------

; Draw vertical line

; INPUT


; bx - end row (dx)

; cx - column

; dx - row

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


@@wall:
call set_pixel
inc dx
cmp dx, bx
je @@done
jmp @@wall
@@done:
ret
endp draw_vertical_line


proc draw_left_wall

mov cx , 5
mov dx , 20
mov bx, 190

mov al, 0100b

call draw_vertical_line

ret 
endp draw_left_wall

proc draw_right_wall

mov cx , 250
mov dx , 20
mov bx, 191

mov al, 0100b

call draw_vertical_line

ret 
endp draw_right_wall

proc draw_top_wall

mov cx , 5
mov dx , 20
mov bx, 250

mov al, 0100b

call draw_horizontal_line


ret 
endp draw_top_wall

proc draw_bottom_wall
mov al, 0100b
mov cx , 5
mov dx , 190
mov bx, 250


call draw_horizontal_line

ret 
endp draw_bottom_wall

proc exit_button
mov al, 0100b
mov cx , 1
mov dx , 1
mov bx, 6

call draw_horizontal_line

mov al, 0100b
mov cx , 1
mov dx , 6
mov bx, 6

call draw_horizontal_line

mov cx , 1
mov dx , 1
mov bx, 6

mov al, 0100b

call draw_horizontal_line

mov cx , 6
mov dx , 1
mov bx, 6

mov al, 0100b

call draw_horizontal_line

endp exit_button

proc draw_inner_background


mov dx , 190



@@looper:
sub dx, 1

call white_line

cmp dx, 21
je @@done
jmp @@looper

@@done:

ret
endp draw_inner_background

proc draw_out_background


mov dx , 200


@@looper:
sub dx, 1

call background_color

cmp dx, 0
je @@done
jmp @@looper

@@done:

ret
endp draw_out_background

proc background_color
push cx
push dx
push bx
mov cx , 0
mov bx, 320

mov al, 1110b

call draw_horizontal_line
pop bx
pop dx
pop cx
ret
endp background_color


proc white_line
push cx
push dx
push bx
mov cx , 6
mov bx, 250

mov al, 1111b

call draw_horizontal_line
pop bx
pop dx
pop cx
ret
endp white_line



proc resetAndShowCursor
mov ax, 0 
int 33h 
mov ax, 1 
int 33h 
ret
endp resetAndShowCursor

proc getMouseLocation
mov ax, 3 
int 33h 
ret

endp getMouseLocation

proc setPixelAtMouseLocation
shr cx, 2
shl cx, 1    
cmp bx, 1
jne @@done
cmp cx, 250 
ja @@done 
cmp cx, 5
jbe @@done 

cmp dx, 190
ja @@done

cmp dx, 20
jbe @@done

call set_pixel
@@done:
ret
endp setPixelAtMouseLocation

proc mouse_loop
@@drawLoop:
;call escape
;jz @@done
call getMouseLocation
call setPixelAtMouseLocation
jmp @@drawLoop

@@done:
ret
endp mouse_loop

proc render
call init
;call cls
call draw_out_background
call draw_inner_background
call draw_bottom_wall
call draw_left_wall
call draw_right_wall
call draw_top_wall
;call author_print
call resetAndShowCursor
call mouse_loop
ret
endp render

截图:

Screenshot

0 个答案:

没有答案