New Yahtzee for the Commodore 64 in BASIC V2

C64 website updates, new releases of games, demos, tools etc.

Moderator: Lemoners

User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

New Yahtzee for the Commodore 64 in BASIC V2

Post by wizball6502 »

Dear Lemon64 members

Here I would like to present you another game of my BASIC type-in games series with listings that fit on three A4 pages.

This time I did an interpretation of the well-known dice game "Yahtzee". I tried again to create a product as round as possible with only the core elements necessary but still appealing to play. I put emphasis on improving the code to make my first-attempt algorithms simpler, something I learned form my BASIC 10Liner contest contributions worth practicing. Maybe you find the one or the other interesting trick in the code.

Image Image

ImageImage

Yahtzee2020.pdf

My Yahtzee version is designed for 1-4 players

Additional features:
  • - dice can be set to either black or multicolored ("Pip Color")
    - Animated dice increase the tension
    - Realistic random numbers within the rolling dice animation. For example after a 6 there can not follow another 6, but also not a 1.
    - Dice rattle-in-a-leather-cup sound
    - Fast, direct input via keyboard
    - The 5 dice can be held and/or released with keys 1-5
    - Keys A-M assign the points on the dice to a free category.
Have fun with the game.

PS: Please don't upload or share the .prg file of the game. Exploring the listing is half the fun.


Edit: For better understanding here is an overview of the variables used in the listing:

Code: Select all

a     = Temporary variable used in various occasions
b$    = Blank line of 5 spaces "{space*5}" + next line element r$
b     = Tab position for current player column only used in function "score category"
c$    = Screen color codes to show the dice's pip color either in color or black
c     = Flag 0 or 1 to toggle the dice's pip color
d$    = String with 22 "down" screen control elements to set cursor position
d     = Temporary variable to further evaluate current key press Ascii value
dc$   = Screen code for empty dice cube with white background
dc$() = Screen code for dice faces (1-6)
f     = Number of dice to be rolled, starting with 5, less if some were locked
g     = Game state and jump value for "on g goto" (0=continue, 1=next round, 2=game over)
i     = Temporary variable mostly used in for/next loops
j     = Temporary variable mostly used in for/next loops
k$    = Temporary variable to get key press (getk$)
k     = Ascii value of k$
l$    = Screen code for middle part of empty dice cube background + next line element r$
l     = Index/line number where score table element needs to be updated after scoring
l()   = flag if dice is locked(1) or not(0)
n$    = String variation of n with leading blanks
n     = Score value
p$    = Score table as printed on screen (faster than dynamically building the table on screen each time)
p     = Current player (0-3)
r$    = Screen code to go to the next line of 5er block from cursor position "{down}{left*5}".
r     = Round counter (game ends after 13 rounds)
s     = Value of SID base address (54272)
t$    = String combo "playerround " to either show "space=next player" or "space=next round"
t     = Dice Roll counter within a turn (max 3 rolls are allowed)
v     = Value of VIC base address (53248)
w     = Helper variable used to temporarily store a value from a w(i) element
w()   = Used in the dice roll animation to calulate rolling distance to bottom as per dice
x     = Temporary helper variable used in functions "score category" and "dice roll animation"
x()   = Current face value of dice 1-5
y     = Temporary helper variable used in function "score category" to check for a full house
z     = Number (0-3) of selected players 1-4
Last edited by wizball6502 on Tue Jun 16, 2020 4:08 pm, edited 5 times in total.
Minuous
Joe Blade
Joe Blade
Posts: 171
Joined: Mon Apr 15, 2002 1:02 am
Location: Canberra, Australia
Contact:

Re: New Yahtzee for the Commodore 64 in BASIC V2

Post by Minuous »

wizball6502 wrote:PS: Please don't upload or share the .prg file of the game. Exploring the listing is half the fun.
We are all supposed to waste our time typing it in then? Instead of the job just being done once?
Only Amiga makes it possible!
User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

Re: New Yahtzee for the Commodore 64 in BASIC V2

