diff --git a/include/keyboard.h b/include/keyboard.h index 0684dd6..9a9cd6a 100755 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -29,5 +29,7 @@ #define STATUS_SCRL 0x4000 void keyboard(); +void reboot(); void outkbd(u8 port, u8 data); u8 waitascii(); +u8* getstring(u8* temp); diff --git a/include/types.h b/include/types.h index be5b73d..3273377 100755 --- a/include/types.h +++ b/include/types.h @@ -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 { diff --git a/lib/keyboard.c b/lib/keyboard.c index f6111e9..caf721c 100755 --- a/lib/keyboard.c +++ b/lib/keyboard.c @@ -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(); diff --git a/lib/string.c b/lib/string.c index 76a2293..a635a48 100755 --- a/lib/string.c +++ b/lib/string.c @@ -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; diff --git a/system/system.c b/system/system.c index 8377076..73a198a 100755 --- a/system/system.c +++ b/system/system.c @@ -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(); } }