-
Notifications
You must be signed in to change notification settings - Fork 36
Implementation of bitmap primitives for SC-3000/SG-1000 #69
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
base: master
Are you sure you want to change the base?
Conversation
|
Interesting! |
|
This implementation requires that the tiles are sequentical ordered, row by row. The function consist of two parts, reading from vdp the byte which contains the pixel pattern(of tile line) and reading the byte for the color information(2 nibbles fg, bg ). A sample is attached, using the bresenham for drawing a line. |
|
I see, |
Add Windows support for Makefile
|
Ok, the naming isn't great, I can rename the putPixel macro as setPixel with fixed foreground flag but how should I name the two functions? |
|
No, sorry, I wasn't complaining about the naming at all. Also, I have no idea what's best here, if to have a single function that prepares the tile order in the PNT and sets the background color such as Of course this means sharing the same background color for the whole screen - unless a separate function is provided to update the background color for a specific rectangular area of the screen. In short, I don't know what's the best approach, but I'd like something that it's simple to use. |
|
I'm still thinking about this. Maybe a solution could be, after having initialized the bitmap to an empty (all zeroes) starting point with a background color of choice, have a single function to draw a pixel that works like this:
How does it sound? I think this would work very well for 99% of the cases, and we would just need a function to update the color info in case the user wants to change the background color for a specific location... |
|
I'm still elaborating in my head about this, and I think we could even have an interesting twist on the above approach if:
This would result in a faster operation when drawing using the single color we specified while initializing, but also when successive calls want to set the same foreground color that's already set, because we won't need to pointlessly update another byte in VRAM. You opinion on this? 😃 |
|
Sorry for my delayed answer, too much holidays in Germany now and lately:-) |
Simplify drawing API
When the third parameter in the setPixel function doesn't match with either the current background or the current foreground color information for the pixel, we have to set a new foreground color information for it, using the requested color value.
Isn't that the transparent color? I think this should be a valid color both for the background and for the foreground, unless it's pointless (can sprites be set behind the background image in Mode 2?) 🤔 |
|
Actually your previous message just give me an additional idea: what if the third parameter could be either an actual color (0-15) or be a pseudo-color, that is some way to tell the function that we don't want to mess with the color information at all? What I mean is: if you want to draw a pixel of color 4 you do something like Does this sound like something that could be useful? I mean, once you initialized the bitmap mode you could in theory just use that as a 1bpp bitmap using just these two above and that would be faster... |
|
FYI, I just updated the PR where both functions are merged into one, setting pixel and coloring. |
I'm not sure I get what you mean here 🤔
We could leave this feature out for now, possibly improving later if needed.
Yes, that's why I insisted in having a single function to plot a pixel of any color, regardless of what is the existing color information for that area. |
|
I went through your latest commits and it looks like it's not working as expected. For instance, if you initialize the bitmap with green as foreground color and black as a background color, then drawing a black pixel will change the foreground color of that area while it should instead use the background color. The I suspect it's my fault not explain well enough how this should work - my point was to avoid useless changing of color information either explicitly (using two constants such as Let me know if you thought of a simpler approach, in the user point of view. |
Add unsetting pattern pixel Improve drawing performance by reducing WAIT's
|
With the latest commit it should be fixed.
The third argument color expect values from 0-15 &16 for foreground, to suppress color update NO_COLOR_UPDATE is(16) used. |
|
Sorry, this is not going towards the way it should work, especially the setPixel function should never affect the BMP background color. Let me try to be clearer with some pseudo-code. |
|
Let's make this simpler, let's leave the Something like this would work just fine: |
|
Back to this! I tried to rework your SG_setPixel, and this is what I got (note: untested code!) So this works as one would expect: the pixel on screen at (x,y) will get the color specified in the function call (color is 0 to 15 as expected) but the function will skip updating the color memory if it's possible, which is when the desired color happen to be already the current FG color or the current BG color of that block. How does that sound to you? I'm looking forward to your opinion 😃 We can talk other improvements later. |
|
I wanted to see if the code above was actually really working, so I made a quick test using code from your example. It works, I just had to rename that
Here's the source and the compiled ROM if you want to see how it is: test.zip Emulicious' profiler says it takes from 899 to 1214 cycles at each call, which doesn't seem so bad. Let me know what you think about this solution. Cheers! |
|
I just pushed an update to SGlib adding support for a bitmap mode, and I have rewritten the C function to put a pixel in assembly so that it's way faster now. To initialize the bitmap mode you use After the initialization you can draw pixels in any color using I hope you find this useful 😃 If you want to provide code for an example that shows how to draw something, that is really appreciated. |

Tested with Meka, Emulicious and SC-3000H, looking good for me.