Subscribe via RSS
6Sep/213

Build Your Own Macintosh Classic!

Man, somehow I google'd across this link on creating your own Macintosh Classic and decided I'd do it myself. I'd already sunk cost into my own Kickstart'd Creality CR-6 SE printer and decided wtf, how hard can it be? The article even had a BOM that included all of the other physical components required. I placed the order, it arrived, COVID happened, box was stored, everything was forgotten.

Come Melbourne's lockdown #6 and I'm bashing through everything in the received-but-not-touched list. What to do first? Print the case. If that doesn't work, then who could care less about the tech purchased?

DSC03952 DSC03954 DSC03951

DSC03955

And with the printing, I screwed up! Make sure to configure your print settings with supports everywhere, not just 'touching base' or whatever the boring default is, as it won't work. I had to scrape the top inner frame of the display window to get it to not look too saggy!

DSC04001

The floppy disk is an insert and, as per the instructions, I added a white sticky-label to make it actually look like a floppy label. Once in the case it looks great!

Required Hardware

First off, we'll be using a Raspberry Pi Zero W, an old IDE cable and a 640x480 VGA screen for inside the case. Outside, some form of USB Keyboard and Mouse will be required to get everything installed. The Pi Zero is a very bare-bones unit and you'll need to get out the soldering iron, find some headers and solder up the GPIO interface.

DSC03989

From there, you just need to plug in the IDE cable and test it out. I did this first with just the standard RasPi install.

DSC03996

It worked fine... and was hilariously small.

Installing RetroPie

So, long-story-short, I tried the latest RasPiOS + yada and although the UI was lovely, the speed was shite. I then tried compiling my own BasiliskII and it just chuggggged. So, what's the answer? THIS IS THE INTERTUBES, someone has already done this: let me present to you RetroPie! Now, this is an amazing front-end + engines for Linux, to the point where configuration is out-of-the-box, but not so much for what we're about to do.... there's a bit of screwing around required!

First off, to get that Pi Zero W to boot, you're going to need to flash an SD card. On Windows, use the official Raspberry Pi Imager and choose RetroPie from the Emulators sub-menu.

rpimg1

rpimg2 rpimg3 rpimg4

Grab the card, a USB KB/Mouse and a display and boot the Pi. If everything works, you should be at a prompt to configure a gamepad?!

DSC04126

This was a little confusing for me as I didn't really care for a gamepad on this system at all. RetroPie expects you'll be playing Bubble Bobble, Snow Bros and Metal Slug, so it demands a controller configuration on installation. And so, with our goal being to play A-Train on System 7.5.5, we don't need a gamepad, but we'll still need to configure a device. This device will be a stock-standard keyboard and we'll need to tread lightly when mapping the buttons.

DSC04128

