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: 4397
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
Master Emulator
Posts: 312
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: 4208
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
Master Emulator
Posts: 312
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
Master Emulator
Posts: 312
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
Master Emulator
Posts: 312
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
Student Driver
Posts: 11
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
Master Emulator
Posts: 312
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: 4208
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
Master Emulator
Posts: 312
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
Student Driver
Posts: 11
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
Student Driver
Posts: 11
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
Student Driver
Posts: 11
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: 4208
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
Student Driver
Posts: 11
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: 4208
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
Master Emulator
Posts: 312
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: 92
Joined: Sun Sep 28, 2014 11:53 am

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: 4208
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
Master Emulator
Posts: 312
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.
kataetheweirdo
Master Emulator
Posts: 312
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

kataetheweirdo wrote: Thu Feb 17, 2022 2:56 pm We also had to dissect the Power Mac 6100 ROM, which includes a decent chunk of debugging symbols.
So, which symbols are included can vary between ROMs.

For example, here's where the GetPPCGlobalFlag symbol can be found:
  • 63ABFD3F - Power Mac & Performa 5200,5300,6200,6300
    83A21950 - PowerBook 1400cs.ROM
    9B037F6F - Workgroup Server 9150-120.ROM
    9B7A3AAD - Power Mac 7100 (newer)
    9FEB69B3 - Power Mac 6100 & 7100 & 8100
As you can tell, mostly the NuBus or NuBus-based Macs have these symbols, with the 5200/5300 ROM also referencing stuff for the ATA hard drives. This symbol was also found in the Powerbook 190cs ROM for reasons not fully understood, but I'd reckon it might have been compiled in by accident. These ROMs also contain symbols for the FragRegisterMemLib (i.e. NewClosureID).

On the flip side, it seems only the PowerMac and PowerBook G3 ROMs (and PowerExpress) have any strings for LLNub (Low Level Debug Nub?) and many of the PCI Power Mac ROMS have the string "Switched to Macsbug- G to resume" in them.
User avatar
Becatto
Inquisitive Elf
Posts: 25
Joined: Tue Oct 11, 2022 7:48 am

Re: Programming my own Mac emulator

Post by Becatto »

Wow! how did you learn where to start?
-------------------------------------------------------------------------------------------------------------------------
Is it just me or every time I comment on a post, it dies :???:
kataetheweirdo
Master Emulator
Posts: 312
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

I actually found a document relating to the Yosemite Boot ROM, specifically the engineering requirements spec. The copy available is incomplete, but it goes over a lot of technical details for the Mac.

There's also source code available from Apple, which means code specifically for PPC hardware can be found in source code tress for Mac OS X 10 to 10.5. That said, you might be better off trying to get source code from the Mac OS Server X 1.x discs or using the MkLinux tree.
kataetheweirdo
Master Emulator
Posts: 312
Joined: Sun Feb 01, 2009 4:55 pm

Re: Programming my own Mac emulator

Post by kataetheweirdo »

Been some progress going on. I can't reveal what we're doing yet, but I'll give a sneak peek:
Image
User avatar
Cat_7
Expert User
Posts: 6121
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Programming my own Mac emulator

Post by Cat_7 »

Hi kataetheweirdo,

Nice, that is the g3beige target attempting to run 10.0 or 10.2?
How's adb support for the older Mac OS coming along?

Best,
Cat_7
Post Reply