"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 two bytes short of maximum length when tokenised, and so very hard to type in. The solution to this is to type it in as several lines and with a few spaces so it gets correctly tokenised, the run a little bit of code which peeks and pokes the tokenised program code to remove the spaces and join the lines together. This might seem like cheating, but it was fairly common for one-line BBC BASIC programs pre-dating Rheolism.
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.
Anyway, here is V3.0 (which is a byte shorter than the V2.0 and two bytes shorter than V1.0):
| Extra Rheolism - a one line Tetris game *BASIC 0MO.9:OFF:GC.-9:CLG:REP.s=s+VP.:P.CHR$30s:REP.SYS6,135TOi,p,d:P.TAB(p=0)CHR$9;: 1IFPOS=22V.3100;VP. 21;6667;:U.0EL.U.VP.=25:v=ABSRND MOD7:V.31:C.3: 2REP.m=9-INKEY(INKEYTRUE OR6)MOD3:F.r=TRUE TO1:t=r A.SGNt: 3IFt=r C.v-15:V.r EORm:i+=m=7A.9-6*r:IF0EL.F.n=0TO11:d=n DIV3OR2EORd:V.d: 4IF1<<(n+i)MOD12A.&C2590EC DIV8^v A.975t+=PO.p*POS,31-VP.<<5):IFr V.p,8:IF0EL. 5N.,:V.20:U.t*LOGm:U.VP.=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;VPOS21;6667;:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:VDU 31:COLOUR3:REPEATm=9-INKEY(INKEYTRUEOR6)MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOUR v-15:VDUrEORm:i+=m=7AND9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF1<<(n+i)MOD 12AND&C2590ECDIV8^vAND975t+=POINT(p*POS,31-VPOS<<5):IFrVDUp,8:IF0ELSENEXT,:VDU20 :UNTILt*LOGm:UNTILVPOS=3:Z
If you're unfortunate enough not to have access to a real RISC OS machine, you can try out Extra Rheolism emulated in your browser.
You can look at the code by hitting "Escape" (or letting the playing area
fill up), then LIST
to show the program. RUN
will
start a new game.
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 (TAB(x)
when
x
< 0 being a no-op) which doesn't work on a BBC Micro - there
TAB(x)
seems to implicitly perform TAB(x AND255)
.
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
This works on the original BBC Model B, but not on a BBC Master - the reason is that the latter predefines 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.
The missing features in this original version compared to the RISC OS version of Extra Rheolism were:
OFF:
) but in BBC BASIC II that requires VDU279;0;0;0;0;
- this can be combined with an existing VDU
statement,
but it still would add 12 bytes. Or it could be crowbarred onto the
PRINT
for the score in 9 bytes:
CHR$23CHR$1CHR$0SPC7
(which would execute it for each new
piece but that's harmless really), or done via poking OS workspace in 8 bytes: ?584=20:
. We can't use VDU5
here
(which would only need 2 bytes if done via an existing VDU
or PRINT
statement) as we make extensive use of the text
cursor.
:Z
to cause "Mistake" to be printed would
work, but there aren't two spare bytes.
364780
instead of &C2590EC
).
I gave a short talk at WOSSAT in February 2020 about this: Another Brick in the Wall. [VIDEO] (youtube)
In January 2025 I spotted some ways to shave off enough bytes to support all 7 block shapes, add the end of game message, and restore the original scoring system:
I also replaced 1E3 with 999 which is the same code size but a little bit faster while still meaning we check a pixel in the same character cell, and 11,26 with 6667; which has the same effect but is also a little faster.
The BBC version is now much closer to the RISC OS version but it still lacks turning the cursor off and the drop key.
Here is V3.0 which is the maximum BBC BASIC line length:
0MODE2:GCOL0,-9:CLG:A%=135:d=9:REPEATs=s+VPOS:PRINTCHR$30s:REPEATIFUSR-12ANDHIME MPRINT:UNTIL0ELSEVDU9:IFLOGPOSVDU28;VPOS9ABSTRUE6667;:UNTIL0ELSEUNTILVPOS=26:v=s MOD7:VDU31,5,4:REPEATm=9-INKEY0MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOURv-15:VDUr EORm:IFm=7I%=I%+9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF2^((n+I%)MOD12)AND &C2590ECDIV8^vAND975t=t+POINT(64*POS,999-VPOS*32):IFrVDU32,8:IF0ELSENEXT,:VDU20: UNTILt*LOGm:UNTILVPOS=4:Z
Click here to play in Owlet. Note you need to click on the right pane to give it focus for keypresses to go to the emulator. Multiple key-sets are supported, but e.g. "4" and "6" shift left and right while "5" rotates. Owlet doesn't currently hook up jsbeeb's sound so you'll have to imagine the amazing sound effect.
The editor pane shows the code before it has been packed into one line - you can
see the one line version which you are actually playing 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.
If you wish the BBC Micro version had squarer blocks and feel it is too colourful then you should try this MODE1 variant (MODE1 is a 4 colour mode so there are only 3 foreground colours to use for blocks): Click to play variant version in Owlet.
Last updated 2025-01-15 <olly@survex.com>