This commit is contained in:
Kev 2018-12-27 10:50:35 +00:00
commit c75f7f5153
18 changed files with 3279 additions and 337 deletions

View File

@ -203,6 +203,7 @@ extern UINT8 DebugSnd_YM2612Initted;
extern UINT8 DebugSnd_YM3526Initted;
extern UINT8 DebugSnd_YM3812Initted;
extern UINT8 DebugSnd_YMF278BInitted;
extern UINT8 DebugSnd_YMF262Initted;
extern UINT8 DebugSnd_C6280Initted;
extern UINT8 DebugSnd_DACInitted;
extern UINT8 DebugSnd_ES5506Initted;

View File

@ -33,6 +33,7 @@ UINT8 DebugSnd_YM2612Initted;
UINT8 DebugSnd_YM3526Initted;
UINT8 DebugSnd_YM3812Initted;
UINT8 DebugSnd_YMF278BInitted;
UINT8 DebugSnd_YMF262Initted;
UINT8 DebugSnd_C6280Initted;
UINT8 DebugSnd_DACInitted;
UINT8 DebugSnd_ES5506Initted;
@ -110,6 +111,7 @@ void DebugTrackerExit()
if (DebugSnd_YM3526Initted) bprintf(PRINT_ERROR, _T("Sound Module YM3526 Not Exited\n"));
if (DebugSnd_YM3812Initted) bprintf(PRINT_ERROR, _T("Sound Module YM3812 Not Exited\n"));
if (DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("Sound Module YMF278B Not Exited\n"));
if (DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("Sound Module YMF262 Not Exited\n"));
if (DebugSnd_C6280Initted) bprintf(PRINT_ERROR, _T("Sound Module C6280 Not Exited\n"));
if (DebugSnd_DACInitted) bprintf(PRINT_ERROR, _T("Sound Module DAC Not Exited\n"));
if (DebugSnd_ES5506Initted) bprintf(PRINT_ERROR, _T("Sound Module ES5506 Not Exited\n"));

View File

