Page 1 of 1

VGA mode 0x13 Y Axis issue

Posted: Thu Jan 23, 2025 11:13 am
by eclipsereal
hello, im making a basic os (im a beginner), im trying to use the 0x13 VGA mode (320x200), but the Y axis is 0-25, not 0-200, it like stretches? Here is how it looks:
Image

my code:

Code: Select all

void VGA_PUT_PIXEL(int x, int y, unsigned char color)
{
    unsigned char* location = (unsigned char*)0xA0000 + 320 * y + x;
    *location = color;
}

void VGA_CLEAR(unsigned char color)
{
    for (int x = 0; x < VGA_WIDTH; ++x)
    {
        for (int y = 0; y < VGA_HEIGHT; ++y)
        {
            VGA_PUT_PIXEL(x, y, color);
        }    
    }
}

void VGA_INIT()
{
    OUTB(0x3C2, 0x63);
    OUTW(0x3D4,0x0E11);
    OUTW(0x3D4,0x0008);
    OUTW(0x3D4,0x4014);
    OUTW(0x3D4,0xa317);
    OUTW(0x3C4,0x0e04);
    OUTW(0x3C4,0x0101);
    OUTW(0x3C4,0x0f02);
    OUTW(0x3Ce,0x4005);
    OUTW(0x3Ce,0x0506);
    INB(0x3DA);
    OUTB(0x3C0,0x30); 
    OUTB(0x3C0,0x41);
    OUTB(0x3C0,0x33); 
    OUTB(0x3C0,0x00);

    VGA_CLEAR(GET_VGA_COLOR(0x000));
}

void VGA_RECT(int _x, int _y, int width, int height, unsigned char color)
{
    for (int x = _x; x < _x + width; x++) {
        VGA_PUT_PIXEL(x, _y, color);
        VGA_PUT_PIXEL(x, _y + height - 1, color);
    }

    for (int y = _y; y < _y + height; y++) {
        VGA_PUT_PIXEL(_x, y, color);
        VGA_PUT_PIXEL(_x + width - 1, y, color);
    }
}

Code: Select all

VGA_RECT(0, 0, 320, 25, GET_VGA_COLOR(0xFFF));

Re: VGA mode 0x13 Y Axis issue

Posted: Thu Jan 23, 2025 9:26 pm
by Octocontrabass
Your VGA_INIT function doesn't set enough of the VGA registers to switch to mode 0x13 from whichever mode you're using before you call it.