Jump to content
IGNORED

Challenge: Write a game in Atari Basic under 4K


NuY

Recommended Posts

Yeah, that was an omission I never liked. Too many comparisons bogs down quick. IMHO, ON GOTO works much better, but takes up room. Maybe no more than the comparisons do.

 

Somewhere I saw a USR function contained in a string method that would be nice and quick, but no ML for this one...

Link to comment
Share on other sites

That's probably about as long-winded as just checking for all the conditions in an if so i'll leave what's there. So... entries in .BAS format since i know how that's done? =-)

If you come close to hitting the 4K limit, it will save a good few bytes over IF/THEN constructs too.

 

Entries in .BAS are great, also an ATR in any DOS flavour with the Basic file saved on it is cool also. When they're all in, I'll put them all on one disk image too with a boot menu (PicoDOS?) for people to be able to easily play them and post it up here :)

 

My problem at the minute is that I know most of the theory into getting a game done (movement, UDGs, PMGs, collision etc.) but I'm racking my brains for inspiration for an actual subject for a game :(

 

If this project catches a few people's imagination, feel free to mention it in RG btw ;)

Link to comment
Share on other sites

There is one last stick routine that is worth mentioning, using Atari Basic's capability of using a variable, expression or function in a GOTO statement, and it avoids doing any evaluations completely, but will eat up more memory. It is however, very fast for Basic. This is for eight way movement, can be changed to suit for 4 way or accidental pushes to up/left or down/left:

 

1 GOTO 20:REM Jumps over stick routine
5 X=X+1:Y=Y+1:RETURN
6 X=X+1:Y=Y-1:RETURN
7 X=X+1:RETURN
9 X=X-1:Y=Y+1:RETURN
10 X=X-1:Y=Y-1:RETURN
11 X=X-1:RETURN
13 Y=Y+1:RETURN
14 Y=Y-1:RETURN
15 RETURN
20 GOSUB STICK(0)
30 ...

 

Again, no sanity checking there, but you get the idea.

Edited by NuY
  • Like 1
Link to comment
Share on other sites

Okay, that's me done then. The game is called Stellar Caverns, the .BAS file is 3,209 bytes long and it's one of those "use PRINT to scroll" games where the player has to dodge the landscape. It uses PMGs (well, one player at least), a custom display list with split screen, has a little in-game sound... and it scrolls downwards!!

 

post-3086-0-33346300-1345316943_thumb.png

 

That was a giggle... although i was supposed to be working today and spent far too long on this. =-)

stellar_caverns.zip

  • Like 11
Link to comment
Share on other sites

That's bally impressive for a day's work...I doff my cap to you sir :)

 

You've set the ball rolling now of course, let's see how many entries we can get up to. I need to read up on some internal Atari trickery I think, to try and get my head round what you did there :)

 

I've had some ideas floating round my head for something scrolling...Is horizontal scrolling from Basic as easy as vertical?

Link to comment
Share on other sites

There is one last stick routine that is worth mentioning, using Atari Basic's capability of using a variable, exp<b></b>ression or function in a GOTO statement, and it avoids doing any evaluations completely, but will eat up more memory. It is however, very fast for Basic. This is for eight way movement, can be changed to suit for 4 way or accidental pushes to up/left or down/left:

 

 

That's cool

 

1 GOTO 20:REM Jumps over stick routine
5 X=X+1:Y=Y+1:RETURN
6 X=X+1:Y=Y-1:RETURN
7 X=X+1:RETURN
9 X=X-1:Y=Y+1:RETURN
10 X=X-1:Y=Y-1:RETURN
11 X=X-1:RETURN
13 Y=Y+1:RETURN
14 Y=Y-1:RETURN
15 RETURN
20 GOSUB STICK(0)
30 ...

 

Again, no sanity checking there, but you get the idea.

Link to comment
Share on other sites

That's bally impressive for a day's work...I doff my cap to you sir :)

 

You've set the ball rolling now of course, let's see how many entries we can get up to. I need to read up on some internal Atari trickery I think, to try and get my head round what you did there :)

 

There's not much trickery really, just a bit of abusing the display list; the scroller relies on that old chestnut of printing until you hit the bottom line of the screen and it being scrolled up (the look is based on a simple game called Road Vs Car written in 1983/4 by a school friend which i don't think he saved...) but there's a custom display list set up at the start which forces the standard screen to draw the second to bottom line of the screen first, then the one that's usually above it and so on until the top line (the very bottom line was skipped to avoid the flickering caused by printing/pushing and the title line added to make up the difference in display list length, it's )

 

I've had some ideas floating round my head for something scrolling...Is horizontal scrolling from Basic as easy as vertical?

 

i reckon the problem with horizontal scroll is going to either be getting new data into play or rewriting multiple LMS statements in the display list fast enough to avoid tearing. It should be possible over a limited vertical area but i'm not sure how much of an area will work...

Link to comment
Share on other sites

There is one last stick routine that is worth mentioning, using Atari Basic's capability of using a variable, expression or function in a GOTO statement, and it avoids doing any evaluations completely, but will eat up more memory. It is however, very fast for Basic. This is for eight way movement, can be changed to suit for 4 way or accidental pushes to up/left or down/left:

 

1 GOTO 20:REM Jumps over stick routine
5 X=X+1:Y=Y+1:RETURN
6 X=X+1:Y=Y-1:RETURN
7 X=X+1:RETURN
9 X=X-1:Y=Y+1:RETURN
10 X=X-1:Y=Y-1:RETURN
11 X=X-1:RETURN
13 Y=Y+1:RETURN
14 Y=Y-1:RETURN
15 RETURN
20 GOSUB STICK(0)
30 ...

 

Again, no sanity checking there, but you get the idea.

 

This is shorter:

 


10 s=stick(0)
20 x=x+(s>4 and s<8 )-(x>8 and X<12)
30 y=y+(s=5 or s=9 or s=13)-(s=6 or s=10 or s=14)

  • 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.

 

Assuming all FRE(0) sizes are measured in the same machine under the same hw/sw configuration , so this method is only valid for the final evaluation by the judge :)

