SourMesen / Mesen

Mesen is a cross-platform (Windows & Linux) NES/Famicom emulator built in C++ and C#
https://www.mesen.ca
GNU General Public License v3.0
1.26k stars 319 forks source link

HD Pack Feature Request: Attach additional tiles to a sprite tile #565

Open mkwong98 opened 5 years ago

mkwong98 commented 5 years ago

Allow HD pack to define additional tiles to be rendered when a matching sprite tile is found.

  1. In the hires.txt, add lines which define the tile data and palette of a sprite tile, relative location of the additional tile and the replacement graphics of that tile.
  2. The emulator has an array similar to the OAM for storing the additional tiles.
  3. The emulator reads the OAM once before rendering the screen to see if there is a match.
  4. If a match is found, the emulator adds the additional tile to the array. The flip and priority will be the same as the sprite. The location of the tile will be calculated from the location and flip of the sprite.
  5. When rendering, the emulator will read the array and render the additional tile in the same way as HD sprite but the additional tiles do not count towards the 8 sprites per scanline limit

This is the easiest way of expending sprite graphics that I can think of.

SourMesen commented 5 years ago

This is most likely possible - my main concern is finding a way of doing it without affecting the emulator's performance (e.g when no HD packs are used). At the moment the functions that are overloaded by the "HD PPU" wouldn't allow me to implement this, so I would probably need to make more functions virtual functions, or copy most of the PPU's code twice over and have a single virtual "Exec" function on both PPUs. Neither of these options are great, I'll have to see if I can find a better solution by looking at the code (rather than just thinking about it while typing this :p)