summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/nes_apu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/nes_apu.h')
-rw-r--r--src/devices/sound/nes_apu.h51
1 files changed, 34 insertions, 17 deletions
diff --git a/src/devices/sound/nes_apu.h b/src/devices/sound/nes_apu.h
index 673c967fec7..2ebfcf3f84b 100644
--- a/src/devices/sound/nes_apu.h
+++ b/src/devices/sound/nes_apu.h
@@ -4,16 +4,12 @@
MAME/MESS NES APU CORE
- Based on the Nofrendo/Nosefart NES N2A03 sound emulation core written by
+ Based on the Nofrendo/Nosefart NES RP2A03 sound emulation core written by
Matthew Conte (matt@conte.com) and redesigned for use in MAME/MESS by
Who Wants to Know? (wwtk@mail.com)
This core is written with the advise and consent of Matthew Conte and is
- released under the GNU Public License. This core is freely available for
- use in any freeware project, subject to the following terms:
-
- Any modifications to this code must be duly noted in the source and
- approved by Matthew Conte and myself prior to public submission.
+ released under the GNU Public License.
*****************************************************************************
@@ -52,11 +48,11 @@ public:
virtual void device_reset() override;
virtual void device_clock_changed() override;
- u8 read(offs_t offset);
+ u8 status_r();
void write(offs_t offset, u8 data);
protected:
- nesapu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+ nesapu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
// device-level overrides
virtual void device_start() override;
@@ -64,31 +60,52 @@ protected:
// sound stream update overrides
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
+ virtual void update_lfsr(apu_t::noise_t &chan);
+
private:
/* GLOBAL CONSTANTS */
static constexpr unsigned SYNCS_MAX1 = 0x20;
static constexpr unsigned SYNCS_MAX2 = 0x80;
+ static constexpr u32 NTSC_APU_CLOCK = 21477272 / 12;
+ static constexpr u32 PAL_APU_CLOCK = 26601712 / 16;
// internal state
apu_t m_APU; /* Actual APUs */
+ u8 m_is_pal;
u32 m_samps_per_sync; /* Number of samples per vsync */
- u32 m_buffer_size; /* Actual buffer size in bytes */
- u32 m_vbl_times[0x20]; /* VBL durations in samples */
+ u32 m_vbl_times[SYNCS_MAX1]; /* VBL durations in samples */
u32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */
u32 m_sync_times2[SYNCS_MAX2]; /* Samples per sync table */
+ stream_buffer::sample_t m_square_lut[31]; // Non-linear Square wave output LUT
+ stream_buffer::sample_t m_tnd_lut[16][16][128]; // Non-linear Triangle, Noise, DMC output LUT
+
sound_stream *m_stream;
devcb_write_line m_irq_handler;
devcb_read8 m_mem_read_cb;
+ emu_timer *m_frame_timer;
+ attotime m_frame_period;
+ u16 m_frame_clocks;
+
+ TIMER_CALLBACK_MEMBER(frame_timer_cb);
void calculate_rates();
- void create_syncs(unsigned long sps);
- s8 apu_square(apu_t::square_t *chan);
- s8 apu_triangle(apu_t::triangle_t *chan);
- s8 apu_noise(apu_t::noise_t *chan);
- s8 apu_dpcm(apu_t::dpcm_t *chan);
- inline void apu_regwrite(int address, u8 value);
+ void apu_square(apu_t::square_t *chan);
+ void apu_triangle(apu_t::triangle_t *chan);
+ void apu_noise(apu_t::noise_t *chan);
+ void apu_dpcm(apu_t::dpcm_t *chan);
};
-DECLARE_DEVICE_TYPE(NES_APU, nesapu_device)
+class apu2a03_device : public nesapu_device
+{
+public:
+ apu2a03_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ virtual void update_lfsr(apu_t::noise_t &chan) override;
+};
+
+
+DECLARE_DEVICE_TYPE(NES_APU, nesapu_device)
+DECLARE_DEVICE_TYPE(APU_2A03, apu2a03_device)
#endif // MAME_SOUND_NES_APU_H