-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the missing files and fixed 2 small bugs
- Loading branch information
1 parent
33cd11a
commit 86907fd
Showing
5 changed files
with
289 additions
and
10 deletions.
There are no files selected for viewing
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,173 @@ | ||
/* | ||
PeePeePlayer - an old-fashioned module player | ||
Copyright (C) 2011 Steffen Ohrendorf <[email protected]> | ||
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 3 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @ingroup XmModule | ||
* @{ | ||
*/ | ||
|
||
#include "xmcell.h" | ||
|
||
#include "xmbase.h" | ||
#include "genmod/genbase.h" | ||
#include "stream/iarchive.h" | ||
|
||
namespace ppp { | ||
namespace xm { | ||
|
||
XmCell::XmCell() : GenCell(), m_note(0), m_instr(0), m_volume(0), m_effect(Effect::None), m_effectValue(0) { | ||
} | ||
|
||
XmCell::~XmCell() = default; | ||
|
||
bool XmCell::load(BinStream& str) { | ||
uint8_t data; | ||
str.read(&data); | ||
if((data & 0x80) == 0) { | ||
m_note = data; | ||
str.read(&m_instr).read(&m_volume).read(reinterpret_cast<uint8_t*>(&m_effect)).read(&m_effectValue); | ||
return !str.fail(); | ||
} | ||
if(data & 0x01) | ||
str.read(&m_note); | ||
if(data & 0x02) | ||
str.read(&m_instr); | ||
if(data & 0x04) | ||
str.read(&m_volume); | ||
if(data & 0x08) | ||
str.read(reinterpret_cast<uint8_t*>(&m_effect)); | ||
if(data & 0x10) | ||
str.read(&m_effectValue); | ||
return !str.fail(); | ||
} | ||
|
||
void XmCell::clear() { | ||
m_note = 0; | ||
m_instr = 0xff; | ||
m_volume = 0; | ||
m_effect = Effect::None; | ||
m_effectValue = 0; | ||
} | ||
|
||
std::string XmCell::fxString() const { | ||
if(m_effect == Effect::None) { | ||
return "..."; | ||
} | ||
else if(static_cast<uint8_t>(m_effect) <= 0x0f) { | ||
return stringf("%1X%.2X", static_cast<uint8_t>(m_effect), m_effectValue); | ||
} | ||
else if(static_cast<uint8_t>(m_effect) <= 0x21) { | ||
return stringf("%c%.2X", static_cast<uint8_t>(m_effect) - 0x0f + 'F', m_effectValue); | ||
} | ||
else { | ||
return stringf("?%.2X", m_effectValue); | ||
} | ||
} | ||
|
||
std::string XmCell::noteString() const { | ||
if(m_note == 0) { | ||
return "..."; | ||
} | ||
else if(m_note == KeyOffNote) { | ||
return "==="; | ||
} | ||
else if(m_note < KeyOffNote) { | ||
return stringf("%s%d", NoteNames.at((m_note - 1) % 12), (m_note - 1) / 12); | ||
} | ||
else { | ||
return "???"; | ||
} | ||
} | ||
|
||
std::string XmCell::trackerString() const { | ||
/* if(!isActive()) | ||
return "... ...";*/ | ||
std::string xmsg = noteString(); | ||
if(m_instr == 0) { | ||
xmsg += " "; | ||
} | ||
else { | ||
xmsg += stringf(" %2X ", m_instr); | ||
} | ||
/* | ||
VfxVolSlideDown = 6, | ||
VfxVolSlideUp = 7, | ||
VfxFineVolSlideDown = 8, | ||
VfxFineVolSlideUp = 9, | ||
VfxSetVibSpeed = 0xa, | ||
VfxVibrato = 0xb, | ||
VfxSetPanning = 0xc, | ||
VfxPanSlideLeft = 0xd, | ||
VfxPanSlideRight = 0xe, | ||
VfxPorta = 0xf | ||
*/ | ||
static const char vfxChars[] = "-+DUSVPLRM"; | ||
switch(highNibble(m_volume)) { | ||
case 0: | ||
xmsg += " "; | ||
break; | ||
case 1: | ||
case 2: | ||
case 3: | ||
case 4: | ||
case 5: | ||
xmsg += stringf("%2d ", m_volume - 0x10); | ||
break; | ||
default: | ||
xmsg += stringf("%c%X ", vfxChars[highNibble(m_volume) - 6], lowNibble(m_volume)); | ||
break; | ||
} | ||
return xmsg + fxString(); | ||
} | ||
|
||
uint8_t XmCell::note() const { | ||
return m_note; | ||
} | ||
|
||
uint8_t XmCell::instrument() const { | ||
return m_instr; | ||
} | ||
|
||
uint8_t XmCell::volume() const { | ||
return m_volume; | ||
} | ||
|
||
Effect XmCell::effect() const { | ||
return m_effect; | ||
} | ||
|
||
uint8_t XmCell::effectValue() const { | ||
return m_effectValue; | ||
} | ||
|
||
IArchive& XmCell::serialize(IArchive* data) { | ||
*data | ||
% m_note | ||
% m_instr | ||
% m_volume | ||
% *reinterpret_cast<uint8_t*>(&m_effect) | ||
% m_effectValue; | ||
return *data; | ||
} | ||
|
||
} | ||
} | ||
|
||
/** | ||
* @} | ||
*/ |
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,104 @@ | ||
/* | ||
PeePeePlayer - an old-fashioned module player | ||
Copyright (C) 2011 Steffen Ohrendorf <[email protected]> | ||
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 3 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. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef XMCELL_H | ||
#define XMCELL_H | ||
|
||
/** | ||
* @ingroup XmModule | ||
* @{ | ||
*/ | ||
|
||
#include "genmod/gencell.h" | ||
#include "xmbase.h" | ||
#include "stream/binstream.h" | ||
|
||
namespace ppp { | ||
namespace xm { | ||
|
||
/** | ||
* @class XmCell | ||
* @brief Cell of a pattern | ||
*/ | ||
class XmCell : public GenCell { | ||
public: | ||
typedef std::shared_ptr<XmCell> Ptr; //!< @brief Class pointer | ||
typedef std::vector<Ptr> Vector; //!< @brief Vector of class pointers | ||
private: | ||
uint8_t m_note; //!< @brief Note value | ||
uint8_t m_instr; //!< @brief Instrument value | ||
uint8_t m_volume; //!< @brief Volume value | ||
Effect m_effect; //!< @brief Effect | ||
uint8_t m_effectValue; //!< @brief Effect value | ||
public: | ||
XmCell(); | ||
virtual ~XmCell(); | ||
/** | ||
* @brief Load the cell data from a stream | ||
* @param[in] str The stream to load from | ||
* @return @c true on success | ||
*/ | ||
bool load(BinStream& str); | ||
virtual void clear(); | ||
virtual std::string trackerString() const; | ||
/** | ||
* @brief Get the note string, e.g. in the form "C#3" | ||
* @return The note string | ||
*/ | ||
std::string noteString() const; | ||
/** | ||
* @brief Get the string representation of the effect/value columns | ||
* @return String in the form of e.g. "R0A" | ||
*/ | ||
std::string fxString() const; | ||
/** | ||
* @brief Get the note value | ||
* @return m_note | ||
*/ | ||
uint8_t note() const; | ||
/** | ||
* @brief Get the instrument value | ||
* @return m_instrument | ||
*/ | ||
uint8_t instrument() const; | ||
/** | ||
* @brief Get the volume value | ||
* @return m_volume | ||
*/ | ||
uint8_t volume() const; | ||
/** | ||
* @brief Get the effect | ||
* @return m_effect | ||
*/ | ||
Effect effect() const; | ||
/** | ||
* @brief Get the effect value | ||
* @return m_effectValue | ||
*/ | ||
uint8_t effectValue() const; | ||
virtual IArchive& serialize(IArchive* data); | ||
}; | ||
|
||
} | ||
} | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#endif |
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