如何在emu8086中创建和绘制精灵? [英] How to create and draw sprites in emu8086?

查看:103
本文介绍了如何在emu8086中创建和绘制精灵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经获得了一个任务,需要使用emu8086来创建游戏.

I have obtained an assignment where I need to create a game using emu8086.

但是问题是我不知道如何绘制精灵.

But the problem is I don't know how to draw a sprite.

有人可以通过向我解释精灵创建来帮助我吗?

Can anyone help me by explaining sprite creation to me?

推荐答案

你能告诉我如何使用emu8086吗?

Can you tell me how to draw on emu8086 ?

首先,您设置图形视频模式.接下来的代码选择320x200 256色模式:

First you setup a graphics video mode. Next code selects the 320x200 256-color mode:

mov     ax, 0013h  ; AH=00h is BIOS.SetVideoMode, AL=13h is 320x200 mode
int     10h

现在,您可以绘制任何喜欢的像素.下面是在屏幕中央绘制单个像素的示例:

Now you can plot any pixel you like. Below is an example that plots a single pixel in the center of the screen:

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):

To draw a line you repeat plotting a pixel while changing one or both coordinates. Below is an example that draws the vertical line (100,50) - (100,150). This line has 101 pixels (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):

To plot an area you use a couple of nested loops. Below is an example that plots the rectangle between (200,33) - (209,35). This area has 30 pixels (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 

这篇关于如何在emu8086中创建和绘制精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