Jump to content


Check out our Community Blogs





- - - - -

My new hacker toy

Posted by DarkLordCthulhu, 04 March 2015 · 7445 views

commodore 64 c64 retrocomputing vintage computing basic
I have an interest in old computer stuff, not just obsolete computers, but also ancient programming languages, deprecated networking technologies, antiquated operating systems, terminals and other peripherals, and computer manuals. My interest in old computers, as well as in computing in general, goes way back to my childhood in the 90s, when I was watching my older brother on his Apple ][c. I've been interested in retrocomputing and vintage computing for a long time, though my experience has been pretty much limited playing MS-DOS games in DOSBox and getting a few broken Apple computers from a freecycle. I've only used some emulators and some clones and newer versions of old Unix programs, and I've always dreamed of being able to experience the real thing. I mean dream in both senses of the word, as in I've actually had dreams about using old computers. It's something that is not just a conscious goal, but a subconscious yearning as well.

Needless to say, I was rather excited when I found that Ebay is full of auctions for old computer equipment and software. Commodore 64s, Apple ][c's, TRS-80s, even a couple of VAX minicomputers. You name it and you can probably find it on Ebay. So I joined Ebay and spent some time learning the ropes, trying to figure out how to fully take advantage of the system. I learned about automatic bidding as well as many other features of Ebay. I started bidding on a Commodore 64 that was for sale. The bidding got really fierce towards the end, but I won through a combination of clever maneuvers and blind luck. I was really excited by this. I had actually won something, and now I would finally be able to touch a working vintage computer. I didn't stick around to pay for it, since I was outside at night in the bitter cold (I don't have Internet access at home and the auction ended at 8:50 PM; I had to sit outside the library). I was freezing to death, so I just went home for the night and then took a long hot shower because I was so cold. I promptly went out the next morning and paid for the C64, and bought a monitor (not an auction) to go along with it.

Both the C64 and the monitor shipped sometime the next week. I had to go to the post office to get them. They were in two rather large boxes, very well packaged. I kept the boxes and all the packaging material so that I'll be able to transport them safely when I move out of the group home. The Commodore 64 was in its original box, along with a Commodore 64C power supply, video and audio cables for S-video display, the user manual, a joystick, and a cartridge for Jumpman Junior. The monitor was a Commodore 1702 color CRT. When I first hooked them up, I plugged the A/V cables into the RCA ports on the front, which were for composite video. This resulted in the screen being grey, with no color. Realizing that the cables were for S-video rather than composite video, I plugged them into the S-video ports in the back and moved the switch on the back panel indicating what set of ports to use. I turned the monitor and the C64 on and was welcomed by the Commodore startup message:
    **** COMMODORE 64 BASIC V2 ****
 64K RAM SYSTEM  38911 BASIC BYTES FREE
READY.
That was so cool. All caps, monospace, light blue text on a dark blue background, with the cursor blinking right below where it said "READY". I spent some time typing on the keyboard, getting used to the layout, and I also did a little bit of rudimentary BASIC programming. At first I didn't register any of it. This was too much of a shock for me. It took a while for me to register the fact that I had actually used and programmed a real vintage computer. Something I had dreamed of and fantasized about for so long, to the point where there was an almost mystical quality to it. This was no mere emulator. This was the real thing.

At first I wasn't that excited about it. But later, as I began to register what was truly going on, I felt thrilled. I kept turning the C64 on every day, just playing around with it. I set out to learn as much as I could about this computer. I learned more of the Commodore BASIC language, and I found some resources on archive.org. Here are some of the BASIC programs I've written:

This is a casino program. Before playing you bet a certain amount. The program displays three random suits, and if they are all the same, you win that amount. If they are not all the same you lose that amount. This is not actually the original code. The "SPADE", "HEART", "CLUB", and "DIAMOND" strings are actually replacement for the PETSCII characters for those suits. The program is rather frustrating, because you lose your money really quickly. I'm thinking of modifying it so that what you win is more than what you lose (say 5 times what you bet).
10 REM COMMODORE CASINO
20 REM (C) ZENHACK SOFTWARE, 1983
30 PRINT "WELCOME TO COMMODORE CASINO."
40 PRINT "HOW MUCH MONEY DO YOU WANT TO BRING?"
50 INPUT X
60 LET X% = INT(100 * X)
70 REM THIS EFFECTIVELY ROUNDS TO THE NEAREST CENT.
80 REM BEGIN BETTING LOOP:
90 PRINT "PLACE YOUR BET:"
100 INPUT B
110 LET B% = INT(100 * B)
120 IF B% <= X% THEN 150
130 IF B% > X% THEN PRINT "INVALID AMOUNT. YOU ONLY HAVE $"; X% / 100; "."
140 GOTO 90
150 LET A$(0) = "SPADE": A$(1) = "HEART": A$(2) = "DIAMOND": A$(3) = "CLUB"
160 LET Q$ = A$(INT(4 * RND(1)))
170 LET R$ = A$(INT(4 * RND(1)))
180 LET S$ = A$(INT(4 * RND(1)))
190 PRINT Q$; R$; S$
200 IF Q$ = R$ AND R$ = S$ THEN 210
210 IF Q$ <> R$ OR R$ <> S$ THEN 250
210 REM PLAYER WINS:
220 PRINT "YOU WIN!"
230 LET X% = X% + B%
240 GOTO
250 REM PLAYER LOSES:
260 PRINT "YOU LOSE!"
270 LET X% = X% - B%
280 REM END DECISION BRANCH
290 PRINT "YOU NOW HAVE $"; X% / 100; "."
300 PRINT "PLAY AGAIN? (Y/N)"
310 GET P$
320 IF P$ = "" THEN 310
330 IF P$ = "Y" THEN 90
340 END
This one is a display hack. It puts a wall of squares on the screen and then puts holes in the wall by randomly poking spaces into the screen memory. Soon it starts to look like a sponge, and then eventually it looks like a maze. You can stop it at any time by pressing the RUN/STOP key. By this time, I had learned about the CHR$() function, so the program code didn't include any graphical characters, and what you see is exactly what was on the C64.
10 REM SQUARE DECAY
20 PRINT CHR$(147)
30 REM DRAW SQUARES
40 FOR X = 1 TO 1000
50 PRINT CHR$(166);
60 NEXT X
70 REM START DECAY
80 LET X% = INT(40 * RND(1))
90 LET Y% = INT(25 * RND(1))
100 LET P = 1024 + X% + 40 * Y%
110 POKE P,32 : REM SPACE
120 GOTO 70
130 END
This program displays the startup screen:
10 REM COMMODORE 64 STARTUP SCREEN
20 LET L = PEEK(43) + PEEK(44) * 256; REM LOW END OF BASIC MEMORY
30 LET H = PEEK(55) + PEEK(56) * 256; REM HIGH END OF BASIC MEMORY
40 REM THE C64 IS LITTLE-ENDIAN.
50 LET R = L - H; REM RANGE
60 PRINT "{CLR/HOME}"
70 PRINT "    **** COMMODORE 64 BASIC V2 ****"
80 PRINT
90 PRINT " 64K RAM SYSTEM "; R; "BASIC BYTES FREE"
100 END
This program causes the C64 to look and act like a DEC VT220 terminal connected to a VAX minicomputer running VMS. Keep in mind I've never used said terminal, computer, or operating system, so this is a very primitive imitation:
10 REM EMULATE DEC VT220 TERMINAL STARTUP
20 POKE 53280,0 : REM BLACK BORDER
30 POKE 53281,0 : REM BLACK BACKGROUND
40 PRINT CHR$(158) : REM YELLOW TEXT
50 PRINT CHR$(247) : REM CLEAR/HOME
60 PRINT "WELCOME TO VAX/VMS"
70 PRINT "INTERFACE: DEC VT220 TERMINAL"
80 PRINT
90 PRINT "LOGIN:";
100 REM GET LOGIN LOOP
110 LET I% = 0 : REM VARIABLE FOR LOOPING THROUGH ARRAY
120 GET K$
130 IF K$ = "" THEN 120
140 IF ASC(K$) = 13 THEN 160 : REM ENTER KEY
150 LET A$(I%) = K$
160 PRINT "*";
170 LET I% = I% + 1
180 GOTO 120
190 PRINT
200 IF A$(0) = "V" AND A$(1) = "T" THEN 230
210 PRINT "INCORRECT LOGIN"
220 GOTO 100
230 PRINT "YOU ARE LOGGED INTO VAX/VMS."
240 PRINT "HAPPY COMMAND LINE HACKING!"
250 END
My advocate at the group home asked me how I can use this Commodore 64 to achieve my goals. I told her that I don't see how it will help me in that area. I said it's not really something I can learn useful skills from; it's more just a hacker's toy, and it's something that will make me happy, so I don't regret spending my savings on it. Surprisingly, however, I've learned a great deal from messing around with this computer. It has opened my eyes to many new things. I've learned about sprite graphics, and about bitmaps. I've learned about character ROM, and how it can be used to generate characters on the screen in the absence of a graphical operating system (e.g. for the BIOS screen or a non-graphical OS). I've gained a better understanding of the limitations of operating systems, and realized that displaying text is not an inherent limitation; it's just easier to write a set of predefined patterns to predefined locations in the framebuffer than it is to create actual graphics; that's why you can play graphical games and run graphical applications on command-line OS's like MS-DOS and Commodore DOS. I've gained a more intimate understanding of how functions and subroutines are implemented, because BASIC's subroutine scheme is much like that used by assembly languages and machine languages. I have also been prompted to start studying reverse-engineering.

Though I don't have any software for it yet, I've learned to do a lot of nifty things on the Commodore. I found this website that shows the layout of the C64's memory, and from it I learned how to change the background and border color of the display. I've also learned how to more effectively edit programs. At some point I want to get a floppy drive for the C64, as well as some software on floppies. I tried inserting the cartridge I got, but couldn't seem to get it in.

So yeah. Old computers are awesome. This is the beginning of a strange and wonderful journey for me. I hope to amass a whole collection or vintage computers and software in the future.

  • 1



Yeah, my first computer was a Tandy 8088 with Tandy graphics (between CGA and EGA), running MS-DOS 3.3. I still have my 486 DX2-66, with a monstrous 333MB hard drive (monstrous as in physical size), as well as a x6 speed CD-ROM drive.

 

There is SO much people learning programming today often don't understand about computers, because so much is abstracted away from their awareness. A lot of the games I played on computers as a kid used characters on the screen to "generate" the "graphics". It didn't matter, they were fun. Then there was the horror of upgrading from my 286 to my 486, and discovering that many of my games became completely unplayable. They depending on a fixed CPU speed to determine their behavior. When CPUs started getting faster, the games became faster as well. They would literally turn into insta-death games.

 

Great, now I have a goofy smile on my face from reminiscing.

    • 1

Yeah, I experienced that when playing games like Kroz and Stargoose in DOSBox.  They go so fast, by the time I process where my character is on the screen I'm dead.  My first thought was "Gee, computer games used to be really hard."  Eventually I realized that these are games written for 16-bit 8086 CPUs, being run on a 64-bit 2.5 GHz Core i5 processor.  Obviously they're going to run fast.  Emulators rarely give you the optimal game playing experience, unless you're playing a turn-for-turn game like Rogue.

 

I've noticed many of the people who are into vintage computers are people who grew up programming them and playing games on them, and they're mostly doing it out of some sense of nostalgia.  That's not my case at all.  My first computer was a Macbook laptop running OS X Tiger that I bought in 2007.  I missed out on the glory days of computing by a long shot.  Missed out on time-sharing, missed out on BBSs, missed out on homebrew computing, missed out on Spacewar, Lunar Lander, etc.  This is my way of compensating for that.

    • 1