[go: up one dir, main page]

Menu

#2169 VSP memory corruption emulation skips last page

v3.x
closed-fixed
gpz
None
x64sc
2025-09-17
2025-09-15
Luke
No

VSP memory corruption emulation skips page $ff.

Patch:

--- vice/src/viciisc/vicii-cycle.c  (Revision 45768)
+++ vice/src/viciisc/vicii-cycle.c  (Arbeitskopie)
@@ -1,4 +1,4 @@
-/*
+*
  * vicii-cycle.c - Cycle based VIC-II emulation.
  *
  * Written by
@@ -339,7 +339,7 @@
     /* simulate the "VSP bug" problem */
     if(vicii_resources.vsp_bug_enabled) {
         if((vsp_buglines[line] + vsp_bugchannels[channel] + lib_unsigned_rand(0, 1)) > VSP_PROB_THRESH) {
-            for(page = 0x00; page < 0xff; page++) {
+            for(page = 0x00; page <= 0xff; page++) {
                 /* keep 98,5% of all pages untouched. this is hand tweaked to result in
                  * somewhat convincing long term plots in vsp-lab */
                 if (lib_unsigned_rand(0, 1000) > 985) {

Discussion

  • gpz

    gpz - 2025-09-15

    Now i am curious how you even noticed this :)

     
    • Luke

      Luke - 2025-09-15

      And rightfully so! :D I am working on VSP safety and wanted to patch vice in order to perform extreme VSP memory corruption - that's where I stumbled across it. ;)

      This is my full diff:

      Index: vice/src/viciisc/vicii-cycle.c
      ===================================================================
      --- vice/src/viciisc/vicii-cycle.c  (Revision 45768)
      +++ vice/src/viciisc/vicii-cycle.c  (Arbeitskopie)
      @@ -1,4 +1,4 @@
      -/*
      +*
        * vicii-cycle.c - Cycle based VIC-II emulation.
        *
        * Written by
      @@ -256,6 +256,7 @@
       #define VSP_PROB_MAX 4
       #define VSP_PROB_MIN 0
       #define VSP_PROB_THRESH 3
      +#define VSP_PROB_EXTREME true
      
       static unsigned int vsp_ysmoothold = 0;
       static unsigned int vsp_buglines[8];
      @@ -269,7 +270,11 @@
           unsigned int val, i;
      
           vsp_ysmoothold = vicii.ysmooth;
      -    vsp_bugwarn = 100;  /* max 100 lines of warnings before we give up */
      +    if (VSP_PROB_EXTREME) {
      +        log_message(vicii.log, "VSP Bug: extreme mode activated, disabling bug occurrence warnings.");
      +    } else {
      +        vsp_bugwarn = 100;  /* max 100 lines of warnings before we give up */
      +    }
      
           for (i = 0; i < 8; i++) {
               vsp_buglines[i] =  VSP_PROB_MAX / 2;
      @@ -277,7 +282,7 @@
           }
           /* FIXME: we might want to make this a user setting */
           /* get a random mask for channels that we want to make immune */
      -    val = lib_unsigned_rand(0, 0xff);
      +    val = VSP_PROB_EXTREME ? 0 : lib_unsigned_rand(0, 0xff);
           log_message(vicii.log,
                   "VSP Bug: safe channels are: %s%s%s%s%s%s%s%s. Emulation of memory corruption is %s.",
                   (val & 1) ? "0" : "",
      @@ -338,11 +343,11 @@
      
           /* simulate the "VSP bug" problem */
           if(vicii_resources.vsp_bug_enabled) {
      -        if((vsp_buglines[line] + vsp_bugchannels[channel] + lib_unsigned_rand(0, 1)) > VSP_PROB_THRESH) {
      -            for(page = 0x00; page < 0xff; page++) {
      +        if(VSP_PROB_EXTREME || (vsp_buglines[line] + vsp_bugchannels[channel] + lib_unsigned_rand(0, 1)) > VSP_PROB_THRESH) {
      +            for(page = 0x00; page <= 0xff; page++) {
                       /* keep 98,5% of all pages untouched. this is hand tweaked to result in
                        * somewhat convincing long term plots in vsp-lab */
      -                if (lib_unsigned_rand(0, 1000) > 985) {
      +                if (VSP_PROB_EXTREME || lib_unsigned_rand(0, 1000) > 985) {
                           int seen0 = 0, seen1 = 0, fragile, result;
                           int firstrow = 7;
                           /* in each page, all addresses ending with 7 or F are affected */
      
       
  • gpz

    gpz - 2025-09-17

    patch applied in r45773 - thanks!

     
    ❤️
    1
  • gpz

    gpz - 2025-09-17
    • status: open --> closed-fixed
    • assigned_to: gpz
     

Log in to post a comment.