fixed fast forward
This commit is contained in:
parent
37c4d267c4
commit
89a1b4cec6
@ -127,8 +127,6 @@ typedef struct {
|
||||
float right_cap;
|
||||
|
||||
int history_timer;
|
||||
float smooth_left;
|
||||
float smooth_right;
|
||||
|
||||
double cycles_needed;
|
||||
|
||||
|
@ -10,6 +10,7 @@ typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
|
||||
#define FAST_FORWARD_SPEED 2
|
||||
#define BIT(a, n) ((a & (1 << n)) ? 1 : 0)
|
||||
#define BIT_SET(a, n, on) {if(on) a |= (1 << n); else a &= ~(1 << n);}
|
||||
#define BETWEEN(a, b, c) ((a >= b) && (a <= c))
|
||||
|
@ -8,6 +8,7 @@ typedef struct {
|
||||
bool die;
|
||||
u64 ticks;
|
||||
const char *app_path;
|
||||
bool fast_forward;
|
||||
} emu_context;
|
||||
|
||||
int emu_run(int, char**);
|
||||
|
32
lib/audio.c
32
lib/audio.c
@ -8,10 +8,9 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SAMPLE_RATE 44100.0
|
||||
#define SAMPLE_RATE 192000.0
|
||||
#define FRAMES_PER_BUFFER 64
|
||||
#define SAMPLES_PER_AUDIO_TICK SAMPLE_RATE / 4194304.0
|
||||
#define LPF_BETA 0.025f
|
||||
#define HISTORY_INTERVAL 5
|
||||
|
||||
const u8 square_sample_00[8] = {
|
||||
@ -282,19 +281,8 @@ void audio_sample_tick() {
|
||||
u8 right_vol = ctx.volume_right == 0 ? 1 : ctx.volume_right;
|
||||
left *= (float)left_vol/7.0f;
|
||||
right *= (float)right_vol/7.0f;
|
||||
ctx.smooth_left = ctx.smooth_left - (LPF_BETA * (ctx.smooth_left - left));
|
||||
ctx.smooth_right = ctx.smooth_right - (LPF_BETA * (ctx.smooth_right - right));
|
||||
ctx.cycles_needed += SAMPLES_PER_AUDIO_TICK;
|
||||
ctx.cycles_needed += emu_get_context()->fast_forward ? SAMPLES_PER_AUDIO_TICK/FAST_FORWARD_SPEED : SAMPLES_PER_AUDIO_TICK;
|
||||
if(ctx.cycles_needed > 1){
|
||||
//printf("tick\n");
|
||||
//if(ctx.buffer_cnt == AUDIO_BUFFER_SIZE){
|
||||
//ctx.buffer_cnt--;
|
||||
//ctx.sq1_read_index++;
|
||||
//ctx.sq1_read_index %= AUDIO_BUFFER_SIZE;
|
||||
//delay(1);
|
||||
//printf("overflow\n");
|
||||
//return;
|
||||
//}
|
||||
ctx.cycles_needed -= 1;
|
||||
|
||||
|
||||
@ -302,10 +290,10 @@ void audio_sample_tick() {
|
||||
float left_out = 0;
|
||||
float right_out = 0;
|
||||
if(dacs) {
|
||||
left_out = ctx.smooth_left - ctx.left_cap;
|
||||
right_out = ctx.smooth_right - ctx.right_cap;
|
||||
ctx.left_cap = ctx.smooth_left - left_out * 0.999958;
|
||||
ctx.right_cap = ctx.smooth_right - right_out * 0.999958;
|
||||
left_out = left - ctx.left_cap;
|
||||
right_out = right - ctx.right_cap;
|
||||
ctx.left_cap = left - left_out * 0.999958;
|
||||
ctx.right_cap = right - right_out * 0.999958;
|
||||
}
|
||||
|
||||
|
||||
@ -325,10 +313,12 @@ void audio_sample_tick() {
|
||||
right_out = 1;
|
||||
}
|
||||
|
||||
ctx.left_audio_buffer[(ctx.buffer_write_index)] = left_out;
|
||||
ctx.right_audio_buffer[(ctx.buffer_write_index)] = right_out;
|
||||
if(ctx.buffer_write_index < FRAMES_PER_BUFFER){
|
||||
ctx.left_audio_buffer[(ctx.buffer_write_index)] = left_out;
|
||||
ctx.right_audio_buffer[(ctx.buffer_write_index)] = right_out;
|
||||
ctx.buffer_write_index++;
|
||||
}
|
||||
|
||||
ctx.buffer_write_index++;
|
||||
ctx.history_timer++;
|
||||
if(ctx.history_timer >= HISTORY_INTERVAL){
|
||||
ctx.history_timer = 0;
|
||||
|
8
lib/ui.c
8
lib/ui.c
@ -282,13 +282,11 @@ void ui_update() {
|
||||
update_debug_window();
|
||||
}
|
||||
|
||||
static bool ff = false;
|
||||
|
||||
void ui_on_key(bool down, u32 key_code) {
|
||||
if(key_code == SDLK_SPACE && down == true) {
|
||||
ff = !ff;
|
||||
if(ff){
|
||||
ppu_get_context()->target_frame_time = 1000/300;
|
||||
emu_get_context()->fast_forward = !emu_get_context()->fast_forward;
|
||||
if(emu_get_context()->fast_forward){
|
||||
ppu_get_context()->target_frame_time = 1000/(60 * FAST_FORWARD_SPEED);
|
||||
} else {
|
||||
ppu_get_context()->target_frame_time = 1000/60;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user