Programming my own Mac emulator

Anything about Mac emulation that does not belong in the above categories.

Moderators: Cat_7, Ronald P. Regensburg

User avatar
ClockWise
Site Admin
Posts: 4224
Joined: Mon May 20, 2002 4:37 am
Location: Uiwang

Re: Programming my own Mac emulator

Post by ClockWise »

Alright. Just let me know!
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

Going to bump this topic here - The emulator has a decent amount of progress put into it. With a hack or two, we can display the black-and-white display pattern, but locks up there.

To get farther requires hard drive emulation, so we'll need to emulate either the IDE interface (we've documented much of it in the zdocs folder) or the SCSI interface (which is what all Old World Macs will need).

There's also some slight progress in regards to Power Mac 6100 emulation.
Last edited by kataetheweirdo on Mon Sep 27, 2021 2:54 pm, edited 1 time in total.
User avatar
adespoton
Forum All-Star
Posts: 3736
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Programming my own Mac emulator

Post by adespoton »

I highly recommend going for the SCSI interface, at least the mass storage spec. It opens up more long-term opportunities for improvement.
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

We'll have to include SCSI emulation sooner or later, as we're also targeting the Power Mac 6100.

I've also cleaned up 601 opcode emulation.
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

As of writing, we recently merged into some commits that allow us to see the Sad Mac using a Power Mac 6100 ROM. We'll need to code some fixes in for the processor (namely, the crxor instruction) and the ADB emulation.
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

Over the past month, we've implemented enough to start booting off a floppy with the current Power Mac 6100 emulation. It currently can reach the "Welcome to Macintosh"/Mac OS logo before crashing due to unemulated NuBus hardware.
User avatar
uliwitness
Space Cadet
Posts: 8
Joined: Thu Feb 17, 2022 12:04 am

Re: Programming my own Mac emulator

Post by uliwitness »

That sounds cool. I'd be curious in hearing where one would even start with such an emulator. I'm currently working on a HyperCard clone, which involves a bytecode compiler for HyperTalk, and I have a manual for some Mototrola PowerPC CPU that Apple never used, but where do you even find details like how to emulate NuBus stuff etc.?
Cheers,
-- Uli Kusterer
https://hypercard.org
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

While a good chunk of it was gathered from open source repositories, some of it required digging into documents not available to the public. That said, here are a few resources we found that are publicly available:
  • This NuBus DECL ROM decompilation - It also has some useful links, like one for designing hardware for 68k NuBus Macs.
  • MkLinux - The earliest machines supported in Apple's own open source repos are Beige Power Mac G3s and the like. For anything earlier, MkLinux has significant amounts relating to both NuBus and early PCI PowerMacs. nubus-pmac might be another possibility if you want to look at OSes with NuBus support.
  • The SuperMario code - This was occasionally spread around as leaked System 7.1 source code, but it's actually ROM and Toolbox code. The current version floating around dates from February 1994 and covers Macs up until early prototyping on PCI boards. This also includes a significant chunk of NuBus code. cdg5 have also made patches for this, mainly to get Mac OS 9 working on newer G4 machines.
  • The Power Macintosh Book (1994) by Stephan Somogyi, Foreword by Donald A. Norman - General hardware overview of early Power Macs
We also had to dissect the Power Mac 6100 ROM, which includes a decent chunk of debugging symbols. That said, it isn't an easy task due to containing both 68k and PowerPC code by necessity. A small hint though: The PowerPC code starts at around 0x300000 in the ROM, while the 68k code takes up most of the first 3/4 of the ROM.
User avatar
adespoton
Forum All-Star
Posts: 3736
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Programming my own Mac emulator

Post by adespoton »

It's also sometimes useful to refer to the NetBSD codebase; that was my first exposure to Mac hardware from an outside perspective. Of course, there's parts that the NetBSD guys just ignored/co-opted from an already-booted Mac OS, but it's useful in helping to figure out where one part of the hardware leaves off and the other more open areas start, too. And they did a good job of clean-room analysis of the calls and APIs they did have access to.
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

Right now, DingusPPC can boot off installation floppies from the System 7 era. I'll be implementing whatever I can for hard disk support next.
User avatar
uliwitness
Space Cadet
Posts: 8
Joined: Thu Feb 17, 2022 12:04 am

Re: Programming my own Mac emulator

Post by uliwitness »

