你能告诉我如何在emu8086上画画吗?
首先,您设置图形视频模式。下一个代码选择 320x200 256 色模式:
mov ax, 0013h ; AH=00h is BIOS.SetVideoMode, AL=13h is 320x200 mode
int 10h
现在您可以绘制任何您喜欢的像素。下面是在屏幕中心绘制单个像素的示例:
mov dx, 100 ; Y = 200 / 2
mov cx, 160 ; X = 320 / 2
mov bh, 0 ; DisplayPage
mov ax, 0C02h ; AH=0Ch is BIOS.WritePixel, AL=2 is color green
int 10h
要绘制一条线,您需要在更改一个或两个坐标的同时重复绘制像素。下面是绘制垂直线 (100,50) - (100,150) 的示例。该线有 101 个像素 (150 - 50 + 1):
mov bh, 0 ; DisplayPage doesn't change
mov cx, 100 ; X is fixed for a vertical line
mov dx, 50 ; Y to start
More:
mov ax, 0C04h ; AH=0Ch is BIOS.WritePixel, AL=4 is color red
int 10h
inc dx ; Next Y
cmp dx, 150
jbe More
要绘制一个区域,您可以使用几个嵌套循环。下面的示例绘制了 (200,33) - (209,35) 之间的矩形。该区域有 30 个像素 (209 - 200 + 1) * (35 - 33 + 1):
mov si, Bitmap
mov bh, 0 ; DisplayPage doesn't change
mov dx, 33 ; Y to start
OuterLoop:
mov cx, 200 ; X to start
InnerLoop:
lodsb ; Fetch color for this pixel
mov ah, 0Ch ; AH=0Ch is BIOS.WritePixel
int 10h
inc cx ; Next X
cmp cx, 209
jbe InnerLoop
inc dx ; Next Y
cmp dx, 35
jbe OuterLoop
...
Bitmap: ; Just some blue and cyan pixels
db 1, 3, 1, 3, 1, 3, 1, 3, 1, 3
db 3, 1, 3, 1, 3, 1, 3, 1, 3, 1
db 1, 3, 1, 3, 1, 3, 1, 3, 1, 3