To get started, hold down a key on your keyboard for about 5 seconds. From there, please map the D-PAD directions to the arrow keys on your keyboard and then start=enter and select=space. From there, you can either spend time holding down any key to skip the association or just choose any key (don't choose the same key each time) to map to the millions of buttons. Once you succeed, the OK button will be highlighted and you get to press the key you mapped to button A.. do you remember?

DSC04132

If all is well, you'll have hit the screen above. This, in all it's glory, is RetroPie as a shell, with no engines underneath. Before we install engines, let's make sure we have full connectivity. Make sure that Configuration is showing under the RetroPie banner (use left and right buttons to select it) and then press the A button. You should see the following list:

DSC04127

From here, scroll all the way down to raspi-config (yes yes, the shot above doesn't show this highlighted!) and press A. You'll get thrown back to a console and raspi-config will load up in all of it's ncurses-glory. From here, configure wireless and enable SSH. Note that you'll be back to standard keyboard key mapping, so don't try and use the A button... just stick with your standard cursors keys and enter... escape'ing when you choose the wrong adventure.

Meanwhile, if you happen to select the wrong wireless country, you can hit escape to the main menu and re-select it in the Localization sub-menu by selecting WLAN Country.

SSH is under Interfaces and, once enabled, the configuration app will ask you to reboot. Do this. Finally, SSH in with your favourite terminal client using the credentials pi/raspberry.

     .***.     Sunday,  5 September 2021, 10:51:22
     *****     Linux 5.4.72+ armv6l GNU/Linux
     `***'
      |*|      Filesystem      Size  Used Avail Use% Mounted on
      |*|      /dev/root        30G  2.5G   26G   9% /
    ..|*|..    Uptime.............: 0 days, 00h14m35s
  .*** * ***.  Memory.............: 97496kB (Free) / 247472kB (Total)
  *******@@**  Running Processes..: 88
  `*****@@**'  IP Address.........: 192.168.1.57
   `*******'   Temperature........: CPU: 48°C/118°F GPU: 48°C/118°F
     `"""'     The RetroPie Project, https://retropie.org.uk

pi@classicpi:~ $

From here, let's cut over to the VGA display. This is done via the following:

pi@classicpi:~ $ cd ~/
pi@classicpi:~ $ git clone https://github.com/tianyoujian/MZDPI.git
Cloning into 'MZDPI'...
remote: Enumerating objects: 323, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 323 (delta 15), reused 26 (delta 10), pack-reused 291
Receiving objects: 100% (323/323), 1.54 MiB | 599.00 KiB/s, done.
Resolving deltas: 100% (165/165), done.
pi@classicpi:~ $ cd MZDPI/vga
pi@classicpi:~/MZDPI/vga $ sudo chmod +x mzdpi-vga-autoinstall-online
pi@classicpi:~/MZDPI/vga $ sudo ./mzdpi-vga-autoinstall-online

... setup setup ...

Setting up libgtk2.0-0:armhf (2.24.32-3+rpt1) ...
Setting up matchbox-keyboard-im (0.1+svn20080916-12) ...
Setting up libgail18:armhf (2.24.32-3+rpt1) ...
Setting up libgtk2.0-bin (2.24.32-3+rpt1) ...
Setting up libgail-common:armhf (2.24.32-3+rpt1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libgdk-pixbuf2.0-0:armhf (2.38.1+dfsg-1) ...
Processing triggers for mime-support (3.62) ...
Processing triggers for libc-bin (2.28-10+rpi1) ...

ZERO-W

CM

2B

3B

3B+

CM3
pi@classicpi:~/MZDPI/vga $ sudo reboot

From here, reboot and disconnect your HDMI screen.

System RAM

I did note that my system was only reporting 256mb total system memory when it had 512mb on-board?

pi@classicpi:~ $ free
              total        used        free      shared  buff/cache   available
Mem:         247468       48468       91656        2932      107344      146248
Swap:        102396           0      102396

Turns out the boot configuration is allocating 256mb to Video RAM!? Let's fix that... we don't need anywhere near that much RAM for a 640x480 screen. Here's the important part in /boot/config.txt.

[all]
gpu_mem_256=128
gpu_mem_512=64
gpu_mem_1024=256

The three lines are the settings related to actual system RAM. We care about gpu_mem_512 and, as you can see, it's setting VRAM to 256mb! Change that to 64 and reboot. Don't try any lower as RetroPie will struggle badly.

Install Basilisk II

Jump back into SSH and start up RetroPie's setup application. Note that you can also do this through the front end if you're working directly on the unit.

pi@classicpi:~ $ ls
RetroPie  RetroPie-Setup
pi@classicpi:~ $ cd RetroPie-Setup/
pi@classicpi:~/RetroPie-Setup $ ls
AUTHORS          COPYRIGHT.md  logs           README.md             retropie_setup.sh
CONTRIBUTING.md  LICENSE.md    platforms.cfg  retropie_packages.sh  scriptmodules
pi@classicpi:~/RetroPie-Setup $ sudo ./retropie_setup.sh

From here, you'll be warned you shouldn't have paid for this... and I hope you didn't.

packages-1

You'll find Basilisk II (package:basilisk) under opt and Mini vMac (package:minivmac) under experimental. Note you'll also find OpenTTD under opt... I might try that for fun. All packages will ask you a few questions, I always default to install from binary.

packages-2 packages-3 packages-4

packages-5

After installing each package, you'll be brought back to that packages sub-menu offering options for the already-installed package... without it telling you that it installed correctly. Slightly confusing, but just press the TAB key to get Back highlighted below and then hit Enter.

packages-6

Go and install anything else you're after, whilst you're here, and then choose the reboot option at the bottom. You'll then get a final warning, of which you'll only need to heed if you've been tinkering with the front-end whilst waiting for this stuff to install... I should've mentioned above that you shouldn't do this!

reboot-2

So... reboot!

Configuring Basilisk II

This took a little bit of working-out before I got it how I liked it. Emulators on RetroPie have configuration/data in multiple places. ROMs (of which Basilisk II needs) are in the main users' (pi, in this case) home directory, whereas configuration is in the /opt/retropie folder. We'll be tinkering around everywhere to get this to work.

Although we've installed the Basilisk II package, the individual configuration file for it hasn't been created yet. To make it appear, we need to actually kick off Basilisk II once and let it error back to the RetroPie menu. Do this now by going back to RetroPie and selecting Start from the Macintosh menu. If everything worked, there'll now be a configuration file located in /opt/retropie/configs/macintosh/.

Next, download the fundamental items to get Basilisk II to work: ROM, OS 8.1 ISO. Expand both items locally and then copy them across to the ~/RetroPie/roms/macintosh folder. Rename the ROM file to mac.rom and the ISO file to anything you want, but make sure it matches the configuration below. Also make sure the CD image is read-only:

pi@classicpi:~/RetroPie/roms/macintosh $ chmod -w macos_81.iso
pi@classicpi:~/RetroPie/roms/macintosh $ ls -l
total 935696
-r-xr--r-- 1 pi   pi   420229120 Sep  5 12:01 macos_81.iso
-rwxr--r-- 1 pi   pi     1048576 Sep  5 11:35 mac.rom
-rw-r--r-- 1 root root         0 Sep  5 11:06 Start.txt

We'll also need to create a harddisk file which we will format and install OS 8.1 onto inside the emulator. The following command will create a 512mb blank file.

pi@classicpi:~/RetroPie/roms/macintosh $ dd if=/dev/zero of=disk.img bs=1024k count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 63.6174 s, 8.4 MB/s

Note that we've called it disk.img. This is because the RetroPie configuration specifies this file on the command line and we'll just use that, instead of adding more config. We do have to do a few other configuration changes, so open up /opt/retropie/configs/macintosh/basiliskii.cfg with nano and update the settings as follows. Note that, if you want to change the allocated RAM, you should use a proper 8-byte value, so lookup the value here and update the config accordingly.

displaycolordepth 0
extfs /
seriala /dev/ttyS0
serialb /dev/ttyS1
ether slirp
udptunnel false
udpport 6066
bootdrive 0
bootdriver 0
ramsize 67108864
frameskip 6
modelid 14
cpu 4
fpu false
nocdrom false
nosound false
noclipconversion false
nogui false
jit false
jitfpu false
jitdebug false
jitcachesize 0
jitlazyflush false
jitinline false
keyboardtype 5
keycodes false
mousewheelmode 1
mousewheellines 3
dsp /dev/dsp
mixer /dev/mixer
ignoresegv false
idlewait true
disk macos_81.iso

The 'extfs' option defines the location of the 'Unix' drive that appears on the desktop. Note that, although there is an 'extfs' option configured above, RetroPie overrides this on the command line and sets it to the directory where we've just copied everything to. It's a great mechanism for copying files into the emulated machine, so you can copy extra things into this folder and then access them in Basilisk II. You can even do it while it's running... just close and re-open the Unix folder.

With the configuration saved, you should be able to choose start from RetroPie and ...

DSC04107

Hah, it booted and OS 8.1 is installing. Slowly!

Getting Audio Out Of A Pi Zero W

This wasn't easy! The Pi Zero W is a tiny board, missing many of the standard components so save cost. One of the components missing is an audio-out jack, but fortunately we can wire one up to the alread-in-use GPIO header. One note before you read any of the following: The pin numbering on the header is different to the connected pin numbers on the main CPU. Most of the time, when sites talk about GPIO18 or GPIO19, they actually mean the pin on the CPU and not GPIO Header pin 18 or 19! Grab and build the tools here and then run the gpio readall command:

pi@classicpi:~ $  gpio readall
 +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT2 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT2 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 | ALT2 | 1 |  7 || 8  | 0 | ALT2 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 0 | ALT2 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 | ALT2 | 0 | 11 || 12 | 0 | ALT5 | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 1 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 | ALT2 | 0 | 15 || 16 | 0 | ALT2 | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | ALT2 | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 0 | ALT2 | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | ALT2 | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 | ALT2 | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 | ALT2 | 0 | 31 || 32 | 1 | ALT2 | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 | ALT2 | 1 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 | ALT5 | 0 | 35 || 36 | 0 | ALT2 | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | ALT2 | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | ALT2 | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+-Pi ZeroW-+---+------+---------+-----+-----+

So, there's a lot to take-in above. Note it's mirrored, so start outside-in when reading. On both outside columns are the GPIO pins of the BCM CPU. We're looking for 18 and 19 in these columns. Above, I've already actually configured the unit for sound, so you'll see that these are configured for ALT5. To understand ALT5, you can read the GPIO mappings here, but just understand that both need to be ALT5 for PWM to come out of 18 and 19. These then map to header-pins 12 and 35 respectively. You'll find these two numbers in the inner two columns on the table above.

Next, we'll need a bit of physical hardware to interface with the GPIO header. Fortunately, since I have used an old IDE cable, we already have a point to connect into! The IDE cable has the middle header on the Raspberry Pi, one end on the LCD and, on the final end, we'll need to tap into pins 35 and 12. From these pins, we'll wire into a low-pass filter as per the circuit schematic here.

DSC04105

The VGA project specifically left GPIO18 and 19 free to let us have audio out, but they aren't enabled just yet. To do this, we'll need to edit /boot/config.txt once more and tell it to send PWM out the required pins. Add the following line to the very bottom of the file:

dtoverlay=pwm-2chan,pin=18,func=2,pin2=19,func2=2

The first note here is that func2=2 somehow equals ALT5, which is what we want. The second is that, with any future changes of boot config by any software, you should review this file and make sure this configuration is still at the bottom! Once confirmed, reboot and double-check that headphones are selected in raspi-config.

audio-1

audio-2 audio-3 audio-4

Save and exit and see what happens when you test with:

aplay /usr/share/sounds/alsa/Front_Center.wav

If the sound is quiet, then use alsamixer to adjust the volume.

┌───────────────────────────────────────── AlsaMixer v1.1.8 ──────────────────────────────────────────┐
│ Card: bcm2835 Headphones                                                    F1:  Help               │
│ Chip: Broadcom Mixer                                                        F2:  System information │
│ View: F3:[Playback] F4: Capture  F5: All                                    F6:  Select sound card  │
│ Item: Headphone [dB gain: 1.25]                                             Esc: Exit               │
│                                                                                                     │
│                                                                                                     │
│                                                                                                     │
│                                                ┌──┐                                                 │
│                                                │  │                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                │▒▒│                                                 │
│                                                ├──┤                                                 │
│                                                │OO│                                                 │
│                                                └──┘                                                 │
│                                                 90                                                  │
│                                            <Headphone >                                             │
│                                                                                                     │
│                                                                                                     │
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘

Bump the volume up to 90%.

Networking

So, TCP/IP to the internet should just work. AppleTalk to local ethernet devices probably won't work as AppleTalk packets don't survive over Wireless. I don't know why... but it's the same thing that happened when I was mucking around with physical LocalTalk adapters. Since I have another Pi on the network providing AppleTalk shares, I have the option to create a VPN and route AppleTalk over it to make it show up in Chooser auto-magically... but on a first attempt, the effort required is huge. I'll stick with manual IP entry for now, as that works fine!

The End Result

The screen is hilariously small, but games can be played!

241118466 361998575428700 6298152496122914924 n

The Pi Zero has just enough CPU to run OS 8.1 and A-Train. Audio works great and the MIDI sounds fine!

241139049 609410486890269 6802814062589133231 n

Shares are mounted via AppleTalk to the NAS and all is well!

Filed under: Apple Leave a comment
Comments (3) Trackbacks (0)
  1. Thx for the really well written setup of BasiliskII for Retropie. I followed your steps verbatim and when I launch the ‘start’ file in Retropie Macintosh I get disk with a question mark in it. I’m so close – do you have any insight what I might be missing?

    • krad311,
      This might take a bit of back-and-forth, so I’ve sent you an email. We can update this thread/post when we work out the solution.
      Steven.

    • krad311,
      Haven’t had a response from you. If you happen to read this, then please provide me with the following information:

      cat /opt/retropie/configs/macintosh/basiliskii.cfg
      ls -l ~/RetroPie/roms/macintosh


Leave a comment


*

No trackbacks yet.