Macintosh Personal Color, a Fantasy 1986, 68000 Mac with a 4bpp Color Mode (Emulator)

Snial

Well-known member
Near the beginning of my exploration for Mac Color Personal (I now prefer MacCP to MacPC ;) ), I considered how developers might develop on it. The biggest issue is how to run a suitable compiler on a Mac 512K. At the time, I was aware of Consulair C, but I had the feeling that it was a bit too primitive and therefore thought that an early THINK Lightspeed C would be the minimum, and it'd need 1MB, i.e. an expanded Mac CP.

More recently I've come across the MegaMax C compiler. There's a download for it on the Macintosh Garden. It's a really interesting compiler, a one pass 'C' compiler (and inline assembler) that fits in 96kB!!! It's still very primitive. It's probably most famous for the Asteroids clone Megaroids, which was written entirely in MegaMax C and is very playable!

The way it's designed to work is that you run the Editor and the Editor's file menu (note the non-standard lower case!) has some options to transfer to the compiler and linker. However, I found that when I tried to do that, it crashed and corrupted my project disk, so until I get around to seeing if that can be fixed, I just quit the editor and then run the compiler.

So, this is my main desktop when running MegaMax C under MFS System 3 (because the Mac ColorPersonal only has a 64kB ROM).

1741037066112.png

I have a list of the apps in one desktop window, so when I quit the editor I can choose another app. mmcc is the compiler itself, which produces .o files so you then need mmlink (just off the bottom of the window) to link an application. Most of the time MFS disks get in the way, because all the folders are fake and I'd forgotten how frustrating that can be. When you open a file, you see every single file on the disk and they all have to have different names, as do the folders. Then when you compile, it doesn't matter if your .c files are in a folder, they end up at the root of your project disk anyway. That's why you can see edit.o, Edit and parts of my other compiled files.

MegaMaxC supports the Macintosh Toolbox, but stupidly, they made all the Toolbox symbols (types, functions etc) lower-case. Also only the first 10 characters in an identifier count and really oddly, short is 8-bit. Nevertheless, the initial colour palette demo is very similar to the THINK C version:

C:
#include <qd.h>
#include <misc.h>
#include <mem.h>
#include <res.h>
#include <win.h>
#include <control.h>
#include <event.h>

#include <qdvars.h>

#define kPalSize (16)
unsigned int gClrPal[kPalSize]={
    0x000, 0x400, 0x080, 0x480,
    0x008, 0x408, 0x088, 0x255,
    0x4aa, 0x700, 0x0f0, 0x7f0,
    0x00f, 0x70f, 0x0ff, 0x7ff
};

#define VidMdSet(aVal) *((unsigned int*)0xbffffa)=(aVal)
#define PalSet(aEntry, aColor) VidMdSet(0x8000|(aEntry<<11)|aColor)
#define MdeSet(aMode) VidMdSet(aMode)

rect gSrcRct;
windowrecord gMainWin;
windowptr gWin;

InitTlbx()
{
    /*
        Startup toolbox managers
    */
    initgraf(&theport);
    initfonts();
    flushevents(everyevent, 0);
    initwindows();
    initcursor();
}

BtnWait()
{
    while(button()) { /* wait for button up */
    }
    while(!button()) { /* wait for button */
    }
}

main()
{
    int ix;
    InitTlbx();
    /*
        Initialize screen rectangle
    */
    setrect( &gSrcRct, 4, 40, 256, 128);

    /*
        Create Initial window
    */
    gWin = newwindow( &gMainWin, &gSrcRct, "Video", 1, 0,
             (long)-1, 1, (long)0);
    setport( gWin);
    moveto(0,12);
    drawstring("Click the button!");
    BtnWait();
    for(ix=15; ix>=0; ix--) {
        PalSet(ix, gClrPal[ix]);
    }
    MdeSet(1); /* now we're in color mode */
    BtnWait();
    PalSet(0, 0x7ff);
    PalSet(1, 0);
    MdeSet(0); /* now we're in mono mode */
}

And indeed it works too:
1741037631071.png
Also, the cursor is initialised properly to an arrow, which is recognisable on the colour screen. As before, with my palette setup we get green on the left and magenta on the right, because a single colour scanlines is 128 bytes, or 2 standard Mac 512K scanlines and the checkerboard pattern has 0x55 on even lines (Green) and 0xaa on odd lines (Magenta).

According to a book I was reading on the compiler, it can't handle programs bigger than 32kB. I think that's not true since at least 2 code segments get linked into a fairly standard program and they have individual names. This means the segment names are part of the object files and I guess it's possible to define your own segments then.

Finally, one of the real oddities about the MegaMax C compiler is that it has no make program and no project manager. Instead, large, multifile projects are handled using a batch language driven by the application batchX. Bizarre huh? But it makes a bit more sense once you know that MegaMax C was also available on the Atari ST, also within its 512kB limits and I guess the ST's MSDOS-like file system made batch processing a more natural tool (or maybe they developed it as a cross compiler on a PC first?).

