Jump to content
IGNORED

BASIC 10 Liner Contest 2021


carlsson

Recommended Posts

13 hours ago, AMSDOS said:

the same person wrote 'Silo' which looks appealing too, but I can't seem to read VIC-20 BASIC

Ok, since the source code was posted, I made an attempt to interpret it. I didn't study the game mechanics in detail, only the particularities of this dialect to help you.

 

 

Line 1: CLR clears variables (which is automatic by RUN so a waste of 4 characters). I would rather do POKE56,28 to prevent custom characters from being overwritten by (string) variables but probably it doesn't use that many variables.

 

The PRINT statement is a clever way to put binary data on the screen (address 7680 and onwards) which is later used to copy it into custom characters (address 7168).
F=30720 equals the difference between colour memory (38400) and screen (7680) and is often used in order to quickly add colours to screen.
FOR I=0 TO 39 obviously defines 40/8 = 5 custom characters, and then defines a blank space at (7424 - 7168)/8 = 32, i.e. space.

Line 2: B$ defines the graphic, five yellow A characters and a red @ (which look different after redefining the graphics)
S is the loop delay which doesn't seem to decrease at any point.
V=36876 equals the treble register in the sound portion. Sounds are played in the value range 128-255. V+2 = 36878 sets the volume to max.

Line 3: POKE 36879,8 sets the background and border both to black.
POKE 36869,255 enables custom characters (at 7168). You still get to access ROM characters by enabling reverse mode, which explains why some text is printed in reverse mode.
The symbols for {clear} screen, cursor {down}, {white} text etc should be fairly self explanatory. Worth remembering is that the VIC-20 screen is 22 columns x 23 rows.

Line 4: B is set to 7745 (rightmost column on line 3, because 7745 - 7680 = 65 and 22 columns per row) + another 21 columns + random number of rows. The value 2 is a redefined B and the colour 3 is cyan. In a similar fashion, the position 7708 (second row, 6th character) is set to a white, redefined C which seems to be static?

Line 5: The screen position B-1 is read, position B is set to space etc. If B-1 held a @ character, both positions B and P are cleared.

Line 6: A sound effect that goes from highest to lowest (and below playable range) is played on treble register 36876. Then the keyboard buffer is cleared (POKE 198,0) and the program waits for a keypress (WAIT 198,1) before the game restarts.

Line 7: PEEK(197) reads the character buffer. It returns 64 if no key is pressed, so as soon as any key is pressed, it branches to line 9.

Line 8: Besides the POKEs to graphics and colour memory, it also branches if no key is pressed: A$="" returns -1, so it inverts that value to have ON x GOTO work. If a key was pressed, G=1 and it branches anyway.

Actually I believe Rainer could have rewritten that as:
GET A$:G=SGN(G-(A$="")):GOTO5
but remember that in VIC/Microsoft BASIC, true = -1 while it is 1 in Atari BASIC.

Line 9-10: Draws a graphic effect on every row (step 22).

 

Edited by carlsson
  • Like 2
Link to comment
Share on other sites

 

 Discussion on bitwise operators inspired me to try illustrating them on the Atari 2600 with the print command :) 

 

The print command in SuperCharger BASIC prints binary strings to the Television screen for visualizing bitwise transformations or for game design.

 

It's interesting that the + and - operators can also be leveraged as bitwise operators in BASIC provided the target bits they act on are set from the first bitwise op as in the two examples in lines 10 and 30.

5 rem Fun with SuperCharger BASIC on the Atari 2600! 
7 rem using the BASIC print command with binary strings
8 rem to print output to the screen using the 
9 rem bitwise operators & and, ^ xor, | or , + plus, - minus
10 i=%11111111 & %00001111 + %00100000:rem expect 00101111
20 k=%11111111 | %00001111:rem expect 11111111
30 j=%11111111 ^ %00001111 - %01000000:rem expect 10110000
40 l=%11111111
50 print i(virtualworld,1)
60 print k(virtualworld,13)
70 print j(virtualworld,25):print l(virtualworld,37)
90 vwpixel(13,1,flip):rem flip or set a single pixel
100 if g=0 then g=1:scrollvirtualworldtoggle=1

 

