WIP: Reversi

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

WIP: Reversi

Post by carlsson » Mon Jan 07, 2013 10:46 pm

As part of my programming exercise, I decided to actually develop a machine code game to Creativision. To start with something relatively simple, I'll port my 1K VIC-20 Othello game from 2002 (Minigame Compo entry) using slightly updated graphics. The game engine should pretty much already be done, it is mostly a matter of adjusting routines and replace VIC and ROM calls.
othello1.gif
ROM + source code will be posted once I have the game running. Once I'm done with this, I might port some of my other games as well, i.e. Tetris, Jewels, perhaps Q*Bert.
You do not have the required permissions to view the files attached to this post.
Last edited by carlsson on Thu Mar 28, 2013 4:11 pm, edited 2 times in total.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Othello

Post by MADrigal » Thu Jan 10, 2013 7:18 am

WOW this is really GREAT news!!!!!! :shock:
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 15, 2013 11:56 pm

There is slow but steady progress. Actually I thought this game would be slightly easier to convert than it turns out to be, but I'm building a small library of handy helper routines that could be reused for later development.
reversi3.gif
No, one is not supposed to be able to place markers outside of the board. That is the latest of bugs that suddenly emerged when I thought all the other ones were squashed. :D
You do not have the required permissions to view the files attached to this post.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Wed Jan 16, 2013 12:28 pm

wow you're doing a great job!! I'm impressed :-)

i had a binary made by kurt woloch, where he succeeded in moving sprites through joystick control. but sadly i can't find the binary anymore, and i suppose it also came with source code.

maybe kurt would be glad to help you fixing your bug, or adding some code to yours :-)

ps. it would be GREAT (and make the game look "professional") if you decided to "respect" the behaviour of commercial games for creativision.

i mean: making the "creativision" logo at startup. this means "interfacing" your source code with BIOS calls.

instead of letting all the game code execute as soon as the first BIOS call goes into game ROM area, you should make the game jsr or jmp to the BIOS again, where it displays the Creativision logo.

i suppose that if you read the binary of every creativision game ROM, you'll find the "sequence" of calls. shouldn't be hard, cause you're a pro :-)
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 » Wed Jan 16, 2013 3:41 pm

Moving a sprite with the joystick is very simple and was solved already last week. 8-)

I figured the smoothest action is achieved by using the custom interrupt handler which is executed about 60 times a second. For each interrupt, a counter will be decreased until it hits zero. At that point, the zeropage joystick values documented by Kurt will be read and stored into temporary variables, and the counter is set to its maximum value again. The main program will be busy waiting to pick up the temporary variable and take action on non-zero results and then zero the variable. By doing like this, the counter in the interrupt routine will limit how many times per second the joystick will be read, preventing unwanted jitter. I suppose for an action game, I might want to rethink this or at least use a lower max value for the counter.

The idea to get the Creativision logo on screen before starting the game is very good, and something I've considered looking into. Kurt has some pointers on this too, plus that I've studied Barry's ROM disassembly to get some additional hints. From the disassembly, it seems the default font is scattered around in ROM on various locations to the point it almost is useless unless my print routines rearrange ASCII to whatever weird character order the Creativision has. This is one of the reasons why I included a VIC-20 font in the game ROM, to have letters and numbers in the regular order. Of course I could dump the original Creativision font and store it inside the game ROM in the order it should be, or look again at the ROM. However I made a brief test to read from BIOS ROM and got an unexpected result (well, unexpected until I read the disassembly).

Once I get the game mostly working, I'll have look at the sound generation too. It doesn't look any more complex than the VDP, and I already have rather nice and compact track + block based music routines from the VIC-20 that I hope to adapt in order to play music the way I prefer it to be encoded.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Wed Jan 16, 2013 6:51 pm

> Moving a sprite with the joystick is very simple and was solved already last week. 8-)

:-)

> I figured the smoothest action is achieved by using the custom interrupt handler which
> is executed about 60 times a second....

is there a routine in the BIOS which manages the joystick polling? or is it an interrupt of the PIA?

> The idea to get the Creativision logo on screen before starting the game is very good
> ...

why not also letting the game behave as on a real creativision, that's demo mode when startup (for example a cpu-vs-cpu game mode with random moves), and then you have to press RESET to enter the actual game mode? a "game start" jingle would also be great :-)

> From the disassembly, it seems the default font is scattered around in ROM on various
> locations

hm.... are you sure? from my memory, all the ASCII data is all in a row, except the "creativision" logo which should be elsewhere.

> Once I get the game mostly working, I'll have look at the sound generation too.

again, you can look at Kurt's source code from the Creativemu download repository. his sound generation routines work very well.

can't wait to see the game working. will you allow me to beta-test it? :-)
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Wed Jan 16, 2013 7:01 pm

ok just checked the BIOS with my own Biteditor application and this is what I found:

$f880 to $f8cf = 0 to 9
$f8d0 to $f907 = first part of "(C) creativision TM" logo
$f908 to $f9d7 = A to Z
$f9d8 to $f9ff = second part of "(C) creativision TM" logo