Anyway, that's my foray into the world of 1985 Macintosh 'C' compilers. I'm not totally traumatised, so I count it as a win o_O !
 

Snial

Well-known member
One of the aspects of the Mac CP I'm interested in is how well it can reproduce realistic images. The 16 colour palette and limited resolution would suggest that the answer is not very, or at least very unsatisfactorily.

To test this I wrote a Java program (yay!) that can take an image, such as a .png or .jpg and convert it (with optional dithering) to my default 16 colour palette (which is the set of primary colours at 50% brightness + primary colours at 100% brightness + 1/3 grey and 2/3 grey). Then I wrote a simple application in THINK C to open such a file (a .px4 file, with type 'PX4 ' and fake creator: 'cPnt' or 'Cpnt' I forget which) and read it to the CP's screen. You'd need to first resize the image so that the dimensions are exactly 256 x 171; otherwise, you're going to crash the Mac application when it runs.

I tried it on a few sample images. The first one was a fake image of Earth in space (note, no clouds!), next to the Mac CP version on the right:

1741431116313.png. 1741431213998.png

At the same scale it looks surprisingly good, I think! You can see plenty of speckled effects from the Floyd-Steinberg dithering algorithm, but the tonal range seems pretty decent. If you were to enlarge either image, you'd see how blocky they both are. Next up: kittens!

1741431364138.png. 1741431413186.png
This is a picture of our cats, Kyra (on the left) and Casper (on the right) in early 2013 when they were maybe just a couple of months old. In many ways this is a more convincing image, except you can see that the specular reflection in Casper's eyes has virtually gone. Sadly, Kyra is no longer with us, but Casper is now 12 and still in good health!

A Word About Dithering
Dithering is surprisingly effective at compensating for poor colour depth, effectively trading image resolution for depth. Apple used a lot of dithering algorithms in the late 1980s for early Colour Macs, because memory was still expensive and indexed 256-mode colours were the most practical.

I remember getting my PowerCD for my LC II back in 1994 and exploring the demo PhotoCD that came with it: seeing realistic images on the LC II, even in 256 colour mode seemed really impressive - the dithering is often not that noticeable, when you squint and walk to the back of the room ;) . But it's certainly more challenging with 16-colour modes.

First let's look at both images without dithering:

1741432184780.png 1741432366883.png

This is how such images might typically have been displayed on Atari STs in the late 80s or Windows 3.1 in the early 1990s in 16 colour modes. They are pretty awful. What Floyd-Steinberg dithering scan every single pixel in turn, in raster order. For each pixel it computes the difference between the closest colour you can generate and the actual pixel's colour; replaces the actual pixel with that closest one and then adds a fraction of the error to the pixels immediately below and to the right. Generally speaking errors then accumulate until a future modified pixel becomes nearer to a different colour than it would have been, before being modified.

The dithered kitten image IMHO looks better than the dithered earth image. That's because the kitten image is both brighter and has more tonal variety. At low brightness levels the speckling effect becomes more noticeable (because the ratio between the dithered colours is greater), but also the kitten image's is already fairly busy: quite a lot of colours, fairly closely spaced which disguises the dithering effect. Of course, it's possible to improve low-brightness dithered images by picking a less bright palette, but this won't work if there are some fairly dark areas + some bright areas elsewhere - the same palette can't do a good job for both; and of course, the colour range for the palette is fairly limited: just 4 bits for Red and Green, and only 3 bits for Blue.

Floyd-Steinberg is pretty slow though; my Java implementation is far from optimised and I use floating point arithmetic and 24-bit internal colour calculations to generate the best resultant image I can. An Atari ST-era computer would struggle with the memory requirements (192kB for 320x200) and the computation could never be done in real-time, AFAIK. As a consequence, Apple picked quicker, though usually less effective dithering algorithms.

I've supplied my THINK C project (it's not got much error-checking!) and Java dithering algorithm. The THINK C project also contains the converted px4 images shown here (22kB each).
 

Attachments

  • MacCpImgDemo.cpt.hqx.zip
    29.5 KB · Views: 0
  • CpImager.zip
    6.6 KB · Views: 0
Last edited:

Snial

Well-known member
Hilariously, you can run System 7.1 on an InfiniteMac, emulated Quadra 650 at 256x172 in 4bpp mode! :ROFLMAO: !

1742158260217.png


Boy, it scrolls quickly!
 

joevt

Well-known member
Hilariously, you can run System 7.1 on an InfiniteMac, emulated Quadra 650 at 256x172 in 4bpp mode! :ROFLMAO: !
It uses the BasiliskII emulator which has a custom screen size option like SheepShaver does which I showed in #3 .

DingusPPC will also have a custom screen size option eventually. The Power Mac 8500/8600 emulation has an emulated composite/video out mode which is 256x192.
 

Snial

Well-known member
It uses the BasiliskII emulator which has a custom screen size option like SheepShaver does which I showed in #3 .
Thanks, I did read it at the time. I knew the Q650 emulator could do non-standard screen sizes and I had used that before, mostly to simulate LC screenshots at 512x384. I'd never tried anything as small as 256x172 (note: it can't do 256x171!) - I didn't seriously think that classic Mac OS could run at that resolution!

And this is the Q650 at Atari ST resolution and depth vs an Atari ST screenshot at the same resolution:

1742167106803.png1742167351818.png
Slightly less ridiculous, but it illustrates some of the design considerations between classic Mac OS and GEM TOS. Namely: even System 1 looked a lot nicer than TOS; while being more functional, yet it's visually more of a squeeze. GEM TOS uses tinier fonts to make their clunky GUI more usable. The windowing system is just plain awful though. I hadn't worked out how to move or copy a file easily from one folder to another, because when you open a folder it opens into the same window as the disk window, so you can't see two folders independently.

So what I've been doing is navigating to the inner folder, then copying the file(s) to the Floppy Disk icon, which pops it at the top level; then I can move it deeper. However, I've just discovered it's possible to open two windows for the same root disk, which means that it works more like Mac OS X than classic Mac OS.

DingusPPC will also have a custom screen size option eventually.
Great! And curious - didn't the 6100 only support 640x480?
The Power Mac 8500/8600 emulation has an emulated composite/video out mode which is 256x192.
Close and very Sinclair, so I approve!
 

joevt

Well-known member
Slightly less ridiculous, but it illustrates some of the design considerations between classic Mac OS and GEM TOS. Namely: even System 1 looked a lot nicer than TOS; while being more functional, yet it's visually more of a squeeze. GEM TOS uses tinier fonts to make their clunky GUI more usable.
classic Mac OS is like the Retina/HiDPI of GEM TOS. Just as modern macOS is the Retina/HiDPI of classic Mac OS or old Mac OS X. Everything looks better when you give it more pixels.

didn't the 6100 only support 640x480?
It supports these modes:
Code:
Rgb12in  512x384
VGA      640x480
Rgb13in  640x480
Rgb16in  832x624
Portrait 640x870
Of course, you can connect different graphics cards which support more modes.
 

NJRoadfan

Well-known member
The GEM screenshot is actually 640x200 stretched to 640x400 to correct the aspect ratio. The ST did support 640x400, but only with a monochrome monitor. All three of the 16-bit micros offered GUIs running on 640x200 (hence why I mentioned the IIgs as a "what if" situation), so it was a serviceable resolution. Apple's Shaston font was optimized for this use case.
 

Snial

Well-known member
The GEM screenshot is actually 640x200 stretched to 640x400 to correct the aspect ratio.
It's actually 320x200 stretched to 640x400 on the PCE emulator. All the emulation screen sizes are the same so that the emulator can just open a 640x400 SDL window.
The ST did support 640x400, but only with a monochrome monitor. All three of the 16-bit micros offered GUIs running on 640x200 (hence why I mentioned the IIgs as a "what if" situation), so it was a serviceable resolution. Apple's Shaston font was optimized for this use case.
I think what you meant by "what if" was that the Apple IIgs was what I'm intending by the Mac Color Personal. Is that correct?

I think my response is that the IIgs wasn't, because it "threatened the Mac while not really challenging the ST or Amiga".

A 2.8MHz 65C816 just doesn't have the power to compete with a 7.5MHz 68000. e.g. Dhrystones = 236 (=236/1757=0.134 Dhrystone MIPs) vs 702 for Macintosh (=0.40 Dhrystone MIPs) (I found a similar figure for the Atari ST when compiling on MegaMax C). Sadly, you need an 8.4 MHz 65C816 to compete.


Also, the IIgs must have been relatively expensive to produce.
Apple IIGS ROM 01 - Motherboard Front.jpg
It's not expensive just because it has about 46 chips. The connectors, separate display and disk drive and expansion slots will add to the cost too. Compare with the Mac Personal (the CP is basically the same since the colour hardware would be mostly in the ASIC).

index.php

16 chips + 2x ROMs + 16 DRAMs = 34 chips; one edge connector.

I would never say the IIgs isn't a lovely computer - I was wowed by it when I first saw it in Personal Computer World:

1742302903054.png
Aesthetically it's great: Clean Snow-white Platinum design; somewhat Apple ///-ish; well-proportioned monitor; vibrant colours (3200 in 320x200 mode with the interlace palette trick). It just couldn't compete with the Atari or Amiga. 1.5M IIgs systems were sold between 1986 and 1992 vs 2.1M Atari STs (or 4-6M depending on the source) and 4.8M Amigas.


1742304477902.png

But a better what if question is surely - what if they'd ploughed the effort of the IIgs into a Mac CP? And for education users who really needed Apple ][ compatibility, provide a software emulator (https://macintoshgarden.org/apps/ii-in-a-mac) or a CPU-based emulator like they did with the LC?

It's not that there were easy choices to make in the transition from 8-bits to 16-bits; here I'm simply exploring a quick hack to compete with STs and Amigas.
 

olePigeon

Well-known member
@Snial I think this is really cool and could open up avenues for displays not normally used, like those tiny OLED displays. Or those 1:1 square ratio displays. That would be neat.
 
Top