Can't make anything fit into 1K... or is it me?

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Can't make anything fit into 1K... or is it me?

Post by XavSnap »

Code: Select all

IF X=Q THEN PRINT AT R,P+W;"O"
 IF X=W OR X=E THEN PRINT AT E,P+Q;"O";AT T,P+E;"O"
 IF X=E THEN PRINT AT R,P+W;"O"
 IF X=R OR X=T THEN PRINT AT E,P+Q;"O O";AT T,P+Q;"O O"
 IF X=T THEN PRINT AT R,P+W;"O"
 IF X=Y THEN PRINT AT E,P+Q;"OOO";AT T,P+Q;"OOO" 
equal

Code: Select all

PRINT AT R,P+W;"O" AND X=Q;AT E,P+Q;"O";AT T,P+E;"O" AND (X=W OR X=E);AT R,P+W;"O" AND X=E;AT E,P+Q;"O O";AT T,P+Q;"O O" AND (X=R OR X=T);AT R,P+W;"O" AND X=T;AT E,P+Q;"OOO";AT T,P+Q;"OOO" AND X=Y
another very good emulator
:shock:
:lol:
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Can't make anything fit into 1K... or is it me?

Post by 1024MAK »

This program shows how small the program has to be if you use a large amount of the screen (and hence the display file becomes large):

Code: Select all

1 PRINT CHR$ (RND*25+38);
2 IF PEEK 16442=INT PI THEN GOSUB 9
3 GOTO SGN PI
9 SCROLL
10 SCROLL
11 PRINT AT 19,SGN PI;
12 RETURN
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
LoadError
Posts: 22
Joined: Thu Apr 29, 2021 12:45 pm

Re: Can't make anything fit into 1K... or is it me?

Post by LoadError »

That part of the code scratches die #2 when not needed, so I kept it in.
The variables are used multiple times.
Thanks for all the hints! I was even able to put "FG SOFT" back in :D
My Sinclair belongings:
- unexpanded, unmodified, unbackporched ZX81
- expanded (from 16K to 48K) rubber keyed ZX Spectrum
- a Cambridge Scientific pocket calculator
User avatar
LoadError
Posts: 22
Joined: Thu Apr 29, 2021 12:45 pm

Re: Can't make anything fit into 1K... or is it me?

Post by LoadError »

XavSnap wrote: Sun May 02, 2021 6:33 pm

Code: Select all

IF X=Q THEN PRINT AT R,P+W;"O"
 IF X=W OR X=E THEN PRINT AT E,P+Q;"O";AT T,P+E;"O"
 IF X=E THEN PRINT AT R,P+W;"O"
 IF X=R OR X=T THEN PRINT AT E,P+Q;"O O";AT T,P+Q;"O O"
 IF X=T THEN PRINT AT R,P+W;"O"
 IF X=Y THEN PRINT AT E,P+Q;"OOO";AT T,P+Q;"OOO" 
equal

Code: Select all

PRINT AT R,P+W;"O" AND X=Q;AT E,P+Q;"O";AT T,P+E;"O" AND (X=W OR X=E);AT R,P+W;"O" AND X=E;AT E,P+Q;"O O";AT T,P+Q;"O O" AND (X=R OR X=T);AT R,P+W;"O" AND X=T;AT E,P+Q;"OOO";AT T,P+Q;"OOO" AND X=Y
This is neat! Very different from the Commodore dialect I'm used to.
My Sinclair belongings:
- unexpanded, unmodified, unbackporched ZX81
- expanded (from 16K to 48K) rubber keyed ZX Spectrum
- a Cambridge Scientific pocket calculator
bola_dor
Posts: 398
Joined: Wed Oct 02, 2019 5:32 am

Re: Can't make anything fit into 1K... or is it me?

Post by bola_dor »

LoadError wrote: Sun May 02, 2021 7:49 pm That part of the code scratches die #2 when not needed, so I kept it in.
The variables are used multiple times.
Thanks for all the hints! I was even able to put "FG SOFT" back in :D
Yes I felt sorry for that..
Perhaps you can recover some animation in the larger version..
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come :D
User avatar
LoadError
Posts: 22
Joined: Thu Apr 29, 2021 12:45 pm

Re: Can't make anything fit into 1K... or is it me?

Post by LoadError »

