Vehicle Sprite Bug

OutRun Engine & Level Editor: Chat, Bugs, Your Levels

Vehicle Sprite Bug

Postby Amethyst » Wed Jan 15, 2014 11:13 am

Firstly, thanks for CannonBall, I'm really enjoying it.
I think I have spotted a car sprite bug with 2 of the games vehicles. It is the Mercedes-esque car and the Pickup vehicle. The 2 sprites of those vehicles are permanently stuck in their 'downhill' state on both level and uphill road. I spotted them straightaway, and then compared them to the arcade sprites. Please look at the pics below:

Arcade version showing how they should look on level road:
Image

Image


CannonBall version showing Mercedes-esque car stuck as its 'downhill' sprite on both level and uphill road:
Image

Image

As you can see, it doesn't quite look right on the CanonBall version. The Pickup vehicle does the same thing too. These 2 vehicles are the only ones I've noticed with this issue.
Thanks in advance.
Amethyst
 
Posts: 3
Joined: Wed Jan 15, 2014 10:34 am

Re: Vehicle Sprite Bug

Postby reassembler » Wed Jan 15, 2014 2:52 pm

Hmm.. I'll look into that. It definitely used to be ok... maybe something broke at some point.
reassembler
Site Admin
 
Posts: 82
Joined: Wed Dec 04, 2013 11:35 am

Re: Vehicle Sprite Bug

Postby reassembler » Wed Jan 15, 2014 10:53 pm

Hohoho, well I was wrong. This is in fact a bug that's always been present. You did well to spot this. If you're wondering, the bug is here:
https://github.com/djyt/cannonball/blob ... c.cpp#L472

this:
Code: Select all
int8_t incline = (y >= 0x12) ? 0x10 : 0; // d1


should be:
Code: Select all
int8_t incline = (y < 0x12) ? 0x10 : 0; // d1


I'll have it fixed for the next release. Here's a screenshot showing the fix:
Image

One reason I probably didn't spot it is, as you point out, it doesn't affect all vehicles. The other thing is that in the original game, the traffic sometimes looks odd anyway. Here's a screenshot from MAME to show what I mean:

Image
Notice how the brown car is actually pointing into the sky on this one.

And the truck here:
Image
reassembler
Site Admin
 
Posts: 82
Joined: Wed Dec 04, 2013 11:35 am

Re: Vehicle Sprite Bug

Postby Amethyst » Thu Jan 16, 2014 12:00 am

Haha, thanks for this. I was about to test some older revisions. I knew about the oddities in arcade version (the vehicles riding on their back wheels or driving off a cliff effect), maybe Yu Suzuki/AM2 thought it ran so fast no one would notice. But I knew this bug was something else, I spotted it about 10 seconds into my first game of CannonBall to be honest. Not surprising really, I used to work behind a bar in a hotel and this was the only arcade game we had. After work, I played this pretty much every night for about 2 years. Only thing I miss about that job.
Thanks a lot for fixing this.
Amethyst
 
Posts: 3
Joined: Wed Jan 15, 2014 10:34 am

Re: Vehicle Sprite Bug

Postby reassembler » Thu Jan 16, 2014 12:05 am

No worries. I verified the fix against both the original assembler and MAME debugger, so it should be good.

I'm keen to catch anything else like this I may have missed, so please post anything you come across.

Whilst I like to think the engine is close to perfect, I'm sure there's more.
reassembler
Site Admin
 
Posts: 82
Joined: Wed Dec 04, 2013 11:35 am

Re: Vehicle Sprite Bug

Postby Amethyst » Fri Jan 17, 2014 4:49 am

