Re: [cc65] Atari file i/o functions

Date view Thread view Subject view

From: Christian Groessler (cpg_at_aladdin.de)
Date: 2002-04-24 12:40:37


Hi,

On 04/23/2002 01:08:28 PM MST "Shawn Jefferson" wrote:
>
>I was doing some programming on the Atari with the C file i/o
>functions and I noticed that fseek and ftell, and fopen with append
>are not implemented.

Correct.

>
>I took a look at the source for the atari library and I figured that
>fseek and ftell could be implemented for SpartaDOS fairly easily,
>since SpartaDOS implements a sane NOTE and POINT functions in the
>FMS.  POINT is XIO#37 and NOTE is XIO #38.  AtariDOS is another story
>since it doesn't use an offset from the beginning of the file like
>SpartaDOS... it uses sector and byte!  Ugh!

I don't know about SpartaDOS, but since I'm using it all the time and
if it has "sane" NOTE and POINT, it'd be worthwile to implement
fseek/ftell for it.


On 04/23/2002 02:01:17 PM MST "Shawn Jefferson" wrote:
>
>Ok.  We will have to do a bunch of stuff in the lseek function to
>implement it properly, in assembly... ugh.  The Atari has the fseek
>and ftell functions built into the DOS, called POINT and NOTE.  We
>have to call point after working out the offset from whence, call CIO
>with the command for point and then call CIO again with the command
>for note to return the file position.  All in assembly... not my
>forte unfortunately.. I will have to do some quick learning! ;)

I had the idea to implementing fseek and ftell (that's the reason
there is the lseek.s file), but it appeared as rather difficult.

The NOTE call returns the sector number on disk and the offset inside
the sector of the current file position. This can then later be given
to the POINT command to set the file ptr to the same position.

I order to provide a generic fseek function which uses the file
offset, one whould have to re-read the whole file to get to the
correct position, since there is no easy way to find the sector
number from file offset. An optimization idea I had, was to modify the
read/write functions to always split the read/write sizes to sector
sizes and make a NOTE call after every read/write and generate a file
offset <-> sector table in RAM. But this will further reduce
read/write speed.

This is for Atari DOS, if SpartaDOS provides NOTE and POINT functions
which use the file offset, it should be easy to implement there.

regards,
chris

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-04-24 12:41:57 CEST