RACE/sound.c

103 lines
1.8 KiB
C
Raw Normal View History

2020-01-07 11:22:21 +00:00
/*---------------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
2016-10-14 17:01:29 +00:00
2020-01-07 11:22:21 +00:00
/* sound.cpp: implementation of the sound class. */
2016-10-14 17:01:29 +00:00
2020-10-03 21:57:24 +00:00
#include "types.h"
2016-10-14 17:01:29 +00:00
#ifdef DRZ80
#include "DrZ80_support.h"
#else
#if defined(CZ80)
#include "cz80_support.h"
#else
#include "z80.h"
#endif
#endif
#include <math.h>
#define Machine (&m_emuInfo)
int sndCycles = 0;
void soundStep(int cycles)
{
sndCycles+= cycles;
2016-10-14 17:01:29 +00:00
}
2020-01-07 11:22:21 +00:00
/*
*
* Neogeo Pocket Sound system
*
*/
2016-10-14 17:01:29 +00:00
unsigned int ngpRunning;
2020-01-07 11:22:21 +00:00
void ngpSoundStart(void)
2016-10-14 17:01:29 +00:00
{
ngpRunning = 1; /* ? */
2016-10-14 17:01:29 +00:00
#if defined(DRZ80) || defined(CZ80)
Z80_Reset();
2016-10-14 17:01:29 +00:00
#else
z80Init();
z80SetRunning(1);
2016-10-14 17:01:29 +00:00
#endif
}
2020-01-07 11:22:21 +00:00
/* Execute all gained cycles (divided by 2) */
void ngpSoundExecute(void)
2016-10-14 17:01:29 +00:00
{
#if defined(DRZ80) || defined(CZ80)
int toRun = sndCycles/2;
if(ngpRunning)
{
Z80_Execute(toRun);
}
2020-01-07 11:22:21 +00:00
#if 0
timer_add_cycles(toRun);
2020-01-07 11:22:21 +00:00
#endif
sndCycles -= toRun;
2016-10-14 17:01:29 +00:00
#else
int elapsed;
while(sndCycles > 0)
{
elapsed = z80Step();
sndCycles-= (2*elapsed);
2020-01-07 11:22:21 +00:00
#if 0
timer_add_cycles(elapsed);
2020-01-07 11:22:21 +00:00
#endif
}
2016-10-14 17:01:29 +00:00
#endif
}
2020-01-07 11:22:21 +00:00
/* Switch sound system off */
void ngpSoundOff(void)
{
ngpRunning = 0;
2016-10-14 17:01:29 +00:00
#if defined(DRZ80) || defined(CZ80)
#else
2020-01-07 11:22:21 +00:00
z80SetRunning(0);
2016-10-14 17:01:29 +00:00
#endif
}
2020-01-07 11:22:21 +00:00
/* Generate interrupt to ngp sound system */
void ngpSoundInterrupt(void)
{
if (ngpRunning)
{
2016-10-14 17:01:29 +00:00
#if defined(DRZ80) || defined(CZ80)
2020-01-07 11:22:21 +00:00
Z80_Cause_Interrupt(0x100); /* Z80_IRQ_INT??? */
2016-10-14 17:01:29 +00:00
#else
2020-01-07 11:22:21 +00:00
z80Interrupt(0);
2016-10-14 17:01:29 +00:00
#endif
2020-01-07 11:22:21 +00:00
}
2016-10-14 17:01:29 +00:00
}