Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly support games that use 8x16 sprites #30

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

quephird
Copy link
Owner

@quephird quephird commented Sep 24, 2024

I only recently figured out that games like Gradius, Castlevania, and even Galaga use 8x16 sprites, which explains why I only saw half of the sprites, or sprites were otherwise only partially rendered, while playing them in my emulator. And so this PR introduces changes to support such sprites, making games like them actually playable. The following changes were made:

  • New computed properties for sprite and tile width and height to centralize magic numbers
  • bytesForTileAt() now takes a bank index instead of a ControllerRegister instance for more general usage, namely because 8x16 sprites
  • cacheSpriteIndices() was updated to consider the height of both 8x8 and 8x16 sprites when selecting sprites per each scanline
  • getSpriteColor() does the most work for 8x16 sprites, now determining:
    • the pixel x and y coordinates within the tile, taking into account the height of such sprites, as well as the horizontal and vertical flip bits
    • the tile index, which is dependent on the tile index byte, but is formed from its first seven bits, using them as is for the top tile, but that value plus one for the bottom tile
    • the bank index, which is obtained from the last bit of the tile index byte not from ControllerRegister
    • the color index, needs to use the correct tile index as well as adjust the y value passed in when handling the bottom tile

@quephird quephird force-pushed the get_gradius_sprites_displaying_properly branch from 118f520 to 9e22119 Compare September 24, 2024 04:29
@quephird quephird merged commit fca8ced into main Sep 24, 2024
@quephird quephird deleted the get_gradius_sprites_displaying_properly branch September 24, 2024 20:18
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.

1 participant