我已经获得了一个任务,在那里我需要创建一个游戏使用emu8086。
但问题是我不知道怎么画雪碧。
有人能帮我向我解释精灵的创作吗?
发布于 2019-03-03 22:47:29
你能告诉我如何在emu8086上画画吗?
首先,您设置了图形视频模式。下一个代码选择320x200256颜色模式:
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 https://stackoverflow.com/questions/54937822
复制相似问题