Updated version of Crazy Tetrominoes, clone of Tetris is now supporting Emulator R43.
Crazy Tetrominoes is written completely in BASIC and it comes with detailed walk through the code.
Access to full source code and tutorial is on my blog at:
https://www.8bitcoding.com/p/crazy-tetrominoes.html
Program can also be downloaded here:
Or you can Try It Now! online.
Enjoy!
Crazy Tetrominoes
- DusanStrakl
- Posts: 127
- Joined: Sun Apr 26, 2020 9:15 pm
- Location: Bay Area, California
- Contact:
-
- Posts: 4
- Joined: Tue Jun 27, 2023 8:20 pm
Re: Crazy Tetrominoes
Hi Dušan,
a small problem here: on hardware, I always get the same 2x2 box.
See video:
https://www.youtube.com/watch?v=rd-IF31aPGk
I think this is caused by the RND(0) in the code, which always returns a constant on my machine.
RND(1) seems to work OK.
What do you think?
Jaroslav.
a small problem here: on hardware, I always get the same 2x2 box.
See video:
https://www.youtube.com/watch?v=rd-IF31aPGk
I think this is caused by the RND(0) in the code, which always returns a constant on my machine.
RND(1) seems to work OK.
What do you think?
Jaroslav.
meet me at https://www.jsykora.info/ OR in mastodon https://oldbytes.space/@jarda
Re: Crazy Tetrominoes
According to C64 BASIC, RND(0) returns a random number based on the clock, while RND(1) returns a random number based on whatever the seed originally was, and RND(negative number) sets the seed.
It seems the common convention for doing random numbers is RND(-TI) to seed based on the jiffy timer, then RND(1) to get the next random number.
It seems the common convention for doing random numbers is RND(-TI) to seed based on the jiffy timer, then RND(1) to get the next random number.
- DusanStrakl
- Posts: 127
- Joined: Sun Apr 26, 2020 9:15 pm
- Location: Bay Area, California
- Contact:
Re: Crazy Tetrominoes
Hi Jaroslav,
thank you for the info. I went to my physical X16 and tried it. I used the game as it was shipped on SD originally with the board and it plays fine. I recreated a little loop like yours and it also seem to create random values just fine:
Not sure what could cause different behavior. If the data is based on timer, perhaps you are missing battery on your board, but that is pure guessing...
thank you for the info. I went to my physical X16 and tried it. I used the game as it was shipped on SD originally with the board and it plays fine. I recreated a little loop like yours and it also seem to create random values just fine:
Not sure what could cause different behavior. If the data is based on timer, perhaps you are missing battery on your board, but that is pure guessing...
- DusanStrakl
- Posts: 127
- Joined: Sun Apr 26, 2020 9:15 pm
- Location: Bay Area, California
- Contact:
Re: Crazy Tetrominoes
I also just tried to replace RND(0) with RND(1) on my system and works fine.
Can you try changing these two lines of code:
Can you try changing these two lines of code:
130 SN=INT(RND(0)*7) 160 S=INT(RND(0)*7):CX=17:CY=13:GOSUB 2210:GOSUB 2000:SN=Sto
130 SN=INT(RND(1)*7) 160 S=INT(RND(1)*7):CX=17:CY=13:GOSUB 2210:GOSUB 2000:SN=Sand see if it works.
Re: Crazy Tetrominoes
It has been my personal experience that... On some versions of the emulator, neither the jiffy clock nor the real time clock will start running until you set them.
It would appear that on hardware, they both start running on powerup. And the RTC continues to keep time while the computer is off, provided you've installed a battery.
It would appear that on hardware, they both start running on powerup. And the RTC continues to keep time while the computer is off, provided you've installed a battery.
Re: Crazy Tetrominoes
On that note, the emulator's real time clock should start with the current time if you run with "-rtc".kelli217 wrote: ↑Wed Jun 28, 2023 7:17 pm It has been my personal experience that... On some versions of the emulator, neither the jiffy clock nor the real time clock will start running until you set them.
It would appear that on hardware, they both start running on powerup. And the RTC continues to keep time while the computer is off, provided you've installed a battery.
-
- Posts: 4
- Joined: Tue Jun 27, 2023 8:20 pm
Re: Crazy Tetrominoes
Hi, I confirm that changing to RND(1) fixes the game.DusanStrakl wrote: ↑Wed Jun 28, 2023 6:32 pm Can you try changing these two lines of code:
130 SN=INT(RND(0)*7) 160 S=INT(RND(0)*7):CX=17:CY=13:GOSUB 2210:GOSUB 2000:SN=Sto
130 SN=INT(RND(1)*7) 160 S=INT(RND(1)*7):CX=17:CY=13:GOSUB 2210:GOSUB 2000:SN=Sand see if it works.
I checked in MENU and the time is running. Also PRINT TI shows incrementing values.
But OK, I will debug this myself, at least I have something to play with
Jaroslav.
meet me at https://www.jsykora.info/ OR in mastodon https://oldbytes.space/@jarda
Re: Crazy Tetrominoes
Yeah, it's been a while since I did anything on the emulator that involved trying to time things, so I could've been a few versions out of date. That's why I was careful to preface my comment with it being only my personal experience.TestPleaseIgnore wrote: ↑Wed Jun 28, 2023 9:12 pm I checked in MENU and the time is running. Also PRINT TI shows incrementing values.
But OK, I will debug this myself, at least I have something to play with
Jaroslav.
When I did, I was just setting a variable equal to TI, and then at the end of the program subtracting that variable from the current value of TI. Something like:
0 T0=TI [...] 9999 ? TI-T0:ENDAnd when I did that, it always gave me a value of 0. But if I instead did this:
0 TI=0 [...] 9999 ? TI:ENDIt would give me the elapsed jiffies between the start and end of the program, which is what I wanted. The same thing would happen if I checked TI$ for the current time of day. It would always be "000000" unless I set it first, then it would start running.
All that being said? I just did both of those things just now on R43, and it behaves as Jaroslav indicates.
- DusanStrakl
- Posts: 127
- Joined: Sun Apr 26, 2020 9:15 pm
- Location: Bay Area, California
- Contact:
Re: Crazy Tetrominoes
Hmm very interesting.
Of course fixing the game with RND(-TI) and then using RND(1) is trivial but I wonder why it behaves differently on different systems. I also tried the Emulator with R43 ROM and couldn't reproduce repeating of the same number.
Of course fixing the game with RND(-TI) and then using RND(1) is trivial but I wonder why it behaves differently on different systems. I also tried the Emulator with R43 ROM and couldn't reproduce repeating of the same number.