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
|
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/*
vboy.h - Virtual Boy audio emulation
By Richard Bannister and Gil Pedersen.
MESS device adaptation by R. Belmont
*/
#ifndef MAME_AUDIO_VBOY_H
#define MAME_AUDIO_VBOY_H
#pragma once
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> vboysnd_device
class vboysnd_device : public device_t, public device_sound_interface
{
public:
// construction/destruction
vboysnd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 5'000'000);
uint8_t read(offs_t offset);
void write(offs_t offset, uint8_t data);
sound_stream *m_stream;
protected:
static constexpr unsigned CHANNELS = 4;
struct s_snd_channel {
int8_t playing; // the sound is playing
// state when sound was enabled
uint32_t env_steptime; // Envelope step time
uint8_t env0; // Envelope data
uint8_t env1; // Envelope data
uint8_t volLeft; // Left output volume
uint8_t volRight; // Right output volume
uint8_t sample[580]; // sample to play
int sample_len; // length of sample
// values that change, as the sample is played
int offset; // current offset in sample
int time; // the duration that this sample is to be played
uint8_t envelope; // Current envelope level (604)
int env_time; // The duration between envelope decay/grow (608)
};
struct s_regchan {
int32_t sINT;
int32_t sLRV;
int32_t sFQL;
int32_t sFQH;
int32_t sEV0;
int32_t sEV1;
int32_t sRAM;
};
struct s_sreg {
// Sound registers structure
s_regchan c[4];
};
// device-level overrides
virtual void device_start() override;
virtual void device_clock_changed() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
s_snd_channel snd_channel[5];
uint16_t waveFreq2LenTbl[2048];
uint16_t waveTimer2LenTbl[32];
uint16_t waveEnv2LenTbl[8];
emu_timer *m_timer;
uint8_t m_aram[0x600];
};
// device type definition
DECLARE_DEVICE_TYPE(VBOYSND, vboysnd_device)
#endif //MAME_AUDIO_VBOY_H
|