This page is a wiki. Please login or create an account to begin editing.


32 posts / 0 new
Last post
kataetheweirdo's picture
Offline
Joined: 2009 Apr 10
Making my own emulator

Right now, it's still mostly an interpreter in its very early stages. I just refactored it for optimization (hopefully). I need all of the hardware documentation I can find for this, because the other emulators can't do much in terms of Old World Mac emulation.

Sheepshaver is the closest it can get, and even that's really buggy (and hacky). Fast, but buggy. And there are also compilation issues galore, which someone is addressing, but with little response. There are updates, but none of them address crucial emulation errors due to how old the code is and how little documentation there is on how the code works.

QEMU does well for doing Mac OS 9.1 - Mac OS X 10.4, but it's not going to do Old World Mac emulation any time soon for legal reasons.

Here's the memory controller used by the old world G3:
https://www.nxp.com/docs/en/data-sheet/MPC106EC.pdf

Device Tree for a Power Mac G3:
http://web.archive.org/web/20090107140642/http://penguinppc.org/historic...

More importantly, I need to find a memory map for several Macintoshes, or any PowerPC Macintosh for that matter. This is to make the emulator work at all beyond raw metal code.

Unrelated, but you can't download anything from Ambrosia now. I think it might be safe to get their stuff up here soon.

Comments

MikeTomTom's picture
Offline
Joined: 2009 Dec 7

Really encouraging news to hear. What platform is the intended emulator going to run on, initially? Anyway, the thought of something more stable than SheepShaver interests me a lot. Thank you for this news.

On the unrelated topic. As a test I was able to DL the Demios demo from Ambrosia just now.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

Er...I meant download Ambrosia's games from Ambrosia's website.

Anyhow, this will initially be a console application. Mainly developed for Windows, but could run on anything with text output.

Also, some memory notes:

Mac OS Classic can only allocated up to 1.5 GB of memory, though most Macs can't have more than 2 GB of memory anyway due to hardware limitations. The other 2 GB is taken up by PCI slot attachments, the I/O controller, and misc. hardware bits. This is a 32-bit OS that this emulator is dealing with, so it might not be so bad in terms of allocating memory.

SkyCapt's picture
Offline
Joined: 2017 Jan 11

Emulation and bugs are bosom buddies. I love simple Atari 800 emulation, and I love simple Mac OS 9, but I won't use the primitive emulator(s) for A8/OS 9 they're so buggy. The A8 emulation only became insanely great with the last 2012 version that needs OS X Tiger minimum, and still some of the bugs that persist should embarrass the authors if they were still on it, 2012 was its last update and not because the job was done.

Now that is Atari 800, an 8 bit machine that individual people can master in its entirety. The number of transistors in each chip is in thousands, not millions or billions, trillions? More complex, it's worse. The classic Mac's PSX emulator "CVGS" has a list of most PSX games from the time which admits to which titles work and the large percent of all titles that do not. I tried MorphOS v3.8 once and the Amiga emulation graphics had constant distorting and crashing, Morph claimed my hw is compatible but I have non std graphics hw updated and so gave up then.

Best wishes.
I haven't used SS/B2 yet, chances are high some day I will .

WhosIt.There's picture
Offline
Joined: 2014 Aug 23

The Amiga was a great computer, screwed over by incompetent management ... BUT the problem for both emulation and real hardware, was the memory handling was a kludge. There's a mixture of "Fast RAM" (expansion cards) and "Chip RAM" (motherboard), which necessitates lots of mucking about with the emulator settings to get things to work properly or on real hardware you often had to unplug or turn off RAM expansions. There's also varying video settings to add further complication.

SkyCapt's picture
Offline
Joined: 2017 Jan 11

The alternative to Amiga's fast RAM/slow RAM system was to have it all be slow Smile. The ram wasn't so much a kluj as it was the product of streamlining fewer transistors in the coprocessors, slow ram aka chip ram is where support coprocessor chips operated on video DMA thereby making cpu access to the chip ram slower. The coprocessors had no ability to touch fast ram because the address wires and chip circuits to control those wires did not exist. This wasn't directly cleaved between motherboard ram and expansion ram. The first Amigas to come with 1MB mobo ram were already 512K slow ram and 512K fast ram. If the coprocessor(s) were socketed then there were replacement chips that could turn the whole 1MB into slow-chip ram, the one wire or trace for 1MB existed without the existing coprocessor(s) ability to use that one wire.

