My fork of Basilisk II

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

My fork of Basilisk II

Post by uyjulian »

https://github.com/uyjulian/macemu
Check out the "core_cleanup" branch.

I personally want to do the following:
1. remove all support code for other platforms for BasiliskII except macOS/SDL (already done)
2. convert BasiliskII build system to CMake, like Hatari and Previous are doing (already done)
3. Backport CPU from old BasiliskII (this will reduce the amount of differences when porting a new CPU core) (already done)
4. Port JIT from ARAnyM (partially done; currently hangs.)
5. Modularize the Toolbox traps, so that it's easy for anybody to accelerate Toolbox functions with just a trap number and a function definition.

I'll clean up and send #4 and #5 in a PR after those are finished. #1, #2, and #3 are just to get familiar with the source code.

Also, check out my Basilisk II FLTK GUI. viewtopic.php?f=6&t=9467

These are "far off" ideas:
Port Dolphin JIT to SheepShaver
AOT compiler with LLVM
UAE emulation when 68k code is executed in Sheepshaver
Boot from folder in shared directory instead of disk image
Toolbox windows managed by WindowServer/Wayland/X compositor
User avatar
adespoton
Forum All-Star
Posts: 3068
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: My fork of Basilisk II

Post by adespoton »

Thanks, Julia! That's a lot of progress already!
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

Okay, I decided to put latest BasiliskII uae_core back in, but I used the ARAnyM JIT compiler.
ARM JIT still needs some work to be done.

Oh, and as a bonus, JIT compiler works again on the latest macOS and compilers! pagezero_size was changed to 0x2000; JIT compilers don't work on 64-bit macOS if pagezero_size isn't set properly. Also, the CPUID function was replaced with the one from ARAnyM, which allows the CPUID check to work again.

Also, if you are attempting to compile it yourself, you can just use CMake. Be sure you set CMAKE_BUILD_TYPE to Release to optimize the executable. Also, LTO will just result in an abort trap for some reason.

Also, the "sleep when idle"/"idlewait" functions will result in the Toolbox hanging since no events are processed randomly. Be sure to turn it off/uncheck the option.

Also, if it hangs while you are trying to launch, just do

Code: Select all

killall -KILL BasiliskII
and try again. It takes a few tries.

Here's a benchmark from the 1 March 2014 build for reference:
Image

Initial try with 8192 Translation Cache Size:
Image
Now, processor speed is slow... but look at the disk scores!

Second try with 16384 Translation Cache Size:
Image
The processor speed comes back... but disk scores are lower than even the 1 March 2014 build...
I'm going to mess with it more next week.
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

Temporary test build 2018-06-06, including fltkbasiliskgui: https://transfer.sh/jg3ZQ/BasiliskII-test1.zip

Source code repository has also been updated. Disable "idlewait" or "Don't use CPU when idle" or events, such as mouse click/keyboard type will stop working randomly.

If my build hangs immediately while you are trying to run it, kill it with

Code: Select all

killall -KILL BasiliskII
then try running it again. It takes a few tries.

Now for some benchmarks:
Image
User avatar
rickyzhang
Mac Mechanic
Posts: 193
Joined: Mon Sep 15, 2014 7:59 pm

Re: My fork of Basilisk II

Post by rickyzhang »

Boy, I missed you thread completely! Great work!

1. remove all support code for other platforms for BasiliskII except macOS/SDL (already done)
2. convert BasiliskII build system to CMake, like Hatari and Previous are doing (already done)
Why? You want to pissed off Power PC Mac and Linux folks?
3. Backport CPU from old BasiliskII (this will reduce the amount of differences when porting a new CPU core) (already done)
Why are you doing this? Can you give me more technical background on this?
4. Port JIT from ARAnyM (partially done; currently hangs.)
Very interesting project. What is your motivation? Can you point to me more details so that I can take a quick look?
5. Modularize the Toolbox traps, so that it's easy for anybody to accelerate Toolbox functions with just a trap number and a function definition.
Nice work. But what toolbox function is a deal breaker in emulated OS that need acceleration? TBH, in my dated Intel i7 2600k box I have zero performance problem at all in all apps I'm running. Even I can't use JIT.

So far there are some compatible issues that is hard to figure it out why in emulator. That's why I improved the run time debugger last year. Because it crashed in some application. It is a real show stopper to me.

Glad that you make some serious coding work. Please keep us posted!
There is an App for that!
https://github.com/rickyzhang82
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

rickyzhang wrote:Boy, I missed you thread completely! Great work!

1. remove all support code for other platforms for BasiliskII except macOS/SDL (already done)
2. convert BasiliskII build system to CMake, like Hatari and Previous are doing (already done)
Why? You want to pissed off Power PC Mac and Linux folks?
I'm planning on also looking at support for E-UAE PowerPC JIT compiler.
rickyzhang wrote:
3. Backport CPU from old BasiliskII (this will reduce the amount of differences when porting a new CPU core) (already done)
Why are you doing this? Can you give me more technical background on this?
Most of the work on this point has been undone. It didn't work very well.
rickyzhang wrote:
4. Port JIT from ARAnyM (partially done; currently hangs.)
Very interesting project. What is your motivation? Can you point to me more details so that I can take a quick look?
Make JIT work on 64-bit x86, ARM, and on newer compilers. Look here for source code -> https://github.com/uyjulian/macemu on core_cleanup branch
rickyzhang wrote:
5. Modularize the Toolbox traps, so that it's easy for anybody to accelerate Toolbox functions with just a trap number and a function definition.
Nice work. But what toolbox function is a deal breaker in emulated OS that need acceleration? TBH, in my dated Intel i7 2600k box I have zero performance problem at all in all apps I'm running. Even I can't use JIT.
QuickDraw mainly. It would be nice to GPU-accelerate it. I also want to get rid of or work around nested EmulOp calls and JIT, since it causes problems with the "idlewait" function of BasiliskII.
rickyzhang wrote: So far there are some compatible issues that is hard to figure it out why in emulator. That's why I improved the run time debugger last year. Because it crashed in some application. It is a real show stopper to me.