SuperCharger_BASIC_print_command_with_bitwise_operators_Atari_2600.JPG.7f83c729f586cc2347eee88dcdd51df0.JPG

 

Link to comment
Share on other sites

@carlsson Appreciate the help, I found an online vic-20 emulator, so I'll "try" typing it in. I don't understand the graphical definitions which seem to take place on the 1st line, though obviously I can see the graphics which take place within the game, so I can redefine on my machine accordingly, though this can be a small project I can do after the contest is over.

Link to comment
Share on other sites

{cm f*3} means hold down the C= key and press F three times. {sh asterisk} means hold down Shift key and press *. You have the colours {blk} {wht} {red} {cyn} {pur} {grn} {blu} {yel} by holding down the CTRL key and pressing numbers 1-8. {reverse on} is CTRL-9, {reverse off} is CTRL-0.

 

Most probably you will need to abbreviate most keywords, e.g. ? for PRINT, pO for POKE, nE for NEXT, tH for THEN, gO for GOTO etc.

Edited by carlsson
Link to comment
Share on other sites

Educational walk through of SUPERBLITZ game entry features and visual effects

 

Hoping to inspire more Atari 2600 10 line BASIC games for 2021! :)  

 

 

There are only two small rem statements in the code but SuperCharger BASIC is a very verbose classic BASIC with listings that are easy to understand.

 

Biggest drawback to writing 10 liners in SuperCharger BASIC is that only one if-then-else statement is allowed per line and some language intrinsics take up many precious characters. 

 

Biggest feature is probably the Camera object; a soft ANTIC that is very easy for A8 programmers to conceptualize and control transparently setting x,y coordinates in BASIC:

Figure2_VirtualWorld.jpg.c6b8e4eb1c08dc5f45a73d8b8356e279.jpg  

SUPERBLITZ uses the camera in simple mode to pan the entire screen, but a8 coders will like the display lists where horizontal sections of the screen can be split into multiple camera zones and scrolled independently.

 rem ----------------------------------------------------------------------------
 rem --- SUPERBLITZ Throttle Control 3/2021 
 rem --- basic10liner.com competition verison 
 rem --- Waves and Missions                 
 rem ----------------------------------------------------------------------------
 rem --- Insignia on Plane revealed after Night Mission is completed! 
 rem --- Multiple Waves over differently colored Sky's and Cities
 rem --- More optical illusions: Some color combinations create unreal artifacting such as textured bricks -
 rem --- complete several rounds and describe what you encounter!
 rem --- note: Classic hardware and a CRT required to experience artifacting textures and additional illusions
 rem --- unique features - you control your speed and difficulty increases as you play
 rem --- BW switch pegs the throttle (Advanced) 
 rem --- Each wave achieved keeps it's colors in Attract mode! 
 rem --- Unlimited continues until powering off the console!

0 data city 5,9,6,9,7,6,7,5,9,5,5,5,5,6,6,7,5,8,5,8,7,5,8,8,5,5,6,6,7,5,7,8,9,8,8,7,8,9,5,6,8,5,9,6,6,7,5,7,5,5,8,5
1 if g=0 or CXP0FB>126 then CXCLR=0:for j=0 to 9:player1(j)=189:player0(j)=pl(j):rowcolors(j)=178+w:next j else goto 3
2 for j=20 to 71:k=j-20:k=city(k):for i=k to 9:vwpixel(j,i,on):next i,j:player0y=96:player0x=84:y=11:g=1:w=16*z
3 if f<player0y/52 and joy0right=0 and SWCHB|247=255 then f=f+1:goto 9 else AUDC1=7:AUDF1=BITIndex/5:AUDV1=BITIndex:f=0
4 AUDV0=f:scrollvirtualworldtoggle=1:BITIndex=BITIndex+1:missile0x=missile0x+2:data pl 0,224,127,231,252,192,128,0
5 if joy0fire=1 and y>8 then AUDF0=12:AUDC0=9:SUSTAINFORFRAMES=7:x=BITIndex+9:i=96-player0y:i=i/10:y=1+i:remPlayahTune 
6 if y<10 then vwpixel(x,y,bindplayer1):COLUP1=M(y):y=y+1:data M 122,138,12,170,154,250,234,218,202,186,42,58,74,28   
7 if y<10 and vwpixel(x,y,poll)>0 then vwpixel(x,y,flip):player1x=0:player1y=0:AUDC0=y:y=21:AUDF0=4:AUDV0=15:rem Hit! 
8 if BITIndex>71 then BITIndex=0:player0y=player0y-2 else missile1x=missile1x+1:missile1y=missile1y+3:rem SUPERBLITZ 86
9 if player0y=0 then g=0:player0colors(3)=14:player0colors(4)=112+z:COLUBK=M(z)-10:z=z+1 else missile0y=missile0y+2

