switch to graphic move from "C" like this
Code: Select all
#define VBE_DISPI_IOPORT_INDEX 0x01CE
#define VBE_DISPI_IOPORT_DATA 0x01CF
#define VBE_DISPI_INDEX_ID 0x0
#define VBE_DISPI_INDEX_XRES 0x1
#define VBE_DISPI_INDEX_YRES 0x2
#define VBE_DISPI_INDEX_BPP 0x3
#define VBE_DISPI_INDEX_ENABLE 0x4
#define VBE_DISPI_INDEX_BANK 0x5
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
#define VBE_DISPI_INDEX_X_OFFSET 0x8
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
#define VBE_DISPI_DISABLED 0x00
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_GETCAPS 0x02
#define VBE_DISPI_8BIT_DAC 0x20
#define VBE_DISPI_LFB_ENABLED 0x40
#define VBE_DISPI_NOCLEARMEM 0x80
void vbe_write( uint16_t index, uint16_t value) {
// http://wiki.osdev.org/VGA_Hardware#Memory_Layout_in_16-color_graphics_modes
outw(VBE_DISPI_IOPORT_INDEX, index);
outw(VBE_DISPI_IOPORT_DATA, value);
}
void vbe_set( uint16_t xres, uint16_t yres, uint16_t bpp) {
// http://wiki.osdev.org/VGA_Hardware#Memory_Layout_in_16-color_graphics_modes
vbe_write(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
vbe_write(VBE_DISPI_INDEX_XRES, xres);
vbe_write(VBE_DISPI_INDEX_YRES, yres);
vbe_write(VBE_DISPI_INDEX_BPP, bpp);
vbe_write(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
}
// ---------------------------------------------------------------
screenWidth = 640;
screenHeight = 480;
uint32_t ppb = 16;
vbe_set( screenWidth, screenHeight, ppb ); // Vga is limited to a 640x480x16
Code: Select all
MBALIGN equ 1<<0 ; // align loaded modules on page boundaries
MEMINFO equ 1<<1 ; // provide memory map
;VIDMOD equ 1<<2 ; // information about the video mode table must be available to the kernel.
;ELF_OR equ 1<<16 ; // must be providet if kernel is not ELF
FLAGS equ MBALIGN | MEMINFO; | VIDMOD
MAGIC equ 0x1BADB002 ; // 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS) ; // checksum of above, to prove we are multiboot
; Vga is limited to a 640x480x16
section .text
dd MAGIC
dd FLAGS
dd CHECKSUM
dd 0 ; 12 u32 header_addr if flags[16] is set
dd 0 ; 16 u32 load_addr if flags[16] is set
dd 0 ; 20 u32 load_end_addr if flags[16] is set
dd 0 ; 24 u32 bss_end_addr if flags[16] is set
dd 0 ; 28 u32 entry_addr if flags[16] is set
dd 0 ; 32 u32 mode_type if flags[2] is set
dd 640 ; 36 u32 width if flags[2] is set
dd 480 ; 40 u32 height if flags[2] is set
dd 16 ; 44 u32 depth if flags[2] is set
;dd 1 ; 32 u32 mode_type if flags[2] is set
;dd 80 ; 36 u32 width if flags[2] is set
;dd 25 ; 40 u32 height if flags[2] is set
;dd 0 ; 44 u32 depth if flags[2] is set
The mode im using: [640x480x16]. It does not matter,which mode im using, the result is th same, just colors are different, because of bits per pixel is wrong. bud it is not important for the moment.
Code: Select all
uint16_t Y = 1, i = 0;
uint16_t * screen = (uint16_t *) 0xA0000;
while ( i < 640 * 480 * 32 ) {
unsigned where = (i*4) + Y*3200;
screen[ where ] = 0b01111111;
screen[ where + 1] = 0;
i++;
}