Retro Programming Nostalgia: Commodore Amiga and Molecular Visualization

Italy 1989, it was the age of Commodore Amiga with its BOING demo, the bouncing ball that conquest the heart of the millions of young people living the microcomputer revolution.


It was the time when a software failure was a moment of Guru Meditation and when possessing a hard disk of 60 MB, it was considered a luxury of abundance and privilege.


It was for me also the age of the Amiga BASIC programming. I moved my first steps in learning how to program a computer using the CBM BASIC of the Commodore VIC 20 (another mythical microcomputer of the ’80 that deserve another blog) and by refining my skills with the MSX BASIC of the PHILIPS VG 8010 before end up using the Amiga BASIC. I fell always nostalgic when I come back with my memory to those years since I wrote many interesting programs with this language for the simulation or the study of different serious and recreational topics in Physics and Chemistry. Few year ago,  in the verge of one of these nostalgic moments, I have dedicated some time in an effort of forensic archaeology to recover, from my 27 years old collection of Amiga floppy disks, the forgotten products of my pristine programming experiences.  I sold my powerful Amiga 500 (it was equipped with a Motorola 68020 CPU with the arithmetic coprocessor and an external 40 MB hard disk) to buy a PC running the wonderful OS Linux that I got to know in 1993 when I started my Ph.D. Not having anymore an Amiga computer, I could not read the 800 kB formatted Amiga disk with a normal PC. In fact, these floppy disks require an Amiga floppy driver that format the disk in a different manner than those on common PC. I was almost resolved to buy a second hand Amiga 500 on eBay (an idea that still is tickling in my mind time to time) when I discover the smart adfread software by Toni Wilen and Simon Owen, that use two PC floppy drivers to read 800kB Amiga formatted. I was lucky to still possess an old PC with a motherboard supporting 2 floppy drivers, and that the  2-drive trick worked nicely for all of my 27 years old floppies! So I could recover all my programs. The next step in this story is the great Amiga emulator FS-UEA ( that can run very nicely the emulation of the Amiga 4000 (Motorola 68040 CPU, the top level of the Amiga family that was for me a dream computer since I could not afford to buy it!) with Workbench 3.1 on my MacBook laptop. This allowed me to run software that I have developed more than 27 years ago! The largest projects that I accomplished with this computer was the realization of a program for the visualization of molecules. I have described it in another blog in Italian. Here, I will give a short summary.


The program is one of the most complex programs in the BASIC programming language that I have ever written using a microcomputer. It combines both capabilities of editing and visualization of molecular structures.

The program assists in editing the coordinates of the molecules creating a sort of database. The coordinates can be retrieved using a file loader shown in the screenshot below from the FS-UAE emulator.


The file loader window contains a list of molecules whose crystallographic fractional coordinates. I have copied these coordinates by hand from books and journals of crystallography from the library of the Department of chemistry.  Unfortunately, at that time, I was a chemistry undergraduate student without the access to the crystallographic database (CSD)… I had also to spend quite some time to find the general formula to transform the coordinated from fractional crystallographic to cartesian (normal) one. I remember that I was jubilant and proud of myself when finally I figured out the correct matrix!

The atomic coordinates are usually reported in the literature as fractional coordinates (i.e. divided by the length of the sides (a,b,c) of the unit cell) in the reference frame of the unit cell. To represent them in the Cartesian reference system used in my program, it is needed to apply a reference system transformation that takes in account the crystallographic angles (\alpha, \beta, and \gamma) of the unit cell. For a given atom of fractional coordinates (x_f,y_f,z_f) the corresponding cartesian coordinates (x_c,y_c,z_c) are obtaind by the transformation:

\left(\begin{matrix} x_c \\ y_c \\ z_c \end{matrix}\right)=\left(\begin{matrix} a\sin \gamma & 0 & c\left(\frac{\cos \beta -\cos \gamma \cos \alpha}{\sin \gamma}\right) \\ a \cos \gamma & b & c\cos \alpha \\ 0 & 0 & c\frac{1}{\sin \gamma}\sqrt{1-\cos^2 \gamma -\cos^2 \alpha -\cos^2 \beta +2 \cos \alpha \cos \beta \cos \gamma}  \end{matrix}\right) \left(\begin{matrix} x_f \\ y_f \\ z_f \end{matrix}\right)

 ' In Amiga Basic
 ' Convert Fractional to Cartesian Coordinates

 ZC=(Z/SIN(ga))*SQR(1-(COS(ga)^2)-(COS(al)^2) -(COS(be)^2)+2*COS(al)*COS(be)*COS(ga))

Crystal structure of the beta-carotene. On the right color coding of atomic element for the ball-and-stick representation.

The unitary cell can be also visualized with the atomic coordinates. In the above screenshot, the crystal structure of the beta-carotene molecule and the crystallographic unit cell are shown.


In addition, the program can manipulate the molecules in space by performing translation, scaling and rotations along the axis of the reference system. The resulting coordinates are projected on the viewport of the screen using the parallel-perspective transformation. The program can also generate the visualization of the crystallographic packing.


Finally, in this last screenshot, it is shown one of the windows for the measure of geometric properties of the molecule, in this case bond angles.

The source code of the program is available mmb1 as PDF file.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.