Amiga video was awfully klugie. They acted like no computers would ever go faster than 33 MHz, they made a wide range of tricks in hardware to squeeze out new shortcuts, and they had and would still have the best graphics if indeed computers were stuck at 33 MHz. But when 66 MHz came along, and then 100 and higher, it became like: why do video that way? why ever that way, what were we thinking? Must be a b!tch on Amiga emulation.

Halfbrite video mode, Hold-and-modify (Ham) video mode, I remember those.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

If anyone wants a link, I do have a Discord channel of sorts open now. At this point, it's important to gather documentation especially for any Apple-related parts like the I/O controller (Paddington) and the sound chip (AWACS or Burgundy).

Although I do have a general memory map for a Power Mac G3/G4, it's important to know more specific details where the hard drive controller, the graphics card, the sound chip, and any I/O components are located.

I am considering using PortAudio, Allegro, and SDL as my APIs. If any suggestions can be made for any better APIs, that would be appreciated.

uyjulian's picture
Offline
Joined: 2013 Jul 13

Instead of low-level emulating each hardware component, why not just hook the Toolbox calls?

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

I could do that too, but I'd have to find where each Toolbox call is in the dozens of ROMs and that isn't particularly well-documented.

Sheepshaver does this already, but the developers had to deal with limited documentation on how Toolbox calls work within ROMs. The result is that it only emulates enough to have it functioning and it works inconsistently across ROMs. It only works for specific ROMs, mainly those that they did have access to. It also relies heavily on hex code, both in 68k and PPC assembly, to patch the ROM and get past certain things that would otherwise completely prevent it from emulating the Mac (like anything related to the PMMU).

There was also Classix, which was a compatibility layer that never got far enough in development to run non-trivial applications.

Also, there's no real low-level emulator for the PPC Mac (QEMU aside), let alone an Old World Mac.

Temporary Joe's picture
Offline
Joined: 2009 Nov 14

