Summer 2007 programming challenge: 358 bytes of Basic V2!

Basic and Machine Language

Moderator: Moderators

Post Reply
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Summer 2007 programming challenge: 358 bytes of Basic V2!

Post by Boray »

I felt for a little programming challenge. 3583 BYTES FREE? That's too much. 1/10 of that sounds like a nice challenge I think. ;) Write something (anything really) in just 358 bytes of basic code. (The .prg file can be at most 360 bytes). The program should run on a vic-20. Memory expansions and disk drives are allowed but not basic extensions.

If you have no web space, you can mail it to me at Image

Have fun!
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Demo? Game? Anything?
High Scores, Links, and Jeff's Basic Games page.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

358 bytes of anything. That's the idea. :D
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Boing

Post by Boray »

Boing

Download:
http://user.tninet.se/~pug510w/datormuseum/boing.zip

Programmed on a real PAL vic-20. Runs in both unexpanded and expanded mode.

The NTSC version is tested in VICE only.


PAL version:

Code: Select all

0 X=36864:Y=X+1:V=X+14:L=V-4:A=8:B=10:Q=1:W=1:POKEV+1,8
1 PRINT"{CLR}{GRN}BY ANDERS PERSSON 2007{DOWN} 358 BYTES CHALLENGE"
2 FORT=1TO900:POKEV,9:POKEV,0:NEXT
3 PRINT"{CLR}  {C=-@}{C=-P}{C=-@}  {RVS ON}{SH-POUND}     {C=-*}        BORAY        {RVS OFF}{C=-*}{RVS ON}     {RVS OFF}{SH-POUND}  {C=-T}{C=-Y}{C=-T}":POKEY+1,(PEEK(Y+1)AND128)+7
6 A=A+Q:IFA<8ORA>47THENQ=-Q:POKEV,7:POKEL,180
7 B=B+W*(B/10):IFB>130THENW=-W:H=15:S=130
8 POKEL,S:IFB<9THENB=9:W=-W
10 POKEV,H:IFH>0THENH=H-1:S=S+1
11 POKEY,B:POKEX,A:GOTO6

NTSC version

Code: Select all

0 X=36864:Y=X+1:V=X+14:L=V-4:A=8:B=10:Q=1:W=1:POKEV+1,8
1 PRINT"{CLR}{GRN}BY ANDERS PERSSON 2007{DOWN} 358 BYTES CHALLENGE"
2 FORT=1TO900:POKEV,9:POKEV,0:NEXT
3 PRINT"{CLR}  {C=-@}{C=-P}{C=-@}  {RVS ON}{SH-POUND}     {C=-*}        BORAY        {RVS OFF}{C=-*}{RVS ON}     {RVS OFF}{SH-POUND}  {C=-T}{C=-Y}{C=-T}":POKEY+1,(PEEK(Y+1)AND128)+7
6 A=A+Q:IFA<4ORA>37THENQ=-Q:POKEV,7:POKEL,180
7 B=B+W*(B/10):IFB>100THENW=-W:H=15:S=130
8 POKEL,S:IFB<8THENB=8:W=-W
10 POKEV,H:IFH>0THENH=H-1:S=S+1
11 POKEY,B:POKEX,A:GOTO6
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

C64

The c64 is now also included in the challenge.
( http://folkvagn.commodore64.org/phpbb/v ... hp?p=14987 )

The basic is exactly the same, so why not! Make your choice, vic-20 or 64. Just as long as you only use Basic V2 and the prg file not is bigger than 360 bytes.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

If you want to check if your program is within the limit:

On a vic-20 write
CLR:PRINT FRE(0)
...and you will get the number of free bytes. On an unexpanded vic-20, this value can't be lower than 3225.

On a c64:
CLR:PRINT FRE(0)-(FRE(0)<0)*65536
...This value can't be lower than 38553.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

My second 358 byte program:

PrgInfo

Download:
http://user.tninet.se/~pug510w/datormuseum/prginfo.zip

That's right, it's a 358 byte version of this program:
http://user.tninet.se/~pug510w/datormuseum/prginfo.html

Should run on any Commodore 8-bit computer.

Code: Select all

3 INPUT"FILE";F$:OPEN1,8,0,F$:GET#1,A$,B$:IFST<>0THENPRINT"ERROR":CLOSE1:END
4 IFA$<>""THENA=ASC(A$)
6 CLOSE1:A=A+ASC(B$)*256:PRINT"{DOWN}ADDRESS"A"{DOWN}"
9 READB,B$:IFB=0THENPRINT"???":END
12 IFA<>BTHEN9
18 PRINTB$:DATA4097,VIC20 UNEXP /PLUS4,1025,VIC+3K,4609,EXPANDED VIC
21 DATA2049,C64,7169,C128,40960,VIC BL5,24576,VIC BL3,16384,VIC BL2
24 DATA8192,VIC BL1,45056,VIC BL5,28672,VIC BL3,20480,VIC BL2,12288,VIC BL1,0,0
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Re: Summer 2007 programming challenge: 358 bytes of Basic V2

Post by ravenxau »

Boray wrote:I felt for a little programming challenge. 3583 BYTES FREE? That's too much. 1/10 of that sounds like a nice challenge I think.

cool - kinda like the 256 byte demo scene for the pc - but specially adapted for the vic (or c64). I'm in - just gotta come up with a good idea now :D
User avatar
Mike
Herr VC
Posts: 4838
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

BASIC auto-tokenizer for SEQ files

Post by Mike »

My entry. Around 150-160 bytes (depending on the filename used):

Code: Select all

63996 POKE812,238:OPEN2,8,2,"FILE,S,R"
63997 PRINT"{CLR}";:IFST<>0THENPOKE812,239:CLOSE2:END
63998 GET#2,A$:PRINTA$;:IFA$<>CHR$(13)THEN63998
63999 PRINT"GOTO63997":POKE631,19:POKE632,13:POKE633,13:POKE198,3
this is (more or less) the inverse to:

Code: Select all

OPEN2,8,2,"FILE,S,W":CMD2:LIST
PRINT#2:CLOSE2
only that the appended 'READY.' will disturb the program a little bit. Just type in a final 'GOTO63997' to cleanly end the process.

Michael

Edit: corrected a small typo
Last edited by Mike on Thu Aug 30, 2007 9:34 am, edited 1 time in total.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Mike, I tried your program in VICE and nothing happens?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Mike
Herr VC
Posts: 4838
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Erm, I could say the same about PrgInfo, where I'm just prompted with 'FILE?', and a blinking cursor. (Hint: :wink:)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

You mean I should input something?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Mike
Herr VC
Posts: 4838
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Yes. Preferably you should make available a SEQ file named "FILE", that contains a PETSCII program listing. Or any other name, if you alter the OPEN command in line 63996.

As an example, construct the file "FILE" as follows:

Code: Select all

10 OPEN2,8,2,"FILE,S,W"
15 PRINT#2,"1 PRINT"+CHR$(34)+"VC20"+CHR$(34)+";"
20 PRINT#2,"2 GOTO 1"
25 CLOSE2
1. RUN this program. After this, there will be the file "FILE" on disc, SEQ type.
2. Enter NEW to prepare for the next program.
3. Then type in my 4-liner, enter RUN again. The SEQ file will be read in, and tokenized. Afterwards, you may delete the lines 63996-63999.
4. Enter RUN a third time to start Example 1 of the User's guide.

(methinks there are no dumb questions, only dumb answers...)

Hope that helps,

Michael
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Aha! ok... thanks...

Reminds me of my "datamaker" program: http://user.tninet.se/~pug510w/datormus ... maker.html
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Post Reply