A downloadable game

CORRIDORS81 -----------------------------------------------------------------

 BY LUIS PIERI <luis.pieri@gmail.com>

 ZX81 BASIC to be converted using ZXText2P 

            (http://freestuff.grok.co.uk/zxtext2p/index.html)

             

 DATE      : 08-FEB-2024 TO 09-MAR-2024

 CONTEST   : https://gkanold.wixsite.com/homeputerium/copy-of-rules

 DEADLINE  : March 16th, 2024

 CATEGORY  : PUR-120

 LINK      : https://lupoman.itch.io/corridors81

 DATA      :  Include the following in a ZIP file with your submission: 

             - The program (on disk or tape image file); 

              - a text file with the program description and instructions;

              - a short description of how to start the game using the emulator;

              - a screenshot in jpg or png format (or an animated screenshot in gif format);

              - a program listing that proves the program does not have more characters 

                than allowed for the category. 

              - For program descriptions and code explanations there can be up to 0.5 bonus points

                in the rating.

              - Send to GKANOLD-at-GMAIL dot COM, get a confirmation by e-mail or in the 10Liner forum.

 IDEA      : You control a spider robot running through long corridors in a Moon base

             You need to escape with all the data!

             The walls are magnetic and destroy the robot!


  - You need to wait for the level to finish drawing, but you can start moving with the keys 5 and 8 (cursors keys in ZX81)

  - Then the level will scroll down and you can try to advance without touching the white walls.

  - Please bear in mind that theres a little delay (lag...) between you press the key and you start moving.

  - I worked a lot around this, but the zx81 basic is too slow, you can crank up the emulation speed if you want!

  - A good strategy to handle this lag is to press the key (5 or 8) and say "one" and then release the key, the lag is part of the gameplay :-) because the robot is in the moon... :-)

  - In the top left corner, you will see the score (increases with each sector you cleared).

  - When you touch a wall the score resets back to 0 and a new level start.


CODE EXPLANATION --------------------------------------------------------------

  - The code below is formated to be converted with the utility ZXText2P.

  - Once converted the lines are much shorter in the ZX81 Basic.

  - You can see the final listing opening the .P file on the emulator.

  - Please bear in mind that ZX81 Basic only supports one statement for code line.

LINE 01 -----------------------------------------------------------------------

This code is to init all the vars in a string, this is the only way to get

10 lines, the idea behind this is from Marco's retrobits (https://retrobits.itch.io/)

 Init vars players + 2 sectors y and type

 all the vars are stored in one big string!

 the int values are encoded in char values, use CODE and CHR$!!!

 POS 1 = X of player

 POS 2 = Y of Sector 1

 POS 3 = Y of Sector 2

 POS 4 = older X of player

 POS 5 = flip 0/1 not used

 POS 6 = Type of Sector 1

 POS 7 = Type of Sector 2

 POS 8 = Score (is up to 255 points then resets back to 0)

1 LET A$=CHR$ 16+CHR$ 13+CHR$ 5+CHR$ 16+CHR$ 0+CHR$ 1+CHR$ 3+CHR$ 0

LINE 02 -----------------------------------------------------------------------

 This setups all the types of sectors in a long string

 Init sector data AT 1+Type(I) TO 1+Type(I)*8

 escape secuences for converting using ZXText2P

              <--5-->

 Sector 01 = "X.....X" 

 Sector 02 = "X..X..X" 

 Sector 03 = "X.X.X.X"  

 Sector 04 = "XX...XX"

 Sector 05 = "X.XXX.X"

 Sector 06 = "XXX.XXX"

 Sector 07 = "XXXX..X"

 Sector 08 = "X..XXXX"

 The sector data does not include the borders

 I'm using inverse chars for the corridor pathway

2 LET S$="\::\::\::\::\::\::\::\  \::\::\::\  \::\  \::\  \::\::\::\  \::\  \  \  \::\  \  \::\  \  \  \  \  \::\::\::\::\  \  \  "

LINE 03 -----------------------------------------------------------------------

 Update player X pos with the pressed key

 Update y pos of each sector

 Saves the previous X player

 Copy the last 3 chars of the string (3 last vars)

 The last byte is score and the previous was a ver to flip between 0 and 1, not used anymore, it was used before for animating the player and a way to For..Next loop for the sectors.

 The key of this program is the powerfull ZX81 Basic's String slicing!

3 LET A$=CHR$(CODE A$(1)-(INKEY$="5")+(INKEY$="8"))+CHR$(CODE A$(2)+1)+CHR$(CODE A$(3)+1)+A$(1)+A$(5TO)

LINE 04 OK --------------------------------------------------------------------

 Print sector 1 and also prints a clear section below to allow the player to

 switch more easily between corridors.

4 PRINT AT CODE A$(2),14;S$(CODE A$(6)*5-4 TO CODE A$(6)*5);AT CODE A$(2)+1,14;"\::\::\::\::\::"

LINE 05 OK --------------------------------------------------------------------

 Print sector 1 and also prints a clear section below to allow the player to

 switch more easily between corridors.

 This line and the one before could be easily converted to one line using the

 the var that flip 0 and 1, but you would get a more longer line then!

5 PRINT AT CODE A$(3),14;S$(CODE A$(7)*5-4 TO CODE A$(7)*5);AT CODE A$(3)+1,14;"\::\::\::\::\::"

LINE 06 OK --------------------------------------------------------------------

 Check for Player collision, I'm peeking the dfile directly:

  DFILE + x + y*33  

 First you need to get the dfile location and then you peek it!

 The y*33 value is precalculated because it never changes.

 if there's a white wall then Restart the game!

6 IF PEEK(PEEK 16396+PEEK 16397*256+496+CODE A$(1))=0 THEN GOTO 1

LINE 07 -----------------------------------------------------------------------

 Delete player previous position and then Print player

7 PRINT AT15,CODE A$(4);"\::";AT15,CODE A$(1);"%*";AT1,1;CODE A$(8);" "

LINE 08 -----------------------------------------------------------------------

 Check if sector 1 reach bottom of screen, reset y=0 and type sector to rnd() 

 Increase the score by 1.

 Important you need to take care to copy the rest of the vars in the string!

8 IF CODE A$(2)>17 THEN LET A$=A$(1)+CHR$ 0+A$(3TO5)+CHR$(INT(RND*7)+2)+A$(7)+CHR$(CODE A$(8)+1)

LINE 09 -----------------------------------------------------------------------

 Check if sector 2 reach bottom of screen, reset y=0 and type sector to rnd() 

 Increase the score by 1.

 As stated before this 2 lines could be condensed in one, using the var that

 flip 0/1, but then the line would be too long for the compo.

9 IF CODE A$(3)>17 THEN LET A$=A$(TO2)+CHR$ 0+A$(4TO6)+CHR$(INT(RND*7)+2)+CHR$(CODE A$(8)+1)

LINE 10 -----------------------------------------------------------------------

 Go to top of the loop (line 3, update vars...)

10 GOTO 3


LOG ---------------------------------------------------------------------------

 2024-02-07: Find the BASIC 10Liner Contest in reddit.

             Started proto in basic.

 2024-02-08: Changed idea and start creating the pseudocoded needed.

             used Marco Retrobit's idea on vars encoded in one string

             https://bunsen.itch.io/squash-trainer-by-marcos-retrobits

 2024-02-09: Start converting pseudo code into ZX81 BASIC.

             Testing string slicing, string logical operators.

             Finished the code, but of course doesn't work

             I made some parts works, but I forgot how slow

             Basic on the zx81 was, I need to get rid of the FOR loop.

 2024-02-10: Rewrite, using only 2 sector slices instead of 3

             get rid of the FOR, putting all two print statements.

             added more space between sections

 2024-02-11: Check if there's room for score???

             if its possible to lower to 128 char/lines?

             Check if there's black do not erase white on player movement

             Check if line 8 & 9 can be consolidated using anim var A$(7)

 2024-02-13: Game too slow, will try some strategies

             Compacted lines 40-50 and 80-90, using anim var

             Changed GFX to inversed to create sense of slot/groove

             Revert compacted lines, to get under 128 chars.

             Undo de flip 0/1, no animation anymore, simplify print.

             Move to sections of 5 chars width.

             Reorder the vars in the string to try to make the update line

             less than 128 chars!

             A little bit faster, the keyboard is still a bit unresponsive

             Fix some bugs, now the player is deleted with the proper back

             char.

 2024-02-14: Try to use flip 0/1 again and consolidate sector code

             a couple of lines exceed 128 chars, some older bugs appear again.

             Added score, 1 point for each sector completed. Max score is 255.

             Changed behaviour when player collide restart game, before it 

             showed "HIT"

             The speed is OK for ZX81 Basic I think, there's some delay with 

             the buttons

             IMHO is not much to be done, just GIF and other files needed to 

             upload.

             Perhaps change the game to Corridors81? CHANGED

   

 2024-02-15: Noticing the category is for 120 chars NOT 128!!!

             Changed code to get to the line lenght limit.

             Change the print of player from AT to TAB, change score to the 

             same line. Is it a little faster? NOP go back to using AT.

             Fix bug with RND sector generator.

             Little speed up avoiding 2 string slices on the blank lines 

             before each sector.

             Clear the char after the score.

 2024-03-09: Not check the previous char when deleting the player

             too slow!

             Extra testing, preparing all the files to send to the compo.

-------------------------------------------------------------------------------

StatusReleased
Rating
Rated 4.0 out of 5 stars
(2 total ratings)
AuthorBASIC 10Liner
GenreAction
Tags10liner, 8-Bit, basic, sinclair, zx81

Download

Download
corridors81.p 1 kB
Download
corridors81.txt 10 kB

Install instructions

INSTRUCTIONS ------------------------------------------------------------------

  - Open zx81 emulator (EightyOne: https://sourceforge.net/projects/eightyone-sinclair-emulator/)

  - Menu File -> Open Tape -> Select corridors81.p

  - The LOAD command will appear automcatically if not type L (LOAD Command) and shift-p twice 

  - Wait until "0/0" appears

  - If you press Enter (New Line in ZX81) key the listing will appear.

  - Press R for RUN command and then enter

Leave a comment

Log in with itch.io to leave a comment.