Removing warnings in main.cpp and planning what will be the next steps.

This commit is contained in:
Némo 2017-02-12 15:46:09 +01:00
parent 261a1d004f
commit e37b2a0af7
5 changed files with 66 additions and 36 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
build/*
eigen.g1a

View File

@ -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);
void randomnum(void);

23
notes.txt Normal file
View File

@ -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

View File

@ -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));
}

View File

@ -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;
}}