Release notes – Torus Clone

We’ve previously looked at Taurus 2 by Yak in the most recent instalment of our Code Notes series and that seemed like a prime candidate for a C64CD-branded cheap but very cheerful copy as well, which has been titled Torus Clone. No dear reader, the names on these released aren’t going to become any more inventive and your correspondent can only apologise for that…

Torus Clone (C64)In keeping with how your correspondent assumes the original demo works, the position for each sprite is calculated by adding two values from a pre-generated curve for each axis; as with all of our previous releases apart from Clonemas, this is a mathematically calculated curve but could just as easily be created without anything more complex than addition and subtraction. Four counters in total govern where these values come from within the table sprite_sinus with the routines sine_x_gen_1 and sine_y_gen_1 reading the first set of values whilst sine_x_gen_2 and sine_y_gen_2 add a second to get the final value; a subroutine named preset_fetch gets new speed values for the four counters (which in turn will change the on screen movement) and is called roughly every five seconds.

The background effect uses a four by four character area with the characters themselves arranged into columns – look for the table screen_data to see the sixteen bytes and how they’re ordered, that gets “tiled” all over the almost the entire screen – because that means that the Y co-ordinate doesn’t have to be translated. The co-ordinates for the plotter actually come from the sprite positions as they’re worked out; the maximum value that adding two numbers from the sine curve can produce for either X or Y is 126 (or $7e in hex) and a couple of LSR commands[1] will divide that value by four to make it fit neatly into the 32 by 32 pixel area of the plotter –your correspondent assumes that the original demo has it’s curves at a similar radius for that reason as well.

Your correspondent usually adds a disclaimer about not using the released source code as a learning tool if new to the C64 but, whilst that still applies here, Torus Clone is probably the easier C64CD demos to understand in that context. It does jump through a couple of hoops (if you’ll excuse the “pun”) in order to get the plotter working with a reasonable degree of efficiency which probably weren’t really necessary, but the sprite movement at least should be quite easy to follow with a few passes at the C64 Programmer’s Reference Guide appendix on VIC-II registers where appropriate and the scrolling message code is recycled from previous C64CD release Hello Github. As always dear reader, please feel free to ask if there’s anything you’d like explained.

[1] LSR moves all the bits in a byte right, so the bit representing 128 is shifted to 64, 64 becomes 32 and so on with the final bit “falling off” into the carry flag; this means one LSR command will essentially divide the number it’s working on in memory or the accumulator by two.

This entry was posted in Programming and tagged , , , , , , , . Bookmark the permalink.