Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:57 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ThatDiceGame

     Page 1 of 2    
Author Message
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 01:19pm 05 Jan 2021
Copy link to clipboard 
Print this post

Here is a playable, but incomplete, version of my version of a popular dice game...well, used to be popular back in the day....

Currently there is no 'ai' player, so no matter what you select for player mode, it's human only, both players. I think I have most of the glitches out, but there's nothing like other people using your software to reveal flaws!

Plays best with a mouse, I changed the click areas to make it less fiddly/frustrating when using a joystick....speaking of which...I borrowed code from Sasquatch's Mandelbrot programs....but apparently not enough of it, since it wouldn't work at all. When I finally got the cursor to move, it was way too fast! Finally, I set up a settick to reduce the 'polling' time...it works...

Left to do:

AI player
Keyboard support
bug fixes

Steve


ThatDiceGame_1.zip
 
PilotPirx

Regular Member

Joined: 03/11/2020
Location: Germany
Posts: 99
Posted: 08:11pm 05 Jan 2021
Copy link to clipboard 
Print this post

Hello yock1960,

great idea for a game, but on my CMM2 it doesn't work.
I use a nunchuk and after going on "Roll" i get the error
"Error in chirps.inc line 138: Sound output in use"
I have V5.06.00
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 02:28am 06 Jan 2021
Copy link to clipboard 
Print this post

  PilotPirx said  Hello yock1960,

great idea for a game, but on my CMM2 it doesn't work.
I use a nunchuk and after going on "Roll" i get the error
"Error in chirps.inc line 138: Sound output in use"
I have V5.06.00


Sorry Pilot, I don't have a Nunchuk and it's not supported as of yet. I will have to add some additional checking for nunchuk devices. Just out of curiosity, what model CMM2 do you have and what speed CPU? You can use 'print mm.info(cpuspeed)' to find out. I will look into getting keyboard support added in the meantime.

Steve
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 05:29pm 06 Jan 2021
Copy link to clipboard 
Print this post

  yock1960 said  
  PilotPirx said  Hello yock1960,

great idea for a game, but on my CMM2 it doesn't work.
I use a nunchuk and after going on "Roll" i get the error
"Error in chirps.inc line 138: Sound output in use"
I have V5.06.00


Sorry Pilot, I don't have a Nunchuk and it's not supported as of yet. I will have to add some additional checking for nunchuk devices. Just out of curiosity, what model CMM2 do you have and what speed CPU? You can use 'print mm.info(cpuspeed)' to find out. I will look into getting keyboard support added in the meantime.

Steve


I was able to borrow a Nunchuk from one of my kids, added it and made a slight tweak that may fix the sound issue. Nunchuk is assumed to be in the front connector or wherever channel 3 is. This would be my least favorite controller option....but I didn't grow up using one!

Steve


ThatDiceGame_1.zip
 
PilotPirx

Regular Member

Joined: 03/11/2020
Location: Germany
Posts: 99
Posted: 07:40pm 06 Jan 2021
Copy link to clipboard 
Print this post

Hello Steve,
my CPU has a speed of 480MHz and i have a CMM2 Deluxe Edition (without mouse support).

Your new version with nunchuk support works fine now. I will play some rounds with my wife. She loves this game. In germany you call it "Kniffel".

Thanks or programming,  

Peter
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 12:37am 07 Jan 2021
Copy link to clipboard 
Print this post

  PilotPirx said  Hello Steve,
my CPU has a speed of 480MHz and i have a CMM2 Deluxe Edition (without mouse support).

Your new version with nunchuk support works fine now. I will play some rounds with my wife. She loves this game. In germany you call it "Kniffel".

Thanks or programming,  

Peter


Peter,

Glad it's working for you now and hope you and your wife enjoy it! Kniffel...that's good to know, perhaps some others would name this game for their country/region, thanks!

Steve
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 02:44pm 08 Jan 2021
Copy link to clipboard 
Print this post

yock1960.  Hi.

Your game will not work no matter which controller I chose.  My system is as follows
I am on 5.7.0B2
1 Standard CMM2 480
2 Mouse = PS/2 on 0 port
3 Nunchuck or classic controller in the front port
I have tested that ALL of these are working in other programs and test programs

If I chose mouse it just crashes.  I changed one OPTION MOUSE command(line 145) to port 0 and it runs but just shows the cursor in the top left and does not respond

If I chose either Nunchuck of Classic it crashes to prompt with cursor closed at 289

I really love Yahtzee and would love to play this but it will just not work. Mouse would be nice so can you set a variable at the top and REM it so we can just change it to port 0 if we have the new PS/2 mouse on Zero.  That is going to be the most likely to be used as it is easy to make the cable for the least cost.  It took me 10 minutes and I had a cable from my junk bins at 0 costs.  

Thanks.  I still can't fathom why both the WII devices will not work.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 05:05pm 08 Jan 2021
Copy link to clipboard 
Print this post

  mclout999 said  yock1960.  Hi.

Your game will not work no matter which controller I chose.  My system is as follows
I am on 5.7.0B2
1 Standard CMM2 480
2 Mouse = PS/2 on 0 port
3 Nunchuck or classic controller in the front port
I have tested that ALL of these are working in other programs and test programs

