break out cassette FFWD to tone function and expose to user

This commit is contained in:
Christopher Mosher 2019-01-21 21:37:22 -05:00
parent 0e29c34f79
commit 5ec3f59f2e
5 changed files with 30 additions and 8 deletions

View File

@ -52,9 +52,15 @@ The tape is automatically positioned at the first header tone.
+cassette rewind+ +cassette rewind+
This command rewinds the tape currently on the CASSETTE IN port. This command rewinds the tape currently on the CASSETTE IN port. After rewinding
This command first positions the tape to its beginning, the tape, you will typically need to fast-forward to the head tone using
and then ``fast-forwards'' to the first header tone. the +cassette tone+ command.
+cassette tone+
If more than one program is stored in one WAVE file, then after loading the first
program, you may need to fast-forward to the next header tone. This command will
do just that.
+cassette blank <file-path>+ +cassette blank <file-path>+

View File

@ -170,6 +170,7 @@ The +cassette+ command performs various operations of the emulated cassette tape
-------- --------
cassette load [ <file-path> ] cassette load [ <file-path> ]
cassette rewind cassette rewind
cassette tone
cassette blank <file-path> cassette blank <file-path>
cassette save cassette save
cassette eject { in | out } cassette eject { in | out }

View File

@ -157,17 +157,26 @@ void CassetteIn::rewind() {
this->playing = false; this->playing = false;
note_pos(); note_pos();
this->gui.setCassettePos(this->t/10,this->samp_siz);
}
void CassetteIn::tone() {
if (!isLoaded()) {
return;
}
note_pos();
note("FAST FORWARD TO TONE"); note("FAST FORWARD TO TONE");
this->playing = false;
const unsigned int HEAD_SAMPLES = 17; const unsigned int HEAD_SAMPLES = 17;
std::int_fast8_t slope_was = 0; std::int_fast8_t slope_was = 0;
uint i_was = 0; std::uint_fast32_t i_was = 0;
uint c_head = 0; std::uint_fast32_t c_head = 0;
for (std::uint_fast32_t i = 1; i < this->samp_siz; ++i) {
const std::uint_fast32_t start = this->t/10 > 0 ? this->t/10 : 1;
for (std::uint_fast32_t i = start; i < this->samp_siz; ++i) {
std::int_fast8_t slope_is = slope(this->samp[i-1], this->samp[i]); std::int_fast8_t slope_is = slope(this->samp[i-1], this->samp[i]);
if (slope_is) { if (slope_is) {
if (slope_is != slope_was) { if (slope_is != slope_was) {
@ -244,6 +253,7 @@ bool CassetteIn::load(const std::string& filePath) {
this->gui.setCassetteInFile(filePath); this->gui.setCassetteInFile(filePath);
rewind(); rewind();
tone();
return true; return true;
} }

View File

@ -42,6 +42,7 @@ public:
bool load(const std::string& filePath); bool load(const std::string& filePath);
void rewind(); void rewind();
void tone();
virtual bool eject(); virtual bool eject();
}; };

View File

@ -304,6 +304,10 @@ void Config::tryParseLine(const std::string& line, Memory& ram, Memory& rom, Slo
{ {
cassetteIn.rewind(); cassetteIn.rewind();
} }
else if (cas == "tone")
{
cassetteIn.tone();
}
else if (cas == "blank") else if (cas == "blank")
{ {
std::string fcas; std::string fcas;