mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-27 11:00:27 +00:00
neo_run, intf/cd - cleanup time
This commit is contained in:
parent
d071fcc09f
commit
2e265c6bdd
@ -1,11 +1,10 @@
|
||||
// NeoGeo CD-WIP - Jan 25, 2019 - present
|
||||
|
||||
// mit .bin/.cue & .ccd/.img (trurip) unterstutzung (feb.4.2019)
|
||||
// todo:
|
||||
// burner/win32/neocdsel.cpp needs updated to support mode1/2352
|
||||
// known issues:
|
||||
// Audio Hz rate must be 44100 for proper CDDA speed
|
||||
// ssrpg bugs in sfx-audio in cutscene after starting game
|
||||
|
||||
|
||||
/*
|
||||
* FB Alpha Neo Geo module
|
||||
*
|
||||
@ -66,15 +65,13 @@
|
||||
* to 15360 (40 scanlines * 384 pixels per scanline).
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "neogeo.h"
|
||||
#include "cd_interface.h"
|
||||
#include "burn_ym2610.h"
|
||||
#include "bitswap.h"
|
||||
#include "neocdlist.h"
|
||||
|
||||
static INT32 isowav_mode = 0;
|
||||
|
||||
// #undef USE_SPEEDHACKS
|
||||
|
||||
// #define LOG_IRQ
|
||||
@ -408,13 +405,13 @@ static void NeoSetSystemType()
|
||||
if (nNeoSystemType & NEO_SYS_PCB) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// See if we're emulating MVS or AES hardware
|
||||
if (nBIOS == -1 || nBIOS == 15 || nBIOS == 16 || nBIOS == 17 || ((NeoSystem & 0x74) == 0x20)) {
|
||||
nNeoSystemType = NEO_SYS_CART | NEO_SYS_AES;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
nNeoSystemType = NEO_SYS_CART | NEO_SYS_MVS;
|
||||
}
|
||||
|
||||
@ -424,7 +421,7 @@ static INT32 NeoLoad68KBIOS(INT32 nNewBIOS)
|
||||
if (nNeoSystemType & NEO_SYS_CD) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_TRACKBALL) {
|
||||
nNewBIOS = 34;
|
||||
}
|
||||
@ -435,7 +432,7 @@ static INT32 NeoLoad68KBIOS(INT32 nNewBIOS)
|
||||
|
||||
// The most recent MVS models doesn't have a Z80 BIOS
|
||||
bZ80BIOS = (nNewBIOS != 0) ? true : false;
|
||||
|
||||
|
||||
// Check if we need to load a new BIOS
|
||||
if (nNewBIOS == nBIOS) {
|
||||
return 0;
|
||||
@ -456,7 +453,7 @@ static INT32 NeoLoad68KBIOS(INT32 nNewBIOS)
|
||||
}
|
||||
|
||||
if (!strcmp(BurnDrvGetTextA(DRV_NAME), "kf2k3pcb") || !strcmp(BurnDrvGetTextA(DRV_NAME), "k2k3pcbd")) kf2k3pcb_bios_decode();
|
||||
|
||||
|
||||
NeoUpdateVector();
|
||||
|
||||
return 0;
|
||||
@ -647,7 +644,7 @@ static INT32 LoadRoms()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!strcmp("kof2k4se", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] += 0x800000;
|
||||
if (!strcmp("cphd", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] = 0x4000000;
|
||||
if (!strcmp("kf2k4pls", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] += 0x800000;
|
||||
@ -669,9 +666,9 @@ static INT32 LoadRoms()
|
||||
if (!strcmp("kof2k2omg9b", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] = 0x1000000;
|
||||
if (!strcmp("kof2k2omg9", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] = 0x1000000;
|
||||
if (!strcmp("kof98pfe", BurnDrvGetTextA(DRV_NAME))) nYM2610ADPCMASize[nNeoActiveSlot] = 0x1000000;
|
||||
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("%x\n"), nYM2610ADPCMASize[nNeoActiveSlot]);
|
||||
|
||||
|
||||
// The kof2k3 PCB has 96MB of graphics ROM, however the last 16MB are unused, and the protection/decryption hardware does not see them
|
||||
// if (nSpriteSize[nNeoActiveSlot] > 0x4000000) {
|
||||
// nSpriteSize[nNeoActiveSlot] = 0x5000000;
|
||||
@ -689,7 +686,7 @@ static INT32 LoadRoms()
|
||||
} else {
|
||||
BurnSetProgressRange(1.0 / ((double)nSpriteSize[nNeoActiveSlot] / 0x800000 / 3));
|
||||
}*/
|
||||
|
||||
|
||||
if (BurnDrvGetHardwareCode() & (HARDWARE_SNK_CMC42 | HARDWARE_SNK_CMC50)) {
|
||||
double fRange = (double)pInfo->nSpriteNum / 4.0;
|
||||
if (fRange < 1.5) {
|
||||
@ -717,7 +714,7 @@ static INT32 LoadRoms()
|
||||
// Extract data from the end of C ROMS
|
||||
BurnUpdateProgress(0.0, _T("Decrypting text layer graphics...")/*, BST_DECRYPT_TXT*/, 0);
|
||||
NeoCMCExtractSData(NeoSpriteROM[nNeoActiveSlot], NeoTextROM[nNeoActiveSlot], nSpriteSize[nNeoActiveSlot], nNeoTextROMSize[nNeoActiveSlot]);
|
||||
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_DEDICATED_PCB) {
|
||||
for (INT32 i = 0; i < nNeoTextROMSize[nNeoActiveSlot]; i++) {
|
||||
NeoTextROM[nNeoActiveSlot][i] = BITSWAP08(NeoTextROM[nNeoActiveSlot][i] ^ 0xd2, 4, 0, 7, 2, 5, 1, 6, 3);
|
||||
@ -746,13 +743,13 @@ static INT32 LoadRoms()
|
||||
if (NeoZ80ROM[nNeoActiveSlot] == NULL) {
|
||||
return 1;
|
||||
}
|
||||
NeoZ80ROMActive = NeoZ80ROM[nNeoActiveSlot];
|
||||
NeoZ80ROMActive = NeoZ80ROM[nNeoActiveSlot];
|
||||
|
||||
BurnLoadRom(NeoZ80ROMActive, pInfo->nSoundOffset, 1);
|
||||
if (BurnDrvGetHardwareCode() & HARDWARE_SNK_ENCRYPTED_M1) {
|
||||
neogeo_cmc50_m1_decrypt();
|
||||
}
|
||||
|
||||
|
||||
if (NeoCallbackActive && NeoCallbackActive->pInitialise) {
|
||||
NeoCallbackActive->pInitialise();
|
||||
}
|
||||
@ -1027,14 +1024,14 @@ UINT8 __fastcall neogeoReadByteGambling(UINT32 sekAddress)
|
||||
case 0x280001: {
|
||||
return 0xff - NeoInput[3];
|
||||
}
|
||||
|
||||
|
||||
case 0x2c0001: {
|
||||
return 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Byte 0x%08X.\n"), sekAddress);
|
||||
|
||||
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
@ -1044,12 +1041,12 @@ UINT16 __fastcall neogeoReadWordGambling(UINT32 sekAddress)
|
||||
case 0x280000: {
|
||||
return 0xff - NeoInput[3];
|
||||
}
|
||||
|
||||
|
||||
case 0x2c0000: {
|
||||
return 0x0003;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Word 0x%08X.\n"), sekAddress);
|
||||
|
||||
return 0xffff;
|
||||
@ -1090,7 +1087,7 @@ UINT8 __fastcall vliner_timing(UINT32 sekAddress)
|
||||
return (0x3f) & 0xE7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T("Read Byte 0x%08X.\n"), sekAddress);
|
||||
return 0xff;
|
||||
}
|
||||
@ -1131,7 +1128,7 @@ static void NeoMapActiveCartridge()
|
||||
NeoSetSpriteSlot(nNeoActiveSlot);
|
||||
NeoSetTextSlot(nNeoActiveSlot);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
Neo68KROMActive = Neo68KROM[nNeoActiveSlot];
|
||||
@ -1155,12 +1152,12 @@ static void NeoMapActiveCartridge()
|
||||
SekMapMemory(Neo68KFix[nNeoActiveSlot], 0x200000, 0x27FFFF, MAP_ROM);
|
||||
SekMapMemory(Neo68KFix[nNeoActiveSlot], 0x280000, 0x2FFFFF, MAP_ROM);
|
||||
}
|
||||
|
||||
|
||||
if (nCodeSize[nNeoActiveSlot] <= 0x100000) {
|
||||
SekMapMemory(Neo68KFix[nNeoActiveSlot], 0x000000, 0x0FFFFF, MAP_ROM);
|
||||
SekMapMemory(Neo68KFix[nNeoActiveSlot], 0x200000, 0x2FFFFF, MAP_ROM);
|
||||
}
|
||||
|
||||
|
||||
if (nCodeSize[nNeoActiveSlot] > 0x100000) {
|
||||
SekMapMemory(Neo68KFix[nNeoActiveSlot], 0x000000, 0x0FFFFF, MAP_ROM);
|
||||
|
||||
@ -1185,19 +1182,19 @@ static void NeoMapActiveCartridge()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_GAMBLING) {
|
||||
SekMapMemory(NeoNVRAM2, 0x200000, 0x201FFF, MAP_RAM); // 68K RAM
|
||||
|
||||
|
||||
SekMapHandler(6, 0x202000, 0x2FFFFF, MAP_READ);
|
||||
SekSetReadByteHandler(6, neogeoReadByteGambling);
|
||||
SekSetReadWordHandler(6, neogeoReadWordGambling);
|
||||
|
||||
|
||||
if (vlinermode) {
|
||||
SekMapHandler(7, 0x320000, 0x320001, MAP_READ);
|
||||
SekSetReadByteHandler(7, vliner_timing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NeoZ80ROMActive) {
|
||||
ZetSetBUSREQLine(0);
|
||||
@ -1216,7 +1213,7 @@ static void NeoMapActiveCartridge()
|
||||
|
||||
NeoSetSpriteSlot(nNeoActiveSlot);
|
||||
NeoSetTextSlot(nNeoActiveSlot);
|
||||
|
||||
|
||||
// the text rendering code will get confused if we don't do this
|
||||
memset(NeoGraphicsRAM + 0xEA00, 0, 0x0200);
|
||||
|
||||
@ -1349,7 +1346,7 @@ INT32 NeoScan(INT32 nAction, INT32* pnMin)
|
||||
ba.szName = "NVRAM";
|
||||
BurnAcb(&ba);
|
||||
}
|
||||
|
||||
|
||||
if (((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_GAMBLING) && (nAction & ACB_NVRAM)) {
|
||||
ba.Data = NeoNVRAM2;
|
||||
ba.nLen = 0x00002000;
|
||||
@ -1742,10 +1739,6 @@ void __fastcall neogeoZ80Out(UINT16 nAddress, UINT8 nValue)
|
||||
|
||||
break;
|
||||
|
||||
case 0x80:
|
||||
bprintf(PRINT_ERROR, _T(" - Z80 port 0x%04X -> 0x%02X.\n"), nAddress, nValue);
|
||||
break;
|
||||
|
||||
default: {
|
||||
// bprintf(PRINT_NORMAL, _T(" - Z80 port 0x%04X -> 0x%02X.\n"), nAddress, nValue);
|
||||
}
|
||||
@ -1917,7 +1910,7 @@ UINT8 __fastcall neogeoReadByte(UINT32 sekAddress)
|
||||
// bprintf(PRINT_NORMAL, _T(" - Sound reply read (0x%02X).\n"), nSoundReply);
|
||||
return nReply;
|
||||
}
|
||||
|
||||
|
||||
if (nNeoSystemType & NEO_SYS_MVS) {
|
||||
UINT8 nuPD4990AOutput = uPD4990ARead(SekTotalCycles() - nuPD4990ATicks);
|
||||
nuPD4990ATicks = SekTotalCycles();
|
||||
@ -1945,10 +1938,10 @@ UINT16 __fastcall neogeoReadWord(UINT32 sekAddress)
|
||||
switch (sekAddress & 0xFE0000) {
|
||||
case 0x300000:
|
||||
return (ReadInput1(sekAddress & 0xFE) << 8) | ReadInput1((sekAddress & 0xFE) | 1);
|
||||
|
||||
|
||||
case 0x320000:
|
||||
SEK_DEF_READ_WORD(0, sekAddress);
|
||||
|
||||
|
||||
case 0x340000:
|
||||
return (ReadInput2(sekAddress & 0xFE) << 8) | ReadInput2((sekAddress & 0xFE) | 1);
|
||||
|
||||
@ -2000,7 +1993,7 @@ static void WriteIO1(INT32 nOffset, UINT8 byteValue)
|
||||
|
||||
break;
|
||||
|
||||
case 0x41: // Latch LED output
|
||||
case 0x41: // Latch LED output
|
||||
// for numeric displays - digits displayed = ~bytevalue
|
||||
// for start buttons - highlighted marquee = ~bytevalue
|
||||
// bprintf(PRINT_NORMAL, _T(" - LED output -> 0x%02X.\n"), byteValue);
|
||||
@ -2185,7 +2178,7 @@ void __fastcall neogeoWriteByte(UINT32 sekAddress, UINT8 byteValue)
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T(" - Attempt to write byte 0x%06X -> 0x%02X\n"), sekAddress, byteValue);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
void __fastcall neogeoWriteWord(UINT32 sekAddress, UINT16 wordValue)
|
||||
@ -2511,17 +2504,10 @@ static void LC8951UpdateHeader()
|
||||
} else {
|
||||
|
||||
// HEAD registers have header
|
||||
if (isowav_mode) {
|
||||
LC8951RegistersR[4] = ((NeoCDSectorMin / 10) << 4) | (NeoCDSectorMin % 10); // HEAD0
|
||||
LC8951RegistersR[5] = ((NeoCDSectorSec / 10) << 4) | (NeoCDSectorSec % 10); // HEAD1
|
||||
LC8951RegistersR[6] = ((NeoCDSectorFrm / 10) << 4) | (NeoCDSectorFrm % 10); // HEAD2
|
||||
LC8951RegistersR[7] = 1; // HEAD3
|
||||
} else {
|
||||
LC8951RegistersR[4] = NeoCDSectorData[12]; // HEAD0
|
||||
LC8951RegistersR[5] = NeoCDSectorData[13]; // HEAD1
|
||||
LC8951RegistersR[6] = NeoCDSectorData[14]; // HEAD2
|
||||
LC8951RegistersR[7] = NeoCDSectorData[15]; // HEAD3
|
||||
}
|
||||
LC8951RegistersR[4] = NeoCDSectorData[12]; // HEAD0
|
||||
LC8951RegistersR[5] = NeoCDSectorData[13]; // HEAD1
|
||||
LC8951RegistersR[6] = NeoCDSectorData[14]; // HEAD2
|
||||
LC8951RegistersR[7] = NeoCDSectorData[15]; // HEAD3
|
||||
}
|
||||
}
|
||||
|
||||
@ -2540,11 +2526,7 @@ static char* LC8951InitTransfer()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (isowav_mode) {
|
||||
return NeoCDSectorData + ((LC8951RegistersW[5] << 8) | LC8951RegistersW[4]);
|
||||
} else {
|
||||
return NeoCDSectorData + 12 + ((LC8951RegistersW[5] << 8) | LC8951RegistersW[4]);
|
||||
}
|
||||
return NeoCDSectorData + 12 + ((LC8951RegistersW[5] << 8) | LC8951RegistersW[4]);
|
||||
}
|
||||
|
||||
static void LC8951EndTransfer()
|
||||
@ -2565,6 +2547,7 @@ static void LC8951EndTransfer()
|
||||
|
||||
static void LC8951Reset()
|
||||
{
|
||||
nLC8951Register = 0;
|
||||
memset(LC8951RegistersR, 0, sizeof(LC8951RegistersR));
|
||||
memset(LC8951RegistersW, 0, sizeof(LC8951RegistersW));
|
||||
|
||||
@ -2577,10 +2560,6 @@ static void LC8951Reset()
|
||||
LC8951UpdateHeader();
|
||||
}
|
||||
|
||||
// for NeoGeo CD (WAV playback)
|
||||
//void wav_exit();
|
||||
//void wav_pause(bool bResume);
|
||||
|
||||
static void NeoCDProcessCommand()
|
||||
{
|
||||
memset(NeoCDCommsStatusFIFO, 0, sizeof(NeoCDCommsStatusFIFO));
|
||||
@ -2607,29 +2586,16 @@ static void NeoCDProcessCommand()
|
||||
case 0: {
|
||||
UINT8* ChannelData = CDEmuReadQChannel();
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[1] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[1] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[2] / 10;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[2] % 10;
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[2] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[3] / 10;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[3] % 10;
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[3] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[3] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[2] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[3] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[3] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
}
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
|
||||
// bprintf(PRINT_ERROR, _T(" %02i %02i:%02i:%02i %02i:%02i:%02i %02i\n"), ChannelData[0], ChannelData[1], ChannelData[2], ChannelData[3], ChannelData[4], ChannelData[5], ChannelData[6], ChannelData[7]);
|
||||
|
||||
@ -2638,91 +2604,51 @@ static void NeoCDProcessCommand()
|
||||
case 1: {
|
||||
UINT8* ChannelData = CDEmuReadQChannel();
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[4] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[4] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[4] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[4] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[5] / 10;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[5] % 10;
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[5] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[5] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[6] / 10;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[6] % 10;
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[6] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[6] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[4] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[4] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = ChannelData[5] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = ChannelData[5] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = ChannelData[6] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = ChannelData[6] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
}
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
|
||||
UINT8* ChannelData = CDEmuReadQChannel();
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[0] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[0] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = ChannelData[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = ChannelData[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
}
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
UINT8* TOCEntry = CDEmuReadTOC(-2);
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] / 10;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] % 10;
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] / 10;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] % 10;
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] & 0x0F;
|
||||
}
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] & 0x0F;
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
UINT8* TOCEntry = CDEmuReadTOC(-1);
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] > 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] / 10;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] % 10;
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] > 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
}
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2731,42 +2657,26 @@ static void NeoCDProcessCommand()
|
||||
|
||||
UINT8* TOCEntry = CDEmuReadTOC(NeoCDTrack);
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] / 10;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] % 10;
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] / 10;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] % 10;
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] / 10;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] % 10;
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[2] = TOCEntry[0] >> 4;
|
||||
NeoCDCommsStatusFIFO[3] = TOCEntry[0] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = TOCEntry[1] >> 4;
|
||||
NeoCDCommsStatusFIFO[5] = TOCEntry[1] & 0x0F;
|
||||
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] & 0x0F;
|
||||
}
|
||||
NeoCDCommsStatusFIFO[6] = TOCEntry[2] >> 4;
|
||||
NeoCDCommsStatusFIFO[7] = TOCEntry[2] & 0x0F;
|
||||
|
||||
// bit 3 of the 1st minutes digit indicates a data track
|
||||
if (TOCEntry[3] & 4) {
|
||||
NeoCDCommsStatusFIFO[6] |= 8;
|
||||
}
|
||||
|
||||
if (isowav_mode) {
|
||||
NeoCDCommsStatusFIFO[8] = NeoCDTrack % 10;
|
||||
} else {
|
||||
NeoCDCommsStatusFIFO[8] = NeoCDTrack & 0x0F;
|
||||
}
|
||||
NeoCDCommsStatusFIFO[8] = NeoCDTrack & 0x0F;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: {
|
||||
|
||||
UINT8* ChannelData = CDEmuReadQChannel();
|
||||
|
||||
NeoCDCommsStatusFIFO[8] = ChannelData[7];
|
||||
@ -2775,10 +2685,9 @@ static void NeoCDProcessCommand()
|
||||
}
|
||||
|
||||
case 7: {
|
||||
|
||||
// must be 02, 0E, 0F, or 05
|
||||
NeoCDCommsStatusFIFO[2] = 0;
|
||||
NeoCDCommsStatusFIFO[3] = (isowav_mode) ? 5 : NeoCDAssyStatus;
|
||||
NeoCDCommsStatusFIFO[3] = NeoCDAssyStatus;
|
||||
|
||||
NeoCDCommsStatusFIFO[4] = 0;
|
||||
NeoCDCommsStatusFIFO[5] = 0;
|
||||
@ -2805,9 +2714,6 @@ static void NeoCDProcessCommand()
|
||||
NeoCDSectorLBA += NeoCDCommsCommandFIFO[6] * (10 );
|
||||
NeoCDSectorLBA += NeoCDCommsCommandFIFO[7] * ( 1 );
|
||||
|
||||
if (isowav_mode)
|
||||
NeoCDSectorLBA -= CD_FRAMES_PREGAP;
|
||||
|
||||
CDEmuStartRead();
|
||||
// LC8951RegistersR[1] |= 0x20;
|
||||
} else {
|
||||
@ -2816,11 +2722,7 @@ static void NeoCDProcessCommand()
|
||||
bprintf(PRINT_ERROR, _T("*** Switching CD mode to audio while in CD-ROM mode!(PC: 0x%06X)\n"), SekGetPC(-1));
|
||||
}
|
||||
|
||||
if (isowav_mode) {
|
||||
CDEmuPlay((NeoCDCommsCommandFIFO[2] * 10) + NeoCDCommsCommandFIFO[3], (NeoCDCommsCommandFIFO[4] * 10) + NeoCDCommsCommandFIFO[5], (NeoCDCommsCommandFIFO[6] * 10) + NeoCDCommsCommandFIFO[7]);
|
||||
} else {
|
||||
CDEmuPlay((NeoCDCommsCommandFIFO[2] * 16) + NeoCDCommsCommandFIFO[3], (NeoCDCommsCommandFIFO[4] * 16) + NeoCDCommsCommandFIFO[5], (NeoCDCommsCommandFIFO[6] * 16) + NeoCDCommsCommandFIFO[7]);
|
||||
}
|
||||
CDEmuPlay((NeoCDCommsCommandFIFO[2] * 16) + NeoCDCommsCommandFIFO[3], (NeoCDCommsCommandFIFO[4] * 16) + NeoCDCommsCommandFIFO[5], (NeoCDCommsCommandFIFO[6] * 16) + NeoCDCommsCommandFIFO[7]);
|
||||
}
|
||||
|
||||
NeoCDAssyStatus = 1;
|
||||
@ -2843,14 +2745,12 @@ static void NeoCDProcessCommand()
|
||||
NeoCDAssyStatus = 4;
|
||||
bNeoCDLoadSector = false;
|
||||
CDEmuPause();
|
||||
//if (isowav_mode) wav_pause(0);
|
||||
break;
|
||||
case 7:
|
||||
// bprintf(PRINT_ERROR, _T(" CD comms received command %i\n"), NeoCDCommsCommandFIFO[0]);
|
||||
NeoCDAssyStatus = 1;
|
||||
bNeoCDLoadSector = true;
|
||||
CDEmuResume();
|
||||
//if (isowav_mode) wav_pause(1);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
@ -2868,6 +2768,7 @@ static void NeoCDProcessCommand()
|
||||
}
|
||||
}
|
||||
|
||||
// For Double Dragon (Early release) - see notes a few pages below..
|
||||
static INT32 CheckDMASourceForBlankVectorTable(INT32 dmadest, INT32 dmasrc)
|
||||
{
|
||||
if (dmadest == 0) {
|
||||
@ -3121,10 +3022,6 @@ static void NeoCDDoDMA()
|
||||
default: {
|
||||
bprintf(PRINT_ERROR, _T(" Unknown transfer type 0x%04X (PC: 0x%06X)\n"), NeoCDDMAMode, SekGetPC(-1));
|
||||
bprintf(PRINT_NORMAL, _T(" ??? : 0x%08X 0x%08X 0x%04X 0x%04X 0x%08X\n"), NeoCDDMAAddress1, NeoCDDMAAddress2, NeoCDDMAValue1, NeoCDDMAValue2, NeoCDDMACount);
|
||||
|
||||
extern INT32 bRunPause;
|
||||
bRunPause = 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3165,13 +3062,6 @@ static void NeoCDCommsControl(UINT8 clock, UINT8 send)
|
||||
|
||||
NeoCDCommsStatusFIFO[0] = NeoCDAssyStatus;
|
||||
|
||||
#if 0
|
||||
extern INT32 counter;
|
||||
if (counter) {
|
||||
NeoCDCommsStatusFIFO[0] = counter & 0x0F;
|
||||
}
|
||||
#endif
|
||||
|
||||
// compute checksum
|
||||
|
||||
sum = 0;
|
||||
@ -3210,44 +3100,35 @@ static void NeoCDCommsControl(UINT8 clock, UINT8 send)
|
||||
bNeoCDCommsClock = clock;
|
||||
}
|
||||
|
||||
void NeoCDReadSector()
|
||||
static void NeoCDReadSector()
|
||||
{
|
||||
if ((nff0002 & 0x0500)) {
|
||||
if (NeoCDAssyStatus == 1 && bNeoCDLoadSector) {
|
||||
|
||||
// if (LC8951RegistersW[10] & 0x80) {
|
||||
NeoCDSectorLBA++;
|
||||
if (isowav_mode) {
|
||||
NeoCDSectorLBA = CDEmuLoadSector(NeoCDSectorLBA, NeoCDSectorData + 4) - 1;
|
||||
} else {
|
||||
NeoCDSectorLBA = CDEmuLoadSector(NeoCDSectorLBA, NeoCDSectorData) - 1;
|
||||
}
|
||||
// }
|
||||
NeoCDSectorLBA++;
|
||||
NeoCDSectorLBA = CDEmuLoadSector(NeoCDSectorLBA, NeoCDSectorData) - 1;
|
||||
|
||||
if (LC8951RegistersW[10] & 0x80) {
|
||||
LC8951UpdateHeader();
|
||||
|
||||
|
||||
LC8951RegistersR[12] = 0x80; // STAT0
|
||||
LC8951RegistersR[13] = 0; // STAT1
|
||||
LC8951RegistersR[14] = 0x10; // STAT2
|
||||
LC8951RegistersR[15] = 0; // STAT3
|
||||
|
||||
|
||||
//bprintf(PRINT_IMPORTANT, _T(" Sector %08i (%02i:%02i:%02i) read\n"), NeoCDSectorLBA, NeoCDSectorMin, NeoCDSectorSec, NeoCDSectorFrm);
|
||||
|
||||
INT32 sectoffs = (isowav_mode) ? 0 : 12;
|
||||
|
||||
if (NeoCDSectorData[sectoffs + 4 + 64] == 'g' && !strncmp(NeoCDSectorData + sectoffs + 4, "Copyright by SNK", 16)) {
|
||||
if (NeoCDSectorData[(12 + 4) + 64] == 'g' && !strncmp(NeoCDSectorData + 12 + 4, "Copyright by SNK", 16)) {
|
||||
//bprintf(0, _T("\n simulated CDZ protection error\n"));
|
||||
//bprintf(PRINT_ERROR, _T(" %.70hs\n"), NeoCDSectorData + sectoffs + 4);
|
||||
|
||||
NeoCDSectorData[sectoffs + 4 + 64] = 'f';
|
||||
|
||||
|
||||
NeoCDSectorData[(12 + 4) + 64] = 'f';
|
||||
|
||||
// LC8951RegistersR[12] = 0x00; // STAT0
|
||||
}
|
||||
|
||||
nIRQAcknowledge &= ~0x20;
|
||||
NeoCDIRQUpdate(0);
|
||||
|
||||
|
||||
LC8951RegistersR[1] &= ~0x20;
|
||||
|
||||
// bprintf(PRINT_IMPORTANT, _T(" DECI interrupt triggered\n"));
|
||||
@ -3255,14 +3136,13 @@ void NeoCDReadSector()
|
||||
}
|
||||
|
||||
bNeoCDLoadSector = true;
|
||||
// bNeoCDLoadSector = false;
|
||||
}
|
||||
}
|
||||
|
||||
UINT8 __fastcall neogeoReadByteCDROM(UINT32 sekAddress)
|
||||
static UINT8 __fastcall neogeoReadByteCDROM(UINT32 sekAddress)
|
||||
{
|
||||
// bprintf(PRINT_NORMAL, _T(" - CDROM: 0x%06X read (byte, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
|
||||
|
||||
|
||||
switch (sekAddress & 0xFFFF) {
|
||||
|
||||
case 0x0017:
|
||||
@ -3304,28 +3184,25 @@ UINT8 __fastcall neogeoReadByteCDROM(UINT32 sekAddress)
|
||||
return ~0;
|
||||
}
|
||||
|
||||
UINT16 __fastcall neogeoReadWordCDROM(UINT32 sekAddress)
|
||||
static UINT16 __fastcall neogeoReadWordCDROM(UINT32 sekAddress)
|
||||
{
|
||||
// bprintf(PRINT_NORMAL, _T(" - CDROM: 0x%06X read (word, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
|
||||
|
||||
#if 1
|
||||
switch (sekAddress & 0xFFFF) {
|
||||
case 0x011C:
|
||||
return ~((0x10 | (NeoSystem & 3)) << 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
// bprintf(PRINT_NORMAL, _T(" - NGCD port 0x%06X read (word, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
|
||||
|
||||
return ~0;
|
||||
}
|
||||
|
||||
void __fastcall neogeoWriteByteCDROM(UINT32 sekAddress, UINT8 byteValue)
|
||||
static void __fastcall neogeoWriteByteCDROM(UINT32 sekAddress, UINT8 byteValue)
|
||||
{
|
||||
// bprintf(PRINT_NORMAL, _T(" - Neo Geo CD: 0x%06X -> 0x%02X (PC: 0x%06X)\n"), sekAddress, byteValue, SekGetPC(-1));
|
||||
|
||||
switch (sekAddress & 0xFFFF) {
|
||||
//case 0x000E:
|
||||
case 0x000F:
|
||||
NeoCDIRQUpdate(byteValue);
|
||||
break;
|
||||
@ -3436,9 +3313,6 @@ void __fastcall neogeoWriteByteCDROM(UINT32 sekAddress, UINT8 byteValue)
|
||||
// bprintf(PRINT_ERROR, _T(" - NGCD port 0x%06X -> 0x%02X (PC: 0x%06X)\n"), sekAddress, byteValue, SekGetPC(-1));
|
||||
|
||||
MapVectorTable(!(byteValue == 0xFF));
|
||||
|
||||
//extern INT32 bRunPause;
|
||||
//bRunPause = 1;
|
||||
break;
|
||||
|
||||
case 0x016F:
|
||||
@ -3458,7 +3332,7 @@ void __fastcall neogeoWriteByteCDROM(UINT32 sekAddress, UINT8 byteValue)
|
||||
BurnYM2610Reset();
|
||||
ZetReset();
|
||||
}
|
||||
clara = byteValue;
|
||||
clara = byteValue;
|
||||
break;
|
||||
}
|
||||
case 0x01A1:
|
||||
@ -3474,7 +3348,7 @@ void __fastcall neogeoWriteByteCDROM(UINT32 sekAddress, UINT8 byteValue)
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue)
|
||||
static void __fastcall neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue)
|
||||
{
|
||||
// bprintf(PRINT_NORMAL, _T(" - NGCD port 0x%06X -> 0x%04X (PC: 0x%06X)\n"), sekAddress, wordValue, SekGetPC(-1));
|
||||
|
||||
@ -3487,12 +3361,6 @@ void __fastcall neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue)
|
||||
nff0002 = wordValue;
|
||||
|
||||
// LC8951RegistersR[1] |= 0x20;
|
||||
|
||||
/* if (nff0002 & 0x0500)
|
||||
nNeoCDCyclesIRQPeriod = (INT32)(12000000.0 * nBurnCPUSpeedAdjust / (256.0 * 75.0));
|
||||
else
|
||||
nNeoCDCyclesIRQPeriod = (INT32)(12000000.0 * nBurnCPUSpeedAdjust / (256.0 * 75.0));
|
||||
*/
|
||||
break;
|
||||
|
||||
case 0x000E:
|
||||
@ -3559,16 +3427,16 @@ void __fastcall neogeoWriteWordCDROM(UINT32 sekAddress, UINT16 wordValue)
|
||||
// bprintf(PRINT_NORMAL, _T(" - NGCD port 0x%06X -> 0x%04X (PC: 0x%06X)\n"), sekAddress, wordValue, SekGetPC(-1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Reads from / writes to the transfer area
|
||||
|
||||
UINT8 __fastcall neogeoReadByteTransfer(UINT32 sekAddress)
|
||||
static UINT8 __fastcall neogeoReadByteTransfer(UINT32 sekAddress)
|
||||
{
|
||||
// if ((sekAddress & 0x0FFFFF) < 16)
|
||||
// printf(PRINT_NORMAL, _T(" - NGCD port 0x%06X read (byte, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
|
||||
|
||||
|
||||
sekAddress ^= 1;
|
||||
|
||||
switch (nActiveTransferArea) {
|
||||
@ -3586,11 +3454,11 @@ UINT8 __fastcall neogeoReadByteTransfer(UINT32 sekAddress)
|
||||
return NeoTextRAM[(sekAddress & 0x3FFFF) >> 1];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ~0;
|
||||
}
|
||||
|
||||
UINT16 __fastcall neogeoReadWordTransfer(UINT32 sekAddress)
|
||||
static UINT16 __fastcall neogeoReadWordTransfer(UINT32 sekAddress)
|
||||
{
|
||||
// if ((sekAddress & 0x0FFFFF) < 16)
|
||||
// bprintf(PRINT_NORMAL, _T(" - Transfer: 0x%06X read (word, PC: 0x%06X)\n"), sekAddress, SekGetPC(-1));
|
||||
@ -3610,11 +3478,11 @@ UINT16 __fastcall neogeoReadWordTransfer(UINT32 sekAddress)
|
||||
return 0xFF00 | NeoTextRAM[(sekAddress & 0x3FFFF) >> 1];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ~0;
|
||||
}
|
||||
|
||||
void __fastcall neogeoWriteByteTransfer(UINT32 sekAddress, UINT8 byteValue)
|
||||
static void __fastcall neogeoWriteByteTransfer(UINT32 sekAddress, UINT8 byteValue)
|
||||
{
|
||||
// if ((sekAddress & 0x0FFFFF) < 16)
|
||||
// bprintf(PRINT_NORMAL, _T(" - Transfer: 0x%06X -> 0x%02X (PC: 0x%06X)\n"), sekAddress, byteValue, SekGetPC(-1));
|
||||
@ -3644,7 +3512,7 @@ void __fastcall neogeoWriteByteTransfer(UINT32 sekAddress, UINT8 byteValue)
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall neogeoWriteWordTransfer(UINT32 sekAddress, UINT16 wordValue)
|
||||
static void __fastcall neogeoWriteWordTransfer(UINT32 sekAddress, UINT16 wordValue)
|
||||
{
|
||||
// if ((sekAddress & 0x0FFFFF) < 16)
|
||||
// bprintf(PRINT_NORMAL, _T(" - Transfer: 0x%06X -> 0x%04X (PC: 0x%06X)\n"), sekAddress, wordValue, SekGetPC(-1));
|
||||
@ -3678,7 +3546,7 @@ void __fastcall neogeoWriteWordTransfer(UINT32 sekAddress, UINT16 wordValue)
|
||||
}
|
||||
}
|
||||
|
||||
UINT16 __fastcall neogeoCDReadWord68KProgram(UINT32 sekAddress)
|
||||
static UINT16 __fastcall neogeoCDReadWord68KProgram(UINT32 sekAddress)
|
||||
{
|
||||
if (sekAddress < 0x80 && NeoCDVectorSwitch == 0) {
|
||||
return *((UINT16*)(NeoVectorActive + sekAddress));
|
||||
@ -3687,7 +3555,7 @@ UINT16 __fastcall neogeoCDReadWord68KProgram(UINT32 sekAddress)
|
||||
return *((UINT16*)(Neo68KROMActive + sekAddress));
|
||||
}
|
||||
|
||||
UINT8 __fastcall neogeoCDReadByte68KProgram(UINT32 sekAddress)
|
||||
static UINT8 __fastcall neogeoCDReadByte68KProgram(UINT32 sekAddress)
|
||||
{
|
||||
if (sekAddress < 0x80 && NeoCDVectorSwitch == 0) {
|
||||
return NeoVectorActive[sekAddress ^ 1];
|
||||
@ -3702,7 +3570,7 @@ static INT32 neogeoReset()
|
||||
{
|
||||
if (nNeoSystemType & NEO_SYS_CART) {
|
||||
NeoLoad68KBIOS(NeoSystem & 0x3f);
|
||||
|
||||
|
||||
if (nBIOS == -1 || nBIOS == 33) {
|
||||
// Write system type & region code into BIOS ROM
|
||||
*((UINT16*)(Neo68KBIOS + 0x000400)) = BURN_ENDIAN_SWAP_INT16(((NeoSystem & 4) << 13) | (NeoSystem & 0x03));
|
||||
@ -3743,15 +3611,15 @@ static INT32 neogeoReset()
|
||||
case 0x1d: { bprintf(PRINT_IMPORTANT, _T("Emulating using Universe BIOS ver. 1.2 BIOS\n")); break; }
|
||||
case 0x1e: { bprintf(PRINT_IMPORTANT, _T("Emulating using Universe BIOS ver. 1.2 (alt) BIOS\n")); break; }
|
||||
case 0x1f: { bprintf(PRINT_IMPORTANT, _T("Emulating using Universe BIOS ver. 1.1 BIOS\n")); break; }
|
||||
case 0x20: { bprintf(PRINT_IMPORTANT, _T("Emulating using Universe BIOS ver. 1.0 BIOS\n")); break; }
|
||||
case 0x21: { bprintf(PRINT_IMPORTANT, _T("Emulating using NeoOpen BIOS v0.1 beta BIOS\n")); break; }
|
||||
case 0x20: { bprintf(PRINT_IMPORTANT, _T("Emulating using Universe BIOS ver. 1.0 BIOS\n")); break; }
|
||||
case 0x21: { bprintf(PRINT_IMPORTANT, _T("Emulating using NeoOpen BIOS v0.1 beta BIOS\n")); break; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_SNK_CONTROLMASK) == HARDWARE_SNK_TRACKBALL) {
|
||||
bprintf(PRINT_IMPORTANT, _T("Emulating using custom Trackball BIOS\n"));
|
||||
}
|
||||
|
||||
|
||||
if ((BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_DEDICATED_PCB) {
|
||||
bprintf(PRINT_IMPORTANT, _T("Emulating using custom PCB BIOS\n"));
|
||||
}
|
||||
@ -3764,9 +3632,6 @@ static INT32 neogeoReset()
|
||||
#if 1 && defined FBA_DEBUG
|
||||
if (nNeoSystemType & NEO_SYS_CD) {
|
||||
bprintf(PRINT_IMPORTANT, _T(" - Emulating Neo CD system.\n"));
|
||||
|
||||
// exit WAV object if needed
|
||||
//if (isowav_mode) wav_exit();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3832,7 +3697,7 @@ static INT32 neogeoReset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set by a switch on the PCB
|
||||
if (!strcmp(BurnDrvGetTextA(DRV_NAME), "svcpcb") || !strcmp(BurnDrvGetTextA(DRV_NAME), "svcpcba") || !strcmp(BurnDrvGetTextA(DRV_NAME), "svcpcbnd") || !strcmp(BurnDrvGetTextA(DRV_NAME), "ms5pcb") || !strcmp(BurnDrvGetTextA(DRV_NAME), "ms5pcbnd")) {
|
||||
SekMapMemory(Neo68KBIOS + 0x20000 * (~NeoSystem & 1), 0xc00000, 0xc1ffff, MAP_ROM);
|
||||
@ -3929,7 +3794,7 @@ static INT32 NeoInitCommon()
|
||||
memset(AllRAM, 0, nLen); // Initialise memory
|
||||
RAMIndex(); // Index the allocated memory
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_A68K
|
||||
if (nNeoSystemType & NEO_SYS_CD) {
|
||||
SwitchToMusashi();
|
||||
@ -4011,16 +3876,16 @@ static INT32 NeoInitCommon()
|
||||
SekMapHandler(6, 0xE00000, 0xEFFFFF, MAP_RAM);
|
||||
|
||||
SekSetReadWordHandler(6, neogeoReadWordTransfer);
|
||||
SekSetReadByteHandler(6, neogeoReadByteTransfer);
|
||||
SekSetReadByteHandler(6, neogeoReadByteTransfer);
|
||||
SekSetWriteWordHandler(6, neogeoWriteWordTransfer);
|
||||
SekSetWriteByteHandler(6, neogeoWriteByteTransfer);
|
||||
SekSetWriteByteHandler(6, neogeoWriteByteTransfer);
|
||||
|
||||
SekMapHandler(7, 0xF00000, 0xFFFFFF, MAP_RAM);
|
||||
|
||||
SekSetReadWordHandler(7, neogeoReadWordCDROM);
|
||||
SekSetReadByteHandler(7, neogeoReadByteCDROM);
|
||||
SekSetReadByteHandler(7, neogeoReadByteCDROM);
|
||||
SekSetWriteWordHandler(7, neogeoWriteWordCDROM);
|
||||
SekSetWriteByteHandler(7, neogeoWriteByteCDROM);
|
||||
SekSetWriteByteHandler(7, neogeoWriteByteCDROM);
|
||||
|
||||
SekSetReadByteHandler(2, neoCDReadByteMemoryCard);
|
||||
SekSetWriteByteHandler(2, neoCDWriteByteMemoryCard);
|
||||
@ -4126,7 +3991,7 @@ static INT32 NeoInitCommon()
|
||||
} else {
|
||||
BurnYM2610Init(8000000, YM2610ADPCMBROM[0], &nYM2610ADPCMBSize[0], YM2610ADPCMBROM[0], &nYM2610ADPCMBSize[0], &neogeoFMIRQHandler, 0);
|
||||
}
|
||||
|
||||
|
||||
BurnYM2610SetRoute(BURN_SND_YM2610_YM2610_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
|
||||
BurnYM2610SetRoute(BURN_SND_YM2610_YM2610_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
|
||||
BurnYM2610SetRoute(BURN_SND_YM2610_AY8910_ROUTE, 0.20, BURN_SND_ROUTE_BOTH);
|
||||
@ -4254,7 +4119,7 @@ INT32 NeoInit()
|
||||
}
|
||||
|
||||
recursing = false;
|
||||
|
||||
|
||||
for (nNeoActiveSlot = 0; nNeoActiveSlot < nNeoNumSlots; nNeoActiveSlot++) {
|
||||
NeoVector[nNeoActiveSlot] = (UINT8*)BurnMalloc(0x0400);
|
||||
if (NeoVector[nNeoActiveSlot] == NULL) {
|
||||
@ -4385,7 +4250,7 @@ INT32 NeoExit()
|
||||
|
||||
nBurnDrvActive = nDriver;
|
||||
}
|
||||
|
||||
|
||||
uPD4990AExit();
|
||||
|
||||
NeoExitPalette();
|
||||
@ -4415,7 +4280,7 @@ INT32 NeoExit()
|
||||
BurnFree(YM2610ADPCMBROM[nNeoActiveSlot]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (nNeoSystemType & NEO_SYS_CD) {
|
||||
NeoExitSprites(0);
|
||||
NeoExitText(0);
|
||||
@ -4437,7 +4302,7 @@ INT32 NeoExit()
|
||||
NeoZ80ROMActive = NULL;
|
||||
|
||||
nCodeSize[0] = 0;
|
||||
|
||||
|
||||
#ifdef BUILD_A68K
|
||||
// Switch back CPU core if needed
|
||||
if (nNeoSystemType & NEO_SYS_CD) {
|
||||
@ -4452,7 +4317,7 @@ INT32 NeoExit()
|
||||
#endif
|
||||
|
||||
recursing = false;
|
||||
|
||||
|
||||
bDisableNeoWatchdog = false;
|
||||
|
||||
// release the NeoGeo CD information object if needed
|
||||
@ -4535,9 +4400,6 @@ static void NeoStandardInputs(INT32 nBank)
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
#define NeoSekRun SekRun
|
||||
#else
|
||||
static INT32 NeoSekRun(const INT32 nCycles)
|
||||
{
|
||||
INT32 nCyclesExecutedTotal = 0, nOldCyclesSegment = nCyclesSegment;
|
||||
@ -4572,7 +4434,6 @@ static INT32 NeoSekRun(const INT32 nCycles)
|
||||
|
||||
return nCyclesExecutedTotal;
|
||||
}
|
||||
#endif
|
||||
|
||||
INT32 NeoFrame()
|
||||
{
|
||||
@ -4583,7 +4444,7 @@ INT32 NeoFrame()
|
||||
|
||||
neogeoReset();
|
||||
}
|
||||
|
||||
|
||||
NeoInput[ 5] &= 0x1F; // Clear ports
|
||||
NeoInput[13] = 0x00; //
|
||||
|
||||
@ -4726,7 +4587,7 @@ INT32 NeoFrame()
|
||||
if (nPrevBurnCPUSpeedAdjust != nBurnCPUSpeedAdjust) {
|
||||
// 68K CPU clock is 12MHz, modified by nBurnCPUSpeedAdjust
|
||||
nCyclesTotal[0] = (INT32)((INT64)12000000 * nBurnCPUSpeedAdjust / (256.0 * NEO_VREFRESH));
|
||||
|
||||
|
||||
#if defined Z80_SPEED_ADJUST
|
||||
// Z80 CPU clock always 68K / 3
|
||||
nCyclesTotal[1] = nCyclesTotal[0] / 3;
|
||||
@ -4773,7 +4634,7 @@ INT32 NeoFrame()
|
||||
NeoClearScreen();
|
||||
}
|
||||
nSliceEnd = 0x10;
|
||||
|
||||
|
||||
SekNewFrame();
|
||||
ZetNewFrame();
|
||||
|
||||
@ -4787,20 +4648,6 @@ INT32 NeoFrame()
|
||||
nuPD4990ATicks = nCyclesExtra[0];
|
||||
|
||||
// Run 68000
|
||||
|
||||
|
||||
if (isowav_mode) {
|
||||
if ((nNeoSystemType & NEO_SYS_CD) && (nff0002 & 0x0050)) {
|
||||
nIRQAcknowledge &= ~0x10;
|
||||
NeoCDIRQUpdate(0);
|
||||
|
||||
if (nff0002 & 0x0500) {
|
||||
NeoCDReadSector();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nCyclesSegment = nSekCyclesScanline * 24;
|
||||
while (SekTotalCycles() < nCyclesSegment) {
|
||||
|
||||
@ -5033,13 +4880,13 @@ INT32 NeoFrame()
|
||||
// bprintf(PRINT_NORMAL, " -- IRQControl: %02X, nIRQCycles / nSekCyclesScanline: %3i.\n", nIRQControl, nIRQCycles / nSekCyclesScanline);
|
||||
|
||||
// Update the sound until the end of the frame
|
||||
|
||||
|
||||
nCycles68KSync = SekTotalCycles();
|
||||
BurnTimerEndFrame(nCyclesTotal[1]);
|
||||
if (pBurnSoundOut) {
|
||||
BurnYM2610Update(pBurnSoundOut, nBurnSoundLen);
|
||||
}
|
||||
|
||||
|
||||
// Update the uPD4990 until the end of the frame
|
||||
uPD4990AUpdate(SekTotalCycles() - nuPD4990ATicks);
|
||||
|
||||
@ -5066,7 +4913,7 @@ INT32 NeoFrame()
|
||||
}
|
||||
|
||||
if (pBurnSoundOut) {
|
||||
if (!(LC8951RegistersW[10] & 4))
|
||||
if ((nNeoSystemType & NEO_SYS_CD) && !(LC8951RegistersW[10] & 4))
|
||||
CDEmuGetSoundBuffer(pBurnSoundOut, nBurnSoundLen);
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ static InterfaceInfo CDEmuInfo = { NULL, NULL, NULL };
|
||||
#elif defined BUILD_SDL
|
||||
// CD emulation module
|
||||
#elif defined (_XBOX)
|
||||
extern struct CDEmuDo isowavDo;
|
||||
extern struct CDEmuDo cdimgDo;
|
||||
#endif
|
||||
|
||||
static struct CDEmuDo* pCDEmuDo[] =
|
||||
@ -23,7 +23,7 @@ static struct CDEmuDo* pCDEmuDo[] =
|
||||
#elif defined BUILD_SDL
|
||||
// CD emulation module
|
||||
#elif defined (_XBOX)
|
||||
&isowavDo,
|
||||
&cdimgDo,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1,595 +0,0 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// iso/cue/wav support
|
||||
/*-----------------------------------------------------------------------------
|
||||
Modified by: CaptainCPS-X
|
||||
Updates:
|
||||
(10/24/2011)
|
||||
- removed libmad and MP3 support
|
||||
- added my custom DirectSound library to add WAV support
|
||||
- removed most (if not all) references to MP3
|
||||
- modified a few other things as needed
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "burner.h"
|
||||
#include "cdsound.h"
|
||||
|
||||
#define MAXIMUM_NUMBER_TRACKS (100)
|
||||
|
||||
#define CD_FRAMES_MINUTE (60 * 75)
|
||||
#define CD_FRAMES_SECOND ( 75)
|
||||
#define CD_FRAMES_PREGAP ( 2 * 75)
|
||||
|
||||
struct isowavTRACK_DATA {
|
||||
char Control;
|
||||
char TrackNumber;
|
||||
char Address[4];
|
||||
TCHAR* Filename;
|
||||
};
|
||||
|
||||
struct isowavCDROM_TOC {
|
||||
char FirstTrack;
|
||||
char LastTrack;
|
||||
isowavTRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS];
|
||||
};
|
||||
|
||||
static isowavCDROM_TOC* isowavTOC;
|
||||
|
||||
static FILE* isowavFile = NULL;
|
||||
static int isowavTrack = 0;
|
||||
static int isowavLBA = 0;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static const char* isowavLBAToMSF(const int LBA)
|
||||
{
|
||||
static char address[4];
|
||||
|
||||
address[0] = 0;
|
||||
address[1] = LBA / CD_FRAMES_MINUTE;
|
||||
address[2] = LBA % CD_FRAMES_MINUTE / CD_FRAMES_SECOND;
|
||||
address[3] = LBA % CD_FRAMES_SECOND;
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
static int isowavMSFToLBA(const char* address)
|
||||
{
|
||||
int LBA;
|
||||
|
||||
LBA = address[3];
|
||||
LBA += address[2] * CD_FRAMES_SECOND;
|
||||
LBA += address[1] * CD_FRAMES_MINUTE;
|
||||
|
||||
return LBA;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int isowavGetTrackSizes()
|
||||
{
|
||||
// determine the lenght of the .iso / .mp3 files to complete the TOC
|
||||
|
||||
FILE* h;
|
||||
|
||||
for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {
|
||||
|
||||
const char* address;
|
||||
|
||||
if (isowavTOC->TrackData[i].Control & 4) {
|
||||
|
||||
// data track
|
||||
|
||||
h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
|
||||
if (h == NULL) return 1;
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
||||
address = isowavLBAToMSF((ftell(h) + 2047) / 2048 + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
|
||||
|
||||
if(h) fclose(h);
|
||||
|
||||
} else {
|
||||
|
||||
// audio track
|
||||
|
||||
h = _tfopen(isowavTOC->TrackData[i].Filename, _T("rb"));
|
||||
if (h == NULL)return 1;
|
||||
|
||||
fseek(h, 0, SEEK_END);
|
||||
|
||||
address = isowavLBAToMSF(((ftell(h) + 2047) / 2048) + isowavMSFToLBA(isowavTOC->TrackData[i].Address));
|
||||
if(h) fclose(h);
|
||||
}
|
||||
|
||||
isowavTOC->TrackData[i + 1].Address[0] += 0; // always 0 [?]
|
||||
isowavTOC->TrackData[i + 1].Address[1] += address[1]; // M
|
||||
isowavTOC->TrackData[i + 1].Address[2] += address[2]; // S
|
||||
isowavTOC->TrackData[i + 1].Address[3] += address[3]; // F
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavTestISO()
|
||||
{
|
||||
TCHAR fullname[MAX_PATH];
|
||||
TCHAR* filename;
|
||||
int length = 0;
|
||||
int offset = 0;
|
||||
int track = 2;
|
||||
FILE* h;
|
||||
|
||||
_tcscpy(fullname, CDEmuImage);
|
||||
length = _tcslen(fullname);
|
||||
|
||||
// assume CD-ROM mode1/2048 format
|
||||
|
||||
if (length <= 4 && (_tcscmp(_T(".iso"), fullname + length - 4) || _tcscmp(_T(".bin"), fullname + length - 4))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// create a TOC with only the data track first
|
||||
|
||||
isowavTOC->FirstTrack = 1;
|
||||
isowavTOC->LastTrack = 1;
|
||||
|
||||
isowavTOC->TrackData[0].TrackNumber = 1;
|
||||
|
||||
isowavTOC->TrackData[0].Address[1] = 0;
|
||||
isowavTOC->TrackData[0].Address[2] = 2;
|
||||
isowavTOC->TrackData[0].Address[3] = 0;
|
||||
|
||||
isowavTOC->TrackData[0].Filename = (TCHAR*)malloc((length + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[0].Filename == NULL) {
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[0].Filename, fullname);
|
||||
|
||||
isowavTOC->TrackData[0].Control = 4;
|
||||
|
||||
// if the filename has a number in it, try to find .mp3 tracks
|
||||
|
||||
filename = ExtractFilename(fullname);
|
||||
offset = (filename - fullname) + length - 6;
|
||||
while (offset >= 0 && fullname[offset] != _T('0') && fullname[offset + 1] != _T('1')) {
|
||||
offset--;
|
||||
}
|
||||
if (offset < 0) {
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
_stprintf(fullname + length - 4, _T(".wav"));
|
||||
|
||||
while (1) {
|
||||
fullname[offset] = _T('0') + track / 10; fullname[offset + 1] = _T('0') + track % 10;
|
||||
|
||||
if ((h = _tfopen(fullname, _T("rb"))) == NULL) {
|
||||
break;
|
||||
}
|
||||
fclose(h);
|
||||
|
||||
isowavTOC->TrackData[track - 1].TrackNumber = track;
|
||||
|
||||
isowavTOC->TrackData[track - 1].Filename = (TCHAR*)malloc((length + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[track - 1].Filename == NULL) {
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[track - 1].Filename, fullname);
|
||||
|
||||
isowavTOC->LastTrack = track;
|
||||
|
||||
track++;
|
||||
}
|
||||
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
static int isowavParseCueFile()
|
||||
{
|
||||
TCHAR szLine[1024];
|
||||
TCHAR szFile[1024];
|
||||
TCHAR* s;
|
||||
TCHAR* t;
|
||||
FILE* h;
|
||||
int track = 0;
|
||||
int length;
|
||||
|
||||
isowavTOC->FirstTrack = 1;
|
||||
isowavTOC->LastTrack = 1;
|
||||
|
||||
isowavTOC->TrackData[0].Address[1] = 0;
|
||||
isowavTOC->TrackData[0].Address[2] = 2;
|
||||
isowavTOC->TrackData[0].Address[3] = 0;
|
||||
|
||||
h = _tfopen(CDEmuImage, _T("rt"));
|
||||
if (h == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
length = _tcslen(szLine);
|
||||
// get rid of the linefeed at the end
|
||||
while (length && (szLine[length - 1] == _T('\r') || szLine[length - 1] == _T('\n'))) {
|
||||
szLine[length - 1] = 0;
|
||||
length--;
|
||||
}
|
||||
|
||||
s = szLine;
|
||||
|
||||
// file info
|
||||
if ((t = LabelCheck(s, _T("FILE"))) != 0) {
|
||||
s = t;
|
||||
|
||||
TCHAR* szQuote;
|
||||
|
||||
// read filename
|
||||
QuoteRead(&szQuote, NULL, s);
|
||||
|
||||
_sntprintf(szFile, ExtractFilename(CDEmuImage) - CDEmuImage, _T("%s"), CDEmuImage);
|
||||
_sntprintf(szFile + (ExtractFilename(CDEmuImage) - CDEmuImage), 1024 - (ExtractFilename(CDEmuImage) - CDEmuImage), _T("/%s"), szQuote);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// track info
|
||||
if ((t = LabelCheck(s, _T("TRACK"))) != 0) {
|
||||
s = t;
|
||||
|
||||
// track number
|
||||
track = _tcstol(s, &t, 10);
|
||||
|
||||
if (track < 1 || track > MAXIMUM_NUMBER_TRACKS) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (track < isowavTOC->FirstTrack) {
|
||||
isowavTOC->FirstTrack = track;
|
||||
}
|
||||
if (track > isowavTOC->LastTrack) {
|
||||
isowavTOC->LastTrack = track;
|
||||
}
|
||||
isowavTOC->TrackData[track - 1].TrackNumber = track;
|
||||
|
||||
isowavTOC->TrackData[track - 1].Filename = (TCHAR*)malloc((_tcslen(szFile) + 1) * sizeof(TCHAR));
|
||||
if (isowavTOC->TrackData[track - 1].Filename == NULL) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
_tcscpy(isowavTOC->TrackData[track - 1].Filename, szFile);
|
||||
|
||||
s = t;
|
||||
|
||||
// type of track
|
||||
|
||||
if ((t = LabelCheck(s, _T("MODE1/2048"))) != 0) {
|
||||
isowavTOC->TrackData[track - 1].Control = 4;
|
||||
|
||||
continue;
|
||||
}
|
||||
if ((t = LabelCheck(s, _T("AUDIO"))) != 0) {
|
||||
isowavTOC->TrackData[track - 1].Control = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pregap
|
||||
if ((t = LabelCheck(s, _T("PREGAP"))) != 0) {
|
||||
s = t;
|
||||
|
||||
int M, S, F;
|
||||
|
||||
// pregap M
|
||||
M = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// pregap S
|
||||
S = _tcstol(s, &t, 10);
|
||||
s = t + 1;
|
||||
// pregap F
|
||||
F = _tcstol(s, &t, 10);
|
||||
|
||||
if (M < 0 || M > 100 || S < 0 || S > 59 || F < 0 || F > 74) {
|
||||
fclose(h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
isowavTOC->TrackData[track - 1].Address[1] = M;
|
||||
isowavTOC->TrackData[track - 1].Address[2] = S;
|
||||
isowavTOC->TrackData[track - 1].Address[3] = F;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(h);
|
||||
|
||||
return isowavGetTrackSizes();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static int isowavExit()
|
||||
{
|
||||
wav_exit();
|
||||
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
|
||||
isowavTrack = 0;
|
||||
isowavLBA = 0;
|
||||
|
||||
if (isowavTOC) {
|
||||
for (int i = 0; i < MAXIMUM_NUMBER_TRACKS; i++) {
|
||||
free(isowavTOC->TrackData[i].Filename);
|
||||
}
|
||||
|
||||
free(isowavTOC);
|
||||
isowavTOC = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavInit()
|
||||
{
|
||||
wav_exit();
|
||||
|
||||
isowavTOC = (isowavCDROM_TOC*)malloc(sizeof(isowavCDROM_TOC));
|
||||
if (isowavTOC == NULL) {
|
||||
return 1;
|
||||
}
|
||||
memset(isowavTOC, 0, sizeof(isowavCDROM_TOC));
|
||||
|
||||
TCHAR* filename = ExtractFilename(CDEmuImage);
|
||||
|
||||
if (_tcslen(filename) < 4) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (_tcscmp(_T(".cue"), filename + _tcslen(filename) - 4) == 0) {
|
||||
if (isowavParseCueFile()) {
|
||||
dprintf(_T("*** Couldn't parse .cue file\n"));
|
||||
isowavExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (isowavTestISO()) {
|
||||
dprintf(_T("*** Couldn't find .iso / .bin file\n"));
|
||||
isowavExit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
dprintf(_T(" CD image TOC read\n"));
|
||||
|
||||
for (int i = isowavTOC->FirstTrack - 1; i < isowavTOC->LastTrack; i++) {
|
||||
dprintf(_T(" track %2i start %02i:%02i:%02i control 0x%02X %s\n"), isowavTOC->TrackData[i].TrackNumber, isowavTOC->TrackData[i].Address[1], isowavTOC->TrackData[i].Address[2], isowavTOC->TrackData[i].Address[3], isowavTOC->TrackData[i].Control, isowavTOC->TrackData[i].Filename);
|
||||
}
|
||||
dprintf(_T(" total running time %02i:%02i:%02i\n"), isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[1], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[2], isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[3]);
|
||||
|
||||
CDEmuStatus = idle;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCHAR* GetIsoPath()
|
||||
{
|
||||
if(isowavTOC) {
|
||||
return isowavTOC->TrackData[0].Filename;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int isowavStop()
|
||||
{
|
||||
wav_stop();
|
||||
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
CDEmuStatus = idle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavPlayLBA(int LBA)
|
||||
{
|
||||
isowavLBA = LBA;
|
||||
|
||||
for (isowavTrack = isowavTOC->FirstTrack - 1; isowavTrack < isowavTOC->LastTrack; isowavTrack++) {
|
||||
if (isowavLBA < isowavMSFToLBA(isowavTOC->TrackData[isowavTrack + 1].Address)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isowavTrack >= isowavTOC->LastTrack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bprintf(PRINT_IMPORTANT, _T(" playing track %2i - %s\n"), isowavTrack + 1, isowavTOC->TrackData[isowavTrack].Filename);
|
||||
|
||||
isowavFile = _tfopen(isowavTOC->TrackData[isowavTrack].Filename, _T("rb"));
|
||||
if (isowavFile == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( _tcsstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".wav")) || _tcsstr(isowavTOC->TrackData[isowavTrack].Filename, _T(".WAV"))) {
|
||||
// is a wav, no need to keep this file pointer
|
||||
if (isowavFile) {
|
||||
fclose(isowavFile);
|
||||
isowavFile = NULL;
|
||||
}
|
||||
|
||||
if(wav_open(isowavTOC->TrackData[isowavTrack].Filename)) {
|
||||
wav_play();
|
||||
} else {
|
||||
// error creating the WAV stream
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//dprintf(_T("*** WAV: wBitsPerSample: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->wBitsPerSample);
|
||||
//dprintf(_T("*** WAV: nAvgBytesPerSec: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nAvgBytesPerSec);
|
||||
//dprintf(_T("*** WAV: m_dwSize: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_dwSize);
|
||||
//dprintf(_T("*** WAV: nBlockAlign: %d \n"), wav->g_pStreamingSound->m_pWaveFile->m_pwfx->nBlockAlign);
|
||||
|
||||
isowavLBA = isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address);
|
||||
CDEmuStatus = playing;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavPlay(unsigned char M, unsigned char S, unsigned char F)
|
||||
{
|
||||
const char address[] = { 0, M, S, F };
|
||||
|
||||
return isowavPlayLBA(isowavMSFToLBA(address));
|
||||
}
|
||||
|
||||
static int isowavLoadSector(int LBA, char* pBuffer)
|
||||
{
|
||||
LBA += CD_FRAMES_PREGAP;
|
||||
|
||||
if (LBA != isowavLBA) {
|
||||
|
||||
int track;
|
||||
|
||||
for (track = isowavTOC->FirstTrack - 1; track < isowavTOC->LastTrack; track++) {
|
||||
if (LBA < isowavMSFToLBA(isowavTOC->TrackData[track + 1].Address)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isowavFile == NULL || track != isowavTrack) {
|
||||
isowavStop();
|
||||
|
||||
isowavTrack = track;
|
||||
|
||||
bprintf(PRINT_IMPORTANT, _T(" reading track %2i - %s\n"), isowavTrack + 1, isowavTOC->TrackData[isowavTrack].Filename);
|
||||
|
||||
isowavFile = _tfopen(isowavTOC->TrackData[isowavTrack].Filename, _T("rb"));
|
||||
if (isowavFile == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (fseek(isowavFile, (LBA - isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address)) * 2048, SEEK_SET)) {
|
||||
dprintf(_T("*** couldn't seek\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
isowavLBA = (ftell(isowavFile) + 2047) / 2048;
|
||||
|
||||
CDEmuStatus = reading;
|
||||
}
|
||||
|
||||
if (fread(pBuffer, 1, 2048, isowavFile) <= 0) {
|
||||
dprintf(_T("*** couldn't read from file\n"));
|
||||
|
||||
isowavStop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
isowavLBA = isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address) + (ftell(isowavFile) + 2047) / 2048;
|
||||
|
||||
return isowavLBA - CD_FRAMES_PREGAP;
|
||||
}
|
||||
|
||||
static unsigned char* isowavReadTOC(int track)
|
||||
{
|
||||
static unsigned char TOCEntry[4];
|
||||
|
||||
if (track == -1) {
|
||||
TOCEntry[0] = isowavTOC->FirstTrack - 1;
|
||||
TOCEntry[1] = isowavTOC->LastTrack;
|
||||
TOCEntry[2] = 0;
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
if (track == -2) {
|
||||
TOCEntry[0] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[1];
|
||||
TOCEntry[1] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[2];
|
||||
TOCEntry[2] = isowavTOC->TrackData[(int)isowavTOC->LastTrack].Address[3];
|
||||
|
||||
TOCEntry[3] = 0;
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
if (track >= isowavTOC->FirstTrack - 1 && track <= isowavTOC->LastTrack) {
|
||||
TOCEntry[0] = isowavTOC->TrackData[track - 1].Address[1];
|
||||
TOCEntry[1] = isowavTOC->TrackData[track - 1].Address[2];
|
||||
TOCEntry[2] = isowavTOC->TrackData[track - 1].Address[3];
|
||||
TOCEntry[3] = isowavTOC->TrackData[track - 1].Control;
|
||||
}
|
||||
|
||||
return TOCEntry;
|
||||
}
|
||||
|
||||
static unsigned char* isowavReadQChannel()
|
||||
{
|
||||
static unsigned char QChannelData[8];
|
||||
|
||||
switch (CDEmuStatus) {
|
||||
case reading:
|
||||
case playing: {
|
||||
const char* AddressAbs = isowavLBAToMSF(isowavLBA);
|
||||
const char* AddressRel = isowavLBAToMSF(isowavLBA - isowavMSFToLBA(isowavTOC->TrackData[isowavTrack].Address));
|
||||
|
||||
QChannelData[0] = isowavTOC->TrackData[isowavTrack].TrackNumber;
|
||||
|
||||
QChannelData[1] = AddressAbs[1];
|
||||
QChannelData[2] = AddressAbs[2];
|
||||
QChannelData[3] = AddressAbs[3];
|
||||
|
||||
QChannelData[4] = AddressRel[1];
|
||||
QChannelData[5] = AddressRel[2];
|
||||
QChannelData[6] = AddressRel[3];
|
||||
|
||||
QChannelData[7] = isowavTOC->TrackData[isowavTrack].Control;
|
||||
|
||||
break;
|
||||
}
|
||||
case paused: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
memset(QChannelData, 0, sizeof(QChannelData));
|
||||
}
|
||||
}
|
||||
|
||||
return QChannelData;
|
||||
}
|
||||
|
||||
static int isowavGetSoundBuffer(short* /*buffer*/, int /*samples*/)
|
||||
{
|
||||
// ---------------------------------------------------------------------
|
||||
// TODO:
|
||||
// Port the old 'isomp3GetSoundBuffer()' function from 'cd_isomp3.cpp'
|
||||
// to use WAVE stream data, porting that function will fix the
|
||||
// 00:00 progress status on the main NeoGeo CD BIOS menu.
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isowavGetSettings(InterfaceInfo* /*pInfo*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct CDEmuDo isowavDo = { isowavExit, isowavInit, isowavStop, isowavPlay, isowavLoadSector, isowavReadTOC, isowavReadQChannel, isowavGetSoundBuffer, isowavGetSettings, _T("cue/iso/wav CD emulation") };
|
@ -1,433 +0,0 @@
|
||||
#include "burner.h"
|
||||
#include "cdsound.h"
|
||||
|
||||
WavClass::WavClass()
|
||||
{
|
||||
m_DirectSound = 0;
|
||||
m_primaryBuffer = 0;
|
||||
m_secondaryBuffer1 = 0;
|
||||
}
|
||||
|
||||
WavClass::WavClass(const WavClass&)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
WavClass::~WavClass()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
bool WavClass::Initialize(HWND hwnd, TCHAR* szFile)
|
||||
{
|
||||
bool result;
|
||||
|
||||
// Initialize direct sound and the primary sound buffer.
|
||||
result = InitializeDirectSound(hwnd);
|
||||
if(!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load a wave audio file onto a secondary buffer.
|
||||
result = LoadWaveFile(szFile, &m_secondaryBuffer1);
|
||||
if(!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WavClass::Shutdown()
|
||||
{
|
||||
// Release the secondary buffer.
|
||||
ShutdownWaveFile(&m_secondaryBuffer1);
|
||||
|
||||
// Shutdown the Direct Sound API.
|
||||
ShutdownDirectSound();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool WavClass::InitializeDirectSound(HWND hwnd)
|
||||
{
|
||||
HRESULT result;
|
||||
DSBUFFERDESC bufferDesc;
|
||||
WAVEFORMATEX waveFormat;
|
||||
|
||||
// Initialize the direct sound interface pointer for the default sound device.
|
||||
result = _DirectSoundCreate(NULL, &m_DirectSound, NULL);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the cooperative level to priority so the format of the primary sound buffer can be modified.
|
||||
result = m_DirectSound->SetCooperativeLevel(hwnd, DSSCL_PRIORITY);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GUID guidNULL;
|
||||
memset(&guidNULL,0,sizeof(GUID));
|
||||
|
||||
// Setup the primary buffer description.
|
||||
bufferDesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
bufferDesc.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRLVOLUME;
|
||||
bufferDesc.dwBufferBytes = 0;
|
||||
bufferDesc.dwReserved = 0;
|
||||
bufferDesc.lpwfxFormat = NULL;
|
||||
bufferDesc.guid3DAlgorithm = guidNULL; //GUID_NULL;
|
||||
|
||||
// Get control of the primary sound buffer on the default sound device.
|
||||
result = m_DirectSound->CreateSoundBuffer(&bufferDesc, &m_primaryBuffer, NULL);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup the format of the primary sound bufffer.
|
||||
// In this case it is a .WAV file recorded at 44,100 samples per second in 16-bit stereo (cd audio format).
|
||||
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
|
||||
waveFormat.nSamplesPerSec = 44100;
|
||||
waveFormat.wBitsPerSample = 16;
|
||||
waveFormat.nChannels = 2;
|
||||
waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels;
|
||||
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
|
||||
waveFormat.cbSize = 0;
|
||||
|
||||
// Set the primary buffer to be the wave format specified.
|
||||
result = m_primaryBuffer->SetFormat(&waveFormat);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WavClass::ShutdownDirectSound()
|
||||
{
|
||||
// Release the primary sound buffer pointer.
|
||||
if(m_primaryBuffer)
|
||||
{
|
||||
m_primaryBuffer->Release();
|
||||
m_primaryBuffer = 0;
|
||||
}
|
||||
|
||||
// Release the direct sound interface pointer.
|
||||
if(m_DirectSound)
|
||||
{
|
||||
m_DirectSound->Release();
|
||||
m_DirectSound = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool WavClass::LoadWaveFile(TCHAR* filename, IDirectSoundBuffer** secondaryBuffer)
|
||||
{
|
||||
FILE* filePtr;
|
||||
unsigned int count;
|
||||
WaveHeaderType waveFileHeader;
|
||||
WAVEFORMATEX waveFormat;
|
||||
DSBUFFERDESC bufferDesc;
|
||||
HRESULT result;
|
||||
IDirectSoundBuffer* tempBuffer;
|
||||
unsigned char* waveData;
|
||||
unsigned char* bufferPtr;
|
||||
unsigned long bufferSize;
|
||||
|
||||
|
||||
// Open the wave file in binary.
|
||||
filePtr = _tfopen(filename, _T("rb"));
|
||||
if(!filePtr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in the wave file header.
|
||||
count = fread(&waveFileHeader, sizeof(waveFileHeader), 1, filePtr);
|
||||
if(count != 1)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the chunk ID is the RIFF format.
|
||||
if((waveFileHeader.chunkId[0] != 'R') || (waveFileHeader.chunkId[1] != 'I') ||
|
||||
(waveFileHeader.chunkId[2] != 'F') || (waveFileHeader.chunkId[3] != 'F'))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the file format is the WAVE format.
|
||||
if((waveFileHeader.format[0] != 'W') || (waveFileHeader.format[1] != 'A') ||
|
||||
(waveFileHeader.format[2] != 'V') || (waveFileHeader.format[3] != 'E'))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the sub chunk ID is the fmt format.
|
||||
if((waveFileHeader.subChunkId[0] != 'f') || (waveFileHeader.subChunkId[1] != 'm') ||
|
||||
(waveFileHeader.subChunkId[2] != 't') || (waveFileHeader.subChunkId[3] != ' '))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the audio format is WAVE_FORMAT_PCM.
|
||||
if(waveFileHeader.audioFormat != WAVE_FORMAT_PCM)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the wave file was recorded in stereo format.
|
||||
if(waveFileHeader.numChannels != 2)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the wave file was recorded at a sample rate of 44.1 KHz.
|
||||
if(waveFileHeader.sampleRate != 44100)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure that the wave file was recorded in 16 bit format.
|
||||
if(waveFileHeader.bitsPerSample != 16)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for the data chunk header.
|
||||
if((waveFileHeader.dataChunkId[0] != 'd') || (waveFileHeader.dataChunkId[1] != 'a') ||
|
||||
(waveFileHeader.dataChunkId[2] != 't') || (waveFileHeader.dataChunkId[3] != 'a'))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the wave format of secondary buffer that this wave file will be loaded onto.
|
||||
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
|
||||
waveFormat.nSamplesPerSec = 44100;
|
||||
waveFormat.wBitsPerSample = 16;
|
||||
waveFormat.nChannels = 2;
|
||||
waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels;
|
||||
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
|
||||
waveFormat.cbSize = 0;
|
||||
|
||||
GUID guidNULL;
|
||||
memset(&guidNULL,0,sizeof(GUID));
|
||||
|
||||
// Set the buffer description of the secondary sound buffer that the wave file will be loaded onto.
|
||||
bufferDesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
bufferDesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
|
||||
bufferDesc.dwBufferBytes = waveFileHeader.dataSize;
|
||||
bufferDesc.dwReserved = 0;
|
||||
bufferDesc.lpwfxFormat = &waveFormat;
|
||||
bufferDesc.guid3DAlgorithm = guidNULL; //GUID_NULL;
|
||||
|
||||
// Create a temporary sound buffer with the specific buffer settings.
|
||||
result = m_DirectSound->CreateSoundBuffer(&bufferDesc, &tempBuffer, NULL);
|
||||
if(FAILED(result))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test the buffer format against the direct sound 8 interface and create the secondary buffer.
|
||||
result = tempBuffer->QueryInterface(IID_IDirectSoundBuffer, (void**)&*secondaryBuffer);
|
||||
if(FAILED(result))
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Release the temporary buffer.
|
||||
tempBuffer->Release();
|
||||
tempBuffer = 0;
|
||||
|
||||
// Move to the beginning of the wave data which starts at the end of the data chunk header.
|
||||
fseek(filePtr, sizeof(WaveHeaderType), SEEK_SET);
|
||||
|
||||
// Create a temporary buffer to hold the wave file data.
|
||||
waveData = new unsigned char[waveFileHeader.dataSize];
|
||||
if(!waveData)
|
||||
{
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in the wave file data into the newly created buffer.
|
||||
count = fread(waveData, 1, waveFileHeader.dataSize, filePtr);
|
||||
if(count != waveFileHeader.dataSize)
|
||||
{
|
||||
delete [] waveData;
|
||||
waveData = 0;
|
||||
|
||||
fclose(filePtr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Close the file once done reading.
|
||||
int error = fclose(filePtr);
|
||||
if(error != 0)
|
||||
{
|
||||
delete [] waveData;
|
||||
waveData = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lock the secondary buffer to write wave data into it.
|
||||
result = (*secondaryBuffer)->Lock(0, waveFileHeader.dataSize, (void**)&bufferPtr, (DWORD*)&bufferSize, NULL, 0, 0);
|
||||
if(FAILED(result))
|
||||
{
|
||||
delete [] waveData;
|
||||
waveData = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy the wave data into the buffer.
|
||||
memcpy(bufferPtr, waveData, waveFileHeader.dataSize);
|
||||
|
||||
// Unlock the secondary buffer after the data has been written to it.
|
||||
result = (*secondaryBuffer)->Unlock((void*)bufferPtr, bufferSize, NULL, 0);
|
||||
if(FAILED(result))
|
||||
{
|
||||
delete [] waveData;
|
||||
waveData = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Release the wave data since it was copied into the secondary buffer.
|
||||
delete [] waveData;
|
||||
waveData = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WavClass::ShutdownWaveFile(IDirectSoundBuffer** secondaryBuffer)
|
||||
{
|
||||
// Release the secondary sound buffer.
|
||||
if(*secondaryBuffer)
|
||||
{
|
||||
(*secondaryBuffer)->Release();
|
||||
*secondaryBuffer = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#include "cd_interface.h"
|
||||
|
||||
WavClass* wav;
|
||||
extern HWND hScrnWnd;
|
||||
|
||||
void wav_exit()
|
||||
{
|
||||
if(wav) {
|
||||
wav_stop();
|
||||
wav->Shutdown();
|
||||
wav = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int wav_open(TCHAR* szFile)
|
||||
{
|
||||
wav_exit();
|
||||
|
||||
if(hScrnWnd) {
|
||||
wav = new WavClass;
|
||||
wav->Initialize(hScrnWnd, szFile);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void wav_stop()
|
||||
{
|
||||
if(!wav) return;
|
||||
|
||||
wav->GetSecondaryBuffer()->Stop();
|
||||
wav->GetSecondaryBuffer()->SetCurrentPosition( 0 );
|
||||
}
|
||||
|
||||
void wav_play()
|
||||
{
|
||||
if(!wav) return;
|
||||
|
||||
HRESULT result;
|
||||
|
||||
// Play the contents of the secondary sound buffer.
|
||||
IDirectSoundBuffer* m_secondaryBuffer1 = wav->GetSecondaryBuffer();
|
||||
if(!m_secondaryBuffer1) {
|
||||
//
|
||||
return;
|
||||
}
|
||||
|
||||
// Set volume of the buffer to 100%.
|
||||
result = m_secondaryBuffer1->SetVolume(DSBVOLUME_MAX);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
result = m_secondaryBuffer1->Play(0, 0, DSBPLAY_LOOPING);
|
||||
if(FAILED(result)) {
|
||||
//
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void wav_pause(bool bResume)
|
||||
{
|
||||
if(!wav) return;
|
||||
|
||||
if(!bResume)
|
||||
{
|
||||
DWORD pdwStatus;
|
||||
wav->GetSecondaryBuffer()->GetStatus(&pdwStatus);
|
||||
if((pdwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
||||
{
|
||||
HRESULT result;
|
||||
result = wav->GetSecondaryBuffer()->Stop();
|
||||
if(FAILED(result)) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
DWORD pdwStatus;
|
||||
wav->GetSecondaryBuffer()->GetStatus(&pdwStatus);
|
||||
if((pdwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)
|
||||
{
|
||||
if(CDEmuGetStatus() == playing)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
// Set volume of the buffer to 100%.
|
||||
result = wav->GetSecondaryBuffer()->SetVolume(DSBVOLUME_MAX);
|
||||
if(FAILED(result))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
result = wav->GetSecondaryBuffer()->Play(0, 0, DSBPLAY_LOOPING);
|
||||
if(FAILED(result)) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
#ifndef _WavClass_H_
|
||||
#define _WavClass_H_
|
||||
|
||||
//#include <dsound.h>
|
||||
#include "dsound_core.h"
|
||||
|
||||
class WavClass
|
||||
{
|
||||
private:
|
||||
struct WaveHeaderType
|
||||
{
|
||||
char chunkId[4];
|
||||
unsigned long chunkSize;
|
||||
char format[4];
|
||||
char subChunkId[4];
|
||||
unsigned long subChunkSize;
|
||||
unsigned short audioFormat;
|
||||
unsigned short numChannels;
|
||||
unsigned long sampleRate;
|
||||
unsigned long bytesPerSecond;
|
||||
unsigned short blockAlign;
|
||||
unsigned short bitsPerSample;
|
||||
char dataChunkId[4];
|
||||
unsigned long dataSize;
|
||||
};
|
||||
|
||||
public:
|
||||
WavClass();
|
||||
WavClass(const WavClass&);
|
||||
~WavClass();
|
||||
|
||||
bool Initialize(HWND, TCHAR*);
|
||||
void Shutdown();
|
||||
|
||||
bool InitializeDirectSound(HWND);
|
||||
void ShutdownDirectSound();
|
||||
|
||||
bool LoadWaveFile(TCHAR*, IDirectSoundBuffer**);
|
||||
void ShutdownWaveFile(IDirectSoundBuffer**);
|
||||
|
||||
bool PlayWaveFile();
|
||||
|
||||
IDirectSound* GetDirectSound() { return m_DirectSound; }
|
||||
IDirectSoundBuffer* GetPrimaryBuffer() { return m_primaryBuffer; }
|
||||
IDirectSoundBuffer* GetSecondaryBuffer() { return m_secondaryBuffer1; }
|
||||
|
||||
private:
|
||||
IDirectSound* m_DirectSound;
|
||||
IDirectSoundBuffer* m_primaryBuffer;
|
||||
IDirectSoundBuffer* m_secondaryBuffer1;
|
||||
};
|
||||
|
||||
void wav_exit();
|
||||
int wav_open(TCHAR* szFile);
|
||||
void wav_stop();
|
||||
void wav_play();
|
||||
void wav_pause(bool bResume);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user