Scripting In Commodore BASIC For Windows & Linux
SomeoneGotMyNick writes "Someone more nostalgic than I am, and with a lot of time on their hands, had created a scripting language based on Commodore BASIC for Mac OS X. They recently finished a version that works on Windows and Linux. You can pass the text of a BASIC program as a parameter to the program. I found it odd that it took 1.8 MB of source code to compile to an interpreter that used to fit in 8K of ROM space. If this ever becomes popular, perhaps we'll see Obfuscated CBM BASIC contests." In a simliar vein, in the comments someone points out what is essentially an open source AmigaOS Classic.
I remember coding four pages from 99er, to make a little box go from one side of the screen to the other and change colors, while playing a midi tune. More serious business was the epic dungeon text adventures!
Now of course this would be nice to have on Linux.
The dangers of knowledge trigger emotional distress in human beings.
When will somebody port Radar Rat Race to Windows or Linux?
One of our competitors trademarked the term "hypothesis". From now on, we will call them "boneheaded ideas".
I assume most of the code went into translation stuff the C64 did in hardware into something that makes sense to a modern OS. Not that an emulator probably would have taken less space...
10 FORA=1TO300
20 PRINT"YAY!"
30 NEXT
RUN
It turns out that this is just a disassembly of the interpreter translated into C. The file is so large because it has lots of really long computer-generated symbols.
It's a shame that this is not a reimplementation of BASIC in C.
dom
I guess basic is basic unless it's on a machine you're familiar with... I find Freebasic ( www.freebasic.net ) useful, probably because I came from the same era and did all my programming back then too, although I used a Spectrum and I'd never want to have to use that sort of keyboard again.
Freebasic is a fairly recent compiler that makes pretty neat code and has all the common C calls available to it too as well as being able to process native Qbasic programs (if you migrated from the C64 type basic to the PC later) without many of the limitations and nearly complete compatability.
It also allows cross-scripting between Mac, PC and Linux with the same program which I find useful too.
www.freebasic.net
GrpA.
ps. Basic may not be dead, but you still get funny looks when people see you programming in it. I think some consider it even more ancient and antiquated than cobol (which it's not).
Enjoy science fiction? "Turing Evolved" - AI, Mecha, Androids and rail-gun battles. What more could you want?
I have to say, Commodore BASIC was one of the worst BASIC interpreters available in the "home computer" market. It's pretty clear the C64 was really a game console with a keyboard, so it could be (very successfully, and legitimately so) sold as a computer. If you actually wanted the C64 to do anything interesting, you had the choice of assembly, or BASIC that looked like assembly but ran like crap. As far as I can tell, the C64 BASIC didn't use any of the techniques used by other BASICs from the same era to not run like a total dog.
Don't get me wrong, the C64 was a great machine. It just wasn't a great machine for BASIC programming.
Why? You can already download a C64 emulator for your chosen platform and use REAL Commodore BASIC.
If you have any of those old CBM-BASIC listings from 80's computing magazines, it's full of POKE x,y statements (and sometimes the program is just a hex loader with bunch of READ...DATAs). So I'm really not so sure of the value of this experiment.
(One of the longest "commercial" CBM-BASIC programs I remember - that actually used it for lots of things - was Sid Meier's Pirates!. (Haven't tested the newest Remake - I did like Pirates Gold!, the first remake, a lot)
I found it odd that it took 1.8 MB of source code to compile to an interpreter that used to fit in 8K of ROM space
;-)
Don't forget that the commodore cpu was 8 bit and current cpu's are 32 or 64 bit: Most of the commands were 8 bit and their equivalents are bigger nowadays. That explains the 8KB of ROM
And they did not need fancy memory protection stuff, they hacked straight into the hardware. No dll's, so's to use or API's to follow. Even if it is a lot assembly code, there are a lot more bytes in assembly source than in binary executables.
Context, people, context!
Dependency hell? =>
Is that, some old assembly hackers ought to be able to whip up a fairly tiny basic interpreter. It should be fun in a way and still easier than in the old days of 6502. You have more registers, some basic string instructions, and outstanding support for floating point. I doubt it could be quite as small though, as, the big thing that would bloat it up would be that instructions themselves in 32 bit. For an easier and almost weekend job of it, you could do it in 64 bit assembly for Linux only. That spares you the need to do COM type of stuff and other weirdness that permeates the Windows API. In Linux, you are just doing normal C calls throughout to the OS and so you could bring up basic file services fairly quickly. A clever coder could probably make the BASIC actually be some sort of assembler with it... there's nothing genuinely fancy about it and the memory management of those guys was fairly primitive.
This is my sig.
But the real question is....Why would anybody do this?? Port Commodore64 BASIC to a PC?
I used to have a Commodore64 and learned 6502 Assembler on it. When I got a PC (a 286) I felt nostalgic for the C64 and bought a cheap one. I used it about ten minutes and realized what a mistake it was. Fortunately I was able to sell it right away.
Never look back. There is is nothing that was written for Commodore 64 that isn't 1000 times better on modern PCs. Nothing. Don't give me any BS about the wonderful SID chip and its KOOL mickey-mouse MOD files. They suck, really. Don't tell me about that fantastic game that you used to play on the C64 and have never been able to recreate the excitement on a PC. It's because you were a kid discovering video-games, not the Commode64.
Are you going to tell me that you miss spending four minutes to load a 25K file from the excretable 1541 disk drive? Or spending 40 minutes to download a 25K file on a 300 baud modem from a long-distance BBS when you're paying the phone bill? Or the stupid PEEKs and POKEs. Do you miss typing in hundreds of numbers from Compute's Gazette because the program is written in super-fast 6502 1.2MHz machine code?
The only good thing about the C64 was the keyboard. And once you start talking to your 3GigaHertz PC and having your words appear on the screen as you speak, you don't miss the keyboard. Regardless of how good it is.
Commodore 64's rule!! But, really they suck. Never look back on trash.
obviously.
Hail Eris, full of mischief...
E pluribus sanguinem
I have an old book on how to build your own telescope from the 1980's that included how to hook up a C64 and use a joystick to control the telescope's movements all written in C64 Basic. I remember porting it to QBasic circa 1994/5 and using it for a telescope I had to account for planetary motion for photography. (Back before every telescope came with such features).
That would almost be fun...wow I really am a geek....*shudders* I'm going back to my cave now.
"The problem with socialism is eventually you run out of other people's money" - Thatcher.
I found it odd that it took 1.8 MB of source code to compile to an interpreter that used to fit in 8K of ROM space.
It's not all that odd if the developer is a moron (which apparently this one is).
GOTO isn't evil, but it is considered harmful
GORILLAS.BAS: Microsoft's only open source game.
Lest we forget Allegiance...
If I mod you up, it doesn't necessarily mean I agree with what you've said, sorry.
10 ? Hello Windows OSX World!
20 GOTO 10
Now my 25 year old C64 BASIC programs can run under Linux, OSX, or Windows.
If only my 1541 floppies didn't suffer from bit rot and I loaned most of my collection to friends who didn't return them and somehow lost it after they moved.
Remember, Slashdot does not have a -1 disagree moderation, and no, troll, flamebait, and overrated are not substitutes.
Just as we do our best to get .vbs files locked down someone comes up with a new scripting language just waiting for exploitation.
"It's the height of ridiculousness to say for those 9 lines you get hundreds of millions."
If you know the dir of the nerdcore rhyme, then holler!
The main advantage to BASIC is that it's trivial to get simple graphics going so you can learn how to make a wide variety of games without having to get overloaded with information about APIs and whatnot. Unfortunatly most games don't have terrible graphics so beginning programmers tend not to be satisified with large solid colored blocks.
It may be worthwhile to come up with a compiler that expands the BASIC commands to include functions which load various graphics formats into sprites and allow you to display them easily. I remember having to use primitive shapes to draw graphics and then GETing the area on the screen and PUTing it. Eventually I developed my own graphics format that used text files that could be edited by hand.
Work Safe Porn
Can I change my Windows background color? Let's try...
.frj91`2
10 POKE 53280,0
20 POKE 53281,0
RUN
ERROR OCCURRED.
PLEASE REPORT THIS PROBLEM TO QUANTUM LINK'S CUSTOMER SERVICE.
%)9hlkhd g y4i8
aseg.
dg4yu4i
d;gk
d
gn 73uo24hj rh
!$
y63
+++ATH0
NO CONNECTION
The only thing really great about the C64 is that it forces you to interact with computers on a very low level. Look at kids growing up with computers today: They have hard disk and networks, and never see a command line shell, let alone a programming language (and probably wonder why the "Save" icon in MS Word is a floppy disk - and why you would "save" anyway).
A computer enthusiast today plays around with photo and music collections, a computer enthusiast back in the day found it exciting to discover new PEEKs and POKEs and actually learnt something about technology.
The retro scene is very important. It reminds us what computers are made from, and that there is more to computing than watching Youtube.
Michael
Of course this is a useless project! Almost as useless as model airplanes and magic tricks and football and all of the other wonderfully useless things people do to amuse themselves. Don't care for it? Fine, but no need to insult it.
BASIC 2.0 seems pretty worthless without support for all the PEEKs, POKEs, and SYSs, though. Is there a port of BASIC 7.0? Or at least BASIC 3.5?
5 CLS
10 INPUT "WHAT IS YOUR NAME?"; A$
15 IF A$ = "JOE" THEN GOTO 50
20 PRINT "YOU ARE NOT AS COOL AS JOE, SORRY!"
30 FOR I = 1 TO 10000
35 NEXT I
40 GOTO 5
50 FOR I = 1 TO 20
55 PRINT "JOE IS COOL!"
60 NEXT I
70 FOR I = 1 TO 10000
80 NEXT I
>RUN
The rarer, second definition of "Slashdotted".
Version 2 might have to. Poke & his little brother Peek were the Bastard Twins of Commodore Basic. The Commodore 128 took some steps into making a usable Basic, but the '64 was completely unusable without them.
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
Sure! It's the "English" of 80's Comps. All the way from Oxford King's English to the highly creative mashups like the imported workers in my area speak.
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
Being less talented than your average /.er, Commodore *64* basic reduced me to whimpers at that tender age. I pulled out all the stops and mortgaged my childhood in chores to upgrade to the Commodore 128, and that is basically the best value in an upgrade I'll ever see. Helped by the extra passage of years, on the 128 I made maze programs, a Dodge-The-Mall-Traffic Simulator as a joke, Ethnic dialects of Eliza including the Angry New Yorker, and a few quasi-utilities that were more basic concept exercises. Then I sold it to my neighbor for $100 of munchie cash, thus learning about Exiting the Market.
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
Tell Mom she rules. She earns a free play of this song.
http://www.youtube.com/watch?v=Ts96J7HhO28
"Hey Hey 16k... she bought it to help with her homework!"
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
The Vic-20 was the wo-
rst of both worlds,
bad games, crappy basi
c, and only 22 columns
across. Oh yea, and a
300-baud modem and no
disk drive, just casse
tte. Still, INFOCOM h
ad a few good text adv
entures on it.
>But the real question is....Why would anybody do this??
You jerk off in the shower, why do you do that? Because it amuses you?
Why don't you go sob one off in a corner right now?
<whack> <whack> <whack> <cry>Nobody loves me!</cry>
I agree, it was slow. But sometimes a slow computer forces you to think in better ways to acomplish your tasks, and if you're just learning to program, this can be a good habit (of course, I don't think the 64 is the best platform to learn... got my point)
Sadly, today there is an abuse of "premature optimization is the source of all evils", and young programmers just expect the compiler and the hardware to resolve every performance issue.... well, really they apparently do ignore there can exist performance issues.
For professional developers it also may provide some benefits; for example, sometimes I think the Gnome/gtk/etc developers should be given just 486 machines or at most Pentium II machines to develop and test all their code; I'm sure they could eventually get a decent speed on these systems (they're really smart) and would be a wonder for most people running current Core-2 and the like.
We're used to provide the coders with the top hardware (or the coders auto-provide it) as if that would provide better/faster code... the opposite is the truth.
I disagree, though it took me a minute to formulate the counter-reason.
No one is going to attempt to run Pixar graphics on this. The point is a form of "Limited Time Machine" in which we can return to portions of the past (here, the language) but abuse modern hardware to get sickening speed increases. Then we just drift back in our memories a little about that program we wrote Back In The Day, but now it eats Crays for breakfast.
As for SID tunes, yea, that hardware implementation has passed its prime, but enter Overclocked Remix. It's the musical ideas of those guys that count, and now they can freshen them up into the best kind of Old-Meets-New mashup. That site still makes a quarter of my work music. http://www.ocremix.org/
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
As I type my montor desktop color is C64 Blue on a black monitor.
My first Journal Entry ever, in 8 years! http://slashdot.org/journal/365947/aphelion-scifi-fantasy-horror-poetry-webzine
scripting + commodore + linux. Who did it? Taht boy in Afghanistan?
DNA in your Linux: DNALinux
I remember coding a nuissance program in 6510 assembler on my C-64 that sat in the background and when a key was pressed it had a tiny chance not to echo it to the screen or to echo it twice. After installing it on several classroom computers off the old 1541 floppy it drove some students batty, they thought they had sticky keys. This was before real viruses :)
I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered. My life is my own.
Here's a nice "Applesoft Basic for the Web" in JavaScript: GScript BASIC. It's especially aimed toward kids.
SYS 64738
Given it stands for "Beginners All-purpose Symbolic Instruction Code" I'd say just about any language or variation of it that meets this requirement and uses a similar syntax structure could be called BASIC.
GrpA
Enjoy science fiction? "Turing Evolved" - AI, Mecha, Androids and rail-gun battles. What more could you want?
I honestly really wanted to program the same project over summer (C64^64 BASIC), I almost fell off my chair when I saw this on the front page. Well done to the guy who actually did it, he saved me some time at least.
Damn, I need to start working on my ideas, maybe i'm not as crazy as I thought. :-)
I actually wrote my share of obfuscated CBM BASIC. With the silly notion that some day I might sell some of my code, I would put REM statements randomly on certain line numbers with control codes in them. This would cause the interpreter to fail with a '?SYNTAX ERROR' when doing a 'LIST'. With that hack in place, you would have to 'LIST' a specific line number to see it.
I found it odd that it took 1.8 MB of source code to compile to an interpreter that used to fit in 8K of ROM space.
Especially when you consider that Farbrausch were able to create a near-complete c64 emulator for Windows in under 64K a couple of years ago.
So what does that other 1.74M go to?
SIERRA TANGO FOXTROT UNIFORM
I just wish someone would make a PC version of the Boing ball - I miss it :(
If Google really cared they would fix Android Chrome to reflow text, instead of discriminating
C64 Basic? Nice.Good times.
Real Retro Basic Coolness? BBC Basic IV
Now that is (yes,is!) BASIC!!! Going from 16K TI with a cartridge and tape deck through c64 (with 1 floppy drive shared between 12 machines) graduating to a BBC Master 128...!!! Ahhhhh!!!
Going from that to a PC clone a few years later,with qbasic and that horrible syntax, was like a trip to the stone age.........not to mention all of a sudden things have to be "installed" to "hard drive"....wtf? .....and Elite on the PC .....Pathetic!!!.... after the Beeb!!!!???
I've created a 3-stage reatargeable cross compiler for ZX Spectrum BASIC, and could easily create an interpreter like that for Windows/Linux using the parser module. It's a ZX Spectrum BASIC "dialect", but also has some improvements taken from FreeBasic.
I think it's a nice idea. I will do a Sinclair BASIC interpreter this way.
---
"Nostalgia is not what it used to be"
Here, a reimplementation of BASIC in C.
In about 1.5 KB, and it actually works a treat!
http://www.ioccc.org/1990/dds.c
Enjoy!
Here you are: 1981, with a Basic that has datastructures and a lot of other high-level constructs.
http://en.wikipedia.org/wiki/BBC_Micro
Get the source of the Brandy interpreter (= BBC BASIC V) at:
http://www.bbcbasic.co.uk/bbcbasic.html
This is hands down the best BASIC implementation, ever.
POKE 53280,1
POKE 53281,0
You young whippersnapper....
I became proficient in Commodore BASIC with my VIC-20. We HAD to PEEK and POKE everything and tighten our belts when saving RAM.
We also had to remap entire character sets to get hi-res graphics.
The C64 made hi-res graphics easier to manage than that, even requiring continued use of PEEK and POKE.
"with a lot of time on their hands" what what stupid, uneducated idiots say about people who use their brains to do things they cant possibly think of doing themselves because "with a lot of time on their hands" means they dont watch reality TV or listen to music or watch sports or do the crap that the rest of the 2/3 of the idiots in this nation do to keep themselves awake during the day.
Addressed in the article.
1) It's faster.
2) It can access your files rather than ones inside the emulator.
3) It IS real Commodore BASIC. It was essentially ran through a 6502 assembly->?? recompiler, ran through LLVM to optimize it a little. It's basically raw assembly converted to C, which makes it quite obfuscated and large.
4) It's geeky fun.
Hello,
If you are interested in the hardware hacking environment of the Commodore 64, I suggest looking into the DIY projects world of PIC and AVR microcontrollers. Especially the AVR (www.AVRfreaks.net). These devices are very cheap, easy to program from the PC, and have extensive open-source programming and low-cost debugging tools (such as JTAG in-circuit-emulators and C compilers) available.
Programming these devices brings back all the joy of creating working electronic 'things' that plugging circuits into the back of the Commodore 64 used to. But these chips are all $1-$8 in cost and have the reprogrammable memory, UART, I/O ports, and analog-to-digital converters built into them.
What they don't have as yet is the video. Most microcontroller projects are at the LCD character display module stage. But bit-mapped graphics LCD modules are beginning to fall in price into the single-application range ($5-$15).
I learned microprocessor electronics by building things like memory expanders, temperture sensors, and MIDI interfaces to plug into the back of the Commodore 64, as you have done. I'm still doing the same projects now with AVR microcontrollers using the same techniques more or less. Fortunately the 'crash-and-burn' era of ultra-violet EPROM erasing has been replaced by Flash EEPROM in-system-programming. And when I mess up, the cost is only $5 worth of zapped parts rather than an expensive C64 motherboard or semi-custom 6510 processor.
This really isn't a general Slashdot message, but more a greeting from one C64 hardware hacker to another.