Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 05:11 24 Apr 2024 Privacy Policy
Jump to

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 States
Posts: 326
Posted: 02:44am 26 Jan 2021
Copy link to clipboard 
Print this post

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: Australia
Posts: 5895
Posted: 03:49am 26 Jan 2021
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 8573
Posted: 08:20am 26 Jan 2021
Copy link to clipboard 
Print this post

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: Canada
Posts: 1082
Posted: 06:27pm 26 Jan 2021
Copy link to clipboard 
Print this post

  matherp said  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

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


To reply to this topic, you need to log in.

© JAQ Software 2024