| 1 |
// license:BSD-3-Clause |
| 2 |
// copyright-holders:Nicola Salmoria,Aaron Giles |
| 3 |
#ifndef MAME_SOUND_NAMCO_H |
| 4 |
#define MAME_SOUND_NAMCO_H |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
#include <stdint.h> |
| 8 |
#include <memory> |
| 9 |
|
| 10 |
class namco_audio_device |
| 11 |
{ |
| 12 |
public: |
| 13 |
// configuration |
| 14 |
void set_voices(int voices) { m_voices = voices; } |
| 15 |
void set_stereo(bool stereo) { m_stereo = stereo; } |
| 16 |
|
| 17 |
void sound_enable_w(int state); |
| 18 |
|
| 19 |
static constexpr unsigned MAX_VOICES = 8; |
| 20 |
static constexpr unsigned MAX_VOLUME = 16; |
| 21 |
|
| 22 |
/* this structure defines the parameters for a channel */ |
| 23 |
struct sound_channel |
| 24 |
{ |
| 25 |
uint32_t frequency; |
| 26 |
uint32_t counter; |
| 27 |
int32_t volume[2]; |
| 28 |
int32_t noise_sw; |
| 29 |
int32_t noise_state; |
| 30 |
int32_t noise_seed; |
| 31 |
uint32_t noise_counter; |
| 32 |
int32_t noise_hold; |
| 33 |
int32_t waveform_select; |
| 34 |
int16_t last_out; |
| 35 |
}; |
| 36 |
|
| 37 |
namco_audio_device(uint32_t clock); |
| 38 |
|
| 39 |
// device-level overrides |
| 40 |
virtual void device_start(unsigned char* wavePtr); |
| 41 |
void device_clock_changed(int clk); |
| 42 |
|
| 43 |
// internal state |
| 44 |
|
| 45 |
void build_decoded_waveform( uint8_t *rgnbase ); |
| 46 |
void update_namco_waveform(int offset, uint8_t data); |
| 47 |
uint32_t namco_update_one(short* buffer, int size, const int16_t *wave, uint32_t counter, uint32_t freq, int16_t& last_out); |
| 48 |
|
| 49 |
/* waveform region */ |
| 50 |
uint8_t* m_wave_ptr; |
| 51 |
|
| 52 |
/* data about the sound system */ |
| 53 |
sound_channel m_channel_list[MAX_VOICES]; |
| 54 |
sound_channel *m_last_channel; |
| 55 |
uint8_t *m_wavedata; |
| 56 |
|
| 57 |
/* global sound parameters */ |
| 58 |
int m_wave_size; |
| 59 |
bool m_sound_enable; |
| 60 |
int m_namco_clock; |
| 61 |
int m_sample_rate; |
| 62 |
int m_f_fracbits; |
| 63 |
|
| 64 |
int m_voices; /* number of voices */ |
| 65 |
bool m_stereo; /* set to indicate stereo (e.g., System 1) */ |
| 66 |
|
| 67 |
uint8_t m_waveram_alloc[0x400]; |
| 68 |
|
| 69 |
/* decoded waveform table */ |
| 70 |
int16_t m_waveform[MAX_VOLUME][512]; |
| 71 |
|
| 72 |
virtual void sound_stream_update(short** outputs, int len); |
| 73 |
virtual ~namco_audio_device() {} |
| 74 |
}; |
| 75 |
|
| 76 |
class namco_device : public namco_audio_device |
| 77 |
{ |
| 78 |
public: |
| 79 |
namco_device(uint32_t clock); |
| 80 |
|
| 81 |
void pacman_sound_w(int offset, uint8_t data); |
| 82 |
|
| 83 |
uint8_t polepos_sound_r(int offset); |
| 84 |
void polepos_sound_w(int offset, uint8_t data); |
| 85 |
|
| 86 |
void device_start(unsigned char* wavePtr); |
| 87 |
|
| 88 |
~namco_device() {} |
| 89 |
|
| 90 |
private: |
| 91 |
uint8_t m_soundregs[0x400]; |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
class namco_15xx_device : public namco_audio_device |
| 96 |
{ |
| 97 |
public: |
| 98 |
namco_15xx_device(uint32_t clock); |
| 99 |
|
| 100 |
void namco_15xx_w(int offset, uint8_t data); |
| 101 |
uint8_t sharedram_r(int offset); |
| 102 |
void sharedram_w(int offset, uint8_t data); |
| 103 |
|
| 104 |
void device_start(unsigned char* wavePtr); |
| 105 |
|
| 106 |
~namco_15xx_device() {} |
| 107 |
|
| 108 |
private: |
| 109 |
uint8_t m_soundregs[0x400]; |
| 110 |
}; |
| 111 |
|
| 112 |
|
| 113 |
class namco_cus30_device : public namco_audio_device |
| 114 |
{ |
| 115 |
public: |
| 116 |
namco_cus30_device(uint32_t clock); |
| 117 |
|
| 118 |
void namcos1_cus30_w(int offset, uint8_t data); /* wavedata + sound registers + RAM */ |
| 119 |
uint8_t namcos1_cus30_r(int offset); |
| 120 |
void namcos1_sound_w(int offset, uint8_t data); |
| 121 |
|
| 122 |
void pacman_sound_w(int offset, uint8_t data); |
| 123 |
|
| 124 |
void device_start(unsigned char* wavePtr); |
| 125 |
|
| 126 |
~namco_cus30_device() {} |
| 127 |
}; |
| 128 |
|
| 129 |
#endif // MAME_SOUND_NAMCO_H |