| 1 |
// license:BSD-3-Clause |
| 2 |
// copyright-holders:Hiromitsu Shioya, Olivier Galibert |
| 3 |
/*********************************************************/ |
| 4 |
/* SEGA 8bit PCM */ |
| 5 |
/*********************************************************/ |
| 6 |
|
| 7 |
#ifndef MAMESOUND_SEGAPCM_H |
| 8 |
#define MAMESOUND_SEGAPCM_H |
| 9 |
|
| 10 |
#include <stdint.h> |
| 11 |
#include <functional> |
| 12 |
|
| 13 |
//************************************************************************** |
| 14 |
// TYPE DEFINITIONS |
| 15 |
//************************************************************************** |
| 16 |
|
| 17 |
class segapcm_device { |
| 18 |
public: |
| 19 |
static constexpr int BANK_256 = 11; |
| 20 |
static constexpr int BANK_512 = 12; |
| 21 |
static constexpr int BANK_12M = 13; |
| 22 |
static constexpr int BANK_MASK7 = 0x70 << 16; |
| 23 |
static constexpr int BANK_MASKF = 0xf0 << 16; |
| 24 |
static constexpr int BANK_MASKF8 = 0xf8 << 16; |
| 25 |
|
| 26 |
short lastOut[16][2]; |
| 27 |
|
| 28 |
segapcm_device(); |
| 29 |
|
| 30 |
// configuration |
| 31 |
void set_bank(int bank) { m_bankshift = (bank & 0xf); m_bankmask = (0x70|((bank >> 16) & 0xfc)); } |
| 32 |
void set_read(std::function<unsigned char(unsigned int)> r) { read_byte = r; } |
| 33 |
|
| 34 |
void write(unsigned int offset, uint8_t data); |
| 35 |
uint8_t read(unsigned int offset); |
| 36 |
uint8_t* get_ram(); |
| 37 |
unsigned int get_addr(int ch); |
| 38 |
bool is_playing(int ch); |
| 39 |
void mute(int ch, bool doMute); |
| 40 |
|
| 41 |
// device-level overrides |
| 42 |
void device_start(); |
| 43 |
|
| 44 |
// sound stream update overrides |
| 45 |
void sound_stream_update(int* outputs); |
| 46 |
|
| 47 |
private: |
| 48 |
uint8_t m_ram[0x800]; |
| 49 |
uint8_t m_low[16]; |
| 50 |
bool m_muted[16]; |
| 51 |
int m_bankshift; |
| 52 |
int m_bankmask; |
| 53 |
std::function<unsigned char(unsigned int)> read_byte; |
| 54 |
}; |
| 55 |
|
| 56 |
#endif // MAMESOUND_SEGAPCM_H |