Skip to content

Conversation

@gm-matthew
Copy link
Contributor

When emulating System 24 tilemaps (which Model 2 uses) MAME currently treats color 0 of any palette as transparent, but some Model 2 games use color 0 to encode tile-specific colors. Here is a screenshot of Behind Enemy Lines demonstrating the problem:

image

Here is what that screenshot is supposed to look like:

image

The Sega System 24 Hardware Notes specifies the following when ABSEL=0:

Zero value pixels from the topmost layer are considered transparent.
Zero value pixels from the bottommost layer show color 0 of the specified
palette.

If the topmost layer is blanked, it is considered transparent.
If the bottommost layer is blanked, it is filled with color 0 of palette 0.

On Model 2, tilemap B is usually the bottommost layer unless it has the priority flag set, in which case either tilemap A or the framebuffer is the bottommost layer depending on whether tilemap A also has the priority flag set. However, I have observed that the polygon layer is never displayed if it is empty even if both tilemaps A and B have priority (Virtual On title screen). It is unknown whether tilemap A would instead be chosen if tilemap B has priority set and tilemap A does not, making tilemap A the bottommost layer; I have not observed any games that depend on this.

The easiest solution I have found is to display color 0 from the tile-specific palette of tilemap B if all three would otherwise be transparent; this seems to fix all tilegen issues. My current solution works by drawing the layers in this order:

  • tilemap B without priority as opaque
  • tilemap B with priority as opaque
  • tilemap A without priority
  • frame buffer
  • tilemap B with priority
  • tilemap A with priority

The solution is not quite as neat as I'd like it to be so I'm submitting this commit as a draft for now; any ideas to make the solution more elegant are welcome.

If all three layers (polygon, tilemap A, tilemap B) are transparent, palette entry #0 from tilemap B is shown
@angelosa
Copy link
Member

angelosa commented Nov 4, 2025

There are several games that depends on background pen being chosen by lowermost layer, the most notable is crkdown.
I also vaguely remember a bug of the like in Model 3, don't remember which game tho.

@mamehaze
Copy link
Contributor

mamehaze commented Nov 4, 2025

Yeah the map display has been broken on Crackdown forever in MAME, bits that are meant to be solid are showing as transparent.

@gm-matthew gm-matthew marked this pull request as ready for review November 6, 2025 03:24
@gm-matthew
Copy link
Contributor Author

I've come up with a more elegant fix which uses the TILEMAP_DRAW_OPAQUE flag when calling tilemap_t::draw() and also adds the feature to draw_rect() .

I am satisfied with my current solution so I am declaring this commit as ready for review.

Regarding System 24 specifically, are there any other games besides Crack Down that are known to have similar tilemap bugs?

@angelosa
Copy link
Member

angelosa commented Nov 6, 2025

qsww draws like this at startup on master tip, which apparently is a transparent pen issue
0000

Copy link
Member

@angelosa angelosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MooglyGuy MooglyGuy merged commit 1b4bd1d into mamedev:master Nov 6, 2025
7 checks passed
@gm-matthew gm-matthew deleted the model2 branch November 7, 2025 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants