-
Notifications
You must be signed in to change notification settings - Fork 487
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
Update Sprite palette number to support CGB #295
Update Sprite palette number to support CGB #295
Conversation
pyboy/api/sprite.py
Outdated
@@ -116,15 +116,18 @@ def __init__(self, mb, sprite_index): | |||
The state of the bit in the attributes lookup. | |||
""" | |||
|
|||
self.attr_palette_number = _bit(attr, 4) | |||
if self.mb.cgb: | |||
self.attr_palette_number = attr & 0x3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I had completely missed that. Generally the API has not been fully updated for CGB.
I think it should actually be attr & 0x7
, as it's 3 bits https://gbdev.io/pandocs/OAM#byte-3--attributesflags
And I see that the bank attribute is missing too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i was tired when i found it, i was thinking 3 bits and i wrote 3 lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the bank number var i added and see if that implementation makes sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! The system I use for docs is a little weird, so I added a commit to fix that. The docstring has to come right after the variable, and it cannot be in an if
-statement.
I also almost fell for the 3 vs. 7 haha
I noticed that the palette in the sprite object only supported DMG mode as bit 4 is unused in CGB mode and instead uses bits 2-0 for the palette options
https://gbdev.io/pandocs/OAM