Wednesday, 23 January 2013

Day 23 : Game Development (cont.)

So, a little bit more development today. You can see I now have code dealing cards and counting their best totals, BlackJack style. Player 2 has gone bust, Player 2 has 21 through sheer dumb luck :)

Baccarat is really a simpler variant with just one round of 'hits' and a different scoring system, so tweaking the code for this is pretty simple.

At present the game, bankroll, #players and bet selection code are all dummies, though this is easy enough to write, as I've already written the menuing code and that works fine.

The bottom right white square is just a note to let me know the code has completed running. I don't have a debugger for this code, other than that in the CP1610 Emulator, so old style debugging methods are in use here.

The running is still slow - which is not unreasonable as it's a fairly slow processor (CP1610) which only runs when the vertical blank is on (25% of the time), and the processor itself is running a virtual machine emulator. It's fast enough for this sort of game. It would (like Chip 8 which on a 1802 system has all the same problems) struggle a bit with Space Invaders, but then that's near impossible on this system anyway.

I suppose I could have just written it in CP1610 machine code in the first place, but I do quite like coding in this RISC VM, and if I have time to port it to Arduino, which might be a bit of a stretch in the week remaining, it will make it much easier as I only have to port the VM, not the 1610 - this also solves problems such as an Arduino having seperate code and data and a 1610 not - the VM has ROM code and small RAM data so it's a pretty good match for an MCU.

I actually have got, somewhere, an Arduino screen display that does something like 24 x 20 with a 6 bit character set which would work fine so maybe the Arduino version wouldn't take long to code up, given that I already have a 'C' core.

No comments:

Post a Comment