From 09e4ebbb38f4cc8ee929134c19dcd776b92aaf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 14 Oct 2018 16:18:51 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20correction=20conversion=20EGA->RGB=20et?= =?UTF-8?q?=20decodage=20caract=C3=A8re...Reste=20bogue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/shell.h | 1 + include/video.h | 2 +- {system => lib/VGA}/ansi.c | 2 +- lib/shell.c | 11 +++++++++++ lib/video.c | 27 ++++++++++++++++----------- system/system.c | 3 +-- 6 files changed, 31 insertions(+), 15 deletions(-) rename {system => lib/VGA}/ansi.c (99%) diff --git a/include/shell.h b/include/shell.h index b1bda42..296f448 100644 --- a/include/shell.h +++ b/include/shell.h @@ -24,3 +24,4 @@ int disas(u8* commandline); int bpset(u8* commandline); int bpclr(u8* commandline); int help(); +int logo(); diff --git a/include/video.h b/include/video.h index 9d24cbc..782720e 100755 --- a/include/video.h +++ b/include/video.h @@ -94,7 +94,7 @@ 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); +u32 egatorgb(u8 ega); u8 egatovga(u8 ega); /* Fonctions de console */ diff --git a/system/ansi.c b/lib/VGA/ansi.c similarity index 99% rename from system/ansi.c rename to lib/VGA/ansi.c index e808da5..ea46b25 100644 --- a/system/ansi.c +++ b/lib/VGA/ansi.c @@ -30,4 +30,4 @@ u8 ansilogo[]="\ \xB3\033[0m\033[6C\033[1mF1-F8\033[30m Consoles virtuelles \033[37mF9\033[30m Debug \033[37mF10\033[30m Mode graphique \033[37mF11\033[30m Aide\033[0m\033[9C\033[1;30m\xB3\r\n\ \xB3\033[0m\033[77C\033[1;30m\xB3\r\n\ \xB3\033[0m Developpe par \033[5;1;47mMrNop\033[0m\033[55C\xB3\r\n\ -\xC0\033[1;30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\033[0m\xC4\033[1;30m\xC4\033[0m\xC4\xC4\033[1m\xD9\r\n\r\n"; +\xC0\033[1;30m\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\033[0m\xC4\033[1;30m\xC4\033[0m\xC4\xC4\033[1m\xD9\033[0m\r\n\r\n"; diff --git a/lib/shell.c b/lib/shell.c index d50f29c..0fd748c 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -13,6 +13,7 @@ #include "multiboot2.h" #include "math.h" #include "debug.h" +#include "VGA/ansi.c" static command commands[] = { {"reboot" , "", &rebootnow}, @@ -31,6 +32,7 @@ static command commands[] = { {"bpset" , "", &bpset}, {"bpclr" , "", &bpclr}, {"help" , "", &help}, + {"logo" , "", &logo}, }; /*******************************************************************************/ @@ -70,6 +72,15 @@ int test(void) return; } +/*******************************************************************************/ +/* Affiche le logo */ + +int logo() +{ + print(ansilogo); + return; +} + /*******************************************************************************/ /* Renvoie les commandes disponibles */ diff --git a/lib/video.c b/lib/video.c index 6f4555d..d7865de 100755 --- a/lib/video.c +++ b/lib/video.c @@ -1051,15 +1051,22 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib) pattern = font8x8[(thechar<<3) + y]; for (x = 0; x < 8; x++) { + rol(pattern); set = pattern & 0x1; if (set == 0) - color = egatovga((attrib & 0xF0) >> 8); + if (vinfo->currentdepth==32) + color = egatorgb((attrib & 0xF0) >> 8); + else + color = egatovga((attrib & 0xF0) >> 8); else - color = egatovga(attrib & 0x0F); - if (vinfo->currentdepth==32) - color = vgatorgb(color); + if (vinfo->currentdepth==32) + color = egatorgb(attrib & 0x0F); + else + color = egatovga(attrib & 0x0F); + + + writepxl((coordx<<3) + x, (coordy<<3) + y, color); - rol(pattern); } } } @@ -1078,13 +1085,11 @@ u8 egatovga(u8 ega) /******************************************************************************/ /* Retourne une couleur RGB 32 bits depuis une couleur EGA/VGA */ -u32 vgatorgb(u8 vga) +static convertrgb[]={0x000000,0x0000AA,0x00AA00,0x00AAAA,0xAA0000,0xAA00AA,0xAA5500,0xAAAAAA,0x555555,0x5555FF,0x55FF55,0x55FFFF,0xFF5555,0xFF55FF,0xFFFF55,0xFFFFFF}; + +u32 egatorgb(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); + return convertrgb[vga & 0xF]; } /******************************************************************************/ diff --git a/system/system.c b/system/system.c index 5154152..db13716 100755 --- a/system/system.c +++ b/system/system.c @@ -12,7 +12,6 @@ #include "cpu.h" #include "string.h" #include "2d.h" -#include "ansi.c" #include "gdt.h" #include "shell.h" #include "syscall.h" @@ -56,7 +55,7 @@ int main(u32 magic, u32 addr) /* Efface l'ecran */ print("\033[2J\r\n\000"); - print(ansilogo); + logo(); print("\033[37m\033[0m -Chargement noyaux"); ok();