Post by wizball6502 »

If you think you don‘t gain anything from looking at someone else‘s code then this is probably not for you. This series is addressed to C64 enthusiasts who want to learn something about programming a game in BASIC. And be rewarded with a nice little game at the end.

If you just want to play Yahtzee then why not download one of the 58 Yahtzee versions listed on Gamebase64.

But thank you for the interest.
User avatar
Zaz_cag
Mikie
Mikie
Posts: 436
Joined: Thu Dec 01, 2011 7:24 pm
Location: Pennsylvania
Age: 48

Post by Zaz_cag »

Be lucky that a checksum (i.e. PROOFREADER!) is included.
User avatar
NM156
Jumpman
Jumpman
Posts: 4698
Joined: Fri May 29, 2015 11:13 am

Post by NM156 »

Very hardcore retro 8) last time I typed in a listing must have been 1985.
sidvicious
Zorro
Zorro
Posts: 1227
Joined: Wed Jan 23, 2008 5:05 pm
Location: Indianapolis, IN USA
Contact:

Post by sidvicious »

I pasted it into cbmprog studio (was a bit of a pain to clean it up) so here it is: http://www.victwenty.org/transfer/yahtzee.zip
0110 0110 0110 - The number of the beast....
User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

Post by wizball6502 »

Hi sidvicous. Can you please remove the zip file from the website? As I stated in my inital post I do not want the final program to be uploaded or shared. Otherwise I would have done it myself. Everybody should find his own way of effort to get to the final game. I don't mind you telling other members that you could successfully convert the listing by using CBM prg Studio. But at least let others walk the path on their own. Thank you.
User avatar
Richard of TND
Lemon64 Database Editor
Lemon64 Database Editor
Posts: 4985
Joined: Mon Feb 11, 2002 5:46 pm
Location: United Kingdom
Age: 45
Contact:

Post by Richard of TND »

Nice idea to have a type-in to tantalize us, if we mis-copy the routines and try hunting for the errors.

As for the removal of the game download. I don't think the forum posters have an option to edit/delete the post after a reply has been added. Therefore the download stays in this post, unless the link is either broken, or an admin member removes it. Sorry.
User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

Post by wizball6502 »

Richard of TND wrote:Nice idea to have a type-in to tantalize us, if we mis-copy the routines and try hunting for the errors.
Sure, there is some effort required, to see the result. At the same time I know there are people who will understand and accept my reasons doing it this way. Besides, there is a checksum tool available to signal type-in errors.
Richard of TND wrote:As for the removal of the game download. I don't think the forum posters have an option to edit/delete the post after a reply has been added. Therefore the download stays in this post, unless the link is either broken, or an admin member removes it. Sorry.
Removing the file from the website would be sufficient. But it is not so important. Sidvicious Version produces Syntax Errors anyway. Good I included a copy protection. :wink:
sidvicious
Zorro
Zorro
Posts: 1227
Joined: Wed Jan 23, 2008 5:05 pm
Location: Indianapolis, IN USA
Contact:

Post by sidvicious »

The code could be much better documented, as is, it is definitely not a learning experience. I'll admit I didn't test the game fully and missed an error in the copy/paste progress. Zip file updated to include a fixed .prg. The project still contains the error...

Not to diminish what you did in basic, but honestly, I don't see anyone wanting to type this in. The nostalgia wears off after a few lines. The only reason I bothered to paste it into CBMprog Studio was boring conference calls...

You can think of me having a .prg available like someone "cracking" a free game and posting it to csdb...
0110 0110 0110 - The number of the beast....
User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

Post by wizball6502 »

sidvicious wrote:The code could be much better documented, as is, it is definitely not a learning experience.
Apart from the the listing becoming too bloated with too many REMs, the problem with documenting too much is that people stop the effort of thinking and processing. I'd rather point out to the c64-wiki, so that people learn the ways to search for more information and find out themselves. Using google/c64-wiki to look up certain peek and poke addresses and to find out what they mean, is part of that learning experience. I agree in that the listing is certainly a project for people who already know what a for/next loop is but are interested how things are put together to make a whole C64 game. There is use of sprites and custom chars to show how it can be done with deliberate abandonment of machine language to have not too many data lines without meaning.