no punctuation marks included in the font, just letters + numbers + logo
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 » Wed Jan 16, 2013 10:42 pm

Hm, interesting about the font. I'll see if I can copy it to the VDP memory. Of course you'll be in position to beta test, I don't know anyone else who might bother.

Regarding the joysticks, Kurt described it in this post from 2009. Actually there is a BIOS routine that is called as part of the regular interrupt routine. It reads the PIA and then stores decoded values into the zeropage addresses. What I added was that in my own interrupt routine, I add a counter and reads the already decoded values and store them at another position. The cursor moves one whole square at a time.

Well for that matter I can release a still buggy BIN file if you want to see what happens. Eventually it will stop working or end the game, with no way to restart except recycling the power.
othello-cv.zip
You do not have the required permissions to view the files attached to this post.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: WIP: Reversi (was Othello)

Post by MADrigal » Thu Jan 17, 2013 5:26 pm

> Hm, interesting about the font. I'll see if I can copy it to the VDP memory.

I suppose it will be very easy: you'll have to copy the data from the BIOS in place of your source code (which could be reduced in size).

> Of course you'll be in position to beta test, I don't know anyone else who might bother.

:-)

> Regarding the joysticks, Kurt described it in this post from 2009.
> Actually there is a BIOS routine that is called as part of the regular interrupt routine.
> It reads the PIA and then stores decoded values into the zeropage addresses. What
> I added was that in my own interrupt routine, I add a counter and reads the already
> decoded values and store them at another position. The cursor moves one whole
> square at a time.

I played the game a little bit, and found some annoying things:
1. when I press the fire button to start game, the cpu starts with 4 squares and i start with 1. I suppose it's because when I press fire, the game gets the input TWICE, making me do a sort of "first move" - even though I didn't want to.
2. the flashing cursor moves too fast when pressing the joystick. a one-step per joystick tick would be more suitable, or eventually let the cursor move at half the speed
3. the flashing cursor hides the dots standing in his position. would you consider using a different kind of cursor, for example an empty square? eventually without making if flash
4. the AI algorythm computer is very fast, and this is great. but why not delaying by 1-2 seconds the CPU move? this would make the game look a little bit more "realistic"... it's not "fun" to see the cpu responding in half a while, after the player's move :-) (jusy my opinion heh!). eventually you could consider adding a short tune/jingle between player and cpu moves.
5. the game hangs at a certain point - this i already knew. but what is really annoying is that as the bug happens, the cursor can be moved all around screen, outside of the 8x8 playfield
6. when pressing "reset" (f3 on emulator)during a game, the cursor keeps on flashing. but you can't move (this is correct).
7. suggestion: using better colours. I mean: green, white and black are obvious. but i would love to see some "graphics" around the playfield, instead of the cyan dots. i can design you some graphics you if you want.
8. suggestion part two: why not using a "checkers"-style playground, with light green + dark green cells (or light green + cyan or... whatever you want heh), and remove the black square around them? the squares are fine, but as soon as you place a dot in a certain cell, the black square disappears there. not really what i expected :-/
9. suggestion part three: making 3d-like white/black dots, sort of "isometric" view

hope my report/ideas help :-)

cant wait to see more!!
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 » Fri Jan 18, 2013 8:29 am

Thank you for the input. Regarding the way to start a game, what you don't know is that the routine checks BOTH fire buttons. One of them will make you do the first move (always as black, unfortunately - I'll see if I can change that) and the other one will make the computer do the first move. Thus it will look like 4-1 instead of 2-2.

I can increase the joystick delay so it doesn't move so fast. Also the flashing cursor is subject to alteration, although I kind of like the idea that it looks like a marker. What I can do is to add code to have the cursor skip already placed markers, but it means more complexity.

Of course the CPU can be delayed a bit or add some sound. For more complex games, the CPU gets a little bit slower after a while.

Bugs and restart options will be handled accordingly.

As for graphics, the dots in my version of FunnyMu are purple, not cyan. The border can absolutely be prettified, and use at least up to 8 different characters in its tileset. I just wanted something that is easy to draw to start with. When it comes to the board, it is supposed to be dark green with medium green squares inside each position. As you mention black squares and cyan dots, it sounds like your installed emulator is broken or misconfigured? I used the official VDP colour numbers all the way and get expected colours on my installed version of FunnyMu.

I have studied a half dozen different implentations on other VDP-based machines. Some of them have a checkered board (e.g. Daniel Bienvenue's Reversi for Colecovision) but I'm not so sure that is a proper look. There is another type of layout with black lines completely separating each square, but it makes the markers 8x8 pixels instead of 16x16 and I think that looks too tiny. See my RetroChallenge blog for more pictures.

Your last suggestion to make the dots 3D, I don't know how that would be doable. Surely one could put some kind of fine checkered shadow below, but it would just look ugly. As for a truely isometric view, I think colour limitations would require a major rethink to make it work. Not this time...
Post Reply