From d0d125bbf82f4e991725335d66e2407cc2a5192f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 14 Oct 2018 19:14:19 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20changement=20de=20police=20a=20chaud=20?= =?UTF-8?q?en=20mode=20graphique=20et=20commande=20shell,=20reste=20=C3=A0?= =?UTF-8?q?=20implementer=20le=20mode=20texte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/shell.h | 1 + include/video.h | 14 ++++++++---- lib/shell.c | 15 +++++++++++++ lib/video.c | 57 +++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/include/shell.h b/include/shell.h index 296f448..51399db 100644 --- a/include/shell.h +++ b/include/shell.h @@ -23,5 +23,6 @@ int test(void); int disas(u8* commandline); int bpset(u8* commandline); int bpclr(u8* commandline); +int sfont(u8* commandline); int help(); int logo(); diff --git a/include/video.h b/include/video.h index 782720e..514e0b6 100755 --- a/include/video.h +++ b/include/video.h @@ -8,9 +8,7 @@ #include "stdarg.h" #define MAXDRIVERS 10 - -#define FONT8X16 0 -#define FONT8X8 1 +#define MAXFONTS 10 typedef struct videoinfos { u8 currentmode; @@ -56,12 +54,18 @@ typedef struct videofonction { void (*blink_disable) (); } videofonction __attribute__ ((packed)); - typedef struct drivers { u8* nom; videofonction* pointer; } drivers __attribute__ ((packed)); +typedef struct font { + u8 nom[8]; + u8* pointer; + u8 width; + u8 height; +} font __attribute__ ((packed)); + typedef struct capabilities { u8 modenumber; u16 width; @@ -103,6 +107,8 @@ void putchar(u8 thechar); void clearscreen(void); u16 getwidth(void); u16 getheight(void); +void loadfont(u8 *name,font* pointer,u8 width, u8 height); +void setfont(u8 *fontname); /* Fonctions de haut niveau */ u32 print(u8* string); diff --git a/lib/shell.c b/lib/shell.c index 0fd748c..f60dd4d 100644 --- a/lib/shell.c +++ b/lib/shell.c @@ -33,6 +33,7 @@ static command commands[] = { {"bpclr" , "", &bpclr}, {"help" , "", &help}, {"logo" , "", &logo}, + {"font" , "", &sfont}, }; /*******************************************************************************/ @@ -72,6 +73,20 @@ int test(void) return; } + +/*******************************************************************************/ +/* Change la police courante */ + +int sfont(u8* commandline) +{ + if (strgetnbitems(commandline, ' ') < 2) + { + print("Syntaxe de la commande FONT\r\nfont \33[32mpolice\r\n\r\n \33[32mpolice\33[0m\33[0m\33[25D\33[10C - \33[Nom de la police de caractere\r\n"); + return; + } + setfont(strgetpointeritem(commandline, ' ', 1)); +} + /*******************************************************************************/ /* Affiche le logo */ diff --git a/lib/video.c b/lib/video.c index 65d182d..6beb9da 100755 --- a/lib/video.c +++ b/lib/video.c @@ -4,15 +4,20 @@ #include "asm.h" #include "video.h" #include "stdarg.h" +#include "string.h" #include "VGA/8x8fnt.c" #include "VGA/8x16fnt.c" static drivers registred[MAXDRIVERS]; +static font fonts[MAXFONTS]; + static videoinfos *vinfo; static width,height; +static font* currentfont; + static console vc[8] = { {0x07, 0, 0, 0, 0, 0, 0, 0, true} , {0x07, 0, 0, 0, 0, 0, 0, 0, true} , @@ -202,8 +207,6 @@ void changemode(u8 mode) setvideo_mode(mode); vinfo=getvideo_info(); if (!vinfo->isgraphic) { - font_load(font8x8, 8, 1); - font_load(font8x16, 16, 0); width=vinfo->currentwidth; height=vinfo->currentheight; } @@ -212,6 +215,11 @@ void changemode(u8 mode) width=(vinfo->currentwidth>>3); height=(vinfo->currentheight>>3); } + for(u32 i=0;iheight; y++) { - pattern = font8x8[(thechar<<3) + y]; - for (x = 0; x < 8; x++) + pattern = currentfont->pointer[currentfont->height*thechar + y]; + for (x = 0; x < currentfont->width; x++) { rol(pattern); set = pattern & 0x1; @@ -1066,7 +1074,7 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib) - writepxl((coordx<<3) + x, (coordy<<3) + y, color); + writepxl(currentfont->width*coordx + x, currentfont->height*coordy + y, color); } } } @@ -1148,3 +1156,40 @@ void writepxl (u16 x, u16 y, u32 color) } } +/******************************************************************************/ +/* Chargement d'une police de caractère */ + +void loadfont(u8 *name,font* pointer,u8 width, u8 height) +{ + u32 i; + for(i=0;i