| 1 |
// license:GPL-2.0+ |
| 2 |
// copyright-holders:Jarek Burczynski, Hiromitsu Shioya |
| 3 |
// additional modifications for Furnace by tildearrow |
| 4 |
#ifndef MAME_SOUND_MSM5232_H |
| 5 |
#define MAME_SOUND_MSM5232_H |
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
#include <stdint.h> |
| 10 |
#include <functional> |
| 11 |
|
| 12 |
class msm5232_device |
| 13 |
{ |
| 14 |
public: |
| 15 |
msm5232_device(uint32_t clock); |
| 16 |
|
| 17 |
void set_capacitors(double cap1, double cap2, double cap3, double cap4, double cap5, double cap6, double cap7, double cap8); |
| 18 |
void set_vol_input(double v1, double v2, double v3, double v4, double v5, double v6, double v7, double v8); |
| 19 |
//auto gate() { return m_gate_handler_cb.bind(); } |
| 20 |
|
| 21 |
void write(unsigned int offset, uint8_t data); |
| 22 |
void set_clock(int clock); |
| 23 |
void mute(int voice, bool mute); |
| 24 |
|
| 25 |
// device-level overrides |
| 26 |
void device_start(); |
| 27 |
void device_stop(); |
| 28 |
void device_reset(); |
| 29 |
void device_post_load(); |
| 30 |
|
| 31 |
// sound stream update overrides |
| 32 |
void sound_stream_update(short* outputs); |
| 33 |
|
| 34 |
int get_rate(); |
| 35 |
|
| 36 |
int vo16[8]; |
| 37 |
int vo8[8]; |
| 38 |
int vo4[8]; |
| 39 |
int vo2[8]; |
| 40 |
|
| 41 |
private: |
| 42 |
struct VOICE { |
| 43 |
uint8_t mode; |
| 44 |
bool mute; |
| 45 |
|
| 46 |
int TG_count_period; |
| 47 |
int TG_count; |
| 48 |
|
| 49 |
uint8_t TG_cnt; /* 7 bits binary counter (frequency output) */ |
| 50 |
uint8_t TG_out16; /* bit number (of TG_cnt) for 16' output */ |
| 51 |
uint8_t TG_out8; /* bit number (of TG_cnt) for 8' output */ |
| 52 |
uint8_t TG_out4; /* bit number (of TG_cnt) for 4' output */ |
| 53 |
uint8_t TG_out2; /* bit number (of TG_cnt) for 2' output */ |
| 54 |
|
| 55 |
int egvol; |
| 56 |
int eg_sect; |
| 57 |
int counter; |
| 58 |
int eg; |
| 59 |
|
| 60 |
uint8_t eg_arm; /* attack/release mode */ |
| 61 |
uint8_t eg_ext; /* inhibit envelope generator */ |
| 62 |
|
| 63 |
double ar_rate; |
| 64 |
double dr_rate; |
| 65 |
double rr_rate; |
| 66 |
|
| 67 |
int pitch; /* current pitch data */ |
| 68 |
|
| 69 |
int GF; |
| 70 |
}; |
| 71 |
|
| 72 |
VOICE m_voi[8]; |
| 73 |
|
| 74 |
uint32_t m_EN_out16[2]; /* enable 16' output masks for both groups (0-disabled ; ~0 -enabled) */ |
| 75 |
uint32_t m_EN_out8[2]; /* enable 8' output masks */ |
| 76 |
uint32_t m_EN_out4[2]; /* enable 4' output masks */ |
| 77 |
uint32_t m_EN_out2[2]; /* enable 2' output masks */ |
| 78 |
|
| 79 |
int m_noise_cnt; |
| 80 |
int m_noise_step; |
| 81 |
int m_noise_rng; |
| 82 |
int m_noise_clocks; /* number of the noise_rng (output) level changes */ |
| 83 |
|
| 84 |
unsigned int m_UpdateStep; |
| 85 |
|
| 86 |
/* rate tables */ |
| 87 |
double m_ar_tbl[8]; |
| 88 |
double m_dr_tbl[16]; |
| 89 |
|
| 90 |
uint8_t m_control1; |
| 91 |
uint8_t m_control2; |
| 92 |
|
| 93 |
int m_gate; /* current state of the GATE output */ |
| 94 |
|
| 95 |
int m_chip_clock; /* chip clock in Hz */ |
| 96 |
int m_rate; /* sample rate in Hz */ |
| 97 |
uint32_t m_clock; |
| 98 |
|
| 99 |
double m_external_capacity[8]; /* in Farads, eg 0.39e-6 = 0.36 uF (microFarads) */ |
| 100 |
double m_external_input[8]; |
| 101 |
std::function<void(int)> m_gate_handler_cb;/* callback called when the GATE output pin changes state */ |
| 102 |
|
| 103 |
void init_tables(); |
| 104 |
void init_voice(int i); |
| 105 |
void gate_update(); |
| 106 |
void init(int clock, int rate); |
| 107 |
void EG_voices_advance(); |
| 108 |
void TG_group_advance(int groupidx); |
| 109 |
}; |
| 110 |
|
| 111 |
#endif // MAME_SOUND_MSM5232_H |