2k adventure

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

2k adventure

Post by Crayon21 »

this is a new game I made utilizing just 2k of ram. enjoy. it's supposed to be short as I am still getting used to the BASIC on the zx81 though any tips to improve it would be nice
Attachments
2k adventure.tzx
(991 Bytes) Downloaded 277 times
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
TMAOne
Posts: 212
Joined: Thu Aug 16, 2012 6:56 pm
Location: Waterloo, Ontario, Canada

Re: 2k adventure

Post by TMAOne »

Wow, that's a pretty high hurdle you've set yourself to. Adventure in 2K,... not easy. :D
Crayon21
Posts: 346
Joined: Sun Nov 04, 2018 2:33 am

Re: 2k adventure

Post by Crayon21 »

TMAOne wrote: Mon Nov 19, 2018 11:19 pm Wow, that's a pretty high hurdle you've set yourself to. Adventure in 2K,... not easy. :D
I honestly can't tell whether that's sarcasm or appreciation :?:
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
TMAOne
Posts: 212
Joined: Thu Aug 16, 2012 6:56 pm
Location: Waterloo, Ontario, Canada

Re: 2k adventure

Post by TMAOne »

Crayon21 wrote: Tue Nov 20, 2018 1:15 am I honestly can't tell whether that's sarcasm or appreciation :?:
Oh it was meant as applause for tackling a difficult project, definitely. Text is a bear when it comes to RAM, and 2K is not much for any code, let alone an adventure game. I think it's an intriguing prospect. How good can you make it, given the core limitation? I'm sure the guys will chime in with some suggestions. By way of apology for being ambiguous, I'll start,...

The first thing I would do is set up strings for NORTH, SOUTH, etc. You can then reuse the reference, and test IF A$=N$ for movement, etc. You can initialize the strings with direct commands, saving program space.

