-
Notifications
You must be signed in to change notification settings - Fork 0
/
sound.cpp
112 lines (94 loc) · 2.41 KB
/
sound.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//---------------------------------------------------------------------------
// 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.
//
//////////////////////////////////////////////////////////////////////
//Flavor - Convert from DirectSound to SDL
#ifndef __GP32__
#include "StdAfx.h"
#endif
#include "main.h"
#include "sound.h"
#include "memory.h"
#ifdef DRZ80
#include "DrZ80_support.h"
#else
#if defined(CZ80)
#include "cz80_support.h"
#else
#include "z80.h"
#endif
#endif
#ifndef __GP32__
#include <math.h>
#endif
#define Machine (&m_emuInfo)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
int sndCycles = 0;
void soundStep(int cycles)
{
sndCycles+= cycles;
}
/////////////////////////////////////////////////////////////////////////////////
///
/// Neogeo Pocket Sound system
///
/////////////////////////////////////////////////////////////////////////////////
unsigned int ngpRunning;
void ngpSoundStart()
{
ngpRunning = 1; // ?
#if defined(DRZ80) || defined(CZ80)
Z80_Reset();
#else
z80Init();
z80SetRunning(1);
#endif
}
/// Execute all gained cycles (divided by 2)
void ngpSoundExecute()
{
#if defined(DRZ80) || defined(CZ80)
int toRun = sndCycles/2;
if(ngpRunning)
{
Z80_Execute(toRun);
}
//timer_add_cycles(toRun);
sndCycles -= toRun;
#else
int elapsed;
while(sndCycles > 0)
{
elapsed = z80Step();
sndCycles-= (2*elapsed);
//timer_add_cycles(elapsed);
}
#endif
}
/// Switch sound system off
void ngpSoundOff() {
ngpRunning = 0;
#if defined(DRZ80) || defined(CZ80)
#else
z80SetRunning(0);
#endif
}
// Generate interrupt to ngp sound system
void ngpSoundInterrupt() {
if (ngpRunning)
{
#if defined(DRZ80) || defined(CZ80)
Z80_Cause_Interrupt(0x100);//Z80_IRQ_INT???
#else
z80Interrupt(0);
#endif
}
}