Open Gronis opened 10 months ago
There are various things that I'd change/optimize/code differently. I need to think more about this. I may just merge it in a separate branch and slowly work on it before porting it to main.
Sounds like a good plan. It's your codebase so I was expecting you to rewrite some parts that you don't like anyways. At least the current state works well and I reasonably presentable.
However, there were some things that turned out slightly more complicated than I would've like, for example the font shadow logic which uses colors 15 and 7 specifically because 15 | 7 = 15 and 2 | 15 = 15 and 2 | 7 = 7 witch simplifies the rasteriser part. Also, the idea with the allocate tiles function was to allocate several tiles at once, by counting how many tiles were needed before rasterising characters, which in the end didn't happen.
For curiosity, what part do you think should/can be optimised? Too me, the slowest function seems to be convert_1bpp
which will loop 64 times for each tile. Or maybe you mean optimise for ease of understanding/readability? Just curious :)
Haven't really looked at it, so I don't really know, besides the style.
In regards to your question, for 1bpp conversions you can prepare a 1bpp to 4bpp conversion table for the single rows, meaning you only need to iterate 8 times.
Plus, if you make the assumption that tiles are 8 rows tall, you can unroll your loop to reduce jumps.
You can see what I mean (although in assembly) here: https://github.com/Lorenzooone/M3_Eng_1_3/blob/master/general_hacks.asm#L237
That sounds like a good idea. But you probably need 2 tables since there are two font colors (foreground +shadow). That should take and additional 2kB of ram which is not very much and provide a significant speedup. Good idea 👍
Fixes #10