From 7eabebb97f36c0a8774dc093737d93b0845cebf5 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 2 Feb 2022 02:43:40 +0100 Subject: [PATCH 1/5] More temporary reverts. --- src/86box.c | 4 +++- src/cpu/cpu.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/86box.c b/src/86box.c index bdd5f4ffa..a5c2483c9 100644 --- a/src/86box.c +++ b/src/86box.c @@ -1049,7 +1049,9 @@ pc_reset_hard_init(void) pc_full_speed(); cycles = 0; - fpu_cycles = 0; +#ifdef FPU_CYCLES + fpu_cycles = 0; +#endif #ifdef USE_DYNAREC cycles_main = 0; #endif diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 690869424..c140cb7db 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -354,7 +354,11 @@ typedef struct { uint8_t ssegs, ismmx, abrt, _smi_line; +#ifdef FPU_CYCLES int _cycles, _fpu_cycles, _in_smm; +#else + int _cycles, _in_smm; +#endif uint16_t npxs, npxc; @@ -457,7 +461,9 @@ COMPILE_TIME_ASSERT(sizeof(cpu_state_t) <= 128) #define DI cpu_state.regs[7].w #define cycles cpu_state._cycles +#ifdef FPU_CYCLES #define fpu_cycles cpu_state._fpu_cycles +#endif #define cpu_rm cpu_state.rm_data.rm_mod_reg.rm #define cpu_mod cpu_state.rm_data.rm_mod_reg.mod From 25e8801ede02bd87cb6929f3406422acd3c1ca55 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 2 Feb 2022 02:46:11 +0100 Subject: [PATCH 2/5] And more. --- src/cpu/386.c | 5 +++-- src/cpu/386_dynarec.c | 4 ++-- src/cpu/386_dynarec_ops.c | 2 ++ src/cpu/808x.c | 7 +++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cpu/386.c b/src/cpu/386.c index 1340b1479..6cec5ee43 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -93,12 +93,13 @@ x386_log(const char *fmt, ...) cycles -= (c);\ }\ } + +#define CLOCK_CYCLES_FPU(c) cycles -= (c) +#define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #else #define CLOCK_CYCLES(c) cycles -= (c) #endif -#define CLOCK_CYCLES_FPU(c) cycles -= (c) -#define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) #include "x86_ops.h" diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index bb61cce88..c72da124b 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -279,11 +279,11 @@ static void prefetch_flush() cycles -= (c);\ }\ } +#define CLOCK_CYCLES_FPU(c) cycles -= (c) +#define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #else #define CLOCK_CYCLES(c) cycles -= (c) #endif -#define CLOCK_CYCLES_FPU(c) cycles -= (c) -#define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) diff --git a/src/cpu/386_dynarec_ops.c b/src/cpu/386_dynarec_ops.c index 40aa2db80..c90673066 100644 --- a/src/cpu/386_dynarec_ops.c +++ b/src/cpu/386_dynarec_ops.c @@ -65,8 +65,10 @@ static __inline void fetch_ea_16_long(uint32_t rmdat) #define OP_TABLE(name) dynarec_ops_ ## name #define CLOCK_CYCLES(c) +#if 0 #define CLOCK_CYCLES_FPU(c) #define CONCURRENCY_CYCLES(c) fpu_cycles = (c) +#endif #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) #include "386_ops.h" diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 827ec5b1c..191ff97cd 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -89,6 +89,7 @@ static int refresh = 0, cycdiff; wait(val, 0); \ } +#if 0 #define CLOCK_CYCLES_ALWAYS(val) \ { \ wait(val, 0); \ @@ -113,6 +114,12 @@ static int refresh = 0, cycdiff; } #define CONCURRENCY_CYCLES(c) fpu_cycles = (c) +#else +#define CLOCK_CYCLES(val) \ + { \ + wait(val, 0); \ + } +#endif typedef int (*OpFn)(uint32_t fetchdat); From b3a8d0aaed1632f790b37e0fc1bb83917f0c22d0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 2 Feb 2022 02:51:18 +0100 Subject: [PATCH 3/5] And more. --- src/cpu/386.c | 2 ++ src/cpu/386_dynarec.c | 2 ++ src/cpu/386_dynarec_ops.c | 3 +++ src/cpu/808x.c | 9 ++++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cpu/386.c b/src/cpu/386.c index 6cec5ee43..6af8173eb 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -98,6 +98,8 @@ x386_log(const char *fmt, ...) #define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #else #define CLOCK_CYCLES(c) cycles -= (c) +#define CLOCK_CYCLES_FPU(c) cycles -= (c) +#define CONCURRENCY_CYCLES(c) #endif #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index c72da124b..4371efd00 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -283,6 +283,8 @@ static void prefetch_flush() #define CONCURRENCY_CYCLES(c) fpu_cycles = (c) #else #define CLOCK_CYCLES(c) cycles -= (c) +#define CLOCK_CYCLES_FPU(c) cycles -= (c) +#define CONCURRENCY_CYCLES(c) #endif #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) diff --git a/src/cpu/386_dynarec_ops.c b/src/cpu/386_dynarec_ops.c index c90673066..2eb3a5f00 100644 --- a/src/cpu/386_dynarec_ops.c +++ b/src/cpu/386_dynarec_ops.c @@ -68,6 +68,9 @@ static __inline void fetch_ea_16_long(uint32_t rmdat) #if 0 #define CLOCK_CYCLES_FPU(c) #define CONCURRENCY_CYCLES(c) fpu_cycles = (c) +#else +#define CLOCK_CYCLES_FPU(c) +#define CONCURRENCY_CYCLES(c) #endif #define CLOCK_CYCLES_ALWAYS(c) cycles -= (c) diff --git a/src/cpu/808x.c b/src/cpu/808x.c index 191ff97cd..023d89a60 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -89,12 +89,12 @@ static int refresh = 0, cycdiff; wait(val, 0); \ } -#if 0 #define CLOCK_CYCLES_ALWAYS(val) \ { \ wait(val, 0); \ } +#if 0 #define CLOCK_CYCLES_FPU(val) \ { \ wait(val, 0); \ @@ -119,6 +119,13 @@ static int refresh = 0, cycdiff; { \ wait(val, 0); \ } + +#define CLOCK_CYCLES_FPU(val) \ + { \ + wait(val, 0); \ + } + +#define CONCURRENCY_CYCLES(c) #endif From cceda2c16ec825efdc907f64d109c90546d2a309 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 2 Feb 2022 21:13:10 +0600 Subject: [PATCH 4/5] Fix brief extreme noise on hard resets --- src/sound/sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sound/sound.c b/src/sound/sound.c index b92062665..9ba4fb3df 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -344,9 +344,9 @@ sound_realloc_buffers(void) free(outbuffer_ex_int16); if (sound_is_float) - outbuffer_ex = malloc(SOUNDBUFLEN * 2 * sizeof(float)); + outbuffer_ex = calloc(SOUNDBUFLEN * 2, sizeof(float)); else - outbuffer_ex_int16 = malloc(SOUNDBUFLEN * 2 * sizeof(int16_t)); + outbuffer_ex_int16 = calloc(SOUNDBUFLEN * 2, sizeof(int16_t)); } @@ -359,7 +359,7 @@ sound_init(void) outbuffer_ex = NULL; outbuffer_ex_int16 = NULL; - outbuffer = malloc(SOUNDBUFLEN * 2 * sizeof(int32_t)); + outbuffer = calloc(SOUNDBUFLEN * 2, sizeof(int32_t)); for (i = 0; i < CDROM_NUM; i++) { if (cdrom[i].bus_type != CDROM_BUS_DISABLED) From 2e723683d0a1ef3672b707151456fa46a00d695b Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 2 Feb 2022 21:19:39 +0600 Subject: [PATCH 5/5] Clean speaker sound buffer on each init --- src/sound/snd_speaker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sound/snd_speaker.c b/src/sound/snd_speaker.c index d2ed41b82..027febf40 100644 --- a/src/sound/snd_speaker.c +++ b/src/sound/snd_speaker.c @@ -106,6 +106,7 @@ speaker_get_buffer(int32_t *buffer, int len, void *p) void speaker_init(void) { + memset(speaker_buffer, 0, sizeof(speaker_buffer)); sound_add_handler(speaker_get_buffer, NULL); speaker_mute = 0; }