v.0.2 #2

Merged
mibi88 merged 16 commits from dev into master 2023-04-19 20:24:43 +02:00
8 changed files with 354 additions and 59 deletions
Showing only changes of commit 4040920fba - Show all commits

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
build/
lib/
*g1a

View File

@ -5,6 +5,8 @@
#define size_t unsigned int
#define NULL 0
/******* DISPLAY *******/
#define SWIDTH 128
@ -28,8 +30,8 @@ void supdate(void);
/* void srect(int x1, int y1, int x2, int y2);
Draws a white rectangle with a black border of one pixel from (x1, y1) to (x2, y2)
in the VRAM.
Draws a white rectangle with a black border of one pixel from (x1, y1) to
(x2, y2) in the VRAM.
*/
void srect(int x1, int y1, int x2, int y2);
@ -53,8 +55,8 @@ void spixel(int x, int y, int color);
/* void stext(int x, int y, char *text, int color);
Puts the text text at (x, y) on the screen using casio
default font with color color.
Puts the text text at (x, y) on the screen using casio default font with color
color.
*/
void stext(int x, int y, char *text, int color);
@ -68,8 +70,8 @@ void slocate(int x, int y, char *text);
/* void saddlocate(char *text);
Continues the text displayed with slocate, can be used
multiple times after a locate.
Continues the text displayed with slocate, can be used multiple times after a
locate.
*/
void saddlocate(char *text);
@ -83,8 +85,7 @@ void sgoto(int x, int y);
/* void stextmini(int x, int y, char *text);
Works like stext, but here the font is PrintMini and you cannot
set the color.
Works like stext, but here the font is PrintMini and you cannot set the color.
*/
void stextmini(int x, int y, char *text);
@ -100,8 +101,8 @@ int kisdown(void);
/* int kcheck(int key);
Checks if the key key is down or not : returns a positive
int if the key is down, or 0 if the key key is not down.
Checks if the key key is down or not : returns a positive int if the key is
down, or 0 if the key key is not down.
*/
int kcheck(int key);
@ -151,8 +152,8 @@ void free(void *__ptr);
/* void itohex(char *buffer, int value, int len);
Puts the hex representation of value into buffer. The hex number
will have the size len.
Puts the hex representation of value into buffer. The hex number will have the
size len.
*/
void itohex(char *buffer, int value, int len);
@ -174,8 +175,7 @@ int tgetticks(void);
/* int tiselapsed(int start, int ms);
Check if ms where elapsed since start (ticks that you can
get with tgetticks).
Check if ms where elapsed since start (ticks that you can get with tgetticks).
Returns 1 if ms is elapsed and 0 if it is not.
*/
@ -235,29 +235,26 @@ enum {GDEC = 0, GHEX};
/* int gnumask(char *message, int maxlen, int type);
Asks for a num that is returned. message contains the
message that will be displayed when asking for the number.
maxlen is the maximal length of the input and type can be
GDEC or GHEX. Set type to GDEC if you want to ask for a
decimal number or GHEX if you want that the user inputs a
hexadecimal number.
Asks for a num that is returned. message contains the message that will be
displayed when asking for the number. maxlen is the maximal length of the input
and type can be GDEC or GHEX. Set type to GDEC if you want to ask for a decimal
number or GHEX if you want that the user inputs a hexadecimal number.
*/
int gnumask(char *message, int maxlen, int type);
/* void gstrask(char *buffer, char *message, int maxlen);
Asks for a str that will be in buffer. message contains
the message that will be displayed when asking for the
string and maxlen is the maximal length of the input.
Asks for a str that will be in buffer. message contains the message that will be
displayed when asking for the string and maxlen is the maximal length of the
input.
*/
void gstrask(char *buffer, char *message, int maxlen);
/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode);
Draws an fkey from a Sprite Coder string that is in img,
at fkey position pos.
Draws an fkey from a Sprite Coder string that is in img, at fkey position pos.
*/
void gfkeyset(int pos, unsigned char *img);
@ -269,4 +266,101 @@ Draws a message box of height height with that contains message.
void gmessagebox(int height, char *message);
/******* Memory *******/
/* File types */
enum {
MFILE = 1,
MFOLDER = 5
};
/* Open modes */
enum {
MREAD = 0x01,
MWRITE = 0x02,
MREADW = (MREAD | MWRITE),
MSHARE = 0x80,
MRWS = (MREADW | MSHARE)
};
/* Defines */
#define MRCONTINUE -1 /* Start reading from the current position. */
#define PATHSIZELIMIT 256 /* Max. path size */
/* Prototypes */
/* IMPORTANT NOTE : The CASIOWIN/Fugue compatibility is made automatically. */
/* int mfugue(void);
Returns a postive int if the calculator has a fugue filesystem, or 0 if his fs
is CASIOWIN.
*/
int mfugue(void);
/* int mremove(const char *filename);
Removes the file filename. filename is a const char path for UNIX.
*/
int mremove(const char *filename);
/* int mcreate(const char *filename, int type, int size);
Creates the file or folder filename with size size. filename is a const char
path for UNIX.
Set type to MFILE if you want to create a file. Please consider that your add-in
may run on a CASIOWIN calculator, so please enter the real size of your file,
and not 0.
But if you want to create a folder, set type to MFOLDER and then you can also
set the size to 0 and I also recommend that because fxlib does that.
Returns a negative int if there was an error.
*/
int mcreate(const char *filename, int type, int size);
/* int mopen(const char *filename, int mode);
Opens the file filename with mode mode.
Available modes are :
- MREAD : Opens the file only for reading.
- MWRITE : Opens the file only for writing.
- MREADW : Opens the file for reading and writing.
- MSHARE : (I don't know what it is XD) Opens the file in shared mode.
- MRWS : Opens the file for reading, writing and in shared mode.
As always the filename is for UNIX and is fixed for the calc.
Returns an error code or the file descriptor of this file.
*/
int mopen(const char *filename, int mode);
/* int mwrite(int fd, const void *data, int size);
Writes size bytes of data to the file of file descriptor fd that you can get
with mopen.
Return a negative value if there was an error.
*/
int mwrite(int fd, const void *data, int size);
/* int mread(int fd, void *data, int size, int whence);
Read size bytes of the file of fd and put them into data. Set whence to a
positive value to set where mread should start reading, or to MRCONTINUE to
continue reading from the actual position.
Return a negative value if there was an error.
*/
int mread(int fd, void *data, int size, int whence);
/* int mclose(int fd);
Close the file descriptor fd.
*/
#endif

