Re: [cc65] Uniform mass storage device discovery and file locations

From: Karri Kaksonen <karri1sipo.fi>
Date: 2012-08-16 12:24:02
On 08/16/2012 11:55 AM, Oliver Schmidt wrote:
> The mass storage device discovery I'm asking for in this thread isn't
> related to any POSIX standard. I'm striving for a cc65-proprietary yet
> cc65-cross-target facility.

There are cases where it would be nice to detect if an EEPROM exists on 
a cart or not.

A typical Lynx game has a high-score or game-save feature. Usually I 
keep the high-scores in RAM and write them on EEPROM in case there is an 
EEPROM. I would like to be able to write

if (getActiveDrives() & DRIVE_EEPROM) {
    // EEPROM exists
    char currentDrive = getCurrentDrive();
    setCurrentDrive(EEPROM);
    fd = open("0", O_RDWR);
    read(fd, &highscoreTable, sizeof(highscoreTable));
    // close(fd);
    setCurrentDrive(currentDrive);
}

I can easily live with cc65 specific stuff like:

// return a bit mask of available drives
// 00000000 00000001 DRIVE_ROM0
// 00000000 00000010 DRIVE_ROM1
// 00000000 00000100 DRIVE_EEPROM
unsigned int getActiveDrives();

// 0 - ROM0
// 1 - ROM1
// 2 - EEPROM
setCurrentDrive(unsigned char);

// 0 - ROM0
// 1 - ROM1
// 2 - EEPROM
unsigned char getCurrentDrive();

Then we keep "open" as it is without a concept of specifying the drive 
at all.

You could also write a replacement "open" library that uses the new 
primitives above to create a more complex "open".
--
Regards,
Karri


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Aug 16 12:24:49 2012

This archive was generated by hypermail 2.1.8 : 2012-08-16 12:24:52 CEST