If I chose mouse it just crashes.  I changed one OPTION MOUSE command(line 145) to port 0 and it runs but just shows the cursor in the top left and does not respond

If I chose either Nunchuck of Classic it crashes to prompt with cursor closed at 289

I really love Yahtzee and would love to play this but it will just not work. Mouse would be nice so can you set a variable at the top and REM it so we can just change it to port 0 if we have the new PS/2 mouse on Zero.  That is going to be the most likely to be used as it is easy to make the cable for the least cost.  It took me 10 minutes and I had a cable from my junk bins at 0 costs.  

Thanks.  I still can't fathom why both the WII devices will not work.


So, I can see that I'm going to have to hook up this Retromax...my backup device...which I think is a 480mhz cpu and see if I get some of these glitches! Off the top of my head, I don't know why changing the 'controller mouse open' statement to use channel 0 instead of 2 doesn't work...I'll look to see if I'm doing anything that might cause it...but it might be something for Peter. In the meantime, I added keyboard control last night....second page of help screen describes how it works...it's a bit of a mishmash between single key commands and positioning the cursor with the arrow keys. I think it works pretty well...easier than the Nunchuk, IMHO!

Steve


ThatDiceGame_3.zip
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 05:55pm 08 Jan 2021
Copy link to clipboard 
Print this post

  Quote  Off the top of my head, I don't know why changing the 'controller mouse open' statement to use channel 0 instead of 2 doesn't work.


It does but you also need to set the mouse channel number in the MOUSE function if you are not using the default channel which is 2
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:52am 09 Jan 2021
Copy link to clipboard 
Print this post

New version....getting fancy now!  

Fixed the issue with mclout999's PS2 mouse issue (hopefully) and best of all, did away with asking the user to choose the input device. Program now will choose the mouse (HT or PS2) if one is available or choose a connected Wii Classic or Nunchuk if no mouse is connected or lastly setup keyboard if no other controller is connected. It checks channels 0-3 for any connected controller, choosing the first one found. It works for what I am able to test, which is HT mouse on channel 2, Classic or Nunchuk on channel 3 and no controller attached. Please let me know if it doesn't work for you!

The only other thing I could wish for is being able to detect 'no mouse' plugged into the HT mouse adapter...but it's not a big deal...since it's always connected...

Steve


ThatDiceGame_4.zip
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 06:31pm 09 Jan 2021
Copy link to clipboard 
Print this post

  Quote  Fixed the issue with mclout999's PS2 mouse issue (hopefully)

Yes you did and for everyone else with the PS/2 mouse. Thank you. This is a very nice implementation of Yahtzee.  

Edit:  In at least in a few cases the issue below was that I was getting a double roll entry from a mouse click and was not aware that it was waiting for me to select something to score but there is still the case where it will not do anything. I am over on my CMM2 right now to see if I get another example of it locking up and not showing score on the button.  That is the difference between the two cases.  

The bad news is that there is a fatal error now at least when using my mouse because I can not choose to use any other controls(mouse is best anyway).  At random points, the game gets locked in roll and will not let you roll or move on to score.  you click on the roll button and make the rolling sound but does nothing.  The only thing you can do is quit. I have not been able to complete a game and got so close one time that THE EXPLETIVES DID FLY QUITE PROFUSELY!!

One other issue but I think this is a general one about mouse use that we need to find a good way to deal with is that the selection is very fast and you may be getting a double click or something because if you click on a Die or a scoring option it seems to be finicky about selecting so you may have to click a few times and watch very closely that it is selected or not. So it looks like one click is clicking and then clicking again and unselecting.

Thanks for one of my most favorite games on the CMM2.
Edited 2021-01-10 05:17 by mclout999
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 10:22am 10 Jan 2021
Copy link to clipboard 
Print this post

  Quote  So it looks like one click is clicking and then clicking again and unselecting.


Sounds like switch bounce on your mouse - try b3 just posted in the mouse heaven thread which includes a debounce for mouse button interrupts
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 11:45am 10 Jan 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  So it looks like one click is clicking and then clicking again and unselecting.


Sounds like switch bounce on your mouse - try b3 just posted in the mouse heaven thread which includes a debounce for mouse button interrupts


Cool, thanks Peter! I was just getting ready to try and implement a....?semaphore?...where additional clicks would be ignored until another UI object was clicked.

Steve
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 12:06am 11 Jan 2021
Copy link to clipboard 
Print this post

  Quote  Cool, thanks Peter! I was just getting ready to try and implement a....?semaphore?...where additional clicks would be ignored until another UI object was clicked.


You should consider that because it is not working with the new B3.  It is no better on than on B2.  Thanks.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 01:26am 11 Jan 2021
Copy link to clipboard 
Print this post

  mclout999 said  
  Quote  Cool, thanks Peter! I was just getting ready to try and implement a....?semaphore?...where additional clicks would be ignored until another UI object was clicked.


You should consider that because it is not working with the new B3.  It is no better on than on B2.  Thanks.


Okay.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 03:02am 11 Jan 2021
Copy link to clipboard 
Print this post