The interesting optical illusion that you control with the throttle is designed for CRT, but it can be seen on LCD if you fully maximize the screen:
(For Stella emulation turn off phosphor and merge frames as well)

 

Try SUPERBLITZ online in Javatari!

 

  • Like 4
Link to comment
Share on other sites

3 hours ago, Mr SQL said:

Biggest drawback to writing 10 liners in SuperCharger BASIC is that only one if-then-else statement is allowed per line and some language intrinsics take up many precious characters. 

If SuperCharger BASIC has WHILE...WEND statements, then it should be possible to replace IF-THEN-ELSE, as we discussed earlier. I was using f=0:WHILE <condition> AND (f=0): <code to perform if condition's true>:f=1:WEND, however carlsson's suggestion with f=0:WHILE <condition>*(f-1):<code to perform if condition's true>:f=1:WEND is a few characters shorter and with a name like SuperCharger BASIC, I'm assuming slowdown would be minimal.

  • Like 1
Link to comment
Share on other sites

1 hour ago, AMSDOS said:

If SuperCharger BASIC has WHILE...WEND statements, then it should be possible to replace IF-THEN-ELSE, as we discussed earlier. I was using f=0:WHILE <condition> AND (f=0): <code to perform if condition's true>:f=1:WEND, however carlsson's suggestion with f=0:WHILE <condition>*(f-1):<code to perform if condition's true>:f=1:WEND is a few characters shorter and with a name like SuperCharger BASIC, I'm assuming slowdown would be minimal.

Great question! There are no while/wend statements but goto can be used in an if-then-else statement block to turn it into a while. line 3 is doing this:

3 if f<player0y/52 and joy0right=0 and SWCHB|247=255 then f=f+1:goto 9 else AUDC1=7:AUDF1=BITIndex/5:AUDV1=BITIndex:f=0

It will continue to increment f and jump to line 9 while all conditions are met but once f reaches the threshold (or other conditions are met) f is reset by the second statement block and code execution falls through to run the rest of the code.

  • Like 1
Link to comment
Share on other sites

In one of my Atari BASIC tenliners, I didn't use any of the IF-THEN, IF-GOTO, ON-GOTO, ON-GOSUB, GOTO or GOSUB statements, and all the flow was controlled by FOR-NEXT loops simulating REPEAT-UNTIL structured statements in a way I previously said in this thread, with all the conditions put inside expressions for assignments. Line numbers were irrelevant for the game logic.

 

Spoiler

I included this source listing to show the nested FOR-NEXT loops, but as all statements are abbreviated, it might seem senseless.

 

UFOATAK.LST.png

 

The full and indented listing is in its page (with comments):  UFO Attack!

 

  • Like 1
Link to comment
Share on other sites

I hadn't considered FOR..NEXT loops for conditioning as I normally found them to have a need to enter into the loop at least once, where's if a condition for a WHILE..WEND isn't true, it jumps the loop, though it might have some application.

I'm assuming the Supercharger BASIC won't allow IF <condition> THEN <dothis> ELSE IF <condition2> THEN <dothat>, which can be handy if you need to carry out different things on the same line, for example:

'sel=1' THEN <dothis> ELSE IF 'sel=2' THEN <dothat> 

  • Like 1
Link to comment
Share on other sites

If anyone cares, @dmsc is about to release a new version of Fastbasic, and he is requesting for testers in another thread.

 

The new features include parameters for subroutines.  Well, Fastbasic does not require line numbers or labels because it does not use GOTO or GOSUB... instead you can define procedures, and they can accept parameters for simpliticy of coding, because they are just a quick way to assign values to the same global variables.

 

Again, Fastbasic uses structured programming statements, and FOR-NEXT, WHILE-WEND, REPEAT-UNTIL and DO-LOOP are available for loops of any kind.

 

  • Like 1
