Author Topic: Prizm File I/O Problems  (Read 4050 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
Prizm File I/O Problems
« on: September 03, 2011, 04:52:59 pm »
A few questions regarding how to use some of the functions declared in the fxcg-10/20's version of "stdio.h":


Bfile_OpenFile_OS seems rather awkward for many reasons:  first off, why does it need a pointer to a string of unsigned shorts?  Is this for 2 byte character sets?  It compiles fine with a pointer to a string of chars, (of course it throws a warning, but no error) but do I need to manually input byte sequences to access non-ASCII characters (that was worded bad, but basically, do I need to input different characters to represent the same ones if this parameter is not meant for ASCII characters)?

Secondly, files have to start with "\\fls0\" -- though PrizmWiki doesn't tell how the rest of the file extension has to be represented.  Is "\\fls0\city.pcc" as valid extension?

Thirdly, for Bfile_CreateEntry_OS, what type of modes are available (apparently I should use mode (int) 1, but are there other options?) and what do they do?  Why in god's name do we need to pass the parameter for size as a pointer to the int that holds the size value?  How do you specify where to save it?

For those interested, here's a snippet of code dealing with it (from my contest entry, but I snipped out everything not in question with a "...":

   
Code: [Select]
int SAVE_HANDLE = Bfile_OpenFile_OS("\\fls0\city.pcc", 0x03);
if(SAVE_HANDLE < 0) {

...

Bfile_CreateEntry_OS("city.pcc", 1, size_needed);
} else { ... }
« Last Edit: September 03, 2011, 05:35:57 pm by Ashbad »

Ashbad

  • Guest
Re: Prizm File I/O Problems
« Reply #1 on: September 04, 2011, 12:44:19 pm »
bump.

Offline Horrowind

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +6/-0
    • View Profile
Re: Prizm File I/O Problems
« Reply #2 on: September 04, 2011, 02:28:04 pm »
You could take a look at casios manuals for there fx-9860 SDK (which can be found here: http://edu.casio.com/dl/ under fx-9860 SDk). The Bfile-functions seem to be similar on both calcs, maybe this will help. I dont have a prizm, so these infos build on the similarity of the two platforms.

As for your questions:
1. As far as I understand, there can be two-byte chars, at least for displaying. These would look as described in the character set pdf from these manuals.

2. The manual gives this example: PathName[]={'¥¥','¥¥','f','l','s','0','¥¥','f','i','l','e','n','a','m','e','.','e','x','t',0}; So yes, yours seem to be right.

3. On the old fx, the mode option can be used to create a directory (mode = 5).
I think it being a pointer to an int is a mistake. In the syscall-documentation of simlo is no pointer but a single int.
For where to save it: I think you have to specify the whole path (as in the example above).

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: Prizm File I/O Problems
« Reply #3 on: September 05, 2011, 12:50:37 pm »
Stoop!
Not [inset two yen symbols] but  '\\'

Offline Horrowind

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +6/-0
    • View Profile
Re: Prizm File I/O Problems
« Reply #4 on: September 05, 2011, 01:10:58 pm »
yes, i know, but i was refering to the manual and unwilling to replace them :P

Ashbad

  • Guest
Re: Prizm File I/O Problems
« Reply #5 on: September 05, 2011, 03:13:28 pm »
I think I now realize what's wrong, after I saw GCC didn't know what escape sequence '\c' was...

Since the "\\fls0\" isn't escaped, it's not represented right.  It should be "\\\\fls0\\" instead.  Found the error :)

EDIT: nope, still non-working :/
« Last Edit: September 05, 2011, 03:43:42 pm by Ashbad »

Offline SimonLothar

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 129
  • Rating: +35/-1
    • View Profile
Re: Prizm File I/O Problems
« Reply #6 on: September 05, 2011, 04:07:13 pm »
If Bfile_OpenFile_OS and Bfile_CreateEntry_OS, which you use, are based on the corresponding syscalls, you have to use a short array to pass the filename.
You could use
syscall 0x1DDC: void Bfile_StrToName_ncpy( unsigned short*dest, const unsigned char*source, int n );
to copy a string constant into a short array.
Refer to fx_calculators_SuperH_based_10.chm: the BFile syscall section for details.
I am surprised, that the compiler does not complain about:
Bfile_OpenFile_OS("\\\\fls0\\city.pcc", 0x03);

I'll be back.

Ashbad

  • Guest
Re: Prizm File I/O Problems
« Reply #7 on: September 05, 2011, 06:42:52 pm »
Awesome!  It works now! thanks :D