Re: [cc65] Atari file i/o functions

Date view Thread view Subject view

From: Shawn Jefferson (sjefferson_at_sd62.bc.ca)
Date: 2002-04-24 22:28:29


>>> Christian Groessler <cpg_at_aladdin.de> 04/24/02 03:40AM >>>
>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.

I just did some testing in basic with SpartaDOS v3.3a and there are several XIO functions that work like this:

XIO 37 - POINT:
  Aux3 lo byte (<256)
  Aux4 high byte ( * 256)
  Aux5 highest byte (* 65536)

XIO 38 - NOTE:
  Returns file position in Aux3-5 like POINT.

XIO 39 - file length (could use this for SEEK_END):
  Returns file position in Aux3-5 like POINT.

I propose doing lseek something like this:

off_t __fastcall__ lseek(int fd, off_t offset, int whence)
{
  off_t pos;


  switch(whence) {
    SEEK_SET:
      pos = 0;
      break;
    SEEK_CUR:
      pos = note(fd);                   // XIO #38 SpartaDOS
      break;
    SEEK_END:
      pos = filesize(fd);               // XIO #39 SpartaDOS
      break;
  }

  pos += offset;
  
  // we could check for seek_cur and offset of 0 and not call point
  point(fd, pos);                     // XIO #37 SpartaDOS

  pos = note(fd);
  return(pos);
}

and implementing note, point and filesize as assembly functions.  Of course this doesn't work in AtariDOS since it needs a bunch of magic to go from sector/byte to offset..  Do you know how MyDOS implements XIO 37, 38 (and 39?)

I think I could figure out how to write the assembly for these functions, but am at a bit of a loss as to error checking and returning, etc... and will probably never be able to compile the atari library as I'm not running linux anywhere.  Someone else would have to compile and test it, unfortunately.



----------------------------------------------------------------------
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 22:29:50 CEST