View File

@ -197,4 +197,88 @@ void gstrask(char *buffer, char *message, int maxlen) {
void gfkeyset(int pos, unsigned char *img) {
_DisplayFKeyIcon(pos, img);
}
}
/******* Memory *******/
const unsigned short int fname_start[7] = {'\\', '\\', 'f','l','s','0','\\'};
/* Syscalls */
int _Bfile_DeleteEntry(const unsigned short int *filename);
int _Bfile_Create(const unsigned short int *filename, int type, int *size);
int _Bfile_Write(int fd, const void *data, int size);
int _Bfile_Open(const unsigned short int *filename, int mode);
int _Bfile_Read(int fd, void *data, int size, int whence);
int _Bfile_Close(int fd);
/* Microfx */
extern int fugue;
int mfugue(void) {
return fugue;
}
unsigned short int fname[PATHSIZELIMIT];
void _fixname(const char *filename) {
int len, i;
len = 0;
while(filename[len] != '\0' && len < PATHSIZELIMIT){
len++;
}
for(i=0;i<PATHSIZELIMIT;i++){
fname[i] = '\0';
}
for(i=0;i<7;i++){
fname[i] = fname_start[i];
}
for(i=0;i<len;i++){
if(filename[i+1] != '/'){
fname[i+7] = filename[i+1];
}else{
fname[i+7] = '\\';
}
}
}
int mremove(const char *filename) {
_fixname(filename);
_Bfile_DeleteEntry(fname);
return 0;
}
int mcreate(const char *filename, int type, int size) {
int out;
_fixname(filename);
out = _Bfile_Create(fname, type, &size);
return out;
}
int mopen(const char *filename, int mode) {
int out;
_fixname(filename);
out = _Bfile_Open(fname, mode);
return out;
}
int mwrite(int fd, const void *data, int size) {
int out;
if(!fugue){
if(size%2) return -1;
}
out = _Bfile_Write(fd, data, size);
if(out < 0) return out-1;
return 0;
}
int mread(int fd, void *data, int size, int whence) {
int out;
out = _Bfile_Read(fd, data, size, whence);
return out;
}
int mclose(int fd) {
return _Bfile_Close(fd);
}