I delved into this bit further as it didn't make sense to me why that 1 line of code would only affect those 2 vehicles. Well it doesn't, it affects the Porsche 911 too, it's just harder to spot. I decided to look at the arcade version again, and from what I can tell, the Mercedes, Pickup and Porsche 911 are the only 3 vehicles apart from the players Testarossa to have descending sprites. Some vehicles only appear to have a single sprite (aside from horizontal views) regardless of the roads incline. These appear to be the VW Beetle, the Trans-Am and the Articulated Lorry. These vehicles tend to give the 'hanging in the air' look when viewed from the side when coming off a hill, as demonstrated in your pics above. The Mercedes and Pickup have 2 sprites. The 'level' sprite (which before your fix was not displaying in CannonBall) is used on level and ascending parts of the road. The 'descending' sprite is just used on descending sections of road. The Porshe 911 appears to be the only vehicle apart from the players Testarossa to have 3 sprites. A 'level', 'ascending' and 'descending'. But bizarrely the 911's 'level' sprite is also used on ascending road too, and you only get to see it's 'ascending' sprite just near to or beyond the summit of a hill, even a small hill. It gives the 911 the effect of 'pulling a wheelie' each time it goes over certain hills (see pics below). Maybe AM2 did it on purpose, who knows. Certain vehicles lacking ascending and descending sprites I'm not so sure about, maybe memory constraints?
Had a look at my Japanese Saturn version (which was the closest thing to the arcade at the time, plus has a 60fps mode), and all those car sprite effects I mentioned are present. I remember the PAL Saturn version on Sega Ages Volume 1 had an awful bug, where once you hit the steep incline on stage 2 (Gateway), you would be forced to play the remainder of your game as if you were driving uphill with the slightly raised viewpoint. Should never have been released like that. Was never corrected either.
I looked at all this just out of pure curiosity from that line of code you posted, and looking back at my original post, it doesn't surprise me no-one had noticed it, especially with all these strange car effects going on.
Cheers.

Porsche 911 'pulling wheelies' (Arcade Version):
Image

Image
Amethyst
 
Posts: 3
Joined: Wed Jan 15, 2014 10:34 am

Re: Vehicle Sprite Bug

Postby baritonomarchetto » Fri Jan 17, 2014 8:28 am

Good eye!

Chris, would it be possible to add the missing sprites to cannonball? If it's not a huge amount of work and makes sense for you, i could ask to a very talented friend of mine (he drawn all the 2D sprites of a game we realised years ago) to give it a try...
baritonomarchetto
 
Posts: 31
Joined: Sat Dec 14, 2013 4:16 pm

Re: Vehicle Sprite Bug

Postby reassembler » Sat Jan 18, 2014 12:32 pm

Let's look at what's in ROM with the System 16 Sprite Viewer.

- Each frame has four versions at different sizes, used by the scaling hardware.
- There are 3 x viewpoints for each frame.
- Some vehicles have an additional set of frames used on a road incline (with a further 3 x viewpoints)
- There are no descending frames

Beetle (Level Frames Only)
Image

Corvette (Level Frames Only)
Image

Truck (Level Frames Only)
Image

BMW (Incline & Level Frames) - Note these are in a jumbled order below
Image

Porsche (Incline & Level Frames) - Note these are in a jumbled order below
Image

Now in assembler, these images are referenced by the following traffic setup table:

