dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Add support for 68010 and 68020 #728

Closed dirkwhoffmann closed 1 year ago

dirkwhoffmann commented 1 year ago

Recently, I had another look at the Musashi core and noticed that supporting the 68010 and 68020 isn't as difficult as I originally thought. As a starting point, I've decided to add a 68010 and 68020 mode to Moira that tries to replicate Musashi to 100%. This worked quite well and I'm already able to run Sysinfo in vAmiga:

Bildschirmfoto 2022-08-13 um 10 16 06

As already stated, this is only a starting point. A lot of stuff is missing (the 68020 deals with all kinds of different stack frames, has multiple trace modes etc.). All these features are not emulated yet.

Alessandro1970 commented 1 year ago

Great! …so it could be added the 68882 with 68020 ✌🏻

Vweber73 commented 1 year ago

Hi,

Excellent news, thanks!

  1. I tried it with The Settlers and it works fine, 68020 reported. Now map size can be up to 7 (against 5 for 68000). The absolute max (size 8) would need a 68030. Is 030 planned as well?
  2. I tried Dungeon Master II, which is one of these very few games marked as AGA but actually don't need AGA, just a 68020, so a good test case (actually the only one I know). It starts working, then freezes, it seems that it eats up a lot of ressources, the UI becomes very slow until you restart vAmigaWeb. It is using one of these net yet implemented 020 features?

Cheers

dirkwhoffmann commented 1 year ago

It is using one of these net yet implemented 020 features?

I don't know yet. Which DM2 version did you use (please don't upload the game, just the exact filename)? Does it boot from floppy disk? I'm asking, because I found a version that needs to be installed on HD.

Vweber73 commented 1 year ago

I'm using the hdf version which I found here: https://www.planetemu.net/rom/commodore-amiga-hardfiles-hdf/dungeon-master-ii-1994-interplay-aga

mithrendal commented 1 year ago

I tried it and it actually works ...

image

but it does flood the console with thousands of log output ... seems as if every cpu instruction is logged ...

execBitFieldEa(137,5,4,e9eb)
(Index):876 execExtb(155,0,4,49c3)
(Index):876 execBitFieldEa(137,5,4,e9eb)
(Index):876 execExtb(155,0,4,49c3)
(Index):876 execBitFieldEa(137,5,4,e9eb)
(Index):876 execExtb(155,0,4,49c3)
2(Index):876 execBitFieldEa(137,5,4,e9eb)
4(Index):876 execBitFieldEa(137,5,4,e9e8)

...

thats why it seems to freeze

the line which is responsible for that logging is here I guess https://github.com/dirkwhoffmann/vAmiga/blob/7de0d51f0fa1860c367b352004a9fbe1f100cd00/Emulator/CPU/Moira/MoiraExec_cpp.h#L12

BTW: nice side effect of 68020 support is, that now also kickstart meant for A1200 is usable (which contains probably 68020 instructions)

dirkwhoffmann commented 1 year ago

the line which is responsible for that logging is here I guess

Yes. This is a debug statement which gets active if a 68020-only instruction is executed. It's only meant to be used during debugging.

Vweber73 commented 1 year ago

Yeah! I had the console still on, I switched it off and now it is working fine! So it seems that this 020 emulation is quite complete and reliable after all? I think the main item is the bitfields instructions?

It also seems that The Settlers detects the processor type but doesn't use extra instructions, otherwise it would have lagged as well when I tried?

Vweber73 commented 1 year ago

When I wrote that it worked fine... I hadn't switched the sound on. Now I have done it, and it is pretty sluggish. I guess that the system is still slowed on with this logging even though I turned the console off!?

mithrendal commented 1 year ago

if you turn debugging console off reduces maybe the slow down a bit, but that extensive logging will still happen in background so, maybe I better will comment that printf statment out ...

@dirkwhoffmann what is the proper way to remove the logging ? maybe some config setting e.g. in MoiraConfig.h?

dirkwhoffmann commented 1 year ago

I guess that the system is still slowed on with this logging even though I turned the console off!?

Yes, the logging statement has to be removed. It's a performance killer.

It also seems that The Settlers detects the processor type but doesn't use extra instructions

True. I think it simply uses the CPU modes as an estimate for overall system performance

dirkwhoffmann commented 1 year ago

@dirkwhoffmann what is the proper way to remove the logging ? maybe some config setting e.g. in MoiraConfig.h?

Change the code to

// if constexpr ((cpu) == M68020) { printf("%s(%d,%d,%d,%x)\n", __func__, I, M, S, opcode); }

#define AVAILABILITY(cpu) \
if constexpr (WILL_EXECUTE) willExecute(__func__, I, M, S, opcode); \
assert(C >= (cpu)); \
if constexpr (C == M68020) cp = 0;
Vweber73 commented 1 year ago

I understand that the only differences between the 020 and 030 are not in the instruction set but in the MMU which is not useful in emulation, and data cache + burst mode which probably add nothing much in performance either in emulation, so could it be possible to have a 030 setting that would be identical to the 020 emulation save for the identification bits? So that Settlers can have map size to 8...

mras0 commented 1 year ago

Roots 2.0 by Sanity is another good test case for 020 without AGA (requires ECS).

Vweber73 commented 1 year ago

Roots 2.0 by Sanity is another good test case for 020 without AGA (requires ECS).

Excellent stuff, thanks! Seems to work quite well. Except that after the credits the screen goes black and you only have the music... Is it normal? Or maybe the start of the AGA part?

dirkwhoffmann commented 1 year ago

Brief update:

Next steps:

dirkwhoffmann commented 1 year ago

Fixed in v2.2b1