kataetheweirdo wrote: Thu Feb 17, 2022 2:56 pm We also had to dissect the Power Mac 6100 ROM
Cool, thanks for all those resources!
Cheers,
-- Uli Kusterer
https://hypercard.org
User avatar
uliwitness
Space Cadet
Posts: 8
Joined: Thu Feb 17, 2022 12:04 am

Re: Programming my own Mac emulator

Post by uliwitness »

adespoton wrote: Thu Feb 17, 2022 5:26 pm It's also sometimes useful to refer to the NetBSD codebase;
Thanks! I didn't really think that people would just look at how other open source OSes that ran on the same hardware would do.
Cheers,
-- Uli Kusterer
https://hypercard.org
User avatar
uliwitness
Space Cadet
Posts: 8
Joined: Thu Feb 17, 2022 12:04 am

Re: Programming my own Mac emulator

Post by uliwitness »

kataetheweirdo wrote: Sun Mar 06, 2022 6:41 pm Right now, DingusPPC can boot off installation floppies from the System 7 era. I'll be implementing whatever I can for hard disk support next.
Looking forward to seeing how it works. I really want a System 7 emulator I can play around on, ideally without using the boot disk whenever my inevitably buggy C code crashes :D
Cheers,
-- Uli Kusterer
https://hypercard.org
User avatar
adespoton
Forum All-Star
Posts: 3736
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Programming my own Mac emulator

Post by adespoton »

uliwitness wrote: Wed Mar 09, 2022 9:59 pm
kataetheweirdo wrote: Sun Mar 06, 2022 6:41 pm Right now, DingusPPC can boot off installation floppies from the System 7 era. I'll be implementing whatever I can for hard disk support next.
Looking forward to seeing how it works. I really want a System 7 emulator I can play around on, ideally without using the boot disk whenever my inevitably buggy C code crashes :D
As an aside, you can use the QEMU-system-m68k custom builds on here to that purpose: I believe it should support snapshotting if you use a qcow2 volume, and emulates a Quadra. That way, you can just pop open the monitor and do a snapshot before testing, then revert if you corrupt HFS.
User avatar
uliwitness
Space Cadet
Posts: 8
Joined: Thu Feb 17, 2022 12:04 am

Re: Programming my own Mac emulator

Post by uliwitness »

adespoton wrote: Thu Mar 10, 2022 12:14 am As an aside, you can use the QEMU-system-m68k custom builds on here to that purpose: I believe it should support snapshotting if you use a qcow2 volume, and emulates a Quadra. That way, you can just pop open the monitor and do a snapshot before testing, then revert if you corrupt HFS.
Wasn't aware QEMU worked with 68k as well, will have to set aside some time to play with that, thanks!
Cheers,
-- Uli Kusterer
https://hypercard.org
User avatar
adespoton
Forum All-Star
Posts: 3736
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Programming my own Mac emulator

Post by adespoton »

uliwitness wrote: Thu May 26, 2022 5:52 pm
adespoton wrote: Thu Mar 10, 2022 12:14 am As an aside, you can use the QEMU-system-m68k custom builds on here to that purpose: I believe it should support snapshotting if you use a qcow2 volume, and emulates a Quadra. That way, you can just pop open the monitor and do a snapshot before testing, then revert if you corrupt HFS.
Wasn't aware QEMU worked with 68k as well, will have to set aside some time to play with that, thanks!
"QEMU" doesn't work with 68k, but the custom qemu-system-68k builds on here do -- there's one for generic Mac OS and one for A/UX. They aren't ready to roll into QEMU yet, but ARE functional on their own. Soon they'll be part of QEMU....
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

OpenFirmware now can be run through the command line using the -d and --serial-backend=stdio commands.
kikyoulinux
Tinkerer
Posts: 89
Joined: Sun Sep 28, 2014 11:53 am
Location: China

Re: Programming my own Mac emulator

Post by kikyoulinux »

Cool! My System 7.6 image boots. but I can't get mouse and keyboard work, it just "hangs" there.

Image

the image I made for mame pm6100, also boots on DingusPPC.
https://mega.nz/file/DQ8WAJqJ#POduD-quP ... KnUjSM_N_c
User avatar
adespoton
Forum All-Star
Posts: 3736
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Programming my own Mac emulator

Post by adespoton »

Wow! Congrats! So the core now works and you're on to the serial interface?

Since you're doing 7.6, I presume you're going to go the ADB route?
kataetheweirdo
Apple Corer
Posts: 298
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

We already got some work in for the serial interface. We'll need to fix some timing issues and probably want to implement hard disk support first before tackling ADB.
Post Reply