Add of the FMenus, working with a cfg file
This commit is contained in:
parent
5ab7dd2509
commit
eb7581ca65
BIN
ALGEBRA.G1A
BIN
ALGEBRA.G1A
Binary file not shown.
62
Eigen.dlr
62
Eigen.dlr
|
@ -1 +1,63 @@
|
|||
[DLSimRunSpace]
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=585
|
||||
Flags=00001012
|
||||
Sublevel=1
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=591
|
||||
Flags=00001012
|
||||
Sublevel=1
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=591
|
||||
Flags=00001012
|
||||
Sublevel=2
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\Taumath.cpp
|
||||
Line=14
|
||||
Flags=00001012
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=741
|
||||
Flags=00001012
|
||||
Sublevel=1
|
||||
|
||||
[Breakpoint]
|
||||
Address=80000000:88023F0C
|
||||
Count=00000028
|
||||
Name=Console_FMenu_Init:debug
|
||||
Flags=00000042
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Name=FMenu_entries[3]
|
||||
Flags=00002042
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Name=FMenu_entries[2].str
|
||||
Flags=00002042
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=33
|
||||
Flags=00001012
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=741
|
||||
Flags=00001012
|
||||
Sublevel=2
|
||||
|
||||
[Breakpoint]
|
||||
File=C:\Prizm\Eigenmath\Eigenmath\console.c
|
||||
Line=585
|
||||
Flags=00001012
|
||||
Sublevel=2
|
||||
|
|
144
Eigen.dlw
144
Eigen.dlw
|
@ -2,19 +2,20 @@
|
|||
|
||||
[_1]
|
||||
Type=5
|
||||
Order=2
|
||||
Top=3930
|
||||
Left=-255
|
||||
Height=6360
|
||||
Width=2250
|
||||
Order=1
|
||||
Top=2565
|
||||
Left=4500
|
||||
Height=7095
|
||||
Width=9090
|
||||
State=0
|
||||
Flags=00000020
|
||||
Setting=16:1:console.c
|
||||
OptionA=0
|
||||
|
||||
[_2]
|
||||
Type=1
|
||||
Order=1
|
||||
Top=-840
|
||||
Order=3
|
||||
Top=0
|
||||
Left=13035
|
||||
Height=4785
|
||||
Width=5610
|
||||
|
@ -25,8 +26,8 @@ OptionB=15
|
|||
|
||||
[_3]
|
||||
Type=6
|
||||
Order=3
|
||||
Top=3930
|
||||
Order=2
|
||||
Top=4770
|
||||
Left=13035
|
||||
Height=6345
|
||||
Width=5610
|
||||
|
@ -36,29 +37,29 @@ OptionA=0
|
|||
|
||||
[_4]
|
||||
Type=7
|
||||
Order=9
|
||||
Order=15
|
||||
Top=3900
|
||||
Left=1980
|
||||
Height=3165
|
||||
Width=5565
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000000
|
||||
OptionA=0
|
||||
|
||||
[_5]
|
||||
Type=8
|
||||
Order=10
|
||||
Top=7065
|
||||
Left=1980
|
||||
Order=14
|
||||
Top=8520
|
||||
Left=1365
|
||||
Height=3225
|
||||
Width=5580
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000000
|
||||
OptionA=0
|
||||
|
||||
[_6]
|
||||
Type=3
|
||||
Order=18
|
||||
Order=22
|
||||
Top=0
|
||||
Left=10788
|
||||
Height=6348
|
||||
|
@ -69,22 +70,22 @@ OptionA=0
|
|||
|
||||
[_7]
|
||||
Type=2
|
||||
Order=17
|
||||
Top=6348
|
||||
Order=7
|
||||
Top=6345
|
||||
Left=7800
|
||||
Height=3588
|
||||
Height=3585
|
||||
Width=5220
|
||||
State=16
|
||||
State=0
|
||||
Flags=00000000
|
||||
OptionA=0
|
||||
|
||||
[_8]
|
||||
Type=17
|
||||
Order=5
|
||||
Top=-825
|
||||
Left=-255
|
||||
Height=4755
|
||||
Width=2235
|
||||
Top=1005
|
||||
Left=2070
|
||||
Height=5790
|
||||
Width=4050
|
||||
State=0
|
||||
Flags=00000000
|
||||
OptionA=0
|
||||
|
@ -92,8 +93,8 @@ OptionA=0
|
|||
[_9]
|
||||
Type=15
|
||||
Order=0
|
||||
Top=2490
|
||||
Left=5385
|
||||
Top=6420
|
||||
Left=5520
|
||||
Height=6360
|
||||
Width=14760
|
||||
State=0
|
||||
|
@ -102,7 +103,7 @@ OptionA=0
|
|||
|
||||
[_10]
|
||||
Type=13
|
||||
Order=16
|
||||
Order=21
|
||||
Top=2340
|
||||
Left=2340
|
||||
Height=6930
|
||||
|
@ -111,33 +112,78 @@ State=16
|
|||
Flags=00000020
|
||||
OptionA=0
|
||||
|
||||
[_11]
|
||||
Type=9
|
||||
Order=13
|
||||
Top=870
|
||||
Left=660
|
||||
Height=9750
|
||||
Width=25185
|
||||
State=16
|
||||
Flags=00000020
|
||||
Setting=80000000:080FA6AC:081010F8:FMenu_entries[2].str
|
||||
OptionA=0
|
||||
|
||||
[_12]
|
||||
Type=14
|
||||
Order=9
|
||||
Top=4410
|
||||
Left=2055
|
||||
Height=9750
|
||||
Width=25185
|
||||
State=16
|
||||
Flags=00000020
|
||||
OptionA=0
|
||||
|
||||
[_13]
|
||||
Type=4
|
||||
Order=8
|
||||
Top=5910
|
||||
Left=120
|
||||
Height=9750
|
||||
Width=25185
|
||||
State=16
|
||||
Flags=00000020
|
||||
OptionA=0
|
||||
|
||||
[_14]
|
||||
Type=10
|
||||
Order=4
|
||||
Top=7515
|
||||
Left=3045
|
||||
Height=9570
|
||||
Width=24855
|
||||
State=0
|
||||
Flags=00000020
|
||||
OptionA=0
|
||||
|
||||
[_32]
|
||||
Type=16
|
||||
Order=8
|
||||
Order=11
|
||||
Top=420
|
||||
Left=3630
|
||||
Height=6885
|
||||
Width=12045
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000020
|
||||
Setting=12:1:console.h
|
||||
OptionA=0
|
||||
|
||||
[_33]
|
||||
Type=16
|
||||
Order=11
|
||||
Top=1200
|
||||
Left=3885
|
||||
Order=6
|
||||
Top=7455
|
||||
Left=5340
|
||||
Height=6675
|
||||
Width=15765
|
||||
State=16
|
||||
State=0
|
||||
Flags=00000020
|
||||
Setting=1:1:syscalls_.src
|
||||
Setting=700:1:console.c
|
||||
OptionA=0
|
||||
|
||||
[_34]
|
||||
Type=16
|
||||
Order=14
|
||||
Order=19
|
||||
Top=1230
|
||||
Left=975
|
||||
Height=6930
|
||||
|
@ -149,7 +195,7 @@ OptionA=0
|
|||
|
||||
[_35]
|
||||
Type=16
|
||||
Order=12
|
||||
Order=17
|
||||
Top=3510
|
||||
Left=2535
|
||||
Height=6930
|
||||
|
@ -161,31 +207,31 @@ OptionA=0
|
|||
|
||||
[_36]
|
||||
Type=16
|
||||
Order=4
|
||||
Top=900
|
||||
Left=780
|
||||
Order=12
|
||||
Top=825
|
||||
Left=2010
|
||||
Height=6930
|
||||
Width=15765
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000020
|
||||
Setting=33:28:Taumath.cpp
|
||||
Setting=9:3:Taumath.cpp
|
||||
OptionA=0
|
||||
|
||||
[_37]
|
||||
Type=16
|
||||
Order=6
|
||||
Order=16
|
||||
Top=1665
|
||||
Left=1560
|
||||
Height=6930
|
||||
Width=15765
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000020
|
||||
Setting=572:20:print.cpp
|
||||
Setting=553:11:print.cpp
|
||||
OptionA=0
|
||||
|
||||
[_38]
|
||||
Type=16
|
||||
Order=15
|
||||
Order=20
|
||||
Top=5055
|
||||
Left=1200
|
||||
Height=6930
|
||||
|
@ -197,19 +243,19 @@ OptionA=0
|
|||
|
||||
[_39]
|
||||
Type=16
|
||||
Order=7
|
||||
Order=10
|
||||
Top=1035
|
||||
Left=2685
|
||||
Height=6675
|
||||
Width=15765
|
||||
State=0
|
||||
State=16
|
||||
Flags=00000020
|
||||
Setting=82:48:factorpoly.cpp
|
||||
Setting=63:26:factorpoly.cpp
|
||||
OptionA=0
|
||||
|
||||
[_40]
|
||||
Type=16
|
||||
Order=13
|
||||
Order=18
|
||||
Top=1305
|
||||
Left=2205
|
||||
Height=6675
|
||||
|
|
|
@ -157,9 +157,11 @@ SourceFile=:main.cpp
|
|||
SourceFile=:test.cpp
|
||||
SourceFile=:console.c
|
||||
SourceFile=:syscalls_.src
|
||||
SourceFile=:memory.c
|
||||
HeaderFile=:defs.h
|
||||
HeaderFile=:prototypes.h
|
||||
HeaderFile=:setjmp.h
|
||||
HeaderFile=:stdafx.h
|
||||
HeaderFile=:console.h
|
||||
HeaderFile=:syscalls.h
|
||||
HeaderFile=:memory.h
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@echo off
|
||||
rem Do not edit! This batch file is created by CASIO fx-9860G SDK.
|
||||
|
||||
if exist debug\*.obj del debug\*.obj
|
||||
|
||||
if exist ALGEBRA.G1A del ALGEBRA.G1A
|
||||
|
||||
cd debug
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,24 @@
|
|||
F2
|
||||
cos(
|
||||
sin(
|
||||
tan(
|
||||
F1
|
||||
test(
|
||||
test(
|
||||
F4
|
||||
je(
|
||||
suis(
|
||||
vivant(
|
||||
F5
|
||||
pom(
|
||||
gali(
|
||||
georges(
|
||||
F6
|
||||
return(
|
||||
solve(
|
||||
F3
|
||||
solve(
|
||||
factor(
|
||||
simplify(
|
||||
matrix(
|
||||
d(
|
154
console.c
154
console.c
|
@ -1,7 +1,11 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "console.h"
|
||||
#include "syscalls.h"
|
||||
#include "memory.h"
|
||||
|
||||
static struct line Line[LINE_MAX];
|
||||
static struct FMenu FMenu_entries[6];
|
||||
static struct location Cursor;
|
||||
static unsigned char *Edit_Line;
|
||||
static int Start_Line, Last_Line;
|
||||
|
@ -438,6 +442,8 @@ int Console_GetKey()
|
|||
return Console_Input(tmp_str);
|
||||
}
|
||||
|
||||
if (key >= KEY_CTRL_F1 &&
|
||||
key <= KEY_CTRL_F6) return Console_FMenu(key);
|
||||
if (key == KEY_CHAR_IMGNRY) return Console_Input((const unsigned char *)"i");
|
||||
if (key == KEY_CHAR_MAT) return Console_Input((const unsigned char *)"matrix");
|
||||
if (key == KEY_CHAR_DP) return Console_Input((const unsigned char *)".");
|
||||
|
@ -538,6 +544,91 @@ int Console_GetKey()
|
|||
return CONSOLE_NO_EVENT;
|
||||
}
|
||||
|
||||
int Console_FMenu(int key)
|
||||
{
|
||||
unsigned char *entries[MAX_MENU_ITEMS] = {NULL};
|
||||
if(key == KEY_CTRL_F1) {
|
||||
/*entries[0] = (unsigned char *)Console_Make_Entry((const unsigned char *)"sqrt(");
|
||||
entries[1] = (unsigned char *)Console_Make_Entry((const unsigned char *)"cos(");
|
||||
entries[2] = (unsigned char *)Console_Make_Entry((const unsigned char *)"root(");
|
||||
return Console_Draw_FMenu(key, entries);*/
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[0]);
|
||||
}
|
||||
if(key == KEY_CTRL_F2) {
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[1]);
|
||||
}
|
||||
if(key == KEY_CTRL_F3) {
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[2]);
|
||||
}
|
||||
if(key == KEY_CTRL_F4) {
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[3]);
|
||||
}
|
||||
if(key == KEY_CTRL_F5) {
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[4]);
|
||||
}
|
||||
if(key == KEY_CTRL_F6) {
|
||||
return Console_Draw_FMenu(key, /*entries*/&FMenu_entries[5]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char *Console_Make_Entry(const unsigned char* str)
|
||||
{
|
||||
unsigned char* entry = NULL;
|
||||
entry = calloc((strlen(str)+1), sizeof(unsigned char*));
|
||||
if(entry) memcpy(entry, str, strlen(str)+1);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
int Console_Draw_FMenu(int key, struct FMenu* menu)
|
||||
{
|
||||
int i, nb_entries = 0, selector = 0, position_number, position_x, ret, longest = 0;
|
||||
unsigned char **entries;
|
||||
DISPBOX box;
|
||||
|
||||
position_number = key - KEY_CTRL_F1;
|
||||
|
||||
entries = menu->str;
|
||||
nb_entries = menu->count;
|
||||
|
||||
for(i=0; i<nb_entries; i++)
|
||||
if(strlen(entries[i]) > longest) longest = strlen(entries[i]);
|
||||
|
||||
position_x = 21*position_number;
|
||||
if(position_x + longest*4 > 115) position_x = 115 - longest*4;
|
||||
|
||||
box.left = position_x+3;
|
||||
box.right = position_x + longest*4 + 7;
|
||||
box.bottom = 50+7;
|
||||
box.top = 50+7- nb_entries*7;
|
||||
|
||||
Bdisp_AreaClr_VRAM(&box);
|
||||
|
||||
Bdisp_DrawLineVRAM(3+position_x, 50+7, 3+position_x, 50+7-nb_entries*7);
|
||||
Bdisp_DrawLineVRAM(7+position_x + longest*4, 50+7, 7+position_x+longest*4, 50+7-nb_entries*7);
|
||||
|
||||
while(key != KEY_CTRL_EXE || key != KEY_CTRL_EXIT) {
|
||||
for(i=0; i<nb_entries; i++) {
|
||||
PrintMini(5+position_x, 50-7*i, entries[i], MINI_OVER);
|
||||
}
|
||||
PrintMini(5+position_x,50-7*selector, entries[selector], MINI_REV);
|
||||
GetKey(&key);
|
||||
|
||||
if (key == KEY_CTRL_UP && selector < nb_entries-1) selector++;
|
||||
if (key == KEY_CTRL_DOWN && selector > 0) selector--;
|
||||
|
||||
if (key == KEY_CTRL_EXE) return Console_Input(entries[selector]);
|
||||
if (key == KEY_CTRL_EXIT) return Console_Input((const unsigned char *)"");
|
||||
|
||||
if (key >= KEY_CTRL_F1 && key <= KEY_CTRL_F6) {
|
||||
Console_Input((const unsigned char *)"");
|
||||
Console_Disp();
|
||||
return Console_FMenu(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
以下函数用于初始化。
|
||||
*/
|
||||
|
@ -566,9 +657,72 @@ int Console_Init()
|
|||
|
||||
Case = LOWER_CASE;
|
||||
|
||||
for(i = 0; i < 6; i++) {
|
||||
FMenu_entries[i].count = 0;
|
||||
}
|
||||
|
||||
Console_FMenu_Init();
|
||||
|
||||
return CONSOLE_SUCCEEDED;
|
||||
}
|
||||
|
||||
void Console_FMenu_Init()
|
||||
{
|
||||
//ToDo : handle when there's no file ...
|
||||
int i, number=0, key;
|
||||
//unsigned char debug[40] = {'\0'};
|
||||
unsigned char* tmp_realloc = NULL;
|
||||
unsigned char temp[20] = {'\0'};
|
||||
unsigned char* original_cfg;
|
||||
unsigned char* cfg = memory_load("\\\\fls0\\FMENU.cfg");
|
||||
|
||||
original_cfg = cfg;
|
||||
|
||||
while(*cfg) {
|
||||
for(i=0; i<20, *cfg && *cfg!='\r' && *cfg!='\n'; i++, cfg++) {
|
||||
temp[i] = *cfg;
|
||||
}
|
||||
//if(temp[i-1] == '\r') temp[i-1]='\0';
|
||||
|
||||
if(temp[0] == 'F' && temp[1]>='1' && temp[1]<='6') number = temp[1]-'0' - 1;
|
||||
else if(temp[0]) {
|
||||
tmp_realloc=FMenu_entries[number].str;
|
||||
FMenu_entries[number].str = realloc(tmp_realloc, sizeof(unsigned char*)*(FMenu_entries[number].count+1));
|
||||
|
||||
if(FMenu_entries[number].str != NULL) {
|
||||
FMenu_entries[number].str[FMenu_entries[number].count] = malloc(strlen(temp)+1);
|
||||
|
||||
if(FMenu_entries[number].str[FMenu_entries[number].count] == NULL) {
|
||||
PrintMini(10,40, "Error realloc bis -> FMenu_init()", MINI_OVER);
|
||||
GetKey(&key);
|
||||
FMenu_entries[number].str = realloc(FMenu_entries[number].str, FMenu_entries[number].count); //May never fail.
|
||||
FMenu_entries[number].count--;
|
||||
}
|
||||
|
||||
else {
|
||||
//sprintf(debug, "number = %d and count = %d", number, FMenu_entries[number].count);
|
||||
strcpy(FMenu_entries[number].str[FMenu_entries[number].count], temp);
|
||||
///PrintMini(10,30, debug, MINI_OVER);
|
||||
//PrintMini(50,40, FMenu_entries[number].str[FMenu_entries[number].count], MINI_OVER);
|
||||
//if(FMenu_entries[number].count>0)PrintMini(50,50, FMenu_entries[number].str[FMenu_entries[number].count-1], MINI_OVER);
|
||||
//GetKey(&key);
|
||||
//Bdisp_AllClr_VRAM();
|
||||
}
|
||||
|
||||
FMenu_entries[number].count++;
|
||||
}
|
||||
else {
|
||||
PrintMini(50,40, "Error realloc -> FMenu_init()", MINI_OVER);
|
||||
GetKey(&key);
|
||||
FMenu_entries[number].str = tmp_realloc;
|
||||
}
|
||||
}
|
||||
memset(temp, '\0', 20);
|
||||
cfg++;
|
||||
}
|
||||
free(original_cfg);
|
||||
}
|
||||
|
||||
/*
|
||||
以下函数用于显示所有行。
|
||||
注意:调用该函数后,将首先清空显存。
|
||||
|
|
13
console.h
13
console.h
|
@ -17,7 +17,7 @@ extern "C"{
|
|||
enum CONSOLE_SCREEN_SPEC{
|
||||
LINE_MAX = 32,
|
||||
LINE_DISP_MAX = 7,
|
||||
COL_DISP_MAX = 21,
|
||||
COL_DISP_MAX = 21,//21
|
||||
EDIT_LINE_MAX = 2048
|
||||
};
|
||||
|
||||
|
@ -54,11 +54,18 @@ extern "C"{
|
|||
int disp_len;
|
||||
};
|
||||
|
||||
struct FMenu{
|
||||
unsigned char** str;
|
||||
unsigned char count;
|
||||
};
|
||||
|
||||
struct location{
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#define MAX_MENU_ITEMS 10
|
||||
|
||||
#define is_wchar(c) ((c == 0x7F) || (c == 0xF7) || (c == 0xF9) || (c == 0xE5) || (c == 0xE6) || (c == 0xE7))
|
||||
#define printf(s) Console_Output((const unsigned char *)s);
|
||||
|
||||
|
@ -74,6 +81,10 @@ extern "C"{
|
|||
int Console_GetKey(void);
|
||||
int Console_Init(void);
|
||||
int Console_Disp(void);
|
||||
int Console_FMenu(int key);
|
||||
void Console_FMenu_Init(void);
|
||||
int Console_Draw_FMenu(int key, struct FMenu* menu);
|
||||
unsigned char *Console_Make_Entry(const unsigned char* str);
|
||||
unsigned char *Console_GetLine(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
/****************************************************************/
|
||||
/* */
|
||||
/* Memory */
|
||||
/* */
|
||||
/* Description: Fonctions de manipulation de la memoire */
|
||||
/* Auteur: LePhenixNoir */
|
||||
/* Version: 3.0 */
|
||||
/* Date: 11.06.2014 */
|
||||
/* Fichier: memory.c - Code des fonctions */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
|
||||
#ifndef __FXLIB_H__
|
||||
#include "fxlib.h"
|
||||
#endif
|
||||
|
||||
#ifndef _STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STDLIB
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STRING
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
int memory_errors = 0;
|
||||
|
||||
void memory_seterrors(int e)
|
||||
{
|
||||
memory_errors = (e!=0);
|
||||
}
|
||||
|
||||
void memory_error(char *from, char *func, int val)
|
||||
{
|
||||
unsigned int key;
|
||||
char info[20];
|
||||
if(!memory_errors) return;
|
||||
|
||||
sprintf(info,"%d",val);
|
||||
PopUpWin(6);
|
||||
|
||||
locate(4,2); Print((unsigned char *)"Memory ERROR !!");
|
||||
locate(3,4); Print((unsigned char *)"FROM:");
|
||||
locate(8,4); Print((unsigned char *)from);
|
||||
locate(3,5); Print((unsigned char *)"FUNC:");
|
||||
locate(8,5); Print((unsigned char *)func);
|
||||
locate(3,6); Print((unsigned char *)"INFO:");
|
||||
locate(8,6); Print((unsigned char *)info);
|
||||
locate(3,7); Print((unsigned char *)"META:");
|
||||
locate(8,7);
|
||||
|
||||
switch(val)
|
||||
{
|
||||
case 1: Print((unsigned char *)"NotEnoughRAM"); break;
|
||||
case -1: Print((unsigned char *)"Nonexisting"); break;
|
||||
case -5: Print((unsigned char *)"WrongDevice"); break;
|
||||
case -8: Print((unsigned char *)"AccessDenied"); break;
|
||||
case -14: Print((unsigned char *)"ReadOnly"); break;
|
||||
case -31: Print((unsigned char *)"DeviceError"); break;
|
||||
case -35: Print((unsigned char *)"NotEmpty"); break;
|
||||
default: Print((unsigned char *)"Other"); break;
|
||||
}
|
||||
GetKey(&key);
|
||||
}
|
||||
|
||||
FONTCHARACTER *memory_char2font(char *adresse)
|
||||
{
|
||||
FONTCHARACTER *adr;
|
||||
int i;
|
||||
|
||||
adr = calloc((strlen(adresse)+1),sizeof(FONTCHARACTER));
|
||||
for(i=0;i<strlen(adresse);i++) *(adr+i) = *(adresse+i);
|
||||
return adr;
|
||||
}
|
||||
|
||||
int memory_createfile(char *adresse, int size)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int i = Bfile_CreateFile(adr,size);
|
||||
if(i<0) memory_error("createfile()","CreateFile()",i);
|
||||
|
||||
free(adr);
|
||||
return i;
|
||||
}
|
||||
|
||||
int memory_createdir(char *adresse)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int i = Bfile_CreateDirectory(adr);
|
||||
if(i<0) memory_error("createdir()","CreateDir.()",i);
|
||||
|
||||
free(adr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int memory_openfile(char *adresse, int mode)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int i = Bfile_OpenFile(adr,mode);
|
||||
if(i<0) memory_error("openfile()","OpenFile()",i);
|
||||
|
||||
free(adr);
|
||||
return i;
|
||||
}
|
||||
|
||||
int memory_deletefile(char *adresse)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int i = Bfile_DeleteFile(adr);
|
||||
if(i<0) memory_error("deletefil.()","DeleteFil.()",i);
|
||||
|
||||
free(adr);
|
||||
return i;
|
||||
}
|
||||
|
||||
char **memory_alloc(int l)
|
||||
{
|
||||
char **p = calloc(l,sizeof(char *));
|
||||
int i; for(i=0;i<l;i++) *(p+i) = calloc(20,1);
|
||||
return p;
|
||||
}
|
||||
|
||||
void memory_free(char **p, int l)
|
||||
{
|
||||
int i; for(i=0;i<l;i++) free(*(p+i));
|
||||
free(p);
|
||||
}
|
||||
|
||||
int memory_find(char *adresse, char **files, int max)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
FONTCHARACTER found[30];
|
||||
FILE_INFO fileInfo;
|
||||
int searchHandle,i=1,j,x;
|
||||
|
||||
if(x = Bfile_FindFirst(adr,&searchHandle,found,&fileInfo)) return 0;
|
||||
for(j=0;j<14 && *(found+j);j++) *(*files+j) = *(found+j);
|
||||
|
||||
while(Bfile_FindNext(searchHandle,found,&fileInfo)==0 && i<max) {
|
||||
for(j=0;j<14 && *(found+j);j++) *(*(files+i)+j) = *(found+j);
|
||||
i++; }
|
||||
|
||||
Bfile_FindClose(searchHandle);
|
||||
free(adr);
|
||||
return i;
|
||||
}
|
||||
|
||||
int memory_exists(char *adresse)
|
||||
{
|
||||
char *file[1];
|
||||
int x;
|
||||
|
||||
*file = malloc(14); **file=0;
|
||||
x = memory_find(adresse,file,1);
|
||||
free(*file);
|
||||
|
||||
return x!=0;
|
||||
}
|
||||
|
||||
void *memory_load(char *adresse)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int handle, x, size;
|
||||
void *p;
|
||||
|
||||
if((handle=Bfile_OpenFile(adr,_OPENMODE_READ))<0) { memory_error("load()","OpenFile()",handle); return NULL; }
|
||||
size = Bfile_GetFileSize(handle)+1;
|
||||
p = calloc(size,1);
|
||||
|
||||
if(!p) {
|
||||
memory_error("load()","malloc()",1);
|
||||
Bfile_CloseFile(handle); free(adr); return NULL; }
|
||||
if((x=Bfile_ReadFile(handle,p,size,0))<0) {
|
||||
memory_error("load()","ReadFile()",x);
|
||||
Bfile_CloseFile(handle); free(adr); return NULL; }
|
||||
|
||||
Bfile_CloseFile(handle);
|
||||
free(adr);
|
||||
return p;
|
||||
}
|
||||
|
||||
int memory_save(char *adresse, void *data, int l)
|
||||
{
|
||||
FONTCHARACTER *adr = memory_char2font(adresse);
|
||||
int x=0, handle;
|
||||
|
||||
if(memory_exists(adresse)) x = Bfile_DeleteFile(adr);
|
||||
if(x<0) { memory_error("save()","DeleteFile()",x); free(adr); return x; }
|
||||
x = Bfile_CreateFile(adr,l+1);
|
||||
if(x<0) { memory_error("save()","CreateFile()",x); free(adr); return x; }
|
||||
handle = Bfile_OpenFile(adr,0x02);
|
||||
if(handle<0) { memory_error("save()","OpenFile()",handle); free(adr); return handle; }
|
||||
x = memory_writefile(handle,data,l);
|
||||
if(x<0) { memory_error("save()","WriteFile()",x); free(adr); return x; }
|
||||
memory_closefile(handle);
|
||||
|
||||
free(adr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memory_user_select(char **files, int n, int extension, int exit)
|
||||
{
|
||||
const unsigned char icons[7][32] = {
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x4,0x80,0x2,0x80,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x2,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x74,0x87,0x82,0x98,0x2,0x40,0x2,0x40,0x3a,0x43,0xc2,0x5c,0x2,0x40,0x39,0x43,0xc1,0x2c,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x74,0x87,0x94,0xb8,0x12,0xa0,0xa,0x63,0x8a,0x52,0x8a,0x54,0x4a,0x54,0x66,0x54,0x25,0x48,0x1d,0x29,0xe1,0x2e,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xc4,0x88,0x22,0x8c,0x62,0x4b,0xa2,0x44,0x42,0x42,0x82,0x42,0x82,0x42,0x81,0x44,0x41,0x2f,0xe1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x87,0xe4,0x88,0x12,0x88,0x12,0x48,0x12,0x47,0xe2,0x44,0x22,0x44,0x22,0x44,0x21,0x44,0x21,0x23,0xc1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0x64,0x87,0xb2,0x98,0x52,0x51,0xb2,0x57,0x52,0x51,0xd2,0x4b,0xa,0x48,0x19,0x49,0xe1,0x2e,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 },
|
||||
{ 0x0,0x3c,0xf,0xc4,0xf0,0x4,0x80,0xe4,0x9c,0xa2,0x90,0xa2,0x58,0xe2,0x50,0x2,0x40,0x12,0x4a,0x2a,0x4a,0x39,0x4e,0x29,0x22,0x1,0x20,0xf,0x23,0xf0,0x3c,0x0 } };
|
||||
char *exts[19] = { ".txt", ".c", ".h", ".cpp", ".hpp", ".bmp",".jpg",".png",".gif", ".sav", ".g1m",".g2m",".g1r",".g2r", ".g1e",".g2e",".g1a", ".hex",".bin" };
|
||||
unsigned char indexs[19] = { 1,1,1,1,1, 2,2,2,2, 3, 4,4,4,4, 5,5,5, 6,6 };
|
||||
unsigned char *icoind = malloc(n);
|
||||
unsigned int key;
|
||||
|
||||
int i,j,k,t;
|
||||
int p=0, offset=0;
|
||||
|
||||
if(!icoind) { memory_error("user_sele.()","malloc()",1); return -2; }
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
for(t=-1,j=0;*(*(files+i)+j);j++) if(*(*(files+i)+j) == '.') t = j;
|
||||
icoind[i] = (t==-1?1:0);
|
||||
for(k=0;k<19;k++)
|
||||
if(!strcmp(*(files+i)+t,exts[k])) { icoind[i]=indexs[k]; break; }
|
||||
if(!extension && t+1) *(*(files+i)+t) = 0;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
Bdisp_AllClr_VRAM();
|
||||
|
||||
for(t=0;t<(n>3?3:n);t++)
|
||||
{
|
||||
if(icoind[offset+i]!=255) for(i=0;i<32;i++) {
|
||||
k = icons[icoind[offset+t]][i];
|
||||
for(j=0;j<8;j++) {
|
||||
if(k&1) Bdisp_SetPoint_VRAM(11-j+8*(i&1),20*t+4+(i>>1),1);
|
||||
k >>= 1; } }
|
||||
PrintXY(24,20*t+9,(const unsigned char *)*(files+offset+t),0);
|
||||
}
|
||||
Bdisp_DrawLineVRAM(2,20*p+3,2,20*p+20);
|
||||
Bdisp_DrawLineVRAM(3,20*p+2,99,20*p+2);
|
||||
Bdisp_DrawLineVRAM(3,20*p+21,99,20*p+21);
|
||||
Bdisp_DrawLineVRAM(100,20*p+3,100,20*p+20);
|
||||
if(offset>0) PrintXY(114,6,(const unsigned char *)"\346\234",0);
|
||||
if(offset+3<n) PrintXY(114,51,(const unsigned char *)"\346\235",0);
|
||||
|
||||
while(1)
|
||||
{
|
||||
GetKey(&key);
|
||||
if(key==30002 && exit) { free(icoind); return -1; }
|
||||
if(key==30004) break;
|
||||
if(key==30018 && (offset||p)) { if(p==2) p--; else if(offset) offset--; else p--; break; }
|
||||
if(key==30023 && (offset+p+1<n)) { if(p==0) p++; else if(offset+3<n) offset++; else p++; break; }
|
||||
}
|
||||
|
||||
if(key==30004) break;
|
||||
}
|
||||
|
||||
free(icoind);
|
||||
return offset+p;
|
||||
}
|
||||
|
||||
void *memory_user_autoload(char *prefix, char *selector, int l, int extension, int exit)
|
||||
{
|
||||
char **files = memory_alloc(l);
|
||||
char *adr = malloc(strlen(prefix)+strlen(selector)+1);
|
||||
void *data;
|
||||
int x;
|
||||
|
||||
sprintf(adr,"%s%s",prefix,selector);
|
||||
x = memory_find(adr,files,l);
|
||||
free(adr);
|
||||
x = memory_user_select(files,x,extension,exit);
|
||||
|
||||
adr = malloc(strlen(prefix)+strlen(files[x])+1);
|
||||
sprintf(adr,"%s%s",prefix,files[x]);
|
||||
data = memory_load(adr);
|
||||
|
||||
free(adr);
|
||||
memory_free(files,l);
|
||||
return data;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/****************************************************************/
|
||||
/* */
|
||||
/* Memory */
|
||||
/* */
|
||||
/* Description: Fonctions de manipulation de la memoire */
|
||||
/* Auteur: LePhenixNoir */
|
||||
/* Version: 3.0 */
|
||||
/* Date: 11.06.2014 */
|
||||
/* Fichier: memory.h - Fichier d'en-tete */
|
||||
/* */
|
||||
/****************************************************************/
|
||||
|
||||
#ifndef __MEMORY_H__
|
||||
#define __MEMORY_H__
|
||||
|
||||
|
||||
#define memory_closefile(h) Bfile_CloseFile(h)
|
||||
#define memory_writefile(h,c,l) Bfile_WriteFile(h,c,l)
|
||||
#define memory_readfile(h,b,s,p) Bfile_ReadFile(h,b,s,p)
|
||||
#define memory_seekfile(h,p) Bfile_SeekFile(h,p)
|
||||
#define memory_filesize(h) Bfile_GetFileSize(h)
|
||||
unsigned short *memory_char2font (char *);
|
||||
|
||||
void memory_seterrors (int);
|
||||
void memory_error (char *,char *,int);
|
||||
|
||||
int memory_createfile (char *,int);
|
||||
int memory_createdir (char *);
|
||||
int memory_openfile (char *,int);
|
||||
int memory_deletefile (char *);
|
||||
|
||||
char **memory_alloc (int);
|
||||
void memory_free (char **,int);
|
||||
int memory_find (char *,char **,int);
|
||||
int memory_exists (char *);
|
||||
void *memory_load (char *);
|
||||
int memory_save (char *,void *,int);
|
||||
|
||||
int memory_user_select (char **,int,int,int);
|
||||
void *memory_user_autoload (char *,char *,int,int,int);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,24 @@
|
|||
F2
|
||||
cos(
|
||||
sin(
|
||||
tan(
|
||||
F1
|
||||
test(
|
||||
test(
|
||||
F4
|
||||
je(
|
||||
suis(
|
||||
vivant(
|
||||
F5
|
||||
pom(
|
||||
gali(
|
||||
georges(
|
||||
F6
|
||||
return(
|
||||
solve(
|
||||
F3
|
||||
solve(
|
||||
factor(
|
||||
simplify(
|
||||
matrix(
|
||||
d(
|
Loading…
Reference in New Issue