Programming my own Mac emulator
Moderators: Cat_7, Ronald P. Regensburg
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Programming my own Mac emulator
I've been spending a good chunk of time learning how a PowerPC Mac works. While I still have a long way to go before it can even reach the boot screen, I've put in no small amount of effort into this.
Here is a link to the source code, if you want to give it a spin.
Here is a link to the source code, if you want to give it a spin.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
So, the ROMs get a little farther, but it will be some time before it's ready.
Right now, at best, the emulator runs slightly faster than a PowerPC 601 at 60 MHz. And that's with an Intel Core i7. Needless to say, I'll need to optimize this some before progressing.
Also, dynamic memory mapping will be needed as this is aiming toward multiple Old World Macs.
Right now, at best, the emulator runs slightly faster than a PowerPC 601 at 60 MHz. And that's with an Intel Core i7. Needless to say, I'll need to optimize this some before progressing.
Also, dynamic memory mapping will be needed as this is aiming toward multiple Old World Macs.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
With bit of a tweak, it now performs at slightly under 200 MHz. The change will be merged soon, along with another commit that will deal with both NuBus and PCI PowerMac memory mapping.
Re: Programming my own Mac emulator
Hey, keep sharing your updates. Nice to see a long-time forum member creating something really new.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
So, on two different Macs so far, the Power Mac G3 Beige and the Power Mac 6100, we've gotten up to the point where it starts playing the boot chime.
That said, we're also considering moving this project from C++11 to Rust. Mainly because Rust is a bit more modern in so many ways (dependency management, code interoperation, Some speed-ups (though this is somewhat subjective) etc.)
That said, we're also considering moving this project from C++11 to Rust. Mainly because Rust is a bit more modern in so many ways (dependency management, code interoperation, Some speed-ups (though this is somewhat subjective) etc.)
Re: Programming my own Mac emulator
That's great on getting past the hardware tests and OF initialization!
How hard does the migration from C++11 to Rust look? I've never attempted a re-implementation in Rust, but it looks much more doable than doing a legacy language re-implementation. Are you planning on sticking some legacy code in libraries to import, or just write it all from scratch?
How hard does the migration from C++11 to Rust look? I've never attempted a re-implementation in Rust, but it looks much more doable than doing a legacy language re-implementation. Are you planning on sticking some legacy code in libraries to import, or just write it all from scratch?
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
It would be somewhat difficult, but DingusPPC is largely coded like a C program with some C++ bits here and there and encapsulated. We would mostly just stick with C++ for the initial conversion, but use the Rust toolchain to aid us in development.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
Right now, we're slowly approaching the point to where we can reach OpenFirmware. However, we also need a lot more work to be done. Here's just some of the things to complete:
VERY HIGH PRIORITY
*Flesh out the debugger to include a disassembler, a memory dumper (in progress), more sophisticated logging, etc.
*Perform CPU tests
*Fix the FPU emulation
*Write up documentation further (preferably in Markdown format) for hardware components (and a lot of it is on a Discord channel that needs to be preserved)
*Implement serial, OpenPIC, video (ATI Rage Pro), and any other hardware components not yet added
HIGH PRIORITY
*Get a proper logging library in the program
*Implement the TLB
*Implement hard drive support
*User input support
MEDIUM PRIORITY
*Acceleration support
*USB device support
*New World ROM support
VERY HIGH PRIORITY
*Flesh out the debugger to include a disassembler, a memory dumper (in progress), more sophisticated logging, etc.
*Perform CPU tests
*Fix the FPU emulation
*Write up documentation further (preferably in Markdown format) for hardware components (and a lot of it is on a Discord channel that needs to be preserved)
*Implement serial, OpenPIC, video (ATI Rage Pro), and any other hardware components not yet added
HIGH PRIORITY
*Get a proper logging library in the program
*Implement the TLB
*Implement hard drive support
*User input support
MEDIUM PRIORITY
*Acceleration support
*USB device support
*New World ROM support
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
We improved our debugger significantly, including a disassembler. CPU tests have also been performed, which helped fixed hundreds of small bugs that might not have been noticed otherwise.
Re: Programming my own Mac emulator
Nice work! Which PPC instruction set are you emulating at this point? 601?
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
While it's mostly the G3 instruction set, the 601 does have limited support at the moment (several of the exclusive bit-shifting ops are not yet implemented).
We have included a small dummy ADB emulation, which allows us to complete loading a OpenFirmware bytecode image and it starts going into the cold boot sequence.
Sooner or later, we'll start on the device emulation, but we need to complete documentation and clean up the code further.
We have included a small dummy ADB emulation, which allows us to complete loading a OpenFirmware bytecode image and it starts going into the cold boot sequence.
Sooner or later, we'll start on the device emulation, but we need to complete documentation and clean up the code further.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
We now have audio playback. We've managed to get the boot-up jingle and crash jingle from the Power Mac G3 Beige ROM to play.
Re: Programming my own Mac emulator
A thought for you: somewhere (maybe Bend Boldt's old page? Somewhere on the 68kmla forums?) I remember reading that when they were working on getting through booting, they discovered a way to boot off new world ROMs by taking a 68K ROM (3MB) and just byte aligned appending New World in memory after it. So if we can somehow do a clean room implementation of the 68K part (using ARDI's code?) then we can read the New World into memory after it, and it should be enough to boot a New World-capable OS, assuming the hardware side is properly emulated.
Here's a project for part of it: https://github.com/elliotnunn/mac-rom
Here's a project for part of it: https://github.com/elliotnunn/mac-rom
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
I do have a 4 MB Gigabit Ethernet ROM, but it doesn't resemble the Old World ROMs much. I'd like to see if anyone can find the page you're mentioning.
While it is possible to make a clean-room implementation, that takes a lot of time and effort to code.
While it is possible to make a clean-room implementation, that takes a lot of time and effort to code.
Re: Programming my own Mac emulator
Yeah; so far I've just found the annotated Mac Plus ROM, the various romulators, etc. -- but I can't find the ROM replacement project itself anywhere. And of course, the three toolbox replacement projects attempt to skip over the entire ROM issue by doing direct toolbox and API translation instead of just re-implementing the hardware mapping routines and core toolbox functions.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
Good news - We fixed some crash bugs, inserted some basic video implementation (though it still won't display anything yet), and have some keyboard work started.
Bad news - To get the keyboard working requires a very timing-specific auto-polling implementation and it's required for emulation to progress any further.
Bad news - To get the keyboard working requires a very timing-specific auto-polling implementation and it's required for emulation to progress any further.
Re: Programming my own Mac emulator
Perhaps taking a look at the adb work currently being done on Qemu might help?
https://github.com/mcayland/qemu/commits/adb-wip
Best,
Cat_7
https://github.com/mcayland/qemu/commits/adb-wip
Best,
Cat_7
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
https://github.com/dingusdev/dingusppc/tree/debug-68k
Quick branch to help us debug 68k startup code in the Old World ROMs. Capstone is required for this, so you will have to pull that first.
Quick branch to help us debug 68k startup code in the Old World ROMs. Capstone is required for this, so you will have to pull that first.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
We've managed to debug the 68k ROM up to the point it reaches the BootRetry method.
If anyone can help debug 68k code, here's what we need clarified:
* exception processing (though it mostly has been reversed engineered with the Nanokernel)
* emulator initialization code, especially the part that talks to the Nanokernel
* emulator state control via _MoveFromECR and _MoveToECR traps
This repo will help a lot with digging into the code.
If anyone can help debug 68k code, here's what we need clarified:
* exception processing (though it mostly has been reversed engineered with the Nanokernel)
* emulator initialization code, especially the part that talks to the Nanokernel
* emulator state control via _MoveFromECR and _MoveToECR traps
This repo will help a lot with digging into the code.
Re: Programming my own Mac emulator
Have you connected with Elliot or his team? https://github.com/elliotnunn/powermac-rom
They're active on MacOS9Lives, and are working through similar issues to you right now.
They're active on MacOS9Lives, and are working through similar issues to you right now.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
If anyone wants to help with the JIT in DingusPPC, we're currently investigating how to do it. So far, it seems like asmjit would be the best solution. However, we'll also need to carefully manage both PowerPC and 68k code, being aware of the context the OS is currently running in.
Send a direct message to me in Discord (or PM me here) for more info.
Also, we're finishing up the ADB keyboard emulation, but we'd like to know how we should implement the Power key and the NMI. The Control, Option, and Alt keys will also need to be dealt with between OSes, so we'd like to know how to deal with this across different OSes (Windows, Linux, macOS, etc.).
Send a direct message to me in Discord (or PM me here) for more info.
Also, we're finishing up the ADB keyboard emulation, but we'd like to know how we should implement the Power key and the NMI. The Control, Option, and Alt keys will also need to be dealt with between OSes, so we'd like to know how to deal with this across different OSes (Windows, Linux, macOS, etc.).
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
There's a fair amount of updating going on right now. We've managed to reach up to the point the emulator can execute the InitSlots routine. We've also got some debugging stuff inserted and the command line interface is smidge easier to use.
Re: Programming my own Mac emulator
You cool if I add a link to the project in the wiki? I won't create a page for it now, but I'll stick it on the "other emulator" page.
kataetheweirdo wrote: ↑Sat Dec 05, 2020 9:06 pm There's a fair amount of updating going on right now. We've managed to reach up to the point the emulator can execute the InitSlots routine. We've also got some debugging stuff inserted and the command line interface is smidge easier to use.
-
- Master Emulator
- Posts: 320
- Joined: Sun Feb 01, 2009 4:55 pm
Re: Programming my own Mac emulator
I'd hold off on adding it to the wiki until we can display something, but we're getting there. This year, we've already added some fixes to the instructions and added the mcrf instruction. It tries to initialize the video card, but too much is missing before it can really work. There's also the matter of implementing the interrupt controller.