I haven't looked too closely but I would re-examine your "lbutton" interrupt routine. It looks dangerously long. Maybe instead set a flag indicating a new click, and record the coordinates of the click. Then the main loop can decide how to respond. My entire click routine is the following:
'===========================================
sub LeftClick
 newclick = 1
 handx = mouse(x,mport-1)
 handy = mouse(y,mport-1)

 gui cursor handx,handy  ' update onscreen - not really needed
end sub


Don't know if it helps but I've had success using the mouse (and the nunchuk) to synthesize key strokes, which the key stroke portion of the code then reacts to. I get zero strange mouse clicks this way.

Lastly, I see you are using mode 1,16
I too have a program using mode 1,16 and the new port 0 PS/2 mouse and I am seeing some occasional nasty video sync problems when the mouse is active. (400 Mhz Waveshare) Are you seeing anything similar?
Visit Vegipete's *Mite Library for cool programs.
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 04:22am 11 Jan 2021
Copy link to clipboard 
Print this post

  Quote  
 mclout999 said  
 Quote  
Cool, thanks Peter! I was just getting ready to try and implement a....?semaphore?...where additional clicks would be ignored until another UI object was clicked.


You should consider that because it is not working with the new B3.  It is no better on than on B2.  Thanks.


Okay.

OK I changed my mouse from a Keytronics optical to a new one I got on eBay and it works just fine.  I wonder if it was the same issue on the B2. The Keytronics mouse worked fine on other games like dots&boxes so until now I did not think about switching it.  I love my old Keytronics mouse and its companion keytronics sculpted PS/2 Keyboard but I will use what works best.  I will try my MS USB/PS/2 mice and a few others that work and if any of them have an issue I will report otherwise it was just my favorite functioning mouse.  Thus is life.  Thank you for your effort and a very nice and polished game. It is one of my favorites on the CMM2.
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:51am 11 Jan 2021
Copy link to clipboard 
Print this post

  vegipete said  I haven't looked too closely but I would re-examine your "lbutton" interrupt routine. It looks dangerously long. Maybe instead set a flag indicating a new click, and record the coordinates of the click. Then the main loop can decide how to respond. My entire click routine is the following:
'===========================================
sub LeftClick
 newclick = 1
 handx = mouse(x,mport-1)
 handy = mouse(y,mport-1)

 gui cursor handx,handy  ' update onscreen - not really needed
end sub


Don't know if it helps but I've had success using the mouse (and the nunchuk) to synthesize key strokes, which the key stroke portion of the code then reacts to. I get zero strange mouse clicks this way.

Lastly, I see you are using mode 1,16
I too have a program using mode 1,16 and the new port 0 PS/2 mouse and I am seeing some occasional nasty video sync problems when the mouse is active. (400 Mhz Waveshare) Are you seeing anything similar?


Yes, lbutton() is long...I honestly never gave this any thought, but in hindsight, I see the potential for problems. I'll give some thought on how to shorten it!

As far as issues with mode 1,16...my mouse is an HT mouse...whether or not that makes any difference, I can't say, but I haven't noticed any issues, other than the occasional junk left under the cursor when clicking a button...which I've seen in mode 1,8 also and simply turn the cursor off/on to fix. I also am using a non-waveshare 400mhz unit. I have a 480mhz...also non-waveshare...that I keep thinking of updating to test with....but haven't gotten around to it yet....a legacy from me killing my 'main' unit...now a backup.

Steve
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 10:55am 11 Jan 2021
Copy link to clipboard 
Print this post

  mclout999 said  
  Quote  
 mclout999 said  
 Quote  
Cool, thanks Peter! I was just getting ready to try and implement a....?semaphore?...where additional clicks would be ignored until another UI object was clicked.


You should consider that because it is not working with the new B3.  It is no better on than on B2.  Thanks.


Okay.

OK I changed my mouse from a Keytronics optical to a new one I got on eBay and it works just fine.  I wonder if it was the same issue on the B2. The Keytronics mouse worked fine on other games like dots&boxes so until now I did not think about switching it.  I love my old Keytronics mouse and its companion keytronics sculpted PS/2 Keyboard but I will use what works best.  I will try my MS USB/PS/2 mice and a few others that work and if any of them have an issue I will report otherwise it was just my favorite functioning mouse.  Thus is life.  Thank you for your effort and a very nice and polished game. It is one of my favorites on the CMM2.


Good! Based on Vegipete's input, I'll probably make some changes that may help....eventually....Currently, I have begun coding the AI player....oy vey!

Steve
 
yock1960
Senior Member

Joined: 18/08/2020
Location: United States
Posts: 167
Posted: 06:59pm 11 Jan 2021
Copy link to clipboard 
Print this post

Okay, hopefully this is the last version prior to adding the AI player routines. I took vegipete's advice and broke out 99% of the stuff in the lbutton & rbutton routines. I also added what I hope will prevent any extraneous left clicks from hosing things up...

I also added vegipete's trap for control-c...if the mouse is used.  Mclout99, let me know if your Keytronics mouse works with this version!

Love the feedback, making things better....learning!  

Steve


ThatDiceGame_5.zip
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025