Slashdot Mirror


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.

44 of 213 comments (clear)

  1. TI Basic by mfh · · Score: 2, Interesting

    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.
    1. Re:TI Basic by pilgrim23 · · Score: 3, Informative

      plugh! or was it xyzzy? :)
      there are several Apple II emulators that allow programming in Apple Basic or even Merlin Assembler (65816) for both Mac and Windows. Sweet16 is the best of OS X (a port of Bernie ][ the Rescue from BeOS; originally on Mac Classic), XGS, KEGS and many others are also out there...

      CALL -151

      --
      - Minutus cantorum, minutus balorum, minutus carborata descendum pantorum.
    2. Re:TI Basic by jojisan · · Score: 3, Interesting

      Was that a stock 99-4A or did you have the extended memory cartridge?
      I really do miss call sprite...

      --
      <sig> I wish I had a </sig>
    3. Re:TI Basic by mfh · · Score: 5, Informative

      Was that a stock 99-4A or did you have the extended memory cartridge?

      I had the 10 ton silver expansion box! 32k baby!!! It was the BEST! :) With the Speech Synthesizer to boot! Doc Watson makes me cry when I think about how much that thing cost me... right out of pocket too from my paper route!!

      This particular code made use of CALL SPRITE, but also had the most advanced calls available. Man that brings back memories...

      CALL COLOR, CALL CHAR, CALL SPRITE, CALL PATTERN, CALL MAGNIFY, CALL MOTION, CALL POSITION, CALL LOCATE, CALL DISTANCE, CALL COINC, and CALL DELSPRITE.

      The cartridge was Extended Basic, which was totally elite at the time. :P

      We were all designing color output, while the poor VIC-20 guys were still monochrome.

      I still remember the text adventure, where if you type look up, a piano falls on your head. I think it was called Asylum or something? Man that is going way back to the summer of 1983, if memory serves.

      --
      The dangers of knowledge trigger emotional distress in human beings.
    4. Re:TI Basic by aardwolf64 · · Score: 5, Funny

      I had to get my dad to program the dungeon text adventures, so it wouldn't spoil everything for me. There's just something about typing everything that could happen to you that ruins the game.

    5. Re:TI Basic by digitalhermit · · Score: 2, Interesting

      I remember a similar demo in the TI/994A Reference Manual. It also had a program to re-define a character to make a little jumping man in an 8x16 grid. One of my first programs was to make a running man move across the screen based on the code in the reference manual.

    6. Re:TI Basic by lxs · · Score: 4, Funny

      I used to have a book with type-in adventures where they obfuscated all the strings by shifting them one character precisely to counter that problem.

      Oh and typing in five pages of numbers representing binary code was fun. There were actually checksums printed at the end of each line and a little program showed you the checksums in the corner of the screen after entering each line of code.

      Man I feel old. You young whippersnappers don't know how good you have it with your iPhones and your WiFi.

    7. Re:TI Basic by AmberBlackCat · · Score: 2, Interesting

      I was in the Apple store, asking a Genius why Ms. Pac-Man, which ran on an Atari 2600, is taking up almost 20 megabytes on my iPod Nano. He told me it's because they have to fit all those in-game sound effects into the download. Pure genius.

    8. Re:TI Basic by khellendros1984 · · Score: 4, Informative

      If you wanted a serious answer, it's most likely related to the ties to the graphics and sound libraries, storing sounds as waveforms rather than parameters to tone-generation hardware, and probably packaging overhead.....those are just guesses. I'm no iPod software expert.

      --
      It is pitch black. You are likely to be eaten by a grue.
    9. Re:TI Basic by Anonymous Coward · · Score: 2, Funny

      Don't soften his boner dude. He might not be aware that some TVs only displayed black & white. Leave him to his fantasy.

  2. The important quesiton is... by Thelasko · · Score: 3, Funny

    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".
    1. Re:The important quesiton is... by aardwolf64 · · Score: 2, Informative

      http://www.zzap64.co.uk/c64/c64emulators.html

      You're on your own for the actual game, but I promise it's out there. It's only 6k zipped.

    2. Re:The important quesiton is... by Thelasko · · Score: 4, Funny

      I should have known somebody was going to take that comment seriously. Mention porting a crappy game from 25 years ago, and somebody on Slashdot will do/find it.

      --
      One of our competitors trademarked the term "hypothesis". From now on, we will call them "boneheaded ideas".
  3. READY. by F-3582 · · Score: 2, Funny

    10 FORA=1TO300
    20 PRINT"YAY!"
    30 NEXT
    RUN

    1. Re:READY. by tom17 · · Score: 2, Insightful

      Surely

      10 PRINT "YAY!"
      20 GOTO 10

      RUN

    2. Re:READY. by Blakey+Rat · · Score: 3, Informative

      Semi-colon, buddy, tells the C-64 to not append a newline after the string. Feh, NEWB!

      You could rewrite that as:

      10 PRINT "YAY!";
      20 GOTO 20

    3. Re:READY. by Blakey+Rat · · Score: 2, Funny

      Oh crap, I typoed the code. I'm the newb!

      I can make up for it:

      10 FOR X = 1 TO 16
      20 PRINT "YAY!";
      30 POKE 646,X
      40 NEXT X
      50 GOTO 10

      Now we're cooking with gas.

  4. Why it's 1.8MB by Anonymous Coward · · Score: 5, Insightful

    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

  5. There's also Freebasic. by GrpA · · Score: 5, Informative

    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?
  6. Commodore BASIC by hpa · · Score: 4, Insightful

    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.

    1. Re:Commodore BASIC by decipher_saint · · Score: 3, Interesting

      Compared to...?

      I'm actually quite curious what the differences would be that would make it a bad interpreter.

      C64 was my first exposure to programming (I was 8 when I got my hot little hands on it), and not having tried anything else from that particular era of home computing I don't have a yardstick to measure that sort of thing.

      So please, tell me more :-)

      --
      crazy dynamite monkey
    2. Re:Commodore BASIC by LWATCDR · · Score: 2, Interesting

      Actually Atari Basic was arguably worse the Basic 2.0.
      Atari Basic had totally none standard String handling.
      C64 Basic lacked extensions for graphics and sound but other than that it wasn't terrible.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    3. Re:Commodore BASIC by hpa · · Score: 5, Informative

      A few things that made Commodore BASIC slow compared to some of the BASICs of the time:

      1. A lot of parsing was done at runtime, rather than at entry time or program startup time. This meant that a lot of work got done over and over rather than once per execution, and also encouraged practices that made programs hard to read, like omitting comments and whitespace.
      2. No support for integer-only arithmetic.
      3. Very few high-level constructs. This didn't just turn programs into a mess of POKE statements, but frequently meant that a lot of them were needed -- all of which involved two floating-point to integer conversions to set a single byte.

      Most BASICs at the time would at least tokenize at entry time, and many even converted programs to P-code for execution. It was still much slower than true assembly, but it wasn't anywhere near as bad as the CBM basic. Similarly, most (but again, not all) BASICs of the time supported integer-only arithmetic at least as an option.

      I have to admit to being a bit spoiled at the time, since I first learned to program on the Swedish ABC80 computer, which had a very fast BASIC interpreter. Its follower, ABC800, even had a decent collection of high-level programming constructs in its BASIC. Too bad neither had acceptable graphics, nor a reasonable price point for home use (they ended up being sold mostly into schools and small offices.)

    4. Re:Commodore BASIC by ACMENEWSLLC · · Score: 3, Interesting

      I learned BASIC on an Apple and then moved to the C16 then to a C128 with C64 embedded. I really enjoyed BASIC on the Commodore platform. I loved POKE and PEEK. The with my Super Snapshot card I could get into a pretty good machine language decompiler. From there I could create programs in the $c000 range, store them to a floppy, and sys them. I loved monitoring the raster ($d018 or somewhere close) and changing it's color when it's at various positions to create screenshots better than what the C64 normally allowed.

      I never have got as deep with the x86 platform.

      The thing I've found with most emulators is that this trickery just doesn't work right. A lot of it depended on the set Mhz rate of the hardware.

      I find it odd as many fanboys of the C64 as there are, why not embed one onto a USB dongle. The other end with a RS232C cord?
          Something like this http://www.vesalia.de/e_c64dtv%5B5732%5D.htm?slc=us ported for us programmer types.
         

    5. Re:Commodore BASIC by BitterOak · · Score: 4, Informative

      No support for integer-only arithmetic.

      Actually, that isn't true. You could specify integer variables by suffixing them with a percent sign (eg. i%=1). But most people were lazy and omitted the percent sign, so their programs ended up doing a lot of floating point math unnecessarily.

      --
      If I can be modded down for being a troll, can I be modded up for being an orc, or a balrog?
    6. Re:Commodore BASIC by multipartmixed · · Score: 2, Informative

      Additionally, Commodore BASIC _did_ tokenize input at data entry time.

      That's how the "shortcut" keywords worked -- PRINT's shortcut was P-shift-R (graphical underscore-like character), and not uncoincidentally, that was also the token for the PRINT statement.

      I'm not sure the grandparent is, in fact, talking about CBM BASIC 2.0. :)

      (which, don't get me wrong, sucked -- but it's not like AppleSoft BASIC was any better. Or Timex-Sinclair BASIC. Let's see. What BASIC is he referring to that has data structures and existed on home computers in 1982?)

      --

      Do daemons dream of electric sleep()?
  7. Re:Added layers by LWATCDR · · Score: 2, Informative

    Actually I would guess that it could be the multiplatform code that takes up so much space.
    I have to hope that they don't support Poke and Peek.
    C64 basic doesn't support any of the cool features like Sprites and sound.

    --
    See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
  8. 1.8 MB of source for 8K of ROM by sucker_muts · · Score: 4, Interesting

    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? => /bin/there/done/that
    1. Re:1.8 MB of source for 8K of ROM by khellendros1984 · · Score: 2, Insightful

      Or static linking of libraries, of course...

      --
      It is pitch black. You are likely to be eaten by a grue.
  9. I smell a terrible contest.... by tjstork · · Score: 2, Interesting

    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.
  10. But the real question is.... by Simonetta · · Score: 5, Insightful

    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.

    1. Re:But the real question is.... by spaceyhackerlady · · Score: 4, Insightful

      But the real question is....Why would anybody do this?? Port Commodore64 BASIC to a PC?

      Three reasons come to mind:

      1. Because it's there.

      2. Because you can.

      3. Because it's cool. :-)

      ...laura

    2. Re:But the real question is.... by Super+Jamie · · Score: 2, Insightful

      I agree that there is nothing wonderful about C64 BASIC, and also wonder why someone would port an awful archaic language to modern PCs, when there are far better BASIC interpreters around already.

      However, hardware sound reproduction is something else. SID chips produce a noticeable sound, and sound decks with SIDs built in are worth several thousand dollars and used by many popular recording artists today.

      You'll also find the Gameboy has a popular sound production scene associated with it. Look on YouTube for "little gp tracker" or just "gameboy tracker" and you'll see what I mean.

      tl;dr - BASIC lame, SID good

    3. Re:But the real question is.... by lastchance_000 · · Score: 2, Informative

      The attraction of the home computer scene of the early 80's wasn't productivity, it was the sheer fucking joy of exploration.

    4. Re:But the real question is.... by eharvill · · Score: 2, Informative

      Yes, the Mobygames lists DOS version, but the CGA glory isn't exactly the best release.

      Grab a c64 emulator and play the full color version, as shown from the game box screen shots.

      --
      At night I drink myself to sleep and pretend I don't care that you're not here with me
  11. Because it's there by Nimey · · Score: 2, Insightful

    obviously.

    --
    Hail Eris, full of mischief...

    E pluribus sanguinem
  12. Almost tempted by ducomputergeek · · Score: 4, Funny

    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.
  13. Retrocomputing by Orion+Blastar · · Score: 2, Funny

    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.
  14. I hit L, Shift-O to the Quote and then Dollar! by JoshDM · · Score: 3, Funny

    If you know the dir of the nerdcore rhyme, then holler!

  15. *whoosh* by frieko · · Score: 3, Insightful

    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.

  16. Re:Commodore BASIC - which variant?? by TaoPhoenix · · Score: 2, Interesting

    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
  17. Ah sweet memories, I love /. by Phizzle · · Score: 4, Funny

    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.
  18. malicious code by RackinFrackin · · Score: 3, Funny

    SYS 64738

  19. I'll say. by uhlume · · Score: 2, Insightful

    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