From 4036a583df36a88d653114ad2397350919571765 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sat, 16 May 2020 17:11:55 +0200 Subject: [PATCH] bfile: add BFile syscalls on fx-CG 50 (still unstable) For some reason these syscalls tend to crash in a basic delete, create, open, write, close workflow (after the write is finished). I'll look into using the new gint/fxlib switch to use them safely. --- TODO | 3 +-- include/gint/bfile.h | 6 +++--- src/core/syscalls.S | 46 ++++++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index 5d6bd33..a382c3e 100644 --- a/TODO +++ b/TODO @@ -7,8 +7,7 @@ For the 2.0.0 release: Crucial, missing things. ! core: the four basic memory functions (with automated tests) ! core: use gint_switch() to handle TLB misses -! core: return to menu on fxcg50 -! syscalls: fxcg50 BFile calls +! bfile: solve stability issues Issues. * #3 make drawing functions parameterized diff --git a/include/gint/bfile.h b/include/gint/bfile.h index 9b0d740..4facfc6 100644 --- a/include/gint/bfile.h +++ b/include/gint/bfile.h @@ -24,7 +24,7 @@ int BFile_Remove(uint16_t const *file); @file FONTCHARACTER file path @type Entry type - @size Pointer to file size if [type = BFile_File], ignored otherwise + @size Pointer to file size if [type = BFile_File], use NULL otherwise Returns a BFile error code. */ enum BFile_EntryType { @@ -102,8 +102,8 @@ struct BFile_FileInfo uint32_t data_size; /* Is 0 if the file is complete */ uint32_t property; - /* Address of first fragmented (do not use directly) */ - uint32_t address; + /* Address of first fragment (do not use directly) */ + void *address; }; int BFile_FindFirst(uint16_t const *search, int *shandle, uint16_t *foundfile, struct BFile_FileInfo *fileinfo); diff --git a/src/core/syscalls.S b/src/core/syscalls.S index e3a5c49..5db34e6 100644 --- a/src/core/syscalls.S +++ b/src/core/syscalls.S @@ -62,45 +62,24 @@ _realloc: /* BFile driver */ -# int BFile_Remove(const uint16_t *file) _BFile_Remove: syscall(0x0439) - -# int BFile_Create(uint16_t *file, enum { file = 1, folder = 5 }, int *size) _BFile_Create: syscall(0x0434) - -# int BFile_Open(const uint16_t *file, int mode) _BFile_Open: syscall(0x042c) - -# int BFile_Close(int handle) _BFile_Close: syscall(0x042d) - -# int BFile_Size(int handle) _BFile_Size: syscall(0x042f) - -# int BFile_Write(int handle, const void *ram_buffer, int even_size) _BFile_Write: syscall(0x0435) - -# int BFile_Read(int handle, void *ram_buffer, int size, int whence) _BFile_Read: syscall(0x0432) - -# int BFile_FindFirst(uint16_t const *search, int *shandle, -# uint16_t *foundfile, struct BFile_FileInfo *fileinfo) _BFile_FindFirst: syscall(0x043b) - -# int BFile_FindNext(int shandle, uint16_t *foundfile, -# struct BFile_FileInfo *fileinfo) _BFile_FindNext: syscall(0x043c) - -# int BFile_FindClose(int shandle) _BFile_FindClose: syscall(0x043d) @@ -141,6 +120,31 @@ _calloc: _realloc: syscall(0x1f46) +/* BFile driver */ + +_BFile_Remove: + syscall(0x1db4) +_BFile_Create: + syscall(0x1dae) +_BFile_Open: + syscall(0x1da3) +_BFile_Close: + syscall(0x1da4) +_BFile_Size: + syscall(0x1da6) +_BFile_Write: + syscall(0x1daf) +_BFile_Read: + syscall(0x1dac) +_BFile_FindFirst: + syscall(0x1db7) +_BFile_FindNext: + syscall(0x1db9) +_BFile_FindClose: + syscall(0x1dba) + +/* Return to menu */ + ___Timer_Install: syscall(0x8d9) ___Timer_Start: