vAmiga icon indicating copy to clipboard operation
vAmiga copied to clipboard

Add support for 68010 and 68020

Open dirkwhoffmann opened this issue 2 years ago • 15 comments

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.

dirkwhoffmann avatar Aug 13 '22 08:08 dirkwhoffmann

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

Alessandro1970 avatar Aug 13 '22 10:08 Alessandro1970

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

Vweber73 avatar Aug 15 '22 17:08 Vweber73

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.

dirkwhoffmann avatar Aug 15 '22 17:08 dirkwhoffmann

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

Vweber73 avatar Aug 15 '22 18:08 Vweber73

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)

mithrendal avatar Aug 15 '22 18:08 mithrendal

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.

dirkwhoffmann avatar Aug 15 '22 19:08 dirkwhoffmann

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 avatar Aug 15 '22 19:08 Vweber73

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!?

Vweber73 avatar Aug 15 '22 19:08 Vweber73

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?

mithrendal avatar Aug 15 '22 19:08 mithrendal

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 avatar Aug 15 '22 19:08 dirkwhoffmann

@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;

dirkwhoffmann avatar Aug 15 '22 19:08 dirkwhoffmann

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...

Vweber73 avatar Aug 15 '22 20:08 Vweber73

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

mras0 avatar Aug 15 '22 21:08 mras0

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?

Vweber73 avatar Aug 15 '22 22:08 Vweber73

Brief update:

  • vAmiga passes all 68000, 68010, and 68020 tests from the SIMPLE test suite now.

Next steps:

  • Merge changes back to the Moira repo and fix Musashi compatibility mode (which is obviously broken now).
  • Generate more sophisticated test cases with cputester.

dirkwhoffmann avatar Aug 21 '22 15:08 dirkwhoffmann

Fixed in v2.2b1

dirkwhoffmann avatar Nov 17 '22 13:11 dirkwhoffmann