Super Star Trek

General games-related topics
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Super Star Trek

Post by XavSnap »

Basic speed optimization:

Code: Select all

   820 FOR I=1 TO 8
   825 FOR J=1 TO 8
   830 LET K3=0
   835 LET Z(I,J)=0
   840 LET R=RND
(...)
  1045 NEXT J
  1050 NEXT I
Equal:

Code: Select all

   820 DIM Z(8,8)
   822 FOR I=1 TO 8
   825 FOR J=1 TO 8
   830 LET K3=0
   835 REM ****** LET Z(I,J)=0 *****
   840 LET R=RND
(...)
  1045 NEXT J
  1050 NEXT I
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: Super Star Trek

Post by kmurta »

Well remembered, BASIC Sinclair already initializes arrays with a value of 0, unlike other BASICs.

In this sense, we can also discard the following lines of code:

Code: Select all

   530 FOR I=1 TO 9
   532 LET C(I,1)=0
   535 LET C(I,2)=0
   538 NEXT I
and

Code: Select all

   670 FOR I=1 TO 8
   680 LET D(I)=0
   690 NEXT I
However the impact on game speed is limited as these lines are only executed once at game startup. But saves memory!
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Super Star Trek

Post by XavSnap »

Basic memory optimisation :

Code: Select all

 320 LET Z$="                                "
 (...)
  4050 PRINT ,,Z$( TO 6);O$
  
Hi,
The purpose of these small samples of modifications is not to denounce problems in this game, but to show that the basic standard can very well be adapted on the Zx81, but with small tricks specific to the machine.

Z$( TO 6) = 11 bytes.
" " = 8 bytes !

320 LET Z$=" " = 32bytes in basic and 32bytes in the VARS = " "
This routine is good to use it Z$... up to 4 times to save memory.
In this case, Z$ is OK.

But in case of O$, the variable can be deleted, and the line room saved.
4040 LET O$="-------------------"

On the Sinclair Basic, you MUST chaine all unneeded line…
10 PRINT "HELLO"
20 PRINT "WORLD"

Juste use "HELLO",,"WORLD"
You save the Basic line header and the $76 in the end of the other line. (Only 5 bytes saved… But, on several lines)
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
kmurta
Posts: 302
Joined: Tue Sep 01, 2009 5:04 am
Location: Belo Horizonte - BR
Contact:

Re: Super Star Trek

Post by kmurta »

XavSnap wrote: Thu Mar 05, 2020 4:15 pm The purpose of these small samples of modifications is not to denounce problems in this game, but to show that the basic standard can very well be adapted on the Zx81, but with small tricks specific to the machine.
Don't worry about it, I appreciate your suggestions, they are welcome ;)

My intention when porting the game to the ZX81 was to maintain its integrity, without making any cuts.

As ZXpand has plenty of memory, I didn't bother to optimize the code to save space. I'm actually more interested in optimizing performance than the memory usage.

But I believe that there is still a lot of room for optimization in the code, be it in the use of memory or in the performance of the code.
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Post Reply