From e37b2a0af7ad4a36629ad33f4c9a7bf050b44b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9mo?= Date: Sun, 12 Feb 2017 15:46:09 +0100 Subject: [PATCH] Removing warnings in main.cpp and planning what will be the next steps. --- .gitignore | 1 + include/prototypes.h | 4 +-- notes.txt | 23 +++++++++++++++++ src/config.c | 14 +++++++---- src/main.cpp | 60 +++++++++++++++++++++++--------------------- 5 files changed, 66 insertions(+), 36 deletions(-) create mode 100644 notes.txt diff --git a/.gitignore b/.gitignore index a007fea..09dd52a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/* +eigen.g1a diff --git a/include/prototypes.h b/include/prototypes.h index 611c6f4..aa782cf 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -596,7 +596,7 @@ void mag(void); void yymag(void); void test_mag(void); -// main.cpp +// main_engine.cpp int main(); void clear_term(); void eval_display(void); @@ -996,4 +996,4 @@ void test_zero(void); // random.cpp - by gbl08ma void eval_random(void); -void randomnum(void); \ No newline at end of file +void randomnum(void); diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..9424735 --- /dev/null +++ b/notes.txt @@ -0,0 +1,23 @@ +Some notes sorting out some aspects of the operating of Eigenmath + +In the main loop : + - We get some text + - We run it + - We open a new line + + +Runing (run.cpp) means : + - scan (scan.cpp) the input string which leads to p (the thing we want to evaluate) being on top of the internal stack. + - various tests are performed in run(⋅) to handle some "trivial" cases, but most of the time, p stays on top of the stack and eval() (eval.cpp) is called. + - r, the result is now on top of the stack + - r is then displayed, mostly via display(⋅) (display.cpp) -> printline(⋅) (print.cpp) + - printline(⋅) and its subroutines use the printchar(⋅) "primitive" (defined in main_engine.cpp) which is a direct call to Console_Output(⋅). + + + +Plan : + -> remove any use of Console_* functions in print(⋅) (rely only on the printchar(⋅)) + ( -> maybe don't output any tex for the time ? ) + -> create a new console system ; external usage + * open a new line / tex object + * print stuff on the current line diff --git a/src/config.c b/src/config.c index 544ed4f..c920494 100644 --- a/src/config.c +++ b/src/config.c @@ -16,9 +16,11 @@ int test; void draw_menu(Menu* menu) { - int x, y, i, key; + int x, y, i; + unsigned int key; int longest = 0, tmp; - int border = 1, margin = 2, check_box_width = 15, item_height = 7, letter_width = 4;// inter_line = 1; + int border = 1, margin = 2, check_box_width = 15; + int item_height = 7, letter_width = 4; int cursor_y = 0; DISPBOX box; @@ -31,14 +33,15 @@ void draw_menu(Menu* menu) box.left = (WIDTH/2) - (longest/2) - margin - border; box.right = box.left + longest + 2*margin + 2*border; - box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 /*+ margin*/ + border; + box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 + border; box.top = HEIGHT - box.bottom; Bdisp_AreaClr_VRAM(&box); Bdisp_AreaReverseVRAM(box.left, box.top, box.right, box.bottom); - Bdisp_AreaReverseVRAM(box.left + border, box.top + border, box.right - border, box.bottom - border); + Bdisp_AreaReverseVRAM(box.left + border, box.top + border, + box.right - border, box.bottom - border); while (key != KEY_CTRL_EXIT) { for(i=0; i < menu->items_number; i++) { @@ -148,5 +151,6 @@ void save_config() void load_config() { - if(memory_exists(CONFIG_FILE)) *(int*)(get_tex_flag_address()) = *((int*)memory_load(CONFIG_FILE)); + if(memory_exists(CONFIG_FILE)) + *(int*)(get_tex_flag_address()) = *((int*)memory_load(CONFIG_FILE)); } diff --git a/src/main.cpp b/src/main.cpp index 989e5bc..99931bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,14 +11,13 @@ extern "C"{ #include "config.h" #define EXPR_BUF_SIZE 256 -#define USER_FUNCTIONS "\\\\fls0\\USER.eig" -#define USER_FUNCTIONS_MAX_LENGTH 200 +#define USER_FUNCTIONS (char*)"\\\\fls0\\USER.eig" +#define USER_FUNCTIONS_MAX_LENGTH 200*sizeof(unsigned char) extern U ** mem; extern unsigned int **free_stack; -int -initialize_tuamath() +void initialize_tuamath() { // modified by anderain free_stack = (unsigned int**) calloc(500,sizeof(unsigned int*)); @@ -32,12 +31,12 @@ initialize_tuamath() void TeX_init(void) { - Txt_Init(FONT_SYSTEM); + Txt_Init(FONT_SYSTEM); } void TeX_quit(void) { - Txt_Quit(); + Txt_Quit(); } const /*unsigned*/ char *Setup[]={ @@ -66,13 +65,13 @@ const /*unsigned*/ char *Setup[]={ int main(void) { - unsigned int key; + unsigned int key; unsigned char *expr; unsigned char *user_functions; - int i = 0, j = 0; + unsigned int i = 0, j = 0; - unsigned char *line = (unsigned char *)malloc(USER_FUNCTIONS_MAX_LENGTH*sizeof(unsigned char)); + unsigned char *line = (unsigned char *)malloc(USER_FUNCTIONS_MAX_LENGTH); initialize_tuamath(); @@ -81,19 +80,18 @@ int main(void) Console_Disp(); load_config(); - // initialize failed ? - if (!(line && free_stack && mem && stack && symtab && binding && arglist && logbuf)) - return 0; + /* Has initialisation failed ? */ + if ( !(line && free_stack && mem && stack && symtab && binding + && arglist && logbuf) ) return 0; - while(Setup[i] != NULL) { - run((char *)Setup[i++]); - } + while(Setup[i] != NULL) run((char *)Setup[i++]); i = 0; user_functions = (unsigned char*)memory_load(USER_FUNCTIONS); - // Just extracting each line of the file containing user functions and running them one by one + /* We extracting each line of the file containing user functions and + * we running them one by one */ if(user_functions != NULL) { int line_count = 0; @@ -101,25 +99,26 @@ int main(void) j = 0; line_count++; - memset(line, '\0', USER_FUNCTIONS_MAX_LENGTH * sizeof(unsigned char)); + memset(line, '\0', USER_FUNCTIONS_MAX_LENGTH); - while (i < strlen((char*)user_functions) && j < USER_FUNCTIONS_MAX_LENGTH + while (i < strlen((char*)user_functions) + && j < USER_FUNCTIONS_MAX_LENGTH && user_functions[i] != '\n' && user_functions[i] != '\r' - && user_functions[i] != '\0') { - line[j++] = user_functions[i++]; - } + && user_functions[i] != '\0') + line[j++] = user_functions[i++]; + run((char *)line); - // Printing the error message if needed + /* Printing the error message if needed */ if(Console_GetEditLine()[0] != '\0') { - char line_number[15] = ""; // That should be enough... + char line_number[15] = ""; /* It should be enough */ - // Printing the actual error message + /* Printing the actual error message */ Console_NewLine(LINE_TYPE_OUTPUT,1); - // More details on where the error is + /* Printing more details on where the error actually is */ Console_Output((unsigned char*)"\xE6\x92 USER.eig line : "); sprintf(line_number, "%d", line_count); strcat(line_number, " "); @@ -141,15 +140,18 @@ int main(void) while(1) { - if((expr=Console_GetLine())==NULL) stop("memory error"); + if((expr=Console_GetLine())==NULL) stop((char*)"memory error"); run((char *)expr); //print_mem_info(); - Console_NewLine(LINE_TYPE_OUTPUT,1); + print_str("Bonjour le monde"); + //Console_NewLine(LINE_TYPE_OUTPUT,1); //GetKey(&key); Console_Disp(); } TeX_quit(); - for(;;)GetKey(&key); - return 1; + + for(;;) GetKey(&key); + + return 1; }}