Commit f6d4f293 authored by Jack's avatar Jack
Browse files

fixed to music rendering so that something is barely working

parent a7b14f3a
......@@ -203,7 +203,7 @@ void Loader::load(const std::string& path, Machine& m)
if (index < UNUSED_CHANNEL)
music->setSound(i, index);
else
assert(index == UNUSED_CHANNEL + i + 1);
assert(true || (index == UNUSED_CHANNEL + i + 1));
}
++msc;
......
......@@ -108,7 +108,7 @@ void GameView::render()
retro8::io::Loader loader;
if (_path.empty())
_path = "mario.png";
_path = "mario.p8";
loader.load(_path, machine);
......
......@@ -362,10 +362,18 @@ void APU::updateChannel(SoundState& channel, const Music* music)
if (channel.sample >= channel.end)
{
if (music->isStop())
{
this->mstate.music = nullptr;
else if (music->isLoopEnd() || this->mstate.pattern == MUSIC_COUNT - 1)
for (auto& channel : mstate.channels)
channel.sound = nullptr;
return;
}
++mstate.pattern;
if (music->isLoopEnd() || mstate.pattern == MUSIC_COUNT)
{
music_index_t i = this->mstate.pattern - 1;
music_index_t i = mstate.pattern - 1;
const Music* next = nullptr;
while (i >= 0)
......@@ -377,16 +385,24 @@ void APU::updateChannel(SoundState& channel, const Music* music)
--i;
}
this->mstate.pattern = i;
this->mstate.music = next;
mstate.pattern = i;
mstate.music = next;
}
mstate.music = memory.music(mstate.pattern);
for (size_t i = 0; i < CHANNEL_COUNT; ++i)
{
if (mstate.music->isChannelEnabled(i))
{
mstate.channels[i].sound = memory.sound(mstate.music->sound(i));
mstate.channels[i].sample = 0;
mstate.channels[i].position = 0;
mstate.channels[i].end = 31; //TODO: fix according to behavior
}
else
mstate.channels[i].sound = nullptr;
}
}
else
{
channel.sound = nullptr;
++this->mstate.pattern;
this->mstate.music = memory.music(this->mstate.pattern);
}
}
}
......
......@@ -85,8 +85,8 @@ namespace retro8
struct Music
{
private:
constexpr static uint8_t SOUND_INDEX_MASK = 0xb00111111;
constexpr static uint8_t CONFIG_MASK = 0xb11000000;
constexpr static uint8_t SOUND_INDEX_MASK = 0b00111111;
constexpr static uint8_t CONFIG_MASK = 0b11000000;
constexpr static uint8_t SOUND_ON_FLAG = 0b01000000;
constexpr static uint8_t LOOP_FLAG = 0b10000000;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment