ZX81 SNAKE GAME

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Coggie
Posts: 14
Joined: Thu Oct 12, 2017 1:11 am
Location: Orkney Islands
Contact:

Re: ZX81 SNAKE GAME

Post by Coggie »

Ye Xav I knew about using the logic commands (NOT,OR, AND) to save memory...just wasn't sure if it took less clock cycles to process...
Also I knew about direct String printing instead of using $'s...
I will have a look at using D_FILE instead of Printing...I'm sure it will be faster...I just need to learn a bit more about memory manipulation 1st...

in the meantime I have changed...

607 IF G(A,B)<>0 THEN GOTO 630

to...

607 IF G(A,B) THEN RETURN

Oh and now displays Score,Hi Score Before drawing screen border...
Attachments
SNAKE7.P
(3.07 KiB) Downloaded 190 times
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: ZX81 SNAKE GAME

Post by XavSnap »

Hi,
enclosed, the D_File mirrored version.
But, some of variable/conditions are corrupt...
Probably due to the DFILE relocation!
:cry:

This an alterative release ( :lol: ) :
SNAKEDF.P
(13.55 KiB) Downloaded 203 times
The G() array is keep to check values, but it can be remove to seep up the display!
... if the bug can be found! (? memory error ?)
:evil:

Code: Select all

  2 GOSUB 800
     3 GOSUB 1003
     100 GOSUB 4000
   200 LET A$(X+1,Y)="O"
   201 LET V=G(X,Y)
   203 IF V=0 THEN GOTO 208
   204 IF V=10 OR V=11 THEN GOTO 700
   205 LET L=L+V+1
   206 LET S=S+V
   207 LET D$(1,1 TO)=STR$(S)
   208 LET A$(23)=B$+D$(1)+C$+E$(1)
   210 LET G(X,Y)=11
   211 LET S(H,1)=X
   212 LET S(H,2)=Y
   214 IF RND>.9 THEN GOSUB 600
   250 LET K=CODE INKEY$
   270 IF K>36 THEN GOSUB 500+10*(K-112)
   280 LET X=X+R
   281 LET Y=Y+U
   290 LET H=H+1
   295 IF H>M THEN LET H=1
   300 IF L>0 THEN LET L=L-1
   310 IF L=0 THEN GOSUB 400
   399 GOTO 200
   400 LET A$(S(T,1)+1,S(T,2))=" "
   407 LET G(S(T,1),S(T,2))=0
   410 LET T=T+1
   420 IF T>M THEN LET T=1
   430 RETURN 
   500 IF R=1 THEN RETURN 
   505 LET R=-1
   506 LET U=0
   507 RETURN 
   510 IF R=-1 THEN RETURN 
   515 LET R=1
   516 LET U=0
   517 RETURN 
   520 IF U=1 THEN RETURN 
   525 LET U=-1
   526 LET R=0
   527 RETURN 
   530 IF U=-1 THEN RETURN 
   535 LET U=1
   536 LET R=0
   537 RETURN 
   600 LET A=INT (RND*19)+2
   605 LET B=INT (RND*29)+2
   607 IF G(A,B) THEN RETURN 
   610 LET N=INT (RND*9)+1
   620 LET A$(A+1,B)=CHR$ (N+156)
   625 LET G(A,B)=N
   630 RETURN 
   700 GOSUB 5000
   705 PRINT AT 9,10;"ya«silly«cant" AND V=10;AT 11,4;"you«fell«in«the«dam«ditch" AND V=10;AT 9,9;"ya«daft«basket" AND V=11;AT 11,4;"you«ate«your«feckin«tail" AND V=11;AT 13,8;"play«again«‹y“nŒŠ"
   710 IF S>Z THEN LET Z=S
   750 POKE 16444,Z-(INT (Z/256)*256)
   752 POKE 16445,INT (Z/255)
   755 LET K$=INKEY$
   757 IF K$="Y" THEN GOTO 3
   758 IF K$="N" THEN GOTO 990
   759 GOTO 755
   777 GOTO 3
   800 PRINT AT 2,8;"hello«and«welcome";AT 4,15;"to";AT 6,1;"trakkie«the«amazing«wobbly«worm";AT 10,6;"USE ARROW KEYS TO MOVE";AT 20,7;"PRESS A KEY TO PLAY"
   810 IF INKEY$="" THEN GOTO 810
   820 RETURN 
   990 PRINT AT 15,2;"please«your«fecking«self«then"
   995 STOP 
  1003 CLS 
  1004 FAST 
  1005 CLEAR 
  1008 DIM A$(27,33)
  1009 LET X=11
  1010 LET Y=16
  1011 DIM G(21,31)
  1012 DIM S(555,2)
  1013 LET V=0
  1014 LET U=1
  1015 LET R=0
  1016 LET H=1
  1017 LET T=1
  1018 LET L=100
  1019 LET M=555
  1020 LET S=0
  1021 LET B$="SCORE="
  1022 LET C$="        HI SCORE="
  1023 DIM D$(1,5)
  1024 DIM E$(1,5)
  1030 LET Z=PEEK (16445)*256+PEEK (16444)
  1032 FOR A=1 TO 25
  1033 LET A$(A,33)=CHR$ (118)
  1034 LET A$(25,A)=CHR$ (118)
  1036 NEXT A
  1039 LET DES=8+PEEK (16400)+256*PEEK (16401)
  1040 POKE 16507,PEEK (16396)
  1044 POKE 16508,PEEK (16397)
  1046 POKE 16396,DES-INT (DES/256)*256
  1047 POKE 16397,INT (DES/256)
  1099 SLOW 
  1102 LET E$(1,1 TO)=STR$(Z)
  1103 LET D$(1,1 TO)=STR$(S)
  1104 LET A$(23,TO)=B$+D$(1)+C$+E$(1)
  1105 FOR I=1 TO 31
  1110 LET A$(2,I)="x"
  1115 LET A$(22,32-I)="x"
  1125 LET G(1,I)=10
  1126 LET G(21,I)=10
  1140 NEXT I
  1150 FOR I=2 TO 22
  1160 LET A$(23-I,1)="x"
  1162 LET A$(I,31)="x"
  1165 LET G(I-1,1)=10
  1166 LET G(I-1,31)=10
  1170 NEXT I
  1195 RETURN 
 4000 REM SET NEW DFILE
 4010 POKE 16444,PEEK (16396)
 4011 POKE 16445,PEEK (16397)
 4020 RETURN
 5000 REM RESTORE DFILE
 5010 POKE 16396,PEEK (16507)
 5020 POKE 16397,PEEK (16508)
 5030 RETURN
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Coggie
Posts: 14
Joined: Thu Oct 12, 2017 1:11 am
Location: Orkney Islands
Contact:

Re: ZX81 SNAKE GAME

Post by Coggie »

Hmmm....its starting to get a bit messy lol
theres not any noticable increase in speed using D_FILE method is there...
and because DF method is manipulating memory directly...it would be better to start over & code All in MC...but the project was really meant to see if it was possible to program a Playable Snake Eat Numbers game in ZX81 BASIC.

I have only changed some line numbering and put L back to 3 (init snake length...)
oh and I have CLEARed Vars before saving this file...you maybe forgot to before...

where is that rogue 255 byte on top line of screen coming from?...can't figure that out yet...

I'm still drinking Whisky this morning so my head is a bit confused LOL

Coggie :)
Attachments
SNAKEDF2.p
(3.89 KiB) Downloaded 188 times
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: ZX81 SNAKE GAME

Post by XavSnap »

theres not any noticable increase in speed using D_FILE method is there...
True, but we had to set both array (G() and A$())... and i'm too lazy to convert the G() array into A$() strings to improve speed! :lol:
and because DF method is manipulating memory directly...it would be better to start over & code All in MC...but the project was really meant to see if it was possible to program a Playable Snake Eat Numbers game in ZX81 BASIC.
No, the LET command wasn't bypassed!
We just allow computer display the VARs values instead of video memory...
We just test a character in the string array, like Peeked values in the video memory.
And, the challenge was to code in basic...
oh and I have CLEARed Vars before saving this file...you maybe forgot to before...
:mrgreen:
where is that rogue 255 byte on top line of screen coming from?...can't figure that out yet...
It's a curiosity!
:D
... a bad line synchro at the top of the screen (D_File start!).
We had to start on a $76;$76 memory set... and the relocation may be corrupt.
I had to reserve the first array line A$(1,) to set this flag, but :?
I start the display on the second array line... and throw the score at end off array.
Was a quick example!
;)
Perhaps this bug can be use to :roll: :lol: ...display an hrg picture without asm!
I'm still drinking Whisky this morning so my head is a bit confused LOL
:lol:
1018 LET L=100
:ugeek:
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Coggie
Posts: 14
Joined: Thu Oct 12, 2017 1:11 am
Location: Orkney Islands
Contact:

Re: ZX81 SNAKE GAME

Post by Coggie »

lol...yeah....we could make top line a Fancy HiRes Snake for the Title...ha :)

Have u got a link 2 any more detailed ZX81 Memory Maps?

I've just got the Original ZX81 Manual...
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: ZX81 SNAKE GAME

Post by XavSnap »

:D
The better D_File release. (UDG free!)
SNAKEDF3.P
(3.77 KiB) Downloaded 218 times
All the best !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: ZX81 SNAKE GAME

Post by XavSnap »

Capture.jpg
Capture.jpg (73.73 KiB) Viewed 4136 times
more infos (in French) : http://zx81.ordi5.free.fr/others/
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply