dirkwhoffmann / virtualc64

VirtualC64 is a cycle-accurate C64 emulator for macOS
https://dirkwhoffmann.github.io/virtualc64
Other
351 stars 33 forks source link

1001 Crew Intro hangs #698

Closed Alessandro1970 closed 2 years ago

Alessandro1970 commented 2 years ago

Hi, after trying lots of intro I noticed that the following hangs on the virtualc64: 1001 Crew #07 (19xx)(1001 Crew).prg.zip

VirtualC64:

Schermata 2021-10-16 alle 09 28 38

Vice:

Schermata 2021-10-16 alle 09 30 20

My settings (standard c64 roms):

Schermata 2021-10-16 alle 09 31 31

Bye

dirkwhoffmann commented 2 years ago

Confirmed. Interestingly, the CPU is not jammed. It executes some code around here:

Bildschirmfoto 2021-10-17 um 13 50 56
dirkwhoffmann commented 2 years ago

Fixed

Bildschirmfoto 2021-10-20 um 20 09 00

The culprit was the raster IRQ. When the raster IRQ line is changed by a poke to the corresponding VICII register, the emulator has to check if the trigger condition becomes true (which is the case if the new line matches the current line). I've done this check for $D012 which stores the lower 8 bits of the IRQ raster line. However, I missed out the ninth bit which is stored in $D011. Adding the IRQ check to this register fixes the issue.

Old code:

      case 0x11: // Control register 1

            ...
            rasterIrqLine = (u16)((rasterIrqLine & 0x00FF) | ((value & 0x80) << 1));
            break;

        case 0x12: // RASTER_COUNTER

            rasterIrqLine = (rasterIrqLine & 0xFF00) | value;
            checkForRasterIrq();
            return;

New code:

      case 0x11: // Control register 1

            ...
            rasterIrqLine = (u16)((rasterIrqLine & 0x00FF) | ((value & 0x80) << 1));
            checkForRasterIrq();
            break;

        case 0x12: // RASTER_COUNTER

            rasterIrqLine = (rasterIrqLine & 0xFF00) | value;
            checkForRasterIrq();
            return;
dirkwhoffmann commented 2 years ago

v4.5b1 is online.