View File

@ -3,11 +3,14 @@ extern char start_data, end_data;
extern char romdata_start;
extern int main(void);
int fugue;
__attribute__((section(".pretext")))
int start(void) {
int i;
char *bss_startptr, *data_startptr, *romdataptr;
char *os_version = (void *)0x80010020;
bss_startptr = &start_bss;
for(i=0;i<&end_bss - &start_bss;i++){
bss_startptr[i] = 0;
@ -17,6 +20,10 @@ int start(void) {
for(i=0;i<&end_data - &start_data;i++){
data_startptr[i] = romdataptr[i];
}
if(os_version[1] == '3'){
fugue = 1;
}else{
fugue = 0;
}
return main();
}

View File

@ -25,6 +25,12 @@
.global __Timer_Start
.global __Timer_Stop
/* Files */
.global __Bfile_DeleteEntry
.global __Bfile_Create
.global __Bfile_Write
.global __Bfile_Open
.global __Bfile_Read
.global __Bfile_Close
/* Tools */
.global _itoa
.global _malloc
@ -107,7 +113,20 @@ __Timer_Start:
__Timer_Stop:
syscall(0x011B)
/* Files */
/* Nothing here ... */
__Bfile_DeleteEntry:
mov #0, r5
syscall(0x0439)
__Bfile_Create:
syscall(0x434)
__Bfile_Write:
syscall(0x435)
__Bfile_Open:
mov #0, r6
syscall(0x42C)
__Bfile_Read:
syscall(0x432)
__Bfile_Close:
syscall(0x042D)
/* Tools */
_itoa:
syscall(0x541)

View File

@ -1,6 +0,0 @@
#ifndef MICROFX_CONFIG_H
#define MICROFX_CONFIG_H
#define EX_VERSION "@libMicrofx_VERSION@"
#endif

View File

@ -5,6 +5,8 @@
#define size_t unsigned int
#define NULL 0
/******* DISPLAY *******/
#define SWIDTH 128
@ -28,8 +30,8 @@ void supdate(void);
/* void srect(int x1, int y1, int x2, int y2);
Draws a white rectangle with a black border of one pixel from (x1, y1) to (x2, y2)
in the VRAM.
Draws a white rectangle with a black border of one pixel from (x1, y1) to
(x2, y2) in the VRAM.
*/
void srect(int x1, int y1, int x2, int y2);
@ -53,8 +55,8 @@ void spixel(int x, int y, int color);
/* void stext(int x, int y, char *text, int color);
Puts the text text at (x, y) on the screen using casio
default font with color color.
Puts the text text at (x, y) on the screen using casio default font with color
color.
*/
void stext(int x, int y, char *text, int color);
@ -68,8 +70,8 @@ void slocate(int x, int y, char *text);
/* void saddlocate(char *text);
Continues the text displayed with slocate, can be used
multiple times after a locate.
Continues the text displayed with slocate, can be used multiple times after a
locate.
*/
void saddlocate(char *text);
@ -83,8 +85,7 @@ void sgoto(int x, int y);
/* void stextmini(int x, int y, char *text);
Works like stext, but here the font is PrintMini and you cannot
set the color.
Works like stext, but here the font is PrintMini and you cannot set the color.
*/
void stextmini(int x, int y, char *text);
@ -100,8 +101,8 @@ int kisdown(void);
/* int kcheck(int key);
Checks if the key key is down or not : returns a positive
int if the key is down, or 0 if the key key is not down.
Checks if the key key is down or not : returns a positive int if the key is
down, or 0 if the key key is not down.
*/
int kcheck(int key);
@ -151,8 +152,8 @@ void free(void *__ptr);
/* void itohex(char *buffer, int value, int len);
Puts the hex representation of value into buffer. The hex number
will have the size len.
Puts the hex representation of value into buffer. The hex number will have the
size len.
*/
void itohex(char *buffer, int value, int len);
@ -174,8 +175,7 @@ int tgetticks(void);
/* int tiselapsed(int start, int ms);
Check if ms where elapsed since start (ticks that you can
get with tgetticks).
Check if ms where elapsed since start (ticks that you can get with tgetticks).
Returns 1 if ms is elapsed and 0 if it is not.
*/
@ -235,29 +235,26 @@ enum {GDEC = 0, GHEX};
/* int gnumask(char *message, int maxlen, int type);
Asks for a num that is returned. message contains the
message that will be displayed when asking for the number.
maxlen is the maximal length of the input and type can be
GDEC or GHEX. Set type to GDEC if you want to ask for a
decimal number or GHEX if you want that the user inputs a
hexadecimal number.
Asks for a num that is returned. message contains the message that will be
displayed when asking for the number. maxlen is the maximal length of the input
and type can be GDEC or GHEX. Set type to GDEC if you want to ask for a decimal
number or GHEX if you want that the user inputs a hexadecimal number.
*/
int gnumask(char *message, int maxlen, int type);
/* void gstrask(char *buffer, char *message, int maxlen);
Asks for a str that will be in buffer. message contains
the message that will be displayed when asking for the
string and maxlen is the maximal length of the input.
Asks for a str that will be in buffer. message contains the message that will be
displayed when asking for the string and maxlen is the maximal length of the
input.
*/
void gstrask(char *buffer, char *message, int maxlen);
/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode);
Draws an fkey from a Sprite Coder string that is in img,
at fkey position pos.
Draws an fkey from a Sprite Coder string that is in img, at fkey position pos.
*/
void gfkeyset(int pos, unsigned char *img);
@ -269,4 +266,101 @@ Draws a message box of height height with that contains message.
void gmessagebox(int height, char *message);
/******* Memory *******/
/* File types */
enum {
MFILE = 1,
MFOLDER = 5
};
/* Open modes */
enum {
MREAD = 0x01,
MWRITE = 0x02,
MREADW = (MREAD | MWRITE),
MSHARE = 0x80,
MRWS = (MREADW | MSHARE)
};
/* Defines */
#define MRCONTINUE -1 /* Start reading from the current position. */
#define PATHSIZELIMIT 256 /* Max. path size */
/* Prototypes */
/* IMPORTANT NOTE : The CASIOWIN/Fugue compatibility is made automatically. */
/* int mfugue(void);
Returns a postive int if the calculator has a fugue filesystem, or 0 if his fs
is CASIOWIN.
*/
int mfugue(void);
/* int mremove(const char *filename);
Removes the file filename. filename is a const char path for UNIX.
*/
int mremove(const char *filename);
/* int mcreate(const char *filename, int type, int size);
Creates the file or folder filename with size size. filename is a const char
path for UNIX.
Set type to MFILE if you want to create a file. Please consider that your add-in
may run on a CASIOWIN calculator, so please enter the real size of your file,
and not 0.
But if you want to create a folder, set type to MFOLDER and then you can also
set the size to 0 and I also recommend that because fxlib does that.
Returns a negative int if there was an error.
*/
int mcreate(const char *filename, int type, int size);
/* int mopen(const char *filename, int mode);
Opens the file filename with mode mode.
Available modes are :
- MREAD : Opens the file only for reading.
- MWRITE : Opens the file only for writing.
- MREADW : Opens the file for reading and writing.
- MSHARE : (I don't know what it is XD) Opens the file in shared mode.
- MRWS : Opens the file for reading, writing and in shared mode.
As always the filename is for UNIX and is fixed for the calc.
Returns an error code or the file descriptor of this file.
*/
int mopen(const char *filename, int mode);
/* int mwrite(int fd, const void *data, int size);
Writes size bytes of data to the file of file descriptor fd that you can get
with mopen.
Return a negative value if there was an error.
*/
int mwrite(int fd, const void *data, int size);
/* int mread(int fd, void *data, int size, int whence);
Read size bytes of the file of fd and put them into data. Set whence to a
positive value to set where mread should start reading, or to MRCONTINUE to
continue reading from the actual position.
Return a negative value if there was an error.
*/
int mread(int fd, void *data, int size, int whence);
/* int mclose(int fd);
Close the file descriptor fd.
*/
#endif

Binary file not shown.