dirkwhoffmann / virtualc64

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

Barry McGuigan World Championship Boxing (1985)(Activision).crt freezes #760

Closed dirkwhoffmann closed 1 year ago

dirkwhoffmann commented 1 year ago

Reported by @chris70c.

At some point, the CPU halts:

Bildschirmfoto 2023-04-16 um 13 57 49

Interestingly, the cartridge has type "Magic Desk":

Bildschirmfoto 2023-04-16 um 13 57 56

Also, the CPU instruction view is broken in latest beta:

Bildschirmfoto 2023-04-16 um 14 00 26
dirkwhoffmann commented 1 year ago

Update: This CRT is part of OneLoad64 Games Collection v2 Now Released - 1001 unique games to play via Magic Desk CRT format which contains lots of other CRTs in Magic Desk format. All other titles I've tried seem to work. Hence, I expect the issue is not related to the cartridge format. However, the D64 version of Barry McGuigan works just fine.

chris70c commented 1 year ago

Yes is part of OneLoad64 v4, I've tried 100s of other CRT from the same collection and they seem to work fine, maybe the D64 works fine because of a different crack or the way the memory dump has been made for the CRT... Sent you a d64 of Doughboy who also crash after the trainer (works in VICE)...

dirkwhoffmann commented 1 year ago

I cannot reproduce the Doughboy bug here (although I've spotted some other bugs in the latest beta (v4.6b1 is essentially broken):

Bildschirmfoto 2023-05-09 um 16 39 23
dirkwhoffmann commented 1 year ago

More findings:

Bildschirmfoto 2023-05-09 um 17 19 09

VirtualC64 eventually takes the jump at address $5127 which seems to be a ticket to death (it eventually executes an illegal instruction). VICE doesn't seem to take this jump. The culprit might be the LDA instruction at $5116 which reads from IO2 space. The current implementation of VirtualC64 always returns 0 here (only IO1 is used by this cartridge type).

However, VICE seems to return different values (values behind A:) :

Bildschirmfoto 2023-05-09 um 17 41 09

Now, the question is where those values come from.

chris70c commented 1 year ago

Maybe some changes in 4.6 fixed it, I get a corrupted screen and the emulator stop working completely after the trainer in Doughboy...

dirkwhoffmann commented 1 year ago

Preliminary findings:

Now, the question is where those values come from.

It should behave the same way as if no cartridge is attached (open IO returns the bus value during phi1).

I have no idea what the code is doing. Maybe it's a cartridge check and somehow related to VICE bug 1011

I've tried the following two code changes, but both didn't work

u8
MagicDesk::peekIO2(u16 addr) const
{
    return vic.getDataBusPhi1();
}
u8
MagicDesk::peekIO2(u16 addr) const
{
    return rand() & 0xFF;
}

I'll stop working on this issue for now as I don't have enough time to dig deeper.

dirkwhoffmann commented 1 year ago

Nailed it. Returning phi1 is the right thing to do, but I only did this for the IO 2 space. It also has to be done for IO 1:

u8
MagicDesk::peekIO1(u16 addr)
{
    return spypeekIO1(addr);
}

u8
MagicDesk::spypeekIO1(u16 addr) const
{
    return disabled() ? vic.getDataBusPhi1() : control;
}

I was right with assuming the game implements a cartridge check. But with my first code change, it passed the IO 2 check, only. With the latest changes, it passes the IO 1 check, too.

dirkwhoffmann commented 1 year ago

Fixed in v4.6.