Skip to content

Commit

Permalink
Zelda HLE: Properly implement the square wave generation.
Browse files Browse the repository at this point in the history
Zelda TWW magic meter works properly now.
  • Loading branch information
delroth committed Dec 20, 2014
1 parent 9f24427 commit 402d414
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Source/Core/Core/HW/DSPHLE/UCodes/Zelda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,16 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb)
switch (vpb->samples_source_type)
{
case VPB::SRC_SQUARE_WAVE:
{
u32 pos = vpb->current_pos_frac << 1;
for (size_t i = 0; i < buffer->size(); ++i)
(*buffer)[i] = (i & 1) ? 0x4000 : 0xC000;
{
(*buffer)[i] = ((pos >> 16) & 1) ? 0x4000 : 0xC000;
pos += vpb->resampling_ratio;
}
vpb->current_pos_frac = (pos >> 1) & 0xFFFF;
break;
}

case VPB::SRC_AFC_HQ_FROM_ARAM:
DownloadAFCSamplesFromARAM(raw_input_samples.data() + 4, vpb,
Expand Down

0 comments on commit 402d414

Please sign in to comment.