Thursday 20 September 2012

Sinclair Spectrum 128k +2 MINI

Sinclair Spectrum 128k +2 Mini!
The above image is a mock-up of what a sawed-off Sinclair Spectrum 128k +2 might look like. Read below to see how it turned out to be reality! The idea for this picture came from Marq, who suggested removing the ugly and unnecessary tape device in a rather brutal manner.

The original
The initial idea was that the cut would be aligned with the left edge of the cassette slot opening, giving a very straight line from which to begin. The whole operation ought to be simple, as the tape recorder is not really very integrated to the other stuff inside the casing. The motherboard is entirely contained at the left side.

128+2 insides: With the cut, the heat sink would have to be re-arranged and the casing would lose one support.
Still, the cut suggested in the first image may not be quite as straightforward. There are some parts beside the tape recorder that extend beyond the cutting line. This could be covered by having some kind of addition to the right side, perhaps something that resembles the original 128k Spectrum. Another option might be to use a couple of centimeters of the +2 casing itself! But this would probably leave a visible seam.

Preparing for the cut


Removing the cassette recorder proved to be simple. Also, the computer appears to work just as well without the tape recorder, which comes as no big surprise. In this process the power LED has come off, and I think someone else will have to figure out how to rewire it.


The now revealed plastic protrusions and screw holders can hinder the cut, so some re-thinking is in order at this stage. On the plus side the heat sink (A strange L-shaped contraption) may indeed be possible to turn around to the front side. However, it is unlikely to fit without at least some changes.

Cutting


About that re-thinking... Nah, I just decided to go with the original line. I first used a sharp paper knife to cut as deep as possible along the side of the tape recorder opening. Using a ruler, I also made careful lines using the opening as a guideline. When it came to actually cutting the plastic, the paper knife turned out to be surprisingly poor, so for the rest of the project I only used it for initiating points for sawing.

Some care needs to be taken when sawing the front. I used a straightedge and the paper knife before sawing.

I used a "Japanese" style back saw, meant for wood cutting. I probably ruined the blade but it had seen its best days anyway. This saw took to the plastic surprisingly well, and I felt encouraged to just push violently through the screw holders and other protrusions. However as I progressed I realised the casing would loose most of its support at the same time, and the part remaining to the right side of the keyboard became quite fragile. So I did away with the protrusions with some more care, trying to saw them sideways from below when possible.

The tape recorder part could be made into a unique, stand alone, Spectrum-themed tape unit. But who cares?

It might have been a wiser move to saw first the bottom half, leaving the more visible parts for later stage. Then I could have used the "gained experience" for the more important parts. But this way, I can use the existing cut for lining up the bottom half of the casing. Had the bottom been cut first, the resulting alignment might have been unsuitable. 

But really, I just could not resist getting first at the meat of the matter!

And now, what at first was just a mock-up, is rapidly becoming a reality...
The resulting edge is surprisingly straight given it is hand sawn and my sawing skills are a bit rusty. The success is mostly thanks to the existing tape recorder opening edge. The face certainly needs sanding, but perhaps not as much as I had feared.

Cutting the bottom half posed no problems, but making the end part from the remaining plastic and solving the heat sink placement is a bit tricky.

Closing the case


I have bent the heat sink from the L-shape to a formless blob. It does not quite go into a neat U-shape, at least without sawing the piece. I'm hoping to avoid that work phase, yet it may come to that.

Yet another decision to make...
The seam looks worrying at the moment, and at this stage I am tempted to cap off the end with a flat plastic plane cut from the former case bottom. This would diminish the effect of the seam and make the computer look very neat (from front and above) and much like the original mock-up image. However this would buy very little room for the heatsink and would maybe not look so nice from the side.

Adding the pictured end piece gives some more length to the computer, a bit like the original 128k Spectrum. The bent heat sink would fit easily. This direction means that there will be nearly endless sanding of the two parts and still the seam will probably be somewhat visible.

So, which ever route will be chosen, there will be work. But then again so far everything has gone quite smoothly.

(Continued to Part Two)

Saturday 15 September 2012

8-bit CAD attack

In the following, I will shortly discuss the phenomenom of 3-D modelling on 8-bit computers. I'll also give a little example in Sinclair BASIC that makes use of 3-D graphics and perspective foreshortening. This gives some idea of how the topic of 3-D graphics appeared to the hobbyist programmer at the 1980s.

This kind of software allowed the definition of shapes in three mathematical dimensions. Then these objects would appear from an angle. It's a far cry from today's modellers, where it is possible to sculpt an object directly on the screen as it appears. Also, these little programs are not really Computer Aided Design packages by any means, but it's still interesting that these were ever made.

VU-3D on the Spectrum

VU-3D was created in 1982, released pretty much alongside the release of the Spectrum. Psion made some of the most competently programmed software of the early Spectrum days. To my knowledge, since then nobody has really attempted to create a three-dimensional object modeller and solid renderer on the Spectrum. 3D Construction Kit (1991) from Domark might be closest to the description.

The VU wineglass, the Spectrum equivalent of the tea kettle!

At least to me, the VU-3D wine glass and box image was one of the early "iconic" images associated with the Spectrum. The screenshot was the basis for the cassette inlay of the package.

The three-dimensional shape is created by adding sections from bottom to top.
The editing is quite slick, but does not have any functions for modifying the existing points (that I know of). Nor is there any grid snap that would have made it easier to align the points. When viewing the object, there seemed to be some limitations to the angles from which it can be viewed. So, when devising the object, one needs to be careful to think which way it will be positioned, as this fundamental angle cannot be changed afterwards.

Viewing the created object.
So, it's pretty much a toy program, but the shading renderer is pretty impressive for its time. I found it quite difficult to do anything that would compare with the complexity of the wine-glass object, though.

ORIC CAD

Curiously, a very similar program exists for the Oric home computer, produced by Tansoft. After about 10 minutes of loading (in the slow speed) the user is greeted with a screen of text. Everything appears to have been written in BASIC. The demo object is a kind of round object made from an extruded pentagon, not as impressive as the wine glass on VU-3d.


A complete 8-bit CAD workstation!
The shape addition is not that different to the VU-3D. However, it is possible to go through existing points in the shape and adjust their coordinates. This makes it much more simple to correct any distortions that might have occurred.

Outlining the shape plan with ORIC-CAD.

One question is whether the Oric program is just a straight copy of the VU-3D, or whether there exists a common precedent that they both attempted to emulate. Perhaps there is some precedent on the bigger computers or turnkey CAD systems. Possibly it was something that was featured on a TV show, so the programmers might not even have had real first-hand experience of these bigger programs. But then again, Psion programmers for the early Sinclair software appear to have been quite competent so who knows.

3-D objects in Sinclair BASIC

Given the simplicity of the above programs, it might be just as useful (or useless) to write a program of your own. So, of course I could not resist the idea of doing something very quickly.

The example below gives some idea how such a program could be started, although it has many limitations compared to the above software packages. Back in the day, 3-D programming was quite a difficult topic. Then I could not really work my head around it at all, as oftentimes the examples were quite impenetrable. Yet, after getting how the objects are defined as coordinate lists, it really comes down to two things: perspective foreshortening and transformation (rotation), which are applied to all the coordinates.

I only cover the foreshortening in the following, although one could argue the rotation would be just as important. The foreshortening is simply a matter of proportioning X and Y coordinates of a point with its depth coordinate. (In principle, X=X/Z and Y=Y/Z for each defined point.) Of course the depth coordinate needs to be proportioned to something that gives a working result on screen.


The proportioning is done within lines 210-232 in the listing below. In line 200, the next point coordinate set (X=-50,Y=-50,Z=-50) is grabbed from the data list, and the following lines will mangle the numbers.

210 LET D=(Z+400)/300

First, the "eye" is set back 400 units so that the object coordinates will all be positive. (This adjustment might have been done in the coordinate list, but it's clearer to define the object along it's own coordinate centre.)

The Z coordinate is divided with 300. Here it is a rather arbitrary number. It is meant to give a ratio that shows the object in good size on the TV screen. There's no "right" number as it depends also on the distance and the size of the object, and ultimately what the program is meant to do. Here I'm just interested in getting a sizeable object on screen and 300 seemed to do the trick.

Then the X and Y coordinates (horizontal and vertical) are divided with the proportioned Z coordinate, stored in the D variable. (Line 220) The line 232 moves the coordinates in relation to the middle of the screen. (Remember, Spectrum has 256*192 pixel screen)

Here's the code. Go on, type it on your Spectrum!

By the way, if the eye needs to be moved to the side, a LET X=X+75 (or whatever) after line 200 will do the trick. If this number is too great, the object is drawn out of screen and the program will fail.

There's some added trickery that makes the program use the previously calculated point as a basis for drawing a continuos line through the coordinates. Hence, the DRAW x2-x,y2-y thing at line 40. This helps me avoid making a separate coordinate and point connection list.

The limits of the presented program are obvious. As it is not possible to rotate the coordinates in relation to the eye, the program output is confined to frontal views. Well, one could insert coordinates for a pre-rotated, diagonal cube, but it would be more effective to have the transformation within the program. This would be done after the line 200. 

Some "fun" with the above program.

However, as Spectrum BASIC does not allow lines to cross the screen boundaries, there's only so little that can be done with the above example. Furthermore, if I wanted to extend this program for viewing objects and spaces from the inside, the lines would need to be "clipped" also in relation to the picture depth plane, which is an added complication. Including all required line clipping and transformation routines woud also slow the drawing speed.