2 // E0H : transfer voice parameter
4 // E2H : set mode : 0 0 0 0 F S1 S0
5 // F : frame period 0: 10ms/frame
7 // S1,S0 : synthesis speed 00: NORMAL SPEED
13 // internal voice : 0 0 P5 P4 P3 P2 P1 P0
14 // P5-P0 : select voice kind(0-63)
15 // stop : 1 1 1 1 1 1 1 1
16 // external voice : 1 1 1 1 1 1 1 0
19 // E0H : status register : BSY REQ ~INT/EXT ERR 0 0 0 0
20 // BSY : synthesizing voice 1:busy 0:stop
21 // REQ : voice parameter 1:input request 0:prohibit
22 // ~INT/EXT : message data 1:external 0:internal
25 // E2H : written PortE2 ?
26 // E3H : written PortE3 ?
29 Skelton for retropc emulator
44 typedef int D7752_SAMPLE;
45 typedef int D7752_FIXED;
47 #define D7752_ERR_SUCCESS (0)
48 #define D7752_ERR_PARAM (-1)
50 #define D7752_ERR_DEVICE_MODE (-2)
51 #define D7752_ERR_MEMORY (-3)
52 #define D7752_ERR_BUFFER_FULL (-4)
53 #define D7752_ERR_BUFFER_EMPTY (-5)
55 #define D7752E_BSY (0x80) // b7 BSY - 1 when synthesising voice
56 #define D7752E_REQ (0x40) // b6 REQ - 1 when there is a space in the parameter buffer
57 #define D7752E_EXT (0x20) // b5 INT/EXT
58 #define D7752E_ERR (0x10) // b4 ERR - 1 when error
59 #define D7752E_IDL (0x00) // waiting
63 class UPD7752 : public DEVICE
77 uint8_t ParaBuf[7]; // parameter buffer
78 uint8_t Pnum; // parameter number
79 int Fnum; // repeat frame number
80 int PReady; // complete setting parameter
83 D7752_SAMPLE *Fbuf; // frame buffer pointer (10kHz 1frame)
84 unsigned char *voicebuf;
89 void AbortVoice(void);
90 void CancelVoice(void);
92 void VSetMode(uint8_t mode);
93 void VSetCommand(uint8_t comm);
94 void VSetData(uint8_t data);
97 // filter coefficients
112 int UPD7752_Start(int mode);
113 int GetFrameSize(void);
114 int Synth(uint8_t *param, D7752_SAMPLE *frame);
116 int volume_l, volume_r;
119 UPD7752(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
121 volume_l = volume_r = 1024;
122 set_device_name(_T("uPD7752 Voice Synthesizer"));
131 void __FASTCALL write_io8(uint32_t addr, uint32_t data);
132 uint32_t __FASTCALL read_io8(uint32_t addr);
133 void mix(int32_t* buffer, int cnt);
134 void set_volume(int ch, int decibel_l, int decibel_r);
135 bool process_state(FILEIO* state_fio, bool loading);
138 void initialize_sound(int rate)