From 5171ebb35a96a5da5957e80e702a51a5bfc8ccdb Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 27 Aug 2021 17:23:42 +0500 Subject: [PATCH 1/5] Add a filter for CD de-emphasis, with coefficients calculated based on SoX's code This only adds the filter itself and needs hooking up to the rest of the code --- src/include/86box/filters.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/include/86box/filters.h b/src/include/86box/filters.h index ff11a05d4..98eff66e2 100644 --- a/src/include/86box/filters.h +++ b/src/include/86box/filters.h @@ -299,6 +299,37 @@ static inline double high_cut_iir(int c, int i, double NewSample) { return y[c][i][0]; } +/* fc=5.283kHz, gain=-9.477dB, width=0.4845 */ +static inline double deemph_iir(int i, double NewSample) { + double ACoef[NCoef+1] = { + 0.46035077886318842566, + -0.28440821191249848754, + 0.03388877229118691936 + }; + + double BCoef[NCoef+1] = { + 1.00000000000000000000, + -1.05429146278569141337, + 0.26412280202756849290 + }; + static double y[2][NCoef+1]; /* output samples */ + static double x[2][NCoef+1]; /* input samples */ + int n; + + /* shift the old samples */ + for(n=NCoef; n>0; n--) { + x[i][n] = x[i][n-1]; + y[i][n] = y[i][n-1]; + } + + /* Calculate the new output */ + x[i][0] = NewSample; + y[i][0] = ACoef[0] * x[i][0]; + for(n=1; n<=NCoef; n++) + y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; + + return y[i][0]; +} #undef NCoef #define NCoef 2 From a68ac70c470f1ceea09c324cfa1dcd8c2489f35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Fri, 27 Aug 2021 15:16:49 +0200 Subject: [PATCH 2/5] Fix ARM64 build There is some weird issues regarding linking `__clear_cache` under `clang-cl`, therefore we just call the Windows API instead on these builds. --- src/codegen_new/codegen_allocator.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/codegen_new/codegen_allocator.c b/src/codegen_new/codegen_allocator.c index f441c2c4b..ad07afd73 100644 --- a/src/codegen_new/codegen_allocator.c +++ b/src/codegen_new/codegen_allocator.c @@ -120,7 +120,11 @@ void codegen_allocator_clean_blocks(struct mem_block_t *block) #if defined __ARM_EABI__ || defined _ARM_ || defined __aarch64__ || defined _M_ARM || defined _M_ARM64 while (1) { +#ifndef _MSC_VER __clear_cache(&mem_block_alloc[block->offset], &mem_block_alloc[block->offset + MEM_BLOCK_SIZE]); +#else + FlushInstructionCache(GetCurrentProcess(), &mem_block_alloc[block->offset], MEM_BLOCK_SIZE); +#endif if (block->next) block = &mem_blocks[block->next - 1]; else From 08e36e7d52915ed5f8d80bd002eec294e4b18291 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 27 Aug 2021 20:10:59 +0200 Subject: [PATCH 3/5] Added a sanity check to the new recompiler, prevents the emulator from dividing by zero and crashing. --- src/codegen_new/codegen_ops_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codegen_new/codegen_ops_helpers.c b/src/codegen_new/codegen_ops_helpers.c index 6a3e8f6d8..6d8cbfd3a 100644 --- a/src/codegen_new/codegen_ops_helpers.c +++ b/src/codegen_new/codegen_ops_helpers.c @@ -62,7 +62,7 @@ int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, return 0; max_unroll = UNROLL_MAX_UOPS / ((ir->wr_pos-start)+6); - if (max_unroll > (UNROLL_MAX_REG_REFERENCES / max_version_refcount)) + if ((max_version_refcount != 0) && (max_unroll > (UNROLL_MAX_REG_REFERENCES / max_version_refcount))) max_unroll = (UNROLL_MAX_REG_REFERENCES / max_version_refcount); if (max_unroll > UNROLL_MAX_COUNT) max_unroll = UNROLL_MAX_COUNT; From b0cb4d974cbfd385c97fd93bc7adfdcd7de5eb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miran=20Gr=C4=8Da?= Date: Fri, 27 Aug 2021 20:19:50 +0200 Subject: [PATCH 4/5] Update cdrom.c --- src/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 30ebcf662..223e1411c 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -12,7 +12,7 @@ * * Author: Miran Grca, * - * Copyright 2018,2019 Miran Grca. + * Copyright 2018-2021 Miran Grca. */ #include #include From 906083a0a983cb1df7dcf785b9457113e5a817e5 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Fri, 27 Aug 2021 20:28:50 -0400 Subject: [PATCH 5/5] Removed unused references to snd_mpu401.h and corrected minor typo --- src/sound/snd_audiopci.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 886ab4ff2..e34324657 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -16,7 +16,6 @@ #include <86box/timer.h> #include <86box/sound.h> #include <86box/midi.h> -#include <86box/snd_mpu401.h> #include <86box/snd_ac97.h> @@ -27,8 +26,6 @@ static float low_fir_es1371_coef[ES1371_NCoef]; typedef struct { - mpu_t mpu; - uint8_t pci_command, pci_serr; uint32_t base_addr; @@ -897,7 +894,7 @@ static uint8_t es1371_pci_read(int func, int addr, void *p) case 0x04: return es1371->pci_command; case 0x05: return es1371->pci_serr; - case 0x06: return 0x10; /* Supports support ACPI */ + case 0x06: return 0x10; /* Supports ACPI */ case 0x07: return 0x00; case 0x08: return 0x02; /* Revision ID */