@ -555,7 +555,7 @@ static void draw_pf23_layer_rowscroll(INT32 scroll_x, INT32 scroll_y)
for (INT32 y = 8; y < 248; y++)
{
INT32 row = (scroll_y + y) >> 4;
INT32 xscr = scroll_x + (BURN_ENDIAN_SWAP_INT16(rows[0x40+y]) & 0x3ff);
INT32 xscr = scroll_x + (BURN_ENDIAN_SWAP_INT16(rows[0x40+(y/2)]) & 0x3ff);
dest = pTransDraw + ((y-8) * nScreenWidth);
for (INT32 x = 0; x < 256+16; x+=16)

View File

@ -818,8 +818,11 @@ static void DrvPaletteInit()
static INT32 DrvDraw()
{
DrvPaletteInit();
// extern int counter;
if (DrvRecalc) {
DrvPaletteInit();
DrvRecalc = 0;
}
vector_set_clip(0x20, nScreenWidth-0x20, 0, nScreenHeight);
draw_vector(DrvPalette);

View File

@ -644,7 +644,7 @@ static INT32 DrvDraw()
{
if (DrvRecalc) {
DrvPaletteUpdate();
DrvRecalc = 1; // force update
DrvRecalc = 1; // force update (palram)
}
BurnTransferClear();

View File

@ -982,7 +982,10 @@ static void DrvPaletteInit()
static INT32 DrvDraw()
{
DrvPaletteInit();
if (DrvRecalc) {
DrvPaletteInit();
DrvRecalc = 0;
}
draw_vector(DrvPalette);

View File

@ -443,7 +443,10 @@ static void DrvPaletteInit()
static INT32 DrvDraw()
{
DrvPaletteInit();
if (DrvRecalc) {
DrvPaletteInit();
DrvRecalc = 0;
}
draw_vector(DrvPalette);

View File

@ -5,6 +5,7 @@
#include "m68000_intf.h"
#include "z80_intf.h"
#include "burn_ymf278b.h"
#include "burn_ymf262.h"
static UINT8 *AllMem;
static UINT8 *MemEnd;
@ -415,13 +416,16 @@ static void __fastcall fuuki32_sound_out(UINT16 port, UINT8 data)
return;
case 0x40:
case 0x41:
case 0x42:
case 0x43:
BurnYMF262Write(port&3, data);
return;
case 0x44:
BurnYMF278BSelectRegister((port >> 1) & 3, data);
return;
case 0x41:
case 0x43:
case 0x45:
BurnYMF278BWriteRegister((port >> 1) & 3, data);
return;
@ -433,7 +437,7 @@ static UINT8 __fastcall fuuki32_sound_in(UINT16 port)
switch (port & 0xff)
{
case 0x40:
return BurnYMF278BReadStatus();
return BurnYMF262Read(0);
}
return 0;
@ -459,9 +463,9 @@ static INT32 DrvDoReset()
ZetOpen(0);
ZetReset();
ZetClose();
BurnYMF278BReset();
BurnYMF262Reset();
ZetClose();
return 0;
}
@ -669,13 +673,13 @@ static INT32 DrvInit()
ZetSetInHandler(fuuki32_sound_in);
ZetClose();
if (asurablade) {
BurnYMF278BInit((INT32)(YMF278B_STD_CLOCK * 1.93) | 0x80000000, DrvSndROM, 0x400000, &DrvFMIRQHandler, DrvSynchroniseStream);
} else {
BurnYMF278BInit((INT32)(YMF278B_STD_CLOCK * 1.80) | 0x80000000, DrvSndROM, 0x400000, &DrvFMIRQHandler, DrvSynchroniseStream);
}
BurnYMF278BInit(0, DrvSndROM, 0x400000, NULL, DrvSynchroniseStream);
BurnYMF278BSetRoute(BURN_SND_YMF278B_YMF278B_ROUTE_1, 0.50, BURN_SND_ROUTE_LEFT);
BurnYMF278BSetRoute(BURN_SND_YMF278B_YMF278B_ROUTE_2, 0.50, BURN_SND_ROUTE_RIGHT);
BurnYMF262Init(14318180, &DrvFMIRQHandler, DrvSynchroniseStream, 1);
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_1, 0.50, BURN_SND_ROUTE_LEFT);
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_2, 0.50, BURN_SND_ROUTE_RIGHT);
BurnTimerAttachZet(6000000);
GenericTilesInit();
@ -689,6 +693,7 @@ static INT32 DrvExit()
{
GenericTilesExit();
BurnYMF262Exit();
BurnYMF278BExit();
SekExit();
ZetExit();
@ -1281,7 +1286,7 @@ static INT32 DrvFrame()
if (i == 248) SekSetIRQLine(1, CPU_IRQSTATUS_AUTO); // level 1
if (i == 240) SekSetIRQLine(3, CPU_IRQSTATUS_AUTO); // vblank
cpu_sync(); // sync soundcpu
BurnTimerUpdate((i + 1) * nCyclesTotal[1] / nInterleave);
// hack -- save scroll/offset registers so the
// lines can be drawn in one pass -- should save
@ -1305,6 +1310,7 @@ static INT32 DrvFrame()
if (pBurnSoundOut) {
BurnYMF278BUpdate(nBurnSoundLen);
BurnYMF262Update(nBurnSoundLen);
}
ZetClose();
@ -1334,6 +1340,7 @@ static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
ZetScan(nAction);
BurnYMF278BScan(nAction, pnMin);
BurnYMF262Scan(nAction, pnMin);
}
if (nAction & ACB_WRITE) {

View File

@ -6,13 +6,9 @@
#include "msm6295.h"
#include "eeprom.h"
#include "ymz280b.h"
// ymf262
//#define ENABLE_SOUND_HARDWARE // no sound without ymf262 core anyway...
#ifdef ENABLE_SOUND_HARDWARE
#include "burn_ymf262.h"
#include "z80_intf.h"
#endif
#include "watchdog.h"
static UINT8 *AllMem;
static UINT8 *MemEnd;
@ -42,7 +38,6 @@ static UINT8 *DrvB0Regs;
static UINT8 *DrvC0Regs;
static UINT8 *DrvC8Regs;
#ifdef ENABLE_SOUND_HARDWARE
static UINT8 *DrvZ80ROM;
static UINT8 *DrvZ80RAM;
static UINT8 *DrvSndROM0;
@ -51,7 +46,6 @@ static UINT8 *DrvOkiBank;
static UINT8 *DrvZ80Bank;
static UINT8 *soundlatch;
static UINT8 *soundlatch2;
#endif
static UINT8 protection_read_pointer;
static UINT8 protection_status;
@ -69,15 +63,14 @@ static UINT8 DrvReset;
static UINT16 DrvInputs[2];
static INT32 vblank;
static INT32 watchdog;
static INT32 deroon;
static struct BurnInputInfo DrvInputList[] = {
{"P1 Coin", BIT_DIGITAL, DrvJoy1 + 8, "p1 coin" },
{"P1 Coin", BIT_DIGITAL, DrvJoy1 + 8, "p1 coin" },
{"P1 Start", BIT_DIGITAL, DrvJoy1 + 7, "p1 start" },
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up" },
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down" },
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left" },
{"P1 Up", BIT_DIGITAL, DrvJoy1 + 0, "p1 up" },
{"P1 Down", BIT_DIGITAL, DrvJoy1 + 1, "p1 down" },
{"P1 Left", BIT_DIGITAL, DrvJoy1 + 2, "p1 left" },
{"P1 Right", BIT_DIGITAL, DrvJoy1 + 3, "p1 right" },
{"P1 Button 1", BIT_DIGITAL, DrvJoy1 + 4, "p1 fire 1" },
{"P1 Button 2", BIT_DIGITAL, DrvJoy1 + 5, "p1 fire 2" },
@ -85,18 +78,18 @@ static struct BurnInputInfo DrvInputList[] = {
{"P1 Button 4", BIT_DIGITAL, DrvJoy1 + 10, "p1 fire 4" },
{"P2 Start", BIT_DIGITAL, DrvJoy2 + 7, "p2 start" },
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up" },
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down" },
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left" },
{"P2 Up", BIT_DIGITAL, DrvJoy2 + 0, "p2 up" },
{"P2 Down", BIT_DIGITAL, DrvJoy2 + 1, "p2 down" },
{"P2 Left", BIT_DIGITAL, DrvJoy2 + 2, "p2 left" },
{"P2 Right", BIT_DIGITAL, DrvJoy2 + 3, "p2 right" },
{"P2 Button 1", BIT_DIGITAL, DrvJoy2 + 4, "p2 fire 1" },
{"P2 Button 2", BIT_DIGITAL, DrvJoy2 + 5, "p2 fire 2" },
{"P2 Button 3", BIT_DIGITAL, DrvJoy2 + 6, "p2 fire 3" },
{"P2 Button 4", BIT_DIGITAL, DrvJoy2 + 10, "p2 fire 4" },
{"Reset", BIT_DIGITAL, &DrvReset, "reset" },
{"Service 1", BIT_DIGITAL, DrvJoy1 + 9, "service" },
{"Service 2", BIT_DIGITAL, DrvJoy2 + 9, "service" },
{"Reset", BIT_DIGITAL, &DrvReset, "reset" },
{"Service Mode", BIT_DIGITAL, DrvJoy1 + 9, "diag" },
{"Service", BIT_DIGITAL, DrvJoy2 + 9, "service" },
};
STDINPUTINFO(Drv)
@ -129,7 +122,7 @@ static void protection_reset()
static void tecmosys_prot_data_write(INT32 data)
{
static const UINT8 ranges[] = {
static const UINT8 ranges[] = {
0x10,0x11,0x12,0x13,0x24,0x25,0x26,0x27,0x38,0x39,0x3a,0x3b,0x4c,0x4d,0x4e,0x4f, 0x00
};
@ -195,7 +188,16 @@ static void tecmosys_prot_data_write(INT32 data)
}
}
void __fastcall tecmosys_main_write_word(UINT32 address, UINT16 data)
static inline void cpu_sync() // sync z80 & 68k
{
INT32 t = (SekTotalCycles() / 2) - ZetTotalCycles();
if (t > 0) {
BurnTimerUpdate(t);
}
}
static void __fastcall tecmosys_main_write_word(UINT32 address, UINT16 data)
{
switch (address)
{
@ -209,7 +211,7 @@ void __fastcall tecmosys_main_write_word(UINT32 address, UINT16 data)
return;
case 0x880022:
watchdog = 0;
BurnWatchdogWrite();
return;
case 0xa00000:
@ -244,30 +246,30 @@ void __fastcall tecmosys_main_write_word(UINT32 address, UINT16 data)
return;
case 0xe00000:
#ifdef ENABLE_SOUND_HARDWARE
ZetRun((SekTotalCycles() / 2) - ZetTotalCycles());
cpu_sync();
*soundlatch = data & 0xff;
ZetNmi();
#endif
return;
case 0xe80000:
tecmosys_prot_data_write(data >> 8);
return;
}
//bprintf(0, _T("ww: %X %x\n"), address, data);
}
void __fastcall tecmosys_main_write_byte(UINT32 /*address*/, UINT8 /*data*/)
static void __fastcall tecmosys_main_write_byte(UINT32 address, UINT8 data)
{
//bprintf(0, _T("wb: %X %x\n"), address, data);
}
UINT16 __fastcall tecmosys_main_read_word(UINT32 address)
static UINT16 __fastcall tecmosys_main_read_word(UINT32 address)
{
switch (address)
{
case 0x880000:
return vblank;
return vblank ^ 1;
case 0xd00000:
return DrvInputs[0];
@ -279,12 +281,8 @@ UINT16 __fastcall tecmosys_main_read_word(UINT32 address)
return (EEPROMRead() & 1) << 11;
case 0xf00000:
#ifdef ENABLE_SOUND_HARDWARE
ZetRun((SekTotalCycles() / 2) - ZetTotalCycles());
cpu_sync();
return *soundlatch2;
#else
return 0;
#endif
case 0xf80000:
INT32 ret = protection_value;
@ -295,7 +293,7 @@ UINT16 __fastcall tecmosys_main_read_word(UINT32 address)
return 0;
}
UINT8 __fastcall tecmosys_main_read_byte(UINT32 address)
static UINT8 __fastcall tecmosys_main_read_byte(UINT32 address)
{
switch (address)
{
@ -303,6 +301,8 @@ UINT8 __fastcall tecmosys_main_read_byte(UINT32 address)
return 0x00; // protection status
}
//bprintf(0, _T("rb: %X %x\n"), address);
return 0;
}
@ -322,7 +322,7 @@ static inline void palette_update(INT32 pal)
DrvPalette24[pal] = (r << 16) + (g << 8) + b;
}
void __fastcall tecmosys_palette_write_word(UINT32 address, UINT16 data)
static void __fastcall tecmosys_palette_write_word(UINT32 address, UINT16 data)
{
if ((address & 0xff8000) == 0x900000) {
*((UINT16 *)(DrvPalRAM + 0x0000 + (address & 0x7ffe))) = BURN_ENDIAN_SWAP_INT16(data);
@ -337,7 +337,7 @@ void __fastcall tecmosys_palette_write_word(UINT32 address, UINT16 data)
}
}
void __fastcall tecmosys_palette_write_byte(UINT32 address, UINT8 data)
static void __fastcall tecmosys_palette_write_byte(UINT32 address, UINT8 data)
{
if ((address & 0xff8000) == 0x900000) {
DrvPalRAM[(0x0000 + (address & 0x7fff)) ^ 1] = data;
@ -352,38 +352,25 @@ void __fastcall tecmosys_palette_write_byte(UINT32 address, UINT8 data)
}
}
#ifdef ENABLE_SOUND_HARDWARE
static void bankswitch(INT32 data)
{
if ((data & 0x0f) != *DrvZ80Bank) {
ZetMapArea(0x8000, 0xbfff, 0, DrvZ80ROM + (data & 0x0f) * 0x4000);
ZetMapArea(0x8000, 0xbfff, 2, DrvZ80ROM + (data & 0x0f) * 0x4000);
}
ZetMapMemory(DrvZ80ROM + (data & 0x0f) * 0x4000, 0x8000, 0xbfff, MAP_ROM);
*DrvZ80Bank = data & 0x0f;
}
static void oki_bankswitch(INT32 data)
{
if ((data & 0x33) != *DrvOkiBank) {
INT32 upperbank = (data & 0x30) >> 4;
INT32 lowerbank = (data & 0x03) >> 0;
INT32 upperbank = (data & 0x30) >> 4;
INT32 lowerbank = (data & 0x03) >> 0;
if (lowerbank != ((*DrvOkiBank & 0x0f) >> 0)) {
memcpy (DrvSndROM0 + 0x00000, DrvSndROM0 + 0x80000 + lowerbank * 0x20000, 0x20000);
}
if (upperbank != ((*DrvOkiBank & 0xf0) >> 4)) {
memcpy (DrvSndROM0 +0x20000, DrvSndROM0 + 0x80000 + upperbank * 0x20000, 0x20000);
}
}
MSM6295SetBank(0, DrvSndROM0 + lowerbank * 0x20000, 0x00000, 0x1ffff);
MSM6295SetBank(0, DrvSndROM0 + upperbank * 0x20000, 0x20000, 0x3ffff);
*DrvOkiBank = data & 0x33;
}
void __fastcall tecmosys_sound_out(UINT16 port, UINT8 data)
static void __fastcall tecmosys_sound_out(UINT16 port, UINT8 data)
{
switch (port & 0xff)
{
@ -391,7 +378,7 @@ void __fastcall tecmosys_sound_out(UINT16 port, UINT8 data)
case 0x01:
case 0x02:
case 0x03:
// ymf262_w
BurnYMF262Write(port & 3, data);
return;
case 0x10:
@ -411,16 +398,13 @@ void __fastcall tecmosys_sound_out(UINT16 port, UINT8 data)
return;
case 0x60:
YMZ280BSelectRegister(data);
return;
case 0x61:
YMZ280BWriteRegister(data);
YMZ280BWrite(port & 1, data);
return;
}
}
UINT8 __fastcall tecmosys_sound_in(UINT16 port)
static UINT8 __fastcall tecmosys_sound_in(UINT16 port)
{
switch (port & 0xff)
{
@ -428,7 +412,7 @@ UINT8 __fastcall tecmosys_sound_in(UINT16 port)
case 0x01:
case 0x02:
case 0x03:
return 0; // ymf262_r
return BurnYMF262Read(port & 3);
case 0x10:
return MSM6295Read(0);
@ -438,29 +422,26 @@ UINT8 __fastcall tecmosys_sound_in(UINT16 port)
case 0x60:
case 0x61:
return YMZ280BReadStatus();
return YMZ280BRead(port & 1);
}
return 0;
}
/*
static void DrvIrqHandler(INT32 irq) // for ymf262
static void DrvFMIRQHandler(INT32, INT32 nStatus)
{
if (irq) {
ZetSetIRQLine(0xff, CPU_IRQSTATUS_ACK);
} else {
ZetSetIRQLine(0, CPU_IRQSTATUS_NONE);
}
ZetSetIRQLine(0, (nStatus) ? CPU_IRQSTATUS_ACK : CPU_IRQSTATUS_NONE);
}
*/
#endif
static INT32 DrvDoReset(INT32 full_reset)
static INT32 DrvSynchroniseStream(INT32 nSoundRate)
{
if (full_reset) {
memset (AllRam, 0, RamEnd - AllRam);
return (INT64)ZetTotalCycles() * nSoundRate / 8000000;
}
static INT32 DrvDoReset(INT32 clear_mem)
{
if (clear_mem) {
memset(AllRam, 0, RamEnd - AllRam);
}
SekOpen(0);
@ -471,30 +452,23 @@ static INT32 DrvDoReset(INT32 full_reset)
protection_reset();
watchdog = 0;
BurnWatchdogReset();
#ifdef ENABLE_SOUND_HARDWARE
ZetOpen(0);
bankswitch(0);
ZetReset();
BurnYMF262Reset();
ZetClose();
// ymf262
YMZ280BReset();
MSM6295Reset(0);
*DrvOkiBank = *DrvZ80Bank = ~0;
#endif
MSM6295Reset();
oki_bankswitch(0);
return 0;
}
#ifdef ENABLE_SOUND_HARDWARE
static INT32 MemIndex(INT32 sndlen)
#else
static INT32 MemIndex(INT32 /*sndlen*/)
#endif
{
UINT8 *Next; Next = AllMem;
Drv68KROM = Next; Next += 0x100000;
@ -504,7 +478,6 @@ static INT32 MemIndex(INT32 /*sndlen*/)
DrvGfxROM2 = Next; Next += 0x200000;
DrvGfxROM3 = Next; Next += 0x200000;
#ifdef ENABLE_SOUND_HARDWARE
DrvZ80ROM = Next; Next += 0x040000;
MSM6295ROM = Next;
@ -512,12 +485,11 @@ static INT32 MemIndex(INT32 /*sndlen*/)
YMZ280BROM = Next;
DrvSndROM1 = Next; Next += sndlen;
#endif
DrvPalette = (UINT32*)Next; Next += 0x4800 * sizeof(UINT32);
DrvPalette24 = (UINT32*)Next; Next += 0x4800 * sizeof(UINT32);
DrvPalette24 = (UINT32*)Next; Next += 0x4800 * sizeof(UINT32);
DrvTmpSprites = (UINT16*)Next; Next += 320 * 240 * sizeof(UINT16);
DrvTmpSprites = (UINT16*)Next; Next += 320 * 256 * sizeof(UINT16);
AllRam = Next;
@ -528,23 +500,22 @@ static INT32 MemIndex(INT32 /*sndlen*/)
DrvTxtRAM = Next; Next += 0x004000;
DrvBgRAM0 = Next; Next += 0x001000;
DrvBgScrRAM0 = Next; Next += 0x000400;
DrvBgScrRAM0 = Next; Next += 0x000400;
DrvBgRAM1 = Next; Next += 0x001000;
DrvBgScrRAM1 = Next; Next += 0x000400;
DrvBgScrRAM1 = Next; Next += 0x000400;
DrvBgRAM2 = Next; Next += 0x001000;
DrvBgScrRAM2 = Next; Next += 0x000400;
DrvBgScrRAM2 = Next; Next += 0x000400;
#ifdef ENABLE_SOUND_HARDWARE
DrvOkiBank = Next; Next += 0x000001;
DrvZ80Bank = Next; Next += 0x000001;
DrvOkiBank = Next; Next += 0x000001 * sizeof(UINT32);
DrvZ80Bank = Next; Next += 0x000001 * sizeof(UINT32);
DrvZ80RAM = Next; Next += 0x001800;
soundlatch = Next; Next += 0x000001;
soundlatch2 = Next; Next += 0x000001;
#endif
spritelist_select = Next; Next += 0x000001;
soundlatch = Next; Next += 0x000001 * sizeof(UINT32);
soundlatch2 = Next; Next += 0x000001 * sizeof(UINT32);
spritelist_select = Next; Next += 0x000001 * sizeof(UINT32);
Drv88Regs = Next; Next += 0x000004;
DrvA8Regs = Next; Next += 0x000006;
@ -649,29 +620,29 @@ static INT32 CommonInit(INT32 (*pRomLoadCallback)(), INT32 spritelen, INT32 sndl
EEPROMInit(&eeprom_interface_93C46);
BurnWatchdogInit(DrvDoReset, 400);
BurnSetRefreshRate(57.4458);
#ifdef ENABLE_SOUND_HARDWARE
ZetInit(0);
ZetOpen(0);
ZetMapArea(0x0000, 0x7fff, 0, DrvZ80ROM);
ZetMapArea(0x0000, 0x7fff, 2, DrvZ80ROM);
ZetMapArea(0xe000, 0xf7ff, 0, DrvZ80RAM);
ZetMapArea(0xe000, 0xf7ff, 1, DrvZ80RAM);
ZetMapArea(0xe000, 0xf7ff, 2, DrvZ80RAM);
ZetMapMemory(DrvZ80ROM, 0x0000, 0x7fff, MAP_ROM);
ZetMapMemory(DrvZ80RAM, 0xe000, 0xf7ff, MAP_RAM);
ZetSetOutHandler(tecmosys_sound_out);
ZetSetInHandler(tecmosys_sound_in);
ZetClose();
// ymf262
BurnYMF262Init(14318180, &DrvFMIRQHandler, DrvSynchroniseStream, 1);
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
BurnTimerAttachZet(8000000);
YMZ280BInit(16900000, NULL);
YMZ280BInit(16934400, NULL, sndlen);
YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_1, 0.30, BURN_SND_ROUTE_LEFT);
YMZ280BSetRoute(BURN_SND_YMZ280B_YMZ280B_ROUTE_2, 0.30, BURN_SND_ROUTE_RIGHT);
MSM6295Init(0, 2000000 / 132, 1);
MSM6295SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
#endif
GenericTilesInit();
@ -688,17 +659,15 @@ static INT32 DrvExit()
SekExit();
#ifdef ENABLE_SOUND_HARDWARE
ZetExit();
// ymf262
BurnYMF262Exit();
MSM6295Exit(0);
MSM6295Exit();
MSM6295ROM = NULL;
YMZ280BExit();
YMZ280BROM = NULL;
#endif
BurnFree (DrvSprROM);
BurnFree (AllMem);
@ -730,13 +699,13 @@ static void draw_character_layer()
if (flipx) {
Render8x8Tile_Mask_FlipXY(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
} else {
Render8x8Tile_Mask_FlipY(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
Render8x8Tile_Mask_FlipY(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
}
} else {
if (flipx) {
Render8x8Tile_Mask_FlipX(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
} else {
Render8x8Tile_Mask(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
Render8x8Tile_Mask(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
}
}
} else {
@ -744,13 +713,13 @@ static void draw_character_layer()
if (flipx) {
Render8x8Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
} else {
Render8x8Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
Render8x8Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
}
} else {
if (flipx) {
Render8x8Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
} else {
Render8x8Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
Render8x8Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0, 0xc400, DrvGfxROM0);
}
}
}
@ -789,13 +758,13 @@ static void draw_background_layer(UINT8 *ram, UINT8 *gfx, UINT8 *regs, INT32 yof
if (flipx) {
Render16x16Tile_Mask_FlipXY(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
} else {
Render16x16Tile_Mask_FlipY(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
Render16x16Tile_Mask_FlipY(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
}
} else {
if (flipx) {
Render16x16Tile_Mask_FlipX(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
} else {
Render16x16Tile_Mask(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
Render16x16Tile_Mask(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
}
}
} else {
@ -803,13 +772,13 @@ static void draw_background_layer(UINT8 *ram, UINT8 *gfx, UINT8 *regs, INT32 yof
if (flipx) {
Render16x16Tile_Mask_FlipXY_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
} else {
Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
Render16x16Tile_Mask_FlipY_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
}
} else {
if (flipx) {
Render16x16Tile_Mask_FlipX_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
} else {
Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
Render16x16Tile_Mask_Clip(pTransDraw, code, sx, sy, color, 4, 0, priority, gfx);
}
}
}
@ -876,7 +845,7 @@ static void draw_sprite_nozoom(INT32 addr, INT32 color, INT32 x, INT32 y, INT32
for (INT32 xcnt = 0; xcnt < xsize; xcnt++)
{
INT32 data = rom[xcnt];
if (data) dstptr[drawx - xcnt] = data + color;
}
} else {
@ -885,7 +854,7 @@ static void draw_sprite_nozoom(INT32 addr, INT32 color, INT32 x, INT32 y, INT32
for (INT32 xcnt = 0; xcnt < xsize; xcnt++)
{
INT32 data = rom[xcnt];
if (data) dstptr[xcnt] = data + color;
}
}
@ -896,11 +865,11 @@ static void draw_sprite_nozoom(INT32 addr, INT32 color, INT32 x, INT32 y, INT32
drawx = x + (xsize - 1) - xcnt;
else
drawx = x + xcnt;
if (drawx >= 0 && drawx < 320)
{
INT32 data = rom[xcnt];
if (data) dstptr[drawx] = data + color;
}
}
@ -1014,14 +983,9 @@ static INT32 DrvDraw()
static INT32 DrvFrame()
{
SekNewFrame();
#ifdef ENABLE_SOUND_HARDWARE
ZetNewFrame();
#endif
watchdog++;
if (watchdog >= 400) { //?
DrvDoReset(0);
}
BurnWatchdogUpdate();
if (DrvReset) {
DrvDoReset(1);
@ -1042,70 +1006,48 @@ static INT32 DrvFrame()
if ((DrvInputs[1] & 0x0c) == 0x00) DrvInputs[1] |= 0x0c;
}
INT32 nSegment;
INT32 nInterleave = 256;
#ifdef ENABLE_SOUND_HARDWARE
INT32 nSoundBufferPos = 0;
#endif
INT32 nCyclesTotal[2] = { 1600000000 / 5745, 800000000 / 5745 }; // 57.4458hz
INT32 nCyclesTotal[2] = { (INT32)(16000000 / 57.4458), (INT32)(8000000 / 57.4458) };
INT32 nCyclesDone[2] = { 0, 0 };
nCyclesTotal[0] = (INT32)((INT64)nCyclesTotal[0] * nBurnCPUSpeedAdjust / 0x0100);
nCyclesTotal[1] = (INT32)((INT64)nCyclesTotal[1] * nBurnCPUSpeedAdjust / 0x0100);
SekOpen(0);
#ifdef ENABLE_SOUND_HARDWARE
ZetOpen(0);
#endif
vblank = 1;
vblank = 0;
for (INT32 i = 0; i < nInterleave; i++)
{
if (i == 240) {
vblank = 0;
vblank = 1;
SekSetIRQLine(1, CPU_IRQSTATUS_AUTO);
if (pBurnDraw) {
DrvDraw();
}
}
nSegment = nCyclesTotal[0] / nInterleave;
nCyclesDone[0] += SekRun(nSegment);
nCyclesDone[0] += SekRun(((i + 1) * nCyclesTotal[0] / nInterleave) - nCyclesDone[0]);
#ifdef ENABLE_SOUND_HARDWARE
nCyclesDone[1] += ZetRun((SekTotalCycles() / 2) - ZetTotalCycles());
if (pBurnSoundOut) {
nSegment = nBurnSoundLen / nInterleave;
YMZ280BRender(pBurnSoundOut + nSoundBufferPos, nSegment);
MSM6295Render(0, pBurnSoundOut + nSoundBufferPos, nSegment);
nSoundBufferPos += nSegment << 1;
}
#endif
BurnTimerUpdate((i + 1) * nCyclesTotal[1] / nInterleave);
}
//SekSetIRQLine(1, CPU_IRQSTATUS_NONE);
BurnTimerEndFrame(nCyclesTotal[1]);
#ifdef ENABLE_SOUND_HARDWARE
if (pBurnSoundOut) {
nSegment = nBurnSoundLen - nSoundBufferPos;
if (nSegment > 0) {
YMZ280BRender(pBurnSoundOut + nSoundBufferPos, nSegment);
MSM6295Render(0, pBurnSoundOut + nSoundBufferPos, nSegment);
}
YMZ280BRender(pBurnSoundOut, nBurnSoundLen);
BurnYMF262Update(nBurnSoundLen);
MSM6295Render(pBurnSoundOut, nBurnSoundLen);
}
ZetClose();
#endif
SekClose();
if (pBurnDraw) {
DrvDraw();
}
return 0;
}
static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
static INT32 DrvScan(INT32 nAction, INT32 *pnMin)
{
struct BurnArea ba;
@ -1113,134 +1055,25 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
*pnMin = 0x029702;
}
DrvRecalc = 1;
if (nAction & ACB_MEMORY_ROM) {
ba.Data = Drv68KROM;
ba.nLen = 0x100000;
ba.nAddress = 0;
ba.szName = "68K ROM";
if (nAction & ACB_MEMORY_RAM) {
memset(&ba, 0, sizeof(ba));
ba.Data = AllRam;
ba.nLen = RamEnd-AllRam;
ba.szName = "All Ram";
BurnAcb(&ba);
}
if (nAction & ACB_MEMORY_RAM) {
ba.Data = Drv68KRAM;
ba.nLen = 0x010000;
ba.nAddress = 0x200000;
ba.szName = "68K RAM";
BurnAcb(&ba);
ba.Data = DrvBgRAM0;
ba.nLen = 0x0001000;
ba.nAddress = 0x300000;
ba.szName = "Background RAM";
BurnAcb(&ba);
ba.Data = DrvBgScrRAM0;
ba.nLen = 0x000400;
ba.nAddress = 0x301000;
ba.szName = "Background Scroll RAM";
BurnAcb(&ba);
ba.Data = DrvBgRAM1;
ba.nLen = 0x0001000;
ba.nAddress = 0x400000;
ba.szName = "Midground RAM";
BurnAcb(&ba);
ba.Data = DrvBgScrRAM1;
ba.nLen = 0x000400;
ba.nAddress = 0x401000;
ba.szName = "Midground Scroll RAM";
BurnAcb(&ba);
ba.Data = DrvBgRAM2;
ba.nLen = 0x0001000;
ba.nAddress = 0x500000;
ba.szName = "Foreground RAM";
BurnAcb(&ba);
ba.Data = DrvBgScrRAM2;
ba.nLen = 0x000400;
ba.nAddress = 0x501000;
ba.szName = "Foreground Scroll RAM";
BurnAcb(&ba);
ba.Data = DrvTxtRAM;
ba.nLen = 0x004000;
ba.nAddress = 0x700000;
ba.szName = "Text RAM";
BurnAcb(&ba);
ba.Data = DrvSprRAM;
ba.nLen = 0x001000;
ba.nAddress = 0x800000;
ba.szName = "Sprite RAM";
BurnAcb(&ba);
ba.Data = Drv88Regs;
ba.nLen = 0x000004;
ba.nAddress = 0x880000;
ba.szName = "880000 Registers";
BurnAcb(&ba);
ba.Data = DrvPalRAM;
ba.nLen = 0x008000;
ba.nAddress = 0x900000;
ba.szName = "Sprite Palette RAM";
BurnAcb(&ba);
ba.Data = DrvPalRAM;
ba.nLen = 0x001000;
ba.nAddress = 0x980000;
ba.szName = "Layer Palette RAM";
BurnAcb(&ba);
ba.Data = DrvA8Regs;
ba.nLen = 0x000006;
ba.nAddress = 0xa80000;
ba.szName = "A80000 Registers";
BurnAcb(&ba);
ba.Data = DrvB0Regs;
ba.nLen = 0x000006;
ba.nAddress = 0xb00000;
ba.szName = "B00000 Registers";
BurnAcb(&ba);
ba.Data = DrvC0Regs;
ba.nLen = 0x000006;
ba.nAddress = 0xc00000;
ba.szName = "C00000 Registers";
BurnAcb(&ba);
ba.Data = DrvC8Regs;
ba.nLen = 0x000006;
ba.nAddress = 0xc80000;
ba.szName = "C80000 Registers";
BurnAcb(&ba);
#ifdef ENABLE_SOUND_HARDWARE
ba.Data = DrvZ80RAM;
ba.nLen = 0x001800;
ba.nAddress = 0xff0000;
ba.szName = "Z80 RAM (Not accessible)";
BurnAcb(&ba);
#endif
}
if (nAction & ACB_DRIVER_DATA) {
SekScan(nAction);
#ifdef ENABLE_SOUND_HARDWARE
ZetScan(nAction);
// ymf262
BurnYMF262Scan(nAction, pnMin);
YMZ280BScan(nAction, pnMin);
MSM6295Scan(nAction, pnMin);
#endif
EEPROMScan(nAction, pnMin);
BurnWatchdogScan(nAction);
SCAN_VAR(protection_read_pointer);
SCAN_VAR(protection_status);
@ -1249,19 +1082,11 @@ static INT32 DrvScan(INT32 nAction,INT32 *pnMin)
}
if (nAction & ACB_WRITE) {
#ifdef ENABLE_SOUND_HARDWARE
INT32 bank;
ZetOpen(0);
bank = *DrvZ80Bank;
*DrvZ80Bank = ~0;
bankswitch(bank);
bankswitch(*DrvZ80Bank);
ZetClose();
bank = *DrvOkiBank;
*DrvOkiBank = ~0;
oki_bankswitch(*DrvOkiBank);
#endif
}
return 0;
@ -1303,9 +1128,7 @@ static INT32 DeroonRomCallback()
if (BurnLoadRom(Drv68KROM + 0x0000001, 0, 2)) return 1;
if (BurnLoadRom(Drv68KROM + 0x0000000, 1, 2)) return 1;
#ifdef ENABLE_SOUND_HARDWARE
if (BurnLoadRom(DrvZ80ROM + 0x0000000, 2, 1)) return 1;
#endif
if (BurnLoadRom(DrvSprROM + 0x0000000, 3, 2)) return 1;
if (BurnLoadRom(DrvSprROM + 0x0000001, 4, 2)) return 1;
@ -1318,11 +1141,9 @@ static INT32 DeroonRomCallback()
if (BurnLoadRom(DrvGfxROM3 + 0x0000000, 9, 1)) return 1;
#ifdef ENABLE_SOUND_HARDWARE
if (BurnLoadRom(DrvSndROM1 + 0x0000000, 10, 1)) return 1;
if (BurnLoadRom(DrvSndROM0 + 0x0080000, 11, 1)) return 1;
#endif
if (BurnLoadRom(DrvSndROM0 + 0x0000000, 11, 1)) return 1;
return 0;
}
@ -1334,7 +1155,7 @@ static INT32 DeroonInit()
struct BurnDriver BurnDrvDeroon = {
"deroon", NULL, NULL, NULL, "1995",
"Deroon DeroDero\0", "No sound", "Tecmo", "Miscellaneous",
"Deroon DeroDero\0", NULL, "Tecmo", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
NULL, deroonRomInfo, deroonRomName, NULL, NULL, NULL, NULL, DrvInputInfo, NULL,
@ -1376,7 +1197,7 @@ STD_ROM_FN(deroona)
struct BurnDriver BurnDrvDeroona = {
"deroona", "deroon", NULL, NULL, "1995",
"Deroon DeroDero (alt set)\0", "No sound", "Tecmo", "Miscellaneous",
"Deroon DeroDero (alt set)\0", NULL, "Tecmo", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_POST90S, GBF_PUZZLE, 0,
NULL, deroonaRomInfo, deroonaRomName, NULL, NULL, NULL, NULL, DrvInputInfo, NULL,
@ -1428,10 +1249,8 @@ static INT32 TkdenshoRomCallback()
if (BurnLoadRom(Drv68KROM + 0x0000001, 0, 2)) return 1;
if (BurnLoadRom(Drv68KROM + 0x0000000, 1, 2)) return 1;
#ifdef ENABLE_SOUND_HARDWARE
if (BurnLoadRom(DrvZ80ROM + 0x0000000, 2, 1)) return 1;
memcpy (DrvZ80ROM + 0x20000, DrvZ80ROM, 0x20000);
#endif
if (BurnLoadRom(DrvSprROM + 0x0000000, 3, 2)) return 1;
if (BurnLoadRom(DrvSprROM + 0x0000001, 4, 2)) return 1;
@ -1452,12 +1271,10 @@ static INT32 TkdenshoRomCallback()
if (BurnLoadRom(DrvGfxROM3 + 0x0000000, 15, 1)) return 1;
#ifdef ENABLE_SOUND_HARDWARE
if (BurnLoadRom(DrvSndROM1 + 0x0000000, 16, 1)) return 1;
if (BurnLoadRom(DrvSndROM1 + 0x0200000, 17, 1)) return 1;
if (BurnLoadRom(DrvSndROM0 + 0x0080000, 18, 1)) return 1;
#endif
if (BurnLoadRom(DrvSndROM0 + 0x0000000, 18, 1)) return 1;
return 0;
}
@ -1469,7 +1286,7 @@ static INT32 TkdenshoInit()
struct BurnDriver BurnDrvTkdensho = {
"tkdensho", NULL, NULL, NULL, "1996",
"Toukidenshou - Angel Eyes (VER. 960614)\0", "No sound", "Tecmo", "Miscellaneous",
"Toukidenshou - Angel Eyes (VER. 960614)\0", NULL, "Tecmo", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING, 2, HARDWARE_MISC_POST90S, GBF_VSFIGHT, 0,
NULL, tkdenshoRomInfo, tkdenshoRomName, NULL, NULL, NULL, NULL, DrvInputInfo, NULL,
@ -1523,7 +1340,7 @@ static INT32 TkdenshoaInit()
struct BurnDriver BurnDrvTkdenshoa = {
"tkdenshoa", "tkdensho", NULL, NULL, "1996",
"Toukidenshou - Angel Eyes (VER. 960427)\0", "No sound", "Tecmo", "Miscellaneous",
"Toukidenshou - Angel Eyes (VER. 960427)\0", NULL, "Tecmo", "Miscellaneous",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE, 2, HARDWARE_MISC_POST90S, GBF_VSFIGHT, 0,
NULL, tkdenshoaRomInfo, tkdenshoaRomName, NULL, NULL, NULL, NULL, DrvInputInfo, NULL,

View File

@ -1020,7 +1020,7 @@ static void DrvPaletteInit()
g = (g * j) / 255;
b = (b * j) / 255;
DrvPalette[i * 256 + j] = BurnHighCol(r, g, b, 0);
DrvPalette[i * 256 + j] = (r << 16) | (g << 8) | b; // must be 32bit palette! -dink (see vector.cpp)
}
}
}

View File

@ -0,0 +1,264 @@
#include "burnint.h"
#include "burn_ymf262.h"
static INT32 (*BurnYMF262StreamCallback)(INT32 nSoundRate);
static INT16* pBuffer;
static INT16* pYMF262Buffer[2];
static INT32 bYMF262AddSignal;
static UINT32 nSampleSize;
static INT32 nYMF262Position;
static INT32 nFractionalPosition;
static INT32 nBurnYMF262SoundRate;
static double YMF262Volumes[2];
static INT32 YMF262RouteDirs[2];
static void *ymfchip = NULL;
// ----------------------------------------------------------------------------
// Dummy functions
static INT32 YMF262StreamCallbackDummy(INT32 /* nSoundRate */)
{
return 0;
}
// ----------------------------------------------------------------------------
// Execute YMF262 for part of a frame
static void YMF262Render(INT32 nSegmentLength)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("YMF262Render called without init\n"));
#endif
if (nYMF262Position >= nSegmentLength) {
return;
}
// bprintf(PRINT_NORMAL, _T(" YMF262 render %6i -> %6i\n"), nYMF262Position, nSegmentLength);
nSegmentLength -= nYMF262Position;
pYMF262Buffer[0] = pBuffer + 0 * 4096 + 4 + nYMF262Position;
pYMF262Buffer[1] = pBuffer + 1 * 4096 + 4 + nYMF262Position;
ymf262_update_one(ymfchip, pYMF262Buffer, nSegmentLength);
nYMF262Position += nSegmentLength;
}
// ----------------------------------------------------------------------------
// Update the sound buffer
#define INTERPOLATE_ADD_SOUND_LEFT(route, buffer) \
if ((YMF262RouteDirs[route] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { \
nLeftSample[0] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 3]/* * YMF262Volumes[route]*/); \
nLeftSample[1] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 2]/* * YMF262Volumes[route]*/); \
nLeftSample[2] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 1]/* * YMF262Volumes[route]*/); \
nLeftSample[3] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 0]/* * YMF262Volumes[route]*/); \
}
#define INTERPOLATE_ADD_SOUND_RIGHT(route, buffer) \
if ((YMF262RouteDirs[route] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { \
nRightSample[0] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 3]/* * YMF262Volumes[route]*/); \
nRightSample[1] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 2]/* * YMF262Volumes[route]*/); \
nRightSample[2] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 1]/* * YMF262Volumes[route]*/); \
nRightSample[3] += (INT32)(pYMF262Buffer[buffer][(nFractionalPosition >> 16) - 0]/* * YMF262Volumes[route]*/); \
}
void BurnYMF262Update(INT32 nSegmentEnd)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Update called without init\n"));
#endif
INT16* pSoundBuf = pBurnSoundOut;
if (nBurnSoundRate == 0 || pBurnSoundOut == NULL) {
return;
}
// bprintf(PRINT_NORMAL, _T(" YMF262 render %6i -> %6i\n"), nYMF262Position, nSegmentEnd);
INT32 nSegmentLength = nSegmentEnd;
INT32 nSamplesNeeded = nSegmentEnd * nBurnYMF262SoundRate / nBurnSoundRate + 1;
if (nSamplesNeeded < nYMF262Position) {
nSamplesNeeded = nYMF262Position;
}
if (nSegmentLength > nBurnSoundLen) {
nSegmentLength = nBurnSoundLen;
}
nSegmentLength <<= 1;
YMF262Render(nSamplesNeeded);
pYMF262Buffer[0] = pBuffer + 0 * 4096 + 4;
pYMF262Buffer[1] = pBuffer + 1 * 4096 + 4;
for (INT32 i = (nFractionalPosition & 0xFFFF0000) >> 15; i < nSegmentLength; i += 2, nFractionalPosition += nSampleSize) {
INT32 nLeftSample[4] = {0, 0, 0, 0};
INT32 nRightSample[4] = {0, 0, 0, 0};
INT32 nTotalLeftSample, nTotalRightSample;
INTERPOLATE_ADD_SOUND_LEFT (BURN_SND_YMF262_YMF262_ROUTE_1, 0)
INTERPOLATE_ADD_SOUND_RIGHT (BURN_SND_YMF262_YMF262_ROUTE_1, 0)
INTERPOLATE_ADD_SOUND_LEFT (BURN_SND_YMF262_YMF262_ROUTE_2, 1)
INTERPOLATE_ADD_SOUND_RIGHT (BURN_SND_YMF262_YMF262_ROUTE_2, 1)
nTotalLeftSample = INTERPOLATE4PS_16BIT((nFractionalPosition >> 4) & 0x0fff, nLeftSample[0], nLeftSample[1], nLeftSample[2], nLeftSample[3]);
nTotalRightSample = INTERPOLATE4PS_16BIT((nFractionalPosition >> 4) & 0x0fff, nRightSample[0], nRightSample[1], nRightSample[2], nRightSample[3]);
nTotalLeftSample = BURN_SND_CLIP(nTotalLeftSample * YMF262Volumes[BURN_SND_YMF262_YMF262_ROUTE_1]);
nTotalRightSample = BURN_SND_CLIP(nTotalRightSample * YMF262Volumes[BURN_SND_YMF262_YMF262_ROUTE_2]);
if (bYMF262AddSignal) {
pSoundBuf[i + 0] = BURN_SND_CLIP(pSoundBuf[i + 0] + nTotalLeftSample);
pSoundBuf[i + 1] = BURN_SND_CLIP(pSoundBuf[i + 1] + nTotalRightSample);
} else {
pSoundBuf[i + 0] = nTotalLeftSample;
pSoundBuf[i + 1] = nTotalRightSample;
}
}
if (nSegmentEnd >= nBurnSoundLen) {
INT32 nExtraSamples = nSamplesNeeded - (nFractionalPosition >> 16);
for (INT32 i = -4; i < nExtraSamples; i++) {
pYMF262Buffer[0][i] = pYMF262Buffer[0][(nFractionalPosition >> 16) + i];
pYMF262Buffer[1][i] = pYMF262Buffer[1][(nFractionalPosition >> 16) + i];
}
nFractionalPosition &= 0xFFFF;
nYMF262Position = nExtraSamples;
}
}
// ----------------------------------------------------------------------------
void BurnYMF262Write(INT32 nAddress, UINT8 nValue)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Write called without init\n"));
#endif
YMF262Render(BurnYMF262StreamCallback(nBurnYMF262SoundRate));
ymf262_write(ymfchip, nAddress&3, nValue);
}
UINT8 BurnYMF262Read(INT32 nAddress)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Read called without init\n"));
#endif
YMF262Render(BurnYMF262StreamCallback(nBurnYMF262SoundRate));
return ymf262_read(ymfchip, nAddress&3);
}
// ----------------------------------------------------------------------------
static int ymf262_timerover(int /*num*/, int c)
{
return ymf262_timer_over(ymfchip, c);
}
void BurnYMF262Reset()
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Reset called without init\n"));
#endif
BurnTimerReset();
ymf262_reset_chip(ymfchip);
}
void BurnYMF262Exit()
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Exit called without init\n"));
#endif
if (!DebugSnd_YMF262Initted) return;
ymf262_shutdown(ymfchip);
BurnTimerExit();
BurnFree(pBuffer);
DebugSnd_YMF262Initted = 0;
}
INT32 BurnYMF262Init(INT32 nClockFrequency, void (*IRQCallback)(INT32, INT32), INT32 nAdd)
{
return BurnYMF262Init(nClockFrequency, IRQCallback, BurnSynchroniseStream, nAdd);
}
INT32 BurnYMF262Init(INT32 nClockFrequency, void (*IRQCallback)(INT32, INT32), INT32 (*StreamCallback)(INT32), INT32 nAdd)
{
DebugSnd_YMF262Initted = 1;
BurnYMF262StreamCallback = YMF262StreamCallbackDummy;
if (StreamCallback) {
BurnYMF262StreamCallback = StreamCallback;
}
nBurnYMF262SoundRate = nClockFrequency / 288; // hw rate based on input clock
nSampleSize = (UINT32)nBurnYMF262SoundRate * (1 << 16) / nBurnSoundRate;
bYMF262AddSignal = nAdd;
BurnTimerInit(&ymf262_timerover, NULL);
ymfchip = ymf262_init(nClockFrequency, nBurnYMF262SoundRate, IRQCallback, BurnYMF262TimerCallback);
pBuffer = (INT16*)BurnMalloc(4096 * 2 * sizeof(INT16));
memset(pBuffer, 0, 4096 * 2 * sizeof(INT16));
nYMF262Position = 0;
nFractionalPosition = 0;
// default routes
YMF262Volumes[BURN_SND_YMF262_YMF262_ROUTE_1] = 1.00;
YMF262Volumes[BURN_SND_YMF262_YMF262_ROUTE_2] = 1.00;
YMF262RouteDirs[BURN_SND_YMF262_YMF262_ROUTE_1] = BURN_SND_ROUTE_LEFT;
YMF262RouteDirs[BURN_SND_YMF262_YMF262_ROUTE_2] = BURN_SND_ROUTE_RIGHT;
return 0;
}
void BurnYMF262SetRoute(INT32 nIndex, double nVolume, INT32 nRouteDir)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262SetRoute called without init\n"));
if (nIndex < 0 || nIndex > 1) bprintf(PRINT_ERROR, _T("BurnYMF262SetRoute called with invalid index %i\n"), nIndex);
#endif
YMF262Volumes[nIndex] = nVolume;
YMF262RouteDirs[nIndex] = nRouteDir;
}
void BurnYMF262Scan(INT32 nAction, INT32* pnMin)
{
#if defined FBA_DEBUG
if (!DebugSnd_YMF262Initted) bprintf(PRINT_ERROR, _T("BurnYMF262Scan called without init\n"));
#endif
BurnTimerScan(nAction, pnMin);
ymf262_save_state(ymfchip, nAction);
if (nAction & ACB_WRITE) {
nYMF262Position = 0;
nFractionalPosition = 0;
memset(pBuffer, 0, 4096 * 2 * sizeof(INT16));
}
}