Strings variables apparently take less room than literals in the code itself. One trick is to initialize string variables (even if they don't need to be "variable") with direct commands, and then reference them in the code, like PRINT W$ instead of PRINT "WHATEVER". A disadvantage of all this is you cannot then execute a CLEAR or RUN. You must GOTO 1 instead to start the program.

Hopefully someone more knowledgeable than I, (or with a copy of The Explorer's Guide to the ZX81 close at hand), can explain, but I think it boils down to the fact that the computer sets up a pointer for any literal referenced in a program statement, to the statement itself, and the pointer is less efficient than an entry in the variables table. And even the quotes themselves cost two bytes.

You definitely want to get rid of the REM statement complaining that memory is getting low. That costs quite a few bytes right there, and serves no real purpose I can see. And if you make the first line 10 SAVE "2K ADVENTURE", you don't have to worry about CLEAR or RUN wiping out your variables--the program will just fall through and execute.

But anyway, congratulations for coming up with a unique learning exercise that hopefully will help you acquire a lot of skill with ZX81 Basic and the tactics of surviving on very little RAM.

Ian
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: 2k adventure

Post by XavSnap »

If A$="HELLO" (30 INPUT A$), we got the lamp !
Is it normal?

Just get a 16k ram pack on your TS1000...

Code: Select all

# REM 2K ADVENTURE
    10  REM [HEX:\
1E,30,00,26,29,3B,2A,33,\
39,3A,37,2A ]

    20 PRINT "YOU ARE IN A CAVE. IN THE CAVE IS A LAMP"
    30 INPUT A$
    40 IF A$="GET LAMP"  THEN GOTO 45
    45 PRINT "LAMP TAKEN, YOU CAN NOW SEE FURTHER"
    50 PRINT "THE CAVE IS NOW BRIGHT AND YOU CAN SEE THE TREASURE I THE DISTANCE"
    55 LET T=TREASURE
    56 LET TT=TRAP
    57 INPUT A$
    58 IF A$="GO NORTH"  THEN LET TT=1
    59 PRINT "TRAP SPRUNG. YOU ARE NOW ONE LEVEL BELOW THE TREASURE. THERE IS A LAMP HERE TO REPLACE THE BROKEN ONE"
    60 INPUT A$
    61 IF A$="TAKE LAMP"  THEN GOTO 45
    62 PRINT "YOU CAN GO EAST, WEST OR NORTH"
    63 INPUT A$
    64 IF A$="NORTH" THEN GOTO 66 

# REM 2K GETTING FULL
    65  REM [HEX:\
1E,30,00,2C,2A,39,39,2E,\
33,2C,00,2B,3A,31,31 ]

    66 PRINT "YOU GO NORTH AND FIND YOUR WAY BACK. YOU HAVE TAKEN TE TREASURE,YAY"
    67 IF A$="SOUTH"  THEN GOTO 77
    76 INPUT A$
    77 PRINT "YOU TAKE THE TREASURE AND HEAD OUT OF THE CAVE"
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Crayon21
Posts: 346
Joined: Sun Nov 04, 2018 2:33 am

Re: 2k adventure

Post by Crayon21 »

I would but the blinking problem for any line past 67 is so annoying, I have to stop around 60 or so.
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
Crayon21
Posts: 346
Joined: Sun Nov 04, 2018 2:33 am

Re: 2k adventure

Post by Crayon21 »

TMAOne wrote: Tue Nov 20, 2018 3:44 am
Crayon21 wrote: Tue Nov 20, 2018 1:15 am I honestly can't tell whether that's sarcasm or appreciation :?:
Oh it was meant as applause for tackling a difficult project, definitely. Text is a bear when it comes to RAM, and 2K is not much for any code, let alone an adventure game. I think it's an intriguing prospect. How good can you make it, given the core limitation? I'm sure the guys will chime in with some suggestions. By way of apology for being ambiguous, I'll start,...

The first thing I would do is set up strings for NORTH, SOUTH, etc. You can then reuse the reference, and test IF A$=N$ for movement, etc. You can initialize the strings with direct commands, saving program space.

Strings variables apparently take less room than literals in the code itself. One trick is to initialize string variables (even if they don't need to be "variable") with direct commands, and then reference them in the code, like PRINT W$ instead of PRINT "WHATEVER". A disadvantage of all this is you cannot then execute a CLEAR or RUN. You must GOTO 1 instead to start the program.

Hopefully someone more knowledgeable than I, (or with a copy of The Explorer's Guide to the ZX81 close at hand), can explain, but I think it boils down to the fact that the computer sets up a pointer for any literal referenced in a program statement, to the statement itself, and the pointer is less efficient than an entry in the variables table. And even the quotes themselves cost two bytes.

You definitely want to get rid of the REM statement complaining that memory is getting low. That costs quite a few bytes right there, and serves no real purpose I can see. And if you make the first line 10 SAVE "2K ADVENTURE", you don't have to worry about CLEAR or RUN wiping out your variables--the program will just fall through and execute.

But anyway, congratulations for coming up with a unique learning exercise that hopefully will help you acquire a lot of skill with ZX81 Basic and the tactics of surviving on very little RAM.

Ian
I also read the machine code articles for the zx81 and need the basic equivalent of LDIR, ADD and RET, if you could help with that, I'd be grateful
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
TMAOne
Posts: 212
Joined: Thu Aug 16, 2012 6:56 pm
Location: Waterloo, Ontario, Canada

Re: 2k adventure

Post by TMAOne »

Crayon21 wrote: Tue Nov 20, 2018 5:39 am I also read the machine code articles for the zx81 and need the basic equivalent of LDIR, ADD and RET, if you could help with that, I'd be grateful
Hmm. Not sure where you're going with this, and I'm not terribly Z80 assembler literate, but I'll take a poke at it. (Whoops,... THAT was a poor choice of words! :lol: )

With respect to ADD, doing math in Basic is just a matter of using another LET statement, eg. LET TOTAL=SUBTOTAL+TAX, or LET A=A+1. The RET equivalent (to come back from a GOSUB) is RETURN. [I have no idea if I'm answering your real questions or not.] LDIR is tougher. What are you trying to do?

As for the "blinking problem", by which I assume you mean the system repainting the screen over and over when you cursor down line by line, the easier way is to LIST your way through the program. eg. LIST 100 will start at line 100, and put the cursor on that line should you want to EDIT it.

XavSnap is quite right--there are logic holes and bumps in the code as it stands now. I assumed it was a work-in-progress and still a living breathing creature.
Lardo Boffin
Posts: 2160
Joined: Sat Nov 26, 2016 2:42 am

Re: 2k adventure

Post by Lardo Boffin »

Wow. An adventure in 2k is an awesome project! I just about managed to squeeze a simple avoid the obstancle game into 1k using machine code but it was far from easy.

I seem to remember that in a 1k zeddy the display file is minimise and grows as required to give you the most room for BASIC but in a 2K machine it is defaulted to full size? If that is the case then the screen will be using 700 or so bytes of RAM that are not required. You could put the description on the first two lines and keep most of the display file empty to save memory. Not sure how you do that in BASIC.
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: 2k adventure

Post by dr beep »

Lardo Boffin wrote: Tue Nov 20, 2018 10:16 am Wow. An adventure in 2k is an awesome project! I just about managed to squeeze a simple avoid the obstancle game into 1k using machine code but it was far from easy.

I seem to remember that in a 1k zeddy the display file is minimise and grows as required to give you the most room for BASIC but in a 2K machine it is defaulted to full size? If that is the case then the screen will be using 700 or so bytes of RAM that are not required. You could put the description on the first two lines and keep most of the display file empty to save memory. Not sure how you do that in BASIC.
Screen is compressed when RAM < 3.5K
Empty line is then just 1 byte.
Post Reply