20 Lines: Tetris

Discussion, Reviews & High-scores

Moderator: Moderators

Post Reply
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

20 Lines: Tetris

Post by ravenxau »

I didn't write it - but it does fit the critera

Code: Select all

1 REM PETRIS (C)2002 CURTIS F KAYLOR
2 T$="{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT} {RIGHT}{RIGHT} {RIGHT}{RIGHT}{RIGHT}  {RIGHT} {RIGHT}{RIGHT}{RIGHT} {RIGHT} {RIGHT}  {RIGHT}{RIGHT}    {RIGHT}{RIGHT}{RIGHT} {RIGHT}{RIGHT}  {RIGHT} {RIGHT} {RIGHT}    {RIGHT}{RIGHT}  {RIGHT}    {RIGHT}    "
3 DIMT$(15):FORI=0TO15:T$(I)=MID$(T$,4*I+1,4):NEXT:DIMB%(6,3,3):DIMP(23)
4 B$="DDDD@O@@DDDD@O@@@FDD@GA@@AAC@DG@@FBB@AG@@DDF@GD@@BFB@BG@@BCB@GB@@ACB@FC@"
5 B$=B$+"@ACB@FC@@DFB@CF@@DFB@CF@@FF@@FF@@FF@@FF@":FORI=0TO6:FORJ=0TO3:FORK=0TO3
6 Z=Z+1:B%(I,J,K)=ASC(MID$(B$,Z))AND15:NEXT:NEXT:NEXT:FORI=0TO19:P(I)=4097:NEXT:P(I)=8191
7 PRINT"{CLR}":FORI=0TO20:P=P(I):PRINT"{RVS ON}"T$(P/4096)T$(P/256AND15)T$(P/16AND15)T$(PAND15):NEXT
8 PRINT "{UP}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RVS ON}PETRIS";S
9 X=5:Y=0:B=7*RND(0):C=0:D=2:PRINT"{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{DOWN}";:R=1
10 IFRTHEND$="":FORI=0TO3:D$=D$+T$(B%(B,C,I))+"{DOWN}{LEFT}{LEFT}{LEFT}{LEFT}":NEXT:D$=D$+"{UP}{UP}{UP}{UP}"
11 PRINT CHR$(93*ABS(M)+64*M)"{RVS ON}";D$;:IF M+R THEN M=0:R=0:GOTO14
12 GET K$:M=(K$="{RIGHT}")-(K$="{DOWN}"):R=(K$=" "):IFMTHENX=X+M:GOSUB16:IFZTHENX=X-M:M=0
13 IFRTHENC=C-RAND3:GOSUB16:IFZTHENC=C+RAND3:R=0
14 IF M+R=0 THEN Y=Y+1:GOSUB16:IF Z THEN Y=Y-1:ONSGN(Y)GOTO17:END
15 PRINT"{RVS OFF}"D$;CHR$(-17*(M+R=0));:GOTO10
16 Z=0:T=2^X:FORI=0TO3:Z=Z+(P(Y+I)ANDB%(B,C,I)*T):NEXT:RETURN
17 A=0:FORI=0TO3:P(Y+I)=P(Y+I)ORB%(B,C,I)*T:IFP(Y+I)=8191ANDY+I<20THENGOSUB19
18 NEXT:ONDGOTO7,9
19 FORZ=Y+ITO1STEP-1:P(Z)=P(Z-1):NEXT:P(0)=4097:D=1:A=A+10:S=S+A:RETURN
Android Tablet running Frodo 64 emulator running VIC 20 emulator....
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Dude, can you post a PRG or something? Even after converting this to lowercase, I get SYNTAX errors pasting it into VICE... sigh. Some of the lines may have been crunched to fit.
High Scores, Links, and Jeff's Basic Games page.
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Post by ravenxau »

Jeff-20 wrote:Dude, can you post a PRG or something? Even after converting this to lowercase, I get SYNTAX errors pasting it into VICE... sigh. Some of the lines may have been crunched to fit.

try here :)

http://www.cling.gu.se/~cl3polof/miniga ... petris.zip

when loading in vice use load"petris.prg",8

do NOT include ,1 at the end
Android Tablet running Frodo 64 emulator running VIC 20 emulator....
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Wow.... I can't wrap my head around the code. This game is giving me an inferior complex! :lol:
High Scores, Links, and Jeff's Basic Games page.
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Post by ravenxau »

Jeff-20 wrote:Wow.... I can't wrap my head around the code. This game is giving me an inferior complex! :lol:
Yes to that! - I consider myself a reasonable coder (C++, VB.NET, ASP PHP, SQL and some simple 6502 Assembly), and i haven't been able to unravel the secrets of this gem :(
Android Tablet running Frodo 64 emulator running VIC 20 emulator....
DanSolo
Vic 20 Dabbler
Posts: 88
Joined: Sat Apr 21, 2007 5:22 am

Post by DanSolo »

Holy JC, lines 6 and 7 are the most divinely cryptic lines of code I've ever seen. Do they store the shapes of the various blocks in little 4x4 arrays?
gklinger
Vic 20 Elite
Posts: 2051
Joined: Tue Oct 03, 2006 1:39 am

Post by gklinger »

DanSolo wrote:Do they store the shapes of the various blocks in little 4x4 arrays?
Ask Curtis directly. :)
In the end it will be as if nothing ever happened.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

It might be useful to point out Petris was part of the 2002 MiniGame Compo. As far as I know it is written to be runnable on any Commodore computer with Microsoft Basic, i.e. from PET 2001 to C128, perhaps even C65.
Anders Carlsson

Image Image Image Image Image
ravenxau
Vic 20 Devotee
Posts: 296
Joined: Fri May 28, 2004 10:03 pm

Post by ravenxau »

carlsson wrote:It might be useful to point out Petris was part of the 2002 MiniGame Compo. As far as I know it is written to be runnable on any Commodore computer with Microsoft Basic, i.e. from PET 2001 to C128, perhaps even C65.
you are correct - I myself have run it on three different commodore platforms.
Android Tablet running Frodo 64 emulator running VIC 20 emulator....
Post Reply