Jump to content
IGNORED

Challenge: Write a game in Atari Basic under 4K


NuY

Recommended Posts

SIO99's recent musings stimulated a thought in my overworked and undernourished brain. UK based fellow Atari enthusiasts will probably remember the old 5-liners in Atari User, the premise of which was to fit an entire program in five lines of Basic. Most were crap, but I remember a couple of notable ones in there which I enjoyed - a Snake clone, a Pacman clone - simple but fun.

 

So I thought a simple challenge to maybe stimulate some brains and have a bit of fun with it: Make a game in under 4K of Atari Basic!

 

Any takers? No prizes, just for fun. Attach in replies to this post and I dunno, maybe make a mini-poll at the end to find out which one people think is best.

 

Not many rules, but important I reckon, to keep in with the spirit of the competitions at demo parties and such:

 

1. No machine code. This includes embedded MC in strings. Data statements allowed, but only for UDG/PMG definitions, or say, data for a tune (doubt we'll see that in a 4K prog!). Pokes allowed to set up charsets or PMGs and similar, as long as it doesnt involve a mini MC routine. DLIs allowed.

 

2. 4K limit to be explicit is program length tokenised, including var table, is 4096 bytes as saved to disk (or however you can work out that limit in Basic... ;)). Most of you guys will know the trick here, but for those that don't, LIST the program to disk, NEW it, and ENTER the program back in to rebuild the var table, and then save back out to disk again.

 

That's pretty much it! Now I'll be the first to admit I'm no expert in using the A8's multitude of hidden tricks, and my imagination for an idea of a game to try and do is pretty much non-existent. But if anyone can toss an idea up, I'm up for trying to implement it :) Disclaimer: My Basic skills are average at best, and my MC is non-existent :P

 

So there we go. Let's say an end date of end of September. To the keyboards men!

  • Like 1
Link to comment
Share on other sites

I managed the snake/surround game in some insane small amount. It was something like 1-3 lines all up.

4K is fair scope to do something decent in Basic.

 

Atari Basic also puts the filespec in Saved programs. So there's scope for savings by using a minimal filename.

Actually, the shortest possible would probably be to have it as a CSAVE file.

 

But the best way to judge size would be FRE(0) difference before/after loading the program.

Edited by Rybags
Link to comment
Share on other sites

You may find some inspiration here -

 

Please watch these videos, like them and subscribe to this amazing channel! It contains long videos about A8 programming in BASIC, plus Assembler. The programmer needs some encouragement to continue ASAP, otherwise no more tutorials! :-((

 

http://www.youtube.com/user/SeetheTruth4Yourself?feature=watch

Link to comment
Share on other sites

DLI's are machine code. Do you just mean display list changes are allowed?

Sorry if that wasn't clear :) Yes, modifying the display list for a mixed mode display, or enabling scrolling, as examples is fine. Using the interrupts to exec some MC isn't ;)
Link to comment
Share on other sites

I managed the snake/surround game in some insane small amount. It was something like 1-3 lines all up.

4K is fair scope to do something decent in Basic.

 

Atari Basic also puts the filespec in Saved programs. So there's scope for savings by using a minimal filename.

Actually, the shortest possible would probably be to have it as a CSAVE file.

 

But the best way to judge size would be FRE(0) difference before/after loading the program.

Aye, probably a good idea as some DOSs chuck extra bytes in to the disk file for pointers I think?

 

Will still have to do the LIST/NEW/ENTER/ thing to reset the var table though to get an accurate figure.

Link to comment
Share on other sites

What's that do?

 

Takes a text file on a PC and converts it into tokenised BASIC to load into the target machine, in some cases working with labels rather than line numbers in the source file.

There are 2 editors I know of that will read a tokenised Basic file, not sure if you can save one out though, it's been a while since I've used them...Memopad and ATASCIIView; links are below:

 

http://joyfulcoder.com/memopad/

 

http://www.leehanken....co.uk/atascii/

 

Both are Windows apps.

Edited by NuY
Link to comment
Share on other sites

The mini-pacman and the Quasimodo 5 liners were pretty good. I was thinking of having a go and an Idea popped into my head; working title 'Blob Runner' so I've made a start. Hit my first error using the locate command and had to check the books (forgot to open the screen!)... I'm a bit rusty ;)

