我已经获得了我需要使用EMU8086创建游戏的作业。
但是问题是我不知道如何绘制精灵。
谁能通过向我解释Sprite的创作来帮助我?
您能告诉我如何利用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