typedef struct _vgm_file_header_base\r
{\r
sdword fccVGM; // 00\r
- UINT32 lngEOFOffset; // 04\r
- UINT32 lngVersion; // 08\r
- UINT32 lngSkip1[2]; // 0C\r
- UINT32 lngGD3Offset; // 14\r
- UINT32 lngTotalSamples; // 18\r
- UINT32 lngLoopOffset; // 1C\r
- UINT32 lngLoopSamples; // 20\r
- UINT32 lngRate; // 24\r
- UINT32 lngSkip2[3]; // 28\r
- UINT32 lngDataOffset; // 34\r
- UINT32 lngSkip3[2]; // 38\r
+ sdword lngEOFOffset; // 04\r
+ sdword lngVersion; // 08\r
+ sdword lngSkip1[2]; // 0C\r
+ sdword lngGD3Offset; // 14\r
+ sdword lngTotalSamples; // 18\r
+ sdword lngLoopOffset; // 1C\r
+ sdword lngLoopSamples; // 20\r
+ sdword lngRate; // 24\r
+ sdword lngSkip2[3]; // 28\r
+ sdword lngDataOffset; // 34\r
+ sdword lngSkip3[2]; // 38\r
} VGM_BASE_HDR;\r
\r
#define PBMODE_MUSIC 0x00\r
#define PBMODE_SFX 0x01\r
typedef struct _vgm_playback\r
{\r
- UINT8 pbMode;\r
- UINT8 vgmEnd; // 00 - running, 01 - finished, FF - not loaded\r
- UINT16 curLoopCnt;\r
- UINT32 vgmPos;\r
- UINT32 vgmSmplPos;\r
- UINT32 pbSmplPos;\r
+ byte pbMode;\r
+ byte vgmEnd; // 00 - running, 01 - finished, FF - not loaded\r
+ sword/**/ curLoopCnt;\r
+ sdword vgmPos;\r
+ sdword vgmSmplPos;\r
+ sdword pbSmplPos;\r
VGM_FILE* file;\r
\r
// oplChnMask:\r
// Music: mask of channels used/overridden by SFX\r
// SFX: ID of channel used by SFX (all commands are forces to it)\r
- UINT16 oplChnMask;\r
- UINT8* oplRegCache;\r
- UINT8 workRAM[0x04];\r
+ sword/**/ oplChnMask;\r
+ byte* oplRegCache;\r
+ byte workRAM[0x04];\r
} VGM_PBK;\r
\r
\r
\r
-INLINE UINT16 ReadLE16(const UINT8* buffer)\r
+INLINE sword/**/ ReadLE16(const byte* buffer)\r
{\r
#ifdef QUICK_READ\r
- return *(UINT16*)buffer;\r
+ return *(sword/**/*)buffer;\r
#else\r
return (buffer[0x00] << 0) | (buffer[0x01] << 8);\r
#endif\r
}\r
\r
-INLINE UINT32 ReadLE32(const UINT8* buffer)\r
+INLINE sdword ReadLE32(const byte* buffer)\r
{\r
#ifdef QUICK_READ\r
- return *(UINT32*)buffer;\r
+ return *(sword*)buffer;\r
#else\r
return (buffer[0x00] << 0) | (buffer[0x01] << 8) |\r
(buffer[0x02] << 16) | (buffer[0x03] << 24);\r
\r
\r
// Function Prototypes\r
-//UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile);\r
+//byte OpenVGMFile(const char* FileName, VGM_FILE* vgmFile);\r
//void FreeVGMFile(VGM_FILE* vgmFile);\r
\r
static boolean DoVgmLoop(VGM_PBK* vgmPlay);\r
-static void UpdateVGM(VGM_PBK* vgmPlay, UINT16 Samples);\r
+static void UpdateVGM(VGM_PBK* vgmPlay, sword/**/ Samples);\r
\r
//void InitEngine(void);\r
//void DeinitEngine(void);\r
\r
-//UINT8 PlayMusic(VGM_FILE* vgmFile);\r
-//UINT8 PlaySFX(VGM_FILE* vgmFile, UINT8 sfxChnID);\r
-//UINT8 StopMusic(void);\r
-//UINT8 StopSFX(UINT8 sfxChnID); // Note: sfxChnID == 0xFF -> stop all SFX\r
-//UINT8 PauseMusic(void);\r
-//UINT8 ResumeMusic(void);\r
+//byte PlayMusic(VGM_FILE* vgmFile);\r
+//byte PlaySFX(VGM_FILE* vgmFile, byte sfxChnID);\r
+//byte StopMusic(void);\r
+//byte StopSFX(byte sfxChnID); // Note: sfxChnID == 0xFF -> stop all SFX\r
+//byte PauseMusic(void);\r
+//byte ResumeMusic(void);\r
static void StartPlayback(VGM_PBK* vgmPb);\r
static void StopPlayback(VGM_PBK* vgmPb);\r
\r
-static void ym2413_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data);\r
-static void ym3812_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data);\r
-static void ym3512_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data);\r
-static void ymf262_write(VGM_PBK* vgmPb, UINT8 port, UINT8 reg, UINT8 data);\r
+static void ym2413_write(VGM_PBK* vgmPb, byte reg, byte data);\r
+static void ym3812_write(VGM_PBK* vgmPb, byte reg, byte data);\r
+static void ym3512_write(VGM_PBK* vgmPb, byte reg, byte data);\r
+static void ymf262_write(VGM_PBK* vgmPb, byte port, byte reg, byte data);\r
\r
//void UpdateSoundEngine(void);\r
\r
\r
// Functions that must be supplied by external library\r
-extern void OPL2_Write(UINT8 reg, UINT8 data);\r
-extern UINT8 OPL2_ReadStatus(void);\r
+extern void OPL2_Write(byte reg, byte data);\r
+extern byte OPL2_ReadStatus(void);\r
\r
\r
\r
static VGM_PBK vgmPbMusic;\r
static VGM_PBK vgmPbSFX[SFX_CHN_COUNT];\r
\r
-static UINT8 oplRegs_Music[0x100];\r
-static UINT8 oplRegs_SFX[SFX_CHN_COUNT][0x0D]; // 20 23 40 43 60 63 80 83 E0 E3 C0 A0 B0\r
+static byte oplRegs_Music[0x100];\r
+static byte oplRegs_SFX[SFX_CHN_COUNT][0x0D]; // 20 23 40 43 60 63 80 83 E0 E3 C0 A0 B0\r
\r
-static const UINT8 SFX_REGS[0x0D] =\r
+static const byte SFX_REGS[0x0D] =\r
{ 0x20, 0x23, 0x40, 0x43, 0x60, 0x63, 0x80, 0x83,\r
0xE0, 0xE3, 0xC0, 0xA0, 0xB0};\r
-static const UINT8 SFX_REGS_REV[0x10] = // 20/30 -> 0, 40/50 -> 2, ...\r
+static const byte SFX_REGS_REV[0x10] = // 20/30 -> 0, 40/50 -> 2, ...\r
{ 0xFF, 0xFF, 0x00, 0x00, 0x02, 0x02, 0x04, 0x04,\r
0x06, 0x06, 0x0B, 0x0C, 0x0A, 0xFF, 0x08, 0x08};\r
-static const UINT8 CHN_OPMASK[0x09] =\r
+static const byte CHN_OPMASK[0x09] =\r
{ 0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12};\r
-static const UINT8 CHN_OPMASK_REV[0x20] =\r
+static const byte CHN_OPMASK_REV[0x20] =\r
{ 0x00, 0x01, 0x02, 0x80, 0x81, 0x82, 0xFF, 0xFF,\r
0x03, 0x04, 0x05, 0x83, 0x84, 0x85, 0xFF, 0xFF,\r
0x06, 0x07, 0x08, 0x86, 0x87, 0x88, 0xFF, 0xFF,\r
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r
\r
\r
-UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile)\r
+byte OpenVGMFile(const char* FileName, VGM_FILE* vgmFile)\r
{\r
size_t hdrSize;\r
size_t readEl; // 'elements' read from file\r
size_t bytesToRead;\r
VGM_BASE_HDR vgmBaseHdr;\r
FILE* hFile;\r
- UINT32 CurPos;\r
+ sdword CurPos;\r
\r
memset(vgmFile, 0x00, sizeof(VGM_FILE));\r
\r
}\r
\r
vgmFile->dataLen = vgmBaseHdr.lngEOFOffset + 0x04;\r
- vgmFile->data = (UINT8*)malloc(vgmFile->dataLen);\r
+ vgmFile->data = (byte*)malloc(vgmFile->dataLen);\r
if (vgmFile->data == NULL)\r
{\r
fclose(hFile);\r
CurPos = 0x40;\r
hdrSize = sizeof(VGM_HEADER);\r
if (hdrSize > CurPos)\r
- memset((UINT8*)&vgmFile->header + CurPos, 0x00, hdrSize - CurPos);\r
+ memset((byte*)&vgmFile->header + CurPos, 0x00, hdrSize - CurPos);\r
\r
fclose(hFile);\r
return 0x00;\r
return true;\r
}\r
\r
-static void UpdateVGM(VGM_PBK* vgmPlay, UINT16 Samples)\r
+static void UpdateVGM(VGM_PBK* vgmPlay, sword/**/ Samples)\r
{\r
- const UINT32 vgmLen = vgmPlay->file->dataLen;\r
- const UINT8* vgmData = vgmPlay->file->data;\r
- const UINT8* VGMPnt;\r
- UINT32 VGMPos;\r
- UINT32 VGMSmplPos;\r
- UINT8 Command;\r
- UINT8 blockType;\r
- UINT32 blockLen;\r
+ const sdword vgmLen = vgmPlay->file->dataLen;\r
+ const byte* vgmData = vgmPlay->file->data;\r
+ const byte* VGMPnt;\r
+ sdword VGMPos;\r
+ sdword VGMSmplPos;\r
+ byte Command;\r
+ byte blockType;\r
+ sdword blockLen;\r
\r
vgmPlay->pbSmplPos += Samples;\r
VGMPos = vgmPlay->vgmPos;\r
\r
void InitEngine(void)\r
{\r
- UINT8 curSFX;\r
- UINT8 curReg;\r
+ byte curSFX;\r
+ byte curReg;\r
\r
memset(oplRegs_Music, 0x00, 0x100);\r
memset(&vgmPbMusic, 0x00, sizeof(VGM_PBK));\r
\r
void DeinitEngine(void)\r
{\r
- UINT8 curSFX;\r
+ byte curSFX;\r
\r
StopPlayback(&vgmPbMusic);\r
for (curSFX = 0; curSFX < SFX_CHN_COUNT; curSFX ++)\r
}\r
\r
\r
-UINT8 PlayMusic(VGM_FILE* vgmFile)\r
+byte PlayMusic(VGM_FILE* vgmFile)\r
{\r
VGM_PBK* vgmPb = &vgmPbMusic;\r
\r
return 0x00;\r
}\r
\r
-UINT8 PlaySFX(VGM_FILE* vgmFile, UINT8 sfxChnID)\r
+byte PlaySFX(VGM_FILE* vgmFile, byte sfxChnID)\r
{\r
VGM_PBK* vgmPb;\r
\r
return 0x00;\r
}\r
\r
-UINT8 StopMusic(void)\r
+byte StopMusic(void)\r
{\r
StopPlayback(&vgmPbMusic);\r
return 0x00;\r
}\r
\r
-UINT8 StopSFX(UINT8 sfxChnID)\r
+byte StopSFX(byte sfxChnID)\r
{\r
if (sfxChnID == 0xFF)\r
{\r
return 0x00;\r
}\r
\r
-UINT8 PauseMusic(void)\r
+byte PauseMusic(void)\r
{\r
if (vgmPbMusic.vgmEnd == 0xFF)\r
return 0xFF; // not playing\r
return 0x00;\r
}\r
\r
-UINT8 ResumeMusic(void)\r
+byte ResumeMusic(void)\r
{\r
if (vgmPbMusic.vgmEnd == 0xFF)\r
return 0xFF; // not playing\r
\r
if (vgmPb->pbMode == PBMODE_SFX)\r
{\r
- UINT8 curReg;\r
+ byte curReg;\r
\r
curReg = 0xB0 | vgmPb->oplChnMask;\r
if (oplRegs_Music[curReg] & 0x20)\r
\r
if (vgmPb->pbMode == PBMODE_MUSIC)\r
{\r
- UINT8 curReg;\r
- UINT16 chnMask;\r
+ byte curReg;\r
+ sword/**/ chnMask;\r
\r
chnMask = 0x0001;\r
for (curReg = 0xB0; curReg < 0xB9; curReg ++, chnMask <<= 1)\r
}\r
else //if (vgmPb->pbMode == PBMODE_SFX)\r
{\r
- UINT8 regID;\r
- UINT8 curReg;\r
- UINT8 opMask;\r
+ byte regID;\r
+ byte curReg;\r
+ byte opMask;\r
\r
curReg = 0xB0 | vgmPb->oplChnMask;\r
if (vgmPb->oplRegCache[0x0C] & 0x20)\r
\r
\r
\r
-static void OPL_CachedWrite(VGM_PBK* vgmPb, UINT8 reg, UINT8 data)\r
+static void OPL_CachedWrite(VGM_PBK* vgmPb, byte reg, byte data)\r
{\r
- UINT8 regChn;\r
- UINT8 ramOfs;\r
+ byte regChn;\r
+ byte ramOfs;\r
\r
if (vgmPb->pbMode == PBMODE_MUSIC)\r
{\r
}\r
\r
\r
-static void ym2413_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data)\r
+static void ym2413_write(VGM_PBK* vgmPb, byte reg, byte data)\r
{\r
return; // unsupported for now\r
}\r
\r
-static void ym3812_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data)\r
+static void ym3812_write(VGM_PBK* vgmPb, byte reg, byte data)\r
{\r
if (reg == 0x01)\r
{\r
return;\r
}\r
\r
-static void ym3512_write(VGM_PBK* vgmPb, UINT8 reg, UINT8 data)\r
+static void ym3512_write(VGM_PBK* vgmPb, byte reg, byte data)\r
{\r
if ((reg & 0xE0) == 0xE0)\r
{\r
return;\r
}\r
\r
-static void ymf262_write(VGM_PBK* vgmPb, UINT8 port, UINT8 reg, UINT8 data)\r
+static void ymf262_write(VGM_PBK* vgmPb, byte port, byte reg, byte data)\r
{\r
return; // unsupported for now\r
}\r
\r
void UpdateSoundEngine(void)\r
{\r
- UINT8 tmrMask;\r
- UINT8 curSFX;\r
+ byte tmrMask;\r
+ byte curSFX;\r
\r
tmrMask = OPL2_ReadStatus();\r
if (! (tmrMask & 0x40))\r