Link to comment
Share on other sites

The mini-pacman and the Quasimodo 5 liners were pretty good. I was thinking of having a go and an Idea popped into my head; working title 'Blob Runner' so I've made a start. Hit my first error using the locate command and had to check the books (forgot to open the screen!)... I'm a bit rusty ;)

Quick pointer on the LOCATE command. There are certain circumstances where doing a LOCATE at a screen pos will, for some reason that escapes me at the minute, erase what's currently there. If this happens, before manipulating the variable that you used in your LOCATE command, use a POSITION then a PUT command to restore the screen.

 

If I can remember why this happens, I'll put it up here ;)

 

Example below:

 

...
310 LOCATE X,Y,CODE
320 POSITION X,Y:PUT #6,CODE
...

Edited by NuY
Link to comment
Share on other sites

Okay, so if i commit myself to writing in the emulator rather than using a tokeniser... how do i save out what i've done? 25 years is a long time and i never owned a disk drive! =-(

What I sometimes do is use Notepad or similar to bash text out and use Altirra's awesome ability to paste text into the emulator screen. Not quite what you were after, but saves having to type directly in the emulator.

 

Only drawback to this is getting the ATASCII gfx char in though - they still have to be done manually, unless someone can figure out how to get a heart character in Notepad :P

Link to comment
Share on other sites

Quick few pointers for anyone that needs them for memory saving if struggling to get under 4K:

  1. Get rid of all REM statements.
  2. Use variable constants - if you have the number 1 occurring quite often in the listing for example, assign the number 1 to a variable and use that everywhere 1 is used. (eg. N1=1)
  3. You can fudge an equivalent to the IF...THEN...ELSE construct that is present in other Basics, this can sometimes save a bit of space instead of having another line to do the ELSE bit:
     
    230 ON HIT<>1 GOTO 240:PRINT "YOU WERE HIT":GOTO 500
     
    In this example, if variable HIT is equal to anything but 1, execution gets sent off to line 240. If HIT is equal to 1, the rest of line 230 will be executed.

Link to comment
Share on other sites

What I sometimes do is use Notepad or similar to bash text out and use Altirra's awesome ability to paste text into the emulator screen. Not quite what you were after, but saves having to type directly in the emulator.

 

Oh now he fecking tells me over halfway through getting something going!! =-)

 

Is there any way to check bits in a byte at all? i could just check for the three possible states when the joystick is pushed left i s'pose (to filter out accidental leans on up or down) but it feels clunky.

Edited by TMR
Link to comment
Share on other sites

What I sometimes do is use Notepad or similar to bash text out and use Altirra's awesome ability to paste text into the emulator screen. Not quite what you were after, but saves having to type directly in the emulator.

 

Oh now he fecking tells me over halfway through getting something going!! =-)

You're welcome ;)

 

Is there any way to check bits in a byte at all? i could just check for the three possible states when the joystick is pushed left i s'pose (to filter out accidental leans on up or down) but it feels clunky.

Not in Basic, but you can use Boolean logic instead for the joystick. Following should give you something to work with:

 

10 S=STICK(0)
20 LEFT=(S=9 OR S=10 OR S=11)
30 RIGHT=(S=5 OR S=6 OR S=7)
40 UP=(S=10 OR S=14 OR S=6)
50 DOWN=(S=9 OR S=13 OR S=5)

Edited by NuY
Link to comment
Share on other sites

You can also extend this out to get X/Y coordinate changes done too. This assumes that you're moving a char/PM one position in any compass direction, with no sanity checking:

 

10 S=STICK(0)
20 X=X+(S=7 OR S=6 OR S=5)-(S=11 OR S=9 OR S=10)
30 Y=Y-(S=10 OR S=14 OR S=6)+(S=13 OR S=9 OR S=5)

 

With sanity checking, but will be slower (assumes 40x24 screen):

 

10 S=STICK(0)
20 X=X+(X<39)*(S=7 OR S=6 OR S=5)-(X>0)*(S=11 OR S=9 OR S=10)
30 Y=Y-(Y>0)*(S=10 OR S=14 OR S=6)+(Y<23)*(S=13 OR S=9 OR S=5)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...