-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Variable bit-per-pixel drawing #1099
Conversation
Fixes #1074 - the first nibble of 0x03FFC serves as a register to control the target of the drawing function. - spr, map and textri can use variable bpp, font will come later - tic_tilesheet is used as the representation of a bpp-aware tilesheet window in memory
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.
A very cool addition that expands creativity for users without breaking compatibility with the older carts.
The code looks very polished and I'm very happy to approve such a nice feature.
Thank you for your contribution 👍
PS. pls, don't hesitate to add your nickname to the license header in the code :)
🤯 💥 |
Thanks for your approval, and thanks a lot for your insight, support and reactivity! I hope this feature will be useful to many :) |
Could you please update the wiki? |
I'll try to write some documentation for the wiki. For the demo cart, I borrowed fonts from other carts for which I don't really know the license, including those can be a problem. I can try to come up with something else. |
i understand how sprites and spritesheet works , I don't understand how flags , map , etc work . Is it possible for someone to write function that when called changes bpp and it reflects over map , fset , fget , textri ,etc ? Just a thought 😄 because it's excessive use of poke4() function 😃 and complex gymnastics |
You could theoretically implement a whole game using 2bpp graphics with a single call to poke4, using only one page of memory for Reference documentation for the feature is there: Advanced Drawing Techniques, I'll try to improve it with your feedback and bake more examples. |
This PR introduces a way to draw the spritesheet with different bpp, allowing a more optimized use of the spritesheet memory for graphics that only use a few colors.
blit segment spec:
Pixel stretching
Low-bpp stretches pixels on the X axis when reading the spritesheet.
In 2bpp, the spritesheet becomes twice as large, but stays the same height.
Indexing:
Low bpp stretches indexes on the X axis.
In 2bpp the full index of the rightmost sprite of the first line is 31
In order to preserve compatibility with drawing functions that use total spritesheet indexes (index>255) and prevent reading out of the allowed memory segment, the whole spritesheet wraps around on both vertical and horizontal axis and the segment is interpreted as a translation of the origin of the spritesheet.
Internal access to a tile must specify if they use local indexing (index < 255:
map
,font
,textri
withuse_map
) or total indexing (index < 255 * 2*nbPages:spr
)(default)Lifted indexing limitations
Using the blit segment, map and font can draw from other parts of the spritesheet than their default However, they can't draw from more than 1 segment in the same call, as they still use 8bits indexing.
System sheet and font:
blit segment values 0 and 1 are reserved respectively to implement a 1bpp system spritesheet and to access the 1bpp font sheet.
Font drawing:
In order to preserve compatibility with existing font calls drawing from sprites, BG and FG sheets are swapped in
font
's interpretation of the blit segment.The endianness of the system font in memory has been adjusted to read like sprites.
Flags:
fset
andfget
don't take the blit segment into account, because it would be tedious to keep poking the blit segment to retrieve for flags. The user has to adapt their use of flags if necessary.Sprite Editor:
The UI has been adjusted to allow edition in different bpp modes and navigation in a larger spritesheet.
Test cart :
https://gist.github.com/ddelemeny/956ae9496a6ce124cc1f43a316b14325