Thanks for replies.
I've decided to use VBE mode 800x600x16. I've set this in my bootsector as follows:
Code:
mov ax, 0 ;segment 0
mov es, ax
mov di, 0x1000 ;offset 1000
mov ax, 0x4F01 ;get VBE mode information block
mov cx, 0x4114 ;graphic mode 800x600 16 bpp
int 0x10 ;load informations
;set VESA video mode
mov ax, 0x4F02 ;set VBE graphic mode
mov bx, 0x4114 ;graphic mode 800x600 16bpp
int 0x10 ;start BIOS interrupt
My code for setting up VESA:
Code:
void read_vesa_info(void) {
uint32_t *vesablockd = (uint32_t *) 0x1000; //position of Vesa Mode Info Block loaded by bootloader dword read
uint16_t *vesablockw = (uint16_t *) 0x1000; //position of Vesa Mode Info Block loaded by bootloader word read
uint8_t *vesablockb = (uint8_t *) 0x1000; //position of Vesa Mode Info Block loaded by bootloader byte read
vesa_lfb=vesablockd[10]; //Linear Frame Buffer position
vesa_x=vesablockw[9];
vesa_y=vesablockw[10];
vesa_bpp=vesablockb[23];
}
//putpixel function
void pixel(int line, int column, uint16_t color) {
uint16_t *pixel = (uint16_t*) vesa_lfb + line * vesa_x + column; //start of frame buffer
pixel = color;
}
I'm sure that this functions work, because I've tried to draw a line and it has worked. But when I try to draw the letter 'A' that is stored in an array, nothing is being printed!!
Code:
static const int a_ch[128] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,1,0,0,0,0,
0,0,1,1,1,0,0,0,
0,1,1,0,1,1,0,0,
1,1,0,0,0,1,1,0,
1,1,0,0,0,1,1,0,
1,1,1,1,1,1,1,0,
1,1,0,0,0,1,1,0,
1,1,0,0,0,1,1,0,
1,1,0,0,0,1,1,0,
1,1,0,0,0,1,1,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
};
//zeros are blacks, ones are white
for (int r = line; r < line + 16; r++) {
for (int c = column; c < column + 8; c++) {
if (a_ch[index] == 0) pixel(r, c, WHITE);
if (a_ch[index] == 1) pixel(r, c, BLACK);
index++;
}
}
col+=8;
This function would read the array and fill the pixels, but it doesn't. What am I doing wrong?
P.S. WHITE = 0xFFFF and BLACK = 0x0000, remember that the screen is filled WHITE.
P.P.S. the code for printing the letter A is in a function, where column and line are set to 10.