Yes, I was able to also add the animation back!
Maybe I'll post it in the "crap games" cathegory :lol:
By the way, I'm happy. Now if I only could make my real ZX81 display an image on a TV...
My Sinclair belongings:
- unexpanded, unmodified, unbackporched ZX81
- expanded (from 16K to 48K) rubber keyed ZX Spectrum
- a Cambridge Scientific pocket calculator
bola_dor
Posts: 398
Joined: Wed Oct 02, 2019 5:32 am

Re: Can't make anything fit into 1K... or is it me?

Post by bola_dor »

Look at MAK1024 signature for his buffer composite mod.. it's really good and works. Unless you have an older non back porch ULA
Ernesto
ZX80 USA, ZX81UK, ZX Spectrum, ZX Spectrum+, ZX Spectrum 128+ UK, ZX Spectrum +2/A, Sinclair QL, CZ1000, CZ1500, CZ2000, CZ1000Plus, CZ1500Plus, CZ Spectrum, CZ Spectrum Plus, TK83, TK85, TK90X, TK95. TS2068. And more to come :D
User avatar
LoadError
Posts: 22
Joined: Thu Apr 29, 2021 12:45 pm

Re: Can't make anything fit into 1K... or is it me?

Post by LoadError »

XavSnap wrote: Sun May 02, 2021 6:33 pm

Code: Select all

IF X=Q THEN PRINT AT R,P+W;"O"
 IF X=W OR X=E THEN PRINT AT E,P+Q;"O";AT T,P+E;"O"
 IF X=E THEN PRINT AT R,P+W;"O"
 IF X=R OR X=T THEN PRINT AT E,P+Q;"O O";AT T,P+Q;"O O"
 IF X=T THEN PRINT AT R,P+W;"O"
 IF X=Y THEN PRINT AT E,P+Q;"OOO";AT T,P+Q;"OOO" 
equal

Code: Select all

PRINT AT R,P+W;"O" AND X=Q;AT E,P+Q;"O";AT T,P+E;"O" AND (X=W OR X=E);AT R,P+W;"O" AND X=E;AT E,P+Q;"O O";AT T,P+Q;"O O" AND (X=R OR X=T);AT R,P+W;"O" AND X=T;AT E,P+Q;"OOO";AT T,P+Q;"OOO" AND X=Y
Actually, I've done some tests and the two codes do not appear to be equivalent.
See this example:

print at 1,1;"o" and x=1;at 0,0;"o";at 2,2;"o" and x=2

This results in "o" being printed at 1,1 if x=1 (correct); in "o" at 0,0 being *always* printed regardless of if x is 1 or 2 (unwanted); and in "o" at 2,2 being printed if x=2 (correct).
So the second AND boolean only validates the third "print at" (2,2) and not the second (0,0) which is always validated.
So it should be:

print at 1,1;"o" and x=1;at 0,0;"o" and x=2;at 2,2;"o" and x=2

and then it would be equivalent to

if x=1 then print at 1,1;"o"
if x=2 then print at 0,0;"o";at 2,2;"o"

Still, 7 bytes less so maybe worth it.
My Sinclair belongings:
- unexpanded, unmodified, unbackporched ZX81
- expanded (from 16K to 48K) rubber keyed ZX Spectrum
- a Cambridge Scientific pocket calculator
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Can't make anything fit into 1K... or is it me?

Post by XavSnap »

:oops:

It's true, this boolean graphics conditions are use block by block.

IF X=Y THEN PRINT AT E,P+Q;"OOO";AT T,P+Q;"OOO"

IF X=Y THEN PRINT (AT E,P+Q;"OOO");(AT T,P+Q;"OOO")

…;AT E,P+Q;"OOO" AND X=Y ;AT T,P+Q;"OOO" AND X=Y;...

Somes conditions have been forgotten in the previous example !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
LoadError
Posts: 22
Joined: Thu Apr 29, 2021 12:45 pm

Re: Can't make anything fit into 1K... or is it me?

Post by LoadError »

I've just finished porting my dice program to the ZX80, or should I say "rewriting". The '81 version is centered around the PRINT AT instruction which is missing in the '80, so I had to rethink the whole thing. I'm happy with the result (I just stripped down the animations because they would not make sense on a ZX80 anyway). I guess the fact that the '80 BASIC is integer only did help though, because I had no problems making it fit in 1K without the tricks I had to use on the 81 (like replacing numbers with integer variables). The only problem now is: I WANT A ZX80! That's about as hardcore as it gets, this side of an Altair 8800! :lol:
My Sinclair belongings:
- unexpanded, unmodified, unbackporched ZX81
- expanded (from 16K to 48K) rubber keyed ZX Spectrum
- a Cambridge Scientific pocket calculator
Post Reply