Link to comment
Share on other sites

There already is a german type-in listing named "Hubert" - a Q-Bert clone.
http://a8.fandal.cz/detail.php?files_id=6955
http://www.mushca.com/f/atari/index.php?dl=347|HUBEBERT
http://ataribasiclistings.mygamesonline.org/Homecomputer/Homecomputer_1986.7z
Released 1986 in the german Homecomputer magazine. Maybe you can name your version Ben-10, errmmm, Hubert 10 ?
 
 
My grandfather's name was Edbert. It's funny because back in the 80's i always called qbert "edbert" because I just thought it was funny. I offer the name up here as another possibility. :)

Sent from my E6533 using Tapatalk

Link to comment
Share on other sites

In one of my Atari BASIC tenliners, I didn't use any of the IF-THEN, IF-GOTO, ON-GOTO, ON-GOSUB, GOTO or GOSUB statements, and all the flow was controlled by FOR-NEXT loops simulating REPEAT-UNTIL structured statements in a way I previously said in this thread, with all the conditions put inside expressions for assignments. Line numbers were irrelevant for the game logic.   Spoiler  

 

 

I included this source listing to show the nested FOR-NEXT loops, but as all statements are abbreviated, it might seem senseless.

 

UFOATAK.LST.png

 

The full and indented listing is in its page (with comments):  UFO Attack!

 

 

 

 

 

 

 

 

 

 

The game I'm working on intentionally exploits the atari basic trap statement as a controlled branch operation. Under the right circumstances it's great and only takes up 3 characters of code! i.e. TRAP 4 is abbreviated as T.4

 

 

It can replace if statements, argument evaluations, and goto operations, all in one whack and only use 3 characters of code.

 

Bonus is that it behaves more like an object because trap is event driven. So once you define it, the branch-action will occur if an error happens until you redefine it with another trap statement.

 

 

 

Sent from my E6533 using Tapatalk

 

 

 

 

 

 

 

 

 

  • Like 3
Link to comment
Share on other sites

Earlier I was trying to return a sequence of random numbers, which returns a result of either 1 or -1. Eventually I worked out if numbers were 1 or 0, I could NOT result-(result*3), so if result is 0, after applying the NOT on it, -1 is resulted because NOT 0 becomes -1 and 0*3=0. Otherwise if result is 1, after applying the NOT on it -2 result produced and 1*3 = 3, so the equation becomes 3-2 to return 1.

 

I tried looking for a problem like this on Rosetta Code, but I'm unsure they have tackled this problem, it would seem to be an useful one if a variable needed to alternate between an positive and negetative number without resorting with IF statements to change between 1 and -1.

Link to comment
Share on other sites

13 minutes ago, AMSDOS said:

Earlier I was trying to return a sequence of random numbers, which returns a result of either 1 or -1. Eventually I worked out if numbers were 1 or 0, I could NOT result-(result*3), so if result is 0, after applying the NOT on it, -1 is resulted because NOT 0 becomes -1 and 0*3=0. Otherwise if result is 1, after applying the NOT on it -2 result produced and 1*3 = 3, so the equation becomes 3-2 to return 1.

 

I tried looking for a problem like this on Rosetta Code, but I'm unsure they have tackled this problem, it would seem to be an useful one if a variable needed to alternate between an positive and negetative number without resorting with IF statements to change between 1 and -1.

how about A=(A=1)-(A=0)  ?

 

  • Like 2
Link to comment
Share on other sites

Talking about 10 liners, here's something silly I did that I thought I'd share for the heck of it...

 

I took my PUR-80 BASIC entry from last year called "Palisade", which was written in pure Atari Basic of course, and I ported it straight over to assembly.

 

I didn't change any logic really, just ported it over operation by operation.   I just did this as an exercise, and because I was curious as to how it would compare with the Atari Basic version. 

 

So check out the PALIS-ML.XEX file for the executable. 

 

NOTE: The only notable "feature" I added to this version is that between games, BEFORE you press fire to start a new game, you can press the joystick left or right(and then press fire) to speed up or slow down the next game when it begins. 

 

Also attaching the original Atari Basic version as well so you can also compare the two versions yourself. 

 

