mirror of
https://github.com/libretro/RACE.git
synced 2024-11-23 08:59:49 +00:00
103 lines
1.8 KiB
C
103 lines
1.8 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);
|
|
}
|
|
#if 0
|
|
timer_add_cycles(toRun);
|
|
#endif
|
|
sndCycles -= toRun;
|
|
#else
|
|
int elapsed;
|
|
while(sndCycles > 0)
|
|
{
|
|
elapsed = z80Step();
|
|
sndCycles-= (2*elapsed);
|
|
#if 0
|
|
timer_add_cycles(elapsed);
|
|
#endif
|
|
}
|
|
#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
|
|
}
|
|
}
|