libsidplayfp  0.3.5
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
SidTune Class Reference

#include <SidTune.h>

Inheritance diagram for SidTune:
SidTuneMod

List of all members.

Public Member Functions

 SidTune (const char *fileName, const char **fileNameExt=0, const bool separatorIsSlash=false)
 SidTune (const uint_least8_t *oneFileFormatSidtune, const uint_least32_t sidtuneLength)
void setFileNameExtensions (const char **fileNameExt)
bool load (const char *fileName, const bool separatorIsSlash=false)
bool read (const uint_least8_t *sourceBuffer, const uint_least32_t bufferLen)
const SidTuneInfooperator[] (const uint_least16_t songNum)
uint_least16_t selectSong (const uint_least16_t songNum)
const SidTuneInfogetInfo ()
void getInfo (SidTuneInfo &)
 operator bool ()
bool getStatus ()
bool isStereo ()
bool placeSidTuneInC64mem (uint_least8_t *c64buf)
bool saveC64dataFile (const char *destFileName, const bool overWriteFlag=false)
bool saveSIDfile (const char *destFileName, const bool overWriteFlag=false)
bool savePSIDfile (const char *destFileName, const bool overWriteFlag=false)
void fixLoadAddress (const bool force=false, uint_least16_t initAddr=0, uint_least16_t playAddr=0)
bool loadFile (const char *fileName, Buffer_sidtt< const uint_least8_t > &bufferRef)
bool saveToOpenFile (std::ofstream &toFile, const uint_least8_t *buffer, uint_least32_t bufLen)

Protected Member Functions

void convertOldStyleSpeedToTables (uint_least32_t speed, int clock=SIDTUNE_CLOCK_PAL)
 Convert 32-bit PSID-style speed word to internal tables.
virtual int convertPetsciiToAscii (SmartPtr_sidtt< const uint_least8_t > &, char *)
bool checkCompatibility (void)
 Check compatibility details are sensible.
bool checkRelocInfo (void)
 Check for valid relocation information.
bool resolveAddrs (const uint_least8_t *c64data)
 Common address resolution procedure.
virtual LoadStatus PSID_fileSupport (Buffer_sidtt< const uint_least8_t > &dataBuf)
virtual bool PSID_fileSupportSave (std::ofstream &toFile, const uint_least8_t *dataBuffer)
virtual LoadStatus SID_fileSupport (Buffer_sidtt< const uint_least8_t > &dataBuf, Buffer_sidtt< const uint_least8_t > &sidBuf)
virtual bool SID_fileSupportSave (std::ofstream &toFile)
virtual LoadStatus MUS_fileSupport (Buffer_sidtt< const uint_least8_t > &musBuf, Buffer_sidtt< const uint_least8_t > &strBuf)
LoadStatus MUS_load (Buffer_sidtt< const uint_least8_t > &musBuf, bool init=false)
LoadStatus MUS_load (Buffer_sidtt< const uint_least8_t > &musBuf, Buffer_sidtt< const uint_least8_t > &strBuf, bool init=false)
virtual bool MUS_detect (const void *buffer, const uint_least32_t bufLen, uint_least32_t &voice3Index)
virtual bool MUS_mergeParts (Buffer_sidtt< const uint_least8_t > &musBuf, Buffer_sidtt< const uint_least8_t > &strBuf)
virtual void MUS_setPlayerAddress ()
virtual void MUS_installPlayer (uint_least8_t *c64buf)
virtual LoadStatus INFO_fileSupport (Buffer_sidtt< const uint_least8_t > &dataBuf, Buffer_sidtt< const uint_least8_t > &infoBuf)
virtual LoadStatus PRG_fileSupport (const char *fileName, Buffer_sidtt< const uint_least8_t > &dataBuf)
virtual LoadStatus X00_fileSupport (const char *fileName, Buffer_sidtt< const uint_least8_t > &dataBuf)

Protected Attributes

SidTuneInfo info
bool status
uint_least8_t songSpeed [SIDTUNE_MAX_SONGS]
uint_least8_t clockSpeed [SIDTUNE_MAX_SONGS]
uint_least16_t songLength [SIDTUNE_MAX_SONGS]
char infoString [SIDTUNE_MAX_CREDIT_STRINGS][SIDTUNE_MAX_CREDIT_STRLEN]
 holds text info from the format headers etc.
bool isSlashedFileName
uint_least32_t fileOffset
 For files with header: offset to real data.
uint_least16_t musDataLen
 Needed for MUS/STR player installation.
Buffer_sidtt< const uint_least8_t > cache

Static Protected Attributes

static const char ** fileNameExtensions = defaultFileNameExt
 Filename extensions to append for various file types.
