Devlogs
LynxJam2023 - day 9
Posted December 06, 2023 by KanedaFr
#lynx
I spent the last days working on the game engine.
While trying to optimize the text part, I browsed CC65 TGI driver to look how it handles text.
I talk about tgi_outtextxy( ) mainly.
What it does :
- store x,y on 2 zero page vars for faster access
- call outtext native method
- compute size based on number of characters
- create a bitmap of this size
- copy each char bitmap from the tgi font to this large bitmap
- create a sprite with this large bitmap as sprite data
- compute size (again !) based on number of characters
- add it to store x,y
So
Pros :
- you can use tgi_outtext right after, the text will be at the right position
- you can also use tgi_gotoxy any time
Cons:
- The size is computed twice so we lost ticks
- The bitmap isn't cache (and you can't get it either to cache it yourself), so it's done EVERY frame
- You can't change the font
- You could make you're own outtext with own font...but you can't remove the native one so more bytes lost