View File

@ -0,0 +1,24 @@
#include "driver.h"
//extern "C" {
#include "ymf262.h"
//}
#include "timer.h"
void BurnYMF262Write(INT32 nAddress, UINT8 nValue);
UINT8 BurnYMF262Read(INT32 nAddress);
INT32 BurnYMF262Init(INT32 nClockFrequency, void (*IRQCallback)(INT32, INT32), INT32 nAdd);
INT32 BurnYMF262Init(INT32 nClockFrequency, void (*IRQCallback)(INT32, INT32), INT32 (*StreamCallback)(INT32), INT32 nAdd);
void BurnYMF262SetRoute(INT32 nIndex, double nVolume, INT32 nRouteDir);
void BurnYMF262Reset();
void BurnYMF262Exit();
void BurnYMF262Update(INT32 nSegmentEnd);
void BurnYMF262Scan(INT32 nAction, INT32* pnMin);
#define BURN_SND_YMF262_YMF262_ROUTE_1 0
#define BURN_SND_YMF262_YMF262_ROUTE_2 1
#define BurnYMF262SetAllRoutes(v, d) \
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_1, v, d); \
BurnYMF262SetRoute(BURN_SND_YMF262_YMF262_ROUTE_2, v, d);

View File

@ -17,6 +17,8 @@ static INT32 nBurnYMF278SoundRate;
static double YMF278BVolumes[2];
static INT32 YMF278BRouteDirs[2];
static INT32 uses_timer; // when init passed w/NULL IRQHandler, timer is disabled.
// ----------------------------------------------------------------------------
// Dummy functions
@ -210,7 +212,8 @@ void BurnYMF278BReset()
if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BReset called without init\n"));
#endif
BurnTimerReset();
if (uses_timer)
BurnTimerReset();
ymf278b_reset();
}
@ -224,7 +227,8 @@ void BurnYMF278BExit()
YMF278B_sh_stop();
BurnTimerExit();
if (uses_timer)
BurnTimerExit();
BurnFree(pBuffer);
@ -258,7 +262,11 @@ INT32 BurnYMF278BInit(INT32 nClockFrequency, UINT8* YMF278BROM, INT32 YMF278BROM
nSampleSize = (UINT32)nBurnYMF278SoundRate * (1 << 16) / nBurnSoundRate;
bYMF278BAddSignal = 0; // not used by any driver. (yet)
BurnTimerInit(&ymf278b_timer_over, NULL);
uses_timer = (IRQCallback != NULL);
if (uses_timer)
BurnTimerInit(&ymf278b_timer_over, NULL);
ymf278b_start(0, YMF278BROM, YMF278BROMSize, IRQCallback, BurnYMFTimerCallback, nClockFrequency);
pBuffer = (INT16*)BurnMalloc(4096 * 2 * sizeof(INT16));
@ -293,7 +301,10 @@ void BurnYMF278BScan(INT32 nAction, INT32* pnMin)
if (!DebugSnd_YMF278BInitted) bprintf(PRINT_ERROR, _T("BurnYMF278BScan called without init\n"));
#endif
BurnTimerScan(nAction, pnMin);
if (uses_timer) {
BurnTimerScan(nAction, pnMin);
}
ymf278b_scan(nAction, pnMin);
if (nAction & ACB_WRITE) {

2767
src/burn/snd/ymf262.cpp Normal file

File diff suppressed because it is too large Load Diff

25
src/burn/snd/ymf262.h Normal file
View File

@ -0,0 +1,25 @@
#pragma once
#ifndef __YMF262_H__
#define __YMF262_H__
/* select number of output bits: 8 or 16 */
#define OPL3_SAMPLE_BITS 16
typedef INT16 OPL3SAMPLE;
typedef void (*OPL3_TIMERHANDLER)(INT32, INT32 timer,double period);
typedef void (*OPL3_IRQHANDLER)(INT32, INT32 irq);
typedef void (*OPL3_UPDATEHANDLER)();
void *ymf262_init(int clock, int rate, void (*irq_cb)(INT32, INT32), void (*timer_cb)(INT32, INT32, double));
void ymf262_shutdown(void *chip);
void ymf262_reset_chip(void *chip);
int ymf262_write(void *chip, int a, int v);
unsigned char ymf262_read(void *chip, int a);
int ymf262_timer_over(void *chip, int c);
void ymf262_update_one(void *chip, INT16 **buffers, int length);
void ymf262_save_state(void *chippy, INT32 nAction);
#endif /* __YMF262_H__ */

View File

@ -577,9 +577,9 @@ void YMZ280BWriteRegister(UINT8 nValue)
if ((nValue & 0x80) == 0) {
YMZ280BChannelInfo[nWriteChannel].bEnabled = false;
if (!YMZ280BChannelInfo[nWriteChannel].bLoop) {
//if (!YMZ280BChannelInfo[nWriteChannel].bLoop) { // dec.24,2018 - also stops looping (fixes glitches in deroon & tkdensho)
YMZ280BChannelInfo[nWriteChannel].bPlaying = false;
}
//}
} else {
if (!YMZ280BChannelInfo[nWriteChannel].bEnabled) {
YMZ280BChannelInfo[nWriteChannel].bEnabled = true;
@ -588,9 +588,8 @@ void YMZ280BWriteRegister(UINT8 nValue)
YMZ280BChannelInfo[nWriteChannel].nStep = 127;
if (YMZ280BChannelInfo[nWriteChannel].nMode > 1) {
#ifdef DEBUG
//bprintf(0,_T("Sample Start: %08X - Stop: %08X.\n"),YMZ280BChannelInfo[nWriteChannel].nSampleStart, YMZ280BChannelInfo[nWriteChannel].nSampleStop);
#endif
// Handy debug info:
//bprintf(0,_T("ch#%02x - Sample Start: %08X - Stop: %08X. %S\n"), nWriteChannel, YMZ280BChannelInfo[nWriteChannel].nSampleStart, YMZ280BChannelInfo[nWriteChannel].nSampleStop, (YMZ280BChannelInfo[nWriteChannel].bLoop) ? "Looping" : "");
}
#if 0

View File

@ -197,6 +197,21 @@ void BurnYMFTimerCallback(INT32 /* n */, INT32 c, double period)
// bprintf(PRINT_NORMAL, _T(" - timer %i started, %08X ticks (fires in %lf seconds)\n"), c, nTimerCount[c], period);
}
void BurnYMF262TimerCallback(INT32 /* n */, INT32 c, double period)
{
pCPURunEnd();
if (period == 0.0) {
nTimerCount[c] = MAX_TIMER_VALUE;
return;
}
nTimerCount[c] = (INT32)(period * (double)TIMER_TICKS_PER_SECOND);
nTimerCount[c] += MAKE_TIMER_TICKS(BurnTimerCPUTotalCycles(), BurnTimerCPUClockspeed);
// bprintf(PRINT_NORMAL, _T(" - timer %i started, %08X ticks (fires in %lf seconds)\n"), c, nTimerCount[c], period);
}
void BurnTimerSetRetrig(INT32 c, double period)
{
pCPURunEnd();

View File

@ -11,6 +11,7 @@ void BurnOPMTimerCallback(INT32 c, double period); // perio
void BurnOPNTimerCallback(INT32 n, INT32 c, INT32 cnt, double stepTime); // period = cnt * stepTime in s
void BurnOPLTimerCallback(INT32 c, double period); // period in s
void BurnYMFTimerCallback(INT32 n, INT32 c, double period); // period in us
void BurnYMF262TimerCallback(INT32 n, INT32 c, double period); // period in s
// Start / stop a timer
void BurnTimerSetRetrig(INT32 c, double period); // period in s