fix: correction couleur EGA->VGA->RGB et erreur pilote VESA

This commit is contained in:
Nicolas Hordé 2018-10-14 11:14:34 +02:00
parent 03aa538dc9
commit 8863c798fc
7 changed files with 37 additions and 16 deletions

View File

@ -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);

View File

@ -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
{

View File

@ -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 */

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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();