diff --git a/.gitignore b/.gitignore index 2e708e50..14321f8c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ out/ bin/ gen/ .idea/ -playbae +xcuserdata/ +minibae/Tools/playbae/playbae diff --git a/minibae/BAE_Source/Common/DriverTools.c b/minibae/BAE_Source/Common/DriverTools.c index 43ff128a..2b047694 100755 --- a/minibae/BAE_Source/Common/DriverTools.c +++ b/minibae/BAE_Source/Common/DriverTools.c @@ -248,7 +248,7 @@ SongResource * XNewSongPtr( SongType songType, switch (songType) { case SONG_TYPE_SMS: - songSMS = (SongResource_SMS *)XNewPtr((long)sizeof(SongResource_SMS)); + songSMS = (SongResource_SMS *)XNewPtr((XSDWORD)sizeof(SongResource_SMS)); if (songSMS) { songSMS->songType = SONG_TYPE_SMS; @@ -266,7 +266,7 @@ SongResource * XNewSongPtr( SongType songType, song = (SongResource *)songSMS; break; case SONG_TYPE_RMF: - songRMF = (SongResource_RMF *)XNewPtr((long)sizeof(SongResource_RMF) - sizeof(short)); + songRMF = (SongResource_RMF *)XNewPtr((XSDWORD)sizeof(SongResource_RMF) - sizeof(short)); if (songRMF) { songRMF->songType = SONG_TYPE_RMF; @@ -281,7 +281,7 @@ SongResource * XNewSongPtr( SongType songType, song = (SongResource *)songRMF; break; case SONG_TYPE_RMF_LINEAR: - songRMF2 = (SongResource_RMF_Linear *)XNewPtr((long)sizeof(SongResource_RMF_Linear) - sizeof(short)); + songRMF2 = (SongResource_RMF_Linear *)XNewPtr((XSDWORD)sizeof(SongResource_RMF_Linear) - sizeof(short)); if (songRMF2) { songRMF2->songType = SONG_TYPE_RMF_LINEAR; @@ -322,7 +322,7 @@ void XGetKeySplitFromPtr(InstrumentResource *theX, short int entry, KeySplit *ke } else { - XSetMemory((void *)keysplit, (long)sizeof(KeySplit), 0); + XSetMemory((void *)keysplit, (XSDWORD)sizeof(KeySplit), 0); } } @@ -331,12 +331,12 @@ void XGetKeySplitFromPtr(InstrumentResource *theX, short int entry, KeySplit *ke // Find a resource type and return a pointer to its memory block. If type is R_LAST_RESOURCE, then return // a pointer to the very last memory block #if USE_FULL_RMF_SUPPORT == TRUE -static void * PV_FindSongResourceTypePointer(SongResource_RMF *songRMF, SongResourceType findType, long *pResourceLength) +static void * PV_FindSongResourceTypePointer(SongResource_RMF *songRMF, SongResourceType findType, XSDWORD *pResourceLength) { char *pUnit; short int count, subCount; SongResourceType type; - unsigned long length; + XDWORD length; short int resourceCount; void *pEnd; @@ -382,16 +382,16 @@ static void * PV_FindSongResourceTypePointer(SongResource_RMF *songRMF, SongReso // this is a zero terminated string, always if (songRMF->locked == FALSE) { - length = (unsigned long)XStrLen(pUnit) + 1; + length = (XDWORD)XStrLen(pUnit) + 1; } else { - length = (unsigned long)XEncryptedStrLen(pUnit) + 1; + length = (XDWORD)XEncryptedStrLen(pUnit) + 1; } pUnit += length; if (pResourceLength) { - *pResourceLength = (long)length; + *pResourceLength = (XSDWORD)length; } break; case R_VELOCITY_CURVE: @@ -409,7 +409,7 @@ static void * PV_FindSongResourceTypePointer(SongResource_RMF *songRMF, SongReso pUnit += length; if (pResourceLength) { - *pResourceLength = (long)length; + *pResourceLength = (XSDWORD)length; } break; } @@ -434,15 +434,15 @@ static void * PV_FindSongResourceTypePointer(SongResource_RMF *songRMF, SongReso // dataTarget or lengthTarget can be NULL. If not NULL, then data will be placed there // if both are non-NULL, *lengthTarget is assumed to be the length in bytes of the block at dataTarget static void PV_FillSongResource(SongResourceType resourceType, short int resourceCount, XBOOL encrypted, - void* pResourceData, unsigned long resourceDataLength, - void* dataTarget, unsigned long* lengthTarget) + void* pResourceData, XDWORD resourceDataLength, + void* dataTarget, XDWORD* lengthTarget) { char *pUnit; short int count, subCount; SongResourceType type; XBOOL fill; - unsigned long length; - unsigned long textBytes; + XDWORD length; + XDWORD textBytes; if (pResourceData && resourceCount && resourceDataLength) { @@ -486,11 +486,11 @@ static void PV_FillSongResource(SongResourceType resourceType, short int resourc // this is a zero terminated string, always if (encrypted == FALSE) { - length = (unsigned long)XStrLen(pUnit) + 1; + length = (XDWORD)XStrLen(pUnit) + 1; } else { - length = (unsigned long)XEncryptedStrLen(pUnit) + 1; + length = (XDWORD)XEncryptedStrLen(pUnit) + 1; } if (fill) { @@ -602,10 +602,10 @@ static XBOOL PV_ValidResourceForSongType(SongResourceType resourceType, SongType #endif //USE_CREATION_API == TRUE #if USE_CREATION_API == TRUE -static SongResource_RMF * PV_AddRMFSongResource(SongResource *theSong, SongResourceType resourceType, void *pResource, long resourceLength) +static SongResource_RMF * PV_AddRMFSongResource(SongResource *theSong, SongResourceType resourceType, void *pResource, XDWORD resourceLength) { SongResource_RMF *newSong; - long size; + XDWORD size; char *pBlock; newSong = NULL; @@ -614,7 +614,7 @@ static SongResource_RMF * PV_AddRMFSongResource(SongResource *theSong, SongResou if (PV_ValidResourceForSongType(resourceType, SONG_TYPE_RMF)) { size = XGetPtrSize(theSong); - newSong = (SongResource_RMF *)XNewPtr((long)(size + sizeof(SongResourceType) + resourceLength)); + newSong = (SongResource_RMF *)XNewPtr((XSDWORD)(size + sizeof(SongResourceType) + resourceLength)); if (newSong) { XBlockMove(theSong, newSong, size); @@ -623,7 +623,7 @@ static SongResource_RMF * PV_AddRMFSongResource(SongResource *theSong, SongResou { size = XGetShort(&newSong->resourceCount) + 1; XPutShort(&newSong->resourceCount, (unsigned short)size); - XPutLong(pBlock, (unsigned long)resourceType); + XPutLong(pBlock, (XDWORD)resourceType); pBlock += 4; XBlockMove(pResource, pBlock, resourceLength); } @@ -642,7 +642,7 @@ static SongResource_RMF * PV_AddRMFSongResource(SongResource *theSong, SongResou static SongResource_RMF * PV_DeleteRMFSongResource(SongResource *theSong, SongResourceType resourceType) { SongResource_RMF *newSong; - long size, resourceLength, offsetStart, offsetEnd; + XSDWORD size, resourceLength, offsetStart, offsetEnd; char *pBlock; newSong = NULL; @@ -653,7 +653,7 @@ static SongResource_RMF * PV_DeleteRMFSongResource(SongResource *theSong, SongRe pBlock = (char *)PV_FindSongResourceTypePointer((SongResource_RMF *)theSong, resourceType, &resourceLength); if (pBlock) { - size = (long)(XGetPtrSize(theSong) - sizeof(SongResourceType) - resourceLength); + size = (XSDWORD)(XGetPtrSize(theSong) - sizeof(SongResourceType) - resourceLength); if (size > 0) { newSong = (SongResource_RMF *)XNewPtr(size); @@ -664,7 +664,7 @@ static SongResource_RMF * PV_DeleteRMFSongResource(SongResource *theSong, SongRe XBlockMove(theSong, newSong, offsetStart); XBlockMove(((char *)theSong) + offsetEnd, ((char *)newSong) + offsetStart, size - offsetEnd); - size = (long)XGetShort(&newSong->resourceCount) - 1; + size = (XSDWORD)XGetShort(&newSong->resourceCount) - 1; XPutShort(&newSong->resourceCount, (unsigned short)size); } } @@ -678,7 +678,7 @@ static SongResource_RMF * PV_DeleteRMFSongResource(SongResource *theSong, SongRe // Given a SongResource and a new type, data and length, this will create a new SongResource // with the modified resource and return it. // The newly returned SongResource is allocated, and the old one passed in is not deallocated. -SongResource * XChangeSongResource(SongResource *theSong, long songSize, SongResourceType resourceType, void *pResource, long resourceLength) +SongResource * XChangeSongResource(SongResource *theSong, XDWORD songSize, SongResourceType resourceType, void *pResource, XDWORD resourceLength) { SongResource_SMS *songSMS; SongResource_RMF *songRMF; @@ -809,20 +809,21 @@ static SongInfo PV_TranslateSongResourceTypeIntoSongInfo(SongResourceType type) } -unsigned long XGetSongInformationSize(SongResource *theSong, long songSize, SongInfo type) +XDWORD XGetSongInformationSize(SongResource *theSong, XDWORD songSize, SongInfo type) { char *pData, *pName; - long length, offset; - unsigned long temp; + XSDWORD length, offset; + XDWORD temp; SongResourceType r_temp; SongResource_SMS *songSMS; SongResource_RMF *songRMF; - unsigned long size; + XDWORD size; size = 0; if (theSong && songSize) { - switch (((SongResource_SMS *)theSong)->songType) + SongType type = (SongType)((SongResource_SMS *)theSong)->songType; + switch (type) { case SONG_TYPE_SMS: songSMS = (SongResource_SMS *)theSong; @@ -942,12 +943,12 @@ unsigned long XGetSongInformationSize(SongResource *theSong, long songSize, Song #endif // USE_FULL_RMF_SUPPORT == TRUE #if USE_FULL_RMF_SUPPORT == TRUE -void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, - char* targetBuffer, unsigned long bufferBytes) +void XGetSongInformation(SongResource *theSong, XDWORD songSize, SongInfo type, + XBYTE* targetBuffer, XDWORD bufferBytes) { char *pData, *pName; - long length, offset; - unsigned long temp; + XSDWORD length, offset; + XDWORD temp; SongResourceType r_temp; SongResource_SMS *songSMS; SongResource_RMF *songRMF; @@ -977,7 +978,7 @@ void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, pData = (char *)songSMS; offset += temp; pName = (char *)pData + offset; - XBlockMove(pName + 1, targetBuffer, (long)pName[0]); + XBlockMove(pName + 1, targetBuffer, (XSDWORD)pName[0]); targetBuffer[(short)pName[0]] = 0; } break; @@ -994,7 +995,7 @@ void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, { pData = (char *)songSMS; pName = (char *)pData + offset; - XBlockMove(pName + 1, targetBuffer, (long)pName[0]); + XBlockMove(pName + 1, targetBuffer, (XSDWORD)pName[0]); targetBuffer[(short)pName[0]] = 0; } break; @@ -1020,7 +1021,7 @@ void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, if (offset < length) { pName = (char *)pData + offset; - XBlockMove(pName + 1, targetBuffer, (long)pName[0]); + XBlockMove(pName + 1, targetBuffer, (XSDWORD)pName[0]); targetBuffer[(short)pName[0]] = 0; } } @@ -1051,7 +1052,7 @@ void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, if (offset < length) { pName = (char *)pData + offset; - XBlockMove(pName + 1, targetBuffer, (long)pName[0]); + XBlockMove(pName + 1, targetBuffer, (XSDWORD)pName[0]); targetBuffer[(short)pName[0]] = 0; } } @@ -1156,7 +1157,7 @@ XBOOL XIsSongCompressed(SongResource *pSong) { XShortResourceID id; XPTR data; - long type; + XSDWORD type; XBOOL compressed; compressed = FALSE; @@ -1227,7 +1228,7 @@ void XSetSongLocked(SongResource *pSong, XBOOL locked) SongResource_RMF *songRMF; SongResource_RMF_Linear *songRMF2; char *pData; - unsigned long length; + XDWORD length; char *pUnit; short int count, resourceCount; SongResourceType type; @@ -1257,7 +1258,7 @@ void XSetSongLocked(SongResource *pSong, XBOOL locked) if (resourceCount) { pData = (char *)&songRMF->resourceData; - length = (unsigned long)(pData - (char *)songRMF); + length = (XDWORD)(pData - (char *)songRMF); pUnit = pData; for (count = 0; count < resourceCount; count++) { @@ -1297,21 +1298,21 @@ void XSetSongLocked(SongResource *pSong, XBOOL locked) // this is a zero terminated string, always if ( (songRMF->locked == FALSE) && locked) { - length = (unsigned long)XStrLen(pUnit) + 1; + length = (XDWORD)XStrLen(pUnit) + 1; XEncryptData(pUnit, length); } if (songRMF->locked && (locked == FALSE)) { - length = (unsigned long)XEncryptedStrLen(pUnit) + 1; + length = (XDWORD)XEncryptedStrLen(pUnit) + 1; XDecryptData(pUnit, length); } if (songRMF->locked && (locked)) { - length = (unsigned long)XEncryptedStrLen(pUnit) + 1; + length = (XDWORD)XEncryptedStrLen(pUnit) + 1; } if ((songRMF->locked == FALSE) && (locked == FALSE)) { - length = (unsigned long)XStrLen(pUnit) + 1; + length = (XDWORD)XStrLen(pUnit) + 1; } pUnit += length; break; @@ -1656,7 +1657,7 @@ static const SongResourceType rmf_processTypes[] = R_MANUFACTURER, R_MISC1, R_MISC2, R_MISC3, R_MISC4, R_MISC5, R_MISC6, R_MISC7, R_MISC8 }; -SongResource_Info * XGetSongResourceInfo(SongResource *pSong, long songSize) +SongResource_Info * XGetSongResourceInfo(SongResource *pSong, XDWORD songSize) { SongResource_Info *pInfo; char *text; @@ -1670,7 +1671,7 @@ SongResource_Info * XGetSongResourceInfo(SongResource *pSong, long songSize) text = (char *)XNewPtr(8192L); if (pSong && songSize && text) { - pInfo = (SongResource_Info *)XNewPtr((long)sizeof(SongResource_Info)); + pInfo = (SongResource_Info *)XNewPtr((XSDWORD)sizeof(SongResource_Info)); if (pInfo) { // fields common to all types @@ -1744,7 +1745,7 @@ SongResource * XNewSongFromSongResourceInfo(SongResource_Info *pSongInfo) char *resourceName; SongResourceType type; SongResourceType const *pProcess; - long resourceLength; + XSDWORD resourceLength; newSong = NULL; max = 0; @@ -1865,10 +1866,10 @@ void XDisposeSongResourceInfo(SongResource_Info *pSongInfo) // // if pType is not NULL, then store the type // if pReturnedSize is not NULL, then store size -XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pType) +XPTR XGetMidiData(XLongResourceID theID, XDWORD *pReturnedSize, XResourceType *pType) { XPTR theData, pData; - long midiSize; + XDWORD midiSize; XResourceType type; type = ID_NULL; @@ -1881,13 +1882,13 @@ XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pTy if (pData) { XBlockMove(theData, pData, midiSize); - XDecryptData(pData, (unsigned long)midiSize); // decrypt first + XDecryptData(pData, (XDWORD)midiSize); // decrypt first } XDisposePtr(theData); theData = pData; if (theData) { - pData = XDecompressPtr(theData, (unsigned long)midiSize, TRUE); // uncompress second + pData = XDecompressPtr(theData, (XDWORD)midiSize, TRUE); // uncompress second if (pData) { midiSize = XGetPtrSize(pData); // get new size @@ -1912,7 +1913,7 @@ XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pTy if (pData) { XBlockMove(theData, pData, midiSize); - XDecryptData(pData, (unsigned long)midiSize); // decrypt first + XDecryptData(pData, (XDWORD)midiSize); // decrypt first type = ID_EMID; } XDisposePtr(theData); @@ -1926,7 +1927,7 @@ XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pTy theData = XGetAndDetachResource(ID_CMID, theID, &midiSize); if (theData) { - pData = XDecompressPtr(theData, (unsigned long)midiSize, TRUE); + pData = XDecompressPtr(theData, (XDWORD)midiSize, TRUE); if (pData) { XDisposePtr(theData); @@ -1962,10 +1963,10 @@ XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pTy // Get sound resource and detach from resource manager but don't decompress. -XPTR XGetRawSoundResourceByID(XLongResourceID theID, XResourceType *pReturnedType, long *pReturnedSize) +XPTR XGetRawSoundResourceByID(XLongResourceID theID, XResourceType *pReturnedType, XDWORD *pReturnedSize) { XPTR theData; - long size; + XSDWORD size; XResourceType type; size = 0; @@ -1998,10 +1999,10 @@ XPTR XGetRawSoundResourceByID(XLongResourceID theID, XResourceType *pReturnedTyp // Get sound resource and detach from resource manager or decompress // This function can be replaced for a custom sound retriver -XPTR XGetSoundResourceByID(XLongResourceID theID, long *pReturnedSize) +XPTR XGetSoundResourceByID(XLongResourceID theID, XDWORD *pReturnedSize) { XPTR thePreSound, theData; - unsigned long size; + XDWORD size; // look for compressed version first theData = XGetAndDetachResource(ID_CSND, theID, pReturnedSize); @@ -2011,14 +2012,14 @@ XPTR XGetSoundResourceByID(XLongResourceID theID, long *pReturnedSize) theData = XGetAndDetachResource(ID_ESND, theID, pReturnedSize); if (theData) { - size = (unsigned long)*pReturnedSize; + size = (XDWORD)*pReturnedSize; // since this is encrypted, make a new copy and decrypt thePreSound = theData; - theData = XNewPtr((long)size); + theData = XNewPtr((XSDWORD)size); if (theData) { - XBlockMove(thePreSound, theData, (long)size); + XBlockMove(thePreSound, theData, (XSDWORD)size); XDecryptData(theData, size); } XDisposePtr(thePreSound); @@ -2032,7 +2033,7 @@ XPTR XGetSoundResourceByID(XLongResourceID theID, long *pReturnedSize) else { thePreSound = theData; - theData = XDecompressPtr(thePreSound, (unsigned long)*pReturnedSize, FALSE); + theData = XDecompressPtr(thePreSound, (XDWORD)*pReturnedSize, FALSE); XDisposePtr(thePreSound); *pReturnedSize = XGetPtrSize(theData); } @@ -2042,7 +2043,7 @@ XPTR XGetSoundResourceByID(XLongResourceID theID, long *pReturnedSize) #if X_PLATFORM != X_WEBTV // Get sound resource and detach from resource manager or decompress // This function can be replaced for a custom sound retriver -XPTR XGetSoundResourceByName(void *cName, long *pReturnedSize) +XPTR XGetSoundResourceByName(void *cName, XDWORD *pReturnedSize) { XPTR thePreSound, theData; @@ -2065,7 +2066,7 @@ XPTR XGetSoundResourceByName(void *cName, long *pReturnedSize) if (theData) { XBlockMove(thePreSound, theData, *pReturnedSize); - XDecryptData(theData, (unsigned long)*pReturnedSize); + XDecryptData(theData, (XDWORD)*pReturnedSize); } XDisposePtr(thePreSound); } @@ -2074,7 +2075,7 @@ XPTR XGetSoundResourceByName(void *cName, long *pReturnedSize) else { thePreSound = theData; - theData = XDecompressPtr(thePreSound, (unsigned long)*pReturnedSize, FALSE); + theData = XDecompressPtr(thePreSound, (XDWORD)*pReturnedSize, FALSE); XDisposePtr(thePreSound); *pReturnedSize = XGetPtrSize(theData); } @@ -2222,21 +2223,21 @@ void XSetSongReverbType(SongResource *pSong, short int reverbType) XPTR XCreateBankStatus(BankStatus *pStatus) { char *pBank, *pData; - long size; + XSDWORD size; pBank = NULL; if (pStatus) { size = XStrLen(pStatus->bankURL) + 1; size += XStrLen(pStatus->bankName) + 1; - size += sizeof(long); + size += sizeof(XSDWORD); pBank = (char *)XNewPtr(size); if (pBank) { pData = pBank; XPutLong(pData, pStatus->version); - pData += sizeof(long); + pData += sizeof(XSDWORD); size = XStrLen(pStatus->bankURL) + 1; if (size > 1) { @@ -2258,7 +2259,7 @@ XPTR XCreateVersion(short int major, short int minor, short int subMinor) { XVersion *pVers; - pVers = (XVersion *)XNewPtr((long)sizeof(XVersion)); + pVers = (XVersion *)XNewPtr((XSDWORD)sizeof(XVersion)); if (pVers) { XPutShort(&pVers->versionMajor, major); @@ -2273,17 +2274,17 @@ XPTR XCreateVersion(short int major, short int minor, short int subMinor) void XGetBankStatus(BankStatus *pStatus) { char *pBank; - long size; + XSDWORD size; if (pStatus) { - XSetMemory((XPTR)pStatus, (long)sizeof(BankStatus), 0); + XSetMemory((XPTR)pStatus, (XSDWORD)sizeof(BankStatus), 0); pBank = (char *)XGetAndDetachResource(ID_BANK, DEFAULT_RESOURCE_BANK_ID, &size); if (pBank) { pStatus->version = XGetLong(pBank); // get version - pBank += sizeof(long); // get bank URL + pBank += sizeof(XSDWORD); // get bank URL size = XStrLen(pBank) + 1; if (size > BANK_NAME_MAX_SIZE-1) { @@ -2314,7 +2315,7 @@ XAliasLinkResource * XGetAliasLink(void) XERR XLookupAlias(XAliasLinkResource *pLink, XLongResourceID sourceID, XLongResourceID *pDestID) { XERR err; - unsigned long count, max; + XDWORD count, max; err = -1; if (pDestID && pLink) @@ -2362,7 +2363,7 @@ XAliasLinkResource * XGetAliasLinkFromFile(XFILE thisFile) void XGetVersionNumber(XVersion *pVersionNumber) { XVersion *pData; - long size; + XSDWORD size; if (pVersionNumber) { diff --git a/minibae/BAE_Source/Common/GenAudioStreams.c b/minibae/BAE_Source/Common/GenAudioStreams.c index 0135ae95..0848cf86 100755 --- a/minibae/BAE_Source/Common/GenAudioStreams.c +++ b/minibae/BAE_Source/Common/GenAudioStreams.c @@ -300,9 +300,9 @@ struct GM_AudioStreamFileInfo { XFILENAME playbackFile; XFILE fileOpenRef; - unsigned long fileStartPosition; // units are in bytes but as a complete decoded sample - unsigned long filePlaybackPosition; // for example: fileEndPosition for a MP3 file might be 40 MB. - unsigned long fileEndPosition; // these variables are used for positioning and control. + XDWORD fileStartPosition; // units are in bytes but as a complete decoded sample + XDWORD filePlaybackPosition; // for example: fileEndPosition for a MP3 file might be 40 MB. + XDWORD fileEndPosition; // these variables are used for positioning and control. XBOOL loopFile; GM_SoundDoneCallbackPtr doneCallback; @@ -313,7 +313,7 @@ struct GM_AudioStreamFileInfo long formatType; // typed file compression mode XPTR pBlockBuffer; // used for decompression - unsigned long blockSize; // used for decompression + XDWORD blockSize; // used for decompression }; typedef struct GM_AudioStreamFileInfo GM_AudioStreamFileInfo; @@ -341,12 +341,12 @@ typedef enum struct GM_PlaybackEvent { GM_EventStatus status; - unsigned long framePosition; + XDWORD framePosition; }; typedef struct GM_PlaybackEvent GM_PlaybackEvent; // $$kk: 09.23.98: end changes <- -#define STREAM_OFFSET_UNSET (unsigned long)0xFFFFFFFFL +#define STREAM_OFFSET_UNSET (XDWORD)0xFFFFFFFFL // this structure, once allocated, becomes a STREAM_REFERENCE struct GM_AudioStream @@ -357,37 +357,37 @@ struct GM_AudioStream // will be DEAD_VOICE if not active OPErr startupStatus; // error return before startup - short int startupBufferFullCount; + XWORD startupBufferFullCount; GM_StreamObjectProc streamCallback; GM_StreamData streamData; void *pStreamBuffer; - unsigned long streamBufferLength; + XDWORD streamBufferLength; - unsigned long streamPreRollBufferSize; // size in frames of how many sample frames + XDWORD streamPreRollBufferSize; // size in frames of how many sample frames // are prerolled prior to playback. This is // set after stream is created. Its used as // an offset to streamPlaybackPosition - unsigned long streamOrgLength1; - unsigned long streamOrgLength2; + XDWORD streamOrgLength1; + XDWORD streamOrgLength2; void *pStreamData1; void *pStreamData2; - unsigned long streamLength1; - unsigned long streamLength2; + XDWORD streamLength1; + XDWORD streamLength2; XBYTE streamMode; // Stream modes XBYTE lastStreamBufferPlayed; - unsigned long streamPlaybackResetAtPosition; // in samples - unsigned long streamPlaybackResetToThisPosition; // in samples + XDWORD streamPlaybackResetAtPosition; // in samples + XDWORD streamPlaybackResetToThisPosition; // in samples - unsigned long streamPlaybackPosition; // in samples; samples in this stream processed by engine - unsigned long streamPlaybackOffset; // in samples; total samples processed by engine when this stream starts - unsigned long samplesWritten; // update in GM_AudioStreamService. total number of samples - unsigned long samplesPlayed; // update in GM_AudioStreamUpdateSamplesPlayed. total number of samples played + XDWORD streamPlaybackPosition; // in samples; samples in this stream processed by engine + XDWORD streamPlaybackOffset; // in samples; total samples processed by engine when this stream starts + XDWORD samplesWritten; // update in GM_AudioStreamService. total number of samples + XDWORD samplesPlayed; // update in GM_AudioStreamUpdateSamplesPlayed. total number of samples played // $$kk: 08.12.98 merge: added this field - unsigned long residualSamples; // if we're underflowing, then get more data and reset streamPlaybackOffset + XDWORD residualSamples; // if we're underflowing, then get more data and reset streamPlaybackOffset // before playing all samples, need to record that we can still play these // samples before reaching the new streamPlaybackOffset. @@ -545,7 +545,7 @@ static STREAM_REFERENCE PV_GetEmptyAudioStream(void) } -static unsigned long PV_GetSampleSizeInBytes(GM_StreamData * pAS) +static XDWORD PV_GetSampleSizeInBytes(GM_StreamData * pAS) { return pAS->channelSize * (pAS->dataBitSize / 8); } @@ -553,8 +553,8 @@ static unsigned long PV_GetSampleSizeInBytes(GM_StreamData * pAS) static void PV_FillBufferEndWithSilence(char *pDest, GM_StreamData * pAS) { - unsigned long bufferSize, blockSize; - unsigned long count; + XDWORD bufferSize, blockSize; + XDWORD count; short int *pWData; if (pDest) @@ -584,7 +584,7 @@ static void PV_FillBufferEndWithSilence(char *pDest, GM_StreamData * pAS) static void PV_CopyLastSamplesToFirst(char *pSource, char *pDest, GM_StreamData * pAS) { - unsigned long bufferSize, blockSize; + XDWORD bufferSize, blockSize; if (pAS->dataLength && pSource && pDest) { @@ -1013,7 +1013,7 @@ OPErr GM_AudioStreamError(STREAM_REFERENCE reference) static OPErr PV_FileStreamCallback(void *context, GM_StreamMessage message, GM_StreamData *pAS) { OPErr error; - unsigned long bufferSize, fileSize, outputBufferSize; + XDWORD bufferSize, fileSize, outputBufferSize; GM_AudioStreamFileInfo *pASInfo; GM_AudioStream *pStream; short int blockAlign; @@ -1131,7 +1131,7 @@ static OPErr PV_FileStreamCallback(void *context, GM_StreamMessage message, GM_S case STREAM_SET_POSITION: { - unsigned long samplePosition; + XDWORD samplePosition; pStream = (GM_AudioStream *)pAS->streamReference; pASInfo = (GM_AudioStreamFileInfo *)pAS->userReference; @@ -1222,7 +1222,7 @@ static OPErr PV_FileStreamCallback(void *context, GM_StreamMessage message, GM_S error = NO_ERR; if (pASInfo->loopFile) { - unsigned long savePos; + XDWORD savePos; pStream->streamPlaybackResetAtPosition = (pASInfo->filePlaybackPosition - pASInfo->fileStartPosition) / blockAlign; @@ -1354,14 +1354,14 @@ XBOOL GM_AudioStreamGetLoop(STREAM_REFERENCE reference) // setup streaming a file and place it into pause mode. Don't start STREAM_REFERENCE GM_AudioStreamFileSetup(void *threadContext, XFILENAME *file, AudioFileType fileType, - unsigned long bufferSize, GM_Waveform *pFileInfo, + XDWORD bufferSize, GM_Waveform *pFileInfo, XBOOL loopFile) { STREAM_REFERENCE reference; GM_Waveform *pWaveform; GM_AudioStreamFileInfo *pStream; long format; - unsigned long blockSize; + XDWORD blockSize; OPErr err; void *blockPtr; @@ -1426,7 +1426,7 @@ STREAM_REFERENCE GM_AudioStreamFileSetup(void *threadContext, // long This is an audio reference number. Will be non-zero for valid stream STREAM_REFERENCE GM_AudioStreamSetup(void *threadContext, long userReference, GM_StreamObjectProc pProc, - unsigned long bufferSize, + XDWORD bufferSize, XFIXED sampleRate, // Fixed 16.16 sample rate char dataBitSize, // 8 or 16 bit data char channelSize) // 1 or 2 channels of date @@ -1435,7 +1435,7 @@ STREAM_REFERENCE GM_AudioStreamSetup(void *threadContext, long userReference, GM GM_AudioStream *pStream; GM_StreamData ssData; OPErr theErr; - unsigned long byteLength; + XDWORD byteLength; reference = DEAD_STREAM; theErr = NO_ERR; @@ -1939,11 +1939,11 @@ OPErr GM_AudioStreamStop(void *threadContext, STREAM_REFERENCE reference) // get the position of samples played in a stream. This will be as close as // posible to realtime. Probably off by engine latency. -unsigned long GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference) +XDWORD GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference) { #if 0 GM_AudioStream *pStream; - unsigned long samplePosition; + XDWORD samplePosition; samplePosition = 0; pStream = PV_AudioStreamGetFromReference(reference); @@ -1968,7 +1968,7 @@ unsigned long GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference return samplePosition; #else GM_AudioStream *pStream; - unsigned long samplePosition; + XDWORD samplePosition; samplePosition = 0; pStream = PV_AudioStreamGetFromReference(reference); @@ -1990,11 +1990,11 @@ unsigned long GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference // Get the file position of a audio stream, in samples. This // value is the current file track position. This does not equal what has // been played. Typically it will be ahead of real time. -unsigned long GM_AudioStreamGetFileSamplePosition(STREAM_REFERENCE reference) +XDWORD GM_AudioStreamGetFileSamplePosition(STREAM_REFERENCE reference) { GM_AudioStreamFileInfo *pInfo; GM_AudioStream *pStream; - unsigned long samplePosition; + XDWORD samplePosition; short int blockAlign; samplePosition = 0; @@ -2019,7 +2019,7 @@ unsigned long GM_AudioStreamGetFileSamplePosition(STREAM_REFERENCE reference) } // Set the file position of a audio stream, in samples -OPErr GM_AudioStreamSetFileSamplePosition(STREAM_REFERENCE reference, unsigned long framePos) +OPErr GM_AudioStreamSetFileSamplePosition(STREAM_REFERENCE reference, XDWORD framePos) { GM_AudioStream *pStream; GM_AudioStreamFileInfo *pFileInfo; @@ -2051,8 +2051,8 @@ OPErr GM_AudioStreamSetFileSamplePosition(STREAM_REFERENCE reference, unsigned l return err; } -OPErr GM_AudioStreamGetData(void *threadContext, STREAM_REFERENCE reference, unsigned long startFrame, unsigned long stopFrame, - XPTR pBuffer, unsigned long bufferLength) +OPErr GM_AudioStreamGetData(void *threadContext, STREAM_REFERENCE reference, XDWORD startFrame, XDWORD stopFrame, + XPTR pBuffer, XDWORD bufferLength) { GM_AudioStream *pStream; OPErr theErr; @@ -2109,10 +2109,10 @@ short int GM_AudioStreamGetStereoPosition(STREAM_REFERENCE reference) // Get the playback offset in samples for the stream. // This is the offset between the number of samples processed // by the mixer and the number of samples processed from this stream. -unsigned long GM_AudioStreamGetSampleOffset(STREAM_REFERENCE reference) +XDWORD GM_AudioStreamGetSampleOffset(STREAM_REFERENCE reference) { GM_AudioStream *pStream; - unsigned long offset = 0; + XDWORD offset = 0; pStream = PV_AudioStreamGetFromReference(reference); @@ -2125,10 +2125,10 @@ unsigned long GM_AudioStreamGetSampleOffset(STREAM_REFERENCE reference) // Get the engine's count of samples from this stream actually // played through the device. -unsigned long GM_AudioStreamGetSamplesPlayed(STREAM_REFERENCE reference) +XDWORD GM_AudioStreamGetSamplesPlayed(STREAM_REFERENCE reference) { GM_AudioStream *pStream; - unsigned long samplesPlayed = 0; + XDWORD samplesPlayed = 0; pStream = PV_AudioStreamGetFromReference(reference); @@ -2145,7 +2145,7 @@ unsigned long GM_AudioStreamGetSamplesPlayed(STREAM_REFERENCE reference) void GM_AudioStreamDrain(void *threadContext, STREAM_REFERENCE reference) { GM_AudioStream *pStream; - unsigned long samplesWritten; + XDWORD samplesWritten; // get the samples written. // we have to drain until samples played reaches this value. @@ -2948,17 +2948,17 @@ void GM_AudioStreamService(void *threadContext) // update number of samples played for each stream // delta is number of samples engine advanced, in its format // $$kk: 08.12.98 merge: changed this method to allow streams to exist in the engine until all samples played -void GM_AudioStreamUpdateSamplesPlayed(unsigned long delta) +void GM_AudioStreamUpdateSamplesPlayed(XDWORD delta) { GM_AudioStream *pStream, *pNext; - unsigned long outputSampleRate; + XDWORD outputSampleRate; //$$kk: 05.08.98: adding this variable and removing the next one - unsigned long streamSampleRate; + XDWORD streamSampleRate; //XFIXED scaling; - unsigned long streamDelta; // delta in stream-format samples - unsigned long samplesCommitted = 0; + XDWORD streamDelta; // delta in stream-format samples + XDWORD samplesCommitted = 0; pStream = theStreams; @@ -2993,7 +2993,7 @@ void GM_AudioStreamUpdateSamplesPlayed(unsigned long delta) (MusicGlobals->samplesPlayed > pStream->streamPlaybackOffset)) { // we need to handle the case where the stream may just be starting up again - if ((unsigned long)(MusicGlobals->samplesPlayed - + if ((XDWORD)(MusicGlobals->samplesPlayed - pStream->streamPlaybackOffset) < streamDelta) { streamDelta = MusicGlobals->samplesPlayed - pStream->streamPlaybackOffset; diff --git a/minibae/BAE_Source/Common/GenCache.c b/minibae/BAE_Source/Common/GenCache.c index 1cbb87b4..04af5a8f 100755 --- a/minibae/BAE_Source/Common/GenCache.c +++ b/minibae/BAE_Source/Common/GenCache.c @@ -693,3 +693,43 @@ UINT32 PV_GetCacheIndexFromCachePtr(GM_Mixer * pMixer, *pErr = PARAM_ERR; return 0; } + +/****************************************************************************** +******************************************************************************* +******************************************************************************* +** +** Functions to manage bank tokens +** +******************************************************************************* +******************************************************************************* +******************************************************************************/ + + +XBOOL AreBankTokensIdentical(XBankToken tok1, XBankToken tok2) +{ + if (tok1.fileLen == tok2.fileLen && tok1.xFile == tok2.xFile) + { + return TRUE; + } + return FALSE; +} + +XBankToken CreateBankToken(void) +{ + XBankToken retVal; + + retVal.xFile = (XTOKEN) XFileGetCurrentResourceFile(); + retVal.fileLen = XFileGetLength(retVal.xFile); + + return retVal; +} + +XBankToken CreateBankTokenFromInputs(XTOKEN tok, XDWORD len) +{ + XBankToken retVal; + + retVal.xFile = tok; + retVal.fileLen = len; + + return retVal; +} diff --git a/minibae/BAE_Source/Common/GenCache.h b/minibae/BAE_Source/Common/GenCache.h index d8bb4951..f726b468 100755 --- a/minibae/BAE_Source/Common/GenCache.h +++ b/minibae/BAE_Source/Common/GenCache.h @@ -68,10 +68,7 @@ #ifndef G_CACHE #define G_CACHE -#ifndef __X_API__ - #include "X_API.h" -#endif - +#include "X_API.h" #include "GenPriv.h" #ifdef __cplusplus diff --git a/minibae/BAE_Source/Common/GenPatch.c b/minibae/BAE_Source/Common/GenPatch.c index ee2233b2..a4845208 100755 --- a/minibae/BAE_Source/Common/GenPatch.c +++ b/minibae/BAE_Source/Common/GenPatch.c @@ -653,11 +653,7 @@ static GM_Instrument * PV_CreateInstrumentFromResource(GM_Instrument *theMaster, // Next, increment refcount and grab it's pointer. if (GMCache_IsIDInCache(pMixer, theID, bankToken) != TRUE) { - sndInfo = GMCache_BuildSampleCacheEntry(pMixer, - theID, - bankToken, - NULL, - pErr); + sndInfo = GMCache_BuildSampleCacheEntry(pMixer, theID, bankToken, NULL, pErr); } else { diff --git a/minibae/BAE_Source/Common/GenPriv.h b/minibae/BAE_Source/Common/GenPriv.h index 03c5c096..7e29f47e 100755 --- a/minibae/BAE_Source/Common/GenPriv.h +++ b/minibae/BAE_Source/Common/GenPriv.h @@ -461,8 +461,8 @@ typedef struct U3232 #endif #endif -typedef unsigned char OUTSAMPLE8; -typedef short int OUTSAMPLE16; // 16 bit output sample +typedef XBYTE OUTSAMPLE8; +typedef XSWORD OUTSAMPLE16; // 16 bit output sample enum { @@ -615,14 +615,14 @@ struct GM_SampleCacheEntry XSampleID theID; // sample ID XBankToken bankToken; // The unique bank token to supplement theID XFIXED rate; // sample rate - unsigned long waveSize; // size in bytes - unsigned long waveFrames; // number of frames - unsigned long loopStart; // loop start frame - unsigned long loopEnd; // loop end frame + XDWORD waveSize; // size in bytes + XDWORD waveFrames; // number of frames + XDWORD loopStart; // loop start frame + XDWORD loopEnd; // loop end frame char bitSize; // sample bit size; 8 or 16 char channels; // mono or stereo; 1 or 2 - short int baseKey; // base sample key - long referenceCount; // how many references to this sample block + XSWORD baseKey; // base sample key + XSDWORD referenceCount; // how many references to this sample block void *pSampleData; // pointer to sample data. This may be an offset into the pMasterPtr void *pMasterPtr; // master pointer that contains the snd format information }; @@ -765,7 +765,7 @@ struct GM_Mixer XDWORD reverbBufferSize; // Set the size of memory allocated here. // Make sure you set this because it is // compared and tested against - XSDWORD reverbPtr; // delay line index into verb buffer + XDWORD reverbPtr; // delay line index into verb buffer XSDWORD LPfilterL, LPfilterR; // used for fixed verb XSDWORD LPfilterLz, LPfilterRz; #endif @@ -823,8 +823,8 @@ struct NewReverbParams int mReadIndex[kNumberOfCombFilters]; int mWriteIndex[kNumberOfCombFilters]; - long mUnscaledDelayFrames[kNumberOfCombFilters]; - long mDelayFrames[kNumberOfCombFilters]; + XSDWORD mUnscaledDelayFrames[kNumberOfCombFilters]; + XSDWORD mDelayFrames[kNumberOfCombFilters]; XSDWORD mFeedbackList[kNumberOfCombFilters]; diff --git a/minibae/BAE_Source/Common/GenReverb.c b/minibae/BAE_Source/Common/GenReverb.c index 2fee5743..a5aa7c6b 100755 --- a/minibae/BAE_Source/Common/GenReverb.c +++ b/minibae/BAE_Source/Common/GenReverb.c @@ -118,7 +118,7 @@ static void PV_RunMonoFixedReverb(ReverbMode which) register INT32 *sourceLR, *sourceReverb; register INT32 *reverbBuf; register LOOPCOUNT a; - register long reverbPtr1, reverbPtr2, reverbPtr3, reverbPtr4; + register XDWORD reverbPtr1, reverbPtr2, reverbPtr3, reverbPtr4; reverbBuf = &MusicGlobals->reverbBuffer[0]; if (reverbBuf) diff --git a/minibae/BAE_Source/Common/GenReverbNew.c b/minibae/BAE_Source/Common/GenReverbNew.c index d1d61292..dd73c5b3 100755 --- a/minibae/BAE_Source/Common/GenReverbNew.c +++ b/minibae/BAE_Source/Common/GenReverbNew.c @@ -182,7 +182,8 @@ XBOOL InitNewReverb() // in order to reduce our RAM footprint (especially for WebTV). Therefore, we won't // actually allocate our own buffers for the 6 comb filters and the early reflections // buffer which happen to perfectly fit into the old buffer ;-) -#if 0 + //TODO: fix layed out shared verb memory +#if 1 long kMaxBytes = sizeof(INT32) * kCombBufferFrameSize; // allocate the comb filter delay line memory @@ -203,7 +204,7 @@ XBOOL InitNewReverb() return FALSE; } #else // share the old buffer - + //TODO: doesn't work in 64 bit Assert_(REVERB_BUFFER_SIZE*2 == (kCombBufferFrameSize*kNumberOfCombFilters + kEarlyReflectionBufferFrameSize) ); if(!MusicGlobals->reverbBuffer @@ -217,10 +218,10 @@ XBOOL InitNewReverb() for(i = 0; i < kNumberOfCombFilters; i++) { - params->mReverbBuffer[i] = MusicGlobals->reverbBuffer + i*kCombBufferFrameSize; + params->mReverbBuffer[i] = MusicGlobals->reverbBuffer + (i*kCombBufferFrameSize); } - params->mEarlyReflectionBuffer = MusicGlobals->reverbBuffer + REVERB_BUFFER_SIZE*2 - kEarlyReflectionBufferFrameSize; + params->mEarlyReflectionBuffer = MusicGlobals->reverbBuffer + (REVERB_BUFFER_SIZE*2) - kEarlyReflectionBufferFrameSize; #endif // allocate the diffusion delay line memory @@ -360,9 +361,10 @@ XBOOL CheckReverbType() } // clear out shared buffers, when switching reverb modes... + const INT32 kReverbBufferSize = kCombBufferFrameSize * sizeof(INT32); for(i = 0; i < kNumberOfCombFilters; i++) { - XSetMemory(params->mReverbBuffer[i], sizeof(INT32)*kCombBufferFrameSize, 0); + XSetMemory(params->mReverbBuffer[i], kReverbBufferSize, 0); } XSetMemory(params->mEarlyReflectionBuffer, sizeof(INT32)*kEarlyReflectionBufferFrameSize, 0); @@ -463,7 +465,7 @@ void ScaleDelayTimes() log10maxG = regenList[ (params->mMaxRegen >> 3 ) & 0xf ]; desiredMinFrames = srate * ((log10maxG * T60) >> 7); /*log10(maxG) * T60 / -3.0 */ - // ok, at this point, desiredMinFrames if FIXED 16.16 + // ok, at this point, desiredMinFrames is FIXED 16.16 kMinDelayFrames = 485L * GetSR_44100Ratio(); /*485L << 16*/ /* 11ms */ if(desiredMinFrames < kMinDelayFrames) desiredMinFrames = kMinDelayFrames; @@ -611,7 +613,7 @@ void GenerateFeedbackValues() #endif } -static long delay6tapList[6][6] = +static XSDWORD delay6tapList[6][6] = { { 1259, @@ -670,7 +672,7 @@ static long delay6tapList[6][6] = void GenerateDelayTimes() { int i; - long *delayFrameList; + XSDWORD *delayFrameList; NewReverbParams* params = GetNewReverbParams(); int index = params->mRoomChoice; @@ -679,10 +681,10 @@ void GenerateDelayTimes() delayFrameList = delay6tapList[index]; - + UINT32 ratio = GetSR_44100Ratio(); for(i = 0; i < kNumberOfCombFilters; i++) { - params->mUnscaledDelayFrames[i] = (delayFrameList[i] * GetSR_44100Ratio() ) >> 16; + params->mUnscaledDelayFrames[i] = (delayFrameList[i] * ratio ) >> 16; } ScaleDelayTimes(); diff --git a/minibae/BAE_Source/Common/GenSample.c b/minibae/BAE_Source/Common/GenSample.c index 9101c2e2..d37a53ce 100755 --- a/minibae/BAE_Source/Common/GenSample.c +++ b/minibae/BAE_Source/Common/GenSample.c @@ -293,7 +293,7 @@ static void PV_ServeEffectsFades(void) static void PV_ServeEffectCallbacks(void *threadContext) { long count, minValue, maxValue; - unsigned long offsetStart, offsetEnd; + XDWORD offsetStart, offsetEnd; GM_Voice *pVoice; GM_SampleCallbackEntry *pCallbackEntry; GM_Mixer *pMixer; @@ -450,6 +450,7 @@ XBOOL GM_IsSoundReferenceValid(VOICE_REFERENCE reference) goodVoice = FALSE; if (MusicGlobals) { + //FIX: not 64 bit if ( ((long)reference >= 0) && ((long)reference < (MusicGlobals->MaxNotes+MusicGlobals->MaxEffects)) ) { goodVoice = TRUE; @@ -488,22 +489,22 @@ XBOOL GM_IsSoundDone(VOICE_REFERENCE reference) // scan through fast, and get the largest peak static void PV_CalculateLargestPeak(GM_Voice *pVoice) { - short min = 0; - short max = 0; - short sample; - unsigned long noiseMin, noiseMax; - char *pStartB; - short *pStartW; - char *pEndB; - short *pEndW; + XSWORD min = 0; + XSWORD max = 0; + XSWORD sample; + XDWORD noiseMin, noiseMax; + XBYTE *pStartB; + XSWORD *pStartW; + XBYTE *pEndB; + XSWORD *pEndW; int step; if (pVoice) { - pStartW = (short *)pVoice->NotePtr; - pStartB = (char *)pVoice->NotePtr; - pEndW = (short *)pVoice->NotePtrEnd; - pEndB = (char *)pVoice->NotePtrEnd; + pStartW = (XSWORD *)pVoice->NotePtr; + pStartB = (XBYTE *)pVoice->NotePtr; + pEndW = (XSWORD *)pVoice->NotePtrEnd; + pEndB = (XBYTE *)pVoice->NotePtrEnd; pVoice->largestPeak = 0; if (pStartW < pEndW) @@ -544,8 +545,8 @@ static void PV_CalculateLargestPeak(GM_Voice *pVoice) pStartW += step; } } - noiseMin = ((long)min + 32768L); - noiseMax = ((long)32768L - max); + noiseMin = ((XSDWORD)min + 32768L); + noiseMax = ((XSDWORD)32768L - max); if (noiseMin < noiseMax) { pVoice->largestPeak = noiseMin; @@ -913,10 +914,10 @@ void GM_EndAllSamples(void) #if X_PLATFORM != X_WEBTV -unsigned long GM_GetSampleStartTimeStamp(VOICE_REFERENCE reference) +XDWORD GM_GetSampleStartTimeStamp(VOICE_REFERENCE reference) { GM_Voice *pVoice; - unsigned long time; + XDWORD time; time = 0; pVoice = PV_GetVoiceFromSoundReference(reference); @@ -928,9 +929,9 @@ unsigned long GM_GetSampleStartTimeStamp(VOICE_REFERENCE reference) } // given a valid voice, return the current playback position -unsigned long GM_GetSamplePlaybackPosition(VOICE_REFERENCE reference) +XDWORD GM_GetSamplePlaybackPosition(VOICE_REFERENCE reference) { - unsigned long position; + XDWORD position; GM_Voice *pVoice; position = 0L; @@ -944,7 +945,7 @@ unsigned long GM_GetSamplePlaybackPosition(VOICE_REFERENCE reference) } // given a valid voice, set the position of the current playback -OPErr GM_SetSamplePlaybackPosition(VOICE_REFERENCE reference, unsigned long framePos) +OPErr GM_SetSamplePlaybackPosition(VOICE_REFERENCE reference, XDWORD framePos) { GM_Voice *pVoice; OPErr err; @@ -963,7 +964,7 @@ OPErr GM_SetSamplePlaybackPosition(VOICE_REFERENCE reference, unsigned long fram return err; } -void * GM_GetSamplePlaybackPointer(VOICE_REFERENCE reference, unsigned long *outFrameLength) +void * GM_GetSamplePlaybackPointer(VOICE_REFERENCE reference, XDWORD *outFrameLength) { void *pointer; GM_Voice *pVoice; @@ -1262,7 +1263,7 @@ void GM_ChangeSampleVolume(VOICE_REFERENCE reference, INT16 sampleVolume) } #if X_PLATFORM != X_WEBTV -void GM_SetSampleLoopPoints(VOICE_REFERENCE reference, unsigned long start, unsigned long end) +void GM_SetSampleLoopPoints(VOICE_REFERENCE reference, XDWORD start, XDWORD end) { register GM_Voice *pVoice; @@ -1284,7 +1285,7 @@ void GM_SetSampleLoopPoints(VOICE_REFERENCE reference, unsigned long start, unsi #endif -OPErr GM_SetWaveformLoopPoints(GM_Waveform *pWave, unsigned long start, unsigned long end) +OPErr GM_SetWaveformLoopPoints(GM_Waveform *pWave, XDWORD start, XDWORD end) { OPErr theErr; @@ -1331,7 +1332,7 @@ OPErr GM_SetWaveformLoopPoints(GM_Waveform *pWave, unsigned long start, unsigned } -OPErr GM_GetWaveformLoopPoints(GM_Waveform *pWave, unsigned long *outStart, unsigned long *outEnd) +OPErr GM_GetWaveformLoopPoints(GM_Waveform *pWave, XDWORD *outStart, XDWORD *outEnd) { OPErr theErr; diff --git a/minibae/BAE_Source/Common/GenSeq.c b/minibae/BAE_Source/Common/GenSeq.c index 79f2b32e..7187b8ca 100755 --- a/minibae/BAE_Source/Common/GenSeq.c +++ b/minibae/BAE_Source/Common/GenSeq.c @@ -879,7 +879,7 @@ void GM_SetSongCallback(GM_Song *theSong, GM_SongCallbackProcPtr theCallback, vo } } -void GM_SetSongTimeCallback(GM_Song *theSong, GM_SongTimeCallbackProcPtr theCallback, long reference) +void GM_SetSongTimeCallback(GM_Song *theSong, GM_SongTimeCallbackProcPtr theCallback, XPTR reference) { if (theSong) { @@ -904,7 +904,7 @@ static void PV_CallSongMetaEventCallback(void *threadContext, GM_Song *pSong, ch } } -void GM_SetSongMetaEventCallback(GM_Song *theSong, GM_SongMetaCallbackProcPtr theCallback, long reference) +void GM_SetSongMetaEventCallback(GM_Song *theSong, GM_SongMetaCallbackProcPtr theCallback, XPTR reference) { if (theSong) { @@ -3084,7 +3084,7 @@ static void PV_ProcessIgorMeta(GM_Song *pSong, unsigned char *pMidiStream) // but we only can overide instruments not in use, so // we must use the current bank as our token. // files, assign it as such... - // bankToken = CreateBankTokenFromInputs((XTOKEN) pSong->midiData, (XTOKEN) 0); + // bankToken = CreateBankTokenFromInputs((XTOKEN) pSong->midiData, (XDWORD) 0); bankToken = CreateBankToken(); pMidiStream += 4; @@ -4199,7 +4199,7 @@ void GM_GetTrackSoloStatus(GM_Song *pSong, char *pStatus) // If allowPitch is FALSE, then "GM_SetSongPitchOffset" will have no effect on passed // channel (0 to 15) -void GM_AllowChannelPitchOffset(GM_Song *pSong, unsigned short int channel, XBOOL allowPitch) +void GM_AllowChannelPitchOffset(GM_Song *pSong, XWORD channel, XBOOL allowPitch) { if (pSong) { @@ -4215,7 +4215,7 @@ void GM_AllowChannelPitchOffset(GM_Song *pSong, unsigned short int channel, XBOO } // Return if the passed channel will allow pitch offset -XBOOL GM_DoesChannelAllowPitchOffset(GM_Song *pSong, unsigned short int channel) +XBOOL GM_DoesChannelAllowPitchOffset(GM_Song *pSong, XWORD channel) { XBOOL flag; @@ -4228,7 +4228,7 @@ XBOOL GM_DoesChannelAllowPitchOffset(GM_Song *pSong, unsigned short int channel) } // set note offset in semi tones (12 is down an octave, -12 is up an octave) -void GM_SetSongPitchOffset(GM_Song *pSong, long offset) +void GM_SetSongPitchOffset(GM_Song *pSong, XSWORD offset) { if (pSong) { @@ -4237,9 +4237,9 @@ void GM_SetSongPitchOffset(GM_Song *pSong, long offset) } // return note offset in semi tones (12 is down an octave, -12 is up an octave) -long GM_GetSongPitchOffset(GM_Song *pSong) +XSWORD GM_GetSongPitchOffset(GM_Song *pSong) { - long offset; + XSDWORD offset; offset = 0; if (pSong) diff --git a/minibae/BAE_Source/Common/GenSeqTools.c b/minibae/BAE_Source/Common/GenSeqTools.c index 6366ed1f..56e11521 100755 --- a/minibae/BAE_Source/Common/GenSeqTools.c +++ b/minibae/BAE_Source/Common/GenSeqTools.c @@ -76,7 +76,7 @@ // given a pointer, get a short int ordered in a Motorola way, and only // access on word bounderies -XWORD XGetShortWordAligned(XWORD *pData, long byteOffset) +XWORD XGetShortWordAligned(XWORD *pData, XSDWORD byteOffset) { short wordOffset; short byteIndex; @@ -117,7 +117,7 @@ XWORD XGetShortWordAligned(XWORD *pData, long byteOffset) } // given a pointer, get a long ordered in a Motorola way -XDWORD XGetLongWordAligned(XWORD *pData, long byteOffset) +XDWORD XGetLongWordAligned(XWORD *pData, XSDWORD byteOffset) { short wordOffset; short byteIndex; @@ -164,7 +164,7 @@ XDWORD XGetLongWordAligned(XWORD *pData, long byteOffset) } -XWORD XGetCharWordAligned(XWORD *pData, long byteOffset) +XWORD XGetCharWordAligned(XWORD *pData, XSDWORD byteOffset) { return (XGetShortWordAligned(pData, byteOffset) >> 8); } @@ -176,7 +176,7 @@ static short int PV_ToLower(short int c) } -short int XLStrnCmpWordAligned(const char* s1, XWORD *s2, long byteOffset, long n) +XWORD XLStrnCmpWordAligned(const char* s1, XWORD *s2, XSDWORD byteOffset, XDWORD n) { XWORD ch1, ch2; @@ -209,9 +209,9 @@ short int XLStrnCmpWordAligned(const char* s1, XWORD *s2, long byteOffset, long } -long XStrnToLongWordAligned(XWORD* pData, long byteOffset, long length) +XDWORD XStrnToLongWordAligned(XWORD* pData, XSDWORD byteOffset, XDWORD length) { - long result, numDigits, count; + XDWORD result, numDigits, count; XWORD ch; result = 0; diff --git a/minibae/BAE_Source/Common/GenSeqTools.h b/minibae/BAE_Source/Common/GenSeqTools.h index dd39f823..44362890 100755 --- a/minibae/BAE_Source/Common/GenSeqTools.h +++ b/minibae/BAE_Source/Common/GenSeqTools.h @@ -69,16 +69,18 @@ #ifndef G_SEQ_TOOLS #define G_SEQ_TOOLS +#include "X_API.h" + #ifdef __cplusplus extern "C" { #endif -XWORD XGetShortWordAligned(XWORD *pData, long byteOffset); -XDWORD XGetLongWordAligned(XWORD *pData, long byteOffset); -XWORD XGetCharWordAligned(XWORD *pData, long byteOffset); +XWORD XGetShortWordAligned(XWORD *pData, XSDWORD byteOffset); +XDWORD XGetLongWordAligned(XWORD *pData, XSDWORD byteOffset); +XWORD XGetCharWordAligned(XWORD *pData, XSDWORD byteOffset); -short int XLStrnCmpWordAligned(const char* s1, XWORD *s2, long byteOffset, long n); -long XStrnToLongWordAligned(XWORD* pData, long byteOffset, long length); +XWORD XLStrnCmpWordAligned(const char* s1, XWORD *s2, XSDWORD byteOffset, XDWORD n); +XDWORD XStrnToLongWordAligned(XWORD* pData, XSDWORD byteOffset, XDWORD length); #ifdef __cplusplus } diff --git a/minibae/BAE_Source/Common/GenSetup.c b/minibae/BAE_Source/Common/GenSetup.c index 4255db3f..e6861436 100755 --- a/minibae/BAE_Source/Common/GenSetup.c +++ b/minibae/BAE_Source/Common/GenSetup.c @@ -239,9 +239,9 @@ static XBOOL PV_ValidateRate(Rate theRate) // convert GenSynth Rate to actual sample rate used -unsigned long GM_ConvertFromOutputRateToRate(Rate rate) +XDWORD GM_ConvertFromOutputRateToRate(Rate rate) { - unsigned long sampleRate; + XDWORD sampleRate; sampleRate = 0; if (PV_ValidateRate(rate)) @@ -249,7 +249,7 @@ unsigned long GM_ConvertFromOutputRateToRate(Rate rate) switch (rate) { default: - sampleRate = (unsigned long)rate; + sampleRate = (XDWORD)rate; break; case Q_RATE_22K_TERP_44K: sampleRate = 44100; @@ -460,8 +460,8 @@ unsigned long BAE_GetSliceTimeInMicroseconds(void) // This assumes that the pMixer and theRate are valid, no exceptions. static void PV_SetSampleSliceSize(GM_Mixer *pMixer, Rate theRate) { - unsigned long maxChunkSize; - unsigned long rate; + XDWORD maxChunkSize; + XDWORD rate; pMixer->maxChunkSize = MAX_CHUNK_SIZE; pMixer->One_Slice = MAX_CHUNK_SIZE; @@ -1406,9 +1406,9 @@ UINT32 GM_GetDeviceTimeStamp(void) // given the sample frame size from the mixer variables // $$kk: 08.12.98 merge: changed this function // $$kk: no, we're getting the currentPos in SAMPLES, not bytes, from BAE_GetDeviceSamplesPlayedPosition(). -void GM_UpdateSamplesPlayed(unsigned long currentPos) +void GM_UpdateSamplesPlayed(XDWORD currentPos) { - unsigned long delta; + XDWORD delta; if (currentPos >= MusicGlobals->lastSamplePosition) { @@ -1432,7 +1432,7 @@ void GM_UpdateSamplesPlayed(unsigned long currentPos) // number of devices. ie different versions of the BAE connection. DirectSound and waveOut // return number of devices. ie 1 is one device, 2 is two devices. // NOTE: This function needs to function before any other calls may have happened. -long GM_MaxDevices(void) +XDWORD GM_MaxDevices(void) { return BAE_MaxDevices(); } @@ -1441,14 +1441,14 @@ long GM_MaxDevices(void) // NOTE: This function needs to function before any other calls may have happened. // Also you will need to call BAE_ReleaseAudioCard then BAE_AquireAudioCard // in order for the change to take place. -void GM_SetDeviceID(long deviceID, void *deviceParameter) +void GM_SetDeviceID(XDWORD deviceID, void *deviceParameter) { BAE_SetDeviceID(deviceID, deviceParameter); } // return current device ID // NOTE: This function needs to function before any other calls may have happened. -long GM_GetDeviceID(void *deviceParameter) +XDWORD GM_GetDeviceID(void *deviceParameter) { return BAE_GetDeviceID(deviceParameter); } @@ -1462,7 +1462,7 @@ long GM_GetDeviceID(void *deviceParameter) // "WinOS,waveOut,multi threaded" // "WinOS,VxD,low level hardware" // "WinOS,plugin,Director" -void GM_GetDeviceName(long deviceID, char *cName, unsigned long cNameLength) +void GM_GetDeviceName(XDWORD deviceID, char *cName, XDWORD cNameLength) { BAE_GetDeviceName(deviceID, cName, cNameLength); } @@ -1480,7 +1480,7 @@ UINT32 GM_GetSyncTimeStamp(void) return ticks; } -long GM_GetAudioBufferOutputSize(void) +XDWORD GM_GetAudioBufferOutputSize(void) { return BAE_GetAudioByteBufferSize(); } diff --git a/minibae/BAE_Source/Common/GenSnd.h b/minibae/BAE_Source/Common/GenSnd.h index 907fc0a3..65596f7b 100755 --- a/minibae/BAE_Source/Common/GenSnd.h +++ b/minibae/BAE_Source/Common/GenSnd.h @@ -425,8 +425,7 @@ extern "C" { #endif - -/* System defines */ + /* System defines */ /* Used in InitGeneralSound */ @@ -464,7 +463,7 @@ typedef enum #define M_USE_STEREO (1<<1L) #define M_DISABLE_REVERB (1<<2L) #define M_STEREO_FILTER (1<<3L) -typedef long AudioModifiers; +typedef XDWORD AudioModifiers; // Interpolation types enum @@ -475,7 +474,7 @@ enum E_LINEAR_INTERPOLATION_FLOAT, E_LINEAR_INTERPOLATION_U3232 }; -typedef long TerpMode; +typedef XDWORD TerpMode; // verb types enum @@ -503,7 +502,7 @@ typedef struct ReverbMode type; XBYTE thresholdEnableValue; // 0 for variable, value to enable fixed XBOOL isFixed; - unsigned long globalReverbUsageSize; // GM_Mixer->reverbBuffer size + XDWORD globalReverbUsageSize; // GM_Mixer->reverbBuffer size GM_ReverbProc pMonoRuntimeProc; GM_ReverbProc pStereoRuntimeProc; } GM_ReverbConfigure; @@ -563,7 +562,7 @@ typedef unsigned char VelocityCurveType; // 1024 * 1024 = 1MB. This limit exisits only in DROP_SAMPLE, TERP1, TERP2 cases #define MIN_LOOP_SIZE 20 // min number of loop samples that can be processed -#define MIN_SAMPLE_RATE ((unsigned long)1L) // min sample rate. 1.5258789E-5 kHz +#define MIN_SAMPLE_RATE ((XDWORD)1L) // min sample rate. 1.5258789E-5 kHz #define MAX_SAMPLE_RATE rate48khz // max sample rate 48 kHz #define MAX_PAN_LEFT (-63) // max midi pan to the left #define MAX_PAN_RIGHT 63 // max midi pan to the right @@ -647,20 +646,20 @@ typedef void (*GM_SampleFrameCallbackPtr)(void *threadContext, XSDWORD re typedef void (*GM_ControlerCallbackPtr)(void *threadContext, struct GM_Song *pSong, void * reference, short int channel, short int track, short int controler, short int value); typedef void (*GM_SongCallbackProcPtr)(void *threadContext, struct GM_Song *pSong, void *reference); typedef void (*GM_SongTimeCallbackProcPtr)(void *threadContext, struct GM_Song *pSong, XDWORD currentMicroseconds, XDWORD currentMidiClock); -typedef void (*GM_SongMetaCallbackProcPtr)(void *threadContext, struct GM_Song *pSong, char markerType, void *pMetaText, long metaTextLength, XSWORD currentTrack); +typedef void (*GM_SongMetaCallbackProcPtr)(void *threadContext, struct GM_Song *pSong, char markerType, void *pMetaText, XDWORD metaTextLength, XSWORD currentTrack); // mixer callbacks typedef void (*GM_AudioTaskCallbackPtr)(void *threadContext, void *reference); -typedef void (*GM_AudioOutputCallbackPtr)(void *threadContext, void *samples, long sampleSize, long channels, unsigned long lengthInFrames); +typedef void (*GM_AudioOutputCallbackPtr)(void *threadContext, void *samples, XDWORD sampleSize, XDWORD channels, XDWORD lengthInFrames); #define X_PACK_FAST #include "X_PackStructures.h" struct GM_SampleCallbackEntry { - unsigned long frameOffset; + XDWORD frameOffset; GM_SampleFrameCallbackPtr pCallback; - long reference; + XPTR reference; struct GM_SampleCallbackEntry *pNext; }; typedef struct GM_SampleCallbackEntry GM_SampleCallbackEntry; @@ -681,9 +680,9 @@ enum // small footprint identifier. These represent the larger file based tags. This can be smaller, // but every where the UNIT_TYPE is used is must be changed to the samller units. #if USE_MEMORY_OPTS == 1 -typedef short int UNIT_TYPE; +typedef XSWORD UNIT_TYPE; #else -typedef long UNIT_TYPE; +typedef XSDWORD UNIT_TYPE; #endif // Flags for ADSR module. GM_ADSR.ADSRFlags @@ -1080,16 +1079,16 @@ struct GM_Song XWORD allowPitchShift[(MAX_CHANNELS / 16) + 1]; // allow pitch shift void *context; // context of song creation. C++ 'this' pointer, thread, etc - long userReference; // user reference. Can be anything + XPTR userReference; // user reference. Can be anything GM_SongCallbackProcPtr songEndCallbackPtr; // called when song ends/stops/free'd up void *songEndCallbackReference; GM_SongTimeCallbackProcPtr songTimeCallbackPtr; // called every slice to pass the time - long songTimeCallbackReference; + XPTR songTimeCallbackReference; GM_SongMetaCallbackProcPtr metaEventCallbackPtr; // called during playback with current meta events - long metaEventCallbackReference; + XPTR metaEventCallbackReference; // these pointers are NULL until used, then they are allocated GM_ControlCallbackPtr controllerCallback; // called during playback with controller info @@ -1272,7 +1271,7 @@ OPErr GM_GetRate(Rate *outRate); OPErr GM_GetInterpolationMode(TerpMode *outTerpMode); // convert GenSynth Rate to actual sample rate used -unsigned long GM_ConvertFromOutputRateToRate(Rate rate); +XDWORD GM_ConvertFromOutputRateToRate(Rate rate); /**************************************************/ /* @@ -1294,20 +1293,20 @@ void GM_FinisGeneralSound(void *threadContext, struct GM_Mixer *mixer); struct GM_Mixer * GM_GetCurrentMixer(void); // get calculated microsecond time different between mixer slices. -unsigned long GM_GetMixerUsedTime(void); +XDWORD GM_GetMixerUsedTime(void); // Get CPU load in percent. This function is realtime and assumes the mixer has been allocated -unsigned long GM_GetMixerUsedTimeInPercent(void); +XDWORD GM_GetMixerUsedTimeInPercent(void); // return time in microseconds for the decay during sustain system. Values passed in are the stored values // for ADSRLevel. // 15 000 000 = 15 seconds // 1 500 000 = 1.5 seconds // 150 000 = 15 microseconds -unsigned long GM_GetSustainDecayLevelInTime(long storedValue); +XSDWORD GM_GetSustainDecayLevelInTime(XSDWORD storedValue); // given a timeInMicroseconds range check between 50 microseconds and 16 seconds, and return the storable // value for ADSRLevel. -long GM_SetSustainDecayLevelInTime(unsigned long timeInMicroseconds); +XSDWORD GM_SetSustainDecayLevelInTime(XDWORD timeInMicroseconds); #if REVERB_USED != REVERB_DISABLED // allocate the reverb buffers and enable them. @@ -1339,19 +1338,19 @@ void GM_StopHardwareSoundManager(void *threadContext); // number of devices. ie different versions of the HAE connection. DirectSound and waveOut // return number of devices. ie 1 is one device, 2 is two devices. // NOTE: This function needs to function before any other calls may have happened. -long GM_MaxDevices(void); +XDWORD GM_MaxDevices(void); // set the current device. device is from 0 to HAE_MaxDevices() // NOTE: This function needs to function before any other calls may have happened. // Also you will need to call HAE_ReleaseAudioCard then HAE_AquireAudioCard // in order for the change to take place. deviceParameter is a device specific // pointer. Pass NULL if you don't know what to use. -void GM_SetDeviceID(long deviceID, void *deviceParameter); +void GM_SetDeviceID(XDWORD deviceID, void *deviceParameter); // return current device ID, and fills in the deviceParameter with a device specific // pointer. It will pass NULL if there is nothing to use. // NOTE: This function needs to function before any other calls may have happened. -long GM_GetDeviceID(void *deviceParameter); +XDWORD GM_GetDeviceID(void *deviceParameter); // get deviceID name // NOTE: This function needs to function before any other calls may have happened. @@ -1362,7 +1361,7 @@ long GM_GetDeviceID(void *deviceParameter); // "WinOS,waveOut,multi threaded" // "WinOS,VxD,low level hardware" // "WinOS,plugin,Director" -void GM_GetDeviceName(long deviceID, char *cName, unsigned long cNameLength); +void GM_GetDeviceName(XDWORD deviceID, char *cName, XDWORD cNameLength); void GM_GetSystemVoices(XSWORD *pMaxSongVoices, XSWORD *pMixLevel, XSWORD *pMaxEffectVoices); @@ -1497,7 +1496,7 @@ GM_Song * GM_LoadSong(struct GM_Mixer *pMixer, XShortResourceID songID, void *theExternalSong, void *theExternalMidiData, //MOE: This parameter should be const! - long midiSize, + XDWORD midiSize, XShortResourceID *pInstrumentArray, XBOOL loadInstruments, XBOOL ignoreBadInstruments, @@ -1508,14 +1507,14 @@ GM_Song * GM_CreateLiveSong(void *context, XShortResourceID songID); OPErr GM_StartLiveSong(GM_Song *pSong, XBOOL loadPatches, XBankToken bankToken); // return note offset in semi tones (12 is down an octave, -12 is up an octave) -long GM_GetSongPitchOffset(GM_Song *pSong); +XSWORD GM_GetSongPitchOffset(GM_Song *pSong); // set note offset in semi tones (12 is down an octave, -12 is up an octave) -void GM_SetSongPitchOffset(GM_Song *pSong, long offset); +void GM_SetSongPitchOffset(GM_Song *pSong, XSWORD offset); // If allowPitch is FALSE, then "GM_SetSongPitchOffset" will have no effect on passed // channel (0 to 15) -void GM_AllowChannelPitchOffset(GM_Song *pSong, unsigned short int channel, XBOOL allowPitch); +void GM_AllowChannelPitchOffset(GM_Song *pSong, XWORD channel, XBOOL allowPitch); // Return if the passed channel will allow pitch offset -XBOOL GM_DoesChannelAllowPitchOffset(GM_Song *pSong, unsigned short int channel); +XBOOL GM_DoesChannelAllowPitchOffset(GM_Song *pSong, XWORD channel); // Stop this song playing, or if NULL stop all songs playing. // This removes the Song from the mixer, so you can no longer send @@ -1580,7 +1579,7 @@ XDWORD GM_GetDeviceTimeStamp(void); // Update count of samples played. This function caluculates from number of bytes, // given the sample frame size from the mixer variables, and the bytes of data written -void GM_UpdateSamplesPlayed(unsigned long currentPos); +void GM_UpdateSamplesPlayed(XDWORD currentPos); // Get current audio time stamp based upon the audio built interrupt, but ahead in time // and quantized for the particular OS @@ -1597,7 +1596,7 @@ XDWORD GM_GetSamplesPlayed(void); // midiSize size of midi data if theExternalMidiData is not NULL // pInstrumentArray array, if not NULL will be filled with the instruments that need to be loaded. // pErr pointer to an OPErr -XSDWORD GM_GetUsedPatchlist(void *theExternalSong, void *theExternalMidiData, long midiSize, +XDWORD GM_GetUsedPatchlist(void *theExternalSong, void *theExternalMidiData, XDWORD midiSize, XShortResourceID *pInstrumentArray, OPErr *pErr); // set key velocity curve type @@ -1662,10 +1661,12 @@ XSDWORD GM_GetMasterVolume(void); // This is an active voice reference that represents a valid/active voice. // Used in various functions that need to return and reference a voice. -#define DEAD_VOICE (void *)-1L // this represents a dead or invalid voice -typedef void * VOICE_REFERENCE; // reference returned that is a allocated active voice -#define DEAD_LINKED_VOICE (void *)0L // this represents a dead or invalid voice -typedef void * LINKED_VOICE_REFERENCE; // this represents a series of linked VOICE_REFERENCE's +#define DEAD_VOICE -1L // this represents a dead or invalid voice +// will be used to index into an array of GM_Voice objects +typedef long VOICE_REFERENCE; // reference returned that is a allocated active voice + +#define DEAD_LINKED_VOICE (XPTR)0L // this represents a dead or invalid voice +typedef XPTR LINKED_VOICE_REFERENCE; // this represents a series of linked VOICE_REFERENCE's /**************************************************/ /* @@ -1755,10 +1756,10 @@ void GM_SetSampleResonanceFilter(VOICE_REFERENCE reference, short int resonance) short int GM_GetSampleLowPassAmountFilter(VOICE_REFERENCE reference); void GM_SetSampleLowPassAmountFilter(VOICE_REFERENCE reference, short int amount); -void GM_SetSampleLoopPoints(VOICE_REFERENCE reference, unsigned long start, unsigned long end); +void GM_SetSampleLoopPoints(VOICE_REFERENCE reference, XDWORD start, XDWORD end); -OPErr GM_SetWaveformLoopPoints(GM_Waveform *pWave, unsigned long start, unsigned long end); -OPErr GM_GetWaveformLoopPoints(GM_Waveform *pWave, unsigned long *outStart, unsigned long *outEnd); +OPErr GM_SetWaveformLoopPoints(GM_Waveform *pWave, XDWORD start, XDWORD end); +OPErr GM_GetWaveformLoopPoints(GM_Waveform *pWave, XDWORD *outStart, XDWORD *outEnd); OPErr GM_SetWaveformByteSize(GM_Waveform *pWave, XDWORD byteSize); OPErr GM_GetWaveformByteSize(GM_Waveform *pWave, XDWORD *outByteSize); @@ -1781,14 +1782,14 @@ OPErr GM_GetWaveformBaseMidiPitch(GM_Waveform *pWave, XWORD *outBaseMidiPitch) OPErr GM_SetWaveformSampleData(GM_Waveform *pWave, XPTR sampleData); OPErr GM_GetWaveformSampleData(GM_Waveform *pWave, XPTR *outSampleData); -unsigned long GM_GetSampleStartTimeStamp(VOICE_REFERENCE reference); +XDWORD GM_GetSampleStartTimeStamp(VOICE_REFERENCE reference); // given a valid voice, return the current playback position -unsigned long GM_GetSamplePlaybackPosition(VOICE_REFERENCE reference); +XDWORD GM_GetSamplePlaybackPosition(VOICE_REFERENCE reference); // given a valid voice, set the position of the current playback -OPErr GM_SetSamplePlaybackPosition(VOICE_REFERENCE reference, unsigned long framePos); +OPErr GM_SetSamplePlaybackPosition(VOICE_REFERENCE reference, XDWORD framePos); -void * GM_GetSamplePlaybackPointer(VOICE_REFERENCE reference, unsigned long *outFrameLength); +void * GM_GetSamplePlaybackPointer(VOICE_REFERENCE reference, XDWORD *outFrameLength); void GM_ChangeSampleStereoPosition(VOICE_REFERENCE reference, XSWORD newStereoPosition); XSWORD GM_GetSampleStereoPosition(VOICE_REFERENCE reference); @@ -1981,15 +1982,17 @@ void GM_GetInstrumentUsedRange(GM_Song *pSong, XLongResourceID thePatch, XSBYTE // resets the tempo to the inital default state void GM_ResetTempoToDefault(GM_Song *pSong); -void GM_SetSongCallback(GM_Song *theSong, GM_SongCallbackProcPtr songEndCallbackPtr, void *reference); -void GM_SetSongTimeCallback(GM_Song *theSong, GM_SongTimeCallbackProcPtr songTimeCallbackPtr, long reference); -void GM_SetSongMetaEventCallback(GM_Song *theSong, GM_SongMetaCallbackProcPtr theCallback, long reference); +void GM_SetSongCallback(GM_Song *theSong, GM_SongCallbackProcPtr songEndCallbackPtr, XPTR reference); +void GM_SetSongTimeCallback(GM_Song *theSong, GM_SongTimeCallbackProcPtr songTimeCallbackPtr, XPTR reference); +void GM_SetSongMetaEventCallback(GM_Song *theSong, GM_SongMetaCallbackProcPtr theCallback, XPTR reference); void GM_SetControllerCallback(GM_Song *theSong, void * reference, GM_ControlerCallbackPtr controllerCallback, short int controller); // Display XSWORD GM_GetAudioSampleFrame(XSWORD *pLeft, XSWORD *pRight); +void GM_DisplayVoiceData(struct GM_Mixer *pMixer); + // This will check active voices and look at a sub sample of the audio output to // determine if there's any audio still playing XBOOL GM_IsAudioActive(void); @@ -2129,7 +2132,7 @@ void GM_SetAudioOutput(GM_AudioOutputCallbackPtr pOutputProc); GM_AudioOutputCallbackPtr GM_GetAudioOutput(void); GM_AudioTaskCallbackPtr GM_GetAudioTask(void); -long GM_GetAudioBufferOutputSize(void); +XDWORD GM_GetAudioBufferOutputSize(void); #if USE_HIGHLEVEL_FILE_API == TRUE typedef enum @@ -2152,7 +2155,7 @@ GM_Waveform * GM_ReadFileIntoMemory(XFILENAME *file, AudioFileType fileType, XBO OPErr GM_WriteFileFromMemory(XFILENAME *file, GM_Waveform const* pAudioData, AudioFileType fileType); -OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, long size, long channels, long sampleSize); +OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, XDWORD size, XDWORD channels, XDWORD sampleSize); // fill in empty fields in the file header. OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType); @@ -2160,17 +2163,17 @@ OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType); // This will read from a block of memory an entire file and return a GM_Waveform structure. // Assumes that the block of memory is formatted as a fileType // To dispose of a GM_Waveform structure, call GM_FreeWaveform -GM_Waveform* GM_ReadFileIntoMemoryFromMemory(void *pFileBlock, unsigned long fileBlockSize, +GM_Waveform* GM_ReadFileIntoMemoryFromMemory(void *pFileBlock, XDWORD fileBlockSize, AudioFileType fileType, XBOOL decodeSamples, OPErr *pErr); GM_Waveform * GM_ReadRawAudioIntoMemoryFromMemory(void *sampleData, // pointer to audio data - unsigned long frames, // number of frames of audio + XDWORD frames, // number of frames of audio unsigned short int bitSize, // bits per sample 8 or 16 unsigned short int channels,// mono or stereo 1 or 2 XFIXED rate, // 16.16 fixed sample rate - unsigned long loopStart, // loop start in frames - unsigned long loopEnd, // loop end in frames + XDWORD loopStart, // loop start in frames + XDWORD loopEnd, // loop end in frames OPErr *pErr); // This will read into memory just the information about the file and return a @@ -2179,8 +2182,8 @@ GM_Waveform * GM_ReadRawAudioIntoMemoryFromMemory(void *sampleData, // p // store format specific format type // To dispose of a GM_Waveform structure, call GM_FreeWaveform // If pBlockPtr is a void *, then allocate a *pBlockSize buffer, otherwise do nothing -GM_Waveform * GM_ReadFileInformation(XFILENAME *file, AudioFileType fileType, long *pFormat, - void **pBlockPtr, unsigned long *pBlockSize, OPErr *pErr); +GM_Waveform * GM_ReadFileInformation(XFILENAME *file, AudioFileType fileType, XDWORD *pFormat, + void **pBlockPtr, XDWORD *pBlockSize, OPErr *pErr); // functions used with GM_ReadAndDecodeFileStream to preserve state between decode calls. void * GM_CreateFileState(AudioFileType fileType); @@ -2189,21 +2192,21 @@ void GM_DisposeFileState(AudioFileType fileType, void *state); // Read a block of data, based apon file type and format, decode and store into a buffer. // Return length of buffer stored and return an OPErr. NO_ERR if successfull. OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, - AudioFileType fileType, long format, - XPTR pBlockBuffer, unsigned long blockSize, - XPTR pBuffer, unsigned long bufferLength, - short int channels, short int bitSize, - unsigned long *pStoredBufferLength, - unsigned long *pReadBufferLength); + AudioFileType fileType, XDWORD format, + XPTR pBlockBuffer, XDWORD blockSize, + XPTR pBuffer, XDWORD bufferLength, + XWORD channels, XWORD bitSize, + XDWORD *pStoredBufferLength, + XDWORD *pReadBufferLength); // given an open file, format types, and a sample position in frames, reseek the file OPErr GM_RepositionFileStream(XFILE fileReference, - AudioFileType fileType, long format, - XPTR pBlockBuffer, unsigned long blockSize, - short int channels, short int bitSize, - unsigned long newSampleFramePosition, - unsigned long firstSampleInFileOffsetInBytes, - unsigned long *pOuputNewFilePosition); + AudioFileType fileType, XDWORD format, + XPTR pBlockBuffer, XDWORD blockSize, + XWORD channels, XWORD bitSize, + XDWORD newSampleFramePosition, + XDWORD firstSampleInFileOffsetInBytes, + XDWORD *pOuputNewFilePosition); #endif // USE_HIGHLEVEL_FILE_API @@ -2296,21 +2299,21 @@ typedef enum // #define DEAD_STREAM 0L // this represents a dead or invalid stream -typedef long STREAM_REFERENCE; -typedef long LINKED_STREAM_REFERENCE; +typedef XPTR STREAM_REFERENCE; +typedef XPTR LINKED_STREAM_REFERENCE; struct GM_StreamData { STREAM_REFERENCE streamReference; // IN for all messages - long userReference; // IN for all messages. userReference is passed in at AudioStreamStart + XPTR userReference; // IN for all messages. userReference is passed in at AudioStreamStart void *pData; // OUT for STREAM_CREATE, IN for STREAM_DESTROY and STREAM_GET_DATA and STREAM_GET_SPECIFIC_DATA - unsigned long dataLength; // OUT for STREAM_CREATE, IN for STREAM_DESTROY. IN and OUT for STREAM_GET_DATA and STREAM_GET_SPECIFIC_DATA + XDWORD dataLength; // OUT for STREAM_CREATE, IN for STREAM_DESTROY. IN and OUT for STREAM_GET_DATA and STREAM_GET_SPECIFIC_DATA XFIXED sampleRate; // IN for all messages. Fixed 16.16 value char dataBitSize; // IN for STREAM_CREATE only. char channelSize; // IN for STREAM_CREATE only. - unsigned long startSample; // IN for STREAM_GET_SPECIFIC_DATA only. - unsigned long endSample; // IN for STREAM_GET_SPECIFIC_DATA only. - unsigned long framePosition; // IN for STREAM_SET_POSITION only. + XDWORD startSample; // IN for STREAM_GET_SPECIFIC_DATA only. + XDWORD endSample; // IN for STREAM_GET_SPECIFIC_DATA only. + XDWORD framePosition; // IN for STREAM_SET_POSITION only. }; typedef struct GM_StreamData GM_StreamData; @@ -2338,7 +2341,7 @@ typedef OPErr (*GM_StreamObjectProc)(void *threadContext, GM_StreamMessage messa STREAM_REFERENCE GM_AudioStreamSetup( void *threadContext, // platform threadContext long userReference, // user reference GM_StreamObjectProc pProc, // control callback - unsigned long bufferSize, // buffer size + XDWORD bufferSize, // buffer size XFIXED sampleRate, // Fixed 16.16 char dataBitSize, // 8 or 16 bit data char channelSize); // 1 or 2 channels of date @@ -2350,7 +2353,7 @@ STREAM_REFERENCE GM_AudioStreamSetup( void *threadContext, STREAM_REFERENCE GM_AudioStreamFileSetup( void *threadContext, // platform threadContext XFILENAME *file, // file name AudioFileType fileType, // type of file - unsigned long bufferSize, // temp buffer to read file + XDWORD bufferSize, // temp buffer to read file GM_Waveform *pFileInfo, XBOOL loopFile); // TRUE will loop file #endif // USE_HIGHLEVEL_FILE_API @@ -2369,13 +2372,13 @@ void GM_AudioStreamSetDoneCallback(STREAM_REFERENCE reference, GM_SoundDoneCallb // Get the file position of a audio stream, in samples. This // value is the current file track position. This does not equal what has // been played. Typically it will be ahead of real time. -unsigned long GM_AudioStreamGetFileSamplePosition(STREAM_REFERENCE reference); + XDWORD GM_AudioStreamGetFileSamplePosition(STREAM_REFERENCE reference); // Set the file position of a audio stream, in samples -OPErr GM_AudioStreamSetFileSamplePosition(STREAM_REFERENCE reference, unsigned long framePos); +OPErr GM_AudioStreamSetFileSamplePosition(STREAM_REFERENCE reference, XDWORD framePos); // get the position of samples played in a stream. This will be as close as // posible to realtime. Probably off by engine latency. -unsigned long GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference); + XDWORD GM_AudioStreamGetPlaybackSamplePosition(STREAM_REFERENCE reference); // call this to preroll everything and allocate a voice in the mixer, then call // GM_AudioStreamStart to start it playing @@ -2395,9 +2398,9 @@ long GM_AudioStreamGetReference(STREAM_REFERENCE reference); OPErr GM_AudioStreamGetData( void *threadContext, // platform threadContext STREAM_REFERENCE reference, - unsigned long startFrame, - unsigned long stopFrame, - XPTR pBuffer, unsigned long bufferLength); + XDWORD startFrame, + XDWORD stopFrame, + XPTR pBuffer, XDWORD bufferLength); // This will stop a streaming audio object and free any memory. // @@ -2449,14 +2452,14 @@ short int GM_AudioStreamGetStereoPosition(STREAM_REFERENCE reference); // Get the offset, in mixer-format samples, between the mixer play // position and the stream play position. -unsigned long GM_AudioStreamGetSampleOffset(STREAM_REFERENCE reference); + XDWORD GM_AudioStreamGetSampleOffset(STREAM_REFERENCE reference); // Update the number of samples played from each stream, in the // format of the stream. delta is given in engine-format samples. -void GM_AudioStreamUpdateSamplesPlayed(unsigned long delta); +void GM_AudioStreamUpdateSamplesPlayed(XDWORD delta); // get number of samples played for this stream -unsigned long GM_AudioStreamGetSamplesPlayed(STREAM_REFERENCE reference); + XDWORD GM_AudioStreamGetSamplesPlayed(STREAM_REFERENCE reference); // $$kk: 08.12.98 merge: added this // Drain this stream diff --git a/minibae/BAE_Source/Common/GenSong.c b/minibae/BAE_Source/Common/GenSong.c index af3e8942..2cf6c661 100755 --- a/minibae/BAE_Source/Common/GenSong.c +++ b/minibae/BAE_Source/Common/GenSong.c @@ -1017,7 +1017,7 @@ GM_Song * GM_LoadSong(struct GM_Mixer *pMixer, XShortResourceID songID, void *theExternalSong, void *theExternalMidiData, - long midiSize, + XDWORD midiSize, XShortResourceID *pInstrumentArray, XBOOL loadInstruments, XBOOL ignoreBadInstruments, @@ -1702,14 +1702,14 @@ OPErr GM_SetSongMicrosecondPosition(GM_Song *pSong, UINT32 songMicrosecondPositi // pInstrumentArray array, if not NULL will be filled with the instruments that need to be loaded. // pErr pointer to an OPErr #if USE_CREATION_API == TRUE -INT32 GM_GetUsedPatchlist(void *theExternalSong, +XDWORD GM_GetUsedPatchlist(void *theExternalSong, void *theExternalMidiData, - long midiSize, + XDWORD midiSize, XShortResourceID *pInstrumentArray, OPErr *pErr) { GM_Song *theSong; - long count; + XDWORD count; XBankToken bankToken; *pErr = NO_ERR; diff --git a/minibae/BAE_Source/Common/GenSoundFiles.c b/minibae/BAE_Source/Common/GenSoundFiles.c index 59ab2a2d..b4190ac0 100755 --- a/minibae/BAE_Source/Common/GenSoundFiles.c +++ b/minibae/BAE_Source/Common/GenSoundFiles.c @@ -199,7 +199,7 @@ #include "XMPEG_BAE_API.h" #endif -#define ODD(x) ((long)(x) & 1L) +#define ODD(x) ((XDWORD)(x) & 1L) #undef X_PACK_FAST #include "X_PackStructures.h" @@ -375,62 +375,62 @@ enum typedef struct { - long ckID; /* ID */ - long ckSize; /* size */ - long ckData; + XDWORD ckID; /* ID */ + XDWORD ckSize; /* size */ + XDWORD ckData; } X_PACKBY1 XIFFChunk; typedef struct { - short int numChannels; - unsigned long numSampleFrames; - short int sampleSize; - unsigned char sampleRate[10]; + XSWORD numChannels; + XDWORD numSampleFrames; + XSWORD sampleSize; + XBYTE sampleRate[10]; } X_PACKBY1 XAIFFHeader; typedef struct { - short int numChannels; - unsigned long numSampleFrames; - short int sampleSize; - unsigned char sampleRate[10]; - unsigned long compressionType; - char compressionName[256]; /* variable length array, Pascal string */ + XSWORD numChannels; + XDWORD numSampleFrames; + XSWORD sampleSize; + XBYTE sampleRate[10]; + XDWORD compressionType; + XBYTE compressionName[256]; /* variable length array, Pascal string */ } X_PACKBY1 XAIFFExtenedHeader; typedef struct { - unsigned short numMarkers; // 2 - short int id1; // 0 - unsigned long position1; + XWORD numMarkers; // 2 + XSWORD id1; // 0 + XDWORD position1; char name1[8]; // 076265674C6F6F70 'begLoop' - short int id2; // 1 - unsigned long position2; + XSWORD id2; // 1 + XDWORD position2; char name2[8]; // 07656E644C6F6F70 'endLoop' } X_PACKBY1 XSingleLoopMarker; typedef struct { - unsigned char baseFrequency; - unsigned char detune; - unsigned char lowFrequency; - unsigned char highFrequency; - unsigned char lowVelocity; - unsigned char highVelocity; - short int gain; - - short int sustainLoop_playMode; - short int sustainLoop_beginLoop; - short int sustainLoop_endLoop; - short int releaseLoop_beginLoop; - short int releaseLoop_endLoop; - short int extra; + XBYTE baseFrequency; + XBYTE detune; + XBYTE lowFrequency; + XBYTE highFrequency; + XBYTE lowVelocity; + XBYTE highVelocity; + XSWORD gain; + + XSWORD sustainLoop_playMode; + XSWORD sustainLoop_beginLoop; + XSWORD sustainLoop_endLoop; + XSWORD releaseLoop_beginLoop; + XSWORD releaseLoop_endLoop; + XSWORD extra; } X_PACKBY1 XInstrumentHeader; typedef struct { - unsigned long offset; - unsigned long blockSize; + XDWORD offset; + XDWORD blockSize; } X_PACKBY1 XSoundData; /**********************- AU Defines -**************************/ @@ -439,19 +439,19 @@ typedef struct typedef struct { - unsigned long magic; // magic number - unsigned long hdr_size; // size of the whole header, including optional comment. - unsigned long data_size; // optional data size - usually unusalble. - unsigned long encoding; // format of data contained in this file - unsigned long sample_rate; // sample rate of data in this file - unsigned long channels; // numbder of interleaved channels (usually 1 or 2) + XDWORD magic; // magic number + XDWORD hdr_size; // size of the whole header, including optional comment. + XDWORD data_size; // optional data size - usually unusalble. + XDWORD encoding; // format of data contained in this file + XDWORD sample_rate; // sample rate of data in this file + XDWORD channels; // numbder of interleaved channels (usually 1 or 2) } X_PACKBY1 SunAudioFileHeader; typedef struct { struct g72x_state state; - unsigned int buffer; - int bits; + XWORD buffer; + XSWORD bits; } X_PACKBY1 SunDecodeState; // Note these are defined for big-endian architectures @@ -476,10 +476,10 @@ typedef struct // internal structures typedef struct { - long formType; // either X_RIFF, or X_FORM; - long headerType; - long formPosition; // position in file of current FORM - long formLength; // length of FORM + XDWORD formType; // either X_RIFF, or X_FORM; + XDWORD headerType; + XDWORD formPosition; // position in file of current FORM + XDWORD formLength; // length of FORM OPErr lastError; XFILE fileReference; } X_IFF; @@ -501,7 +501,7 @@ static OPErr IFF_Error(X_IFF *pIFF) return NO_ERR; } -static void IFF_SetFormType(X_IFF *pIFF, long formType) +static void IFF_SetFormType(X_IFF *pIFF, XDWORD formType) { if (pIFF) { @@ -515,7 +515,7 @@ static long IFF_GetNextGroup(X_IFF *pIFF, XIFFChunk *pChunk) { long err = 0; - if (XFileRead(pIFF->fileReference, pChunk, (long)sizeof(XIFFChunk) - sizeof(long)) != -1) // get chunk ID + if (XFileRead(pIFF->fileReference, pChunk, (XDWORD)sizeof(XIFFChunk) - sizeof(XDWORD)) != -1) // get chunk ID { if (pIFF->formType == X_RIFF) { @@ -538,7 +538,7 @@ static long IFF_GetNextGroup(X_IFF *pIFF, XIFFChunk *pChunk) pIFF->formPosition = XFileGetPosition(pIFF->fileReference); /* get current pos */ pIFF->formLength = pChunk->ckSize; - if (XFileRead(pIFF->fileReference, &pChunk->ckData, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, &pChunk->ckData, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; } @@ -567,7 +567,7 @@ static long IFF_FileType(X_IFF *pIFF) pIFF->formPosition = 0; pIFF->formLength = 0; - XSetMemory(&type, (long)sizeof(XIFFChunk), 0); + XSetMemory(&type, (XDWORD)sizeof(XIFFChunk), 0); IFF_GetNextGroup(pIFF, &type); return( (type.ckID == pIFF->formType) ? type.ckData : -1L); } @@ -575,9 +575,9 @@ static long IFF_FileType(X_IFF *pIFF) } /*- scan past nested FORM's -*/ -static long IFF_NextBlock(X_IFF *pIFF, long blockID) +static long IFF_NextBlock(X_IFF *pIFF, XDWORD blockID) { - long saveFORM, saveFLEN; + XDWORD saveFORM, saveFLEN; XIFFChunk type; long flag; @@ -619,7 +619,7 @@ static long IFF_NextBlock(X_IFF *pIFF, long blockID) /******- Scan a FORM for a 4 letter block -*******************************/ -static long IFF_ScanToBlock(X_IFF *pIFF, long block) +static long IFF_ScanToBlock(X_IFF *pIFF, XDWORD block) { if (XFileSetPosition(pIFF->fileReference, pIFF->formPosition + 4) == 0) // set to inside of FORM { @@ -633,9 +633,9 @@ static long IFF_ScanToBlock(X_IFF *pIFF, long block) } /******************- Return Chunk size -**********************************/ -static long IFF_ChunkSize(X_IFF *pIFF, long block) +static long IFF_ChunkSize(X_IFF *pIFF, XDWORD block) { - long size; + XDWORD size; // must back up. Variable length change based upon block ID if (IFF_ScanToBlock(pIFF, block) == -1L) @@ -682,7 +682,7 @@ static long IFF_CurrentForm(X_IFF *pIFF) return IFF_NextForm(pIFF); } -static long IFF_ReadBlock(X_IFF *pIFF, XPTR pData, long Length) +static long IFF_ReadBlock(X_IFF *pIFF, XPTR pData, XDWORD Length) { if (XFileRead(pIFF->fileReference, pData, Length) == -1) { @@ -692,7 +692,7 @@ static long IFF_ReadBlock(X_IFF *pIFF, XPTR pData, long Length) } -static long IFF_GetChunk(X_IFF *pIFF, long block, long size, XPTR p) +static long IFF_GetChunk(X_IFF *pIFF, XDWORD block, XDWORD size, XPTR p) { if (IFF_ScanToBlock(pIFF, block) == -1L) { @@ -701,7 +701,7 @@ static long IFF_GetChunk(X_IFF *pIFF, long block, long size, XPTR p) if (size == -1L) /* size not known? */ { XFileSetPositionRelative(pIFF->fileReference, -4L); // back-up and get size - if (XFileRead(pIFF->fileReference, &size, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, &size, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; } @@ -727,7 +727,7 @@ static long IFF_GetChunk(X_IFF *pIFF, long block, long size, XPTR p) } -static long IFF_NextChunk(X_IFF *pIFF, long block, long size, XPTR p) +static long IFF_NextChunk(X_IFF *pIFF, XDWORD block, XDWORD size, XPTR p) { if (IFF_NextBlock(pIFF, block) == -1) { @@ -736,7 +736,7 @@ static long IFF_NextChunk(X_IFF *pIFF, long block, long size, XPTR p) if (size == -1L) /* size not known? */ { XFileSetPositionRelative(pIFF->fileReference, -4L); // back-up and get size - if (XFileRead(pIFF->fileReference, &size, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, &size, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; } @@ -764,19 +764,19 @@ static long IFF_NextChunk(X_IFF *pIFF, long block, long size, XPTR p) #endif #if USE_CREATION_API == TRUE -static void IFF_WriteType(X_IFF *pIFF, unsigned long type) +static void IFF_WriteType(X_IFF *pIFF, XDWORD type) { - unsigned long theType; + XDWORD theType; theType = type; XPutLong(&theType, type); // makes sure its motorola order - XFileWrite(pIFF->fileReference, &theType, sizeof(long)); + XFileWrite(pIFF->fileReference, &theType, sizeof(XDWORD)); } -static OPErr IFF_WriteBlock(X_IFF *pIFF, XPTR pData, unsigned long Length) +static OPErr IFF_WriteBlock(X_IFF *pIFF, XPTR pData, XDWORD Length) { pIFF->lastError = NO_ERR; - if (XFileWrite(pIFF->fileReference, pData, (long)Length) == -1) + if (XFileWrite(pIFF->fileReference, pData, (XDWORD)Length) == -1) { pIFF->lastError = BAD_FILE; } @@ -784,9 +784,9 @@ static OPErr IFF_WriteBlock(X_IFF *pIFF, XPTR pData, unsigned long Length) } // write size of block, but order in the format particulars -static long IFF_WriteSize(X_IFF *pIFF, unsigned long size) +static long IFF_WriteSize(X_IFF *pIFF, XDWORD size) { - unsigned long theSize; + XDWORD theSize; theSize = size; if (pIFF->formType == X_RIFF) @@ -805,12 +805,12 @@ static long IFF_WriteSize(X_IFF *pIFF, unsigned long size) { XPutLong(&theSize, size); // makes sure its motorola order } - return IFF_WriteBlock(pIFF, &theSize, (long)sizeof(unsigned long)); + return IFF_WriteBlock(pIFF, &theSize, (XDWORD)sizeof(XDWORD)); } #endif #if USE_CREATION_API == TRUE -static OPErr IFF_PutChunk(X_IFF *pIFF, long block, long unsigned size, XPTR p) +static OPErr IFF_PutChunk(X_IFF *pIFF, XDWORD block, XDWORD size, XPTR p) { OPErr err; @@ -820,11 +820,11 @@ static OPErr IFF_PutChunk(X_IFF *pIFF, long block, long unsigned size, XPTR p) // SSND chunk in AIFF requires 8 bytes between size and sample data. if (pIFF->formType == X_FORM && block == X_SoundData) { - long tmp = 0; + XDWORD tmp = 0; IFF_WriteSize(pIFF, size + 8); - IFF_WriteBlock(pIFF, (XPTR)&tmp, sizeof(long)); // offset to first sample - IFF_WriteBlock(pIFF, (XPTR)&tmp, sizeof(long)); // alignment block + IFF_WriteBlock(pIFF, (XPTR)&tmp, sizeof(XDWORD)); // offset to first sample + IFF_WriteBlock(pIFF, (XPTR)&tmp, sizeof(XDWORD)); // alignment block } else { @@ -836,7 +836,7 @@ static OPErr IFF_PutChunk(X_IFF *pIFF, long block, long unsigned size, XPTR p) if (ODD(size)) /* is it odd? */ { size = 0L; - XFileWrite(pIFF->fileReference, &size, (long)sizeof(char)); + XFileWrite(pIFF->fileReference, &size, (XDWORD)sizeof(XBYTE)); } } return pIFF->lastError; @@ -850,9 +850,9 @@ static OPErr IFF_PutChunk(X_IFF *pIFF, long block, long unsigned size, XPTR p) // Unpack input codes and pass them back as bytes. Returns 1 if there is residual input, returns -1 if eof, else returns 0. static int PV_UnpackInput(XFILE fileReference, unsigned int *in_buffer, int *in_bits, - unsigned char *code, int bits) + XBYTE *code, int bits) { - unsigned char in_byte; + XBYTE in_byte; if (*in_bits < bits) { @@ -873,31 +873,31 @@ static int PV_UnpackInput(XFILE fileReference, unsigned int *in_buffer, int *in_ #define MAX_AU_DECODE_BLOCK_SIZE 1024L // decode a sun file. If pState is non-zero then this is used between calls, otherwise it // uses clean state on the stack. -static OPErr PV_ReadSunAUFile( long encoding, +static OPErr PV_ReadSunAUFile( XDWORD encoding, XFILE fileReference, void *pSample, - unsigned long sampleByteLength, - unsigned long *pBufferLength, + XDWORD sampleByteLength, + XDWORD *pBufferLength, SunDecodeState *pState ) { OPErr err; short sample; - unsigned char code; + XBYTE code; int count; int (*dec_routine)(int i, int out_coding, struct g72x_state *state_ptr); int dec_bits; - short int *pSample16; - unsigned char *pSample8; - unsigned char codeBlock[MAX_AU_DECODE_BLOCK_SIZE]; - unsigned long writeLength; + XSWORD *pSample16; + XBYTE *pSample8; + XBYTE codeBlock[MAX_AU_DECODE_BLOCK_SIZE]; + XDWORD writeLength; SunDecodeState state; writeLength = 0; err = NO_ERR; dec_bits = 0; - pSample8 = (unsigned char *)pSample; - pSample16 = (short int *)pSample; + pSample8 = (XBYTE *)pSample; + pSample16 = (XSWORD *)pSample; switch (encoding) { case SUN_AUDIO_FILE_ENCODING_LINEAR_16: @@ -1005,24 +1005,24 @@ static OPErr PV_ReadSunAUFile( long encoding, #pragma mark ## WAVE read functions ## #endif -static long IFF_GetWAVFormatTag(X_IFF *pIFF) +static XWORD IFF_GetWAVFormatTag(X_IFF *pIFF) { long theErr; XWaveHeader header; - theErr = IFF_GetChunk(pIFF, X_FMT, (long)sizeof(XWaveHeader), (void *)&header); + theErr = IFF_GetChunk(pIFF, X_FMT, (XDWORD)sizeof(XWaveHeader), (void *)&header); #if X_WORD_ORDER == FALSE // motorola? header.wFormatTag = XSwapShort(header.wFormatTag); #endif - return (long)header.wFormatTag; + return header.wFormatTag; } static long IFF_GetWAVHeader(X_IFF *pIFF, XWaveHeader * pHeaderInfo) { long theErr; - theErr = IFF_GetChunk(pIFF, X_FMT, (long)sizeof(XWaveHeader), (void *)pHeaderInfo); + theErr = IFF_GetChunk(pIFF, X_FMT, (XDWORD)sizeof(XWaveHeader), (void *)pHeaderInfo); #if X_WORD_ORDER == FALSE // motorola? pHeaderInfo->nSamplesPerSec = XSwapLong(pHeaderInfo->nSamplesPerSec); @@ -1040,7 +1040,7 @@ static long IFF_GetWAVIMAHeader(X_IFF *pIFF, XWaveHeaderIMA * pHeaderInfo) { long theErr; - theErr = IFF_GetChunk(pIFF, X_FMT, (long)sizeof(XWaveHeaderIMA), (void *)pHeaderInfo); + theErr = IFF_GetChunk(pIFF, X_FMT, (XDWORD)sizeof(XWaveHeaderIMA), (void *)pHeaderInfo); #if X_WORD_ORDER == FALSE // motorola? pHeaderInfo->wfx.nSamplesPerSec = XSwapLong(pHeaderInfo->wfx.nSamplesPerSec); @@ -1056,9 +1056,10 @@ static long IFF_GetWAVIMAHeader(X_IFF *pIFF, XWaveHeaderIMA * pHeaderInfo) } // Get compressed and uncompressed size. Return 0 if successful, 1 if failure -static long IFF_GetWAVSampleSize(X_IFF *pIFF, unsigned long *pUncompressedSize, unsigned long *pCompressedSize) +static long IFF_GetWAVSampleSize(X_IFF *pIFF, XDWORD *pUncompressedSize, XDWORD *pCompressedSize) { - long size, error; + XDWORD size; + long error; XWaveHeaderIMA header; error = 0; @@ -1068,7 +1069,7 @@ static long IFF_GetWAVSampleSize(X_IFF *pIFF, unsigned long *pUncompressedSize, if (IFF_ScanToBlock(pIFF, X_DATA) == 0) /* skip to body */ { XFileSetPositionRelative(pIFF->fileReference, -4L); // back-up and get size - if (XFileRead(pIFF->fileReference, &size, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, &size, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; } @@ -1097,8 +1098,8 @@ static long IFF_GetWAVSampleSize(X_IFF *pIFF, unsigned long *pUncompressedSize, size *= 4; /* { - unsigned long cBlocks; - unsigned long cbBytesPerBlock; + XDWORD cBlocks; + XDWORD cbBytesPerBlock; // // how many destination PCM bytes are needed to hold @@ -1157,7 +1158,7 @@ static OPErr IFF_WriteWAVLoopPoints(X_IFF *pIFF, GM_Waveform const* pWaveform) { if (pWaveform->startLoop && pWaveform->endLoop) { - XSetMemory(&sample, (long)sizeof(XSamplerChunk), 0); + XSetMemory(&sample, (XDWORD)sizeof(XSamplerChunk), 0); // this rather complex process in setting these values makes sure the values in the structure are intel ordered, reguardless // of platform we're on. The structure pWaveform is always host ordered. @@ -1170,7 +1171,7 @@ static OPErr IFF_WriteWAVLoopPoints(X_IFF *pIFF, GM_Waveform const* pWaveform) XPutLong(&sample.loops[0].dwPlayCount, XSwapLong(pWaveform->numLoops)); // write WAVE loop block - return IFF_PutChunk(pIFF, X_SMPL, (long)sizeof(XSamplerChunk), (XPTR)&sample); + return IFF_PutChunk(pIFF, X_SMPL, (XDWORD)sizeof(XSamplerChunk), (XPTR)&sample); } } return NO_ERR; @@ -1178,11 +1179,11 @@ static OPErr IFF_WriteWAVLoopPoints(X_IFF *pIFF, GM_Waveform const* pWaveform) #endif // Returns WAV loop points, if there. Return 0 if successful, -1 if failure -static long IFF_GetWAVLoopPoints(X_IFF *pIFF, unsigned long *pLoopStart, unsigned long *pLoopEnd, unsigned long *pLoopCount) +static long IFF_GetWAVLoopPoints(X_IFF *pIFF, XDWORD *pLoopStart, XDWORD *pLoopEnd, XDWORD *pLoopCount) { XSamplerChunk *pSampler; long theErr; - unsigned long size; + XDWORD size; *pLoopStart = 0; *pLoopEnd = 0; @@ -1190,7 +1191,7 @@ static long IFF_GetWAVLoopPoints(X_IFF *pIFF, unsigned long *pLoopStart, unsigne if (IFF_ScanToBlock(pIFF, X_SMPL) == 0) /* skip to body */ { XFileSetPositionRelative(pIFF->fileReference, -4L); // back-up and get size - if (XFileRead(pIFF->fileReference, &size, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, &size, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; theErr = -1; @@ -1251,13 +1252,13 @@ static long IFF_GetWAVLoopPoints(X_IFF *pIFF, unsigned long *pLoopStart, unsigne // return NO_ERR if successfull -static OPErr PV_ReadWAVEAndDecompressIMA(XFILE fileReference, unsigned long sourceLength, - char *pDestSample, unsigned long destLength, +static OPErr PV_ReadWAVEAndDecompressIMA(XFILE fileReference, XDWORD sourceLength, + char *pDestSample, XDWORD destLength, char outputBitSize, char channels, - XPTR pBlockBuffer, unsigned long blockSize, - unsigned long *pBufferLength) + XPTR pBlockBuffer, XDWORD blockSize, + XDWORD *pBufferLength) { - unsigned long writeBufferLength, size, offset; + XDWORD writeBufferLength, size, offset; OPErr error; XBOOL customBlockBuffer; @@ -1326,7 +1327,7 @@ static OPErr PV_ReadWAVEAndDecompressIMA(XFILE fileReference, unsigned long sour // When disposing make sure and dispose of both the GM_Waveform structure and the // theWaveform inside of that structure with XDisposePtr static GM_Waveform* PV_ReadIntoMemoryWaveFile(XFILE file, XBOOL decodeData, - long *pFormat, unsigned long *pBlockSize, + XDWORD *pFormat, XDWORD *pBlockSize, OPErr *pError) { GM_Waveform *wave; @@ -1346,7 +1347,7 @@ static GM_Waveform* PV_ReadIntoMemoryWaveFile(XFILE file, XBOOL decodeData, if (wave) { XWaveHeaderIMA waveHeader; - unsigned long size, sourceLength; + XDWORD size, sourceLength; if ((IFF_FileType(pIFF) == X_WAVE) && (IFF_GetWAVIMAHeader(pIFF, &waveHeader) == 0)) @@ -1508,7 +1509,7 @@ static OPErr PV_WriteFromMemoryWaveFile(XFILENAME *file, GM_Waveform const* pAud return PARAM_ERR; } - pIFF = (X_IFF *)XNewPtr((long)sizeof(X_IFF)); + pIFF = (X_IFF *)XNewPtr((XDWORD)sizeof(X_IFF)); if (pIFF) { IFF_SetFormType(pIFF, X_RIFF); @@ -1544,13 +1545,13 @@ static OPErr PV_WriteFromMemoryWaveFile(XFILENAME *file, GM_Waveform const* pAud #endif // write wave header block - if (IFF_PutChunk(pIFF, X_FMT, (long)sizeof(XWaveHeader), (XPTR)&waveHeader) == NO_ERR) + if (IFF_PutChunk(pIFF, X_FMT, (XDWORD)sizeof(XWaveHeader), (XPTR)&waveHeader) == NO_ERR) { #if X_WORD_ORDER == FALSE // motorola? if (pAudioData->bitSize == 16) { // swap to intel format - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif // write out loop points @@ -1560,8 +1561,8 @@ static OPErr PV_WriteFromMemoryWaveFile(XFILENAME *file, GM_Waveform const* pAud // write out sample data if (IFF_PutChunk(pIFF, X_DATA, pAudioData->waveSize, pAudioData->theWaveform) == NO_ERR) { - unsigned long end; - unsigned long size; + XDWORD end; + XDWORD size; // write end end = XFileGetPosition(pIFF->fileReference); // get current pos @@ -1579,7 +1580,7 @@ static OPErr PV_WriteFromMemoryWaveFile(XFILENAME *file, GM_Waveform const* pAud if (pAudioData->bitSize == 16) { // put back the way we found it - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif } @@ -1664,7 +1665,7 @@ static OPErr PV_WriteFromMemorySunAUFile(XFILENAME *file, GM_Waveform const* pAu #if X_WORD_ORDER != FALSE // intel? if (pAudioData->bitSize == 16) { - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif @@ -1680,7 +1681,7 @@ static OPErr PV_WriteFromMemorySunAUFile(XFILENAME *file, GM_Waveform const* pAu #if X_WORD_ORDER != FALSE // intel? if (pAudioData->bitSize == 16) { - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif @@ -1767,27 +1768,27 @@ static float pv_ldexp(float x, int y) * conversions, and accommodated conversions involving +/- infinity, * NaN's, and denormalized numbers. */ -#define UNSIGNED_TO_FLOAT(u) (((float)((long)(u - 2147483647L - 1))) + 2147483648.0) +#define UNSIGNED_TO_FLOAT(u) (((float)((XDWORD)(u - 2147483647L - 1))) + 2147483648.0) /**************************************************************** * Extended precision IEEE floating-point conversion routine. ****************************************************************/ -XFIXED XConvertFromIeeeExtended(unsigned char *bytes) +XFIXED XConvertFromIeeeExtended(XBYTE *bytes) { float f; int expon; - unsigned long hiMant, loMant; + XDWORD hiMant, loMant; XFIXED ieeeRate; expon = ((bytes[0] & 0x7F) << 8L) | (bytes[1] & 0xFF); - hiMant = ((unsigned long)(bytes[2] & 0xFF) << 24L) - | ((unsigned long)(bytes[3] & 0xFF) << 16L) - | ((unsigned long)(bytes[4] & 0xFF) << 8L) - | ((unsigned long)(bytes[5] & 0xFF)); - loMant = ((unsigned long)(bytes[6] & 0xFF) << 24L) - | ((unsigned long)(bytes[7] & 0xFF) << 16L) - | ((unsigned long)(bytes[8] & 0xFF) << 8L) - | ((unsigned long)(bytes[9] & 0xFF)); + hiMant = ((XDWORD)(bytes[2] & 0xFF) << 24L) + | ((XDWORD)(bytes[3] & 0xFF) << 16L) + | ((XDWORD)(bytes[4] & 0xFF) << 8L) + | ((XDWORD)(bytes[5] & 0xFF)); + loMant = ((XDWORD)(bytes[6] & 0xFF) << 24L) + | ((XDWORD)(bytes[7] & 0xFF) << 16L) + | ((XDWORD)(bytes[8] & 0xFF) << 8L) + | ((XDWORD)(bytes[9] & 0xFF)); if (expon == 0 && hiMant == 0 && loMant == 0) { @@ -1857,14 +1858,14 @@ XFIXED XConvertFromIeeeExtended(unsigned char *bytes) * NaN's, and denormalized numbers. */ -#define FLOAT_TO_UNSIGNED(f) ((unsigned long)(((long)(f - 2147483648.0)) + 2147483647L + 1)) +#define FLOAT_TO_UNSIGNED(f) ((XDWORD)(((XDWORD)(f - 2147483648.0)) + 2147483647L + 1)) -void XConvertToIeeeExtended(XFIXED ieeeFixedRate, unsigned char *bytes) +void XConvertToIeeeExtended(XFIXED ieeeFixedRate, XBYTE *bytes) { int sign; int expon; double fMant, fsMant; - unsigned long hiMant, loMant; + XDWORD hiMant, loMant; double num; num = XFIXED_TO_FLOAT(ieeeFixedRate); @@ -1930,7 +1931,7 @@ static long IFF_GetAIFFHeader(X_IFF *pIFF, XAIFFHeader * pHeaderInfo) { long theErr; - theErr = IFF_GetChunk(pIFF, X_Common, (long)sizeof(XAIFFHeader), (void *)pHeaderInfo); + theErr = IFF_GetChunk(pIFF, X_Common, (XDWORD)sizeof(XAIFFHeader), (void *)pHeaderInfo); #if X_WORD_ORDER != FALSE // intel? pHeaderInfo->numChannels = XSwapShort(pHeaderInfo->numChannels); @@ -1946,7 +1947,7 @@ static long IFF_GetAIFFExtenedHeader(X_IFF *pIFF, XAIFFExtenedHeader * pHeaderIn long theErr; char size; - theErr = IFF_GetChunk(pIFF, X_Common, (long)sizeof(XAIFFHeader) + sizeof(long), (void *)pHeaderInfo); + theErr = IFF_GetChunk(pIFF, X_Common, (XDWORD)sizeof(XAIFFHeader) + sizeof(XDWORD), (void *)pHeaderInfo); #if X_WORD_ORDER != FALSE // intel? pHeaderInfo->numChannels = XSwapShort(pHeaderInfo->numChannels); @@ -1965,7 +1966,7 @@ static long IFF_GetAIFFInstrument(X_IFF *pIFF, XInstrumentHeader * pInstrumentIn { long theErr; - theErr = IFF_GetChunk(pIFF, X_Instrument, (long)sizeof(XInstrumentHeader), (void *)pInstrumentInfo); + theErr = IFF_GetChunk(pIFF, X_Instrument, (XDWORD)sizeof(XInstrumentHeader), (void *)pInstrumentInfo); #if X_WORD_ORDER != FALSE // intel? pInstrumentInfo->gain = XSwapShort(pInstrumentInfo->gain); @@ -1980,21 +1981,21 @@ static long IFF_GetAIFFInstrument(X_IFF *pIFF, XInstrumentHeader * pInstrumentIn } /* - unsigned short numMarkers; // 2 markers + XWORD numMarkers; // 2 markers short id - unsigned long position; // 1 + XDWORD position; // 1 pstring name; // begloop short id - unsigned long position; // 2 + XDWORD position; // 2 pstring name; // endloop */ // searches for MARK and pulls the ID marker's value -static XBOOL IFF_GetAIFFMarkerValue(X_IFF *pIFF, short int ID, unsigned long *pMarkerValue) +static XBOOL IFF_GetAIFFMarkerValue(X_IFF *pIFF, XSWORD ID, XDWORD *pMarkerValue) { - unsigned char loopMark[1024]; + XBYTE loopMark[1024]; long theErr; - unsigned char *pData, *pEnd; - unsigned short len; + XBYTE *pData, *pEnd; + XWORD len; *pMarkerValue = 0; theErr = IFF_GetChunk(pIFF, X_Marker, 1023L, loopMark); @@ -2027,7 +2028,7 @@ static XBOOL IFF_GetAIFFMarkerValue(X_IFF *pIFF, short int ID, unsigned long *pM } // Returns AIFF loop points, if there. Return 0 if successful, -1 if failure -static long IFF_GetAIFFLoopPoints(X_IFF *pIFF, unsigned long *pLoopStart, unsigned long *pLoopEnd) +static long IFF_GetAIFFLoopPoints(X_IFF *pIFF, XDWORD *pLoopStart, XDWORD *pLoopEnd) { XInstrumentHeader inst; long err; @@ -2060,8 +2061,8 @@ static OPErr IFF_WriteAIFFLoopPoints(X_IFF *pIFF, GM_Waveform const* pWaveform) { if (pWaveform->startLoop && pWaveform->endLoop) { - XSetMemory(&inst, (long)sizeof(XInstrumentHeader), 0); - XSetMemory(&loop, (long)sizeof(XSingleLoopMarker), 0); + XSetMemory(&inst, (XDWORD)sizeof(XInstrumentHeader), 0); + XSetMemory(&loop, (XDWORD)sizeof(XSingleLoopMarker), 0); XPutShort(&loop.numMarkers, 2); XPutShort(&loop.id1, 0); // ID 1 @@ -2071,15 +2072,15 @@ static OPErr IFF_WriteAIFFLoopPoints(X_IFF *pIFF, GM_Waveform const* pWaveform) XPutLong(&loop.position1, pWaveform->startLoop); XPutLong(&loop.position2, pWaveform->endLoop); - inst.baseFrequency = (unsigned char)pWaveform->baseMidiPitch; + inst.baseFrequency = (XBYTE)pWaveform->baseMidiPitch; XPutShort(&inst.sustainLoop_playMode, 1); // play forward XPutShort(&inst.sustainLoop_beginLoop, 0); // ID 1 XPutShort(&inst.sustainLoop_endLoop, 1); // ID 2 - err = IFF_PutChunk(pIFF, X_Instrument, (long)sizeof(XInstrumentHeader), (XPTR)&inst); + err = IFF_PutChunk(pIFF, X_Instrument, (XDWORD)sizeof(XInstrumentHeader), (XPTR)&inst); if (err == NO_ERR) { - err = IFF_PutChunk(pIFF, X_Marker, (long)sizeof(XSingleLoopMarker), (XPTR)&loop); + err = IFF_PutChunk(pIFF, X_Marker, (XDWORD)sizeof(XSingleLoopMarker), (XPTR)&loop); } } } @@ -2102,9 +2103,10 @@ static long IFF_GetAIFFBasePitch(X_IFF *pIFF, XWORD *pBasePitch) } // Get compressed and uncompressed size. Return 0 if successful, -1 if failure -static long IFF_GetAIFFSampleSize(X_IFF *pIFF, long *pUncompressedSize, long *pCompressedSize) +static long IFF_GetAIFFSampleSize(X_IFF *pIFF, XDWORD *pUncompressedSize, XDWORD *pCompressedSize) { - long size, error; + XDWORD size; + long error; XAIFFExtenedHeader header; size = 0L; @@ -2148,14 +2150,14 @@ static long IFF_GetAIFFSampleSize(X_IFF *pIFF, long *pUncompressedSize, long *pC else { XFileSetPositionRelative(pIFF->fileReference, -4L); // back-up and get size - if (XFileRead(pIFF->fileReference, pCompressedSize, (long)sizeof(long)) == -1) + if (XFileRead(pIFF->fileReference, pCompressedSize, (XDWORD)sizeof(XDWORD)) == -1) { pIFF->lastError = BAD_FILE; error = -1; } BAE_ASSERT(pCompressedSize); *pCompressedSize = XGetLong(pCompressedSize); -// XFileSetPositionRelative(pIFF->fileReference, sizeof(long) * 2L); +// XFileSetPositionRelative(pIFF->fileReference, sizeof(XDWORD) * 2L); } } @@ -2179,7 +2181,7 @@ static OPErr PV_WriteFromMemoryAiffFile(XFILENAME *file, GM_Waveform const* pAud return PARAM_ERR; } - pIFF = (X_IFF *)XNewPtr((long)sizeof(X_IFF)); + pIFF = (X_IFF *)XNewPtr((XDWORD)sizeof(X_IFF)); if (pIFF) { IFF_SetFormType(pIFF, X_FORM); @@ -2208,13 +2210,13 @@ static OPErr PV_WriteFromMemoryAiffFile(XFILENAME *file, GM_Waveform const* pAud #endif // write aiff header block - if (IFF_PutChunk(pIFF, X_Common, (long)sizeof(XAIFFHeader), (XPTR)&aiffHeader) == NO_ERR) + if (IFF_PutChunk(pIFF, X_Common, (XDWORD)sizeof(XAIFFHeader), (XPTR)&aiffHeader) == NO_ERR) { #if X_WORD_ORDER != FALSE // intel? if (pAudioData->bitSize == 16) { // swap to motorola format - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif @@ -2229,8 +2231,8 @@ static OPErr PV_WriteFromMemoryAiffFile(XFILENAME *file, GM_Waveform const* pAud { if (IFF_PutChunk(pIFF, X_SoundData, pAudioData->waveSize, pAudioData->theWaveform) == NO_ERR) { - unsigned long end; - unsigned long size; + XDWORD end; + XDWORD size; // write end end = XFileGetPosition(pIFF->fileReference); // get current pos @@ -2253,7 +2255,7 @@ static OPErr PV_WriteFromMemoryAiffFile(XFILENAME *file, GM_Waveform const* pAud #if X_WORD_ORDER != FALSE // intel? if (pAudioData->bitSize == 16) { - XSwapShorts((short int*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); + XSwapShorts((XSWORD*)pAudioData->theWaveform, pAudioData->waveFrames * pAudioData->channels); } #endif } @@ -2285,14 +2287,14 @@ static OPErr PV_WriteFromMemoryAiffFile(XFILENAME *file, GM_Waveform const* pAud #define AIFF_IMA_BUFFER_SIZE AIFF_IMA_BLOCK_BYTES * 40 -static OPErr PV_ReadAIFFAndDecompressIMA(XFILE fileReference, long sourceLength, - unsigned char *pDestSample, long destLength, +static OPErr PV_ReadAIFFAndDecompressIMA(XFILE fileReference, XDWORD sourceLength, + XBYTE *pDestSample, XDWORD destLength, char outputBitSize, char channels, - unsigned long *pBufferLength, + XDWORD *pBufferLength, short predictorCache[2]) { XBYTE codeBlock[AIFF_IMA_BUFFER_SIZE]; - long writeBufferLength, size, offset; + XDWORD writeBufferLength, size, offset; OPErr err; err = NO_ERR; @@ -2357,7 +2359,7 @@ static OPErr PV_ReadAIFFAndDecompressIMA(XFILE fileReference, long sourceLength, // When disposing make sure and dispose of both the GM_Waveform structure and the // theWaveform inside of that structure with XDisposePtr static GM_Waveform * PV_ReadIntoMemoryAIFFFile(XFILE file, XBOOL decodeData, - long *pFormat, unsigned long *pBlockSize, + XDWORD *pFormat, XDWORD *pBlockSize, OPErr *pError) { GM_Waveform *wave; @@ -2377,7 +2379,7 @@ X_IFF *pIFF; wave = (GM_Waveform*)XNewPtr(sizeof(GM_Waveform)); if (wave) { - long type; + XDWORD type; type = IFF_FileType(pIFF); pIFF->headerType = type; @@ -2390,8 +2392,8 @@ X_IFF *pIFF; else { XAIFFExtenedHeader aiffHeader; - long size; - long sourceLength; + XDWORD size; + XDWORD sourceLength; XSetMemory(&aiffHeader, sizeof(XAIFFExtenedHeader), 0); @@ -2428,7 +2430,7 @@ X_IFF *pIFF; wave->waveSize = size; wave->waveFrames = wave->waveSize / (wave->channels * (wave->bitSize / 8)); - XFileSetPositionRelative(pIFF->fileReference, sizeof(long) * 2L); + XFileSetPositionRelative(pIFF->fileReference, sizeof(XDWORD) * 2L); // now the file is positioned right at the data block if (pBlockSize) @@ -2436,7 +2438,7 @@ X_IFF *pIFF; wave->currentFilePosition = XFileGetPosition(pIFF->fileReference); BAE_ASSERT(pFormat); *pFormat = aiffHeader.compressionType; - *pBlockSize = sizeof(long) * 2; //MOE: Isn't this too small for efficient streaming? + *pBlockSize = sizeof(XDWORD) * 2; //MOE: Isn't this too small for efficient streaming? // don't read/decode data, other streaming code will do it } else @@ -2523,7 +2525,7 @@ X_IFF *pIFF; break; } - if ((pIFF->lastError == NO_ERR) && ((long)wave->waveSize == size)) + if ((pIFF->lastError == NO_ERR) && ((XDWORD)wave->waveSize == size)) { // now, if the file is 8 bit sample, change the sample phase if (wave->bitSize == 8) @@ -2561,7 +2563,7 @@ X_IFF *pIFF; // When disposing make sure and dispose of both the GM_Waveform structure and the // theWaveform inside of that structure with XDisposePtr static GM_Waveform * PV_ReadIntoMemorySunAUFile(XFILE file, XBOOL decodeData, - long *pFormat, unsigned long *pBlockSize, + XDWORD *pFormat, XDWORD *pBlockSize, OPErr *pError) { GM_Waveform* wave; @@ -2574,14 +2576,14 @@ SunAudioFileHeader sunHeader; wave = NULL; err = NO_ERR; - if (XFileRead(file, &sunHeader, (long)sizeof(SunAudioFileHeader)) == 0) + if (XFileRead(file, &sunHeader, (XDWORD)sizeof(SunAudioFileHeader)) == 0) { - long size; - long filePos; - long originalLength; + XDWORD size; + XDWORD filePos; + XDWORD originalLength; // now skip past any info string - size = XGetLong(&sunHeader.hdr_size) - (long)sizeof(SunAudioFileHeader); + size = XGetLong(&sunHeader.hdr_size) - (XDWORD)sizeof(SunAudioFileHeader); filePos = XFileGetPosition(file) + size; originalLength = XFileGetLength(file) - size + sizeof(SunAudioFileHeader); @@ -2589,9 +2591,9 @@ SunAudioFileHeader sunHeader; // Make sure we've got a legitimate audio file if (XGetLong(&sunHeader.magic) == SUN_AUDIO_FILE_MAGIC_NUMBER) { - long const encoding = XGetLong(&sunHeader.encoding); - long waveLength = 0; - short int bits = 0; + XDWORD const encoding = XGetLong(&sunHeader.encoding); + XDWORD waveLength = 0; + XSWORD bits = 0; switch (encoding) { @@ -2668,7 +2670,7 @@ SunAudioFileHeader sunHeader; // now, if the file is 8 bit sample, change the sample phase if (wave->bitSize == 8) { - XPhase8BitWaveform((unsigned char *)wave->theWaveform, wave->waveSize); + XPhase8BitWaveform((XBYTE *)wave->theWaveform, wave->waveSize); } } } @@ -2712,7 +2714,7 @@ SunAudioFileHeader sunHeader; #if USE_MPEG_DECODER != 0 static GM_Waveform* PV_ReadIntoMemoryMPEGFile(XFILE file, XBOOL decodeData, - long *pFormat, void **ppBlockPtr, unsigned long *pBlockSize, + XDWORD *pFormat, void **ppBlockPtr, XDWORD *pBlockSize, OPErr *pError) { GM_Waveform* wave; @@ -2926,7 +2928,7 @@ GM_Waveform *waveform; } // Read into memory a file -GM_Waveform* GM_ReadFileIntoMemoryFromMemory(void *pFileBlock, unsigned long fileBlockSize, +GM_Waveform* GM_ReadFileIntoMemoryFromMemory(void *pFileBlock, XDWORD fileBlockSize, AudioFileType fileType, XBOOL decodeData, OPErr *pErr) { @@ -2976,8 +2978,8 @@ GM_Waveform *waveform; // Read file information from file, which is a fileType file. If pFormat is not NULL, then // store format specific format type GM_Waveform * GM_ReadFileInformation(XFILENAME *filename, AudioFileType fileType, - long *pFormat, - void **ppBlockPtr, unsigned long *pBlockSize, + XDWORD *pFormat, + void **ppBlockPtr, XDWORD *pBlockSize, OPErr *pErr) { XFILE file; @@ -3029,17 +3031,17 @@ GM_Waveform* pWave = NULL; // given an open file, format types, and a sample position in frames, reseek the file OPErr GM_RepositionFileStream(XFILE fileReference, - AudioFileType fileType, long format, - XPTR pBlockBuffer, unsigned long blockSize, - short int channels, short int bitSize, - unsigned long newSampleFramePosition, - unsigned long firstSampleInFileOffsetInBytes, - unsigned long *pOuputNewPlaybackPositionInBytes) + AudioFileType fileType, XDWORD format, + XPTR pBlockBuffer, XDWORD blockSize, + XWORD channels, XWORD bitSize, + XDWORD newSampleFramePosition, + XDWORD firstSampleInFileOffsetInBytes, + XDWORD *pOuputNewPlaybackPositionInBytes) { OPErr fileError; XBOOL reSeek; - short int frameBlockSize, decodeBlockSize; - unsigned long filePos; + XSWORD frameBlockSize, decodeBlockSize; + XDWORD filePos; reSeek = FALSE; fileError = NO_ERR; @@ -3143,7 +3145,7 @@ OPErr GM_RepositionFileStream(XFILE fileReference, } if (reSeek) { - unsigned long pos; + XDWORD pos; pos = newSampleFramePosition * frameBlockSize; filePos = firstSampleInFileOffsetInBytes + (pos / decodeBlockSize); @@ -3160,18 +3162,18 @@ OPErr GM_RepositionFileStream(XFILE fileReference, // Read a block of data, based apon file type and format, decode and store into a buffer. // Return length of buffer stored or 0 if error. OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, - AudioFileType fileType, long format, - XPTR pBlockBuffer, unsigned long blockSize, - XPTR pBuffer, unsigned long bufferFrames, - short int channels, short int bitSize, - unsigned long *pStoredBufferLength, - unsigned long *pReadBufferLength) -{ - unsigned long returnedLength, writeLength, bufferSize; + AudioFileType fileType, XDWORD format, + XPTR pBlockBuffer, XDWORD blockSize, + XPTR pBuffer, XDWORD bufferFrames, + XWORD channels, XWORD bitSize, + XDWORD *pStoredBufferLength, + XDWORD *pReadBufferLength) +{ + XDWORD returnedLength, writeLength, bufferSize; OPErr fileError; - long filePosition; + XDWORD filePosition; #if USE_MPEG_DECODER != 0 - long count, frames; + XDWORD count, frames; #endif XBOOL calculateFileSize; @@ -3248,7 +3250,7 @@ OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, // now, if the file is 8 bit sample, change the sample phase if (bitSize == 8) { - XPhase8BitWaveform((unsigned char *)pBuffer, bufferSize); + XPhase8BitWaveform((XBYTE *)pBuffer, bufferSize); } #if X_WORD_ORDER != FALSE // intel? // now, if the file is 16 bit sample on a intel ordered system, swap the bytes @@ -3263,11 +3265,11 @@ OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, { fileError = PV_ReadAIFFAndDecompressIMA(fileReference, bufferSize / 4, - (unsigned char *)pBuffer, + (XBYTE *)pBuffer, bufferSize, (char)bitSize, (char)channels, - (unsigned long *)&writeLength, + (XDWORD *)&writeLength, (short*)pBlockBuffer); returnedLength = bufferSize / 4; @@ -3300,7 +3302,7 @@ OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, // now, if the file is 16 bit sample on a intel ordered system, swap the bytes if (bitSize == 16) { - XSwapShorts((short int *)pBuffer, bufferFrames * channels); + XSwapShorts((XSWORD *)pBuffer, bufferFrames * channels); } #endif break; @@ -3332,7 +3334,7 @@ OPErr GM_ReadAndDecodeFileStream(XFILE fileReference, (char)channels, pBlockBuffer, blockSize, - (unsigned long *)&writeLength); + (XDWORD *)&writeLength); returnedLength = bufferSize / 4; // since we decode the samples at runtime, we don't have // to byte swap the words. @@ -3418,9 +3420,9 @@ OPErr GM_WriteFileFromMemory(XFILENAME *file, GM_Waveform const* pAudioData, Aud OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType) { OPErr err; - unsigned long chunk; - unsigned long fileSize; - unsigned long tmp; + XDWORD chunk; + XDWORD fileSize; + XDWORD tmp; XERR xerr; err = NO_ERR; @@ -3477,11 +3479,11 @@ OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType) case FILE_AIFF_TYPE: { - unsigned long size; - unsigned short channels; - unsigned long pos; - unsigned short bits; - unsigned long frames; + XDWORD size; + XWORD channels; + XDWORD pos; + XWORD bits; + XDWORD frames; fileSize = XFileGetLength(file); @@ -3557,7 +3559,7 @@ OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType) case FILE_AU_TYPE: { - unsigned long headerSize; + XDWORD headerSize; fileSize = XFileGetLength(file); @@ -3602,16 +3604,16 @@ OPErr GM_FinalizeFileHeader(XFILE file, AudioFileType fileType) // for 16 bit data. samples are from -32767 to 32768 and 0 is silent // for 8 bit data. samples are from -127 to 128 and 0 is silent. This is oppsite for BAE GM_Waveform * GM_ReadRawAudioIntoMemoryFromMemory(void * sampleData, // pointer to audio data - unsigned long frames, // number of frames of audio - unsigned short int bitSize, // bits per sample 8 or 16 - unsigned short int channels, // mono or stereo 1 or 2 + XDWORD frames, // number of frames of audio + XWORD bitSize, // bits per sample 8 or 16 + XWORD channels, // mono or stereo 1 or 2 XFIXED rate, // 16.16 fixed sample rate - unsigned long loopStart, // loop start in frames - unsigned long loopEnd, // loop end in frames + XDWORD loopStart, // loop start in frames + XDWORD loopEnd, // loop end in frames OPErr *pErr) { GM_Waveform *pWave = NULL; - long size; + XDWORD size; OPErr err; void *copySampleData; @@ -3631,8 +3633,8 @@ GM_Waveform * GM_ReadRawAudioIntoMemoryFromMemory(void * sampleData, pWave->startLoop = loopStart; pWave->endLoop = loopEnd; pWave->baseMidiPitch = 60; - pWave->bitSize = (unsigned char)bitSize; - pWave->channels = (unsigned char)channels; + pWave->bitSize = (XBYTE)bitSize; + pWave->channels = (XBYTE)channels; pWave->sampledRate = rate; pWave->theWaveform = copySampleData; @@ -3664,7 +3666,7 @@ GM_Waveform * GM_ReadRawAudioIntoMemoryFromMemory(void * sampleData, #if USE_HIGHLEVEL_FILE_API == TRUE #if USE_CREATION_API == TRUE -OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, long size, long channels, long sampleSize) +OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, XDWORD size, XDWORD channels, XDWORD sampleSize) { OPErr theErr; @@ -3677,7 +3679,7 @@ OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, lo #if X_WORD_ORDER == FALSE // motorola if (sampleSize == 2) // if 16-bit data, we need to flip to little endian { - XSwapShorts((short *)buffer, (long)(size / sampleSize)); + XSwapShorts((short *)buffer, (XDWORD)(size / sampleSize)); } #endif if (XFileWrite(file, buffer, size) == -1) @@ -3692,12 +3694,12 @@ OPErr GM_WriteAudioBufferToFile(XFILE file, AudioFileType type, void *buffer, lo if (sampleSize == 2) // if 16-bit data, we need to flip to big endian { // swap to motorola format - XSwapShorts((short *)buffer, (long)(size / sampleSize)); + XSwapShorts((short *)buffer, (XDWORD)(size / sampleSize)); } #endif if (sampleSize == 1) // 8-bit data { - XPhase8BitWaveform((unsigned char*)buffer, size); + XPhase8BitWaveform((XBYTE*)buffer, size); } if (XFileWrite(file, buffer, size) == -1) diff --git a/minibae/BAE_Source/Common/GenSynth.c b/minibae/BAE_Source/Common/GenSynth.c index f9ad3df7..f2cde73e 100755 --- a/minibae/BAE_Source/Common/GenSynth.c +++ b/minibae/BAE_Source/Common/GenSynth.c @@ -475,9 +475,9 @@ static const XFIXED expDecayLookup[] = // 1 500 000 = 1.5 seconds // 150 000 = 15 microseconds // This is the amount of time to sustain to 96 dB or no volume. -unsigned long GM_GetSustainDecayLevelInTime(long storedValue) +XSDWORD GM_GetSustainDecayLevelInTime(XSDWORD storedValue) { - unsigned long time; + XSDWORD time; time = 0; if (storedValue < -50) @@ -496,7 +496,7 @@ unsigned long GM_GetSustainDecayLevelInTime(long storedValue) // given a timeInMicroseconds range check between 50000 microseconds and 16 seconds, and return the storable // value for ADSRLevel. // This is the amount of time to sustain to 96 dB or no volume. -long GM_SetSustainDecayLevelInTime(unsigned long timeInMicroseconds) +XSDWORD GM_SetSustainDecayLevelInTime(XDWORD timeInMicroseconds) { timeInMicroseconds /= 8; if (timeInMicroseconds > ((sizeof(expDecayLookup) / sizeof(XFIXED)) * 50000L)) @@ -2269,9 +2269,9 @@ void BAE_BuildMixerSlice(void *threadContext, void *pAudioBuffer, long bufferByt #if BAE_COMPLETE // Get time in microseconds between calls to BAE_BuildMixerSlice -unsigned long GM_GetMixerUsedTime(void) +XDWORD GM_GetMixerUsedTime(void) { - unsigned long time; + XDWORD time; time = 0; if (MusicGlobals) @@ -2284,9 +2284,9 @@ unsigned long GM_GetMixerUsedTime(void) #if BAE_COMPLETE // Get CPU load in percent. This function is realtime and assumes the mixer has been allocated -unsigned long GM_GetMixerUsedTimeInPercent(void) +XDWORD GM_GetMixerUsedTimeInPercent(void) { - unsigned long load; + XDWORD load; load = 0; if (MusicGlobals) @@ -3782,12 +3782,14 @@ INT16 GM_GetAudioSampleFrame(INT16 *pLeft, INT16 *pRight) #endif } -#if 01 -void GM_DisplayVoiceData(void) +void GM_DisplayVoiceData(GM_Mixer *pMixer) { - GM_Mixer *pMixer = GM_GetCurrentMixer(); LOOPCOUNT count; GM_Voice *pVoice; + + if (pMixer == NULL) { + pMixer = GM_GetCurrentMixer(); + } for (count = 0; count < (pMixer->MaxNotes+pMixer->MaxEffects); count++) { @@ -3796,22 +3798,21 @@ void GM_DisplayVoiceData(void) { BAE_PRINTF("### Voice %ld\n", count); BAE_PRINTF(" voiceMode %d\n", pVoice->voiceMode); - BAE_PRINTF(" voiceStartTimeStamp %ld\n", pVoice->voiceStartTimeStamp); + BAE_PRINTF(" voiceStartTimeStamp %lu\n", (unsigned long)pVoice->voiceStartTimeStamp); BAE_PRINTF(" pSong %lx\n", (long)pVoice->pSong); BAE_PRINTF(" pInstrument %lx\n", (long)pVoice->pInstrument); BAE_PRINTF(" NoteChannel %d\n", pVoice->NoteChannel); BAE_PRINTF(" NoteMIDIPitch %d\n", pVoice->NoteMIDIPitch); BAE_PRINTF(" sustainMode %d\n", pVoice->sustainMode); BAE_PRINTF(" NoteVolumeEnvelope %d\n", pVoice->NoteVolumeEnvelope); - BAE_PRINTF(" NoteVolume %ld\n", pVoice->NoteVolume); + BAE_PRINTF(" NoteVolume %ld\n", (long)pVoice->NoteVolume); BAE_PRINTF(" NoteMIDIVolume %d\n", pVoice->NoteMIDIVolume); - BAE_PRINTF(" NoteProgram %ld\n", pVoice->NoteProgram); - BAE_PRINTF(" volumeADSRRecord.sustainingDecayLevel %ld\n", pVoice->volumeADSRRecord.sustainingDecayLevel); + BAE_PRINTF(" NoteProgram %ld\n", (unsigned long)pVoice->NoteProgram); + BAE_PRINTF(" volumeADSRRecord.sustainingDecayLevel %g\n", XFIXED_TO_FLOAT(pVoice->volumeADSRRecord.sustainingDecayLevel)); BAE_PRINTF("###\n"); } } } -#endif // This will check active voices and look at a sub sample of the audio output to // determine if there's any audio still playing diff --git a/minibae/BAE_Source/Common/MiniBAE.c b/minibae/BAE_Source/Common/MiniBAE.c index cf8abc40..c1af7c1d 100755 --- a/minibae/BAE_Source/Common/MiniBAE.c +++ b/minibae/BAE_Source/Common/MiniBAE.c @@ -3183,6 +3183,32 @@ BAEResult BAEMixer_ServiceAudioOutputToFile(BAEMixer theMixer) #endif } +// Debug +BAEResult BAEMixer_DisplayVoiceData(BAEMixer mixer) +{ + OPErr err; + + err = NO_ERR; + if (mixer) + { + if (mixer->pMixer) + { + GM_DisplayVoiceData(mixer->pMixer); + } + else + { + err = NOT_SETUP; + } + } + else + { + err = NULL_OBJECT; + } + return BAE_TranslateOPErr(err); +} + + + // ------------------------------------------------------------------ // BAESound Functions @@ -5677,13 +5703,13 @@ void BAESong_DisplayInfo(BAESong song) printf("UNKNOWN\n"); } } - printf(" sequenceDataSize %ld\n", pSong->sequenceDataSize); + printf(" sequenceDataSize %lu\n", (unsigned long)pSong->sequenceDataSize); printf(" songID %d\n", pSong->songID); printf(" maxSongVoices %d\n", pSong->maxSongVoices); printf(" mixLevel %d\n", pSong->mixLevel); printf(" maxEffectVoices %d\n", pSong->maxEffectVoices); - printf(" MasterTempo %ld\n", pSong->MasterTempo); + printf(" MasterTempo %g\n", XFIXED_TO_FLOAT(pSong->MasterTempo)); printf(" songTempo %d\n", pSong->songTempo); printf(" songPitchShift %d\n", pSong->songPitchShift); printf(" songPaused %s\n", pSong->songPaused ? "TRUE" : "FALSE"); @@ -5703,8 +5729,13 @@ void BAESong_DisplayInfo(BAESong song) printf(" songLoopCount %d\n", pSong->songLoopCount); printf(" songMaxLoopCount %d\n", pSong->songMaxLoopCount); // -1 means GM style bank select, -2 means allow program changes on percussion - printf(" songMidiTickLength %ld\n", pSong->songMidiTickLength); - printf(" songMicrosecondLength %ld\n", pSong->songMicrosecondLength); +#if USE_FLOAT == FALSE + printf(" songMidiTickLength %ld\n", (long)pSong->songMidiTickLength); + printf(" songMicrosecondLength %ld\n", (long)pSong->songMicrosecondLength); +#else + printf(" songMidiTickLength %f\n", (float)pSong->songMidiTickLength); + printf(" songMicrosecondLength %f\n", (float)pSong->songMicrosecondLength); +#endif for (count = 0; count < 16; count++) { @@ -6350,7 +6381,7 @@ BAEResult BAESong_LoadRmfFromFile(BAESong song, BAEPathName filePath, short int GM_Song *pSong; OPErr theErr; XLongResourceID theID; - long size; + XDWORD size; theErr = NO_ERR; if ( (song) && (song->mID == OBJECT_ID) ) diff --git a/minibae/BAE_Source/Common/MiniBAE.h b/minibae/BAE_Source/Common/MiniBAE.h index 9d022489..8b95a8d9 100755 --- a/minibae/BAE_Source/Common/MiniBAE.h +++ b/minibae/BAE_Source/Common/MiniBAE.h @@ -1103,7 +1103,8 @@ void BAEMixer_StopOutputToFile(void); // once started saving to a file, call this to continue saving to file BAEResult BAEMixer_ServiceAudioOutputToFile(BAEMixer mixer); - +// Debug +BAEResult BAEMixer_DisplayVoiceData(BAEMixer mixer); // ----------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------- diff --git a/minibae/BAE_Source/Common/NewNewLZSS.c b/minibae/BAE_Source/Common/NewNewLZSS.c index 8d3dc815..e6edafe2 100755 --- a/minibae/BAE_Source/Common/NewNewLZSS.c +++ b/minibae/BAE_Source/Common/NewNewLZSS.c @@ -137,56 +137,56 @@ #define LOOKBACK (1L << OFFSETBITS) /* size of lookback buffer */ // forwards -static void doLZSSDecode(unsigned char* srcBuffer, unsigned long srcBytes, unsigned char* dstBuffer, long dstSize); +static void doLZSSDecode(unsigned char* srcBuffer, XDWORD srcBytes, unsigned char* dstBuffer, long dstSize); #if USE_CREATION_API == TRUE -static void DeltaMono8(unsigned char* pData, unsigned long frameCount); -static void DeltaStereo8(unsigned char* pData, unsigned long frameCount); -static void DeltaMono16(short* pData, unsigned long frameCount); -static void DeltaStereo16(short* pData, unsigned long frameCount); +static void DeltaMono8(unsigned char* pData, XDWORD frameCount); +static void DeltaStereo8(unsigned char* pData, XDWORD frameCount); +static void DeltaMono16(short* pData, XDWORD frameCount); +static void DeltaStereo16(short* pData, XDWORD frameCount); #endif -static void UnDeltaMono8(unsigned char* pData, unsigned long frameCount); -static void UnDeltaStereo8(unsigned char* pData, unsigned long frameCount); -static void UnDeltaMono16(short* pData, unsigned long frameCount); -static void UnDeltaStereo16(short* pData, unsigned long frameCount); +static void UnDeltaMono8(unsigned char* pData, XDWORD frameCount); +static void UnDeltaStereo8(unsigned char* pData, XDWORD frameCount); +static void UnDeltaMono16(short* pData, XDWORD frameCount); +static void UnDeltaStereo16(short* pData, XDWORD frameCount); #if USE_CREATION_API == TRUE -long LZSSCompressDeltaMono8(XBYTE* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompressDeltaMono8(XBYTE* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData) { -long dstBytes; + XDWORD dstBytes; DeltaMono8(src, srcBytes); dstBytes = LZSSCompress(src, srcBytes, dst, proc, procData); UnDeltaMono8(src, srcBytes); return dstBytes; } -long LZSSCompressDeltaStereo8(XBYTE* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompressDeltaStereo8(XBYTE* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData) { -unsigned long const frameCount = srcBytes / 2; -long dstBytes; + XDWORD const frameCount = srcBytes / 2; + XDWORD dstBytes; DeltaStereo8(src, frameCount); dstBytes = LZSSCompress(src, srcBytes, dst, proc, procData); UnDeltaStereo8(src, frameCount); return dstBytes; } -long LZSSCompressDeltaMono16(short* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompressDeltaMono16(XSWORD* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData) { -unsigned long const frameCount = srcBytes / 2; -long dstBytes; + XDWORD const frameCount = srcBytes / 2; + XDWORD dstBytes; DeltaMono16(src, frameCount); dstBytes = LZSSCompress((XBYTE*)src, srcBytes, dst, proc, procData); UnDeltaMono16(src, frameCount); return dstBytes; } -long LZSSCompressDeltaStereo16(short* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompressDeltaStereo16(XSWORD* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData) { -unsigned long const frameCount = srcBytes / 4; -long dstBytes; + XDWORD const frameCount = srcBytes / 4; + XDWORD dstBytes; DeltaStereo16(src, frameCount); dstBytes = LZSSCompress((XBYTE*)src, srcBytes, dst, proc, procData); @@ -195,31 +195,31 @@ long dstBytes; } #endif -void LZSSUncompress(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes) +void LZSSUncompress(XBYTE* src, XDWORD srcBytes, + XBYTE* dst, XDWORD dstBytes) { doLZSSDecode(src, srcBytes, dst, dstBytes); } -void LZSSUncompressDeltaMono8(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes) +void LZSSUncompressDeltaMono8(XBYTE* src, XDWORD srcBytes, + XBYTE* dst, XDWORD dstBytes) { doLZSSDecode(src, srcBytes, dst, dstBytes); UnDeltaMono8(dst, dstBytes); } -void LZSSUncompressDeltaStereo8(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes) +void LZSSUncompressDeltaStereo8(XBYTE* src, XDWORD srcBytes, + XBYTE* dst, XDWORD dstBytes) { doLZSSDecode(src, srcBytes, dst, dstBytes); UnDeltaStereo8(dst, dstBytes / 2); } -void LZSSUncompressDeltaMono16(unsigned char* src, unsigned long srcBytes, - short* dst, unsigned long dstBytes) +void LZSSUncompressDeltaMono16(XBYTE* src, XDWORD srcBytes, + XSWORD* dst, XDWORD dstBytes) { doLZSSDecode(src, srcBytes, (unsigned char*)dst, dstBytes); UnDeltaMono16(dst, dstBytes / 2); } -void LZSSUncompressDeltaStereo16(unsigned char* src, unsigned long srcBytes, - short* dst, unsigned long dstBytes) +void LZSSUncompressDeltaStereo16(XBYTE* src, XDWORD srcBytes, + XSWORD* dst, XDWORD dstBytes) { doLZSSDecode(src, srcBytes, (unsigned char*)dst, dstBytes); UnDeltaStereo16(dst, dstBytes / 4); @@ -256,7 +256,7 @@ void LZSSUncompressDeltaStereo16(unsigned char* src, unsigned long srcBytes, * * -------------------------------------------------------------------------------- */ -static asm short int findLongestMatch(unsigned char * theData, unsigned long dataLen, unsigned long patternStart, unsigned short* codeWord) +static asm short int findLongestMatch(XBYTE * theData, XDWORD dataLen, XDWORD patternStart, XWORD* codeWord) { fralloc + MOVEM.L D2-D6/A2-A3,-(SP) // Save all registers @@ -359,19 +359,19 @@ static asm short int findLongestMatch(unsigned char * theData, unsigned long dat #else -static short int findLongestMatch(unsigned char * theData, unsigned long dataLen, - unsigned long patternStart, unsigned short* codeWord) +static short int findLongestMatch(XBYTE * theData, XDWORD dataLen, + XDWORD patternStart, XWORD* codeWord) { -unsigned char *pointer; // scanning source pointer -register unsigned char *lookback; // scanning compare pointer -register unsigned char *tPointer; // scanning source pointer -register unsigned char *tLookback; // scanning compare pointer -register long counter; // number of bytes to scan -register unsigned long maxLen; // maximum match length -register unsigned long bestLen; // best match length -register unsigned long bestOff; // best match offset -register unsigned long length; // scanning length -unsigned long forward; // bytes to scan ahead + XBYTE *pointer; // scanning source pointer + register XBYTE *lookback; // scanning compare pointer + register XBYTE *tPointer; // scanning source pointer + register XBYTE *tLookback; // scanning compare pointer + register long counter; // number of bytes to scan + register XDWORD maxLen; // maximum match length + register XDWORD bestLen; // best match length + register XDWORD bestOff; // best match offset + register XDWORD length; // scanning length + XDWORD forward; // bytes to scan ahead pointer = theData + patternStart; @@ -385,7 +385,7 @@ unsigned long forward; // bytes to scan ahead // find maximum match length maxLen = MAXMATCH; forward = dataLen - patternStart; - if (forward < (unsigned long)counter) + if (forward < (XDWORD)counter) { if (forward < maxLen) { @@ -394,7 +394,7 @@ unsigned long forward; // bytes to scan ahead } else { - if ((unsigned long)counter < maxLen) + if ((XDWORD)counter < maxLen) { maxLen = counter; } @@ -451,7 +451,7 @@ unsigned long forward; // bytes to scan ahead /* -------------------------------------------------------------------------------- * * Compress srcBuffer using LZSS technique. * -------------------------------------------------------------------------------- */ -long LZSSCompress(XBYTE* srcBuffer, unsigned long srcBytes, XBYTE* dstBuffer, +XDWORD LZSSCompress(XBYTE* srcBuffer, XDWORD srcBytes, XBYTE* dstBuffer, XCompressStatusProc proc, void* procData) // srcBuffer; /* pointer to uncompressed data */ // srcBytes; /* size of uncompressed data */ @@ -540,10 +540,10 @@ XBYTE* callProcPtr; /* src position at which to call proc */ #else register XBYTE *dataPtr; /* pointer to uncompressed data */ -register unsigned long dataPos; /* buffer position for uncompressed data */ +register XDWORD dataPos; /* buffer position for uncompressed data */ register XBYTE *cdataPtr; /* pointer to compressed data */ -register unsigned long cdataPos; /* buffer position for compressed data */ -unsigned long callProcPos; /* src position at which to call proc */ +register XDWORD cdataPos; /* buffer position for compressed data */ +XDWORD callProcPos; /* src position at which to call proc */ register unsigned int codeCount; /* index for the code group */ register unsigned int codeNumber; /* the number 0-7 of the code element */ @@ -639,7 +639,7 @@ XBYTE codeBuf[16]; /* buffer for the code group */ // dstSize; /* size of uncompressed data */ /* -------------------------------------------------------------------------------- */ #if (X_PLATFORM == X_MACINTOSH) && (CPU_TYPE == k68000) && (ASM_doLZSSDecode) -static asm void doLZSSDecode(unsigned char * srcBuffer, unsigned long srcBytes, +static asm void doLZSSDecode(unsigned char * srcBuffer, XDWORD srcBytes, unsigned char * dstBuffer, long dstSize) { fralloc + @@ -719,7 +719,7 @@ Chris3 */ -static void doLZSSDecode(unsigned char* srcBuffer, unsigned long srcBytes, +static void doLZSSDecode(unsigned char* srcBuffer, XDWORD srcBytes, unsigned char* dstBuffer, long dstSize) { #if 1 //Moe's version @@ -884,7 +884,7 @@ long dstCountdown; /* convert buffer by byte differences */ #if USE_CREATION_API == TRUE -static void DeltaMono8(unsigned char * pData, unsigned long frameCount) +static void DeltaMono8(unsigned char * pData, XDWORD frameCount) { #if 0 asm 68000 @@ -913,7 +913,7 @@ unsigned char prev; } #endif } -static void DeltaStereo8(unsigned char* pData, unsigned long frameCount) +static void DeltaStereo8(unsigned char* pData, XDWORD frameCount) { unsigned char prevL; unsigned char prevR; @@ -934,7 +934,7 @@ unsigned char prevR; prevR = nextR; } } -static void DeltaMono16(short* pData, unsigned long frameCount) +static void DeltaMono16(short* pData, XDWORD frameCount) { short prev; @@ -948,7 +948,7 @@ short prev; prev = next; } } -static void DeltaStereo16(short* pData, unsigned long frameCount) +static void DeltaStereo16(short* pData, XDWORD frameCount) { short prevL; short prevR; @@ -972,7 +972,7 @@ short prevR; #endif /* unconvert byte difference buffer */ -static void UnDeltaMono8(unsigned char * pData, unsigned long frameCount) +static void UnDeltaMono8(unsigned char * pData, XDWORD frameCount) { #if 0 asm 68000 @@ -997,7 +997,7 @@ unsigned char sample; } #endif } -static void UnDeltaStereo8(unsigned char* pData, unsigned long frameCount) +static void UnDeltaStereo8(unsigned char* pData, XDWORD frameCount) { unsigned char left; unsigned char right; @@ -1012,7 +1012,7 @@ unsigned char right; *pData++ = right; } } -static void UnDeltaMono16(short* pData, unsigned long frameCount) +static void UnDeltaMono16(short* pData, XDWORD frameCount) { short sample; @@ -1023,7 +1023,7 @@ short sample; *pData++ = sample; } } -static void UnDeltaStereo16(short* pData, unsigned long frameCount) +static void UnDeltaStereo16(short* pData, XDWORD frameCount) { short left; short right; diff --git a/minibae/BAE_Source/Common/SampleTools.c b/minibae/BAE_Source/Common/SampleTools.c index 60277965..5505ccf4 100755 --- a/minibae/BAE_Source/Common/SampleTools.c +++ b/minibae/BAE_Source/Common/SampleTools.c @@ -182,7 +182,7 @@ // NOTE: This samples parameter is not guarenteed to be word aligned. -void XSwapShorts(short* shortArray, long count) +void XSwapShorts(XSWORD* shortArray, XDWORD count) { UBYTE* byteArray; UBYTE data; @@ -204,7 +204,7 @@ UBYTE data; #endif // This is used on 8 bit samples that are sign encoded. We want 0 to 255 not -128 to 127 -void XPhase8BitWaveform(unsigned char * pByte, long size) +void XPhase8BitWaveform(XBYTE * pByte, XDWORD size) { while (size--) { @@ -213,12 +213,12 @@ void XPhase8BitWaveform(unsigned char * pByte, long size) } // Given a Mac snd pointer, this will return the encoding type, and a pointer to a SoundHeader structure -static void * PV_GetSoundHeaderPtr(XPTR pRes, short int *pEncode) +static void * PV_GetSoundHeaderPtr(XPTR pRes, XSWORD *pEncode) { XSoundHeader *pSndBuffer; - short int soundFormat; - short int numSynths, numCmds; - long offset; + XWORD soundFormat; + XWORD numSynths, numCmds; + XDWORD offset; char *pSndFormat; numSynths = 0; @@ -268,13 +268,14 @@ static void * PV_GetSoundHeaderPtr(XPTR pRes, short int *pEncode) // Given a Mac sample, and loop points, this will change the data associated with it #if USE_CREATION_API == TRUE -void XSetSoundLoopPoints(XPTR pRes, long loopStart, long loopEnd) +void XSetSoundLoopPoints(XPTR pRes, XDWORD loopStart, XDWORD loopEnd) { register XSoundHeader *pSndBuffer; register XCmpSoundHeader *pCmpBuffer; register XExtSoundHeader *pExtBuffer; register XSoundHeader3 *pType3Buffer; - short int encode, count; + XSWORD encode; + int count; pSndBuffer = (XSoundHeader *)PV_GetSoundHeaderPtr(pRes, &encode); if (pSndBuffer) /* did we get the right format? */ @@ -714,7 +715,7 @@ XERR XGetSampleInfoFromSnd(XPTR pResource, SampleDataInfo *pOutInfo) case XCompressedHeader: // compressed header { XCmpSoundHeader* headerCmp; - short compressionID; + XSWORD compressionID; headerCmp = (XCmpSoundHeader*)header; pOutInfo->channels = (short)XGetLong(&headerCmp->numChannels); @@ -813,7 +814,7 @@ XERR XGetSampleInfoFromSnd(XPTR pResource, SampleDataInfo *pOutInfo) break; #endif default: - BAE_PRINTF("Unsupported codec %ld\n", pOutInfo->compressionType); + BAE_PRINTF("Unsupported codec %lu\n", (unsigned long)pOutInfo->compressionType); BAE_ASSERT(FALSE); err = -3; break; @@ -862,6 +863,7 @@ XPTR encodedData; UINT32 startFrame; XBYTE* inIntelOrder; XPTR sampleData; +XDWORD samplePtrOffset; XBYTE order = X_WORD_ORDER; inIntelOrder = ℴ @@ -919,14 +921,20 @@ XBYTE order = X_WORD_ORDER; case XCompressedHeader: // compressed header { XCmpSoundHeader* headerCmp; - short compressionID; + XSWORD compressionID; headerCmp = (XCmpSoundHeader*)header; - encodedData = (XPTR)XGetLong(&headerCmp->samplePtr); - if (!encodedData) /* get ptr to sample data */ + samplePtrOffset = XGetLong(&headerCmp->samplePtrOffset); + if (samplePtrOffset == 0L) { + /* get ptr to sample data */ encodedData = headerCmp->sampleArea; } + else + { + BAE_ASSERT(FALSE); + return NULL; + } info->channels = (short)XGetLong(&headerCmp->numChannels); info->bitSize = XGetShort(&headerCmp->sampleSize); info->frames = XGetLong(&headerCmp->numFrames); @@ -1029,7 +1037,7 @@ XBYTE order = X_WORD_ORDER; break; #endif default: - BAE_PRINTF("Unsupported codec %ld\n", info->compressionType); + BAE_PRINTF("Unsupported codec %lu\n", (unsigned long)info->compressionType); BAE_ASSERT(FALSE); return NULL; } @@ -1113,9 +1121,10 @@ register XSoundHeader *pSndBuffer; register XCmpSoundHeader *pCmpBuffer; register XExtSoundHeader *pExtBuffer; register XSoundHeader3 *pType3Buffer; -long offset; +XDWORD offset; char *sampleData; -short int encode; +XDWORD samplePtrOffset; +XWORD encode; #if X_PLATFORM == X_MACINTOSH XPTR rightData; long count; @@ -1298,11 +1307,17 @@ char *pLeft, *pRight; case XCompressedHeader: // compressed header pCmpBuffer = (XCmpSoundHeader *)pSndBuffer; - sampleData = (char *)XGetLong(&pCmpBuffer->samplePtr); - if (sampleData == NULL) /* get ptr to sample data */ + samplePtrOffset = XGetLong(&pCmpBuffer->samplePtrOffset); + if (samplePtrOffset == 0L) { + /* get ptr to sample data */ sampleData = (char *) pCmpBuffer->sampleArea; } + else + { + BAE_ASSERT(FALSE); + return NULL; + } info->channels = (short)XGetLong(&pCmpBuffer->numChannels); info->bitSize = XGetShort(&pCmpBuffer->sampleSize); BAE_ASSERT((info->bitSize == 8) || (info->bitSize == 16)); @@ -1476,7 +1491,7 @@ char *pLeft, *pRight; #if USE_CREATION_API == TRUE // Given a sample ID, this will search through sample types and return a 'C' string // of the resource name of the currently open resource files -XBOOL XGetSampleNameFromID(XLongResourceID sampleSoundID, char cName[256]) +XBOOL XGetSampleNameFromID(XLongResourceID sampleSoundID, char *cName) { static XResourceType sampleType[] = {ID_CSND, ID_ESND, ID_SND}; short int count; @@ -1506,7 +1521,7 @@ XBOOL XGetSampleNameFromID(XLongResourceID sampleSoundID, char cName[256]) #if USE_CREATION_API == TRUE // given 8 bit data, convert this to 16 bit data -XWORD * XConvert8BitTo16Bit(XBYTE * p8BitPCMData, unsigned long frames, unsigned long channels) +XWORD * XConvert8BitTo16Bit(XBYTE * p8BitPCMData, XDWORD frames, XDWORD channels) { XWORD *newData; unsigned long count, ccount; @@ -1531,7 +1546,7 @@ XWORD * XConvert8BitTo16Bit(XBYTE * p8BitPCMData, unsigned long frames, unsigned #endif // given 16 bit data, convert this to 8 bit data -XBYTE * XConvert16BitTo8Bit(XWORD * p16BitPCMData, unsigned long frames, unsigned long channels) +XBYTE * XConvert16BitTo8Bit(XWORD * p16BitPCMData, XDWORD frames, XDWORD channels) { XBYTE *newData = NULL; unsigned long count, ccount; @@ -1634,7 +1649,7 @@ XSoundFormat1* header; snd = (XExtSndHeader1*)*dst; - XPutLong(&snd->sndBuffer.samplePtr, 0L); + XPutLong(&snd->sndBuffer.samplePtrOffset, 0L); XPutLong(&snd->sndBuffer.numChannels, src.channels); XPutShort(&snd->sndBuffer.sampleSize, src.bitSize); XPutLong(&snd->sndBuffer.sampleRate, src.sampledRate); @@ -1673,7 +1688,7 @@ XSoundFormat1* header; snd = (XCmpSndHeader1*)*dst; - XPutLong(&snd->sndBuffer.samplePtr, 0L); + XPutLong(&snd->sndBuffer.samplePtrOffset, 0L); XPutLong(&snd->sndBuffer.numChannels, src.channels); XPutShort(&snd->sndBuffer.sampleSize, 2); if (src.bitSize == 8) @@ -1747,7 +1762,7 @@ XSoundFormat1* header; snd = (XCmpSndHeader1*)*dst; - XPutLong(&snd->sndBuffer.samplePtr, 0L); + XPutLong(&snd->sndBuffer.samplePtrOffset, 0L); XPutLong(&snd->sndBuffer.numChannels, src.channels); XPutShort(&snd->sndBuffer.sampleSize, 2); diff --git a/minibae/BAE_Source/Common/X_API.c b/minibae/BAE_Source/Common/X_API.c index b681cf14..387b0b2e 100755 --- a/minibae/BAE_Source/Common/X_API.c +++ b/minibae/BAE_Source/Common/X_API.c @@ -424,7 +424,7 @@ static XBOOL PV_XFileValid(XFILE fileRef) if (pReference) { int code; - code = BAE_IsBadReadPointer(&pReference->fileValidID, sizeof(long)); + code = BAE_IsBadReadPointer(&pReference->fileValidID, sizeof(XDWORD)); if (code == 0 || code == 2) { if (pReference->fileValidID == XPI_BLOCK_3_ID) @@ -525,7 +525,7 @@ static INLINE XBOOL PV_IsAnyOpenResourceFiles(void) // convert a c string to a pascal string void XCtoPascalString(char const* cString, char pascalString[256]) { - long length; + XDWORD length; if (cString && pascalString) { @@ -600,9 +600,9 @@ XPI_Memblock * XIsOurMemoryPtr(XPTR data) // ptr may be NULL, in which case the functionality is the same as XNewPtr() // If allocation fails, ptr is unaffected (It's still allocated.) // Like with XNewPtr(), any newly allocated memory is zeroed. -XPTR XResizePtr(XPTR ptr, long size) +XPTR XResizePtr(XPTR ptr, XDWORD size) { -long const currentSize = ptr ? XGetPtrSize(ptr) : 0; + XDWORD const currentSize = ptr ? XGetPtrSize(ptr) : 0; //MOE: If we are allocating to a certain quantum (typically 16 bytes), // We should apply that quantum before this test. @@ -653,7 +653,7 @@ long const currentSize = ptr ? XGetPtrSize(ptr) : 0; } // Allocates a block of ZEROED!!!! memory and locks it down -XPTR XNewPtr(long size) +XPTR XNewPtr(XDWORD size) { char *data; XPI_Memblock *pBlock; @@ -687,15 +687,15 @@ void XDisposePtr(XPTR data) size = XGetPtrSize(data); // need to get the size before we translate the pointer pBlock = (XPI_Memblock *)osAllocatedData; - XPutLong(&pBlock->blockID_one, (unsigned long)XPI_DEAD_ID); // set our ID for this block - XPutLong(&pBlock->blockID_two, (unsigned long)XPI_DEAD_ID); // to be dead. Used for tracking + XPutLong(&pBlock->blockID_one, (XDWORD)XPI_DEAD_ID); // set our ID for this block + XPutLong(&pBlock->blockID_two, (XDWORD)XPI_DEAD_ID); // to be dead. Used for tracking BAE_Deallocate(osAllocatedData); } } -long XGetPtrSize(XPTR data) +XDWORD XGetPtrSize(XPTR data) { - long size; + XDWORD size; XPTR odata; size = 0; @@ -718,7 +718,7 @@ long XGetPtrSize(XPTR data) // Typical block move, expect it must be able to handle overlapping source and // destination pointers -void XBlockMove(XPTRC source, XPTR dest, long size) +void XBlockMove(XPTRC source, XPTR dest, XDWORD size) { if (source && dest && size) { @@ -727,7 +727,7 @@ void XBlockMove(XPTRC source, XPTR dest, long size) } // set memory range with value -void XSetMemory(void *pAdr, long len, char value) +void XSetMemory(void *pAdr, XDWORD len, char value) { if (pAdr && (len > 0)) { memset(pAdr, value, len); @@ -735,9 +735,9 @@ void XSetMemory(void *pAdr, long len, char value) } // Given a pointer, and a bit number; this will set that bit to 1 -void XSetBit(void *pBitArray, unsigned long whichbit) +void XSetBit(void *pBitArray, XDWORD whichbit) { - unsigned long byteindex, bitindex; + XDWORD byteindex, bitindex; unsigned char *byte; if (pBitArray) @@ -750,9 +750,9 @@ void XSetBit(void *pBitArray, unsigned long whichbit) } // Given a pointer, and a bit number; this will set that bit to 0 -void XClearBit(void *pBitArray, unsigned long whichbit) +void XClearBit(void *pBitArray, XDWORD whichbit) { - unsigned long byteindex, bitindex; + XDWORD byteindex, bitindex; unsigned char *byte; if (pBitArray) @@ -765,9 +765,9 @@ void XClearBit(void *pBitArray, unsigned long whichbit) } // Given a pointer, and a bit number; this return the value of that bit -XBOOL XTestBit(void *pBitArray, unsigned long whichbit) +XBOOL XTestBit(void *pBitArray, XDWORD whichbit) { - register unsigned long byteindex, byte, bitindex; + register XDWORD byteindex, byte, bitindex; if (pBitArray) { @@ -814,7 +814,7 @@ XBOOL XIsStereoSupported(void) // wait for a waitAmount of microseconds to pass // CLS??: If this function is called from within the frame thread and // JAVA_THREAD is non-zero, we'll probably crash. -void XWaitMicroseocnds(unsigned long waitAmount) +void XWaitMicroseocnds(XDWORD waitAmount) { BAE_WaitMicroseconds(waitAmount); } @@ -822,7 +822,7 @@ void XWaitMicroseocnds(unsigned long waitAmount) // Returns microseconds since boot // 1 second = 1000 milliseconds = 100000 microseconds -unsigned long XMicroseconds(void) +XDWORD XMicroseconds(void) { return BAE_Microseconds(); } @@ -961,7 +961,7 @@ XFIXED XFixedCos(int angle) } // given a fixed point value, do a floor and return the closest integer -unsigned long XFixedFloor(XFIXED value) +XDWORD XFixedFloor(XFIXED value) { return ((value + XFIXED_ONEHALF) >> 16L); } @@ -977,17 +977,17 @@ unsigned short int XGetShortIntel(void const* pData) (unsigned short)pByte[0]; return data; } -// given a pointer, get a long ordered in an Intel way -unsigned long XGetLongIntel(void const* pData) +// given a pointer, get a XDWORD ordered in an Intel way +XDWORD XGetLongIntel(void const* pData) { register unsigned char *pByte; - register unsigned long data; + register XDWORD data; pByte = (unsigned char *)pData; - data = ((unsigned long)pByte[3] << 24L) | - ((unsigned long)pByte[2] << 16L) | - ((unsigned long)pByte[1] << 8L) | - (unsigned long)pByte[0]; + data = ((XDWORD)pByte[3] << 24L) | + ((XDWORD)pByte[2] << 16L) | + ((XDWORD)pByte[1] << 8L) | + (XDWORD)pByte[0]; return data; } @@ -1003,18 +1003,37 @@ unsigned short int XGetShort(void const* pData) return data; } // given a pointer, get a long ordered in a Motorola way -unsigned long XGetLong(void const* pData) +XDWORD XGetLong(void const* pData) { register unsigned char *pByte; - register unsigned long data; + register XDWORD data; pByte = (unsigned char *)pData; - data = ((unsigned long)pByte[0] << 24L) | - ((unsigned long)pByte[1] << 16L) | - ((unsigned long)pByte[2] << 8L) | - (unsigned long)pByte[3]; + data = ((XDWORD)pByte[0] << 24L) | + ((XDWORD)pByte[1] << 16L) | + ((XDWORD)pByte[2] << 8L) | + (XDWORD)pByte[3]; return data; } + +XWORD XGetShortOrdered(void *address) +{ +#if X_WORD_ORDER == FALSE + return XGetShort(address); + #else + return XGetShortIntel(address); +#endif +} + +XDWORD XGetLongOrdered(void *address) +{ +#if X_WORD_ORDER == FALSE + return XGetLong(address); + #else + return XGetLongIntel(address); + #endif +} + // given a pointer and a value, this with put a short in a ordered 68k way void XPutShort(void *pData, unsigned short data) { @@ -1026,7 +1045,7 @@ void XPutShort(void *pData, unsigned short data) } // given a pointer and a value, this with put a long in a ordered 68k way -void XPutLong(void *pData, unsigned long data) +void XPutLong(void *pData, XDWORD data) { register unsigned char *pByte; @@ -1037,9 +1056,9 @@ void XPutLong(void *pData, unsigned long data) pByte[3] = (UBYTE)(data & 0xFF); } -unsigned long XSwapLong(unsigned long value) +XDWORD XSwapLong(XDWORD value) { - unsigned long newValue; + XDWORD newValue; unsigned char *pOld; unsigned char *pNew; unsigned char temp; @@ -1059,7 +1078,7 @@ unsigned long XSwapLong(unsigned long value) return newValue; } -unsigned short XSwapShort(unsigned short value) +XWORD XSwapShort(XWORD value) { unsigned short newValue; unsigned char *pOld; @@ -1076,11 +1095,11 @@ unsigned short XSwapShort(unsigned short value) return newValue; } -// Swap shorts within a long, but not the bytes in each each short. +// Swap shorts within a XDWORD, but not the bytes in each each short. -unsigned long XSwapShortInLong(unsigned long value) +XDWORD XSwapShortInLong(XDWORD value) { - unsigned long newValue; + XDWORD newValue; unsigned short *pOld; unsigned short *pNew; unsigned short temp; @@ -1098,7 +1117,7 @@ unsigned long XSwapShortInLong(unsigned long value) // if TRUE, then motorola; if FALSE then intel XBOOL XDetermineByteOrder(void) { - static long value = 0x12345678; + static XDWORD value = 0x12345678; XBOOL order; order = FALSE; @@ -1173,7 +1192,7 @@ void XConvertNativeFileToXFILENAME(void *file, XFILENAME *xfile) { if (xfile) { - XSetMemory(xfile, (long)sizeof(XFILENAME), 0); + XSetMemory(xfile, (XDWORD)sizeof(XFILENAME), 0); } if (file) { @@ -1187,10 +1206,10 @@ void XConvertNativeFileToXFILENAME(void *file, XFILENAME *xfile) // Read a file into memory and return an allocated pointer. // 0 is ok, -1 failed to open, -2 failed to read, -3 failed memory // if 0, then *pData is valid -XERR XGetFileAsData(XFILENAME *pResourceName, XPTR *ppData, long *pSize) +XERR XGetFileAsData(XFILENAME *pResourceName, XPTR *ppData, XDWORD *pSize) { XFILE ref; - long size; + XDWORD size; XERR error; XPTR pData; @@ -1254,7 +1273,7 @@ XERR XGetTempXFILENAME(XFILENAME* xfilename) #if X_PLATFORM == X_MACINTOSH_9 short vRefNum; - long theDirID; + XDWORD theDirID; OSErr err; FSSpec fileSpec; char name[64], name2[32]; @@ -1271,7 +1290,7 @@ XERR XGetTempXFILENAME(XFILENAME* xfilename) XStrCpy(&name[length], (char *)XPtoCstr(name2)); // concatinate it to name // Create FSSpec structure from file name - XSetMemory(&fileSpec, (long)sizeof(FSSpec), 0); + XSetMemory(&fileSpec, (XDWORD)sizeof(FSSpec), 0); err = FSMakeFSSpec(vRefNum, theDirID, (unsigned char *)XCtoPstr(name), &fileSpec); if ((err == noErr) || (err == fnfErr)) { @@ -1310,7 +1329,7 @@ XBOOL XFileIsValidResource(XFILE file) { // validate resource file XFileSetPosition(file, 0L); // at start - if (XFileRead(file, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(file, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -1341,7 +1360,7 @@ XBOOL XFileIsValidResourceFromName(XFILENAME *file) } -XFILE XFileOpenResourceFromMemory(XPTR pResource, unsigned long resourceLength, XBOOL allowCopy) +XFILE XFileOpenResourceFromMemory(XPTR pResource, XDWORD resourceLength, XBOOL allowCopy) { XFILENAME *pReference; XFILERESOURCEMAP map; @@ -1349,7 +1368,7 @@ XFILE XFileOpenResourceFromMemory(XPTR pResource, unsigned long resourceLength, allowCopy; err = 0; - pReference = (XFILENAME *)XNewPtr((long)sizeof(XFILENAME)); + pReference = (XFILENAME *)XNewPtr((XDWORD)sizeof(XFILENAME)); if (pReference) { pReference->pResourceData = pResource; @@ -1376,7 +1395,7 @@ XFILE XFileOpenResourceFromMemory(XPTR pResource, unsigned long resourceLength, // validate resource file XFileSetPosition((XFILE)pReference, 0L); // at start - if (XFileRead((XFILE)pReference, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead((XFILE)pReference, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) != XFILERESOURCE_ID) { @@ -1406,7 +1425,7 @@ XFILE XFileOpenResource(XFILENAME *file, XBOOL readOnly) XERR err; err = 0; - pReference = (XFILENAME *)XNewPtr((long)sizeof(XFILENAME)); + pReference = (XFILENAME *)XNewPtr((XDWORD)sizeof(XFILENAME)); if (pReference) { *pReference = *file; @@ -1480,7 +1499,7 @@ XFILE XFileOpenResource(XFILENAME *file, XBOOL readOnly) #endif // validate resource file XFileSetPosition((XFILE)pReference, 0L); // at start - if (XFileRead((XFILE)pReference, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead((XFILE)pReference, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) != XFILERESOURCE_ID) { @@ -1505,11 +1524,11 @@ XFILE XFileOpenResource(XFILENAME *file, XBOOL readOnly) return (XFILE)pReference; } -XFILE XFileOpenForReadFromMemory(XPTR pMemoryBlock, unsigned long memoryBlockSize) +XFILE XFileOpenForReadFromMemory(XPTR pMemoryBlock, XDWORD memoryBlockSize) { XFILENAME *pReference; - pReference = (XFILENAME *)XNewPtr((long)sizeof(XFILENAME)); + pReference = (XFILENAME *)XNewPtr((XDWORD)sizeof(XFILENAME)); if (pReference) { pReference->pResourceData = pMemoryBlock; @@ -1528,7 +1547,7 @@ XFILE XFileOpenForRead(XFILENAME *file) { XFILENAME *pReference; - pReference = (XFILENAME *)XNewPtr((long)sizeof(XFILENAME)); + pReference = (XFILENAME *)XNewPtr((XDWORD)sizeof(XFILENAME)); if (pReference) { *pReference = *file; @@ -1553,7 +1572,7 @@ XFILE XFileOpenForWrite(XFILENAME *file, XBOOL create) { XFILENAME *pReference; - pReference = (XFILENAME *)XNewPtr((long)sizeof(XFILENAME)); + pReference = (XFILENAME *)XNewPtr((XDWORD)sizeof(XFILENAME)); if (pReference) { *pReference = *file; @@ -1595,7 +1614,7 @@ void XFileClose(XFILE fileRef) if (PV_XFileValid(fileRef)) { XFileFreeResourceCache(fileRef); - pReference->fileValidID = (long)XPI_DEAD_ID; + pReference->fileValidID = (XDWORD)XPI_DEAD_ID; if (pReference->pResourceData) { pReference->pResourceData = NULL; // clear memory file access @@ -1609,11 +1628,11 @@ void XFileClose(XFILE fileRef) } } -XERR XFileRead(XFILE fileRef, XPTR buffer, long bufferLength) +XERR XFileRead(XFILE fileRef, XPTR buffer, XDWORD bufferLength) { XFILENAME *pReference; - long newLength; - long err; + XDWORD newLength; + XERR err; pReference = (XFILENAME *)fileRef; if (PV_XFileValid(fileRef)) @@ -1640,7 +1659,7 @@ XERR XFileRead(XFILE fileRef, XPTR buffer, long bufferLength) return -1; } -XERR XFileWrite(XFILE fileRef, XPTRC buffer, long bufferLength) +XERR XFileWrite(XFILE fileRef, XPTRC buffer, XDWORD bufferLength) { XFILENAME *pReference; @@ -1659,7 +1678,7 @@ XERR XFileWrite(XFILE fileRef, XPTRC buffer, long bufferLength) return -1; } -XERR XFileSetPosition(XFILE fileRef, long filePosition) +XERR XFileSetPosition(XFILE fileRef, XDWORD filePosition) { XFILENAME *pReference; XERR err; @@ -1684,9 +1703,9 @@ XERR XFileSetPosition(XFILE fileRef, long filePosition) return err; } -XERR XFileSetPositionRelative(XFILE fileRef, long relativeOffset) +XERR XFileSetPositionRelative(XFILE fileRef, XDWORD relativeOffset) { - long pos; + XDWORD pos; XERR err; err = -1; @@ -1715,12 +1734,12 @@ static XBYTE * PV_GetFilePositionFromMemoryResource(XFILE fileRef) return pos; } -long XFileGetPosition(XFILE fileRef) +XDWORD XFileGetPosition(XFILE fileRef) { XFILENAME *pReference; long pos; - pos = -1; + pos = (XDWORD)-1; pReference = (XFILENAME *)fileRef; if (PV_XFileValid(fileRef)) { @@ -1737,10 +1756,10 @@ long XFileGetPosition(XFILE fileRef) } #if USE_CREATION_API == TRUE -XERR XFileSetLength(XFILE fileRef, unsigned long newSize) +XERR XFileSetLength(XFILE fileRef, XDWORD newSize) { XFILENAME *pReference; - long error; + XERR error; error = 0; pReference = (XFILENAME *)fileRef; @@ -1755,12 +1774,12 @@ XERR XFileSetLength(XFILE fileRef, unsigned long newSize) } #endif -long XFileGetLength(XFILE fileRef) +XDWORD XFileGetLength(XFILE fileRef) { XFILENAME *pReference; - long pos; + XDWORD pos; - pos = -1; + pos = (XDWORD)-1; pReference = (XFILENAME *)fileRef; if (PV_XFileValid(fileRef)) { @@ -1815,11 +1834,12 @@ static XFILE_CACHED_ITEM * PV_XGetNamedCacheEntry(XFILE fileRef, XResourceType r long count, total; XFILERESOURCECACHE *pCache; XFILE_CACHED_ITEM *pItem; - long err=0; + XERR err=0; char tempPascalName[256]; - long savePos; + XDWORD savePos; XFILERESOURCEMAP map; - long data, next; + XDWORD data; + XDWORD next; pItem = NULL; pReference = (XFILENAME *)fileRef; @@ -1831,7 +1851,7 @@ static XFILE_CACHED_ITEM * PV_XGetNamedCacheEntry(XFILE fileRef, XResourceType r //Gotta search the whole bleedin' thing! XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -1842,24 +1862,24 @@ static XFILE_CACHED_ITEM * PV_XGetNamedCacheEntry(XFILE fileRef, XResourceType r err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { pReference->memoryCacheEntry.resourceType = (XResourceType)XGetLong(&data); - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID pReference->memoryCacheEntry.resourceID = (XLongResourceID)XGetLong(&data); err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); XPtoCstr(tempPascalName); if (!XStrCmp((char *)tempPascalName, (char *)cName)) @@ -1903,7 +1923,7 @@ static XFILE_CACHED_ITEM * PV_XGetNamedCacheEntry(XFILE fileRef, XResourceType r err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (XStrCmp((char *)cName, (char *)XPtoCstr(tempPascalName)) == 0) { pItem = &pCache->cached[count]; @@ -1928,9 +1948,9 @@ static XFILE_CACHED_ITEM * PV_XGetNamedCacheEntry(XFILE fileRef, XResourceType r char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, char *pResourceName) { XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; char tempPascalName[256]; XFILE_CACHED_ITEM *pCacheItem; @@ -1960,8 +1980,8 @@ char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongRes err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1); } } } @@ -1973,7 +1993,7 @@ char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongRes else { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -1984,27 +2004,27 @@ char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongRes err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID if ((XLongResourceID)XGetLong(&data) == resourceID) { err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (pResourceName) { - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1 ); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1 ); break; } } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length data = XGetLong(&data); // get resource size } } @@ -2031,7 +2051,7 @@ char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongRes else { // use native resource manager short int theID; - unsigned long theType; + XDWORD theType; Handle theData; short int currentResourceFile; @@ -2057,12 +2077,12 @@ char * XGetResourceNameOnly(XFILE fileRef, XResourceType resourceType, XLongRes XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, char *pResourceName, - XPTR *pReturnedBuffer, long bytesToReadAndAllocate) + XPTR *pReturnedBuffer, XDWORD bytesToReadAndAllocate) { XFILENAME *pReference; XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; XPTR pData; char tempPascalName[256]; @@ -2089,10 +2109,10 @@ XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongRe err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (pResourceName) { - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1); } } } @@ -2132,7 +2152,7 @@ XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongRe else { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -2143,26 +2163,26 @@ XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongRe err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID if ((XLongResourceID)XGetLong(&data) == resourceID) { err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (pResourceName) { - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1); } } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length data = XGetLong(&data); // get resource size // get data @@ -2231,12 +2251,12 @@ XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongRe // resourceID is an ID // pResourceName is a pascal string. pResourceName can be NULL. // pReturnedResourceSize be filled with the size of the resource. pReturnedResourceSize can be NULL. -XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, long *pReturnedResourceSize) +XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, XDWORD *pReturnedResourceSize) { XFILENAME *pReference; XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; XPTR pData; char tempPascalName[256]; @@ -2271,10 +2291,10 @@ XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (pResourceName) { - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1); } } } @@ -2325,7 +2345,7 @@ XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID else { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -2336,26 +2356,26 @@ XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID if ((XLongResourceID)XGetLong(&data) == resourceID) { err = XFileRead(fileRef, &tempPascalName[0], 1L); // get name if (tempPascalName[0]) { - err = XFileRead(fileRef, &tempPascalName[1], (long)tempPascalName[0]); + err = XFileRead(fileRef, &tempPascalName[1], (XDWORD)tempPascalName[0]); if (pResourceName) { - XBlockMove(tempPascalName, pResourceName, (long)tempPascalName[0] + 1); + XBlockMove(tempPascalName, pResourceName, (XDWORD)tempPascalName[0] + 1); } } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length data = XGetLong(&data); // get resource size // get data @@ -2425,49 +2445,6 @@ XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID } - -/****************************************************************************** -******************************************************************************* -******************************************************************************* -** -** Functions to manage bank tokens -** -******************************************************************************* -******************************************************************************* -******************************************************************************/ - - -XBOOL AreBankTokensIdentical(XBankToken tok1, XBankToken tok2) -{ - if (tok1.fileLen == tok2.fileLen && tok1.xFile == tok2.xFile) - { - return TRUE; - } - return FALSE; -} - -XBankToken CreateBankToken(void) -{ - XBankToken retVal; - - retVal.xFile = (XTOKEN) XFileGetCurrentResourceFile(); - retVal.fileLen = (XTOKEN) XFileGetLength(retVal.xFile); - - return retVal; -} - -XBankToken CreateBankTokenFromInputs(XTOKEN tok1, XTOKEN tok2) -{ - XBankToken retVal; - - retVal.fileLen = tok1; - retVal.xFile = tok2; - - return retVal; -} - - - //bvk New! // Adds another cache entry to end of cache. @@ -2476,7 +2453,7 @@ static XBOOL PV_AddToAccessCache(XFILE fileRef, XFILE_CACHED_ITEM *cacheItemPtr { XFILENAME *pReference; XFILERESOURCECACHE *pCache,*newCache; - long int resCount; + long resCount; XFILE_CACHED_ITEM *pItem; pReference = (XFILENAME *)fileRef; @@ -2486,12 +2463,12 @@ static XBOOL PV_AddToAccessCache(XFILE fileRef, XFILE_CACHED_ITEM *cacheItemPtr if (pCache) { resCount = pCache->totalResources + 1; - newCache = (XFILERESOURCECACHE *)XNewPtr((long)sizeof(XFILERESOURCECACHE) + - ((long)sizeof(XFILE_CACHED_ITEM) * resCount)); + newCache = (XFILERESOURCECACHE *)XNewPtr((XDWORD)sizeof(XFILERESOURCECACHE) + + ((XDWORD)sizeof(XFILE_CACHED_ITEM) * resCount)); if (newCache) { - XBlockMove(pCache, newCache, (long)sizeof(XFILERESOURCECACHE) + - ((long)sizeof(XFILE_CACHED_ITEM) * (resCount - 1))); + XBlockMove(pCache, newCache, (XDWORD)sizeof(XFILERESOURCECACHE) + + ((XDWORD)sizeof(XFILE_CACHED_ITEM) * (resCount - 1))); XDisposePtr(pCache); pReference->pCache = newCache; @@ -2511,9 +2488,9 @@ static XBOOL PV_AddToAccessCache(XFILE fileRef, XFILE_CACHED_ITEM *cacheItemPtr XFILERESOURCECACHE * XCreateAccessCache(XFILE fileRef) { XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; XFILERESOURCECACHE *pCache; char pPName[256]; @@ -2524,14 +2501,14 @@ XFILERESOURCECACHE * XCreateAccessCache(XFILE fileRef) if (PV_XFileValid(fileRef)) { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { next = sizeof(XFILERESOURCEMAP); total = XGetLong(&map.totalResources); - pCache = (XFILERESOURCECACHE *)XNewPtr((long)sizeof(XFILERESOURCECACHE) + - ((long)sizeof(XFILE_CACHED_ITEM) * total)); + pCache = (XFILERESOURCECACHE *)XNewPtr((XDWORD)sizeof(XFILERESOURCECACHE) + + ((XDWORD)sizeof(XFILE_CACHED_ITEM) * total)); if (pCache) { pCache->totalResources = total; @@ -2540,24 +2517,24 @@ XFILERESOURCECACHE * XCreateAccessCache(XFILE fileRef) err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type pCache->cached[count].resourceType = (XResourceType)XGetLong(&data); - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID pCache->cached[count].resourceID = (XLongResourceID)XGetLong(&data); pCache->cached[count].fileOffsetName = XFileGetPosition(fileRef); // get name err = XFileRead(fileRef, &pPName[0], 1L); if (pPName[0]) { - err = XFileRead(fileRef, &pPName[1], (long)pPName[0]); + err = XFileRead(fileRef, &pPName[1], (XDWORD)pPName[0]); } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length pCache->cached[count].resourceLength = XGetLong(&data); pCache->cached[count].fileOffsetData = XFileGetPosition(fileRef); // save data offset } @@ -2664,9 +2641,9 @@ void XFileFreeResourceCache(XFILE fileRef) } } -static XBOOL PV_CheckForTypes(XResourceType *pTypes, long total, XResourceType typeCheck) +static XBOOL PV_CheckForTypes(XResourceType *pTypes, XDWORD total, XResourceType typeCheck) { - long count; + XDWORD count; XBOOL found; found = FALSE; @@ -2687,16 +2664,16 @@ static XBOOL PV_CheckForTypes(XResourceType *pTypes, long total, XResourceType t // bvk: why doesn't this use the cache? -long XCountTypes(XFILE fileRef) +XDWORD XCountTypes(XFILE fileRef) { - long typeCount; + XDWORD typeCount; XResourceType lastResourceType; XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; - long *pTypes; + XDWORD *pTypes; err = 0; typeCount = 0; @@ -2714,14 +2691,14 @@ long XCountTypes(XFILE fileRef) { // then use first open file fileRef = g_openResourceFiles[0]; } - pTypes = (long *)XNewPtr((sizeof(long) * MAX_XFILE_SCAN_TYPES)); + pTypes = (XDWORD *)XNewPtr((sizeof(XDWORD) * MAX_XFILE_SCAN_TYPES)); if (pTypes) { pReference = (XFILENAME *)fileRef; if (PV_XFileValid(fileRef)) { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -2732,11 +2709,11 @@ long XCountTypes(XFILE fileRef) err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type lastResourceType = (XResourceType)XGetLong(&data); if (typeCount < MAX_XFILE_SCAN_TYPES) { @@ -2777,16 +2754,16 @@ long XCountTypes(XFILE fileRef) // Return the type from the file based upon an index of 0 to XCountTypes // bvk: why doesn't this use the cache? -XResourceType XGetIndexedType(XFILE fileRef, long resourceIndex) +XResourceType XGetIndexedType(XFILE fileRef, XDWORD resourceIndex) { - long typeCount; + XDWORD typeCount; XResourceType lastResourceType; XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; - long *pTypes; + XDWORD *pTypes; #if X_PLATFORM == X_MACINTOSH_9 if (PV_IsAnyOpenResourceFiles() == FALSE) @@ -2807,14 +2784,14 @@ XResourceType XGetIndexedType(XFILE fileRef, long resourceIndex) { // then use first open file fileRef = g_openResourceFiles[0]; } - pTypes = (long *)XNewPtr((sizeof(long) * MAX_XFILE_SCAN_TYPES)); + pTypes = (XDWORD *)XNewPtr((sizeof(XDWORD) * MAX_XFILE_SCAN_TYPES)); if (pTypes) { pReference = (XFILENAME *)fileRef; if (PV_XFileValid(fileRef)) { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -2825,11 +2802,11 @@ XResourceType XGetIndexedType(XFILE fileRef, long resourceIndex) err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type lastResourceType = XGetLong(&data); if (typeCount < MAX_XFILE_SCAN_TYPES) { @@ -2892,11 +2869,11 @@ static XBOOL PV_IsXFileLocked(XFILE fileRef) #endif #if USE_CREATION_API == TRUE -static XERR PV_CopyWithinFile( XFILE fileRef, long offsetIn, long offsetOut, long size, - void *buffer, long bufferSize) +static XERR PV_CopyWithinFile( XFILE fileRef, XDWORD offsetIn, XDWORD offsetOut, XDWORD size, + void *buffer, XDWORD bufferSize) { - long xferSize, bytesTransferred; - long offset; + XDWORD xferSize, bytesTransferred; + XDWORD offset; XERR err; err = 0; @@ -2995,9 +2972,9 @@ XBOOL XCleanResourceFile(XFILE fileRef) XFILENAME *pReference; XERR err; XFILERESOURCEMAP map; - long data, nextIn, nextOut, resType, resID, totalResSize; - long count, inResTotal, outResTotal; - long resDataSize, fileSize, resInStart, resDataIn, resDataOut; + XDWORD data, nextIn, nextOut, resType, resID, totalResSize; + XDWORD count, inResTotal, outResTotal; + XDWORD resDataSize, fileSize, resInStart, resDataIn, resDataOut; char pResourceName[256]; XBOOL isCompacting; void *fileBuffer; @@ -3025,7 +3002,7 @@ XBOOL XCleanResourceFile(XFILE fileRef) fileSize = XFileGetLength(fileRef); XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -3041,7 +3018,7 @@ XBOOL XCleanResourceFile(XFILE fileRef) break; } resInStart = nextIn; - err = XFileRead(fileRef, &nextIn, (long)sizeof(long)); // get next input pointer + err = XFileRead(fileRef, &nextIn, (XDWORD)sizeof(XDWORD)); // get next input pointer if (err != 0) { err = -5; @@ -3049,9 +3026,9 @@ XBOOL XCleanResourceFile(XFILE fileRef) } nextIn = XGetLong(&nextIn); totalResSize = nextIn - resInStart; - if (nextIn != -1L) + if (nextIn != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if (err != 0) { err = -6; @@ -3090,7 +3067,7 @@ XBOOL XCleanResourceFile(XFILE fileRef) if (isCompacting) { //Get remainder of input info - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID if (err != 0) { err = -8; @@ -3100,9 +3077,9 @@ XBOOL XCleanResourceFile(XFILE fileRef) err = XFileRead(fileRef, &pResourceName[0], 1L); // get name if (pResourceName[0]) { - err = XFileRead(fileRef, &pResourceName[1], (long)pResourceName[0]); + err = XFileRead(fileRef, &pResourceName[1], (XDWORD)pResourceName[0]); } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length if (err != 0) { err = -9; @@ -3123,34 +3100,34 @@ XBOOL XCleanResourceFile(XFILE fileRef) //write out information data XPutLong(&data, nextOut); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); if (err != 0) { err = -16; break; } XPutLong(&data, resType); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put type + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put type if (err != 0) { err = -11; break; } XPutLong(&data, resID); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put ID + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put ID if (err != 0) { err = -12; break; } - err = XFileWrite(fileRef, pResourceName, (long)(((char *)pResourceName)[0])+1L); // put name + err = XFileWrite(fileRef, pResourceName, (XDWORD)(((char *)pResourceName)[0])+1L); // put name if (err != 0) { err = -13; break; } XPutLong(&data, resDataSize); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put length + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put length if (err != 0) { err = -14; @@ -3240,11 +3217,11 @@ XBOOL XCleanResourceFile(XFILE fileRef) XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, XBOOL collectTrash ) { XFILENAME *pReference; - long err=0; + XERR err=0; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; - long whereType, whereID; + XDWORD whereType, whereID; XFILE_CACHED_ITEM *pCachedItem; pReference = (XFILENAME *)fileRef; @@ -3275,12 +3252,12 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResour if (err != -1) { XPutLong(&data, XFILETRASH_ID); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put type + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put type if (err == 0) { XPutLong(&data, 0); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put ID + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put ID } } else @@ -3297,7 +3274,7 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResour { deleteanyways: XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -3308,18 +3285,18 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResour err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { whereType = XFileGetPosition(fileRef); // get current pos - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { whereID = XFileGetPosition(fileRef); // get current pos - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID if ((XLongResourceID)XGetLong(&data) == resourceID) { //We found it! @@ -3328,12 +3305,12 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResour err = XFileSetPosition(fileRef, whereType); XPutLong(&data, XFILETRASH_ID); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put type + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put type if (err == 0) { XPutLong(&data, 0); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put ID + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put ID break; } else @@ -3376,7 +3353,7 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType resourceType, XLongResour // return the number of resources of a particular type. -long XCountResourcesOfType(XResourceType resourceType) +XDWORD XCountResourcesOfType(XResourceType resourceType) { XERR err; @@ -3399,14 +3376,14 @@ long XCountResourcesOfType(XResourceType resourceType) // bvk - NEW for Beatnik Windows // For a given resource type, counts the number of resources of a type. // Does not check for duplicate IDs. -long XCountFileResourcesOfType(XFILE fileRef, XResourceType theType) +XDWORD XCountFileResourcesOfType(XFILE fileRef, XResourceType theType) { - long resCount; + XDWORD resCount; XResourceType resourceType; XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total; XFILERESOURCECACHE *pCache; XFILE_CACHED_ITEM *pCacheItem; @@ -3436,7 +3413,7 @@ long XCountFileResourcesOfType(XFILE fileRef, XResourceType theType) else { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -3447,11 +3424,11 @@ long XCountFileResourcesOfType(XFILE fileRef, XResourceType theType) err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type resourceType = (XResourceType)XGetLong(&data); if (resourceType == theType ) { @@ -3483,8 +3460,8 @@ long XCountFileResourcesOfType(XFILE fileRef, XResourceType theType) // search through open resource files until the resourceType is found based upon the resource index // pResourceName is a pascal string -XPTR XGetIndexedResource(XResourceType resourceType, XLongResourceID *pReturnedID, long resourceIndex, - void *pResourceName, long *pReturnedResourceSize) +XPTR XGetIndexedResource(XResourceType resourceType, XLongResourceID *pReturnedID, XDWORD resourceIndex, + void *pResourceName, XDWORD *pReturnedResourceSize) { long count; XPTR pData; @@ -3548,12 +3525,12 @@ XPTR XGetIndexedResource(XResourceType resourceType, XLongResourceID *pReturnedI // is out of range // pResourceName is a pascal string XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID *pReturnedID, - long resourceIndex, void *pResourceName, long *pReturnedResourceSize) + XDWORD resourceIndex, void *pResourceName, XDWORD *pReturnedResourceSize) { XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data, next; + XDWORD data, next; long count, total, typeCount; XPTR pData; char pPName[256]; @@ -3589,7 +3566,7 @@ XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongRes err = XFileRead(fileRef, &pPName[0], 1L); // get name length if (pPName[0]) { - err = XFileRead(fileRef, &pPName[1], (long)pPName[0]); + err = XFileRead(fileRef, &pPName[1], (XDWORD)pPName[0]); } // get data XFileSetPosition(fileRef, pCacheItem->fileOffsetData); @@ -3638,7 +3615,7 @@ XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongRes else { XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -3649,23 +3626,23 @@ XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongRes err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { if (resourceIndex == typeCount) { - err = XFileRead(fileRef, pReturnedID, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, pReturnedID, (XDWORD)sizeof(XDWORD)); // get ID *pReturnedID = (XLongResourceID)XGetLong(pReturnedID); err = XFileRead(fileRef, &pPName[0], 1L); // get name length if (pPName[0]) { - err = XFileRead(fileRef, &pPName[1], (long)pPName[0]); + err = XFileRead(fileRef, &pPName[1], (XDWORD)pPName[0]); } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length data = XGetLong(&data); // get resource size // get data // is data memory based? @@ -3730,7 +3707,7 @@ XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongRes } if (pResourceName) { - XBlockMove(pPName, pResourceName, (long)pPName[0] + 1); + XBlockMove(pPName, pResourceName, (XDWORD)pPName[0] + 1); } return pData; } @@ -3763,7 +3740,8 @@ XERR XGetUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, XLongRe XFILENAME *pReference; XERR err; XFILERESOURCECACHE *pCache; - long count, total, idCount, next, data; + long count, total, idCount; + XDWORD next, data; XLongResourceID *pIDs; XFILERESOURCEMAP map; @@ -3800,7 +3778,7 @@ XERR XGetUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, XLongRe else { err = XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -3814,14 +3792,14 @@ XERR XGetUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, XLongRe err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID pIDs[idCount] = (XLongResourceID)XGetLong(&data); idCount++; } @@ -3949,7 +3927,7 @@ XERR XMakeUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, // pResourceName is a pascal string // pData is the data block to add // length is the length of the data block -XERR XAddResource(XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, void *pData, long length) +XERR XAddResource(XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, void *pData, XDWORD length) { XERR err; @@ -4018,14 +3996,14 @@ XBOOL XDeleteResource(XResourceType resourceType, XLongResourceID resourceID, XB // length is the length of the data block XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void const* pResourceName, - void *pData, long length) + void *pData, XDWORD length) { XFILENAME *pReference; - long err; + XERR err; XFILERESOURCEMAP map; - long data; + XDWORD data; char fakeName[2]; - long next, nextsave; + XDWORD next, nextsave; XFILE_CACHED_ITEM cacheItem; #if X_PLATFORM == X_MACINTOSH_9 @@ -4056,7 +4034,7 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, XDeleteFileResource(fileRef, XFILECACHE_ID, 0, FALSE); XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -4064,17 +4042,17 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, nextsave = XFileGetPosition(fileRef); // rewrite this later next = -1; // store all Fs for now - err = XFileWrite(fileRef, &next, (long)sizeof(long)); + err = XFileWrite(fileRef, &next, (XDWORD)sizeof(XDWORD)); - XPutLong(&data, (unsigned long)resourceType); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put type - cacheItem.resourceType = (unsigned long)resourceType; + XPutLong(&data, (XDWORD)resourceType); + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put type + cacheItem.resourceType = (XDWORD)resourceType; if (err == 0) { - XPutLong(&data, (unsigned long)resourceID); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put ID - cacheItem.resourceID = (unsigned long)resourceID; + XPutLong(&data, (XDWORD)resourceID); + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put ID + cacheItem.resourceID = (XDWORD)resourceID; if (err == 0) { @@ -4083,7 +4061,7 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, if (pResourceName) { - err = XFileWrite(fileRef, pResourceName, (long)(((char *)pResourceName)[0])+1L); // put name + err = XFileWrite(fileRef, pResourceName, (XDWORD)(((char *)pResourceName)[0])+1L); // put name } else { @@ -4094,7 +4072,7 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, if (err == 0) { XPutLong(&data, length); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); // put length + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); // put length cacheItem.resourceLength = length; if (err == 0) @@ -4110,14 +4088,14 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, XFileSetPosition(fileRef, 0L); // back to start data = XGetLong(&map.totalResources) + 1; XPutLong(&map.totalResources, data); - err = XFileWrite(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)); + err = XFileWrite(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)); if (err == 0) { // write real offset-of-next-resource value XFileSetPosition(fileRef, nextsave); XPutLong(&data, next); - err = XFileWrite(fileRef, &data, (long)sizeof(long)); + err = XFileWrite(fileRef, &data, (XDWORD)sizeof(XDWORD)); if (err == 0) { @@ -4143,17 +4121,17 @@ XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, // get a resource type from the name. cName is a C string -XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedResourceSize) +XPTR XGetNamedResource(XResourceType resourceType, void *cName, XDWORD *pReturnedResourceSize) { XPTR pData; XFILE_CACHED_ITEM *pCacheItem; char pResourceName[256]; long count, total; - short int fileCount; + int fileCount; XERR err; XFILE fileRef; XFILERESOURCEMAP map; - long next, data; + XDWORD next, data; XLongResourceID resourceID; pData = NULL; @@ -4164,7 +4142,7 @@ XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedR #if X_PLATFORM == X_MACINTOSH_9 { Handle theData; - long size; + XDWORD size; // first look inside any open resource files if (PV_IsAnyOpenResourceFiles()) @@ -4229,7 +4207,7 @@ XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedR // search through without cache. fileRef = g_openResourceFiles[fileCount]; XFileSetPosition(fileRef, 0L); // at start - if (XFileRead(fileRef, &map, (long)sizeof(XFILERESOURCEMAP)) == 0) + if (XFileRead(fileRef, &map, (XDWORD)sizeof(XFILERESOURCEMAP)) == 0) { if (XGetLong(&map.mapID) == XFILERESOURCE_ID) { @@ -4240,19 +4218,19 @@ XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedR err = XFileSetPosition(fileRef, next); // at start if (err == 0) { - err = XFileRead(fileRef, &next, (long)sizeof(long)); // get next pointer + err = XFileRead(fileRef, &next, (XDWORD)sizeof(XDWORD)); // get next pointer next = XGetLong(&next); - if (next != -1L) + if (next != (XDWORD)-1L) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get type + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get type if ((XResourceType)XGetLong(&data) == resourceType) { - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get ID + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get ID resourceID = (XLongResourceID)XGetLong(&data); err = XFileRead(fileRef, &pResourceName[0], 1L); // get name if (pResourceName[0]) { - err = XFileRead(fileRef, &pResourceName[1], (long)pResourceName[0]); + err = XFileRead(fileRef, &pResourceName[1], (XDWORD)pResourceName[0]); XPtoCstr(pResourceName); if (XStrCmp(pResourceName, (char *)cName) == 0) { // match? @@ -4260,7 +4238,7 @@ XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedR resourceType, resourceID, pResourceName, pReturnedResourceSize); } - err = XFileRead(fileRef, &data, (long)sizeof(long)); // get length + err = XFileRead(fileRef, &data, (XDWORD)sizeof(XDWORD)); // get length data = XGetLong(&data); // get resource size if (XFileSetPositionRelative(fileRef, data)) { @@ -4327,7 +4305,7 @@ XBOOL XGetResourceName(XResourceType resourceType, XLongResourceID resourceID, if (cName[0] == 0) { // use native resource manager short int theID; - unsigned long theType; + XDWORD theType; Handle theData; SetResLoad(FALSE); @@ -4376,13 +4354,13 @@ XBOOL XGetFileResourceName(XFILE fileRef, XResourceType resourceType, // Get a resource and detach it from the resource manager. Which means that you'll need to call XDisposePtr // to free the memory -XPTR XGetAndDetachResource(XResourceType resourceType, XLongResourceID resourceID, long *pReturnedResourceSize) +XPTR XGetAndDetachResource(XResourceType resourceType, XLongResourceID resourceID, XDWORD *pReturnedResourceSize) { #if X_PLATFORM == X_MACINTOSH_9 Handle theData; XPTR pData; XPTR pNewData; - long size; + XDWORD size; char szPName[256]; short int count; XFILE fileRef; @@ -4450,7 +4428,7 @@ XPTR XGetAndDetachResource(XResourceType resourceType, XLongResourceID resourceI return pData; #else // X_PLATFORM == X_MACINTOSH_9 char szPName[256]; - long lSize = 0; + XDWORD lSize = 0; XPTR pData = NULL; XPTR pNewData; short int count; @@ -4525,9 +4503,9 @@ void XFileUseThisResourceFile(XFILE fileRef) // First byte is a type. // Next three bytes are a length. // Type 0 is Delta LZSS compression -void * XDecompressPtr(void* pData, unsigned long dataSize, XBOOL ignoreType) +void * XDecompressPtr(void* pData, XDWORD dataSize, XBOOL ignoreType) { - unsigned long theTotalSize; + XDWORD theTotalSize; XCOMPRESSION_TYPE theType; XPTR theNewData; @@ -4544,32 +4522,32 @@ void * XDecompressPtr(void* pData, unsigned long dataSize, XBOOL ignoreType) switch (theType) { case X_RAW: - LZSSUncompress((unsigned char*)pData + sizeof(long), - dataSize - sizeof(long), + LZSSUncompress((unsigned char*)pData + sizeof(XDWORD), + dataSize - sizeof(XDWORD), (unsigned char*)theNewData, theTotalSize); break; case X_MONO_8: - LZSSUncompressDeltaMono8((unsigned char*)pData + sizeof(long), - dataSize - sizeof(long), + LZSSUncompressDeltaMono8((unsigned char*)pData + sizeof(XDWORD), + dataSize - sizeof(XDWORD), (unsigned char*)theNewData, theTotalSize); break; case X_STEREO_8: - LZSSUncompressDeltaStereo8((unsigned char*)pData + sizeof(long), - dataSize - sizeof(long), + LZSSUncompressDeltaStereo8((unsigned char*)pData + sizeof(XDWORD), + dataSize - sizeof(XDWORD), (unsigned char*)theNewData, theTotalSize); break; case X_MONO_16: - LZSSUncompressDeltaMono16((unsigned char*)pData + sizeof(long), - dataSize - sizeof(long), + LZSSUncompressDeltaMono16((unsigned char*)pData + sizeof(XDWORD), + dataSize - sizeof(XDWORD), (short*)theNewData, theTotalSize); break; case X_STEREO_16: - LZSSUncompressDeltaStereo16((unsigned char*)pData + sizeof(long), - dataSize - sizeof(long), + LZSSUncompressDeltaStereo16((unsigned char*)pData + sizeof(XDWORD), + dataSize - sizeof(XDWORD), (short*)theNewData, theTotalSize); break; @@ -4594,13 +4572,13 @@ void * XDecompressPtr(void* pData, unsigned long dataSize, XBOOL ignoreType) // The length of the compressed data is returned if compression succeeds // If -1 is returned, the compression failed // If 0 is returned, compression was aborted by proc. -long XCompressPtr(XPTR* compressedDataTarget, - XPTR pData, unsigned long dataSize, +XDWORD XCompressPtr(XPTR* compressedDataTarget, + XPTR pData, XDWORD dataSize, XCOMPRESSION_TYPE type, XCompressStatusProc proc, void* procData) { XPTR compressedData; -long compressedSize; +XDWORD compressedSize; XBYTE *realData; if (!compressedDataTarget) @@ -4654,14 +4632,14 @@ XBYTE *realData; if (compressedSize > 0) { - compressedSize += sizeof(long); + compressedSize += sizeof(XDWORD); realData = (XBYTE*)XNewPtr(compressedSize); if (realData) { XPutLong(realData, dataSize); realData[0] = (XBYTE)type; - XBlockMove(compressedData, realData + sizeof(long), - compressedSize - sizeof(long)); + XBlockMove(compressedData, realData + sizeof(XDWORD), + compressedSize - sizeof(XDWORD)); } *compressedDataTarget = realData; } @@ -4679,10 +4657,10 @@ XPTR XDuplicateMemory(XPTRC src, XDWORD len) dup = NULL; if (src) { - dup = XNewPtr((long)len); + dup = XNewPtr((XDWORD)len); if (dup) { - XBlockMove(src, dup, (long)len); + XBlockMove(src, dup, (XDWORD)len); } } return dup; @@ -4721,7 +4699,7 @@ void XStripStr(char *pString) // Duplicate and string characters between 0-32 char * XDuplicateAndStripStr(char const* src) { - long length; // must be signed + XDWORD length; // must be signed char* cStrippedString; char* cDest; char const* cSource; @@ -4897,7 +4875,7 @@ char * XStrCat(char * dest, char const* source) return dest; } -long XStrLen(char const* src) +XDWORD XStrLen(char const* src) { #if 1 short int len; @@ -4912,7 +4890,7 @@ long XStrLen(char const* src) len++; } while (*src++); - return len; + return (XDWORD)len; #else char const* s; @@ -4921,12 +4899,12 @@ char const* s; { while (*s) s++; } - return s - src; + return (XDWORD)(s - src); #endif } // standard strcmp -short int XStrCmp(char const* s1, char const* s2) +XSWORD XStrCmp(char const* s1, char const* s2) { if (s1 == NULL) { @@ -4963,7 +4941,7 @@ short int XStrCmp(char const* s1, char const* s2) } // standard strcmp, but ignore case -short int XLStrCmp(char const* s1, char const* s2) +XSWORD XLStrCmp(char const* s1, char const* s2) { if (s1 == NULL) { @@ -5001,7 +4979,7 @@ short int XLStrCmp(char const* s1, char const* s2) // Standard strncmp, but ignore case. Compares zero terminated s1 with non zero terminated s2 with s2 having // a length of n -short int XLStrnCmp(char const* s1, char const* s2, long n) +XSWORD XLStrnCmp(char const* s1, char const* s2, XDWORD n) { if (s1 == NULL) { @@ -5030,7 +5008,7 @@ short int XLStrnCmp(char const* s1, char const* s2, long n) } // Standard strncmp. Compares zero terminated s1 with non zero terminated s2 with s2 having // a length of n -short int XStrnCmp(char const* s1, char const* s2, register long n) +XSWORD XStrnCmp(char const* s1, char const* s2, register XDWORD n) { if (s1 == NULL) { @@ -5058,9 +5036,9 @@ short int XStrnCmp(char const* s1, char const* s2, register long n) return 0; } -// Converts a long value to a base 10 string, +// Converts a XSDWORD value to a base 10 string, // Returns pointer to the '\0' at the end of the string -char* XLongToStr(char* dest, long value) +char* XLongToStr(char* dest, XDWORD value) { char* t; @@ -5073,8 +5051,8 @@ char* t; } else { - unsigned long v; - unsigned long power; + XDWORD v; + XDWORD power; XBOOL nonzeroFound; v = value; @@ -5106,10 +5084,10 @@ char* t; return t; } -// This will convert a string to a base 10 long value -long XStrnToLong(char const* pData, long length) +// This will convert a string to a base 10 XDWORD value +XDWORD XStrnToLong(char const* pData, XDWORD length) { - long result, num, count; + XDWORD result, num, count; char data[12]; result = 0; @@ -5146,7 +5124,10 @@ long XStrnToLong(char const* pData, long length) #if 1 -short int XMemCmp(void const* src1, void const * src2, long n) +// returns 0 for ok +// -1 for src1 less than src2 +// 1 for src1 greater than src2 +XSWORD XMemCmp(void const* src1, void const * src2, XDWORD n) { unsigned const char * p1; unsigned const char * p2; @@ -5162,7 +5143,10 @@ short int XMemCmp(void const* src1, void const * src2, long n) return 0; } #else -short int XMemCmp(void const* src1, void const* src2, long n) +// returns 0 for ok +// -1 for src1 less than src2 +// 1 for src1 greater than src2 +XSWORD XMemCmp(void const* src1, void const * src2, XDWORD n) { unsigned char const* p1; unsigned char const* p2; @@ -5186,14 +5170,14 @@ unsigned char const* p2; * pseudo-random number generator * */ -static unsigned long seed = 1; +static XDWORD seed = 1; // return a pseudo-random number in the range of 0-32767 -short int XRandom(void) +XSWORD XRandom(void) { seed = seed * 1103515245 + 12345; - return (short int)((seed >> 16L) & 0x7FFFL); // high word of long, remove high bit + return (XSWORD)((seed >> 16L) & 0x7FFFL); // high word of long, remove high bit } @@ -5202,7 +5186,7 @@ short int XRandom(void) * */ -void XSeedRandom(unsigned long n) +void XSeedRandom(XDWORD n) { seed = n; } diff --git a/minibae/BAE_Source/Common/X_API.h b/minibae/BAE_Source/Common/X_API.h index b9e08196..6298916c 100755 --- a/minibae/BAE_Source/Common/X_API.h +++ b/minibae/BAE_Source/Common/X_API.h @@ -268,6 +268,8 @@ #ifndef __X_API__ #define __X_API__ +#include + // some common types #undef TRUE #ifndef TRUE @@ -502,43 +504,47 @@ typedef void * XPTR; typedef void const* XPTRC; typedef void * XRESOURCE; +// can be free sized typedef long XERR; -typedef unsigned char XBOOL; -typedef unsigned short XBOOL16; +typedef uint8_t XBOOL; +typedef uint16_t XBOOL16; +// can be free sized for performance typedef long LOOPCOUNT; -typedef char XSBYTE; // 8 bit signed -typedef unsigned char XBYTE; // 8 bit unsigned -typedef short XSWORD; // 16 bit signed -typedef unsigned short XWORD; // 16 bit unsigned +typedef int8_t XSBYTE; // 8 bit signed +typedef uint8_t XBYTE; // 8 bit unsigned +typedef int16_t XSWORD; // 16 bit signed +typedef uint16_t XWORD; // 16 bit unsigned // NOTE: on 64-bit platforms, this needs to be redefined because a long is 64 bits! -typedef long XSDWORD; // 32 bit signed -typedef unsigned long XDWORD; // 32 bit unsigned -typedef XDWORD XTOKEN; // base typedef for all toekn types +typedef int32_t XSDWORD; // 32 bit signed +typedef uint32_t XDWORD; // 32 bit unsigned +typedef XPTR XTOKEN; // base typedef for all token types -struct XBankToken +typedef struct XBankToken_t { XTOKEN xFile; - XTOKEN fileLen; -}; -typedef struct XBankToken XBankToken; + XDWORD fileLen; +} XBankToken; +XBOOL AreBankTokensIdentical(XBankToken tok1, XBankToken tok2); +XBankToken CreateBankToken(void); +XBankToken CreateBankTokenFromInputs(XTOKEN tok, XDWORD len); // these macros need to be removed soon. Conflicts are coming -#define UBYTE XBYTE -#define SBYTE XSBYTE +typedef XBYTE UBYTE; +typedef XSBYTE SBYTE; #if X_PLATFORM != X_LIBERATE -#define INT16 XSWORD -#define UINT16 XWORD -#define INT32 XSDWORD -#define UINT32 XDWORD +typedef XSWORD INT16; +typedef XWORD UINT16; +typedef XSDWORD INT32; +typedef XDWORD UINT32; #endif // This is used to solve the 4 character constant problem on some compilers #define FOUR_CHAR(ch1,ch2,ch3,ch4) \ - ((((unsigned long)(ch1)&0x0FFL)<<24L) + (((ch2)&0x0FFL)<<16L) + (((ch3)&0x0FFL)<<8L) + ((ch4)&0x0FFL)) + ((((XDWORD)(ch1)&0x0FFL)<<24L) + (((ch2)&0x0FFL)<<16L) + (((ch3)&0x0FFL)<<8L) + ((ch4)&0x0FFL)) #undef ABS @@ -554,7 +560,7 @@ typedef struct XBankToken XBankToken; -typedef unsigned long XFIXED; +typedef XDWORD XFIXED; // The type XFIXED is an unsigned value, but the the calculations allow for negative numbers. If you changes this // from long to unsigned, then all the fade API's will fail. If you need the extra bit for an unsigned value // use the unsigned macros @@ -564,12 +570,12 @@ typedef unsigned long XFIXED; #define XFIXED_ONEHALF 0x00008000L #define XFIXED_180_OVER_PI 0x00394BB7L -#define LONG_TO_XFIXED(x) (XFIXED)((((long)(x)) * XFIXED_1)) -#define UNSIGNED_LONG_TO_XFIXED(x) (XFIXED)((((unsigned long)(x)) * XFIXED_1)) +#define LONG_TO_XFIXED(x) (XFIXED)((((XDWORD)(x)) * XFIXED_1)) +#define UNSIGNED_LONG_TO_XFIXED(x) (XFIXED)((((XDWORD)(x)) * XFIXED_1)) #define RATIO_TO_XFIXED(a,b) (LONG_TO_XFIXED(a) / (b)) -#define XFIXED_TO_LONG(x) (long)(((long)(x)) / XFIXED_1) -#define XFIXED_TO_UNSIGNED_LONG(x) (unsigned long)(((unsigned long)(x)) / XFIXED_1) -#define XFIXED_TO_SHORT(x) ((short)((x) / XFIXED_1)) +#define XFIXED_TO_LONG(x) (XDWORD)(((XDWORD)(x)) / XFIXED_1) +#define XFIXED_TO_UNSIGNED_LONG(x) (XDWORD)(((XDWORD)(x)) / XFIXED_1) +#define XFIXED_TO_SHORT(x) ((XSWORD)((x) / XFIXED_1)) #define XFIXED_TO_LONG_ROUNDED(x) XFIXED_TO_LONG((x) + XFIXED_1 / 2) #define XFIXED_TO_SHORT_ROUNDED(x) XFIXED_TO_SHORT((x) + XFIXED_1 / 2) @@ -601,11 +607,11 @@ typedef unsigned long XFIXED; // passed to the user. struct XPI_Memblock { - long blockID_one; // ID that this is our block. part 1 - long blockSize; // block size - long blockID_two; // ID that this is our block. part 2 + XDWORD blockID_one; // ID that this is our block. part 1 + XDWORD blockSize; // block size + XDWORD blockID_two; // ID that this is our block. part 2 #if (X_PLATFORM == X_SOLARIS) - long alignment8; // used for alignment to 8 byte boundries + XDWORD alignment8; // used for alignment to 8 byte boundries #endif }; typedef struct XPI_Memblock XPI_Memblock; @@ -620,45 +626,45 @@ typedef struct XPI_Memblock XPI_Memblock; // reference, which will be the real memory allocated with the host allocate memory function. XPI_Memblock * XIsOurMemoryPtr(XPTR data); -XPTR XNewPtr(long size); +XPTR XNewPtr(XDWORD size); void XDisposePtr(XPTR data); -long XGetPtrSize(XPTR data); +XDWORD XGetPtrSize(XPTR data); // This function re-allocates a memory block // ptr may be NULL, in which case the functionality is the same as XNewPtr() // If allocation fails, ptr is unaffected (It's still allocated.) // Like with XNewPtr(), any newly allocated memory is zeroed. -XPTR XResizePtr(XPTR ptr, long size); +XPTR XResizePtr(XPTR ptr, XDWORD size); -void XBlockMove(XPTRC source, XPTR dest, long size); -void XSetMemory(void *pAdr, long len, char value); -void XBubbleSortArray(short int *theArray, short int theCount); -void XSetBit(void *pBitArray, unsigned long whichbit); -void XClearBit(void *pBitArray, unsigned long whichbit); -XBOOL XTestBit(void *pBitArray, unsigned long whichbit); +void XBlockMove(XPTRC source, XPTR dest, XDWORD size); +void XSetMemory(void *pAdr, XDWORD len, char value); +void XBubbleSortArray(XSWORD *theArray, XSWORD theCount); +void XSetBit(void *pBitArray, XDWORD whichbit); +void XClearBit(void *pBitArray, XDWORD whichbit); +XBOOL XTestBit(void *pBitArray, XDWORD whichbit); -unsigned long XMicroseconds(void); -void XWaitMicroseocnds(unsigned long waitAmount); +XDWORD XMicroseconds(void); +void XWaitMicroseocnds(XDWORD waitAmount); // Resource Manager -typedef long XResourceType; -typedef long XLongResourceID; -typedef short XShortResourceID; +typedef XDWORD XResourceType; +typedef XDWORD XLongResourceID; +typedef XWORD XShortResourceID; struct XFILE_CACHED_ITEM { XResourceType resourceType; // resource type XLongResourceID resourceID; // resource ID - long resourceLength; // resource ID - long fileOffsetName; // file offset from 0 to resource name - long fileOffsetData; // file offset from 0 to resource data + XDWORD resourceLength; // resource ID + XDWORD fileOffsetName; // file offset from 0 to resource name + XDWORD fileOffsetData; // file offset from 0 to resource data }; typedef struct XFILE_CACHED_ITEM XFILE_CACHED_ITEM; struct XFILERESOURCECACHE { - long totalResources; + XDWORD totalResources; XFILE_CACHED_ITEM cached[1]; }; typedef struct XFILERESOURCECACHE XFILERESOURCECACHE; @@ -666,9 +672,10 @@ typedef struct XFILERESOURCECACHE XFILERESOURCECACHE; struct XFILENAME { - long fileValidID; + XDWORD fileValidID; // public platform specific - long fileReference; + //#CHECK + XDWORD fileReference; #if X_PLATFORM == X_MACINTOSH_9 FSSpec theFile; #else @@ -679,8 +686,8 @@ struct XFILENAME XBOOL resourceFile; XPTR pResourceData; // if file is memory based - long resMemLength; // length of memory resource file - long resMemOffset; // current offset of memory resource file + XDWORD resMemLength; // length of memory resource file + XDWORD resMemOffset; // current offset of memory resource file XBOOL readOnly; // TRUE then file is read only XBOOL allowMemCopy; // if TRUE, when a memory based resource is // read, a copy will be created otherwise @@ -690,7 +697,8 @@ struct XFILENAME XFILERESOURCECACHE *pCache; // if file has been cached this will point to it }; typedef struct XFILENAME XFILENAME; -typedef long XFILE; // this is used as a pointer, it needs to be changed for 64 bit CPUs. +//#CHECK +typedef XPTR XFILE; // this is used as a pointer, it needs to be changed for 64 bit CPUs. #define XFILERESOURCE_ID FOUR_CHAR('I','R','E','Z') // IREZ #define XFILECACHE_ID FOUR_CHAR('C','A','C','H') // CACH @@ -698,18 +706,18 @@ typedef long XFILE; // this is used as a pointer, it nee struct XFILERESOURCEMAP { - long mapID; - long version; - long totalResources; + XDWORD mapID; + XDWORD version; + XDWORD totalResources; }; typedef struct XFILERESOURCEMAP XFILERESOURCEMAP; // Resource Entry -// long nextentry -// long resourceType -// long resourceID +// XDWORD nextentry +// XDWORD resourceType +// XDWORD resourceID // pascal string resourceName -// long resourceLength +// XDWORD resourceLength // data block // Resource file works as follows: @@ -736,11 +744,11 @@ XFILE XFileOpenResource(XFILENAME *file, XBOOL readOnly); // is an exact copy of the resource file format. Don't dispose of pResource until you // have closed the file. If allowCopy is TRUE, then when resources are read new copies // will be created, otherwise just a pointer into the mapped resource file -XFILE XFileOpenResourceFromMemory(XPTR pResource, unsigned long resourceLength, XBOOL allowCopy); +XFILE XFileOpenResourceFromMemory(XPTR pResource, XDWORD resourceLength, XBOOL allowCopy); // Open file as a read only file from a memory pointer. Don't dispose of pMemoryBlock until you // have closed the file. -XFILE XFileOpenForReadFromMemory(XPTR pMemoryBlock, unsigned long memoryBlockSize); +XFILE XFileOpenForReadFromMemory(XPTR pMemoryBlock, XDWORD memoryBlockSize); // open file for reading and writing. Direct access. XFILE XFileOpenForRead(XFILENAME *file); @@ -759,7 +767,7 @@ XERR XFileDelete(XFILENAME *file); // Read a file into memory and return an allocated pointer. // 0 is ok, -1 failed to open, -2 failed to read, -3 failed memory // if 0, then *pData is valid -XERR XGetFileAsData(XFILENAME *pResourceName, XPTR *pData, long *pSize); +XERR XGetFileAsData(XFILENAME *pResourceName, XPTR *pData, XDWORD *pSize); void XConvertNativeFileToXFILENAME(void *file, XFILENAME *xfile); void XConvertPathToXFILENAME(void *path, XFILENAME *xfile); @@ -776,10 +784,10 @@ void XFileFreeResourceCache(XFILE fileRef); // search through open resource files XBOOL XExistsResource(XResourceType resourceType, XLongResourceID resourceID); XBOOL XGetResourceName(XResourceType resourceType, XLongResourceID resourceID, char *cName); -XPTR XGetNamedResource(XResourceType resourceType, void *cName, long *pReturnedResourceSize); -XPTR XGetAndDetachResource(XResourceType resourceType, XLongResourceID resourceID, long *pReturnedResourceSize); -XPTR XGetIndexedResource(XResourceType resourceType, XLongResourceID *pReturnedID, long resourceIndex, - void *pResourceName, long *pReturnedResourceSize); +XPTR XGetNamedResource(XResourceType resourceType, void *cName, XDWORD *pReturnedResourceSize); +XPTR XGetAndDetachResource(XResourceType resourceType, XLongResourceID resourceID, XDWORD *pReturnedResourceSize); +XPTR XGetIndexedResource(XResourceType resourceType, XLongResourceID *pReturnedID, XDWORD resourceIndex, + void *pResourceName, XDWORD *pReturnedResourceSize); // get a unique ID for a particular file to be used as a resource ID XERR XGetUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, XLongResourceID *pReturnedID); @@ -798,7 +806,7 @@ XERR XMakeUniqueFileResourceID(XFILE fileRef, XResourceType resourceType, // pResourceName is a pascal string // pData is the data block to add // length is the length of the data block -XERR XAddResource(XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, void *pData, long length); +XERR XAddResource(XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, void *pData, XDWORD length); // Delete a resource from the most recently open resource file. // resourceType is a type @@ -807,7 +815,7 @@ XERR XAddResource(XResourceType resourceType, XLongResourceID resourceID, voi XBOOL XDeleteResource(XResourceType theType, XLongResourceID resourceID, XBOOL collectTrash ); // return the number of resources of a particular type. -long XCountResourcesOfType(XResourceType resourceType); +XDWORD XCountResourcesOfType(XResourceType resourceType); // Force a clean/update of the most recently opened resource file XBOOL XCleanResource(void); @@ -819,7 +827,7 @@ XBOOL XCleanResource(void); // pResourceName is a pascal string // pData is the data block to add // length is the length of the data block -XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void const*pResourceName, void *pData, long length); +XERR XAddFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void const*pResourceName, void *pData, XDWORD length); XBOOL XExistsFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID); @@ -831,17 +839,17 @@ XBOOL XExistsFileResource(XFILE fileRef, XResourceType resourceType, XLongReso // Returns TRUE if found, otherwise FALSE XBOOL XGetFileResourceName(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, char *cName); -XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, long *pReturnedResourceSize); -XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID *pReturnedID, long resourceIndex, - void *pResourceName, long *pReturnedResourceSize); +XPTR XGetFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, void *pResourceName, XDWORD *pReturnedResourceSize); +XPTR XGetIndexedFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID *pReturnedID, XDWORD resourceIndex, + void *pResourceName, XDWORD *pReturnedResourceSize); XERR XReadPartialFileResource(XFILE fileRef, XResourceType resourceType, XLongResourceID resourceID, char *pReturnedResourceName, - XPTR *pReturnedBuffer, long bytesToReadAndAllocate); + XPTR *pReturnedBuffer, XDWORD bytesToReadAndAllocate); -XResourceType XGetIndexedType(XFILE fileRef, long resourceIndex); -long XCountTypes(XFILE fileRef); -long XCountFileResourcesOfType(XFILE fileRef, XResourceType theType); +XResourceType XGetIndexedType(XFILE fileRef, XDWORD resourceIndex); +XDWORD XCountTypes(XFILE fileRef); +XDWORD XCountFileResourcesOfType(XFILE fileRef, XResourceType theType); // Get just the name of a resource only // fileRef is the open file @@ -860,55 +868,51 @@ XBOOL XDeleteFileResource(XFILE fileRef, XResourceType theType, XLongResourceI XBOOL XCleanResourceFile( XFILE fileRef ); // File Manager -XERR XFileRead(XFILE fileRef, XPTR buffer, long bufferLength); -XERR XFileWrite(XFILE fileRef, XPTRC buffer, long bufferLength); -XERR XFileSetPosition(XFILE fileRef, long filePosition); -long XFileGetPosition(XFILE fileRef); -XERR XFileSetPositionRelative(XFILE fileRef, long relativeOffset); -long XFileGetLength(XFILE fileRef); -XERR XFileSetLength(XFILE refRef, unsigned long newSize); - -XBOOL AreBankTokensIdentical(XBankToken tok1, XBankToken tok2); -XBankToken CreateBankToken(void); -XBankToken CreateBankTokenFromInputs(XTOKEN tok1, XTOKEN tok2); +XERR XFileRead(XFILE fileRef, XPTR buffer, XDWORD bufferLength); +XERR XFileWrite(XFILE fileRef, XPTRC buffer, XDWORD bufferLength); +XERR XFileSetPosition(XFILE fileRef, XDWORD filePosition); +XDWORD XFileGetPosition(XFILE fileRef); +XERR XFileSetPositionRelative(XFILE fileRef, XDWORD relativeOffset); +XDWORD XFileGetLength(XFILE fileRef); +XERR XFileSetLength(XFILE refRef, XDWORD newSize); // standard string functions -short int XStrCmp(char const* string1, char const* string2); -short int XStrnCmp(char const* string1, char const* string2, long n); +XSWORD XStrCmp(char const* string1, char const* string2); +XSWORD XStrnCmp(char const* string1, char const* string2, XDWORD n); char* XStrCpy(char* dest, char const* src); char* XStrStr(char* source, char const* pattern); -long XStrLen(char const* src); +XDWORD XStrLen(char const* src); char* XStrCat(char* dest, char const* source); char* XStrCatChar(char *dest, char c); -short int XLowerCase(short int c); -XBOOL XIsDigit(short int c); +XSWORD XLowerCase(XSWORD c); +XBOOL XIsDigit(XSWORD c); // standard string functions, but ignore case -short int XLStrCmp(const char* string1, const char* string2); -short int XLStrnCmp(const char* string1, const char* string2, long n); +XSWORD XLStrCmp(const char* string1, const char* string2); +XSWORD XLStrnCmp(const char* string1, const char* string2, XDWORD n); char* XLStrStr(char* source, char const* pattern); XPTR XDuplicateMemory(XPTRC src, XDWORD len); -short int XMemCmp(void const* src1, void const* src2, long n); +XSWORD XMemCmp(void const* src1, void const* src2, XDWORD n); char* XDuplicateStr(char const* src); // Duplicate and string characters below 32 char* XDuplicateAndStripStr(char const* src); void XStripStr(char* pString); // Converts a long value to a base 10 string, returns pointer to the end -char* XLongToStr(char* dest, long value); +char* XLongToStr(char* dest, XDWORD value); // This will convert a string to a base 10 long value -long XStrnToLong(char const* pData, long length); +XDWORD XStrnToLong(char const* pData, XDWORD length); -enum +typedef enum { X_SOURCE_ENCRYPTED = 0, // source encrypted, destination is not encrypted X_SOURCE_DEST_ENCRYPTED // source and destination encrypted -}; +} XEncryptType; // standard strcpy, but with crypto controls -char *XEncryptedStrCpy(char* dest, char const* src, short int copy); -long XEncryptedStrLen(char const* src); +char *XEncryptedStrCpy(char* dest, char const* src, XEncryptType copy); +XDWORD XEncryptedStrLen(char const* src); char *XDecryptAndDuplicateStr(char const* src); @@ -927,7 +931,7 @@ XFIXED XFixedMultiply(XFIXED prodA, XFIXED prodB); XFIXED XFixedCos(int angle); XFIXED XFixedSin(int angle); // given a fixed point value, do a floor and return the closest integer -unsigned long XFixedFloor(XFIXED value); +XDWORD XFixedFloor(XFIXED value); // if TRUE, then motorola; if FALSE then intel XBOOL XDetermineByteOrder(void); @@ -936,17 +940,21 @@ XBOOL XDetermineByteOrder(void); // !!!! These can't be turned into macros because the code accesses bytes // that are not byte aligned. We need to get them byte by byte to prevent // CPU's from failing. -unsigned short XGetShortIntel(void const* address); -unsigned long XGetLongIntel(void const* address); -unsigned short XGetShort(void const* address); -unsigned long XGetLong(void const* address); -void XPutShort(void *address, unsigned short value); -void XPutLong(void *address, unsigned long value); +XWORD XGetShortIntel(void const* address); +XDWORD XGetLongIntel(void const* address); +XWORD XGetShort(void const* address); +XDWORD XGetLong(void const* address); +void XPutShort(void *address, XWORD value); +void XPutLong(void *address, XDWORD value); + +XWORD XGetShortOrdered(void *address); +XDWORD XGetLongOrdered(void *address); + // These will swap bytes no matter the byte order -unsigned short XSwapShort(unsigned short value); -unsigned long XSwapLong(unsigned long value); -unsigned long XSwapShortInLong(unsigned long value); +XWORD XSwapShort(XWORD value); +XDWORD XSwapLong(XDWORD value); +XDWORD XSwapShortInLong(XDWORD value); // Type 0 - Delta encoded LZSS @@ -961,23 +969,23 @@ typedef enum // First byte is a compression type. // Next 3 bytes is uncompressed length. -void* XDecompressPtr(void * pData, unsigned long dataSize, XBOOL ignoreType); - -void LZSSUncompress(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes); -void LZSSUncompressDeltaMono8(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes); -void LZSSUncompressDeltaStereo8(unsigned char* src, unsigned long srcBytes, - unsigned char* dst, unsigned long dstBytes); -void LZSSUncompressDeltaMono16(unsigned char* src, unsigned long srcBytes, - short* dst, unsigned long dstBytes); -void LZSSUncompressDeltaStereo16(unsigned char* src, unsigned long srcBytes, - short* dst, unsigned long dstBytes); +void* XDecompressPtr(void * pData, XDWORD dataSize, XBOOL ignoreType); + +void LZSSUncompress(unsigned char* src, XDWORD srcBytes, + unsigned char* dst, XDWORD dstBytes); +void LZSSUncompressDeltaMono8(unsigned char* src, XDWORD srcBytes, + unsigned char* dst, XDWORD dstBytes); +void LZSSUncompressDeltaStereo8(unsigned char* src, XDWORD srcBytes, + unsigned char* dst, XDWORD dstBytes); +void LZSSUncompressDeltaMono16(unsigned char* src, XDWORD srcBytes, + XSWORD* dst, XDWORD dstBytes); +void LZSSUncompressDeltaStereo16(unsigned char* src, XDWORD srcBytes, + XSWORD* dst, XDWORD dstBytes); // return TRUE to stop typedef XBOOL (*XCompressStatusProc)(void* data, - unsigned long currentBuffer, - unsigned long maxBuffer); + XDWORD currentBuffer, + XDWORD maxBuffer); #if USE_CREATION_API != FALSE // Given a block of data and a size, this will compress it into a newly-allocated. @@ -989,25 +997,25 @@ typedef XBOOL (*XCompressStatusProc)(void* data, // The length of the compressed data is returned if compression succeeds // If -1 is returned, the compression failed // If 0 is returned, compression was aborted by proc. -long XCompressPtr(XPTR* compressedDataTarget, - XPTR pData, unsigned long dataSize, +XDWORD XCompressPtr(XPTR* compressedDataTarget, + XPTR pData, XDWORD dataSize, XCOMPRESSION_TYPE type, XCompressStatusProc proc, void* procData); -long LZSSCompress(XBYTE* src, unsigned long srcBytes, XBYTE* dst, - XCompressStatusProc proc, void* procData); -long LZSSCompressDeltaMono8(XBYTE* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompress(XBYTE* src, XDWORD srcBytes, XBYTE* dst, + XCompressStatusProc proc, void* procData); +XDWORD LZSSCompressDeltaMono8(XBYTE* src, XDWORD srcBytes, XBYTE* dst, + XCompressStatusProc proc, void* procData); +XDWORD LZSSCompressDeltaStereo8(XBYTE* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData); -long LZSSCompressDeltaStereo8(XBYTE* src, unsigned long srcBytes, XBYTE* dst, - XCompressStatusProc proc, void* procData); -long LZSSCompressDeltaMono16(short* src, unsigned long srcBytes, XBYTE* dst, +XDWORD LZSSCompressDeltaMono16(XSWORD* src, XDWORD srcBytes, XBYTE* dst, + XCompressStatusProc proc, void* procData); +XDWORD LZSSCompressDeltaStereo16(XSWORD* src, XDWORD srcBytes, XBYTE* dst, XCompressStatusProc proc, void* procData); -long LZSSCompressDeltaStereo16(short* src, unsigned long srcBytes, XBYTE* dst, - XCompressStatusProc proc, void* procData); #endif -void XSwapShorts(short* shortArray, long count); -void XPhase8BitWaveform(unsigned char * pByte, long size); +void XSwapShorts(XSWORD* shortArray, XDWORD count); +void XPhase8BitWaveform(unsigned char * pByte, XDWORD size); // Sound Support XBOOL XIs8BitSupported(void); @@ -1016,8 +1024,8 @@ XBOOL XIsStereoSupported(void); #define X_FULL_VOLUME 256 // full volume (1.0) -void XGetCompressionName(long compressionType, void *cName); -void XGetShortCompressionName(long compressionType, void *cName); +void XGetCompressionName(XDWORD compressionType, void *cName); +void XGetShortCompressionName(XDWORD compressionType, void *cName); // Mac ADPCM compression (IMA 4 to 1) XPTR XAllocateCompressedAiffIma(void const* src, XDWORD srcBitsPerSample, @@ -1032,7 +1040,7 @@ void XExpandAiffIma(XBYTE const* src, XDWORD srcBytesPerBlock, XDWORD XExpandAiffImaStream(XBYTE const* src, XDWORD srcBytesPerBlock, void *dst, XDWORD dstBitsPerSample, XDWORD srcBytes, XDWORD channelCount, - short predictorCache[2]); + XSWORD predictorCache[2]); // This is used for WAVE files XDWORD XExpandWavIma(XBYTE const* src, XDWORD srcBytesPerBlock, @@ -1040,28 +1048,28 @@ XDWORD XExpandWavIma(XBYTE const* src, XDWORD srcBytesPerBlock, XDWORD srcBytes, XDWORD channelCount); // u law decompression -void XExpandULawto16BitLinear(unsigned char *pSource, short int *pDest, long frames, long channels); +void XExpandULawto16BitLinear(unsigned char *pSource, XSWORD *pDest, XDWORD frames, XDWORD channels); // a law decompression -void XExpandALawto16BitLinear(unsigned char *pSource, short int *pDest, long frames, long channels); +void XExpandALawto16BitLinear(unsigned char *pSource, XSWORD *pDest, XDWORD frames, XDWORD channels); // MACE decompression -void XExpandMace1to6(void *inBuffer, void *outBuffer, unsigned long cnt, +void XExpandMace1to6(void *inBuffer, void *outBuffer, XDWORD cnt, void * inState, void * outState, - unsigned long numChannels, unsigned long whichChannel); -void XExpandMace1to3(void *inBuffer, void *outBuffer, unsigned long cnt, + XDWORD numChannels, XDWORD whichChannel); +void XExpandMace1to3(void *inBuffer, void *outBuffer, XDWORD cnt, void * inState, void * outState, - unsigned long numChannels, unsigned long whichChannel); + XDWORD numChannels, XDWORD whichChannel); // Decrypt a block of data. This should be U.S. munitions safe. ie below 40 bit -void XDecryptData(void *pData, unsigned long size); +void XDecryptData(void *pData, XDWORD size); // Encrypt a block of data. This should be U.S. munitions safe. ie below 40 bit -void XEncryptData(void *pData, unsigned long size); +void XEncryptData(void *pData, XDWORD size); // Random numbers -short int XRandom(void); // return pseudo-random from 0 to 32767 -void XSeedRandom(unsigned long n); // set pseudo-random generator -short int XRandomRange(short int max); // return pseudo-random from 0 to max - 1 +XSWORD XRandom(void); // return pseudo-random from 0 to 32767 +void XSeedRandom(XDWORD n); // set pseudo-random generator +XSWORD XRandomRange(XSWORD max); // return pseudo-random from 0 to max - 1 // Character translation functions diff --git a/minibae/BAE_Source/Common/X_Decompress.c b/minibae/BAE_Source/Common/X_Decompress.c index 72ec4b2b..88ad11eb 100755 --- a/minibae/BAE_Source/Common/X_Decompress.c +++ b/minibae/BAE_Source/Common/X_Decompress.c @@ -107,7 +107,7 @@ #endif #if USE_CREATION_API == TRUE -void XGetShortCompressionName(long compressionType, void *cName) +void XGetShortCompressionName(SndCompressionType compressionType, void *cName) { switch (compressionType) { @@ -180,7 +180,7 @@ void XGetShortCompressionName(long compressionType, void *cName) } } -void XGetCompressionName(long compressionType, void *cName) +void XGetCompressionName(SndCompressionType compressionType, void *cName) { switch (compressionType) { @@ -262,17 +262,17 @@ void XGetCompressionName(long compressionType, void *cName) #if X_PLATFORM == X_MACINTOSH_9 // expand data 1 to 3 use MacOS MACE compression -void XExpandMace1to3(void *inBuffer, void *outBuffer, unsigned long length, +void XExpandMace1to3(void *inBuffer, void *outBuffer, XDWORD length, void * inState, void * outState, - unsigned long numChannels, unsigned long whichChannel) + XDWORD numChannels, XDWORD whichChannel) { Exp1to3(inBuffer, outBuffer, length, (StateBlockPtr)inState, (StateBlockPtr)outState, numChannels, whichChannel); } // expand data 1 to 6 use MacOS MACE compression -void XExpandMace1to6(void *inBuffer, void *outBuffer, unsigned long length, +void XExpandMace1to6(void *inBuffer, void *outBuffer, XDWORD length, void * inState, void * outState, - unsigned long numChannels, unsigned long whichChannel) + XDWORD numChannels, XDWORD whichChannel) { Exp1to6(inBuffer, outBuffer, length, (StateBlockPtr)inState, (StateBlockPtr)outState, numChannels, whichChannel); } @@ -385,7 +385,7 @@ static short int st_ulaw_to_linear(unsigned char ulawbyte) #endif -void XExpandULawto16BitLinear(unsigned char *pSource, short int *pDest, long frames, long channels) +void XExpandULawto16BitLinear(XBYTE *pSource, XSWORD *pDest, XDWORD frames, XDWORD channels) { long count; @@ -399,7 +399,7 @@ void XExpandULawto16BitLinear(unsigned char *pSource, short int *pDest, long fra } -void XExpandALawto16BitLinear(unsigned char *pSource, short int *pDest, long frames, long channels) +void XExpandALawto16BitLinear(XBYTE *pSource, XSWORD *pDest, XDWORD frames, XDWORD channels) { long count; @@ -414,10 +414,10 @@ void XExpandALawto16BitLinear(unsigned char *pSource, short int *pDest, long fra #if USE_CREATION_API == TRUE // compress ALaw or ULaw -void XCompressLaw(SndCompressionType compressionType, short int *pSource, char *pDest, - unsigned long frames, unsigned long channels) +void XCompressLaw(SndCompressionType compressionType, XSWORD *pSource, XBYTE *pDest, + XDWORD frames, XDWORD channels) { - unsigned long count; + XDWORD count; if (pSource && pDest && frames) { @@ -440,11 +440,11 @@ void XCompressLaw(SndCompressionType compressionType, short int *pSource, char * } #endif -#define INIT_R (unsigned long)56549 -#define C1 (unsigned long)52845 -#define C2 (unsigned long)22719 +#define INIT_R (XDWORD)56549 +#define C1 (XDWORD)52845 +#define C2 (XDWORD)22719 -static INLINE unsigned char PV_Decrypt(unsigned long *pR, unsigned char cipher) +static INLINE unsigned char PV_Decrypt(XDWORD *pR, unsigned char cipher) { unsigned char plain; @@ -454,7 +454,7 @@ static INLINE unsigned char PV_Decrypt(unsigned long *pR, unsigned char cipher) } #if USE_CREATION_API == TRUE -static INLINE unsigned char PV_Encrypt(unsigned long *pR, unsigned char plain) +static INLINE unsigned char PV_Encrypt(XDWORD *pR, unsigned char plain) { unsigned char cipher; @@ -464,9 +464,9 @@ static INLINE unsigned char PV_Encrypt(unsigned long *pR, unsigned char plain) } #endif -long XEncryptedStrLen(char const* src) +XDWORD XEncryptedStrLen(char const* src) { - unsigned long R; + XDWORD R; #if 1 short int len; @@ -483,7 +483,7 @@ long XEncryptedStrLen(char const* src) len++; } while (PV_Decrypt(&R, *src++)); - return len; + return (XDWORD)len; #else char const* s; @@ -504,11 +504,11 @@ char const* s; // standard strcpy, but with crypto controls // Copies 'C' string s2 into s1 -char * XEncryptedStrCpy(char *dest, char const* src, short int copy) +char * XEncryptedStrCpy(char *dest, char const* src, XEncryptType copy) { char *sav; char data; - unsigned long R; + XDWORD R; if (src == NULL) { @@ -566,10 +566,10 @@ char * XDecryptAndDuplicateStr(char const* src) #if USE_CREATION_API == TRUE // Encrypt a block of data. This should be U.S. munitions safe. ie below 40 bit -void XEncryptData(void *pData, unsigned long size) +void XEncryptData(void *pData, XDWORD size) { unsigned char *pByte, *pEnd; - unsigned long R; + XDWORD R; if (pData && size) { @@ -587,11 +587,11 @@ void XEncryptData(void *pData, unsigned long size) #endif // USE_CREATION_API == TRUE // Decrypt a block of data. This should be U.S. munitions safe. ie below 40 bit -void XDecryptData(void *pData, unsigned long size) +void XDecryptData(void *pData, XDWORD size) { unsigned char *pByte, *pEnd; - unsigned long R; - unsigned long crc1, crc2; + XDWORD R; + XDWORD crc1, crc2; crc1 = 0; crc2 = 0; diff --git a/minibae/BAE_Source/Common/X_Formats.h b/minibae/BAE_Source/Common/X_Formats.h index 4a427f65..367bfc50 100755 --- a/minibae/BAE_Source/Common/X_Formats.h +++ b/minibae/BAE_Source/Common/X_Formats.h @@ -203,8 +203,8 @@ */ typedef struct { - short int instrumentNumber; - short int ResourceINSTID; + XSWORD instrumentNumber; + XSWORD ResourceINSTID; } X_PACKBY1 Remap; enum @@ -273,25 +273,25 @@ typedef enum typedef struct { XShortResourceID midiResourceID; - char reserved_0; - char reverbType; - unsigned short songTempo; - char songType; // 0 - SMS, 1 - RMF, 2 - MOD - - char songPitchShift; - char maxEffects; - char maxNotes; - short int mixLevel; - unsigned char flags1; // see XBF for flags1 - char noteDecay; - char defaultPercusionProgram; // yes, I wanted signed! - unsigned char flags2; // see XBF for flags2 - short int remapCount; - char remaps; // Remap variable -// unsigned char copyright; // variable pascal string - unsigned char author; // variable pascal string - unsigned char title; // variable pascal string - unsigned char licensor_contact; + XBYTE reserved_0; + XBYTE reverbType; + XWORD songTempo; + XBYTE songType; // 0 - SMS, 1 - RMF, 2 - MOD + + XBYTE songPitchShift; + XBYTE maxEffects; + XBYTE maxNotes; + XSWORD mixLevel; + XBYTE flags1; // see XBF for flags1 + XBYTE noteDecay; + XBYTE defaultPercusionProgram; // yes, I wanted signed! + XBYTE flags2; // see XBF for flags2 + XSWORD remapCount; + XBYTE remaps; // Remap variable +// XBYTE copyright; // variable pascal string + XBYTE author; // variable pascal string + XBYTE title; // variable pascal string + XBYTE licensor_contact; } X_PACKBY1 SongResource_SMS; @@ -335,38 +335,38 @@ typedef enum typedef struct { XShortResourceID rmfResourceID; - char reserved_0; - char reverbType; - unsigned short songTempo; - char songType; // 0 - SMS, 1 - RMF, 2 - MOD - - char locked; // are resource encrypted - short int songPitchShift; - short int maxEffects; - short int maxNotes; - short int mixLevel; - short int songVolume; // 127 is 100%, 256 is 200% etc. - char embeddedSong; // TRUE if embedded in a bank - char reserved_1; - long unused[7]; + XBYTE reserved_0; + XBYTE reverbType; + XWORD songTempo; + XBYTE songType; // 0 - SMS, 1 - RMF, 2 - MOD + + XBYTE locked; // are resource encrypted + XSWORD songPitchShift; + XSWORD maxEffects; + XSWORD maxNotes; + XSWORD mixLevel; + XSWORD songVolume; // 127 is 100%, 256 is 200% etc. + XBYTE embeddedSong; // TRUE if embedded in a bank + XBYTE reserved_1; + XDWORD unused[7]; - short int resourceCount; - short int resourceData; // subtract this when calculating empty structure + XSWORD resourceCount; + XSWORD resourceData; // subtract this when calculating empty structure // // from this point on, the data is based upon types and data blocks -// char title[1]; // variable C string -// char composer[1]; // variable C string -// char copyright_date[1]; // variable C string -// char copyright_line[1]; // variable C string -// char contact_info[1]; // variable C string -// char use_license[1]; // variable C string -// char license_term[1]; // variable C string -// char territory[1]; // variable C string -// char expire_date[1]; // variable C string -// char foreign_rights[1]; // variable C string -// char compser_notes[1]; // variable C string -// char index_number[1]; // variable C string -// short int velocityCurve[128]; +// XBYTE title[1]; // variable C string +// XBYTE composer[1]; // variable C string +// XBYTE copyright_date[1]; // variable C string +// XBYTE copyright_line[1]; // variable C string +// XBYTE contact_info[1]; // variable C string +// XBYTE use_license[1]; // variable C string +// XBYTE license_term[1]; // variable C string +// XBYTE territory[1]; // variable C string +// XBYTE expire_date[1]; // variable C string +// XBYTE foreign_rights[1]; // variable C string +// XBYTE compser_notes[1]; // variable C string +// XBYTE index_number[1]; // variable C string +// XSWORD velocityCurve[128]; } X_PACKBY1 SongResource_RMF; // bits for SongResource_RMF_Linear flags @@ -383,52 +383,52 @@ typedef struct typedef struct { XShortResourceID audioResourceID; - char reserved_0; - char reverbType; - unsigned short songTempo; - char songType; // 0 - SMS, 1 - RMF, 2 - RMF LINEAR - - char locked; // are resource encrypted - short int maxEffects; - short int maxNotes; - short int mixLevel; - short int songVolume; // 100 is 100%, 200 is 200% etc. + XBYTE reserved_0; + XBYTE reverbType; + XWORD songTempo; + XBYTE songType; // 0 - SMS, 1 - RMF, 2 - RMF LINEAR + + XBYTE locked; // are resource encrypted + XSWORD maxEffects; + XSWORD maxNotes; + XSWORD mixLevel; + XSWORD songVolume; // 100 is 100%, 200 is 200% etc. XResourceType audioFormatType; XFIXED sampleRate; - unsigned long lengthInBytes; // length in bytes uncompressed - unsigned long lengthInFrames; // length in frames uncompressed - char channels; - char bitSize; - char flags; // see SongResource_RMF_Linear flags + XDWORD lengthInBytes; // length in bytes uncompressed + XDWORD lengthInFrames; // length in frames uncompressed + XBYTE channels; + XBYTE bitSize; + XBYTE flags; // see SongResource_RMF_Linear flags - char unused1; - long unused2[3]; + XBYTE unused1; + XDWORD unused2[3]; - short int resourceCount; - short int resourceData; // subtract this when calculating empty structure + XSWORD resourceCount; + XSWORD resourceData; // subtract this when calculating empty structure // // from this point on, the data is based upon types and data blocks -// char title[1]; // variable C string -// char composer[1]; // variable C string -// char copyright_date[1]; // variable C string -// char copyright_line[1]; // variable C string -// char contact_info[1]; // variable C string -// char use_license[1]; // variable C string -// char license_term[1]; // variable C string -// char territory[1]; // variable C string -// char expire_date[1]; // variable C string -// char foreign_rights[1]; // variable C string -// char compser_notes[1]; // variable C string -// char index_number[1]; // variable C string +// XBYTE title[1]; // variable C string +// XBYTE composer[1]; // variable C string +// XBYTE copyright_date[1]; // variable C string +// XBYTE copyright_line[1]; // variable C string +// XBYTE contact_info[1]; // variable C string +// XBYTE use_license[1]; // variable C string +// XBYTE license_term[1]; // variable C string +// XBYTE territory[1]; // variable C string +// XBYTE expire_date[1]; // variable C string +// XBYTE foreign_rights[1]; // variable C string +// XBYTE compser_notes[1]; // variable C string +// XBYTE index_number[1]; // variable C string } X_PACKBY1 SongResource_RMF_Linear; #define DEFAULT_RESOURCE_VERS_ID 0 // ID used inside of RMF file, or a bank // version structure typedef struct { - short int versionMajor; - short int versionMinor; - short int versionSubMinor; + XSWORD versionMajor; + XSWORD versionMinor; + XSWORD versionSubMinor; } X_PACKBY1 XVersion; typedef void SongResource; @@ -437,60 +437,60 @@ typedef void SongResource; // Use XGetSongResourceInfo, and XNewSongResourceInfo/XDisposeSongResourceInfo typedef struct { - short int maxMidiNotes; - short int maxEffects; - short int mixLevel; - short int reverbType; + XSWORD maxMidiNotes; + XSWORD maxEffects; + XSWORD mixLevel; + XSWORD reverbType; XShortResourceID objectResourceID; - short int songVolume; + XSWORD songVolume; SongType songType; - long songTempo; - short int songPitchShift; + XDWORD songTempo; + XSWORD songPitchShift; XBOOL songLocked; XBOOL songEmbedded; - char *title; // 0 - char *performed; // 1 - char *composer; // 2 - char *copyright; // 3 - char *publisher_contact_info; // 4 - char *use_license; // 5 - char *licensed_to_URL; // 6 - char *license_term; // 7 - char *expire_date; // 8 - char *compser_notes; // 9 - char *index_number; // 10 - char *genre; // 11 - char *sub_genre; // 12 - char *tempo_description; // 13 - char *original_source; // 14 - - char *manufacturer; // 15 - char *misc1; // 16 - char *misc2; // 17 - char *misc3; // 18 - char *misc4; // 19 - char *misc5; // 20 - char *misc6; // 21 - char *misc7; // 22 - char *misc8; - - short int remapCount; - short int *remaps; - - short int *velocityCurve; + XBYTE *title; // 0 + XBYTE *performed; // 1 + XBYTE *composer; // 2 + XBYTE *copyright; // 3 + XBYTE *publisher_contact_info; // 4 + XBYTE *use_license; // 5 + XBYTE *licensed_to_URL; // 6 + XBYTE *license_term; // 7 + XBYTE *expire_date; // 8 + XBYTE *compser_notes; // 9 + XBYTE *index_number; // 10 + XBYTE *genre; // 11 + XBYTE *sub_genre; // 12 + XBYTE *tempo_description; // 13 + XBYTE *original_source; // 14 + + XBYTE *manufacturer; // 15 + XBYTE *misc1; // 16 + XBYTE *misc2; // 17 + XBYTE *misc3; // 18 + XBYTE *misc4; // 19 + XBYTE *misc5; // 20 + XBYTE *misc6; // 21 + XBYTE *misc7; // 22 + XBYTE *misc8; + + XSWORD remapCount; + XSWORD *remaps; + + XSWORD *velocityCurve; } X_PACKBY1 SongResource_Info; typedef struct { - char lowMidi; - char highMidi; + XBYTE lowMidi; + XBYTE highMidi; XShortResourceID sndResourceID; - short int miscParameter1; // can be smodParmeter1 if ZBF_enableSoundModifier + XSWORD miscParameter1; // can be smodParmeter1 if ZBF_enableSoundModifier // enabled, otherwise its a replacement // rootKey for sample - short int miscParameter2; // if ZBF_enableSoundModifier is enabled then its + XSWORD miscParameter2; // if ZBF_enableSoundModifier is enabled then its // used as smodParmeter2, otherwise its a volume level } X_PACKBY1 KeySplit; @@ -517,23 +517,23 @@ typedef struct typedef struct { XShortResourceID sndResourceID; - short int midiRootKey; - char panPlacement; - unsigned char flags1; // see ZBF bits for values - unsigned char flags2; // see ZBF bits for values - char smodResourceID; // Really a smaller version of XShortResourceID - short int miscParameter1; // can be smodParmeter1 if ZBF_enableSoundModifier + XSWORD midiRootKey; + XBYTE panPlacement; + XBYTE flags1; // see ZBF bits for values + XBYTE flags2; // see ZBF bits for values + XBYTE smodResourceID; // Really a smaller version of XShortResourceID + XSWORD miscParameter1; // can be smodParmeter1 if ZBF_enableSoundModifier // enabled, otherwise its a replacement // rootKey for sample - short int miscParameter2; // if ZBF_enableSoundModifier is enabled then its + XSWORD miscParameter2; // if ZBF_enableSoundModifier is enabled then its // used as smodParmeter2, otherwise its a volume level - short int keySplitCount; // if this is non-zero, then KeySplit structure is inserted + XSWORD keySplitCount; // if this is non-zero, then KeySplit structure is inserted // to go beyond this point, if keySplitCount is non-zero, you must use function calls. - short int tremoloCount; // if this is non-zero, then a Word is inserted. - short int tremoloEnd; // Always 0x8000 - short int reserved_3; - short int descriptorName; // Always 0 - short int descriptorFlags; // Always 0 + XSWORD tremoloCount; // if this is non-zero, then a Word is inserted. + XSWORD tremoloEnd; // Always 0x8000 + XSWORD reserved_3; + XSWORD descriptorName; // Always 0 + XSWORD descriptorFlags; // Always 0 } X_PACKBY1 InstrumentResource; #define DEFAULT_RESOURCE_BANK_ID 0 // ID used inside of RMF file @@ -541,17 +541,17 @@ typedef struct // This is a ID_BANK resource typedef struct { - unsigned long version; - char bankURL[BANK_NAME_MAX_SIZE]; - char bankName[BANK_NAME_MAX_SIZE]; + XDWORD version; + XBYTE bankURL[BANK_NAME_MAX_SIZE]; + XBYTE bankName[BANK_NAME_MAX_SIZE]; } X_PACKBY1 BankStatus; #define DEFAULT_RESOURCE_PASSWORD_ID 0 // ID used inside of RMF file // This is a ID_PASSWORD resource typedef struct { - unsigned long version; -// char eacs[]; // variable length password accessed with XDecryptAndDuplicateStr + XDWORD version; +// XBYTE eacs[]; // variable length password accessed with XDecryptAndDuplicateStr } X_PACKBY1 PasswordAccess; #define DEFAULT_RESOURCE_ALIAS_ID 0 // ID used inside of a patch file @@ -566,8 +566,8 @@ typedef struct // This is a ID_ALIAS resource typedef struct { - unsigned long version; - unsigned long numberOfAliases; + XDWORD version; + XDWORD numberOfAliases; XAliasLink list[1]; // dynamic list } X_PACKBY1 XAliasLinkResource; @@ -589,27 +589,27 @@ enum #define AUDIO_OBJECT_VERSION 0x0001 typedef struct { - unsigned long version; // structure version 1 - unsigned long dataLength; // length of sample data in bytes - unsigned long dataOffset; // offset from begining of structure to data - unsigned long audioType; // audio type of audioType - unsigned long usageType; - unsigned long sampleRate; // sample rate in 16.16 fixed point - unsigned long sampleFrames; // number of sample frames - unsigned long loopStart; // first loop start - unsigned long loopEnd; // first loop end - short int baseMidiKey; // base root midi key - short int bitSize; // 8 or 16 bits per sample - short int channels; // 1 or 2 channels + XDWORD version; // structure version 1 + XDWORD dataLength; // length of sample data in bytes + XDWORD dataOffset; // offset from begining of structure to data + XDWORD audioType; // audio type of audioType + XDWORD usageType; + XDWORD sampleRate; // sample rate in 16.16 fixed point + XDWORD sampleFrames; // number of sample frames + XDWORD loopStart; // first loop start + XDWORD loopEnd; // first loop end + XSWORD baseMidiKey; // base root midi key + XSWORD bitSize; // 8 or 16 bits per sample + XSWORD channels; // 1 or 2 channels XResourceType nameResourceType; // Resource name type. ie (AUDIO_NAME_TYPE) // if ID_NULL, then no name XLongResourceID nameResourceID; // Resource name id. ie AUDIO_NAME_TYPE ID 2000 - char usedInBank; // if true, then sample is embedded in a bank - char unusedFlag2; - char unusedFlag3; - char unusedFlag4; - unsigned long filler[16]; - unsigned long firstSampleFiller; + XBYTE usedInBank; // if true, then sample is embedded in a bank + XBYTE unusedFlag2; + XBYTE unusedFlag3; + XBYTE unusedFlag4; + XDWORD filler[16]; + XDWORD firstSampleFiller; // data } X_PACKBY1 AudioResource; @@ -692,81 +692,82 @@ typedef struct typedef struct { - char *samplePtr; /*if NIL then samples are in sampleArea*/ - unsigned long length; /*length of sound in bytes*/ - unsigned long sampleRate; /*sample rate for this sound*/ - unsigned long loopStart; /*start of looping portion*/ - unsigned long loopEnd; /*end of looping portion*/ - unsigned char encode; /*header encoding*/ - unsigned char baseFrequency; /*baseFrequency value*/ - unsigned char sampleArea[1]; /*space for when samples follow directly*/ + XDWORD samplePtrOffset; /*if NIL then samples are in sampleArea*/ + XDWORD length; /*length of sound in bytes*/ + XDWORD sampleRate; /*sample rate for this sound*/ + XDWORD loopStart; /*start of looping portion*/ + XDWORD loopEnd; /*end of looping portion*/ + XBYTE encode; /*header encoding*/ + XBYTE baseFrequency; /*baseFrequency value*/ + XBYTE sampleArea[1]; /*space for when samples follow directly*/ } X_PACKBY1 XSoundHeader; typedef XSoundHeader *XSoundHeaderPtr; typedef struct { - char *samplePtr; /*if nil then samples are in sample area*/ - unsigned long numChannels; /*number of channels i.e. mono = 1*/ - unsigned long sampleRate; /*sample rate in Apples Fixed point representation*/ - unsigned long loopStart; /*loopStart of sound before compression*/ - unsigned long loopEnd; /*loopEnd of sound before compression*/ - unsigned char encode; /*data structure used , stdSH, extSH, or cmpSH*/ - unsigned char baseFrequency; /*same meaning as regular SoundHeader*/ - unsigned long numFrames; /*length in frames ( packetFrames or sampleFrames )*/ - char AIFFSampleRate[10]; /*IEEE sample rate*/ - char *markerChunk; /*sync track*/ - long format; /*data format type, was futureUse1*/ - char forceSample8bit; /*reserved by Apple, Igor will use as IMA encoder to 8 or 16 bit output. Set to 0x80 */ + XDWORD samplePtrOffset; /*if NIL then samples are in sampleArea*/ + XDWORD numChannels; /*number of channels i.e. mono = 1*/ + XDWORD sampleRate; /*sample rate in Apples Fixed point representation*/ + XDWORD loopStart; /*loopStart of sound before compression*/ + XDWORD loopEnd; /*loopEnd of sound before compression*/ + XBYTE encode; /*data structure used , stdSH, extSH, or cmpSH*/ + XBYTE baseFrequency; /*same meaning as regular SoundHeader*/ + XDWORD numFrames; /*length in frames ( packetFrames or sampleFrames )*/ + XBYTE AIFFSampleRate[10]; /*IEEE sample rate*/ + XBYTE markerChunk[4]; /*sync track*/ + XDWORD format; /*data format type, was futureUse1*/ + XBYTE forceSample8bit; /*reserved by Apple, Igor will use as IMA encoder to 8 or 16 bit output. Set to 0x80 */ // to encode as 8 bit output - char soundIsEmbedded; /*reserved by Apple. Igor uses it as a flag */ - char futureUse2_2; /*reserved by Apple*/ - char futureUse2_3; /*reserved by Apple*/ - void *stateVars; /*pointer to State Block*/ - void *leftOverSamples; /*used to save truncated samples between compression calls*/ - short compressionID; /*0 means no compression, non zero means compressionID*/ - unsigned short packetSize; /*number of bits in compressed sample packet*/ - unsigned short snthID; /*resource ID of Sound Manager snth that contains NRT C/E*/ - unsigned short sampleSize; /*number of bits in non-compressed sample*/ + XBYTE soundIsEmbedded; /*reserved by Apple. Igor uses it as a flag */ + XBYTE futureUse2_2; /*reserved by Apple*/ + XBYTE futureUse2_3; /*reserved by Apple*/ + XBYTE stateVars[4]; /*pointer to State Block*/ + XBYTE leftOverSamples[4]; /*used to save truncated samples between compression calls*/ + XSWORD compressionID; /*0 means no compression, non zero means compressionID*/ + XWORD packetSize; /*number of bits in compressed sample packet*/ + XWORD snthID; /*resource ID of Sound Manager snth that contains NRT C/E*/ + XWORD sampleSize; /*number of bits in non-compressed sample*/ //MOE: For ALAW, ULAW, and IMA, the number of bytes is stored! - unsigned char sampleArea[1]; /*space for when samples follow directly*/ + XBYTE sampleArea[1]; /*space for when samples follow directly*/ } X_PACKBY1 XCmpSoundHeader; typedef XCmpSoundHeader * XCmpSoundHeaderPtr; typedef struct { - char *samplePtr; /*if nil then samples are in sample area*/ - unsigned long numChannels; /*number of channels, ie mono = 1*/ - unsigned long sampleRate; /*sample rate in Apples Fixed point representation*/ - unsigned long loopStart; /*same meaning as regular SoundHeader*/ - unsigned long loopEnd; /*same meaning as regular SoundHeader*/ - unsigned char encode; /*data structure used , stdSH, extSH, or cmpSH*/ - unsigned char baseFrequency; /*same meaning as regular SoundHeader*/ - unsigned long numFrames; /*length in total number of frames*/ - char AIFFSampleRate[10]; /*IEEE sample rate*/ - char *markerChunk; /*sync track*/ - char *instrumentChunks; /*AIFF instrument chunks*/ - char *AESRecording; - unsigned short sampleSize; /*number of bits in sample*/ - char soundIsEmbedded; // reserved by Apple. Igor uses it as a flag - char sampleIsIntelOrder; // reserved by Apple. Igor uses it to determine if samples are Intel ordered - unsigned long futureUse2; /*reserved by Apple*/ - unsigned long futureUse3; /*reserved by Apple*/ - unsigned long futureUse4; /*reserved by Apple*/ - unsigned char sampleArea[1]; /*space for when samples follow directly*/ + XDWORD samplePtrOffset; /*if NIL then samples are in sampleArea*/ + XDWORD numChannels; /*number of channels, ie mono = 1*/ + XDWORD sampleRate; /*sample rate in Apples Fixed point representation*/ + XDWORD loopStart; /*same meaning as regular SoundHeader*/ + XDWORD loopEnd; /*same meaning as regular SoundHeader*/ + XBYTE encode; /*data structure used , stdSH, extSH, or cmpSH*/ + XBYTE baseFrequency; /*same meaning as regular SoundHeader*/ + XDWORD numFrames; /*length in total number of frames*/ + XBYTE AIFFSampleRate[10]; /*IEEE sample rate*/ + //TODO: pointer issues, structure is incorrect for 64 bit + XBYTE *markerChunk; /*sync track*/ + XBYTE *instrumentChunks; /*AIFF instrument chunks*/ + XBYTE *AESRecording; + XWORD sampleSize; /*number of bits in sample*/ + XBYTE soundIsEmbedded; // reserved by Apple. Igor uses it as a flag + XBYTE sampleIsIntelOrder; // reserved by Apple. Igor uses it to determine if samples are Intel ordered + XDWORD futureUse2; /*reserved by Apple*/ + XDWORD futureUse3; /*reserved by Apple*/ + XDWORD futureUse4; /*reserved by Apple*/ + XBYTE sampleArea[1]; /*space for when samples follow directly*/ } X_PACKBY1 XExtSoundHeader; typedef XExtSoundHeader *XExtSoundHeaderPtr; typedef struct { - short int type; - short int numModifiers; - unsigned short modNumber; - long modInit; - short int numCommands; + XSWORD type; + XSWORD numModifiers; + XWORD modNumber; + XDWORD modInit; + XSWORD numCommands; // first command - unsigned short cmd; - short int param1; - long param2; + XWORD cmd; + XSWORD param1; + XDWORD param2; } X_PACKBY1 XSoundFormat1; typedef struct @@ -789,13 +790,13 @@ typedef struct typedef struct { - short int type; - short int refCount; - short int numCmds; + XSWORD type; + XSWORD refCount; + XSWORD numCmds; // first command - unsigned short cmd; - short int param1; - long param2; + XWORD cmd; + XSWORD param1; + XDWORD param2; } X_PACKBY1 XSoundFormat2; typedef struct @@ -812,7 +813,7 @@ typedef struct typedef struct { - short int type; + XSWORD type; XSoundHeader3 sndBuffer; } X_PACKBY1 XSndHeader3; @@ -890,13 +891,13 @@ enum typedef struct { XFIXED rate; // sample rate - unsigned long frames; // number of audio frames - unsigned long size; // size in bytes, compressed size if compressed - unsigned long loopStart; // loop start frame - unsigned long loopEnd; // loop end frame - short int bitSize; // sample bit size; 8 or 16 - short int channels; // mono or stereo; 1 or 2 - short int baseKey; // base sample key + XDWORD frames; // number of audio frames + XDWORD size; // size in bytes, compressed size if compressed + XDWORD loopStart; // loop start frame + XDWORD loopEnd; // loop end frame + XSWORD bitSize; // sample bit size; 8 or 16 + XSWORD channels; // mono or stereo; 1 or 2 + XSWORD baseKey; // base sample key XShortResourceID theID; // sample ID if required XResourceType compressionType; // compression type void *pMasterPtr; // master pointer if required @@ -933,30 +934,30 @@ typedef enum I_MISC8 } SongInfo; -void XGetSongInformation(SongResource *theSong, long songSize, SongInfo type, - char* targetBuffer, unsigned long bufferBytes); +void XGetSongInformation(SongResource *theSong, XDWORD songSize, SongInfo type, + XBYTE* targetBuffer, XDWORD bufferBytes); -unsigned long XGetSongInformationSize(SongResource *theSong, long songSize, SongInfo type); +XDWORD XGetSongInformationSize(SongResource *theSong, XDWORD songSize, SongInfo type); // Create a new song resource. SongResource * XNewSongPtr( SongType songType, XShortResourceID midiID, - short int maxSongVoices, - short int mixLevel, - short int maxEffectVoices, + XSWORD maxSongVoices, + XSWORD mixLevel, + XSWORD maxEffectVoices, ReverbMode reverbType); void XDisposeSongPtr(SongResource *theSong); -void XGetKeySplitFromPtr(InstrumentResource *theX, short int entry, KeySplit *keysplit); +void XGetKeySplitFromPtr(InstrumentResource *theX, XSWORD entry, KeySplit *keysplit); -XPTR XGetSoundResourceByID(XLongResourceID theID, long *pReturnedSize); -XPTR XGetSoundResourceByName(void *cName, long *pReturnedSize); +XPTR XGetSoundResourceByID(XLongResourceID theID, XDWORD *pReturnedSize); +XPTR XGetSoundResourceByName(void *cName, XDWORD *pReturnedSize); // Get sound resource and detach from resource manager but don't decompress. -XPTR XGetRawSoundResourceByID(XLongResourceID theID, XResourceType *pReturnedType, long *pReturnedSize); +XPTR XGetRawSoundResourceByID(XLongResourceID theID, XResourceType *pReturnedType, XDWORD *pReturnedSize); -XPTR XGetMidiData(XLongResourceID theID, long *pReturnedSize, XResourceType *pType); +XPTR XGetMidiData(XLongResourceID theID, XDWORD *pReturnedSize, XResourceType *pType); // Given a ID_SND resource, parse through and return in *pInfo the information // about the sample resource. The pMasterPtr will be set to the resource passed in (pRes). @@ -976,10 +977,10 @@ XPTR XGetSamplePtrFromSnd(XPTR pRes, SampleDataInfo *pInfo); // -3 not supported format type XERR XGetSampleInfoFromSnd(XPTR pResource, SampleDataInfo *pOutInfo); -void XSetSoundLoopPoints(XPTR pRes, long loopStart, long loopEnd); +void XSetSoundLoopPoints(XPTR pRes, XDWORD loopStart, XDWORD loopEnd); void XSetSoundSampleRate(XPTR pRes, XFIXED sampleRate); -void XSetSoundBaseKey(XPTR pRes, short int baseKey); -short int XGetSoundBaseKey(XPTR pRes); +void XSetSoundBaseKey(XPTR pRes, XSWORD baseKey); +XSWORD XGetSoundBaseKey(XPTR pRes); XBOOL XGetSoundEmbeddedStatus(XPTR pRes); void XSetSoundEmbeddedStatus(XPTR pRes, XBOOL soundEmbedded); @@ -1002,7 +1003,7 @@ OPErr XCreateSoundObjectFromData(XPTR* dst, XBOOL XGetSampleNameFromID(XLongResourceID sampleSoundID, char *cName); -SongResource_Info * XGetSongResourceInfo(SongResource *pSong, long songSize); +SongResource_Info * XGetSongResourceInfo(SongResource *pSong, XDWORD songSize); // return a new blank SongResource_Info structure SongResource_Info * XNewSongResourceInfo(void); @@ -1023,22 +1024,22 @@ void XSetSongLocked(SongResource *pSong, XBOOL locked); // will determine if song is using compression. Requires active resource file XBOOL XIsSongCompressed(SongResource *pSong); -void XGetSongPerformanceSettings(SongResource * theSong, short int *maxMidiVoices, - short int *maxEffectsVoices, short int *mixLevel); -void XSetSongPerformanceSettings(SongResource *pSong, short int maxMidiVoices, short int maxEffectsVoices, - short int mixLevel); +void XGetSongPerformanceSettings(SongResource * theSong, XSWORD *maxMidiVoices, + XSWORD *maxEffectsVoices, XSWORD *mixLevel); +void XSetSongPerformanceSettings(SongResource *pSong, XSWORD maxMidiVoices, XSWORD maxEffectsVoices, + XSWORD mixLevel); -short int XGetSongReverbType(SongResource *pSong); -void XSetSongReverbType(SongResource *pSong, short int reverbType); +XSWORD XGetSongReverbType(SongResource *pSong); +void XSetSongReverbType(SongResource *pSong, XSWORD reverbType); -short int XGetSongVolume(SongResource *pSong); -void XSetSongVolume(SongResource *pSong, short int volume); +XSWORD XGetSongVolume(SongResource *pSong); +void XSetSongVolume(SongResource *pSong, XSWORD volume); SongType XGetSongResourceObjectType(SongResource *pSong); -SongResource * XChangeSongResource(SongResource *theSong, long songSize, - SongResourceType resourceType, void *pResource, long resourceLength); +SongResource * XChangeSongResource(SongResource *theSong, XDWORD songSize, + SongResourceType resourceType, void *pResource, XDWORD resourceLength); XBOOL XGetSongEmbeddedStatus(SongResource *pSong); void XSetSongEmbeddedStatus(SongResource *pSong, XBOOL embedded); @@ -1062,22 +1063,22 @@ XPTR XCreateBankStatus(BankStatus *pStatus); // Get bank resource from currently open resource file void XGetBankStatus(BankStatus *pStatus); // Create version resource that is ready to be stored -XPTR XCreateVersion(short int major, short int minor, short int subMinor); +XPTR XCreateVersion(XSWORD major, XSWORD minor, XSWORD subMinor); // Will return a XVersion number in platform order from the currently open resource file void XGetVersionNumber(XVersion *pVersionNumber); // convert to and from ieee to XFIXED. Used for AIF files, and SND resources -XFIXED XConvertFromIeeeExtended(unsigned char *bytes); -void XConvertToIeeeExtended(XFIXED ieeeFixedRate, unsigned char *bytes); +XFIXED XConvertFromIeeeExtended(XBYTE *bytes); +void XConvertToIeeeExtended(XFIXED ieeeFixedRate, XBYTE *bytes); // a law / u law compression -void XCompressLaw(SndCompressionType compressionType, short int *pSource, char *pDest, - unsigned long frames, unsigned long channels); +void XCompressLaw(SndCompressionType compressionType, XSWORD *pSource, XBYTE *pDest, + XDWORD frames, XDWORD channels); // Simple utility to convert promote 8-bit samples to 16 bit -XWORD * XConvert8BitTo16Bit(XBYTE * p8BitPCMData, unsigned long frames, unsigned long channels); +XWORD * XConvert8BitTo16Bit(XBYTE * p8BitPCMData, XDWORD frames, XDWORD channels); // given 16 bit data, convert this to 8 bit data -XBYTE * XConvert16BitTo8Bit(XWORD * p16BitPCMData, unsigned long frames, unsigned long channels); +XBYTE * XConvert16BitTo8Bit(XWORD * p16BitPCMData, XDWORD frames, XDWORD channels); // MPEG decoder @@ -1088,20 +1089,20 @@ struct XMPEGDecodedData XFIXED sampleRate; XBYTE bitSize; XBYTE channels; - unsigned long bitrate; - unsigned long lengthInBytes; // right now, it's simply frameBufferSize*maxFrameBuffers + XDWORD bitrate; + XDWORD lengthInBytes; // right now, it's simply frameBufferSize*maxFrameBuffers // with new MPEG code, it should be the minimum decoded size - unsigned long lengthInSamples; - unsigned long frameBufferSize; - unsigned long maxFrameBuffers; + XDWORD lengthInSamples; + XDWORD frameBufferSize; + XDWORD maxFrameBuffers; }; typedef struct XMPEGDecodedData XMPEGDecodedData; XMPEGDecodedData * XOpenMPEGStreamFromXFILE(XFILE file, OPErr *pErr); -XMPEGDecodedData * XOpenMPEGStreamFromMemory(XPTR pBlock, unsigned long blockSize, OPErr *pErr); +XMPEGDecodedData * XOpenMPEGStreamFromMemory(XPTR pBlock, XDWORD blockSize, OPErr *pErr); OPErr XCloseMPEGStream(XMPEGDecodedData *stream); OPErr XFillMPEGStreamBuffer(XMPEGDecodedData *stream, void *pcmAudioBuffer, XBOOL *pDone); -SndCompressionType XGetMPEGBitrateType(unsigned long bitrate); +SndCompressionType XGetMPEGBitrateType(XDWORD bitrate); #endif // USE_MPEG_DECODER @@ -1132,11 +1133,11 @@ typedef enum struct XMPEGEncodeData { - unsigned long currentFrameBuffer; // OUT current frame buffer processing - unsigned long maxFrameBuffers; // OUT max number of MPEG frames - unsigned long frameBufferSizeInBytes; // OUT byte size of each frame buffer - char *pFrameBuffer; // OUT bytes of completed buffer - unsigned long frameBufferSize; // OUT size in bytes of completed MPEG buffer + XDWORD currentFrameBuffer; // OUT current frame buffer processing + XDWORD maxFrameBuffers; // OUT max number of MPEG frames + XDWORD frameBufferSizeInBytes; // OUT byte size of each frame buffer + XBYTE *pFrameBuffer; // OUT bytes of completed buffer + XDWORD frameBufferSize; // OUT size in bytes of completed MPEG buffer //private: void *pPrivateData; @@ -1154,11 +1155,11 @@ typedef struct XMPEGEncodeData XMPEGEncodeData; // When done, then call XCloseMPEGEncodeStream to cleanup and free memory. XMPEGEncodeData *XOpenMPEGEncodeStreamFromMemory(GM_Waveform *pAudio, XMPEGEncodeRate encodeRate, OPErr *pErr); OPErr XProcessMPEGEncoder(XMPEGEncodeData *stream); // call this XMPEGEncodeData->maxFrameBuffers times -OPErr XCloseMPEGEncodeStream(XMPEGEncodeData *stream, XPTR *pReturnedBuffer, unsigned long *pReturnedSize); +OPErr XCloseMPEGEncodeStream(XMPEGEncodeData *stream, XPTR *pReturnedBuffer, XDWORD *pReturnedSize); // Given an mpeg bit encode rate, and a sample rate, this will return TRUE if // this encoder can encode, or FALSE if it will not work. -XBOOL XIsValidMPEGSampleRateAndEncodeRate(XMPEGEncodeRate encodeRate, XFIXED sampleRate, SndCompressionSubType subType, short int numChannel); +XBOOL XIsValidMPEGSampleRateAndEncodeRate(XMPEGEncodeRate encodeRate, XFIXED sampleRate, SndCompressionSubType subType, XSWORD numChannel); // This will encode an MPEG stream from a formatted GM_Waveform OPErr XCompressMPEG(GM_Waveform const* pWave, diff --git a/minibae/BAE_Source/Platform/BAEBuildOptions_Android.h b/minibae/BAE_Source/Platform/BAEBuildOptions_Android.h old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAEBuildOptions_IOS.h b/minibae/BAE_Source/Platform/BAEBuildOptions_IOS.h old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAEBuildOptions_MacOSX.h b/minibae/BAE_Source/Platform/BAEBuildOptions_MacOSX.h old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAEBuildOptions_WinOS.h b/minibae/BAE_Source/Platform/BAEBuildOptions_WinOS.h old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API.h b/minibae/BAE_Source/Platform/BAE_API.h old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API_Android.c b/minibae/BAE_Source/Platform/BAE_API_Android.c old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API_IOS.c b/minibae/BAE_Source/Platform/BAE_API_IOS.c old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API_MacOSX.c b/minibae/BAE_Source/Platform/BAE_API_MacOSX.c old mode 100755 new mode 100644 index afba6a94..eb11254c --- a/minibae/BAE_Source/Platform/BAE_API_MacOSX.c +++ b/minibae/BAE_Source/Platform/BAE_API_MacOSX.c @@ -201,6 +201,7 @@ void BAE_Deallocate(void *memoryBlock) // return memory used unsigned long BAE_GetSizeOfMemoryUsed(void) { + printf("No memory buoy, can't determine memory size used\n"); // return g_memory_buoy; return(0); } @@ -208,6 +209,7 @@ unsigned long BAE_GetSizeOfMemoryUsed(void) // return max memory used unsigned long BAE_GetMaxSizeOfMemoryUsed(void) { + printf("No memory buoy, can't determine memory size used\n"); // return g_memory_buoy_max; return(0); } @@ -459,11 +461,12 @@ long BAE_FileDelete(void *fileName) // Return -1 if error, otherwise file handle long BAE_FileOpenForRead(void *fileName) { + long file = -1; if (fileName) { - return(open((char *)fileName, O_RDONLY)); + file = open((char *)fileName, O_RDONLY); } - return(-1); + return file; } long BAE_FileOpenForWrite(void *fileName) diff --git a/minibae/BAE_Source/Platform/BAE_API_WinOS.c b/minibae/BAE_Source/Platform/BAE_API_WinOS.c old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API_WinOS_Capture.c b/minibae/BAE_Source/Platform/BAE_API_WinOS_Capture.c old mode 100755 new mode 100644 diff --git a/minibae/BAE_Source/Platform/BAE_API_WinOS_Thread.c b/minibae/BAE_Source/Platform/BAE_API_WinOS_Thread.c old mode 100755 new mode 100644 diff --git a/minibae/Tools/playbae/Makefile b/minibae/Tools/playbae/Makefile index cbf15c70..57ea285e 100644 --- a/minibae/Tools/playbae/Makefile +++ b/minibae/Tools/playbae/Makefile @@ -67,13 +67,11 @@ SRC += playbae.c OBJ_DIR := obj/ OBJ := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(basename ${SRC}))) -#ARCH := -arch x86_64 -ARCH := -arch i386 CC := gcc CXX := g++ LD := g++ -CFLAGS := $(ARCH) -g -O3 $(INC_PATH) -D_THREAD_SAFE +CFLAGS := -g -O3 $(INC_PATH) -D_THREAD_SAFE CFLAGS += -DX_PLATFORM=X_MACINTOSH #CFLAGS += -DUSE_MPEG_DECODER=1 CFLAGS += -D_DEBUG=1 @@ -82,8 +80,9 @@ CXXFLAGS := $(CFLAGS) LDFLAGS := $(ARCH) -all_load -prebind -LIBS = -L/opt/local/lib \ +LIBS = -lc \ -lpthread \ + -Wl,-framework,Foundation \ -Wl,-framework,CoreFoundation \ -Wl,-framework,CoreAudio \ -Wl,-framework,AudioToolbox @@ -112,6 +111,8 @@ lib_install: CONTENT := ../../Content BANKS := ../../banks +TEST_BANK := $(BANKS)/patches/patches.hsb + # requires mp3 codec #TEST_RMF := LT_RMF_MPEG.rmf #TEST_RMF := little_boss.rmf @@ -127,19 +128,19 @@ BANKS := ../../banks TEST_RMF := chop-squad-full.rmf test1: $(TARGET) - ./$(TARGET) -p $(BANKS)/patches/patches.hsb -m $(CONTENT)/rmf/kartv.mid -mr 44100 + ./$(TARGET) -p $(TEST_BANK) -m $(CONTENT)/rmf/kartv.mid -mr 44100 test2: $(TARGET) - ./$(TARGET) -p $(BANKS)/patches/patches.hsb -m $(CONTENT)/midi/synco.mid -mr 44100 + ./$(TARGET) -p $(TEST_BANK) -m $(CONTENT)/midi/synco.mid -mr 44100 test3: $(TARGET) - ./$(TARGET) -p $(BANKS)/patches/patches.hsb -r $(CONTENT)/rmf/$(TEST_RMF) -mr 44100 + ./$(TARGET) -p $(TEST_BANK) -r $(CONTENT)/rmf/$(TEST_RMF) -mr 44100 test4: $(TARGET) - ./$(TARGET) -p $(BANKS)/patches/patches.hsb -w $(CONTENT)/wav/sexy_coffee_pot.wav -mr 44100 + ./$(TARGET) -p $(TEST_BANK) -w $(CONTENT)/wav/sexy_coffee_pot.wav -mr 44100 test5: $(TARGET) - ./$(TARGET) -p $(BANKS)/patches/patches.hsb -sw $(CONTENT)/wav/sexy_coffee_pot.wav -mr 44100 + ./$(TARGET) -p $(TEST_BANK) -sw $(CONTENT)/wav/sexy_coffee_pot.wav -mr 44100 clean: @rm -f $(TARGET) diff --git a/minibae/Tools/playbae/playbae.c b/minibae/Tools/playbae/playbae.c old mode 100755 new mode 100644 index 9931cb6c..11403acf --- a/minibae/Tools/playbae/playbae.c +++ b/minibae/Tools/playbae/playbae.c @@ -76,11 +76,12 @@ static void PV_Idle(BAEMixer theMixer, unsigned long time) } else { - max = time / 12000; - for (count = 0; count < max; count++) - { - BAE_WaitMicroseconds(12000); - } + max = time / 12000; + for (count = 0; count < max; count++) + { + BAE_WaitMicroseconds(12000); +// BAEMixer_DisplayVoiceData(theMixer); + } } } diff --git a/minibae/Tools/playbae/playbae.xcodeproj/project.pbxproj b/minibae/Tools/playbae/playbae.xcodeproj/project.pbxproj index 6ec685a4..00a1bd51 100644 --- a/minibae/Tools/playbae/playbae.xcodeproj/project.pbxproj +++ b/minibae/Tools/playbae/playbae.xcodeproj/project.pbxproj @@ -40,9 +40,12 @@ AA0A975311BC44B500D01187 /* X_Decompress.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0A972C11BC44B500D01187 /* X_Decompress.c */; }; AA0A975411BC44B500D01187 /* X_IMA.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0A972E11BC44B500D01187 /* X_IMA.c */; }; AA0A975511BC44B500D01187 /* BAE_API_MacOSX.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0A973311BC44B500D01187 /* BAE_API_MacOSX.c */; }; - AA83957511A9F4BF00609D90 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA83957411A9F4BF00609D90 /* CoreFoundation.framework */; }; - AA83957A11A9F4D300609D90 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA83957911A9F4D300609D90 /* CoreAudio.framework */; }; - AA83958211A9F52100609D90 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA83958111A9F52100609D90 /* AudioToolbox.framework */; }; + AA6E503C271B3B1E004B7A99 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E503B271B3B1E004B7A99 /* Foundation.framework */; }; + AA6E503E271B3B3B004B7A99 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E503D271B3B3B004B7A99 /* CoreFoundation.framework */; }; + AA6E5040271B3B45004B7A99 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E503F271B3B45004B7A99 /* CoreAudio.framework */; }; + AA6E5042271B3B4E004B7A99 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E5041271B3B4E004B7A99 /* AudioToolbox.framework */; }; + AA6E5044271B3B6A004B7A99 /* libpthread.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E5043271B3B6A004B7A99 /* libpthread.tbd */; }; + AA6E5046271B3B70004B7A99 /* libc.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = AA6E5045271B3B70004B7A99 /* libc.tbd */; }; AADB00FE11853718002DC493 /* playbae.c in Sources */ = {isa = PBXBuildFile; fileRef = AADB00FD11853718002DC493 /* playbae.c */; }; /* End PBXBuildFile section */ @@ -106,9 +109,12 @@ AA0A973211BC44B500D01187 /* BAE_API.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAE_API.h; sourceTree = ""; }; AA0A973311BC44B500D01187 /* BAE_API_MacOSX.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BAE_API_MacOSX.c; sourceTree = ""; }; AA0A973411BC44B500D01187 /* BAEBuildOptions_MacOSX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAEBuildOptions_MacOSX.h; sourceTree = ""; }; - AA83957411A9F4BF00609D90 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; - AA83957911A9F4D300609D90 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; - AA83958111A9F52100609D90 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + AA6E503B271B3B1E004B7A99 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + AA6E503D271B3B3B004B7A99 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = DEVELOPER_DIR; }; + AA6E503F271B3B45004B7A99 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/CoreAudio.framework; sourceTree = DEVELOPER_DIR; }; + AA6E5041271B3B4E004B7A99 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = DEVELOPER_DIR; }; + AA6E5043271B3B6A004B7A99 /* libpthread.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libpthread.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib/libpthread.tbd; sourceTree = DEVELOPER_DIR; }; + AA6E5045271B3B70004B7A99 /* libc.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libc.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib/libc.tbd; sourceTree = DEVELOPER_DIR; }; AADB00FD11853718002DC493 /* playbae.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = playbae.c; sourceTree = ""; }; /* End PBXFileReference section */ @@ -117,9 +123,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - AA83957511A9F4BF00609D90 /* CoreFoundation.framework in Frameworks */, - AA83957A11A9F4D300609D90 /* CoreAudio.framework in Frameworks */, - AA83958211A9F52100609D90 /* AudioToolbox.framework in Frameworks */, + AA6E5046271B3B70004B7A99 /* libc.tbd in Frameworks */, + AA6E5044271B3B6A004B7A99 /* libpthread.tbd in Frameworks */, + AA6E5042271B3B4E004B7A99 /* AudioToolbox.framework in Frameworks */, + AA6E5040271B3B45004B7A99 /* CoreAudio.framework in Frameworks */, + AA6E503E271B3B3B004B7A99 /* CoreFoundation.framework in Frameworks */, + AA6E503C271B3B1E004B7A99 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -131,9 +140,7 @@ children = ( 08FB7795FE84155DC02AAC07 /* Source */, 1AB674ADFE9D54B511CA2CBB /* Products */, - AA83957411A9F4BF00609D90 /* CoreFoundation.framework */, - AA83957911A9F4D300609D90 /* CoreAudio.framework */, - AA83958111A9F52100609D90 /* AudioToolbox.framework */, + AA6E503A271B3B1D004B7A99 /* Frameworks */, ); name = playbae; sourceTree = ""; @@ -225,6 +232,19 @@ path = Platform; sourceTree = ""; }; + AA6E503A271B3B1D004B7A99 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AA6E5045271B3B70004B7A99 /* libc.tbd */, + AA6E5043271B3B6A004B7A99 /* libpthread.tbd */, + AA6E5041271B3B4E004B7A99 /* AudioToolbox.framework */, + AA6E503F271B3B45004B7A99 /* CoreAudio.framework */, + AA6E503D271B3B3B004B7A99 /* CoreFoundation.framework */, + AA6E503B271B3B1E004B7A99 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -251,6 +271,9 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 1300; + }; buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "playbae" */; compatibilityVersion = "Xcode 3.1"; developmentRegion = English; @@ -319,11 +342,11 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; + CLANG_ENABLE_OBJC_WEAK = YES; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -331,9 +354,9 @@ "X_PLATFORM=X_MACINTOSH", ); INSTALL_PATH = /usr/local/bin; + MACOSX_DEPLOYMENT_TARGET = 10.15; PRODUCT_NAME = playbae; SDKROOT = macosx; - VALID_ARCHS = i386; }; name = Debug; }; @@ -341,45 +364,98 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + ARCHS = "$(ARCHS_STANDARD)"; + CLANG_ENABLE_OBJC_WEAK = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_MODEL_TUNING = G5; GCC_PREPROCESSOR_DEFINITIONS = ( "_DEBUG=1", "X_PLATFORM=X_MACINTOSH", ); INSTALL_PATH = /usr/local/bin; + MACOSX_DEPLOYMENT_TARGET = 10.15; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = playbae; SDKROOT = macosx; - VALID_ARCHS = i386; }; name = Release; }; 1DEB928A08733DD80010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; + ARCHS = "$(ARCHS_STANDARD)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_EXPORT_SUPPORTED = NO; + LOCALIZED_STRING_SWIFTUI_SUPPORT = NO; ONLY_ACTIVE_ARCH = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + SDKROOT = macosx; }; name = Debug; }; 1DEB928B08733DD80010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - GCC_C_LANGUAGE_STANDARD = gnu99; + ARCHS = "$(ARCHS_STANDARD)"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - PREBINDING = NO; - SDKROOT = macosx10.6; + LOCALIZATION_EXPORT_SUPPORTED = NO; + LOCALIZED_STRING_SWIFTUI_SUPPORT = NO; + SDKROOT = macosx; }; name = Release; }; diff --git a/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/minibae/Tools/playbae/playbae.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/minibae/Tools/playbae/playbae.xcodeproj/xcshareddata/xcschemes/playbae.xcscheme b/minibae/Tools/playbae/playbae.xcodeproj/xcshareddata/xcschemes/playbae.xcscheme new file mode 100644 index 00000000..17bd2807 --- /dev/null +++ b/minibae/Tools/playbae/playbae.xcodeproj/xcshareddata/xcschemes/playbae.xcscheme @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/minibae/Tools/playbae/win_playbae.dsp b/minibae/Tools/playbae/win_playbae.dsp old mode 100755 new mode 100644 diff --git a/minibae/Tools/playbae/win_playbae.dsw b/minibae/Tools/playbae/win_playbae.dsw old mode 100755 new mode 100644