• Commodore Free, Issue 67 - Part6

    From Stephen Walsh@39:901/281 to all on Thu Feb 14 22:33:04 2013
    irst might save some
    character space in the second line as well.

    I've attached one of my favourites from when I was a child: it fills the
    screen with what appears to be a random maze (and keeps going until Run/Stop
    is pressed). This will work on the VIC and C64, but you can change the colour randomiser to the 16 available from the C64 by changing the value POKEd to 646 (you can use 16 on the VIC, but it switches to multi-colour mode above 8 if I recall). Can anyone do better...? I'm sure that they can.

    Anyway, for anyone who's interested, there is some BASIC compatibility between the C64 and VIC-20, but you get 88 characters on the VIC and 80 on the C64.
    So, you could write your two liner on the VIC and load it into the C64. Also, remember the short cuts to get more characters per line, like ? is PRINT, P shifted O is POKE etc... This will mean you can break the 80 character limit anyway.

    Regards,
    Shaun.

    0 poke646,rnd(1)*8:printchr$(205.4+rnd(1);:run

    Attached are some more 'one liners': a dual scrolly for the VIC-20 and two
    for the C64 using different methods.

    To load into the C64 (because they were written on the VIC), you need to
    LOAD "DUAL SCROLLY C64",8,0

    COMMODORE FREE: After a few emails we have ..................


    *************************************
    COMMODORE FREE
    ONE-LINERS COMPETITION
    *************************************

    Back in the 1980s, I used to love programming my Commodore 64. I wasn't brilliant, but I could do a bit and, as always, my Mum was impressed. Fast forward to 2009 and I needed a change in career, so I thought that I might be able to cut it as a developer, even though I hadn't done any real programming since the 1990s, so I headed to do a Foundation Degree and to learn all about 'coding' again.

    Fast forward again to late 2012 and I recalled some BASIC one-liners that I used to love writing on my Commodore - the best one of them all was this
    little beauty:

    0 print chr$(205.5+rnd(.));:goto

    Many of you may remember this, as it was, unless my memory has failed me, listed in the VIC-20 user manual. A similar listing was also in the Commodore 64 equivalent. So, I contacted Nigel about having a Commodore BASIC one-liner competition. As it happens, one-liners were not just on my mind, as there's been a book published about it. Have a look here: 10print.org. It also happens that the book's authors favourite mystical one line on Commodore BASIC is also mine, although the version above is more efficient than theirs is.

    Anyway, to celebrate the publication of the book, and just for a bit of fun
    for those who like programming in BASIC or other high-level languages, let's have a one-liner competition! In fact, because Commodore BASIC 2.0 does not allow so many characters per line (80 on the C64 and 88 on the VIC-20), there'll be two main categories: One-liners and two-liners. There are restrictions on the latter (more on the rules in a moment), but the extra line will at least allow you to set up any variables and functions, with the rest
    of the logic free to run in the second line, presumably until there's a stop condition to drop out of the program.

    A pro-tip is to use BASIC 2 keywords only and write your program on the Commodore 128, saving it and loading it in on a C64 (or 64 mode), VIC-20 or anything that will be able to read the disk. If you have trouble, remember to load the file name like this:

    LOAD "MYPRG",8,0

    This will force the program to load into the area reserved for BASIC programs.

    Also, because using the 128 should allow you to get something playable, and of course, you could do a BASIC 7 entry, if you wanted, using the more logical DO WHILE loops and IF ELSE IF conditions that are used a lot in languages like C (or at least, I use them a lot). Please give as much information about your entries as possible: Where did you get the idea? How did you create your program (on a C64 using BASIC 2, or emulator using BASIC 7 etc)? Is it platform-specific? Or will it work on any popular Commodore 8-bit, such as the Commodore 16 as well as the C64? The more information you provide, the better.

    Let's have a look at some examples to get you started (which are available in
    a D64 image).

    - - - - - - - - - - - - - - - - - - -

    PROGRAM ONE: DUAL SCROLLY VIC

    This is VIC-20 specific version, written in BASIC 7 to get more text into my message using WinVICE. This displays an 'animated scrolling marquee', as it's known nowadays, or a scrolly text to everyone over the age of 30, which will print out the first 22 characters of the message and then shift each byte in the string one place to the left beforeadding the first character to the end
    of the variable A$. The contents of the top row are copied to the bottom row
    of the screen by reading each position of the top line and POKEing the values to the bottom, also changing the colour attributes there, for a bit of
    variety. Then it'll check if any key has been pressed, and if not will loop around to line 1. Simple, eh? Here's the source code of the listing, noting that any special characters are in curly braces { }. Also be aware that spaces are added here to make each listing more readable. Adding spaces will... err.. take up unnecessary space in your submission unless you need them (for instance, within a string or something). Be aware that there is no closing quotation mark on the string in line zero as this is not required by BASIC and saves you one whole character as well. Remember to use BASIC 2.0 keyword abbreviations if you're using BASIC 7 to write your programmes as this will allow even more commands or data to fit into one line.

    0 print "{CLEAR}" : s = 8164 : c = 38
    884 : a$ = " 'one line' dual scroll
    y by Donkeysoft for commodore free.
    hello to nigel, wayne, chris c16, a
    llan. vic 20 rulez! www.commodorefr
    ee.com
    1 a$ = right$( a$, 138 ) + left$( a$,
    1 ): print "{HOME}" left$( a$, 22 )
    : for i = 0 to 21 : poke c + i, 0 :
    poke s + i, peek( 7680+i ) : next :
    get b$ : if b$ = "" then 1

    - - - - - - - - - - - - - - - - - - -

    PROGRAM TWO : DUAL SCROLLY C64

    This is written in BASIC 7 (using only BASIC 2 keywords with abbreviations, of course), which allowed a longer scrolly message than usual. The top line is inverse video, and a copy of this is printed to the last-but-one row. It stops with a key-press or a RUN/STOP key as there's no attempt at protection here. Note that there's no closing quotation mark on the string in line zero as it's not needed as the string declaration has no other commands after it. Have a look at the listing and experiment.

    0 print "{CLEAR}" : a$ = " c64 dual s
    crolly 'one liner' for commodore fr
    ee. hi nigelp2k, tmr, chris c16 & a
    llan. www.commodorefree.com submit
    your own examples to us :-)
    1 a$ = right$( a$, 150 ) + left$( a$,
    1 ) : print "{HOME}{REVERSE ON}" le
    ft( a$, 40 ) : for i = 0 to 20 : pr
    int : next : print"{REVERSE OFF}" l
    eft$( a$, 40 );: get b$ : if b$ = "
    " goto 1

    - - - - - - - - - - - - - - - - - - -

    PROGRAM THREE : DUAL SCROLL2 C64

    Similar to the example above, and again written in BASIC 7 to get a longer scrolly message, but takes a copy of the message from the top of the screen by POKEing each byte to the corresponding position on the bottom row.

    0 print "{CLEAR}" : a$ = " c64 dual s
    crolly 'one liner' for commodore fr
    ee. hi nigelp2k, tmr, chris c16. ww
    w.commodorefree.com - can you do be
    tter than this? give it a go =-)
    1 a$ = right$( a$, 151 ) + left$( a$,
    1 ) : print "{HOME}{CYAN}"left( a$,
    40 ) : for i = 0 to 40 : poke 1984
    + i, peek( 1024 + i ) : next : get
    b$ : if b$ = "" goto 1

    - - - - - - - - - - - - - - - - - - -

    PROGRAM FOUR: COLOUR MAZE1 VIC

    This is the first variant of the randomly scrolling labyrinth that the book mentioned above is based upon. This is a genuine BASIC 2 entry, which will select a random colour for each diagonal
    --- CrashWrite 2.0
    * Origin: --:)-- Dragon's Lair BBS --(:- (39:901/281)