-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
148 additions
and
164 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Gb_Apu_Buffer.cpp - Gb_Apu subclass which allows direct buffer access | ||
* Copyright (c) 2017 Tres Finocchiaro <tres.finocchiaro/at/gmail.com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
#include "Gb_Apu.h" | ||
#include "Gb_Apu_Buffer.h" | ||
|
||
blip_time_t const FRAME_LENGTH = 70224; | ||
long const CLOCK_RATE = 4194304; | ||
|
||
Gb_Apu_Buffer::Gb_Apu_Buffer() : m_time(0) {} | ||
Gb_Apu_Buffer::~Gb_Apu_Buffer() {} | ||
|
||
void Gb_Apu_Buffer::write_register(blip_time_t ignore, unsigned addr, int data) { | ||
Gb_Apu::write_register(clock(), addr, data); | ||
} | ||
|
||
int Gb_Apu_Buffer::read_register(blip_time_t ignore, unsigned addr) { | ||
return Gb_Apu::read_register(clock(), addr); | ||
} | ||
|
||
void Gb_Apu_Buffer::end_frame(blip_time_t ignore) { | ||
m_time = 0; | ||
Gb_Apu::end_frame(FRAME_LENGTH); | ||
m_buf.end_frame(FRAME_LENGTH); | ||
} | ||
|
||
// Sets specified sample rate and hard-coded clock rate in Multi_Buffer | ||
blargg_err_t Gb_Apu_Buffer::set_sample_rate(long rate) { | ||
Gb_Apu_Buffer::output(m_buf.center(), m_buf.left(), m_buf.right()); | ||
m_buf.clock_rate(CLOCK_RATE); | ||
return m_buf.set_sample_rate(rate); | ||
} | ||
|
||
// Wrap Multi_Buffer::samples_avail() | ||
long Gb_Apu_Buffer::samples_avail() const { | ||
return m_buf.samples_avail(); | ||
} | ||
|
||
// Wrap Multi_Buffer::read_samples(...) | ||
long Gb_Apu_Buffer::read_samples(sample_t* out, long count) { | ||
return m_buf.read_samples(out, count); | ||
} | ||
|
||
void Gb_Apu_Buffer::bass_freq(int freq) { | ||
m_buf.bass_freq(freq); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Gb_Apu_Buffer.cpp - Gb_Apu subclass which allows direct buffer access | ||
* Copyright (c) 2017 Tres Finocchiaro <tres.finocchiaro/at/gmail.com> | ||
* | ||
* This file is part of LMMS - https://lmms.io | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program (see COPYING); if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
*/ | ||
#ifndef GB_APU_BUFFER_H | ||
#define GB_APU_BUFFER_H | ||
|
||
#include "Gb_Apu.h" | ||
#include "Multi_Buffer.h" | ||
#include "MemoryManager.h" | ||
|
||
class Gb_Apu_Buffer : public Gb_Apu { | ||
MM_OPERATORS | ||
public: | ||
Gb_Apu_Buffer(); | ||
~Gb_Apu_Buffer(); | ||
|
||
void write_register(blip_time_t, unsigned addr, int data); | ||
int read_register(blip_time_t, unsigned addr); | ||
void end_frame(blip_time_t); | ||
blargg_err_t set_sample_rate(long rate); | ||
long samples_avail() const; | ||
typedef blip_sample_t sample_t; | ||
long read_samples(sample_t* out, long count); | ||
|
||
void bass_freq(int freq); | ||
private: | ||
Stereo_Buffer m_buf; | ||
blip_time_t m_time; | ||
|
||
// faked CPU timing | ||
blip_time_t clock() { return m_time += 4; } | ||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.