And there is also a reason for leaving my e-mail address in the code. I am happy to answer questions of people who want to get involved with my listings and look for additional answers. This dialog with end users is my reward for giving this out for free.
sidvicious wrote:Not to diminish what you did in basic, but honestly, I don't see anyone wanting to type this in. The nostalgia wears off after a few lines.
I'm fine when you think like that. But what actually is your motiviation to upload the game for others, especially when I asked not to do it? I don't think it gives you much credibility to your veteran cracking handle doing a lame "crack/spread" like this (provided this is you: https://csdb.dk/scener/?id=9919).

And btw why do you think many people were waiting for "TheC64" WITH keyboard? To just be able to press the spacebar in order to skip the cracker intro? :lol:
sidvicious wrote:the only reason I bothered to paste it into CBMprog Studio was boring conference calls...
Ok. "Yahtzee 2020: A game worth more attention than a boring conference call" is a nice tagline. Saves me a lot of marketing efforts. Thank you.
sidvicious wrote:You can think of me having a .prg available like someone "cracking" a free game and posting it to csdb...
Not to diminish your "cracking" efforts :wink: but someone else did do a much more impressive job for converting my last listing into a prg:

pdftotext Downloads/Blackjack2019.pdf - -nopgbrk -layout|cut -b8-|grep "^[1-9]"|sed "s/{sh space}/{\$a0}/g"|petcat -w2 -o blackjack.prg --;x64 blackjack.prg

At least he did not upload the game but left it to the audience to figure it out themselves.
ajordison
Jack The Nipper
Jack The Nipper
Posts: 685
Joined: Wed Apr 09, 2008 12:09 pm
Location: Hartlepool, UK
Age: 57
Contact:

Post by ajordison »

The only reason I bothered to paste it into CBMprog Studio was boring conference calls...
There's a compliment in there somewhere :lol:
Try out CBM prg Studio over at www.ajordison.co.uk "When you've tried the rest, try this one..."
User avatar
wizball6502
William Wobbler
William Wobbler
Posts: 131
Joined: Wed Jan 01, 2014 1:48 pm
Location: Switzerland

Post by wizball6502 »

No question: Your IDE rulez, Arthur! Looking very much forward to the new release. :thumbsup:
Last edited by wizball6502 on Thu Jun 04, 2020 5:40 pm, edited 1 time in total.
User avatar
retroscener
Jack The Nipper
Jack The Nipper
Posts: 784
Joined: Sun Apr 30, 2017 5:09 pm
Location: Northamptonshire, UK
Age: 52

Post by retroscener »

sidvicious wrote:Not to diminish what you did in basic, but honestly, I don't see anyone wanting to type this in. The nostalgia wears off after a few lines. The only reason I bothered to paste it into CBMprog Studio was boring conference calls...
It wasn’t for you to decide that though, this isn’t your project. He only did this to get more people into learning coding in BASIC. So I refuse to download, not that I can be bothered typing it all out anyway (besides the point). You should really remove the link out of respect. In time sometime down the line it may be made publicly downloadable. But until then it is inappropriately too soon to immediately take over and spoil his unique project he took so long to work hard on. You’re lucky he’s taking it better than I thought he would.
sidvicious
Zorro
Zorro
Posts: 1227
Joined: Wed Jan 23, 2008 5:05 pm
Location: Indianapolis, IN USA
Contact:

Post by sidvicious »

First, that is a risk you take when you put something on the internet. That I was the first to post it amazes me.

Second, I didn't read the whole post the first time, so I didn't see the request until later.

Third, yes he took it well, good on him. Had he taken it bad, that would be bad on him.

Fourth, Because he was nice, the link no longer works, as requested. I suspect if someone really wants the .prg it is now out there to save their fingers from 1983 hell.
0110 0110 0110 - The number of the beast....
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests