From 8515230aa680a60f3ddce6b0cac852dc81392177 Mon Sep 17 00:00:00 2001 From: retrowertz Date: Wed, 21 Mar 2018 10:08:25 +0800 Subject: [PATCH] Remove more unneeded files --- nes_emu/Nes_Vrc6.cpp | 224 ------------------------------------------- nes_emu/Nes_Vrc6.h | 85 ---------------- 2 files changed, 309 deletions(-) delete mode 100644 nes_emu/Nes_Vrc6.cpp delete mode 100644 nes_emu/Nes_Vrc6.h diff --git a/nes_emu/Nes_Vrc6.cpp b/nes_emu/Nes_Vrc6.cpp deleted file mode 100644 index 5b7e8ca..0000000 --- a/nes_emu/Nes_Vrc6.cpp +++ /dev/null @@ -1,224 +0,0 @@ - -// Nes_Snd_Emu 0.1.7. http://www.slack.net/~ant/libs/ - -#include "Nes_Vrc6.h" - -/* Copyright (C) 2003-2005 Shay Green. This module is free software; you -can redistribute it and/or modify it under the terms of the GNU Lesser -General Public License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. This -module is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for -more details. You should have received a copy of the GNU Lesser General -Public License along with this module; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -Nes_Vrc6::Nes_Vrc6() -{ - output( NULL ); - volume( 1.0 ); - reset(); -} - -Nes_Vrc6::~Nes_Vrc6() -{ -} - -void Nes_Vrc6::reset() -{ - last_time = 0; - for ( int i = 0; i < osc_count; i++ ) - { - Vrc6_Osc& osc = oscs [i]; - for ( int j = 0; j < reg_count; j++ ) - osc.regs [j] = 0; - osc.delay = 0; - osc.last_amp = 0; - osc.phase = 1; - osc.amp = 0; - } -} - -void Nes_Vrc6::volume( double v ) -{ - double const factor = 0.0967 * 2; - saw_synth.volume_unit( factor / 31 * v ); - square_synth.volume_unit( factor * 0.5 / 15 * v ); -} - -void Nes_Vrc6::treble_eq( blip_eq_t const& eq ) -{ - saw_synth.treble_eq( eq ); - square_synth.treble_eq( eq ); -} - -void Nes_Vrc6::output( Blip_Buffer* buf ) -{ - for ( int i = 0; i < osc_count; i++ ) - osc_output( i, buf ); -} - -void Nes_Vrc6::run_until( nes_time_t time ) -{ - run_square( oscs [0], time ); - run_square( oscs [1], time ); - run_saw( time ); - last_time = time; -} - -void Nes_Vrc6::write_osc( nes_time_t time, int osc_index, int reg, int data ) -{ - run_until( time ); - oscs [osc_index].regs [reg] = data; -} - -void Nes_Vrc6::end_frame( nes_time_t time ) -{ - if ( time > last_time ) - run_until( time ); - last_time -= time; -} - -void Nes_Vrc6::save_snapshot( vrc6_snapshot_t* out ) const -{ - out->saw_amp = oscs [2].amp; - for ( int i = 0; i < osc_count; i++ ) - { - Vrc6_Osc const& osc = oscs [i]; - for ( int r = 0; r < reg_count; r++ ) - out->regs [i] [r] = osc.regs [r]; - - out->delays [i] = osc.delay; - out->phases [i] = osc.phase; - } -} - -void Nes_Vrc6::load_snapshot( vrc6_snapshot_t const& in ) -{ - reset(); - oscs [2].amp = in.saw_amp; - for ( int i = 0; i < osc_count; i++ ) - { - Vrc6_Osc& osc = oscs [i]; - for ( int r = 0; r < reg_count; r++ ) - osc.regs [r] = in.regs [i] [r]; - - osc.delay = in.delays [i]; - osc.phase = in.phases [i]; - } - if ( !oscs [2].phase ) - oscs [2].phase = 1; -} - -#include BLARGG_ENABLE_OPTIMIZER - -void Nes_Vrc6::run_square( Vrc6_Osc& osc, nes_time_t end_time ) -{ - Blip_Buffer* output = osc.output; - if ( !output ) - return; - - int volume = osc.regs [0] & 15; - if ( !(osc.regs [2] & 0x80) ) - volume = 0; - - int gate = osc.regs [0] & 0x80; - int duty = ((osc.regs [0] >> 4) & 7) + 1; - int delta = ((gate || osc.phase < duty) ? volume : 0) - osc.last_amp; - nes_time_t time = last_time; - if ( delta ) - { - osc.last_amp += delta; - square_synth.offset( time, delta, output ); - } - - time += osc.delay; - osc.delay = 0; - int period = osc.period(); - if ( volume && !gate && period > 4 ) - { - if ( time < end_time ) - { - int phase = osc.phase; - - do - { - phase++; - if ( phase == 16 ) - { - phase = 0; - osc.last_amp = volume; - square_synth.offset( time, volume, output ); - } - if ( phase == duty ) - { - osc.last_amp = 0; - square_synth.offset( time, -volume, output ); - } - time += period; - } - while ( time < end_time ); - - osc.phase = phase; - } - osc.delay = time - end_time; - } -} - -void Nes_Vrc6::run_saw( nes_time_t end_time ) -{ - Vrc6_Osc& osc = oscs [2]; - Blip_Buffer* output = osc.output; - if ( !output ) - return; - - int amp = osc.amp; - int amp_step = osc.regs [0] & 0x3F; - nes_time_t time = last_time; - int last_amp = osc.last_amp; - if ( !(osc.regs [2] & 0x80) || !(amp_step | amp) ) - { - osc.delay = 0; - int delta = (amp >> 3) - last_amp; - last_amp = amp >> 3; - saw_synth.offset( time, delta, output ); - } - else - { - time += osc.delay; - if ( time < end_time ) - { - int period = osc.period() * 2; - int phase = osc.phase; - - do - { - if ( --phase == 0 ) - { - phase = 7; - amp = 0; - } - - int delta = (amp >> 3) - last_amp; - if ( delta ) - { - last_amp = amp >> 3; - saw_synth.offset( time, delta, output ); - } - - time += period; - amp = (amp + amp_step) & 0xFF; - } - while ( time < end_time ); - - osc.phase = phase; - osc.amp = amp; - } - - osc.delay = time - end_time; - } - - osc.last_amp = last_amp; -} - diff --git a/nes_emu/Nes_Vrc6.h b/nes_emu/Nes_Vrc6.h deleted file mode 100644 index 94d3fdc..0000000 --- a/nes_emu/Nes_Vrc6.h +++ /dev/null @@ -1,85 +0,0 @@ - -// Konami VRC6 sound chip emulator - -// Nes_Snd_Emu 0.1.7. Copyright (C) 2003-2005 Shay Green. GNU LGPL license. - -#ifndef NES_VRC6_H -#define NES_VRC6_H - -#include "Nes_Apu.h" -#include "Blip_Buffer.h" - -struct vrc6_snapshot_t; - -class Nes_Vrc6 { -public: - Nes_Vrc6(); - ~Nes_Vrc6(); - - // See Nes_Apu.h for reference - void reset(); - void volume( double ); - void treble_eq( blip_eq_t const& ); - void output( Blip_Buffer* ); - enum { osc_count = 3 }; - void osc_output( int index, Blip_Buffer* ); - void end_frame( nes_time_t ); - void save_snapshot( vrc6_snapshot_t* ) const; - void load_snapshot( vrc6_snapshot_t const& ); - - // Oscillator 0 write-only registers are at $9000-$9002 - // Oscillator 1 write-only registers are at $A000-$A002 - // Oscillator 2 write-only registers are at $B000-$B002 - enum { reg_count = 3 }; - enum { base_addr = 0x9000 }; - enum { addr_step = 0x1000 }; - void write_osc( nes_time_t, int osc, int reg, int data ); - -private: - // noncopyable - Nes_Vrc6( const Nes_Vrc6& ); - Nes_Vrc6& operator = ( const Nes_Vrc6& ); - - struct Vrc6_Osc - { - uint8_t regs [3]; - Blip_Buffer* output; - int delay; - int last_amp; - int phase; - int amp; // only used by saw - - int period() const - { - return (regs [2] & 0x0f) * 0x100L + regs [1] + 1; - } - }; - - Vrc6_Osc oscs [osc_count]; - nes_time_t last_time; - - Blip_Synth saw_synth; - Blip_Synth square_synth; - - void run_until( nes_time_t ); - void run_square( Vrc6_Osc& osc, nes_time_t ); - void run_saw( nes_time_t ); -}; - -struct vrc6_snapshot_t -{ - uint8_t regs [3] [3]; - uint8_t saw_amp; - uint16_t delays [3]; - uint8_t phases [3]; - uint8_t unused; -}; -BOOST_STATIC_ASSERT( sizeof (vrc6_snapshot_t) == 20 ); - -inline void Nes_Vrc6::osc_output( int i, Blip_Buffer* buf ) -{ - oscs [i].output = buf; -} - -#endif -