WIP: Reversi

Talk about programming of homebrew games only.
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: WIP: Reversi (was Othello)

Post by carlsson » Mon Jan 28, 2013 11:38 pm

Not as much progress as I had hoped for, but I've got some things implemented.

Most importantly is that I found out how to differ between a cold start and pressing the RESET button. It turns out the Z flag in the 6502 is set when the RESET button is pressed, and the BIOS routine at $F808 begins with checking that flag. If it is set, it quickly jumps to the indirect pointer as specified by the cartridge. Only in case Z=0, the Creativision message is displayed, and thanks to how the loops work, the Z flag will remain cleared after exiting that routine.

It means the very first thing to do in the game code, perhaps after any SEI to disable interrupts, is to store the value of the Z flag or even the whole status register. Once we start doing things with the accumulator, any other register or memory address, the Z flag will be changed so in order to determine demo or game mode this is how the code should begin:

Code: Select all

realgame eqm $xxxx ; variable of your choice, I'm using $80-$ff and $0300-$03ff

   org $A000 ; for an 8K game
Start:
  php
  pla
  and #2
  sta realgame ; will be 2 if RESET was pushed, 0 otherwise

  ...
  lda realgame
  bne selectmode ; NOT EQUAL value != 0, EQUAL value == 0

demogame:
  ...
  jmp demogame

selectmode:
  ...
The actual coding might differ on situation, but in principle this seems to work at least in the emulator. Those who prefer could likely LSR and EOR the value before storing it, to get DEMO=1 on cold start and DEMO=0 when RESET was pushed, but it is just a matter of semantics.
User avatar
MADrigal
Site Admin
Posts: 1192
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Tue Jan 29, 2013 4:07 pm

Ooooh this is very interesting! :-)
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: WIP: Reversi (was Othello)

Post by carlsson » Tue Jan 29, 2013 11:46 pm

New prerelease version with both demo mode and support for two players:
reversi-0.3.zip
In order to select game, you first press RESET and then use either fire button on the left controller to select mode. To start the game, move the stick in either direction. This is not identical to how true Creativision games work, but I'll get back to reading rest of the controller at a later point.
reversi5.gif
Known issues:

The graphic animation is not yet implemented
The background and border colours still are black
In two player mode, both use the left controller
In two player mode, the game says YOU and CPU instead of 1UP and 2UP
No proper game over
No sound effects
No random number generator for the CPU in case of ties
+ anything else that I know about but have forgotten
You do not have the required permissions to view the files attached to this post.
User avatar
MADrigal
Site Admin
Posts: 1192
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Wed Jan 30, 2013 10:35 am

> New prerelease version with both demo mode and support for two players:

That's great! :-)

> In order to select game, you first press RESET and then use either fire button
> on the left controller to select mode.

If you want to match the commercial cv games, you should then add both buttons of both controllers to "Select mode"


> To start the game, move the stick in either direction. This is not identical to how
> true Creativision games work, but I'll get back to reading rest of the controller at
> a later point.

You may want to use the FunnyMu source code to get the exact mapping of keyboard through the PIA. Look at attached file.

> Known issues:

1. I think the "demo mode" is too fast. Cpu "thinks" too quickly
2. I would love to see 4 game modes, not 3 (1p black, 1p white, 2p). It would be great to offer the choice to select white/black for the 2 players version. Don't you like the idea of keeping the words "BLACK" and "WHITE" on screen (while in select mode) and just swap the words "1UP", "2UP" and "CPU" when changing from mode 1 to 4? That would be identical to a commercial cv game. :-)

By the way I'm very very happy of this new beta release! :-)
You do not have the required permissions to view the files attached to this post.
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: WIP: Reversi (was Othello)

Post by carlsson » Mon Feb 04, 2013 3:34 pm

I kind of got the animation working, meaning the animation runs backwards :lol: and all markers at once. However I hope to fix it tonight. The animation will also slow down the playing speed, both for the computer and human players.
User avatar
MADrigal
Site Admin
Posts: 1192
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Mon Feb 04, 2013 6:31 pm

> I kind of got the animation working, meaning the animation runs backwards :lol:

ROTFL, this is a good beginning hahaha!! :-D

> and all markers at once.

will you try the routine i suggested?


> The animation will also slow down the playing speed,
> both for the computer and human players.

Playing speed is something that you really must care of: must not be too fast and too slow.

By the way, when you'll also sfx and/or bgmusic, you'll see what's the correct "rythm" for playing speed :-)
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: WIP: Reversi (was Othello)

Post by carlsson » Mon Feb 04, 2013 8:29 pm

Another beta: changed some colours, implemented animation. All the other lack of features still apply.
reversi-0.4.zip
You do not have the required permissions to view the files attached to this post.
User avatar
MADrigal
Site Admin
Posts: 1192
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Tue Feb 05, 2013 7:45 am

Hi, I just woke up and found this great beta to test. :-)

I love the animation. But hey it seems to me that it "changes" from time to time. It's not a row-by-row animation like I supposed, it also considers the column. What's the exact rule??

Question about the demo mode: why has it a brown background in Demo mode, which is then turned black when in Select and Game mode?
User avatar
carlsson
Posts: 507
Joined: Fri Jun 13, 2008 7:39 am
Location: Västerås, Sweden

Re: WIP: Reversi (was Othello)

Post by carlsson » Tue Feb 05, 2013 9:03 am

The animation actually calculates the distance from last placed marker. Perhaps a few illustrations better explain how it works:

Code: Select all

........ ........ ........ ........ ........
........ ........ ........ ........ ........
........ ........ ........ ....x... ....x...
...xo... ...xo... ..o1o... ..oo1... ..oox...
...ox... ...1x... ...xx... ...xx... ...2x...
........ ...x.... ...x.... ...x.... ...1....
........ ........ ........ ........ ...o....
........ ........ ........ ........ ........

........ ........ ........ ........ ........
........ ........ ........ ........ ........
....x... ....xo.. ....x1x. ....xxx. ....xxx.
.x21x... .xxx1... .xxxo... o123o... ooooo...
...ox... ...ox... ...ox... ...ox... ...ox...
...o.... ...o.... ...o.... ...o.... ...o....
...o.... ...o.... ...o.... ...o.... ...o....
........ ........ ........ ........ ........
It means on first iteration, all markers with distance 1 from last placed marker will initate the rotation. On the next iteration, all markers with distance 2 will start the animation, while the previous ones are still in the middle of theirs. Maximum distance can be 6 in either direction, which happens when you have a marker e.g. at the top row and then one at the bottom row and flip all opponent's markers inbetween those.

I don't know about brown or black backgrounds, need to check. They're supposed to be blue, unless we're talking about different things?
User avatar
MADrigal
Site Admin
Posts: 1192
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Tue Feb 05, 2013 10:05 am

That's a really clever solution to the problem, and the visual effect is "hypnotizing" :-)

I tested the game on FunnyMu Unofficial, most recent version. The bg appeared brown this morning as I tested it. Then when I pressed F3 (reset), turned black and remained black.

By the way, there's a known bug regarding the wrong emulation of bg colour in FunnyMu. I should test that feature on MESS or CvEmu2, which have much better video emulation routines.

Question: which emulator are you testing the game on? Does the bg turn blue on your copy of FunnyMu? Which version is it? I'm guessing whether you're using a different version of the sdl.dll than the one included in my FunnyMu...
Post Reply