feat: ajout interpréteur de commande & fonctions clavier essentielles

This commit is contained in:
Nicolas Hordé 2018-08-21 08:26:35 +02:00
parent aeeb371294
commit 2ce9d70b48
5 changed files with 40 additions and 26 deletions

View File

@ -29,5 +29,7 @@
#define STATUS_SCRL 0x4000
void keyboard();
void reboot();
void outkbd(u8 port, u8 data);
u8 waitascii();
u8* getstring(u8* temp);

View File

@ -10,9 +10,9 @@ typedef int s32;
typedef int bool;
#define true -1;
#define false 0;
#define NULL 0x0000;
#define true 1
#define false 0
#define NULL 0x0000
struct dtr {

View File

@ -94,11 +94,33 @@ static const u8 set1_ctrl[] = {
/******************************************************************************/
/* Attend une chaine de caractère de taille max */
u8* getstring(u8* temp) {
u8 maxwidth=strlen(temp);
u8 *pointer=temp;
u8 ascii=0;
while(ascii!='\r') {
ascii=waitascii();
if (ascii=='\b' && pointer>temp) {
pointer--;
putchar(ascii);
}
else if (ascii>31 && pointer<=&temp+80) {
*pointer++=ascii;
putchar(ascii);
}
}
*pointer='\000';
return temp;
}
/******************************************************************************/
/* Fonction qui attend l'appuie d'une touche générant un code ASCII puis le retourne */
u8 waitascii()
{
u8 oldptrscan = ptrscan;
u8 oldptrascii = ptrascii;
while ((oldptrascii == ptrascii)) ;
return bufferascii[ptrascii];
@ -128,7 +150,7 @@ void outkbd(u8 port, u8 data)
/* Redemarre l'ordinateur */
static void reboot(void)
void reboot()
{
u8 temp;
cli();

View File

@ -376,7 +376,7 @@ u8 strgetbase(u8 *src) {
/******************************************************************************/
/* Renvoie la base du nombre */
/* Transforme une chaine en nombre */
u32 strtoint(u8 *src) {
u8* temp=src;

View File

@ -82,26 +82,16 @@ int main(void)
&cpu.techs);
ok();
u8 test[]="0101011101b\000";
u8 test2[]="12106567h\000";
u8 test3[]="11A1baA7d\000";
u8 test4[]="11454589d\000";
u8 test5[]="0x11A1b7\000";
u8 test6[]="0x11A1B7h\000";
u8 test7[]="129220\000";
u8 dest[]=" \000";
u8 src[]="Ceci est un test pour voir si cela fonctionne correctement\000 ";
printf(&src);
strtoint(&test);
strtoint(&test2);
strtoint(&test3);
strtoint(&test4);
strtoint(&test5);
strtoint(&test6);
strtoint(&test7);
while (1) {
key = waitascii();
putchar(key);
static u8 field[]=" \000";
static u8 item[]=" \000";
static u8 cmd_reboot[]="REBOOT\000";
while (true) {
print("\r\n# ");
getstring(&field);
if (strgetnbitems(&field,' ')<1) continue;
strgetitem(&field, &item, ' ', 0);
strtoupper(&item);
if (strcmp(&item,&cmd_reboot)==0) reboot();
}
}