đŸ Archived View for ageinghacker.net âș test-conversion.gmi captured on 2023-04-26 at 12:49:41. Gemini links have been rewritten to link to archived content
âŹ ïž Previous capture (2022-03-01)
-=-=-=-=-=-=-
Inspired by a happy âdiscoveryâ I made today, Iâve written this instead of finishing the post about identity.
This story began on a summer evening of the late Eighties when I was 10, maybe 11. I was at some small country fair near home with my brother, five years younger than me â quite a big difference back then.
My brother found an audio cassette discarded on the ground, and wanted to take it home; it looked dirty and I remember that I didnât want to pick it up at first, but I guess I wasnât too hard to convince after all. The cassette was probably home-recorded, or in any case it had a blank label. Ok, letâs take it. Back home we tried to listen to it on our little boombox, and we immediately recognized the sound: itâs a computer program! Indeed it was. And it was even for our computer, the Commodore 64 ([6]http://en.wikipedia.org/wiki/Commodore 64) â a machine already a little past its prime at the time, but hey, that was all we had.
We tried it: as a thousand other times I hit SHIFT + RUN STOP, then the usual
PRESS PLAY ON TAPE
appeared on the screen. PLAY. We thought it was a game. And we used to love games back then, but that thing would prove to be so much better.
FOUND "HALLEY"
LOADING...
Then you had to wait the usual two to three minutes for loading. I think this one took a little less than average.
The basic idea of Halley was simple: you told the program a date, time and location on Earth, and it drew the sky bodies as they would look from that place at that time.
It had some more functionalities for highlighting constellations, and of course for showing the position of Halleyâs comet, due to pass in 1986 and hence at the center of a minor popular craze; we got the program later, when it was already a few years old.
Several features. But I think that even as a child I immediately understood that joining the Big Dipper stars with line segments was not the interesting part: that thing could compute the apparent position of the stars, from numbers. Of course I had no practical application for this, but who cared? I didnât know the phrase yet, but I got the idea perfectly: there was a predictive model at work.
The incredible beauty of science. I was in awe and wonder.
The program quickly led me to a second important discovery, this time about programming. This may be somewhat header to âgetâ now, for people not accustomed to the Commodore 64 or to the education environment at the time. I lived in an isolated setting where nobody could teach me about computers; at that time (and for some more years later) everything I knew about programming came from two small books: the Commodore manual, and another one explicitly dedicated to programming that machine â neither was very good, I can say now.
The peculiar limitations of the machine interface didnât help either. âRealâ programs at the time were written in machine language â and Iâm saying machine language, not assembly: see below. Now, knowing myself better, I think I would have been able to learn at least some machine language at the time; but I didnât have any documentation. Assembly and machine language were covered in more advanced books, clearly less popular and therefore less easily available. BBSs were out of reach for me.
For the unlucky children who lived in small country villages as I did, there was just BASIC. Most of the home computers of the time came with a BASIC interpreter in ROM, which was available at boot time and also served as a crude interface to the âoperating systemâ, again in ROM: excruciatingly slow compared to native code, BASIC was touted as âfriendlyâ. And indeed it was easier to use than machine language, but I wouldnât exactly call Commodore 64âs BASIC a high-level language.
PEEK and POKE
For the time when it got out the machine even had some relatively good capabilities in terms of graphics, sound, and connectivity: the problem was that none of these functionalities was available from BASIC: in order to use sprites, for example, which were supported at the hardware level, you had to manually âPEEK and POKEâ (BASIC for what we would call âload and storeâ now) bytes into memory-mapped registers, explicitly mentioning their numeric addresses. Even many mundane operations, such as changing the background color in text mode, could only be performed that way.
I still remember some addresses by heart. For example, this command changed the text-mode background to white:
POKE 53281, 1
The recommended way of resetting the machine via software was by jumping to a machine language routine in ROM, which happened to begin at the address 64738; from BASIC:
SYS 64738
Switching the screen to graphic mode and drawing wasnât trivial at all; moreover there was no linear framebuffer letting you address each pixel individually: instead you could address each row in each 8x8 square making up the screen (40x25 squares), and play with bitwise operators to update the desired pixels in the desired row.
The arrangement of squares in memory wasnât exactly convenient for graphics, either. The first 8x8 square in memory was the topmost leftmost on screen, and contained the eight-pixel rows indexed from 0 to 7; the second square, with rows 8 to 15 was the second from the left in the top row of squares; the third square in the first row of squares had rows 16..23, and so on up to the fortieth square; then started the second row of squares, and the forty-first 8x8 square in memory was the leftmost one of the second row from the top.
In practice you computed the row offset in memory, then you PEEKed the byte at the base address summed to the offset, twiddled some bits in it, and finally POKEd back an updated value.
In two-color mode each square row byte encoded 8 pixels; but in multi-color mode, a square row byte only encoded 4 âwide pixelsâ (two bits each, four colors), with halved horizontal resolution â Those were the official machine specifications; but as I learned many years later good hackers could push those limits by carefully playing with the CRT scan line timing, changing supposedly global settings at just the right moment to have them apply to a selected area of the screen only.
So, if a BASIC program was easier to read than an assembly listing in terms of arithmetics and control flow, many apparently âfundamentalâ operations still had to be implemented at a very low level.
If you didnât know anything else then for you that was just the way things were, and you learned all magic numbers by heart without asking yourself many questions about alternatives. When it was the only way you knew it didnât even feel inconvenient.
Procedures
One day I hit RUN STOP by mistake when running Halley. I saw BREAK IN and some line number, followed by the usual READY prompt and the blinking cursor. Of course I knew what it meant: apparently, Halley was written in BASIC.
LIST seemed to confirm the hypothesis: indeed there was a big BASIC program, which in theory I could have studied and tried to understand.
But very soon I noticed some strange commands in Halleyâs source, whose names all began by the left arrow character âââ, for some reason: my English was still weak at the time but I could understand what ââLINEâ and ââCIRCLEâ meant: apparently they were graphic commands. I tried to run them interactively, and indeed they seemed to work. Yet I was absolutely sure they were not part of the predefined BASIC. I already knew how to draw a line and it was a much bigger pain than that, with all the square row offset computation and bit twiddling.
The new commands stopped working after a machine reset. This fact confirmed that they were part of Halley, which extended the BASIC language, providing new names for higher-level operations accepting parameters. This much I understood by myself, and for me it was quite a discovery. It was obviously the right way of proceeding: naming operations to be used more than once by a caller who may also supply parameters. I had discovered procedural abstraction.
As I only had two programming books I had read them many times, and I knew for sure that Commodoreâs BASIC didnât provide any way of defining named procedures with parameters; so I was sure that such definitions had to be performed in that fabled âmachine languageâ[7]^1. That day I still couldnât write my own procedures, but I had been enlightened.
Iâm a sentimental type; Iâve always been. And of course because of its meaning for me Iâd always have loved to be able to easily run Halley in the following years, after having finally moved to different computers.
Our Commodore 64 is still there in its box, and the tapes should also work; it all worked fine the last time I tried, maybe less than ten years ago. But the setup is clumsy, there is stuff to move around, dust and disagreeable people; and most importantly Iâve been living in France for some time already, physically far from my old computer.
Running Halley on an emulator is the obvious solution; VICE ([8]http://www.viceteam.org/) is free software and works wonderfully; but since itâs not completely trivial to make a usable file from a cassette, in practice I also needed to find a copy of Halley somewhere on the Internet; yet apparently that particular software wasnât that popular, and Iâve always been unable to find even a mention of it â until this afternoon.
When I was looking again at the web search results after lunch, a little bored, I started mindlessly skimming the usual false positives: no, itâs not âThe Galaxy Projectâ nor the other two or three more famous titles always popping up...; then it came.
Identified the author
I donât remember exactly the search query bringing me to the interview with the author Nemo Galletti â but after seeing that name my dĂ©jĂ vu feeling didnât last long. I had finally found it: [9]http://ready64.it/articoli/leggi/idart/8/intervista-a-nemo-galletti. It doesnât look that hard to locate after the fact, and the interview dates back to 2008. Was the last time I looked for Halley really before 2008? Iâm still not sure.
From the interview I discovered something interesting: the new primitives to which I owed my enlightening experience were âthe famous Toma routinesâ: Galletti gladly acknowledges that he reused some graphical routines written by a Danilo Toma. Galletti seems very unassuming: he disclaims any particular competence in the field of astronomy, and dismisses the formulas he used as âeasily available in specialized magazinesâ. This surprises me.
Identified the graphic routinesâ author
Tomaâs routines were published on a paper magazine in at least two versions during the Eighties. His routines, written and assembled manually into machine code (!), were extracted back from memory for publication as a long listing of DATA commands and a âcommented disassemblyâ (!!). At the time there were good technical reasons for such a crude solution: the machine was too small even to host a reasonable assembler, without hardware extensions.
Something I was shocked to learn now after many years was that Tomaâs routines actually supported 3D coordinates, and rendered in perspective; and of course Galletti made use of the third coordinate.
Looking at the code when I was young and without any documentation whatsoever for Tomaâs routines I couldnât understand the role of all parameters; anyway now I feel more than a little disappointed in myself for not having suspected at the time something that important. Itâs clear now that back then I played a bit with circles, lines and points, but I was fascinated by the concept I had understood for the first time, rather than by that particular set of new primitives.
Some years later at 15 or 16 I also wrote my own procedures for rendering wireframe objects in 3D perspective like, Iâve just learned now, Toma did; my project had some interesting aspects and I should write about it sometime, but I think the thing in the end was slowish. And I used Pascal on a much stronger computer instead of machine language on a Commodore 64. No match.
You can find magazine scans with a long article by Toma including the listings for his routines (starting at page 35), and the software on a disk image: [10]http://ready64.it/download/scheda_download.php?id_download=46. By the way, that is what was considered a âpopularâ publication at the time, not necessarily for the mathematically inclined; I wouldnât call it too shallow or dumbed down.
Toma also seemed nice and unassuming; but except for what he wrote in the piece linked above and the occasional mention of âTomaâs routinesâ, I canât seem to find anything about him on the Net; there is some information about a table tennis player with the same name and surname, but the athlete looks way too young to be the same person as the hacker.
Given the authorâs name it became easy to find a downloadable[11]^2 copy of Halley: [12]http://ready64.it/download/scheda_download.php?id_download=255.
Now Iâm finally running the program again, on the VICE emulator. Iâve hesitated a little before looking again at the BASIC source, lest my expertise of today spoiled my childhood memories.
Then I made my mind, hit what would have been RUN STOP and typed[13]^3
LIST
Today Iâm not terribly impressed with the source code. But that doesnât necessarily mean anything.
A reminder for old-timers or an introduction for young spoiled kids: Commodore âBASIC V2â
The lack of primitive operations at a level higher than PEEK and POKE was not the only problem in Commodoreâs BASIC.
That BASIC dialect didnât leave a lot of freedom to the programmer: all variables were global, with names limited to a length of two characters. Since spaces in the source code consumed precious memory it was customary at the time to just leave them out, and for example write
120 FORI=1TO10STEP2:PRINTI:NEXTI
instead of
120 FOR I = 1 TO 10 STEP 2: PRINT I: NEXT I
As was the norm for home computer BASICs at the time, line numbers were mandatory and could not be replaced with symbolic labels.
The only conditional was a simple IF with fall-though control (no âelseâ branch), and a FOR..TO..STEP..NEXT loop (STEP was optional). As far as âstructured programmingâ goes, that was it: if you wanted any other non-procedural control feature, you had to simulate it with GOTO.
There was support for a kind of crude subroutines, of course identified by line numbers only, which you could enter with GOSUB and exit with RETURN; an implicit call stack for BASIC routines was maintained for return addresses, but there was no mechanism at all to pass parameters or return results. And of course no procedure-local variables.
It was another world. It wouldnât be fair to look at the programs of that time with our eyes of today.
And in Halley the âdifficultâ part seems perfectly reasonable, with data about each constellation neatly grouped in their own DATA section; there are comments. Control flow seems hard to follow to my now unaccustomed eyes, but how could it be otherwise? You worked with what you had.
No, I really have nothing negative to say about Halleyâs source.
Halleyâs comet has come and gone, the minor fad of that time also long forgotten. As fads go that was a good one: it introduced people to astronomy, and Iâm sure the interest has stuck at least with somebody.
Even if sometimes I still toy with the idea of buying a cheap telescope and learning something, I doubt astronomy will ever become a real passion for me. But already back then I understood very clearly that astronomy was not the point: it was just one example of the ordered beauty of rationality, so plain and simple that even the child I was could see it.
I didnât know anything about Galileo at the time, but now Iâm sure astronomy wasnât the point for him, either.
First epilogue
Some months ago, a supermarket in a lower-class suburb of Paris. The guy waiting in the counter line in front of me is a little unkempt, with a beard and a tired expression; around my age, he may resemble me somewhat.
He has only two items to check: a big pack of baby food jars, and a telescope.
(Do they sell telescopes here?)
Heâs smiling.
Second epilogue
Here I am, finally again in front of Halley, now running on a virtual Commodore 64 as emulated by VICE, easily many times faster than the real thing even on my YeeLoong. And this is how Halley renders the sky of tonight, 18th September 2011 at 23:59, Paris latitude:
[14]the-sky-from-paris--2011-09-18--23.59--halley
â Luca Saiu, 2011-09-19 05:06 (last update: 2014-11-24 23:55)
[15][hacking.png]-[16][hacking.png] Tags:
[17]commodore-64, [18]english, [15]hacking, [19]my-masters, [20]myself, [21]nostalgia, [22]science
[23]Next post [24]Previous post
___________________________________________________________________________
[25]Go to the main index...
[1]Atom feed-[26][feed-icon.png] All post feeds: [1]Atom 1.0, [2]RSS 2.0.
[27][my photo]
Luca Saiu
The opinions I express here are my own and do not necessarily reflect the beliefs or policies of my employer, or for that matter of anyone else. In case you felt that the public statement of my thoughts threatened your warm sense of security and your emotional stability, please feel free to leave at any time.
The system does not support user comments and probably never will. Anyway you can [28]contact me by e-mail if you want to discuss some topic with me. I might update my posts if you provide interesting insights.
___________________________________________________________________________
Copyright © 2009, 2011-2014, 2017, 2018, 2021, 2022 Luca Saiu
Verbatim copying and redistribution of this entire page are permitted in any medium without royalties, provided this notice is preserved.
This page was generated by [29]trivialblog. trivialblog is [30]free software, available under the [31]GNU GPL.
Tag icon copyright information is available [32]in this file.
___________________________________________________________________________
Footnotes
It was easy to write a machine language routine into memory byte by byte, using only BASIC â even relatively convenient with READ and DATA; the difficult part to figure out was how to compose the machine language part. Alas, I never learned machine language or assembly for the Commodore 64. One of these days I might decide to do it, for kicks.
The publisher explicitly endorses downloading its old Commodore 64 software from [35]http://ready64.it:
â
Sul sito ready64.org legalmente autorizzato da Systems, sono disponibili liberamente le scansioni dei numeri della rivista Commodore Computer Club, Computer, e diversi software per Commodore 64 editi da Systems, quali la collana Commodore Club (poi Software Club), Commodore 64 Club, ma anche software quali La Voce (I, II, III), Raffaello, lâemulatore di MS-DOS, la Dichiarazione dei Redditi, etc. Sul sito www.museo-computer.it legalmente autorizzato da Systems, sono disponibili liberamente le scansioni dei numeri della rivista Sinclair Computer e Commodore Computer Club edite da Systems.
â
â Somebody at [36]http://www.systems.it/chisiamo.html
Halleyâs complete BASIC source code is of course available, just one RUN STOP hit away. Tomaâs routines have no actual source code: the closest existing thing to their âsource codeâ was effectively machine language, not even assembly â and that code is available.
Anyway, even with its full source code available Halley is still not free software, as youâre technically not allowed to modify it and redistribute it (thatâs the default, unless they tell us otherwise: unfortunately the wording âfreely availableâ is not enough in this case). Yet I consider Halley to be a case of nostalgia and retrocomputing; itâs not current productive software use. For this reason only, I find acceptable to publish this article about the software, and link to it.
Actually itâs not that simple. I had forgotten how inconvenient it was to edit a large program on the Commodore 64; the LIST command displayed the program on the screen, scrolling vertically as soon as the last line was reached. You could slow down the process by keeping CONTROL pressed, but not pause or scroll up: so the most comfortable way of reading or editing a program section was listing just a line interval, if you knew more or less what you were looking for: for example you typed
LIST 100-200
to see all the lines with numbers in [100, 200]. Yes, with a dash.
___________________________________________________________________________
[1] file:///blog/feeds/atom.xml
[2] file:///blog/feeds/rss.xml
[3] file:///tmp/tmp.gUbGhiyvr3/patched.html#Top
[4] file:///tmp/tmp.gUbGhiyvr3/dir.html#Top
64 [6] http://en.wikipedia.org/wiki/Commodore 64
[7] file:///tmp/tmp.gUbGhiyvr3/patched.html#FOOT1
[9] http://ready64.it/articoli/leggi/idart/8/intervista-a-nemo-galletti
[10] http://ready64.it/download/scheda_download.php?id_download=46
[11] file:///tmp/tmp.gUbGhiyvr3/patched.html#FOOT2
[12] http://ready64.it/download/scheda_download.php?id_download=255
[13] file:///tmp/tmp.gUbGhiyvr3/patched.html#FOOT3
[14] file:///tmp/tmp.gUbGhiyvr3/the-sky-from-paris--2011-09-18--23.59--halley.png
[15] file:///blog/tags/hacking
[16] file:///blog/icons/hacking.png
[17] file:///blog/tags/commodore-64
[18] file:///blog/tags/english
[19] file:///blog/tags/my-masters
[21] file:///blog/tags/nostalgia
[22] file:///blog/tags/science
[26] file:///blog/icons/feed-icon.png
[27] file:///static/my-photo.jpg
[29] http://ageinghacker.net/blog/posts/2
[30] http://www.gnu.org/philosophy/free-sw.html
[31] http://www.gnu.org/licenses/gpl.html
[32] file:///blog/icons/licenses
[33] file:///tmp/tmp.gUbGhiyvr3/patched.html#DOCF1
[34] file:///tmp/tmp.gUbGhiyvr3/patched.html#DOCF2