Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alex_free

macrumors 65816
Original poster
Feb 24, 2020
1,106
2,366
This is the first game I've ever written. It's written in C89 so I got it to compile with Macintosh Programmer's Workshop for Mac OS 8+, Windows 95 OSR 2.5, and Mac OS X/11. The Mac OS X version is ONE universal binary for Panther and above, PPC/PPC64/i386/x86_64 that should even run on ARM Macs (untested, but up to Catalina is guaranteed to work).

This should also easily work on Linux/BSD/Android if you 'gcc 21c.c -o 21c.c'. If you have any fun with this, find any bugs, etc. let me know.


21C by Alex Free
1.0 Release - September 28th 2020
1.0.1 Release - September 30th 2020

==About==
A portable and open source command line game of Blackjack/21 written in Ansi C/C89.

==Release - Info==
- 21c_1.0.1_src - Source
- 21c_1.0.1_src_1.44mb_floppy - Source floppy image
- 21c_1.0.1_win32 - Windows 95-Windows 10 (64 & 32-bit)
- 21c_1.0.1_dos16 - DOS/some Windows versions (DOS 3.30+)
- 21c_1.0.1_dos16_1.44mb_floppy - DOS/some Windows versions (DOS 3.30+) floppy image
- 21c_1.0.1_classic_mac_os - 68k/PPC universal SIOW app for Mac OS 8+
- 21c_1.0_mac_os_x - PPC, PPC64, PPC750, PPC7400, PPC7450, PPC970, i386, x86_64 universal executable
for Mac OS X 10.3.9-Mac OS 11 (ARM requires Rosetta and is untested but should work).

==Features==
- 'Infinite' deck to draw from
- Infinite splitting
- Dealer hits until 16
- Double Down on an intial sum of 9, 10, or 11
- Insurance bet if the Dealer's first card is an Ace
- Early surrender (late surrender turned out to not be fun)
- Bet and save your balance and pick up where you left off later
- BSD 3-Clause License, Ansi/C89 100% compilant
- Saving:
When you save, a file named 'save.txt' will be generated in the current directory. If 'save.txt'
is in the current directory when executing '21c' you will be prompted to load it if so desired.

==License==
3-Clause BSD License, see 'license.txt'

==Changelog==
Version 1.0.1
- fixes dealer hit bug
- fixes save bug
- improves data input methods and bugs
- adds DOS support (not just MSDOS!)

==Building==
Tested To Compile With:
- Macintosh Programmer's Workshop 3.0 GM (MrC - PowerPC, SC - 68k) (Classic Mac OS 8-9.2.2)
- Xcode 3.0 (Apple GCC 4.0) (Mac OS X 10.3.9+)
- DevCPP 4.99.5 (MingW GCC 3.4.2) (Windows 95 OSR 2.5+)
- TurboC++ 3.0 (TCC 3.0) (DOS 3.30+)

This should essentially compile on any OS with a C89 compilant compiler.

Each folder contains the same source file '21c.c' in a different EOL format:
- eol_cr contains the Classic Mac OS EOL format.
- eol_crlf contains the Windows/DOS EOL format.
- eol_lf contains the Unix EOL format.

Universal Mac OS X 10.3.9+ compile one liner:
gcc -mmacosx-version-min=10.3 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch ppc64 -arch ppc750 -arch ppc7400 -arch ppc7450 -arch ppc970 -arch i386 -arch x86_64 -o 21c 21c.c
 
Last edited:
This is the first game I've ever written. It's written in C89 so I got it to compile with Macintosh Programmer's Workshop for Mac OS 8+, Windows 95 OSR 2.5, and Mac OS X/11. The Mac OS X version is ONE universal binary for Panther and above, PPC/PPC64/i386/x86_64 that should even run on ARM Macs (untested, but up to Catalina is guaranteed to work).

This should also easily work on Linux/BSD/Android if you 'gcc 21c.c -o 21c.c'. If you have any fun with this, find any bugs, etc. let me know.


21C by Alex Free
1.0 Release - September 28th 2020

==About==
A portable and open source command line game of Blackjack/21 written in Ansi C/C89.

==Release - Compatibility==
- 21c_1.0_win32 - Windows 95-Windows 10 (64 & 32-bit)
- 21c_1.0_classic_mac_os - 68k/PPC universal SIOW app for Mac OS 8+
- 21c_1.0_mac_os_x - PPC, x86, x86_64 universal executable for Mac OS X 10.3-Mac OS X 10.15 (10.16/arm with rosetta
unknown)

==Features==
- 'Infinite' deck to draw from
- Infinite splitting
- Dealer hits until 16
- Early surrender (late surrender turned out to not be fun)
- Bet and save your balance and pick up where you left off later
- BSD 3-Clause License, Ansi/C89 100% compilant
- Saving:
When you save, a file named 'save.txt' will be generated in the current directory. If 'save.txt'
is in the current directory when executing '21c' you will be prompted to load it if so desired.

==License==
3-Clause BSD License, see 'license.txt'

==SOURCE INFO==
Tested To Compile With:
- Macintosh Programmer's Workshop 3.0 GM (MrC - PowerPC, SC - 68k) (Classic Mac OS)
- Xcode 3.0/1.5 (GCC 4.04) (Mac OS X)
- DevCPP 4.99.5 (GCC 3.4.2) (MiniGW/Windows 95 OSR 2.5+)

This should essentially compile on any OS with a C89 compilant compiler.

Each folder contains the same source file '21c.c' in a different EOL format.
- eol_cr contains the classic Mac OS EOL format.
- eol_crlf contains the Windows EOL format.
- eol_lf contains the unix EOL format.