Code: Select all
ROM:00004CFA Lorry 1 [+0]
ROM:00004CFA traffic_props:  dc.l unk_F63C
ROM:00004CFA                                                             ; +0 [Long] Sprite data address
ROM:00004CFE                 dc.b  $D                                    ; +4 [Byte] Palette
ROM:00004CFF                 dc.b   1                                    ; +5 [Byte] Collision Mask.
ROM:00004D00                 dc.b   6                                    ; +6 [Byte] Zoom Lookup Value for Width/Height
ROM:00004D01                 dc.b   0                                    ; +7 [Byte] Traffic Type
ROM:00004D02 Lorry 2 [+8]
ROM:00004D02                 dc.l unk_F63C
ROM:00004D06                 dc.b  $F
ROM:00004D07                 dc.b   1
ROM:00004D08                 dc.b   6
ROM:00004D09                 dc.b   0
ROM:00004D0A Lorry 3 [+10]
ROM:00004D0A                 dc.l unk_F63C
ROM:00004D0E                 dc.b $11
ROM:00004D0F                 dc.b   1
ROM:00004D10                 dc.b   6
ROM:00004D11                 dc.b   0
ROM:00004D12 Lorry 4 [+18]
ROM:00004D12                 dc.l unk_F63C
ROM:00004D16                 dc.b $13
ROM:00004D17                 dc.b   1
ROM:00004D18                 dc.b   6
ROM:00004D19                 dc.b   0
ROM:00004D1A Lorry 5 [+20]
ROM:00004D1A                 dc.l unk_F63C
ROM:00004D1E                 dc.b $15
ROM:00004D1F                 dc.b   1
ROM:00004D20                 dc.b   6
ROM:00004D21                 dc.b   0
ROM:00004D22 Van 1 [+28]
ROM:00004D22                 dc.l unk_F3BC
ROM:00004D26                 dc.b $1C
ROM:00004D27                 dc.b   3
ROM:00004D28                 dc.b   4
ROM:00004D29                 dc.b   1
ROM:00004D2A Van 2 [+30]
ROM:00004D2A                 dc.l unk_F3BC
ROM:00004D2E                 dc.b $17
ROM:00004D2F                 dc.b   3
ROM:00004D30                 dc.b   4
ROM:00004D31                 dc.b   1
ROM:00004D32 Van 3 [+38]
ROM:00004D32                 dc.l unk_F3BC
ROM:00004D36                 dc.b $F7 ; ¸
ROM:00004D37                 dc.b   3
ROM:00004D38                 dc.b   4
ROM:00004D39                 dc.b   1
ROM:00004D3A Beetle 1 [+40]
ROM:00004D3A                 dc.l unk_F90C
ROM:00004D3E                 dc.b $CF ; ¤
ROM:00004D3F                 dc.b   3
ROM:00004D40                 dc.b   4
ROM:00004D41                 dc.b   2
ROM:00004D42 Beetle 2 [+48]
ROM:00004D42                 dc.l unk_F90C
ROM:00004D46                 dc.b $82 ; é
ROM:00004D47                 dc.b   3
ROM:00004D48                 dc.b   4
ROM:00004D49                 dc.b   2
ROM:00004D4A Beetle 3 [+50]
ROM:00004D4A                 dc.l unk_F90C
ROM:00004D4E                 dc.b $3C ; <
ROM:00004D4F                 dc.b   3
ROM:00004D50                 dc.b   4
ROM:00004D51                 dc.b   2
ROM:00004D52 Beetle 4 [+58]
ROM:00004D52                 dc.l unk_F90C
ROM:00004D56                 dc.b $3F ; ?
ROM:00004D57                 dc.b   3
ROM:00004D58                 dc.b   4
ROM:00004D59                 dc.b   2
ROM:00004D5A BMW 1 [+60]
ROM:00004D5A                 dc.l unk_F510
ROM:00004D5E                 dc.b $3A ; :
ROM:00004D5F                 dc.b   3
ROM:00004D60                 dc.b   4
ROM:00004D61                 dc.b   3
ROM:00004D62 BMW 2 [+68]
ROM:00004D62                 dc.l unk_F510
ROM:00004D66                 dc.b $FD ; ²
ROM:00004D67                 dc.b   3
ROM:00004D68                 dc.b   4
ROM:00004D69                 dc.b   3
ROM:00004D6A Corvette 1 [+70]
ROM:00004D6A                 dc.l unk_F876
ROM:00004D6E                 dc.b $CA ; -
ROM:00004D6F                 dc.b   3
ROM:00004D70                 dc.b   4
ROM:00004D71                 dc.b   4
ROM:00004D72 Corvette 2 [+78]
ROM:00004D72                 dc.l unk_F876
ROM:00004D76                 dc.b $C8 ; +
ROM:00004D77                 dc.b   3
ROM:00004D78                 dc.b   4
ROM:00004D79                 dc.b   4
ROM:00004D7A Porsche 1 [+80]
ROM:00004D7A                 dc.l unk_F290
ROM:00004D7E                 dc.b $72 ; r
ROM:00004D7F                 dc.b   3
ROM:00004D80                 dc.b   8
ROM:00004D81                 dc.b   5
ROM:00004D82 Porsche 2 [+88]
ROM:00004D82                 dc.l unk_F290
ROM:00004D86                 dc.b $F9 ; ¨
ROM:00004D87                 dc.b   3
ROM:00004D88                 dc.b   8
ROM:00004D89                 dc.b   5
ROM:00004D8A Porsche 3 [+90]
ROM:00004D8A                 dc.l unk_F290
ROM:00004D8E                 dc.b $FB ; ¹
ROM:00004D8F                 dc.b   3
ROM:00004D90                 dc.b   8
ROM:00004D91                 dc.b   5
ROM:00004D92 Porsche 4 [+98]
ROM:00004D92                 dc.l unk_F290
ROM:00004D96                 dc.b $76 ; v
ROM:00004D97                 dc.b   3
ROM:00004D98                 dc.b   8
ROM:00004D99                 dc.b   5
ROM:00004D9A Porsche 5 [+A0]
ROM:00004D9A                 dc.l unk_F290
ROM:00004D9E                 dc.b $78 ; x
ROM:00004D9F                 dc.b   3
ROM:00004DA0                 dc.b   8
ROM:00004DA1                 dc.b   5


