[Game]Pokitto Grand Prix

No rush, I will take some time until I get all optimized and mipmapping to work.

I will put all graphics + my scritps for making them to GitHub soon.

1 Like

I tested this and surprisingly it did not affect to the fps. After a second thought, it was quite understandable:

  • Without optimization, I am doing one add and one shift per pixel for calculating the next U pos.
  • With the LUT-optimization, I am doing one add ( array lookup) and one memory read per pixel to get the next U pos.

What is counter-intuitive is that when I switched my LUT to have 8-bit values instead of 32-bit values, it is slightly faster (!). This is not the first time I notice this kind of oddity.

2 Likes

Wait, but with the original approach you also have to convert each fixed point coordinate to int coordinate, which is an additional step? This is the main reason I precompute these indices.

Yes i was storing int values to the Lut.

There is no more need to make te billboard objects a square size.

2 Likes

I think I will try loop unrolling optimisation next.

1 Like

How do you do that? With #pragma unroll? Doesnā€™t -O3 do most of this?

By hand ofcourse. :nerd_face:

3 Likes

I can imagine @Pharap doing this with templates :exploding_head:

2 Likes

When accessing a byte LUT, the index can be used directly. For 32-bit, the index must be shifted left (multiplied by 4) first. Thatā€™s just one cycle, so itā€™s probably not noticeableā€¦ but it might occupy an extra register, forcing GCC to push something else to RAM then read it back later. The amount of registers available is really limiting on Thumb2.

3 Likes

The compiler does not know how many items to unroll, if the loop limit is not constant. @jonne has used this a lot when blitting the buffer to LCD.

1 Like

You are correct. Checking in the assembly, this time the optimizer has a spare register and it decides to maintain separate (in addition to index) counter for the LUT which it increments by 4 each round.

2 Likes

A new version:

  • starting line
  • other cars (still), cactuses, and rocks (all by @Pharap)
8 Likes

The attention to textures really helps, it looks better than the original F-zero.

3 Likes

There are 32 billboard objects on screen (including cars). Only one div-instruction is needed per object (i.e. 1/z) when calculating the billboard object position and size. No mipmapping is yet used for billboard objects.

2 Likes

Well they probably donā€™t need mipmapping since they always are at the same angle anyway.

Great job! Itā€™s looking really nice and smooth.

Thanks! Mipmapping is also used to dim the objects in distance, and to reduce contrast to reduce flickering. But it might be that it is not so much needed as with tiled textures. Letā€™s see when I get the implementation ready.

1 Like

Mipmapping is for downscaling, which is going on here when the sprites get far away, so they would be helpful. For objects that scale down nonuniformly (e.g. tilt in respect to camera) there is an extension of mipmapping called anisotropic filtering.

My concern with mipmaps here is that youā€™re supposed to create them manually, right? It can be a little bit of extra burden on the artist ā€“ normally they get generated automatically. But if they were computed by the game, theyā€™d have to be stored in RAM, which is bad. How about creating a tool that would precompute mipmaps before compilation? Or instead of ā€œrealā€ mipmapping just do some ā€œsmartā€ scaledown ā€“ e.g. try to preserve sharp lines, automatically lower contrast, always preserve the edge columns/rows etc. (this could be partially precomputed). Just thinking aloud.

1 Like

I am soon going to have lap times in the race. For that I need numbers as a bitmap. I can always use PokittoLib fonts as a base, or get free fonts from the web. But if @Pharap or somebody else in the community feels like drawing some numbers, and leave his or her mark in the game, I am happy to include that in there.

1 Like

What font size do you need? And do you want them in colour? If so which colour?

1 Like