Fruit machine type thing

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Fruit machine type thing

Post by Shaun_B »

Here's a fruit machine type game written in BASIC.

I'm fairly content with the game-play (such as it is for this sort of thing) and it seems fairly bug-free, so now is the difficult bit to go through the symbolic listing to work out how to optimise it.

Regards,

Shaun.
Attachments
fruity-rc2.P
Everything seems worky so I'm happy. Now optimise.
(3.9 KiB) Downloaded 227 times
fruity-rc1.p
First release candidate
(3.49 KiB) Downloaded 250 times
fruity.p
Early version of a fruit machine game
(2.93 KiB) Downloaded 237 times
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Fruit machine type thing

Post by XavSnap »

I tried to test the IF and Print conditions speed:

Code: Select all

1 LET A$="abcdefghij"
2 FOR A=1 TO 10
3 PRINT AT 0,0;A$(A)
4 NEXT A
5 CLS
8 REM CODE 2
9 FOR A=1 TO 10
10 PRINT AT 0,0;"a" AND A=1;"b" AND A=2;"c" AND A=3;"d" AND A=4;"e" AND A=5;"f" AND A=6;"g" AND A=7;"h" AND A=8;"i" AND A=9;"j" AND A=10
11 NEXT A
12 CLS
13 REM CODE 3
15 FOR A=1 TO 10
16 PRINT AT 0,0;
17 IF A=1 THEN PRINT "a"
18 IF A=2 THEN PRINT "b"
19 IF A=3 THEN PRINT "c"
20 IF A=4 THEN PRINT "d"
21 IF A=5 THEN PRINT "e"
22 IF A=6 THEN PRINT "f"
23 IF A=7 THEN PRINT "g"
24 IF A=8 THEN PRINT "h"
25 IF A=9 THEN PRINT "i"
26 IF A=10 THEN PRINT "j"
27 NEXT A
The 2 and 3 codes seem to be at the same speed!
We had to insert a GOTO 27 to the code 3 ,to speed up the program.
IF A=1 THEN GOTO 27...
IF A=2 THEN GOTO 27...
:evil:
Not to use on a 1K ZX81!
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Fruit machine type thing

Post by Shaun_B »

Thanks, I never intended a 1K program otherwise that would be slower still.

I'll look into your listing to see if I can make sense of it.

Regards,

Shaun.
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Fruit machine type thing

Post by Shaun_B »

I've released the game - see the New ZX81 Games in the Games sub-forum.

I got a reasonable amount of speed out of BASIC, and found a fast-ish way of printing numbers to two decimal places, as follows (assumes M is your money):

Code: Select all

1 REM YOUR MONEY AMOUNT
2 LET M=1000
3 GOSUB 100
4 LET M=M-25
5 IF M>0 THEN GOTO 3
6 STOP
100 LET Z$=STR$ M
101 IF Z$="0" THEN LET Z$="00"
102 IF M<100 THEN LET Z$="0"+Z$
103 PRINT AT 0,0;"$";Z$( TO LEN Z$-2);".";Z$(LEN Z$-1 TO);"  "
104 RETURN
Regards,

Shaun.
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Fruit machine type thing

Post by Shaun_B »

I found not so much a bug but some unintended features from the game - I think it was when I was trying to optimise it a bit more. I'll hopefully fix this soon and upload a better version.

Regards,

Shaun.
PS, As I'm in the mood then I'm going to write a cut down version for the ZX80 with 4K ROM - I think.
Shaun_B
Posts: 474
Joined: Wed Apr 22, 2009 10:22 am

Re: Fruit machine type thing

Post by Shaun_B »

Just an update - Monument Microgames is interested in publishing ZX81 Fruits so the fixed/enhanced/optimised version will only be available on cassette until someone pirates it.

Regards,

Shaun.
Post Reply