mirror of
https://github.com/libretro/RACE.git
synced 2024-11-27 02:50:37 +00:00
95 lines
1.7 KiB
C
95 lines
1.7 KiB
C
/*---------------------------------------------------------------------------
|
|
* 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.
|
|
*---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* sound.cpp: implementation of the sound class. */
|
|
|
|
#include "types.h"
|
|
|
|
#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;
|
|
}
|
|
|
|
/*
|
|
*
|
|
* Neogeo Pocket Sound system
|
|
*
|
|
*/
|
|
|
|
unsigned int ngpRunning;
|
|
|
|
void ngpSoundStart(void)
|
|
{
|
|
ngpRunning = 1; /* ? */
|
|
#if defined(DRZ80) || defined(CZ80)
|
|
Z80_Reset();
|
|
#else
|
|
z80Init();
|
|
z80SetRunning(1);
|
|
#endif
|
|
}
|
|
|
|
/* Execute all gained cycles (divided by 2) */
|
|
void ngpSoundExecute(void)
|
|
{
|
|
#if defined(DRZ80) || defined(CZ80)
|
|
int toRun = sndCycles/2;
|
|
if(ngpRunning)
|
|
Z80_Execute(toRun);
|
|
sndCycles -= toRun;
|
|
#else
|
|
int elapsed;
|
|
while(sndCycles > 0)
|
|
{
|
|
elapsed = z80Step();
|
|
sndCycles-= (2*elapsed);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/* Switch sound system off */
|
|
void ngpSoundOff(void)
|
|
{
|
|
ngpRunning = 0;
|
|
#if defined(DRZ80) || defined(CZ80)
|
|
|
|
#else
|
|
z80SetRunning(0);
|
|
#endif
|
|
}
|
|
|
|
/* Generate interrupt to ngp sound system */
|
|
void ngpSoundInterrupt(void)
|
|
{
|
|
if (ngpRunning)
|
|
{
|
|
#if defined(DRZ80) || defined(CZ80)
|
|
Z80_Cause_Interrupt(0x100); /* Z80_IRQ_INT??? */
|
|
#else
|
|
z80Interrupt(0);
|
|
#endif
|
|
}
|
|
}
|