I know, kind of silly, but that's why I am sharing it.  It was an interesting exercise.

 

-Eric

 

 

 

PALIS-ML.xex PALISADE.LIS

  • Like 1
Link to comment
Share on other sites

25 minutes ago, Preppie said:

To swap between a positive and negative just use A=-A

 

 

Although I really don't understand what the orignal poster was trying to say :)

 

 

I was saying to produce a series Random Numbers between 1 and -1, there would have to be a process or altering a value to generate an -1 or 1, so if Random generates an 1, A=1 and it then becomes an -1 and the result is 0. However, if Random generates an 0, A=0 and it then becomes an -0 and -1 is the result. I don't know why, since 0 = 0, result should be 0.

 

Though the point I was trying to make out, is it's not possible to generate a negetative (-1) or positive (1) from a single Random Function. It's possible to have a range of 2 and to subtract 1 from that, which would be generate values (-1,0,1), though in my case I needed the results to be -1 or 1 (no zero's allowed).

Link to comment
Share on other sites

1 minute ago, AMSDOS said:

t's not possible to generate a negetative (-1) or positive (1) from a single Random Function

Hm? I would do this (Microsoft syntax, so your RND may differ).

 

A = -1 + INT(RND(1)*2)*2

 

INT(RND(1)*2) will generate 0 or 1, multiplied by two to make it 0 or 2, subtract 1 to make it -1 or 1.

  • Like 1
Link to comment
Share on other sites

I can generate 0 or 1, though that's as far as I could get, I then need to A=A*2 to get values of 0 or 2 and -1 to have A=A*2-1 to get that. Looks as if my system needs to store a value into a variable from the RND function, before proceeding with A=A*2-1 to get values of 1 or -1.

Link to comment
Share on other sites

That is curious. Which system are you developing for, again? Also does RND(1) generate a floating point number of an integer? Does RND(2) generate something else? I understand that the RND syntax is different for each BASIC dialect so you need to know how yours works.

 

Edit: Does AMS refer to the Amstrad CPC? I managed to get it to work as a single liner in the WinAPE emulator?

Edited by carlsson
Link to comment
Share on other sites

Hi!

 

6 hours ago, AMSDOS said:

Earlier I was trying to return a sequence of random numbers, which returns a result of either 1 or -1. Eventually I worked out if numbers were 1 or 0, I could NOT result-(result*3), so if result is 0, after applying the NOT on it, -1 is resulted because NOT 0 becomes -1 and 0*3=0. Otherwise if result is 1, after applying the NOT on it -2 result produced and 1*3 = 3, so the equation becomes 3-2 to return 1.

 

I tried looking for a problem like this on Rosetta Code, but I'm unsure they have tackled this problem, it would seem to be an useful one if a variable needed to alternate between an positive and negetative number without resorting with IF statements to change between 1 and -1.

 

Those are shorter:

 

Atari BASIC A = (RND(0)<.5)*2-1
FastBasic A = RAND(2)*2-1
FastBasic abbreviated A=2*R.2-1
Microsoft BASIC (C64)

A = (RND(1)<.5)*2+1

Microsoft BASIC (Atari)

A = RND(2)*2-3

 

Have Fun!

 

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

15 hours ago, carlsson said:

Hm? I would do this (Microsoft syntax, so your RND may differ).

 

A = -1 + INT(RND(1)*2)*2

 

INT(RND(1)*2) will generate 0 or 1, multiplied by two to make it 0 or 2, subtract 1 to make it -1 or 1.

That's a good one!  It works in Atari Basic too.

 

Put the -1 at the end and you can even save another character!  :)

A=INT(RND(1)*2)*2-1

Link to comment
Share on other sites

12 hours ago, dmsc said:

Hi!

 

 

Those are shorter:

 

Atari BASIC A = (RND(0)<.5)*2-1
FastBasic A = RAND(2)*2-1
FastBasic abbreviated A=2*R.2-1
Microsoft BASIC (C64)

A = (RND(1)<.5)*2+1

Microsoft BASIC (Atari)

A = RND(2)*2-3

 

Have Fun!

 

Yep, i think we have a winner in Atari Basic, A=(RND(0)<.5)*2-1 is definitely faster and a couple characters shorter than anything else I've tried.  Nice one!

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