This table sets up the different types of traffic. For example there are 5 different Porsche palettes that are used, hence 5 Porsche entries. The only difference is the palette index is different.

Now, the actual address in ROM of the sprite (i.e. the image that is displayed from the sprite sheets I ripped above) is determined as follows:

frame = (traffic_type * 32) + (steering_frame * 4) + incline_offset

where traffic type would be 0xA0 for Porsche #5 or say 0x68 for BMW 2.
incline_offset would be set to 0x10 on hills. Note the code only supports straight/incline.

The steering frame is set based on how left/right the player's Ferrari is from the traffic sprite.
Incline is set based on whether the road is sloping up.

The frame then indexes the following table which has the following format.

Format is [0x20 byte boundaries]:

[+0] Straight Frame
[+4] Straight Frame (same as above)
[+8] Right Frame
[+C] Rightmost Frame

[+10] Straight Frame [uphill version]
[+14] Straight Frame [uphill version] (same as above)
[+18] Right Frame [uphill version]
[+1C] Rightmost Frame [uphill version]

And the table is as follows:

Code: Select all
ROM:00005424 traffic_data:   dc.l unk_F63C
ROM:00005424                                                             ; Lorry Straight
ROM:00005428                 dc.l unk_F63C                               ; Lorry Straight
ROM:0000542C                 dc.l unk_F66E                               ; Lorry Right
ROM:00005430                 dc.l unk_F6A0                               ; Lorry Rightmost
ROM:00005434                 dc.l unk_F63C                               ; Lorry Straight
ROM:00005438                 dc.l unk_F63C                               ; Lorry Straight
ROM:0000543C                 dc.l unk_F66E                               ; Lorry Right
ROM:00005440                 dc.l unk_F6A0                               ; Lorry Rightmost
ROM:00005444                 dc.l unk_F3BC                               ; Pickup Straight
ROM:00005448                 dc.l unk_F3BC                               ; Pickup Straight
ROM:0000544C                 dc.l unk_F420                               ; Pickup Right
ROM:00005450                 dc.l unk_F484                               ; Pickup Rightmost
ROM:00005454                 dc.l unk_F3EE                               ; Pickup Straight [Uphill]
ROM:00005458                 dc.l unk_F3EE                               ; Pickup Straight [Uphill]
ROM:0000545C                 dc.l unk_F452                               ; Pickup Right [Uphill]
ROM:00005460                 dc.l unk_F4B6                               ; Pickup Rightmost [Uphill]
ROM:00005464                 dc.l unk_F90C                               ; Beetle Straight
ROM:00005468                 dc.l unk_F90C
ROM:0000546C                 dc.l unk_F93E
ROM:00005470                 dc.l unk_F970
ROM:00005474                 dc.l unk_F90C
ROM:00005478                 dc.l unk_F90C
ROM:0000547C                 dc.l unk_F93E
ROM:00005480                 dc.l unk_F970
ROM:00005484                 dc.l unk_F510                               ; BMW Straight
ROM:00005488                 dc.l unk_F510
ROM:0000548C                 dc.l unk_F574
ROM:00005490                 dc.l unk_F5D8
ROM:00005494                 dc.l unk_F542                               ; BMW Straight [Uphill]
ROM:00005498                 dc.l unk_F542
ROM:0000549C                 dc.l unk_F5A6
ROM:000054A0                 dc.l unk_F60A
ROM:000054A4                 dc.l unk_F876                               ; Corvette Straight
ROM:000054A8                 dc.l unk_F876
ROM:000054AC                 dc.l unk_F8A8
ROM:000054B0                 dc.l unk_F8DA
ROM:000054B4                 dc.l unk_F876
ROM:000054B8                 dc.l unk_F876
ROM:000054BC                 dc.l unk_F8A8
ROM:000054C0                 dc.l unk_F8DA
ROM:000054C4                 dc.l unk_F290                               ; Porsche 911 Straight
ROM:000054C8                 dc.l unk_F290
ROM:000054CC                 dc.l unk_F2F4
ROM:000054D0                 dc.l unk_F358
ROM:000054D4                 dc.l unk_F2C2                               ; Porsche 911 Straight [Uphill]
ROM:000054D8                 dc.l unk_F2C2
ROM:000054DC                 dc.l unk_F326
ROM:000054E0                 dc.l unk_F38A


