Skip to content

Commit

Permalink
Merging parts of ReGBA commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
gameblabla committed Jun 27, 2019
1 parent a9364d1 commit 62df27d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ typedef u32 fixed8_24;
#endif

#define FULLY_UNINITIALIZED(declarator) declarator __attribute__((section(".noinit")))
#define FP16_16_MAX_FRACTIONAL_PART 0xFFFF

#define FP16_16_TO_U32(value) ((value) >> 16)


#endif
8 changes: 4 additions & 4 deletions sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void sound_timer_queue32(u32 channel, u32 value)
sound_buffer[buffer_index + 1] += dest_sample \

#define render_samples(type) \
while(fifo_fractional <= 0xFFFFFF) \
while(fifo_fractional <= FP16_16_MAX_FRACTIONAL_PART) \
{ \
render_sample_##type(); \
fifo_fractional += frequency_step; \
Expand Down Expand Up @@ -447,10 +447,10 @@ void update_gbc_sound(u32 cpu_ticks)
gbc_sound_partial_ticks += fp16_16_fractional_part(buffer_ticks);
buffer_ticks = fp16_16_to_u32(buffer_ticks);

if(gbc_sound_partial_ticks > 0xFFFF)
if(gbc_sound_partial_ticks > FP16_16_MAX_FRACTIONAL_PART)
{
buffer_ticks += 1;
gbc_sound_partial_ticks &= 0xFFFF;
buffer_ticks += FP16_16_TO_U32(gbc_sound_partial_ticks);
gbc_sound_partial_ticks &= FP16_16_MAX_FRACTIONAL_PART;
}

SDL_LockMutex(sound_mutex);
Expand Down

0 comments on commit 62df27d

Please sign in to comment.