2k adventure

Discussion about ZX80 / ZX81 Software
Crayon21
Posts: 75
Joined: Sun Nov 04, 2018 2:33 am

Re: 2k adventure

Post by Crayon21 » Thu Nov 22, 2018 9:10 pm

I'll check the download later good sir, having thanksgiving in a bit. Enjoy your day :D
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

User avatar
siggi
Posts: 882
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: 2k adventure

Post by siggi » Fri Nov 23, 2018 9:10 am

TMAOne wrote:
Thu Nov 22, 2018 8:03 pm
I started my program on a "Sinclair Diet", but I don't think I'm going to make the 2K finish line without some major loss of functionality,
Without losing functionality a lot of bytes can be lost ;)
Replace
if condition1 then PRINT string1
if condition2 then PRINT string2
by
print string1 AND condtion1; string 2 AND condition2

Replace
GOTO 140
by
GOTO VAL "140"
Yes, the destination of a GOTO/GOSUB may be a numeric expression. You could also GOTO SIN PI ;)

And for the final version (keep a "full" version" as backup): delete the variable initialization inside the BASIC program an hold only the initialized variables in ram:
- delete line 20
- GOTO 1000 (initialize variables)
- delete lines 1000 ff
- GOTO 0 (save the program and initialized variables in RAM)

Later, if you want to restart OR MODIFY the final version: never use CLEAR or RUN (to keep the variables valid).
If you forget that: go back to the full version (backup)

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
TMAOne
Posts: 164
Joined: Thu Aug 16, 2012 6:56 pm
Location: Waterloo, Ontario, Canada

Re: 2k adventure

Post by TMAOne » Fri Nov 23, 2018 9:37 pm

Thank-you Siggi. That helped a lot!

Success. It took some more crash dieting, but it now fits in an un-expanded Timex-Sinclair 1000 with the core game intact.

Code: Select all

  10 SAVE "ADV2k"
  60 PRINT "YOU ARE IN ";R$(R),"THERE IS ";O$(R),,,"YOU CAN GO:",,(N$ AND R<V3),,(S$ AND R<V4),,(E$ AND R=V4),,(W$ AND R=V2)
 100 INPUT A$
 110 CLS
 120 IF R<>V1 OR L=V1 OR A$<>"LAMP" THEN GOTO VAL "160"
 130 PRINT "YOU HAVE ";O$(R),"AND CAN BARELY SEE ";O$(V2);"TO THE ";N$,,,,
 140 LET L=V1
 150 LET O$(R)=Z$
 160 IF R<>V2 OR S=V1 OR A$<>"SWORD" THEN GOTO VAL "200"
 170 PRINT "YOU CLUTCH ";O$(R),,,
 180 LET S=V1
 190 LET O$(R)=Z$
 200 IF R<>V3 OR T=V1 OR A$<>"TREASURE" THEN GOTO VAL "240"
 210 PRINT "YOU TAKE ";O$(R),,,
 220 LET T=V1
 230 LET O$(V3)=Z$
 240 IF R<>V2 OR A$<>W$ OR P=V1 OR L=V1 THEN GOTO VAL "270"
 250 PRINT "IN THE DARK YOU CANT SEE ",O$(V4),," AND YOU ARE INJURED",,,
 260 LET P=V1
 270 IF A$=S$ AND R=V1 THEN GOTO VAL "330"
 280 IF A$=N$ AND R<V3 THEN LET R=R+V1
 290 IF A$=S$ AND R<V4 THEN LET R=R-V1
 300 IF A$=W$ AND R=V2 THEN LET R=V4
 310 IF A$=E$ AND R=V4 THEN LET R=V2
 320 GOTO VAL "30"
 330 PRINT "YOU ESCAPE THE CAVE",,,
 350 PRINT "YOU HAVE THE TREASURE" AND T=V1;AT V3,V0;"YOU WIELD THE MAGIC SWORD" AND S=V1;AT VAL "5",V0;"BUT YOU ARE INJURED" AND P=V1
ADV2K.p
(1.91 KiB) Downloaded 69 times

Another trick I found useful is to use the BASIC keyword within strings whenever possible. I'm sure you guys know this,... but for those that don't, the keyword AND for instance, takes up only 1 byte and gives you " AND " (space, AND, space) within your string, saving 4 bytes.

And thank-you Crayon21 for the initial idea to try to fit in 2K. I hope I haven't stolen your thunder. It's not a great game, but 2K is 2K.

Ian

Crayon21
Posts: 75
Joined: Sun Nov 04, 2018 2:33 am

Re: 2k adventure

Post by Crayon21 » Sun Nov 25, 2018 6:35 pm

it's cool. feel free to expand on it, my work on it is done :D but make sure to give me proper credit, k?
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

User avatar
TMAOne
Posts: 164
Joined: Thu Aug 16, 2012 6:56 pm
Location: Waterloo, Ontario, Canada

Re: 2k adventure

Post by TMAOne » Sun Nov 25, 2018 7:38 pm

I won't be expanding it. As a 2K Adventure game it was a development novelty only--a fun exercise in coding.

A full-RAM version with more rooms and features would require a redesign of some of the compromises to make to fit into 2K, and Adventure games abound in the wilds. (I think the one I posted in this thread is particularly nice, but I'm biased.)

I do credit you Crayon21 with coming up with the challenge of fitting a BASIC Adventure style game into an un-expanded TS1000. That was key for me. It was a neat idea that started me thinking in Sinclair BASIC again.

No one however, is ever going to beat that kid, (I think he was 16?) who created 1KCHESS. Just incredible,...

Keep coding Crayon21. Arrays and loops are your friends. Your game would do better with more RAM available. Cheers.

Ian

Moggy
Posts: 1826
Joined: Wed Jun 18, 2008 2:00 pm

Re: 2k adventure

Post by Moggy » Sun Nov 25, 2018 10:56 pm

TMAOne wrote:
Sun Nov 25, 2018 7:38 pm
I won't be expanding it. As a 2K Adventure game it was a development novelty only--a fun exercise in coding.

A full-RAM version with more rooms and features would require a redesign of some of the compromises to make to fit into 2K, and Adventure games abound in the wilds. (I think the one I posted in this thread is particularly nice, but I'm biased.)

I do credit you Crayon21 with coming up with the challenge of fitting a BASIC Adventure style game into an un-expanded TS1000. That was key for me. It was a neat idea that started me thinking in Sinclair BASIC again.

No one however, is ever going to beat that kid, (I think he was 16?) who created 1KCHESS. Just incredible,...

Keep coding Crayon21. Arrays and loops are your friends. Your game would do better with more RAM available. Cheers.

Ian
I'm sure David Horne was a lot older than 16 when he wrote 1k chess.

You might want to have a look at this thread about a full FIDE(castling, en passent and under-promotion) 1k chess for the 80 and 81 which is far superior to the original, innovative though it was at the time.

viewtopic.php?f=6&t=1841&p=18959&hilit= ... x81#p18959

Shaun_B
Posts: 451
Joined: Wed Apr 22, 2009 10:22 am

Re: 2k adventure

Post by Shaun_B » Thu Jan 03, 2019 2:24 pm

XavSnap wrote:
Thu Nov 22, 2018 6:38 am

Code: Select all

     1 LET R=PI/PI
     5 LET L=NOT R
    10 LET Q=NOT PI/PI
    20 PRINT ,,("YOU ARE IN A CAVE." AND R=1);(" IN THE CAVE  IS A LAMP" AND NOT L AND R=1);(" LAMP TAKEN, YOU CAN NOW SEE FURTHER." AND L=1 AND R=1);(" THE CAVE IS NOW BRIGHT AND YOU CAN SEE THE TREASURE I THE DISTANCE" AND L=1 AND R=1);("TRAP SPRUNG. YOU ARE NOW ONE LEVEL BELOW THE TREASURE." AND R=2);(" THERE IS A LAMP HERE TO REPLACE THE BROKEN ONE" AND R=2 AND NOT L);("YOU CAN GO EAST, WEST OR NORTH" AND R=3 AND L);("YOU GO NORTH AND FIND YOUR WAY  BACK.YOU HAVE TAKEN THE TREASURE,YAY" AND R=4);("YOU TAKE THE TREASURE AND HEAD  OUT OF THE CAVE" AND R=5)
    25 IF R=5 THEN STOP
    30 INPUT A$
    40 IF (R=PI/PI OR R=2) AND A$="GET LAMP" THEN LET L=PI/PI
    50 IF L AND R=1 AND A$="NORTH" THEN LET Q=PI/PI
    60 IF Q THEN LET R=2
    70 IF Q THEN LET L=NOT Q
    80 IF (L AND R=2)OR(R=3) AND A$="NORTH" THEN LET R=R+PI/PI
    100 IF R=4 AND A$="SOUTH" THEN LET R=5
    110 CLS
    120 GOTO 10
2KADV.P

Have fun!
I made a version based on this one, with small amends to the grammar it's under 900 bytes saved. Do not RUN it or you will lose some of the var stack.

Regards,

Shaun.
Attachments
2KADV.P
(869 Bytes) Downloaded 55 times

Post Reply