Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Data statements from Sprite File?
Author | Message | ||||
toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 326 |
Does anyone have a program that can generate DATA statements from a sprite file? I'd like to keep my programs all in one file without having to read in a sprite file. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5895 |
Are you interested in PNG image sprites or the text based ones? For PNG image style, I posted a method a couple of days ago. https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=13382#162965 Note that I used a simple HEX encoding which is much faster than base64 but at the expense of larger files. It would be simple to change it to base64 if there are many large files to encode. If you are using the text based sprite format files, you could skip the encoding part and save the lines of the files as DATA statements 'as is' The other method is to convert the sprites into an array of RGB values and use SPRITE LOADARRAY. The array data needs to be entered as DATA statements and read into the array. That has the advantage of not writing temporary files to SDcard and allows you to use a larger range of colours. The disadvantage with this method is the much bigger file sizes. Jim VK7JH MMedit MMBasic Help |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8572 |
The fastest method would be to convert the file into a pseudo CSUB. Then use PEEK(CFUNADDR to get the address in mmemory. DATA statements are very slow |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Could you then poke the address of the CSUB into the variable table so a particular variable 'points' to the CSUB data? Visit Vegipete's *Mite Library for cool programs. |
||||
Print this page |