• Bit 64

  • by jwhoag

Commodore-related project and thoughts I have worked on

Jun
9

C64List is now available

View, create, and edit Commodore 64 BASIC programs using your favorite text editor on your PC

All Grown Up

Unless you are a hard-core Commodore purist, you probably outgrew your admiration of Commodore’s BASIC editor and keyboard layout years ago.  Typing more than a few keystrokes on the C64 keyboard quickly becomes fatiguing and is rather slow.  And how many times have you typed LIST only to have it appear as LST on the screen?  The 40-character screen seemed like a whole lot of wide open space after the VIC-20, but these days, you can barely fit some email addresses onto one line, let alone a good programming comment.

As you may have deduced from the previous paragraph, I am not a hard-core Commodore purist.  Don’t get me wrong, I have a ton of fond memories of staying up all night long pouring over that little brown box, trying to get my latest program ready to run.  I still think the C64 is a fun little machine.  That little 8-bit machine still occupies a soft spot in my heart and I occasionally like to break it out and do something retro, but I have been spoiled by a lot of new technologies in the past 25-or so years, and I have lost patience with some of that fun little machine’s limitations.  Perhaps that has a lot to do with the fact that my “fun” time is now extremely limited and at a premium.  Perhaps that has to do with the fact that my wrists are not as agile as they were 25 years ago, and anything but an ergonomically shaped keyboard kills my arms after a short time.  Perhaps that has to do with the fact that I have always embraced new technologies that I perceived as better.  Likely, it has to do with all of these reasons, and more that I am not spending my premium time thinking of.

Shrinking Pains

I hadn’t touched a C64 in a long, long time until about 5 years ago.  I found a good deal on one on EBay and nostalgia kicked in and I gave in and placed a bid.  I happened to win the auction and wound up back on EBay a few days later to round out the rest of the system.  After I got my new, old system set up and running, I jumped right into a little programming project and immediately realized I had seriously outgrown some of Commodore’s 1980’s leading-edge quirkiness, and dreadfully missed my “Home” and “End” keys.  My first thought was that I needed to write a BASIC editor program with all kinds of cool new features.  But then I realized that would mean I’d have to do a lot of work using the normal editor before I could use my cool new editor!  I quickly canned that idea, but a new seed was born: I would like to be able to write programs using my comfy PC system, and then run them on my Commodore 64.  True, I could do development using an emulator like Vice, but that would not have solved the editor problem.   So today, a lot of half-hour programming sessions during life time-outs, a number of nothing-but-programming weekends, and few years later, I am happy to report that this is now possible!

Enter C64List

My product is called C64List, and it runs in a command prompt under Windows.  It will convert .prg formatted Commodore BASIC files, detokenize them, and output a plain text file.  Once the initial conversion has been made, you can edit these text files at will using your favorite--or any available--text editor, and then use C64List a second time to convert the edited text files back into .prg files and run them on Vice or a real C64.  C64List actually does a lot more than the basic outline I just described.   I’ll talk about some of the exciting things C64List can do, roughly from “cool” to “COOL!”, so stay tuned for the big finale.

Do those Crunches

Since we are starting small, let’s talk about spaces.  Spaces are pretty darn small, but they do take up one byte each.  Large programs need to stay in shape in order to fit into their shorts, otherwise they will quickly split out the seams of BASIC space.  C64List’s optional Crunch feature removes all unnecessary spaces from your code when converting from .txt to .prg so you can squeeze more code into memory.  Crunch can also do the opposite, adding spaces strategically into your crunched .prg code to make your .txt file more readable and easier on the eyes.

REMark REMoval

Following along the lines of Crunch, C64List also allows you to automatically remove REM statements from your program.  If you are like me, your programs have tons of REMark statements.  I figure if I ignore my project for a few years and then come back to it I’ll probably have forgotten what that younger me was attempting to do, so I spell it all out in plain old English for the older me to read later. 

Unfortunately those 38911 BASIC BYTES FREE turn into ?OUT OF MEMORY ERRORs pretty fast with all those handy remarks.  Not only that, but the simple fact of their existence slows down execution of a BASIC program.

Removing all those REM statements can squeeze more logic into the limited amount of memory, and can speed up your program as well.  You can ask C64List to strip those pesky REM statements out of your program when you convert it to .prg format.  And if you ask nicely enough, C64List will actually do it for you!   If C64List finds a REMark on a line containing code, it will remove it from the end of the line (yes--along with the preceding colon).  If it finds a line that only contains a REMark, the line will be completely removed from the program.    And since you asked really nicely, C64List will even do the really dirty work of finding and changing any GOTO and GOSUB statements that reference those completely-removed lines, and re-route them to the remaining lines of actual code--so you don’t suddenly start getting UNDEF’D STATEMENT errors.

