feat: changement de police a chaud en mode graphique et commande shell, reste à implementer le mode texte
This commit is contained in:
parent
660ce13fdf
commit
d0d125bbf8
|
@ -23,5 +23,6 @@ int test(void);
|
||||||
int disas(u8* commandline);
|
int disas(u8* commandline);
|
||||||
int bpset(u8* commandline);
|
int bpset(u8* commandline);
|
||||||
int bpclr(u8* commandline);
|
int bpclr(u8* commandline);
|
||||||
|
int sfont(u8* commandline);
|
||||||
int help();
|
int help();
|
||||||
int logo();
|
int logo();
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
|
|
||||||
#define MAXDRIVERS 10
|
#define MAXDRIVERS 10
|
||||||
|
#define MAXFONTS 10
|
||||||
#define FONT8X16 0
|
|
||||||
#define FONT8X8 1
|
|
||||||
|
|
||||||
typedef struct videoinfos {
|
typedef struct videoinfos {
|
||||||
u8 currentmode;
|
u8 currentmode;
|
||||||
|
@ -56,12 +54,18 @@ typedef struct videofonction {
|
||||||
void (*blink_disable) ();
|
void (*blink_disable) ();
|
||||||
} videofonction __attribute__ ((packed));
|
} videofonction __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
typedef struct drivers {
|
typedef struct drivers {
|
||||||
u8* nom;
|
u8* nom;
|
||||||
videofonction* pointer;
|
videofonction* pointer;
|
||||||
} drivers __attribute__ ((packed));
|
} drivers __attribute__ ((packed));
|
||||||
|
|
||||||
|
typedef struct font {
|
||||||
|
u8 nom[8];
|
||||||
|
u8* pointer;
|
||||||
|
u8 width;
|
||||||
|
u8 height;
|
||||||
|
} font __attribute__ ((packed));
|
||||||
|
|
||||||
typedef struct capabilities {
|
typedef struct capabilities {
|
||||||
u8 modenumber;
|
u8 modenumber;
|
||||||
u16 width;
|
u16 width;
|
||||||
|
@ -103,6 +107,8 @@ void putchar(u8 thechar);
|
||||||
void clearscreen(void);
|
void clearscreen(void);
|
||||||
u16 getwidth(void);
|
u16 getwidth(void);
|
||||||
u16 getheight(void);
|
u16 getheight(void);
|
||||||
|
void loadfont(u8 *name,font* pointer,u8 width, u8 height);
|
||||||
|
void setfont(u8 *fontname);
|
||||||
|
|
||||||
/* Fonctions de haut niveau */
|
/* Fonctions de haut niveau */
|
||||||
u32 print(u8* string);
|
u32 print(u8* string);
|
||||||
|
|
15
lib/shell.c
15
lib/shell.c
|
@ -33,6 +33,7 @@ static command commands[] = {
|
||||||
{"bpclr" , "", &bpclr},
|
{"bpclr" , "", &bpclr},
|
||||||
{"help" , "", &help},
|
{"help" , "", &help},
|
||||||
{"logo" , "", &logo},
|
{"logo" , "", &logo},
|
||||||
|
{"font" , "", &sfont},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************/
|
/*******************************************************************************/
|
||||||
|
@ -72,6 +73,20 @@ int test(void)
|
||||||
return;
|
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 */
|
/* Affiche le logo */
|
||||||
|
|
||||||
|
|
57
lib/video.c
57
lib/video.c
|
@ -4,15 +4,20 @@
|
||||||
#include "asm.h"
|
#include "asm.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
|
#include "string.h"
|
||||||
#include "VGA/8x8fnt.c"
|
#include "VGA/8x8fnt.c"
|
||||||
#include "VGA/8x16fnt.c"
|
#include "VGA/8x16fnt.c"
|
||||||
|
|
||||||
static drivers registred[MAXDRIVERS];
|
static drivers registred[MAXDRIVERS];
|
||||||
|
|
||||||
|
static font fonts[MAXFONTS];
|
||||||
|
|
||||||
static videoinfos *vinfo;
|
static videoinfos *vinfo;
|
||||||
|
|
||||||
static width,height;
|
static width,height;
|
||||||
|
|
||||||
|
static font* currentfont;
|
||||||
|
|
||||||
static console vc[8] = {
|
static console vc[8] = {
|
||||||
{0x07, 0, 0, 0, 0, 0, 0, 0, true} ,
|
{0x07, 0, 0, 0, 0, 0, 0, 0, true} ,
|
||||||
{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);
|
setvideo_mode(mode);
|
||||||
vinfo=getvideo_info();
|
vinfo=getvideo_info();
|
||||||
if (!vinfo->isgraphic) {
|
if (!vinfo->isgraphic) {
|
||||||
font_load(font8x8, 8, 1);
|
|
||||||
font_load(font8x16, 16, 0);
|
|
||||||
width=vinfo->currentwidth;
|
width=vinfo->currentwidth;
|
||||||
height=vinfo->currentheight;
|
height=vinfo->currentheight;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +215,11 @@ void changemode(u8 mode)
|
||||||
width=(vinfo->currentwidth>>3);
|
width=(vinfo->currentwidth>>3);
|
||||||
height=(vinfo->currentheight>>3);
|
height=(vinfo->currentheight>>3);
|
||||||
}
|
}
|
||||||
|
for(u32 i=0;i<MAXFONTS;i++)
|
||||||
|
fonts[i].nom[0]=NULL;
|
||||||
|
loadfont("BIOS1",font8x8,8,8);
|
||||||
|
loadfont("BIOS0",font8x16,8,16);
|
||||||
|
setfont("BIOS1");
|
||||||
clearscreen();
|
clearscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,10 +1054,10 @@ void showchar(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (y = 0; y < 8; y++)
|
for (y = 0; y < currentfont->height; y++)
|
||||||
{
|
{
|
||||||
pattern = font8x8[(thechar<<3) + y];
|
pattern = currentfont->pointer[currentfont->height*thechar + y];
|
||||||
for (x = 0; x < 8; x++)
|
for (x = 0; x < currentfont->width; x++)
|
||||||
{
|
{
|
||||||
rol(pattern);
|
rol(pattern);
|
||||||
set = pattern & 0x1;
|
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<MAXFONTS;i++)
|
||||||
|
if (fonts[i].nom[0]!=NULL && fonts[i].pointer==pointer)
|
||||||
|
return;
|
||||||
|
i=0;
|
||||||
|
while (fonts[i].nom[0]!=NULL && i<MAXFONTS)
|
||||||
|
i++;
|
||||||
|
fonts[i].pointer=pointer;
|
||||||
|
strcpy(name,fonts[i].nom);
|
||||||
|
fonts[i].width=width;
|
||||||
|
fonts[i].height=height;
|
||||||
|
if (fonts[i].nom[0]=='B' && fonts[i].nom[1]=='I' && fonts[i].nom[2]=='O' && fonts[i].nom[3]=='S')
|
||||||
|
{
|
||||||
|
u8 number=(fonts[i].nom[4]-'0');
|
||||||
|
font_load(pointer, number, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* Changement de la police */
|
||||||
|
|
||||||
|
void setfont(u8 *fontname)
|
||||||
|
{
|
||||||
|
u32 i=0;
|
||||||
|
while (fonts[i].nom!=NULL && i<MAXFONTS) {
|
||||||
|
if (strcmp(fontname,fonts[i].nom)==0) {
|
||||||
|
currentfont=&fonts[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue