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

Update Sprite palette number to support CGB #295

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Update Sprite palette number to support CGB #295

merged 4 commits into from
Dec 6, 2023

Conversation

NicoleFaye
Copy link
Contributor

@NicoleFaye NicoleFaye commented Dec 6, 2023

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

@@ -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
Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Owner

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

@Baekalfen Baekalfen merged commit 53e0eca into Baekalfen:v2.0.0 Dec 6, 2023
28 checks passed
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.

2 participants