"I do believe that he takes too much pride in the brevity of his work" - Mr. Talbot, my geography teacher at age 14
Rheolism is a one-line BBC BASIC V Tetris game. It was written by David Moore and Martin Hollis (with assistance from me), after Martin bet David he couldn't do it.
Extra Rheolism is my enhanced version, which fixes two bugs in the original, and implements the following additional features:
The game features multiple key-sets. Either shift is the drop key, and for example '4', '5', and '6' work as left, rotate and right.
This version has been play-tested on an ARM3 A440, with the cache on and off, and the speed chosen accordingly. If you want to change the speed, alter the 6 in the INKEY on line 4, but remember it can only be a single digit. It should be compatible with RISC OS 2 and RISC OS 3. It will run on a Risc PC without modification, provided your monitor can display MODE 9.
The one line is a byte short of maximum length when tokenised, and so very hard to type in. Hence, it is distributed in the form of a file which should be *Exec-ed. If your WWW viewer allows, cut out the listing and save it, set the filetype to 'Command' and double-click on it. This produces the one line BASIC program, so save it and start playing!
If you want to edit it, I suggest you keep the Command file, as neither the Basic Editor nor !Zap are very happy about the BASIC version.
I'd be very interested if anyone can save 2 more bytes (not including removing 'OFF:' or ':Z') as I have a mechanism for making the game get gradually faster that is quite playable and needs 7 more bytes.
Anyway, here is V2.0 (which is a byte shorter than the V1.0):
| Extra Rheolism - a one line Tetris game *BASIC 0MODE9:OFF:GCOL-9:CLG:REPEATs=s+VPOS:PRINTCHR$30s: 1REPEATSYS6,135TOi,p,d:PRINTTAB(p=0)CHR$9;: 2IF POS=22 VDU3100;VPOS,21;6667;:UNTIL0 ELSE UNTILVPOS=25: 3v=ABSRND MOD7:VDU31:COLOUR3: 4REPEATm=9-INKEY(INKEYTRUE OR 6)MOD3: 5FORr=TRUE TO1:t=r ANDSGNt: 6IFt=r COLOURv-15:VDUr EORm:i+=m=7AND9-6*r:IF0ELSE 7FORn=0TO11:d=n DIV3OR2EORd:VDUd: 8IF1<<(n+i)MOD12AND&C2590EC DIV8^v AND975 t+=POINT(p*POS,31-VPOS<<5):IFr VDUp,8:IF0ELSE 9NEXT,:VDU20:UNTILt*LOGm:UNTILVPOS=3:Z b=PA.+4:F.a=b TOTOP:?b=?a:b=b-(?b<>32):a=a-4*(a?1=13):N. ?(PA.+3)=b:!b=&FF0D
And here's what it looks like as one line, wrapped at 80 columns:
0MODE9:OFF:GCOL-9:CLG:REPEATs=s+VPOS:PRINTCHR$30s:REPEATSYS6,135TOi,p,d:PRINTTAB (p=0)CHR$9;:IFPOS=22VDU3100;VPOS,21;6667;:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:VD U31:COLOUR3:REPEATm=9-INKEY(INKEYTRUEOR6)MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOU Rv-15:VDUrEORm:i+=m=7AND9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF1<<(n+i)MO D12AND&C2590ECDIV8^vAND975t+=POINT(p*POS,31-VPOS<<5):IFrVDUp,8:IF0ELSENEXT,:VDU2 0:UNTILt*LOGm:UNTILVPOS=3:Z
I gave a talk at OSDC 2011 about this: The Art of Writing Small Programs. [VIDEO] (youtube)
David Moore has written an excellent explanation of how Extra Rheolism works.
In early 2020 I came across the marvellous jsbeeb which provides a cycle-accurate emulation of a BBC micro in the browser. My first thought on seeing it was whether I could get a version of Extra Rheolism working on it.
David discussed some of the additional challenges this adds to the mix. He makes an attempt but it is too long to fit in a single line, yet lacks some features compared to even the original Rheolism (for example, the game never actually ends but instead draws new shapes on top of each over forever).
The BBC BASIC V on RISC OS added a number of additional features over BBC BASIC
II on the BBC micro and Rheolism and Extra Rheolism rely on a number of these.
There's also one quirk exploited by Extra Rheolism (
x < 0 being a no-op) which doesn't work on a BBC Micro - there
TAB(x) seems to implicitly perform
After a lot of experimentation I managed to get a working version. This even includes scoring (using a different scoring mechanism). Here's what it looks like, again wrapped at 80 columns:
0MODE2:GCOL0,-9:CLG:A%=135:d=9:TIME=0:REPEATPRINTCHR$30TIME:REPEATIFUSR-12AND819 2PRINT:UNTIL0ELSEVDU9:IFLOGPOSVDU28;VPOS,9,1,11,26:UNTIL0ELSEUNTILVPOS=26:v=3AND RND:i=0:VDU31,5,4:REPEATm=9-INKEY0MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOURv-15:V DUrEORm:IFm=7i=i+9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF2^((n+i)MOD12)AND 364780DIV8^vAND975t=t+POINT(64*POS,1E3-VPOS*32):IFrVDU32,8:IF0ELSENEXT,:VDU20:UN TILt*LOGm:UNTILVPOS=4
The missing features compared to the RISC OS version of Extra Rheolism are:
OFF:) but in BBC BASIC II that requires
VDU279;0;0;0;0;- this can be combined with an existing
VDUstatement, but it still would add 12 bytes. Or it could be crowbarred onto the
CHR$23CHR$1CHR$0SPC7(which would execute it for each new piece but that's harmless really.) We can't use
VDU5here (which would only need 2 bytes if done via an existing
:Zto cause "Mistake" to be printed would work, but there aren't any spare bytes.
The scoring code uses 7 bytes, so could be traded for a full set of block shapes and an end of game message, plus 2 spare bytes.
This works on the original BBC Model B, but not on a BBC Master - the reason is that the latter defines character 255 as a solid block so when we read a character from the screen we get 255 instead of 0 when there's a block.
Click here to play in jsbeeb. Multiple key-sets are supported, but e.g. "4" and "6" shift left and right while "5" rotates.
You can look at the code by hitting "Escape", then
MODE7 to switch
to a more readable screen mode and
LIST to show the program.
RUN will start a new game.
I gave a short talk at WOSSAT in February 2020 about this: Another Brick in the Wall. [VIDEO] (youtube)Last updated 2020-07-13 <email@example.com>