I've never heard of Classix before, seems like it was a project I could really get behind and something I'd wanted to do myself. But it seems to be at a processor emulation level, whereas WINE was processor independent (and a Mac is much more complicated than Nintendo's GameCube). I remember reading from the old Mac forum (forgot its name, but it went down and its server was used to power Mac Garden) about someone who wanted to do something similar, that one of the reasons why Classic Environment wasn't ported to Intel was because of all the 68k libraries that were emulated for PowerPC but would have to be re-ported completely for Intel, and Apple was not willing to port 20+ year old code. The one use I could see for Classix is by using it as a backbone to easily port old Mac software to modern systems.

MikeTomTom's picture
Offline
Joined: 2009 Dec 7

I remember reading from the old Mac forum (forgot its name, but it went down and its server was used to power Mac Garden)

That was "Home of the Underdogs".

For the nostalgic, here's a glimpse of the Macintosh Garden as it's earlier self (Wayback Machine).

Temporary Joe's picture
Offline
Joined: 2009 Nov 14

No, it was MacDomain (I remembered), archive unavailable (though supposedly the forums were backed up offline). The post in question if I recall was a bit more technical and detailed but that was the gist of it.

MikeTomTom's picture
Offline
Joined: 2009 Dec 7

Ah, thanks. And a pity the archive isn't available.

os9er's picture
Offline
Joined: 2013 Nov 15

To be perfectly honest, I actually like that older layout (mainly because I like the look of Mac OS 7.x). Somehow I wonder why it wasn't brought back when the site switched hosts...

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

Might as well drop a link for those interested. Since I've got a basic processor emulation coded up, the next step is to test it against machine code.

Temporary Joe's picture
Offline
Joined: 2009 Nov 14

I'm not sure what the cause of it is, but there's a weird bug with SheepShaver and Basilisk II where quitting an application and opening another application will usually cause the second application to crash (so you can't try multiple applications during one session in an emulator). I assume this has something to do with the way the emulators call the RAM (which is of course all virtual, and can't take advantage of the host computer's RAM, even 2GB would be everything Mac OS 9 could possibly want). I tried asking this on another forum but got nothing. Maybe a newer, less antiquated emulator could address this problem.

WhosIt.There's picture
Offline
Joined: 2014 Aug 23

I've never had that problem with SheepShaver 2.4 under macOS High Sierra.

The main problem with SheepShaver and Basilisk is their disk handling is awful and very picky. Mini vMac is much much much easier to use.

adespoton's picture
Offline
Joined: 2015 Feb 15

We haven’t experienced that on Emaculation with either 2.4 or 2.5 - but it sounds like an issue I’ve had when playing around with alternate ROMs. Maybe that’s the issue?

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

So, I'm starting to boot into the Power Mac G3 Beige ROM, but it locks up 142 opcodes in. Still, baby steps. I was able to figure out where it began in ROM with the help of Sheepshaver. Also, I can identify a number of PPC Mac ROMs.

nil0bject's picture
Offline
Joined: 2012 Nov 14

still pretty cool. keep us updated!

os9er's picture
Offline
Joined: 2013 Nov 15

@nil0bject: Agreed, this sounds like an awesome project. Also looking forward to more updates, and to the project possibly being functionally complete one day. Smile

Temporary Joe's picture
Offline
Joined: 2009 Nov 14

So, what is the goal of the emulator, really? Is it to make an Old World ROM PPC emulator for completionist reasons, is it to essentially replace SheepShaver as the de facto PowerPC emulator, is it to create a "slow but accurate" emulator, is it to better integrate classic Mac applications with the host operating system, or is it to run more games more accurately?

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

For now, it's more a mix of the first two goals.

Sheepshaver is becoming increasingly hard to compile and it's coded with 32-bit machines in mind, which is not good considering that 64-bit OSes are relatively common now. There's also a locking down of memory, which is also bad since Sheepshaver not only expects 1:1 address translation, but also does some nasty memory mapping across the OS like trying to reserve memory at 0x0 (a huge no-no nowadays). If someone wants to address these issues, they have the OK to do so. It's just not trivial to fix.

With Sheepshaver increasingly harder to get working, I'm also hoping to fill in a void left in Sheepshaver's absence. And of course, this means addressing Old World Mac emulation and trying to improve upon what Sheepshaver had. For one, this includes proper SCSI hard drive emulation rather than using the floppy drive emulation in place of proper hard drives.

You can also say I'm trying to improve the state of emulation just a bit, which helps a bit with running games more accurately.

Temporary Joe's picture
Offline
Joined: 2009 Nov 14

Definitely trying to replace an increasingly outmoded emulator is good, and the way SheepShaver handles memory is not good. I know if I've had a lot of programs open recently with the RAM being swapped and used constantly, SheepShaver will refuse to run, throwing up some cryptic error message. The lack of proper QuickTime or OpenGL emulation limits a lot of games, too, and I miss Mac's Bugdom (the PC port isn't as good), WingNuts (same), and Nanosaur. So doing a bit of research, the maximum OS Old World Macs is 9.1, something not possible on SheepShaver due to lack of MMU. I've even heard that you could install Mac OS X 10.0 or 10.1 on beige Macs with the assistance of a hack that they covered in MacAddict once.

nil0bject's picture
Offline
Joined: 2012 Nov 14

a 9.1 emulator would rock

MikeTomTom's picture
Offline
Joined: 2009 Dec 7

I've even heard that you could install Mac OS X 10.0 or 10.1 on beige Macs with the assistance of a hack that they covered in MacAddict once.

Maybe that was using XPostFacto? It could be used to install up to 10.4x - I used XPostFacto v3.1 to get Panther installed and running nicely on my beige G3.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

Well, this is weird, I'm going through the code trying to figure out why it still locks up at 0xFFF0321C (Rom Address 0x30321C). I just rewrote a not insignificant amount of the code, which I thought would fix this issue. Apparently not though.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

So, it seems that the PowerPC emulation is not the issue at this point, but rather now is the time to start implementing the I/O parts to allow further booting. It tries touching the CUDA parts when a Power Mac boots up and the tests for the CUDA fail, it dies on 0x30321C. Lucky for me, it seems like the CUDA logic is referred to starting at 0xF3016000 in memory, on most PowerPC machines (particularly later Old World and New World machines). It's also 0x2000 bytes in size.

I have a CPU emulation stub of sorts that I can refer to if trouble comes up.

adespoton's picture
Offline
Joined: 2015 Feb 15

You may want to refer to the CUDA implementation for QEMU at this point Smile

Jatoba's picture
Offline
Joined: 2018 Apr 16

Wow. I'm really looking forward to this. Wish I had the knowledge to help. (Low-level software development is not something I at all have experience with.) If I ever stop being a bum and learn something that can be useful to this, I'll be sure to remember this project and come back... For now, the closest to that that I'm doing (which is still pretty far from what this project is about) is poking at decompiled New World ROMs (by ELN from MacOS9Lives) and seeing what I learn.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

Bit of a bump: But I'm fixing up several bugs and trying optimize whatever I can.

Halfway through the boot-up initialization in the PowerMac G3 ROM. It's currently hanging up on 0xfff0304c, as it suddenly erases the link register before attempting a branch to the link reg.

kataetheweirdo's picture
Offline
Joined: 2009 Apr 10

My progress in trying to boot a ROM so far