Code Golfing in Commodore BASIC

by Two9Aon 10/1/2023, 8:46 AMwith 40 comments

by wazooxon 10/2/2023, 10:04 AM

Back in the 80s when type-in program magazines were common, in France we had the wonderful "Hebdogiciel" with a perpetually running BASIC programming contest called "deulignes" -- which means "twolines".

"Deulignes" programs could target any platform, but must only take 2 lines of BASIC (most implementations allow only a limited line length, often 255 characters).

Some programs were really impressive; I remember one complete breakout implementation in MSX-BASIC for instance. People actually made whole (small) games in 2 lines of BASIC!

Here's an example page : https://archive.org/details/hebdogiciel-french-098/page/n15/...

by bump-ladelon 10/2/2023, 12:28 PM

If you enjoy this, then you should definitely checkout 8-Bit Show And Tell’s YouTube channel. The presenter, Robin, regularly does deep dives into code optimisation and fixes on Commodore 64 and other machines.

https://www.youtube.com/watch?v=jhQgHW2VI0o

by qiqitorion 10/2/2023, 7:46 AM

https://gkanold.wixsite.com/homeputerium/games-list-2023 Games written in ten lines of vintage BASIC. (Not related to the article but its title.)

by afro88on 10/2/2023, 10:46 AM

BASIC defaults to the tape device if you leave off the device number in LOAD/SAVE commands. So you can save another byte or two by saving to tape instead.

by dep_bon 10/2/2023, 8:01 AM

In a C64 BASIC program keywords like SAVE and PRINT can be abbreviated:

https://www.c64-wiki.com/wiki/BASIC_keyword_abbreviation

That would shave off some more precious bytes!

by lifthrasiiron 10/2/2023, 9:09 AM

I don't know anything about C64 or C64 BASIC, but would it be possible to intentionally write a shorter binary which will break the interpreter and do what we want instead? For example jump directly to a middle of the kernel ROM routine (akin to ROP in the modern days), or use a bad address in the "next line" offset etc.

by einron 10/2/2023, 8:31 AM

Using line number 1 instead of 10 seems like an easy 1 byte save.

by p0w3n3don 10/2/2023, 11:34 AM

remember when people didn't have FDDs but cassete drives instead, because FDDs were too expensive? Pepperidge Farm remembers