Edited by atari8warez
Link to comment
Share on other sites

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

 

Find the ATASCII code and type the corresponding ASCII character in Notepad. Notepad++ is a free and open source alternative to Notepad that does a lot more for program coding in a text editor then does the Notepad

Edited by atari8warez
Link to comment
Share on other sites

One other trick you can use that does not involve machine code, is string offsets. You can take a string, mess around with it's entry in the variable name table, and set that string to reference any location in memory ... this trick is very useful for redefining a character set instantaneously, or manipulating sections of a screen or PMG's ... it's essentially like using a blitter when used in text mode.

 

I did a program called convert.bas which will take any file (like a font file, or machine obj code) and convert it into string assignments, and save the code to disk as a .LST file ... it's in this thread.

 

Cautions:

 

The string has to be the first variable declared in the program.

You cannot manipulate the string in immediate mode, or you will cause a system crash.

Link to comment
Share on other sites

On/goto or Goto Stick(0) has it's risks especially in emulation. You can't rely on only the 8 normal directions being generated, any combination 0-15 should be catered for.

 

Re shorter stick processing - PTRIG can help there, it's equivalent to left/right. So you could simply have e.g. X=X+PTRIG(1)-PTRIG(0)

Link to comment
Share on other sites

Okay, that's me done then. The game is called Stellar Caverns, the .BAS file is 3,209 bytes long and it's one of those "use PRINT to scroll" games where the player has to dodge the landscape. It uses PMGs (well, one player at least), a custom display list with split screen, has a little in-game sound... and it scrolls downwards!!

 

post-3086-0-33346300-1345316943_thumb.png

 

That was a giggle... although i was supposed to be working today and spent far too long on this. =-)

 

That's a damn good work for one day of coding :thumbsup:

Link to comment
Share on other sites

Assuming all FRE(0) sizes are measured in the same machine under the same hw/sw configuration , so this method is only valid for the final evaluation by the judge :)

 

Ooops actually, doing two FRE(0), one before and one after the program is loaded and taking the difference should work on any machine... Sorry Rybags, my fingers were working faster then my mind ;)

Edited by atari8warez
Link to comment
Share on other sites

I tend to stay away from gosub stick(0) or things like:

 

goto 200*(stick(0)=14)+300*(stick(0)=7) ... etc.

 

Reason being: When you use an expression in goto's and gosub's, it makes renumbering lines a pain in the arse. I generally tend to also work in TurboBASIC, and such expressions cause the program to not compile properly.

Link to comment
Share on other sites

tempted now...

 

can I even remember how to program in BASIC though?

 

EDIT: Starting to get the hang of this using the 'paste into Altirra' method. Nobody told me about those bloody error messages in Atari BASIC (or rather the lack of...)

Edited by sack-c0s
Link to comment
Share on other sites

tempted now...

 

can I even remember how to program in BASIC though?

 

EDIT: Starting to get the hang of this using the 'paste into Altirra' method. Nobody told me about those bloody error messages in Atari BASIC (or rather the lack of...)

 

Hint: Use TurboBASIC, but use only code which will work in Atari BASIC for compatibility reasons. Turbo gives you more legible error messages. :)

Link to comment
Share on other sites

I tend to stay away from gosub stick(0) or things like:

 

goto 200*(stick(0)=14)+300*(stick(0)=7) ... etc.

 

Reason being: When you use an expression in goto's and gosub's, it makes renumbering lines a pain in the arse. I generally tend to also work in TurboBASIC, and such expressions cause the program to not compile properly.

Generally I'd agree, but within the confines of this challenge, I'd say it's legit, as it's unlikely 4K of Basic will need renumbering, plus the target is Atari Basic, so speed is going to need to be balanced with size :)
Link to comment
Share on other sites

This is what just over 1K, about an hour of free time and 15 years without writing any BASIC gets you

post-3837-0-92010000-1345552500_thumb.png

 

It's a suprisingly hard language to return to when you've been away for so long and I can't say I miss it much

I do like a good Breakout clone; if it was only an hour and 1K of code up to now, that could be a hit :)
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...