2019-09-20 13:22:16 +02:00
|
|
|
#include <gint/exc.h>
|
|
|
|
#include <gint/keyboard.h>
|
2019-09-18 17:44:47 +02:00
|
|
|
#include <gint/display.h>
|
2019-09-20 13:22:16 +02:00
|
|
|
#include <gint/std/stdlib.h>
|
|
|
|
#include <gint/defs/attributes.h>
|
|
|
|
#include <liblog.h>
|
|
|
|
|
|
|
|
#ifdef FX9860G
|
|
|
|
|
|
|
|
#define MAX_LENGHT 21
|
|
|
|
#define WIDTH 8
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef FXCG50
|
|
|
|
|
|
|
|
#define MAX_LENGHT 150
|
|
|
|
#define WIDTH 17
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct log_line log_line;
|
|
|
|
typedef struct log_line
|
|
|
|
{
|
|
|
|
void* previous;
|
|
|
|
#ifdef FXCG50
|
|
|
|
char text[MAX_LENGHT];
|
|
|
|
#endif
|
|
|
|
#ifdef FX9860G
|
|
|
|
char text[MAX_LENGHT];
|
|
|
|
#endif
|
|
|
|
void* next;
|
|
|
|
} log_line;
|
|
|
|
|
|
|
|
|
|
|
|
static log_line first_line=
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
0,
|
|
|
|
"<Log beginning>",
|
|
|
|
0
|
2019-09-18 17:44:47 +02:00
|
|
|
};
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
static log_line* current_line=&first_line;
|
|
|
|
|
|
|
|
static log_line* add_line()
|
|
|
|
{
|
|
|
|
current_line->next = malloc(sizeof(log_line));
|
|
|
|
log_line* previous = current_line;
|
|
|
|
current_line = current_line->next;
|
|
|
|
current_line->previous=previous;
|
|
|
|
current_line->next=0;
|
|
|
|
current_line->text[0]=' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clear_log()
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
while (current_line->previous)
|
|
|
|
{
|
|
|
|
log_line* next=current_line->previous;
|
|
|
|
free(current_line);
|
|
|
|
current_line=next;
|
|
|
|
}
|
2019-09-18 17:44:47 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
static void show_line(const log_line* l, int y)
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
dtext(1, y, &l->text[0], C_BLACK, C_NONE);
|
2019-09-18 17:44:47 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
static void set_character(char c, int x)
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
if (c=='\0' || c=='\n')
|
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
current_line->text[x]= '\0';
|
|
|
|
add_line();
|
2019-09-18 17:44:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
current_line->text[x] = c;
|
2019-09-18 17:44:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// log something
|
2019-09-20 13:22:16 +02:00
|
|
|
void ll_send(const char * txt)
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
add_line();
|
|
|
|
char c=1;
|
2019-09-18 17:44:47 +02:00
|
|
|
int i=0;
|
2019-09-20 13:22:16 +02:00
|
|
|
int p=0;
|
|
|
|
while (c)
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
c=txt[i];
|
|
|
|
set_character(c,p);
|
|
|
|
p++;
|
|
|
|
if (c=='\0' || c=='\n')
|
|
|
|
p=0;
|
|
|
|
if (p==MAX_LENGHT)
|
|
|
|
{
|
|
|
|
p=0;
|
|
|
|
add_line();
|
|
|
|
}
|
2019-09-18 17:44:47 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-20 13:22:16 +02:00
|
|
|
void ll_display()
|
2019-09-18 17:44:47 +02:00
|
|
|
{
|
2019-09-20 13:22:16 +02:00
|
|
|
|
2019-09-18 17:44:47 +02:00
|
|
|
dclear(C_WHITE);
|
|
|
|
for (int i=0; i<8; i++)
|
2019-09-20 13:22:16 +02:00
|
|
|
{
|
|
|
|
#ifdef FX9860G
|
|
|
|
show_line(current_line, 63 - 8*i);
|
|
|
|
#endif
|
|
|
|
#ifdef FXCG50
|
|
|
|
show_line(current_line, 224 - 13*i);
|
|
|
|
#endif
|
|
|
|
current_line=current_line->previous;
|
|
|
|
if (!current_line)
|
|
|
|
break;
|
|
|
|
}
|
2019-09-18 17:44:47 +02:00
|
|
|
dupdate();
|
|
|
|
}
|
2019-09-20 13:22:16 +02:00
|
|
|
|
|
|
|
GNORETURN void ll_panic()
|
|
|
|
{
|
|
|
|
ll_display();
|
|
|
|
while (1)
|
|
|
|
getkey();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ll_set_panic()
|
|
|
|
{
|
|
|
|
gint_panic_set(ll_panic);
|
|
|
|
}
|