The usage model that I advocate is to do all your development in the .txt file format and then convert it to .prg whenever you want to run it.  This gives you the best of two worlds: all your handy notes-to-self are neatly preserved in your working text file, but they are cleanly stripped out on the way to the .prg file so they won’t clog up your “executable” program.

Cursing at ASCII

One of C64List’s really neat features is the ability to convert cursor-code characters--which are not displayable, let alone editable in a text file--into readable and editable strings such as {right}, {up}, and {red}.  Naturally, it will also convert them back into their native codes when the text file is converted to into the C64-edible .prg format.

C64List will also compress consecutive identical cursor codes into a shorthand form such as {down:5}{right:10}, rather than repeated {down}{down}{down}, etc.  Not only is this more aesthetically pleasing, but it prevents you from having to count those silly characters over and over and over again to make sure you insert the right number of them.

That Sure Did a Number on my Program

And now we’re getting even COOLer!  If you have ever run out of room between line numbers in your program, or you get really tired of that darn line number 49217 that is referenced all over your program,  you can use C64List’s renumbering feature.  C64List gives you a lot of control over the details of how it renumbers your program.  You can tell it to start various sections of your code with nice round numbers like 200 or 5000, and you can also specify the increment between line numbers any number of times you wish.  Or you can just let it do its thing if you don't care!

Normally, doing such a thing would leave every GOTO, GOSUB, ON x GOTO, etc. in your program stranded, pointing to no-longer existing line numbers, or worse, the wrong line of code.  Since that would have left you in a rather unfortunate and precarious bind, C64List helpfully searches through your program and fixes up all the GOTOs and GOSUBs, etc. so they re-route to the new line numbers of the code that they originally referenced.

No Line No.!

The big, shiny, new, COOLEST feature which I saved for the final reveal, allows you to completely eschew line numbers while you are programming.  If you have ever programmed in both Commodore BASIC, as well as just about any other programming language in the known universe, you will immediately understand the magnificent value of this feature.  Now you can simply leave out all the line numbers while you are programming, and C64List will automatically add them for you later.

When you need to GOTO or GOSUB, just create a label at the target line, and then reference these labels as the targets of GOTO and GOSUBs.  When you convert your .txt file back to .prg, C64List will automatically assign line numbers for you and convert the labels and references to the line numbers that were assigned.

This makes it really easy to insert new lines, move chunks of code around without having to worry about squeezing it into thin slices of unused line numbers, stomping on already-used line numbers, or manually fixing all your GOTO and GOSUB statements that refer to those lines.  This feature alone makes C64List an absolutely indispensible tool for BASIC programming on your C64.

As an added bonus, C64List will actually convert a normal, line-numbered Commodore BASIC program into its line numberless labeled format for you.  This function strips off all the line numbers, inserts labels where needed, and converts all GOTOs and GOSUBS, etc. to reference those labels.  This means you can immediately start working on your existing BASIC programs in the new numberless world using all the best features of C64List.

Running Into the Future

Now I am a little out of breath from the excitement of sharing all the cool features packed into C64List.  Once I catch my breath, I have plans to add more cool features as time permits.  I won’t actually enumerate them here, but I’m kicking around ideas like assemblers, disassemblers, programming and debugging aids, mixed case support, and other things.  We are also thinking of actually incorporating C64List directly into CommodoreServer to prevent you from developing Carpal Tunnel syndrome while typing C64List commands at a command prompt.

One piece is that is currently missing, is that C64List does not permit editing C64 graphics characters.  When C64List converts .prg files to .txt files, the graphics characters are converted directly into ASCII codes, and of course, there are no corresponding symbols in ASCII.  This makes it difficult to do anything meaningful with these characters.  However, if you don’t change these characters while they are in text form, they will convert directly back to the proper graphics characters in the .prg file without issue.  I plan to address this in the future.

Let the Fireworks Begin!

The final icing on the C64List cake is that I am sharing this long-awaited masterpiece with anyone who wishes to use it, for free.  Of course, if you would like to donate something to help offset the (literally) years I put into this thing, I will happily accept cash!  I highly encourage participating in this activity, liberally and often!

To get your hands on your own copy of C64List, visit the downloads page on CommodoreServer (https://www.commodoreserver.com/Downloads.asp).  The C64List User’s Guide is also posted there.  It features a thorough reference as well as a tutorial-style narrative to get you going quickly.

To contact me about C64List, email [email protected].  I have a rather time-consuming day job and don’t check this mailbox every day, so expect some lag in responses.

Agent Friday used C64List extensively in his development of Group Zork before the line numberless support was added.  Now he is even more excited to dump all those pesky line numbers he so painstakingly created and jump into the labeled format with both feet.

I hope that you will find C64List useful as well and that it increases your productivity!  Try it out and let me know what you think about it.

Leave a Comment

You must be signed-in to post comments.

Responses