diff --git a/include/video.h b/include/video.h index 60e9b12..9d24cbc 100755 --- a/include/video.h +++ b/include/video.h @@ -94,6 +94,8 @@ u8 getattrib (u16 coordx, u16 coordy); void writepxl (u16 x, u16 y, u32 color); void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color); void changemode(u8 mode); +u32 vgatorgb(u8 ega); +u8 egatovga(u8 ega); /* Fonctions de console */ void changevc(u8 vc); diff --git a/lib/vesa.c b/lib/vesa.c index 93dd73d..139b6d0 100755 --- a/lib/vesa.c +++ b/lib/vesa.c @@ -115,7 +115,7 @@ u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) { if (!increment_src) { u32 pattern = (u32) src; - stosb(pattern,realdst,size); + stosd(pattern,realdst,size); } else { diff --git a/lib/video.c b/lib/video.c index 50c84d2..6f4555d 100755 --- a/lib/video.c +++ b/lib/video.c @@ -1053,15 +1053,11 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib) { set = pattern & 0x1; if (set == 0) - if (vinfo->currentdepth>24) - color = 0xFFFFFF; - else - color = ((attrib & 0xF0) >> 8); + color = egatovga((attrib & 0xF0) >> 8); else - if (vinfo->currentdepth>24) - color = 0; - else - color = (attrib & 0x0F); + color = egatovga(attrib & 0x0F); + if (vinfo->currentdepth==32) + color = vgatorgb(color); writepxl((coordx<<3) + x, (coordy<<3) + y, color); rol(pattern); } @@ -1069,7 +1065,27 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib) } } - +/******************************************************************************/ +/* Retourne une couleur RGB 32 bits depuis une couleur EGA/VGA */ + +static convertega[]={0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63}; + +u8 egatovga(u8 ega) +{ + return convertega[ega & 0xF]; +} + +/******************************************************************************/ +/* Retourne une couleur RGB 32 bits depuis une couleur EGA/VGA */ + +u32 vgatorgb(u8 vga) +{ + if (vga==0) return 0; + u8 red = 85 * (((vga >> 4) & 2) | (vga >> 2) & 1); + u8 green = 85 * (((vga >> 3) & 2) | (vga >> 1) & 1); + u8 blue = 85 * (((vga >> 2) & 2) | vga & 1); + return (red<<16)+(green<<8)+blue+(0x0<<24); +} /******************************************************************************/ /* Retourne le caractère du mode texte aux coordonnées spécifiées */ diff --git a/makefile b/makefile index e30649a..755d563 100755 --- a/makefile +++ b/makefile @@ -91,7 +91,7 @@ qemu-floppy: (killall qemu-system-i386;qemu-system-i386 -m 1G -fda ./final/floppy.img.final --enable-kvm -cpu host -s &) system/system.sys: - (cd system; make ARCH=$(ARCH)) + (cd system; VESA=$(VESA) make) boot/boot12.bin: (cd boot; make) diff --git a/system/makefile b/system/makefile index 9846154..642fbbf 100755 --- a/system/makefile +++ b/system/makefile @@ -12,7 +12,7 @@ system.o: $(GCC) system.o system.c multiboot.o: - $(ASM) -f elf -o multiboot.o multiboot.asm -dARCH=$(ARCH) + $(ASM) -f elf -o multiboot.o multiboot.asm -dVESA=$(VESA) clean: rm -f *.o diff --git a/system/multiboot.asm b/system/multiboot.asm index 055cebf..49e2ee6 100644 --- a/system/multiboot.asm +++ b/system/multiboot.asm @@ -19,7 +19,7 @@ SECTION .multiboot %define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2 -%defstr arch ARCH +%defstr vesa VESA multiboot_header: align MULTIBOOT_TAG_ALIGN @@ -28,6 +28,9 @@ align MULTIBOOT_TAG_ALIGN dd multiboot_header_end - multiboot_header dd -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header)) align MULTIBOOT_TAG_ALIGN +%if vesa = "no" +%warning "Avec la console VGA/EGA." +%else framebuffer_tag_start: %warning "Avec le FRAMEBUFFER VESA." dw MULTIBOOT_HEADER_TAG_FRAMEBUFFER ; type @@ -38,11 +41,11 @@ framebuffer_tag_start: dd 32 ; depth align MULTIBOOT_TAG_ALIGN framebuffer_tag_end: +%endif dw MULTIBOOT_HEADER_TAG_END dw 0 dd 8 multiboot_header_end: - SECTION .text global start diff --git a/system/system.c b/system/system.c index ac50903..91d977b 100755 --- a/system/system.c +++ b/system/system.c @@ -52,11 +52,11 @@ int main(u32 magic, u32 addr) registerdriver(&vgafonctions); registerdriver(&vesafonctions); apply_bestdriver(); - changemode(0x0); + changemode(0x1); /* Efface l'ecran */ print("\033[2J\r\n\000"); - if (getwidth()==80) print(ansilogo); + print(ansilogo); print("\033[37m\033[0m -Chargement noyaux"); ok();