5511emu その3


つぎに5511emuでプログラムを開発していきます。

f:id:tanam:20181231101756j:plain

上記CGA.EXEはMS-DOSLSI C-86 試食版を使って以下の手順で作成できます。

>lcc cga.c

cga.c

#include <dos.h>
#include <stdio.h>

unsigned char far *vram1 =(unsigned char far *)0xB8000000L;
unsigned char far *vram2 =(unsigned char far *)0xBA000000L;
unsigned char far *vram3 =(unsigned char far *)0xBC000000L;
unsigned char far *vram4 =(unsigned char far *)0xBE000000L;

void set_video_mode(unsigned char mode)
{
    union REGS in, out;
    in.h.ah = 0;
    in.h.al = mode;
    int86(0x10, &in, &out);
}

void plot_pixel(unsigned int x, unsigned int y, unsigned char color)
{
    vram1[y * 160 + x] = color*16+color;
    vram2[y * 160 + x] = color*16+color;
    vram3[y * 160 + x] = color*16+color;
    vram4[y * 160 + x] = color*16+color;
}

int main(int argc, char* argv[])
{
    unsigned int i, j;

    set_video_mode(0x09);

    for (i = 0; i < 160; i++) {
        for (j = 0; j < 50; j++) {
            plot_pixel(i, j, i/10);
        }
    }

    getc(stdin);
    return 0;
}