Revision: 45726
http://sourceforge.net/p/vice-emu/code/45726
Author: gpz
Date: 2025-08-06 18:13:36 +0000 (Wed, 06 Aug 2025)
Log Message:
-----------
add some jitter to the lsb of the POT values, partial fix for #2159
Modified Paths:
--------------
trunk/vice/src/sid/sid.c
trunk/vice/src/vic20/vic-mem.c
Modified: trunk/vice/src/sid/sid.c
===================================================================
--- trunk/vice/src/sid/sid.c 2025-08-06 18:10:13 UTC (rev 45725)
+++ trunk/vice/src/sid/sid.c 2025-08-06 18:13:36 UTC (rev 45726)
@@ -172,6 +172,25 @@
#endif
/* ------------------------------------------------------------------------- */
+/* Add some randomness to the pot value(s). Note that _with paddles_ the error
+ gets gradually worse depending on the sampled value (the larger the value,
+ the bigger error. This does _not_ happen with the 1351 mouse */
+static inline uint8_t makepotval(int value)
+{
+/* FIXME: we must somehow determine whether this is a 1531 or not, use the
+ lesser error for the time being */
+#if 0
+ unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+#else
+ unsigned int fuzz = lib_unsigned_rand(0, 1);
+#endif
+ value += fuzz;
+ if (value > 255) {
+ return 255;
+ }
+ return value;
+}
+
static uint8_t sid_read_chip(uint16_t addr, int chipno)
{
int val = -1;
@@ -190,8 +209,8 @@
mouse_poll();
}
- val_pot_x = read_joyport_potx();
- val_pot_y = read_joyport_poty();
+ val_pot_x = makepotval(read_joyport_potx());
+ val_pot_y = makepotval(read_joyport_poty());
}
#endif
val = (addr == 0x19) ? val_pot_x : val_pot_y;
Modified: trunk/vice/src/vic20/vic-mem.c
===================================================================
--- trunk/vice/src/vic20/vic-mem.c 2025-08-06 18:10:13 UTC (rev 45725)
+++ trunk/vice/src/vic20/vic-mem.c 2025-08-06 18:13:36 UTC (rev 45726)
@@ -33,6 +33,7 @@
#include <string.h>
#include "joyport.h"
+#include "lib.h"
#include "maincpu.h"
#include "raster-changes.h"
#include "types.h"
@@ -285,6 +286,25 @@
return ypos;
}
+/* Add some randomness to the pot value(s). Note that _with paddles_ the error
+ gets gradually worse depending on the sampled value (the larger the value,
+ the bigger error. This does _not_ happen with the 1351 mouse */
+static inline uint8_t makepotval(int value)
+{
+/* FIXME: we must somehow determine whether this is a 1531 or not, use the
+ lesser error for the time being */
+#if 0
+ unsigned int fuzz = lib_unsigned_rand(0, (value * 5) / 255);
+#else
+ unsigned int fuzz = lib_unsigned_rand(0, 1);
+#endif
+ value += fuzz;
+ if (value > 255) {
+ return 255;
+ }
+ return value;
+}
+
uint8_t vic_read(uint16_t addr)
{
addr &= 0xf;
@@ -298,8 +318,8 @@
mouse_poll();
}
- vic.regs[8] = read_joyport_potx();
- vic.regs[9] = read_joyport_poty();
+ vic.regs[8] = makepotval(read_joyport_potx());
+ vic.regs[9] = makepotval(read_joyport_poty());
}
}
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|