Glad that you make some serious coding work. Please keep us posted!
User avatar
rickyzhang
Mac Mechanic
Posts: 193
Joined: Mon Sep 15, 2014 7:59 pm

Re: My fork of Basilisk II

Post by rickyzhang »

To accelerate quick draw, I think SDL 2 is an answer not the alternative emulator nor improve JIT.

The pixel from guest OS is written to frame buffer in host OS directly. It is host OS (thus SDL) determine how to plot in host OS screen. It doesn't seem to relate to JIT.
There is an App for that!
https://github.com/rickyzhang82
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

Synchronized with latest ARAnyM compiler sources.

Image

I'm still having the issue where the program may sometimes hang before showing the window, and a SIGKILL is needed to kill the program. It appears that ARAnyM is using fixed addressing with JIT instead of direct addressing, so maybe I'll try that.
User avatar
adespoton
Forum All-Star
Posts: 3068
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: My fork of Basilisk II

Post by adespoton »

This is looking really promising! Thanks for sharing :)

Maybe eventually we can merge your fork back into mainline BII....
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

The rest of uae_cpu from ARAnyM was merged.

There's still the issue of the program sometimes hanging on startup, and I'm not sure where to start on debugging that issue.
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

I synchronized changes with ARAnyM again.

There's still the following issues:
1. Program randomly hanging on startup
2. Program not working properly with idlewait option (no events except mouse movement events are delivered)
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

Okay, it seems like the random hang on startup is caused by the SDL2 code. See https://github.com/cebix/macemu/issues/203
User avatar
rickyzhang
Mac Mechanic
Posts: 193
Joined: Mon Sep 15, 2014 7:59 pm

Re: My fork of Basilisk II

Post by rickyzhang »

If you compile with addressing mode in memory banks in configure, it should workaround the hangs.

Code: Select all

--enable-addressing=banks
I'm working on the permanent fix now.
There is an App for that!
https://github.com/rickyzhang82
User avatar
rickyzhang
Mac Mechanic
Posts: 193
Joined: Mon Sep 15, 2014 7:59 pm

Re: My fork of Basilisk II

Post by rickyzhang »

uyjulian wrote:Okay, it seems like the random hang on startup is caused by the SDL2 code. See https://github.com/cebix/macemu/issues/203
I proposed several solutions in the issue. I will go for the solution that use memory banks addressing.

But I dont know the performance hit, compared to direct addressing. I downloaded MacBench 4.0 from macintoshrepository.com. But the app crashed in BII from System7.5.

where do you get your MacBench 4.0?
There is an App for that!
https://github.com/rickyzhang82
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

rickyzhang wrote:
uyjulian wrote:Okay, it seems like the random hang on startup is caused by the SDL2 code. See https://github.com/cebix/macemu/issues/203
I proposed several solutions in the issue. I will go for the solution that use memory banks addressing.

But I dont know the performance hit, compared to direct addressing. I downloaded MacBench 4.0 from macintoshrepository.com. But the app crashed in BII from System7.5.

where do you get your MacBench 4.0?
Macintosh Garden
User avatar
rickyzhang
Mac Mechanic
Posts: 193
Joined: Mon Sep 15, 2014 7:59 pm

Re: My fork of Basilisk II

Post by rickyzhang »

Image

I benchmark two addressing: direct and memory banks. As I expected, the memory banks is a little bit slower than direct. But in general, there are no noticeable issues at all to run any Apps in BII under direct or memory banks.

But what makes the huge performance differences is the GCC compiler optimization flag:

  1. No optimization at all:

    Code: Select all

    -O0
  2. Optimization at level 3 and native code:

    Code: Select all

    -O3 -march=native
As you can see, memory banks is 10x slower in no optimization flag.
There is an App for that!
https://github.com/rickyzhang82
kanjitalk755
Mac Mechanic
Posts: 153
Joined: Thu Nov 09, 2017 12:06 pm

Re: My fork of Basilisk II

Post by kanjitalk755 »

uyjulian wrote:Okay, it seems like the random hang on startup is caused by the SDL2 code. See https://github.com/cebix/macemu/issues/203
The issue will be fixed with the following commit:

https://github.com/kanjitalk755/macemu/ ... c82f828bac
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

kanjitalk755 wrote:
uyjulian wrote:Okay, it seems like the random hang on startup is caused by the SDL2 code. See https://github.com/cebix/macemu/issues/203
The issue will be fixed with the following commit:

https://github.com/kanjitalk755/macemu/ ... c82f828bac
Cool. I'll check it out
User avatar
adespoton
Forum All-Star
Posts: 3068
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: My fork of Basilisk II

Post by adespoton »

While we're integrating, any chance of integrating Vasi's date offset patch from a few years back into BII/SS?
uyjulian
Apple Corer
Posts: 241
Joined: Fri Aug 27, 2010 1:02 am

Re: My fork of Basilisk II

Post by uyjulian »

Updated with latest ARAnyM changes.

I still need to figure out why "idlewait" hangs randomly…
Post Reply