SuperH-based fx calculators
fx-CG20, Bfile

Legacy Bfile syscalls

syscall 0x1DAE : int Bfile_CreateEntry_OS(  const unsigned short*filename, int mode, int*size  );
Creates either a file or a directory in storage memory.
To create a file call 0x1DAE with size pointing to the required file size and mode = 1.
To create a directory call 0x1DAE with size = nil and mode = 5.
The length of filename must be less than h'10A, else the function returns errorcode -3.
The filename has to start with "\\fls0\" or "\\crd0\". Else errorcode -5 is returned (wrong device).

Contrary to the legacy systems, on the fx-CG20, a new file seems to be filled with zeros instead of 0xFF.

The system needs about 3 minutes to create a file of 1 MB size.

syscall 0x1DA3 : int Bfile_OpenFile_OS( const unsigned short*filename, int mode );
Opens a file in storage memory and returns either a HANDLE or an errorcode. Errorcodes are < 0.
mode:
_OPENMODE_READ 0x01 (not yet verified on the fx-CG20)
_OPENMODE_READ_SHARE
0x80 (not yet verified on the fx-CG20)
_OPENMODE_WRITE
0x02    (verified on the fx-CG20)
_OPENMODE_READWRITE
0x03 (not yet verified on the fx-CG20)
_OPENMODE_READWRITE_SHARE
0x83 (not yet verified on the fx-CG20)

syscall 0x1DA4: int Bfile_CloseFile_OS( int HANDLE );
Closes an open file in storage memory.

syscall 0x1DA6: int Bfile_GetFileSize_OS( int HANDLE );
Returns the filesize.

syscall 0x1DA9: int Bfile_SeekFile_OS( int HANDLE, int pos );
Moves the current filepos to pos.

syscall 0x1DAB: int Bfile_Filepos( int HANDLE );
Returns the current filepos.

syscall 0x1DAC: int Bfile_ReadFile_OS( int HANDLE, void *buf, int size, int readpos );

syscall 0x1DAF: int Bfile_WriteFile_OS( int HANDLE, const void *buf, int size );
Writes to an open file in storage memory.

syscall 0x1DB3: int Bfile_RenameEntry( const unsigned short *oldname , const unsigned short *newname );
Renames a file as well as a directory. It is even possibly to move a file to a different directory.
syscall 0x1DB4: int Bfile_DeleteEntry( const unsigned short *entryname );
Deletes a file as well as a directory.
syscall 0x1DB6: int Bfile_FindFirst_FAT( const unsigned short *filename, int*FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo );
Does not support the
address-member of FILE_INFO.

This call is invoked by 1DB7, if a device other than the SMEM is accessed. The members of the FILE_INFO-struct are not used as documented in the legacy SDK!

syscall 0x1DB7: int Bfile_FindFirst( const unsigned short *filename, int*FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo );
FONTCHARACTER is unsigned short in the current implementation (as in the legacy systems).

typedef struct tag_FILE_INFO
{
    unsigned short id;
    unsigned short type;
    unsigned long fsize;
    unsigned long dsize;
    unsigned int property;
    unsigned long address;
} FILE_INFO;

The function checks the length of the filename first. In case it should be greater than 0x10A the function returns errorcode -3.

Every FindHandle has to be closed with Bfile_FindClose, if is is not needed any more!

syscall 0x1DB8: int Bfile_FindNext_FAT( int FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo );
Does not support the address-member of FILE_INFO.

This call is invoked by 1DB9, if a device other than the SMEM is accessed. The members of the FILE_INFO-struct are not used as documented in the legacy SDK!

syscall 0x1DB9: int Bfile_FindNext( int FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo );
This call seems to be unable to enumerate files in subdirectories.
syscall 0x1DBA: int Bfile_FindClose( int FindHandle );

syscall 0x1DD4: int Bfile_Name_strcpy(const short *target, const short *source );

syscall 0x1DD6: int Bfile_Name_strcmp(const short *s1, const short *s2 );

syscall 0x1DD8: int Bfile_Name_tolower( int c );
syscall 0x1DD9: int Bfile_Name_toupper( int c );
syscall 0x1DDA: int Bfile_Name_MatchMask( const short*mask, const short*filename  );
syscall 0x1DDB: void Bfile_NameToStr_ncpy( unsigned char*dest, const unsigned short*source, int n );
Copies a Bfile-name to a string. If the length of source is below n, dest is padded. If source is terminated by 0xFFFF dest is padded with 0xFF else 0x00!
syscall 0x1DDC: void Bfile_StrToName_ncpy( unsigned short*dest, const unsigned char*source, int n );
Copies a string to a Bfile-name. If the length of source is below n, dest is padded. If source is terminated by 0xFF dest is padded with 0xFFFF else 0x0000!
syscall 0x1DDD: void Bfile_Name_npad( const short *s, int c, int n );
Pad a Bfile_Name with character c up to position n.
syscall 0x1DDE: void Bfile_Name_toupper_tolower( const short *s, int mode );
mode 1: toupper
mode 2: tolower
syscall 0x1DDF: void*Bfile_Name_strchr( const short *s, int c );
syscall 0x1DE0: void*Bfile_Name_strrchr( const short *s, int c );

 


(06.05.2012 06:37:40)