Error and status message strings.
static const char * txt_songNumberExceed = "SIDTUNE WARNING: Selected song number was too high"
static const char * txt_empty = "SIDTUNE ERROR: No data to load"
static const char * txt_unrecognizedFormat = "SIDTUNE ERROR: Could not determine file format"
static const char * txt_noDataFile = "SIDTUNE ERROR: Did not find the corresponding data file"
static const char * txt_notEnoughMemory = "SIDTUNE ERROR: Not enough free memory"
static const char * txt_cantLoadFile = "SIDTUNE ERROR: Could not load input file"
static const char * txt_cantOpenFile = "SIDTUNE ERROR: Could not open file for binary input"
static const char * txt_fileTooLong = "SIDTUNE ERROR: Input data too long"
static const char * txt_dataTooLong = "SIDTUNE ERROR: Size of music data exceeds C64 memory"
static const char * txt_cantCreateFile = "SIDTUNE ERROR: Could not create output file"
static const char * txt_fileIoError = "SIDTUNE ERROR: File I/O error"
static const char * txt_VBI = "VBI"
static const char * txt_CIA = "CIA 1 Timer A"
static const char * txt_noErrors = "No errors"
static const char * txt_na = "N/A"
static const char * txt_badAddr = "SIDTUNE ERROR: Bad address data"
static const char * txt_badReloc = "SIDTUNE ERROR: Bad reloc data"
static const char * txt_corrupt = "SIDTUNE ERROR: File is incomplete or corrupt"

Detailed Description

SidTune


Constructor & Destructor Documentation

SidTune::SidTune ( const char *  fileName,
const char **  fileNameExt = 0,
const bool  separatorIsSlash = false 
)

Load a sidtune from a file.

To retrieve data from standard input pass in filename "-". If you want to override the default filename extensions use this contructor. Please note, that if the specified ``sidTuneFileName'' does exist and the loader is able to determine its file format, this function does not try to append any file name extension. See sidtune.cpp'' for the default list of file name extensions. You can specificsidTuneFileName = 0'', if you do not want to load a sidtune. You can later load one with open().

SidTune::SidTune ( const uint_least8_t *  oneFileFormatSidtune,
const uint_least32_t  sidtuneLength 
)

Load a single-file sidtune from a memory buffer. Currently supported: PSID format


Member Function Documentation

void SidTune::fixLoadAddress ( const bool  force = false,
uint_least16_t  initAddr = 0,
uint_least16_t  playAddr = 0 
)

This function can be used to remove a duplicate C64 load address in the C64 data (example: FE 0F 00 10 4C ...). A duplicate load address of offset 0x02 is indicated by the ``fixLoad'' flag in the SidTuneInfo structure.

The ``force'' flag here can be used to remove the first load address and set new INIT/PLAY addresses regardless of whether a duplicate load address has been detected and indicated by ``fixLoad''. For instance, some position independent sidtunes contain a load address of 0xE000, but are loaded to 0x0FFE and call the player code at 0x1000.

Do not forget to save the sidtune file.

const SidTuneInfo & SidTune::getInfo ( )

Retrieve sub-song specific information. Beware! Still member-wise copy!

void SidTune::getInfo ( SidTuneInfo outInfo)

Get a copy of sub-song specific information. Beware! Still member-wise copy!

bool SidTune::isStereo ( )
inline

Whether sidtune uses two SID chips.

bool SidTune::load ( const char *  fileName,
const bool  separatorIsSlash = false 
)

Load a sidtune into an existing object. From a file.

bool SidTune::loadFile ( const char *  fileName,
Buffer_sidtt< const uint_least8_t > &  bufferRef 
)

Does not affect status of object, and therefore can be used to load files. Error string is put into info.statusString, though.

SidTune::operator bool ( )
inline

Determine current state of object (true = okay, false = error). Upon error condition use getInfo'' to get a descriptive text string inSidTuneInfo.statusString''.

const SidTuneInfo & SidTune::operator[] ( const uint_least16_t  songNum)

Select sub-song (0 = default starting song) and retrieve active song information.

bool SidTune::placeSidTuneInC64mem ( uint_least8_t *  c64buf)

Copy sidtune into C64 memory (64 KB).

bool SidTune::read ( const uint_least8_t *  sourceBuffer,
const uint_least32_t  bufferLen 
)

From a buffer.

bool SidTune::saveC64dataFile ( const char *  destFileName,
const bool  overWriteFlag = false 
)

These functions work for any successfully created object. overWriteFlag: true = Overwrite existing file. false = Default, return error when file already exists. One could imagine an "Are you sure ?"-checkbox before overwriting any file. returns: true = Successful, false = Error condition.

uint_least16_t SidTune::selectSong ( const uint_least16_t  songNum)

Select sub-song (0 = default starting song) and return active song number out of [1,2,..,SIDTUNE_MAX_SONGS].

void SidTune::setFileNameExtensions ( const char **  fileNameExt)
inline

The sidTune class does not copy the list of file name extensions, so make sure you keep it. If the provided pointer is 0, the default list will be activated. This is a static list which

is used by all SidTune objects.


Member Data Documentation

bool SidTune::isSlashedFileName
protected

If your opendir() and readdir()->d_name return path names that contain the forward slash (/) as file separator, but your operating system uses a different character, there are extra functions that can deal with this special case. Set separatorIsSlash to true if you like path names to be split correctly. You do not need these extra functions if your systems file separator is the forward slash.


The documentation for this class was generated from the following files: