I'm right now programming a game for MS DOS using mode 13h of the VGA card. I'm using DJGPP as my compiler. The following problem is with my Display class. I've originally used _farpokeb() to copy my buffer (which is an array with the size of the entire screen) byte by byte to the VGA card's VRAM. But, since this is increibly slow (due to copying it bytewise and because _farpokeb() apparently is slow), I've decided to just copy the array to VRAM in one go. This does compile and run, but the screen just stays black. can somebody help me?
#include "Display.h"
Display::Display()
{
backBuffer = new byte[screenHeight * screenWidth];
}
Display::~Display()
{
delete[] backBuffer;
}
void Display::SwapBuffers()
{
memcpy(VGA, backBuffer, screenWidth * screenHeight);
}
bool Display::IsVBlank()
{
return ((inportb(0x3da) & 0x08) != 0);
}
void Display::SetVideoMode(byte mode)
{
__dpmi_regs r;
r.x.ax = mode;
__dpmi_int(0x10, &r);
}
void Display::SetPixel(int x, int y, byte color)
{
int address = y * 320 + x;
if(address < 64000)
{
backBuffer[address] = color;
}
}
void Display::ClearBackground()
{
memset(backBuffer, 0x00, screenWidth * screenHeight);
}
void Display::DrawBitmap(int x, int y, byte bitmap[], int lines, int columns)
{
for (int i = 0; i < lines*columns ; i++)
{
if (bitmap[i] != 0xff)
{
SetPixel(x + (i % columns), y + (i / columns), bitmap[i]);
}
}
}
void Display::FrameUpdate(Scene *scene)
{
ClearBackground();
for(Entity* e : scene->outlinerLayer0)
{
DrawBitmap(e->position.x, e->position.y, (byte*)e->sprite.texture[0], e->sprite.lines, e->sprite.columns);
}
for(Entity* e : scene->outlinerLayer1)
{
DrawBitmap(e->position.x, e->position.y, (byte*)e->sprite.texture[0], e->sprite.lines, e->sprite.columns);
}
for(Entity* e : scene->outlinerLayer2)
{
DrawBitmap(e->position.x, e->position.y, (byte*)e->sprite.texture[0], e->sprite.lines, e->sprite.columns);
}
for(Entity* e : scene->outlinerLayer3)
{
DrawBitmap(e->position.x, e->position.y, (byte*)e->sprite.texture[0], e->sprite.lines, e->sprite.columns);
}
}