=== Top of the Swiki === Attachments ===

Porting Squeak

Be sure to also look at InterpreterSupportCode class >> macMinimal

As a quick start on the subject here is some mail advice I once sent on the subject.

As I expect you will notice very soon after taking a look at the Squeak VM
sources, it's pretty simple. Most of the code is produced for you and is
platform independent - at least, nobody has had problems so far.
The platform specific code can be broken down into two parts:-
a) relatively simple stuff such as starting up, reading commandline (if
appropriate) arguments, using fopen/fseek/fread/fclose to load the image,
open a window, read keyboard/mouse events, some way to do a few directory
related functions
b) more complex stuff like sockets, midi, serial, and so on.

The items in b) can be left till much later, as long as we can make
sensible 'null' routines to satisfy the linker. My recent comments on the
thread about cleaning up the VM are in large part aimed at reducing this
problem. I can certainly help with producing an image to help with this.


For the part a) items, a normal ANSI C library will suffice for most of the
file handling. All the float and arithmetic etc is plain ansi. We need to
be able to return a sensible path string for the VM and the image file -
they are used to work out relative paths etc later. Basic directory
enumerations are needed, a quick look at the sqXXXXDirectory.c files for
the different platforms will explain quite well. Some way to allocate a

This will be typically a malloc of image file size + 1 or more MB for
working room. You can manage with less, but it hurts performance and
reliability.
The most tricky work is normally that relating to connecting to the display
and input events. We need to be able to copy pixels from the Squeak display
bitmap to the actual machine display memory. Complications include things
like the Squeak display being 16bpp when the machine is displaying 8bpp, or
vice versa. It is feasible during early development to set things up to
match the bpp of the two. Input events need to be translated to map key
presses reasonably closely to Mac key numbers, in order to get metakey
events to work. This can be a right bugger to get done correctly!

Basically, if you can see how to write a prog that will:-
to start with)
top/left/right/bottom values and maybe converting bpp, and maybe converting
from big-endian to little endian at the same time
then we're in business. Everything else is negotiable later.

If you've already been looking at Squeak then you already have the sources
for the Mac built into the system. The PC sources are usually available at
ftp://alix.inria.fr/pub/squeak as are various unix sources. My Acorn sources
are off the Squeak page on my website (see below). Since I have never bothered
to do the sound, serial or midi stuff for the Acorn, the relevant files would
make good null files to start with.