Saturday, March 31, 2012

Mame graphics bug? Update: Solved!

Now is the following a bug in the original game, or MAME's video emulation?

In the below screenshot you can see a large shadow bottom left. What is it? Where has it come from? Who knows! 

Correct behaviour (car x position 0x1E3)

Shadow error bottom left (car x position 0x1E2)

  • You can reproduce this by manually setting the car x position to 0x1E2 in the mame debugger (offset 0x260050 in memory). 
  • Drive forward from the start line, and you'll see this shadow flicker on and off.
  • Setting the car position to 0x1E1 or 0x1E3 sees the shadow disappear as below.
Can someone try reproducing this on hardware? You probably want to give it a go on MAME first to get the hang of where to drive without using the debugger!

I suspect this is an issue with MAME's video emulation code, which I've used as a basis for my port, but would be nice to get verification.

Incidentally, I can't reproduce this issue on the Sega Saturn port. (Interestingly, the Saturn port also fixes some of the other bugs I found that can be reproduced on hardware). 

Update:
Thanks to Magic Knight for reproducing this on hardware. Surprisingly, it's a bug in the original game code. It only took 5 minutes to find and fix in my C++ translation. Here's the offending code:

// Hide Sprite if off screen
if (sprite_y2 < 256 || sprite_y > 479 ||
    sprite_x + width < 192 || sprite_x > 512)
{
    hide_hwsprite(input, output);
    return;
}

The fix is to change the highlighted > symbol to >=. Easy! I'm going to wait before patching the original game, just in case this has caused any side effects. 

The bug is caused by the shadow on the right hand side, wrapping to the left as it goes off-screen. 

5 comments:

Magic Knight said...

I've had a look at this problem on the original hardware too, just now in fact. I've seen this extra shadow appear at the same position as in your screenshot, in fact it appears maybe three or four times at regular intervals as you move along. So it looks like an original bug. This was on a Rev. A board.

yt said...

Awesome. Thanks for trying to reproduce this.

This will make resolving the bug easier. We can also potentially fix the bug in the original game as well.

Magic Knight said...

I've been playing Out Run a lot today, I've seen this effect after the chicane in the first level. Seems to be related to the pine trees at the side.

Jeff said...

Hi, just found and read all your work on Outrun. I still love that game too. Awesome work!! I have done a couple of remakes - Need for Speed and Carmageddon. I went in the opposite way though, using the original assets I recoded the games from scratch. Just for fun and to see how they worked!

I documented my OpenC1 project here: http://blog.1amstudios.com/search/label/OpenC1

Would love to see the c++ code when you're ready. You say you're using the MAME rendering code? How does that work - have you included the VGA chip code in your codebase?

yt said...

Hi Jeff - project looks interesting, apart from your run-in with the lawyers :( Boo!

The easiest way to understand the project is as follows:

Fully ported C++ game engine -> Emulated video hardware -> SDL based video output.

The video hardware is completely emulated, hence why I thought the bug may reside in that layer originally.

The advantage of video emulation is that it should be easy to move graphic mods and level tweaks between my port and the original arcade machine in future. Let's say if someone built a track editor using my research for example...