Strategies to convert a bitmap into OR-color sprites for MSX 2

Par albs_br

Champion (473)

Portrait de albs_br

18-10-2021, 00:01

Hi, fellows.

This would be something simple, but turned out to be not so easy:
I have an image (say a sprite sheet from some commercial 90's game) and want to convert it to a series of 16x16 sprites, with two overlapping and using the OR-color capability. So, 3 colors for each 16 pixels horizontally.

My approach is:
- Convert the bitmap to .SC5 file using BMP2MSX, so I don't have to deal with reducing color count, it makes it for me.
- After that I am trying to create a script to make the conversion of the .SC5 to sprite patterns and colors. But here is the problem, the colors that can be used on OR-color are restricted. I'm not willing, at least for now, to brute force all combinations until find one that fits.

Is this a good approach? Am I missing something? Are there aready tools that makes this work for me?

!login ou Inscrivez-vous pour poster

Par Metalion

Paragon (1625)

Portrait de Metalion

18-10-2021, 08:32

Hello,

The OR color is a problem that had been bothering the MSX developers for ages ... AFAIK, there is no "automatic tool" to do this, notably because it involves choosing the right palette structure to suit your needs, both for the sprites and the decor. And there is no automatic way to do that, it's mostly manual work.

I would suggest reading the excellent wiki article on the subject: https://www.msx.org/wiki/The_OR_Color

Par albs_br

Champion (473)

Portrait de albs_br

19-10-2021, 03:28

Actually I managed to solve it by brute force (using random palette combinations instead of a lot of nested loops).

Hopefully soon I will have something cool to show.

Par wolf_

Ambassador_ (10109)

Portrait de wolf_

17-11-2021, 09:52

I too was working on this kind of conversion, I think I nailed it last night. Question for coders though;

If a line o' colors has 8 9 12 13, then these can be reduced to sprites 8 9 12 (you get 13 as a bonus), which is nothing more than visual trial 'n error by myself. However, my algo gives 1 4 8 as result. And this indeed also gives 13 as a bonus, and 5 and 9 and 12. On paper my algo does a better job, but as I wouldn't need these extra colors it wouldn't be necessary. Would a coder be able to come up with a reason why one combination would be favored over the other? Does the VDP need more processing cycles by offering four bonus colors rather than one? Or is any combination of three sprites alright?

Par bore

Master (169)

Portrait de bore

17-11-2021, 11:22

If there are no other sprites I see no reason to why one combination would be better than another.

With other possible sprites on the line you might want to take into consideration what colors you get if one of the sprites are blanked due to having too many sprites on the line.
In that case the 8 9 and 12 combination sprite won't take any colors not originally assigned to the sprite.
A 1, 4 and 8 combination sprite could suddenly show color 1, 4 and 5 as a result.
(I think, I haven't tested any of this.)

If the sprite with color 8 have pixels set for color 9,12 and 13 too (even if it is unnecessary.) the sprite will keep its shape even if the two other sprites are blanked out.

Par Grauw

Ascended (10772)

Portrait de Grauw

17-11-2021, 13:37

wolf_ wrote:

Does the VDP need more processing cycles by offering four bonus colors rather than one? Or is any combination of three sprites alright?

If your definition of processing power is the availability of access slots to the command engine or the CPU, then any combination of sprites will take equal processing power for the VDP, the amount of free VRAM access slots does not change.

If your definition of processing power is the amount of sprites it can process per line, it’s of course equal to the number of sprites used, with the max capacity being 8.

Par wolf_

Ambassador_ (10109)

Portrait de wolf_

17-11-2021, 15:34

I was referring to a situation where a number of colours can be represented by multiple combinations of OR-sprites, and whether there's a good reason to pick one combination over another. If there's no performance issue (as you suggest, Grauw), then what's left to consider is bore's sprite flickering situation.

https://youtu.be/0ZePpFKaeks?t=3369

Usas, see those cyan creatures on the floor (any idea what these creatures are called?). At some point there are five of 'em and things start flickering. If have the impression that a whole cyan creature flickers, not just half of it due one sprite, you can test by mouse-clicking youtube to pause the video. So I wonder if this is how everyone makes their game: if sprites on a row are used up, a whole NPC disappears, rather than a sprite layer.

Hence, it'd be nice to know whether it really doesn't matter what colour combination is used, or whether coders want the lowest amount or highest amount of bonus colours for their sprite characters.

Par Parn

Paladin (837)

Portrait de Parn

17-11-2021, 15:49

It looks like Konami recycles the entire sprite group. This also happens later, while fighting the boss, which makes parts of the main character flicker.

Par Grauw

Ascended (10772)

Portrait de Grauw

17-11-2021, 16:24

If you don’t cycle the entire sprite OR-group, then depending on which subsprite is cycled you will get different colours or the entire sprite will disappear if it’s the first. I don’t think it’ll look good and cycling the entire group seems the sensible approach, I don’t recall seeing it done otherwise.

What could be interesting is to design the sprites such that if only the first sprite is shown you still get a readable silhouette, and then if there’s too many sprites on a line you render only the first sprite, instead of flickering between them. So sort of a LOD system where the sprite fidelity is lowered as needed. Though it does sound like a hassle tbh, so I would only attempt it if the game design absolutely requires it for some reason.

Par bore

Master (169)

Portrait de bore

17-11-2021, 17:52

If you keep track of the number of sprites per line anyway you can just have a separate single-color version of the sprite to switch to.

The benefit of selecting the colors so that one of the sprites "looks good" on its own is that you don't have to keep track of it. Just allocate the lower sprite numbers for the first sprite in each object and let the video chip downgrade automatically if they happen to be on the same line.