Anyway, in conclusion:

- The 'missing' graphics aren't in ROM.
- The Beetle, Truck and Corvette use the same code, but simply duplicate the 'level' table for the 'incline' section
- I have no idea why the game was coded in this way! I don't think it was constraints as there are other unused sprites they could have removed
- I'm not massively inclined to try to hook in new sprites for the missing frames, as I don't think it's really noticeable when you're speeding through a level.
reassembler
Site Admin
 
Posts: 82
Joined: Wed Dec 04, 2013 11:35 am

Re: Vehicle Sprite Bug

Postby matt » Fri Jan 24, 2014 11:29 am

Love this insight!

Good eyes.
matt
 
Posts: 14
Joined: Tue Jan 14, 2014 7:31 pm

Re: Vehicle Sprite Bug

Postby Finer » Sat Jan 25, 2014 3:18 pm

I think the problem is exacerbated by one of the Porsche frames having unrelated sprites, as seen in the following image (red arrow):
Image
On the right side, I have recreated what I think are the correct versions (green arrow).

I then took Amethyst's examples and replaced the wheelie Porches with the new sprites; I think it looks more reasonable now.
Image Image

I now have a question about the Ferrari behaviour when running over Height Map patterns. It seems that every time it crosses a height map point, the car judders, or bobs, up and down. Do you think it was intended? It is most odd on gentle inclines, as if the car just went over a pot hole or a big stone. When playing with the elevated camera view, this doesn't happen, as when passing though the other Height patterns.

Finally, I'd like to say how much I'm enjoying playing this game and reading all the posts about how it got made and the rest of the 'oddities' about one of the classic arcade games of all time.
Finer
 
Posts: 1
Joined: Sat Jan 18, 2014 3:56 pm

Next

Return to CannonBall & LayOut

Who is online

Users browsing this forum: No registered users and 1 guest

cron