Commodore FREE One Liners competition.

Basic and Machine Language

Moderator: Moderators

Shaun.Bebbington
Vic 20 Dabbler
Posts: 78
Joined: Fri Jan 20, 2006 3:41 am

Commodore FREE One Liners competition.

Post by Shaun.Bebbington »

Commodore FREE is running a One Liners competition to link in with the publication of this book.

All Commodore 8-bit formats are welcome, and your program must be a maximum of two lines (so there are two categories: genuine one liners, and two liners). The two line thing is to compensate for the lack of characters per line in most dialects of Commodore BASIC. For instance, you can get a lot of logic into Sinclair BASIC and others in just one line of BASIC.

I've done an example disk to get everyone started. The full article should be published in the next issue of Commodore FREE - if not then the deadline might have to be moved. It's announced here to give you a head start :-)

Here are some rules:

* Machine code can be used if it's using a MC loader (DATA/FOR/POKE combo) – 0 sys 2059 which then runs an entire game written in assembly, C or some other compiled or assembled code is not a one liner for the purposes of this competition.

* For two-liners, the first line should be used for variables, functions and data, and the second should contain the logic.

* Please provide as much information as possible with your submissions, ie, what you were trying to achieve, and how far you think you got to achieving it; how you created your program (genuine one liner, BASIC 7 or whatever).

* Entries are welcome on all Commodore 8-bit formats in any known variant of BASIC – please save them to a D64 disk image along with your documentation. So, you could try something for the VIC-20, for instance.

* Have fun with it – remember, 640 bytes ought to be enough for anyone!

* The closing date is Friday 8th March 2013 at 11:59pm GMT. The winner will be announced in the next available issue of Commodore FREE, and through the various forums that we use. We will dig out some prizes for you.

Please feel free to ask any questions.
Without context, we are only data.
groepaz
Vic 20 Scientist
Posts: 1185
Joined: Wed Aug 25, 2010 5:30 pm

Post by groepaz »

"the first line should be used for variables, functions and data"
could you clearify what that does actually exclude? my code usually purely consists of variables, functions and data.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

Hmm... 176 bytes of basic (on the vic) isn't a heck of a lot. :)
Shaun.Bebbington
Vic 20 Dabbler
Posts: 78
Joined: Fri Jan 20, 2006 3:41 am

Post by Shaun.Bebbington »

groepaz wrote:"the first line should be used for variables, functions and data"
could you clearify what that does actually exclude? my code usually purely consists of variables, functions and data.
It's just a rule of BASIC, isn't it? You can't declare a variable in line 200 to use in line 100 without a gosub or something. But yes, you are correct. Programs are basically variables, functions and data.

Regards,

Shaun.
Without context, we are only data.
groepaz
Vic 20 Scientist
Posts: 1185
Joined: Wed Aug 25, 2010 5:30 pm

Post by groepaz »

that doesnt answer in any way what exactly i am allowed to put into the first line and what not
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

I suppose by functions he means function definitions.
So you can put anything except control logic and output in the first line.
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Post by Witzo »

I'm a little confused.
A two-liner on the VIC is 2x2x22=88 characters of basic. The length of a basic line is two screen lines, am I right?
And then a maximum of 640 bytes is mentioned, which would fit a lot longer program than in two lines of VIC basic.

I have a little idea, but I don't think it'll fit in two lines of VIC basic. But 640 bytes of basic code must be more than enough. So can I use that?
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

The screen editor of the VIC-20 accepts up to four physical lines as a single logical line, i.e. 88 characters.

With abbreviations (for example, ? for PRINT, F SHIFT-O for FOR, N SHIFT-E for NEXT, etc., see the VIC User's manual), you can enter some more code into these four lines. When this line is LISTed again though, the abbreviations are expanded to the complete keywords. The line then spans more than four physical lines, and cannot be edited anymore as a whole (unless you retype it again in abbreviated form).

BASIC itself is not limited though to lines of just 88 characters, regardless whether typed in full or in abbreviated form. Rather, the interpreter accepts lines with up to 255 bytes in length, including the two-byte link pointer, two-byte line number, and the terminating null byte at the end of the line. Keywords of BASIC (the 'tokens') count for a single byte. Lines longer than this cannot be handled by the routine that relinks the lines when a program is loaded.

Such an over-length line can't be entered in quite the usual way, but - at least in principle - one could POKE it into memory by hand. Or use petcat.

The 640 bytes note is presumably just a joke referring to an old saying attributed to Bill Gates. :wink:
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

Hmm... I had a go, but I couldn't write much in less than 256 bytes.
So here's my 256 byte attempt. ZXOK to move, P to bomb.
http://www.kweepa.com/step/vic20/games/twofiftysix.prg
User avatar
Witzo
Vic 20 Afficionado
Posts: 381
Joined: Thu Dec 01, 2011 9:14 am
Location: The Hague

Post by Witzo »

Thanks Mike. Two basic lines of four physical lines each, then that's what I'll be aiming for.
I'll disregard Shaun.Bebbington's remark about the 640 bytes.
Shaun.Bebbington
Vic 20 Dabbler
Posts: 78
Joined: Fri Jan 20, 2006 3:41 am

Post by Shaun.Bebbington »

Witzo wrote:Thanks Mike. Two basic lines of four physical lines each, then that's what I'll be aiming for.
I'll disregard Shaun.Bebbington's remark about the 640 bytes.
It's a reference to Bill Gate's supposed claim that 640 Kilobytes ought to be enough for anyone (that's only part of what he said, as I recall). But if you've written something in *less than* 640 bytes then 640 bytes *was enough* for your one-liner as you've got space to spare.

So far, there has been one disqualification - it was a program listing that had around 30 lines.

Anyway, the deadline is close, so feel free to submit your entries.

Regards,

Shaun.
Without context, we are only data.
Shaun.Bebbington
Vic 20 Dabbler
Posts: 78
Joined: Fri Jan 20, 2006 3:41 am

Post by Shaun.Bebbington »

Kweepa wrote:Hmm... I had a go, but I couldn't write much in less than 256 bytes.
So here's my 256 byte attempt. ZXOK to move, P to bomb.
http://www.kweepa.com/step/vic20/games/twofiftysix.prg
Very good, but I count five lines of BASIC.

Regards,

Shaun.
Without context, we are only data.
Leeeeee
soldering master
Posts: 396
Joined: Fri Apr 23, 2004 8:14 am

Post by Leeeeee »

I count six, but lines 1 through 4 can be turned onto one long FOR .. NEXT loop with line 5 tagged on the end.

Entering the thus modified very long second line may be a bit of a problem though.

Lee.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

I really wanted to do this, but I haven't had time to program in a while. The deadline is just too close.
High Scores, Links, and Jeff's Basic Games page.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

Shaun.Bebbington wrote: Very good, but I count five lines of BASIC.
Great! We can hide a line by numbering it 0! :)

It wasn't really an attempt to enter, since I think the rules are too strict for the VIC, although as Leeeeeee says the same game could theoretically be entered as two lines. I'd prefer a byte count. What is the C64 line limit? Is it 4x40=160 'bytes'?
Post Reply