Universal Mac OS X/Mac OS 11 compile:

gcc -mmacosx-version-min=10.3 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch ppc64 -arch i386 -arch x86_64 -o 21c 21c.c

Compatibility
Architecture: 68k PPC x86 (Intel:Mac) x86 (Windows)
Mac OS 8+
Mac OS X 10.3.9+
Windows 95 OSR 2.5+
Hmm, shouldn't the dealer have hit again here? The dealer stood on 14 o_O
 

Attachments

  • blackjack.png
    blackjack.png
    84.6 KB · Views: 252
  • Like
Reactions: alex_free
- 21c_1.0_classic_mac_os - 68k/PPC universal SIOW app for Mac OS 8+
Wait, hold on, 68k? So not only is this provided as a universal binary, but you managed to make provide a fat binary too? I suppose the only shame is that it couldn't also be carbon. That said, I tried the Windows version and it's a nice little game. The Windows version also runs perfectly fine under Wine in Linux, but that's probably not much of a surprise. :p
 
  • Like
Reactions: alex_free
Wait, hold on, 68k? So not only is this provided as a universal binary, but you managed to make provide a fat binary too? I suppose the only shame is that it couldn't also be carbon. That said, I tried the Windows version and it's a nice little game. The Windows version also runs perfectly fine under Wine in Linux, but that's probably not much of a surprise. :p

Yup, classic binary is fat and OS X binary is universal. Couldn't make the classic version carbon as SIOW app type is not available. I had this running in DOS as well, when I post the next update with a bug fix for the dealer I'll add the official 16-bit DOS version. Writing with a toaster as the target can do wonders in portability...
 
  • Like
Reactions: repairedCheese
I have multiple Apple IIs to test on - Apple II+, Apple IIe, Apple IIc, Apple IIc Plus, Apple IIgs. With a floppy emulator that makes getting it to the systems a *LOT* easier. (A cassette-load version as an audio file you can play back to the cassette-in port via any modern device with a headphone jack would be good, too.)
 
Yep. I have a Platinum //e. As long as you can get it to fit on 5.25 disk image I can transfer the image on to a real floppy and test it out.

Wow, there’s a lot of demand! I messed with this last night, the compiler doesn’t support floats so it won’t work as is but I have some ideas to get around this and will definitely try some things. Would certainly be cool to see a picture of a real Apple II running it.

Update: Seems Aztec C is the way, I *should* be able to make this work as is for Apple II DOS 3.3 and ProDOS 8.

@Anonymous Freak

By the way, what’s the cheapest Apple II you can get now?
 
Last edited:
Wow, there’s a lot of demand! I messed with this last night, the compiler doesn’t support floats so it won’t work as is but I have some ideas to get around this and will definitely try some things. Would certainly be cool to see a picture of a real Apple II running it.

Update: Seems Aztec C is the way, I *should* be able to make this work as is for Apple II DOS 3.3 and ProDOS 8.

@Anonymous Freak

By the way, what’s the cheapest Apple II you can get now?

I'd say probably the Apple //e's are the most common with //gs and ][+ models slightly less common but common enough to find on ebay. There's a really nice community of Apple ][ minded folks on Facebook worth checking out if you have more questions. I wish MacRumors had an Apple ][ forum though.
 
Wait, hold on, 68k? So not only is this provided as a universal binary, but you managed to make provide a fat binary too? I suppose the only shame is that it couldn't also be carbon. That said, I tried the Windows version and it's a nice little game. The Windows version also runs perfectly fine under Wine in Linux, but that's probably not much of a surprise. :p
Since I've recently switched to Fedora Linux on my daily driver, I decided to compile my game as a static x86_64 Linux executable. This Linux version should work on most x86_64 Linux distributions. This game is insanely portable, in general it is as easy to compile as a hello world program so if the Linux version does not suit your needs as long as your OS/compiler is newer then 1989/1990 it should be something along the lines of:

Code:
gcc 21c.c -o 21c

Downloads:
| GitHub | Garden |
 
So I’m attempting to port this to the PSX/PS1. So far, at least in the PCSXR emulator (not burning a CD-R until this is much further along) I have controller input working, press X to draw 2 random cards (using my own random number generator concept since there’s no clock on the PSX).

I know that Apple II support was previously requested, that and better modern OS system support will probably happen. Are there any other systems that y’all would like to see this on?
 
So I’m attempting to port this to the PSX/PS1. So far, at least in the PCSXR emulator (not burning a CD-R until this is much further along) I have controller input working, press X to draw 2 random cards (using my own random number generator concept since there’s no clock on the PSX).

I know that Apple II support was previously requested, that and better modern OS system support will probably happen. Are there any other systems that y’all would like to see this on?
Well, if you're really feeling like getting out there, how about PPC, x86, and ARM Linux? Got to give those Mac users running Linux something to play!

Edit: I see you have x86 Linux covered, but what about the other two?
 
  • Like
Reactions: alex_free
Well, if you're really feeling like getting out there, how about PPC, x86, and ARM Linux? Got to give those Mac users running Linux something to play!

Edit: I see you have x86 Linux covered, but what about the other two?
Should already work just by compiling on all those systems due to the magic of C89:
gcc 21c.c -o 21c. I may fire up some more VMs and make releases however.

I’d be very surprised if this didn’t work even on Rhapsody.
 
Should already work just by compiling on all those systems due to the magic of C89:
gcc 21c.c -o 21c. I may fire up some more VMs and make releases however.

I’d be very surprised if this didn’t work even on Rhapsody.
I'll accept that. But, what about 16-bit Windows? How on earth am I ever supposed to run this on Windows 3.11 for Workgroups?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.