New games every week!
A Curious Day Blog
5th September 2022
Deciding to take the Sunday off, I opened up my archive of old Amstrad Computer User magazines and started flicking through, taking a crazy nostalgia trip into the unknown.

-=-=-


Triangulation - 4JLhSRqk.BAS

From Issue Two of Amstrad Computer Music magazine.
Although the triangle drawing code was more or less easily portable, I did have to rewrite a couple of bits and pieces to get it to work properly inside of JSE.
But it was nice to be able to get some proper old fashioned code to work in JSE.

There's a heck of a lot of program listings, even in the very first issue, that use some incredibly complicated commands that just don't exist in JSE. It's kind of staggering how much stuff they crammed into BASIC listings, even back in 1984!!

Which brought me to another piece of code..


Full size (Copyright Amstrad/AMSOFT, 1984)

From the VERY FIRST issue of the magazine, a 3D wireframe generator!!
There's no way that would work as-is, but the concept was relatively simple.
Create a line of points, offset from the center. Each point is an X/Y co-ordinate running down the length of the shaft.
Next, extrude (is that the right word) rotationally so that the points become a cylindrical set of 3D points.
Then draw lines between the points onto the screen.

So I set about doing just that, and there was a heck of a lot of Maths involved in the code, and after about an hour or so, JSE was struggling exactly as I thought it might..

How to speed it up, then?
Well, I'd written rotational 3D maths to take x,y,z and rotate them through rx,ry,rz..
If I converted that into a JSE command, that'd be a lot quicker..

Unfortunately, I'd need to destructively alter the variables sent into the command.. I don't *think* I've done that before, though I might be wrong.
After a little tweaking, I came up with a Rotate3D command..
Rotate3D(Point X,Point Y,Point Z,Rotate X,Rotate Y, Rotate Z) will take replace the values of x,y,z with the rotated versions, based on the given rotation values.
To draw them, however, you'd then need to convert x,y,z to screen x,y co-ordinates, so in went another function Isometric3D(Point X,Point Y,Point Z, x2D, y2D)
Again, another destructive variable, replacing x2D and y2D variables with the resulting 2D flat points. It's up to you to then offset/scale those so they fit on the screen.

With those commands in the engine, I stripped out most of the 3D maths from my GotoJSE code and replaced them with the new commands.
The result is really quite nice, though it's still not what you'd want to use for an actual game or anything.
It's still slow when it comes to running through the array and drawing all the lines.


You can Try out the result here.
(Be sure you refresh to update to v.3ggl - It's displayed in the FPS area)

I've not yet written up the new commands for the help file, but will probably do that later today.
I might try to add a Perspective3D command to go alongside the Isometric3D one, though goodness knows how well that'll go!

Amstrad Magazines sourced from RetroPDFs
Views 67, Upvotes 13  
Daily Blog , Jse
New games every week!
Site credits : Jayenkai put all his heart and soul into everything you can see on this site.
(c) Jayenkai 2023 and onwards, RSS feed 88

Blog - A Curious Day - AGameAWeek