Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Deep Toaster on October 07, 2011, 06:45:55 pm

Title: Text sprite finder
Post by: Deep Toaster on October 07, 2011, 06:45:55 pm
For making graphical TI-BASIC games, I've always kept a 5x5 [tibd]textsprites[/tibd] finder that takes a sprite in the form of a matrix and finds characters whose leftmost columns help build the sprite. I made it back in 2009 or so, and it was nearly four hundred bytes, which for me back then was an achievement. Last year I figured I'd try fixing it up again and got it down to 308 bytes, but today I decided to try again and cut out half of that. So here's my 148-byte text sprite finder. It takes a matrix (in Ans) as input and outputs a string (in Ans), and destroys L1-L5 and I in the process. Here it is in TokenIDE format:
Code: [Select]
Matr>list(Ans,L1,L2,L3,L4,L5
"?
For(I,1,5
Ans+sub(" .?X+çQB^SplotcrossJ|v[s][e]plotsquareTI:?^^x[xhat]CAY?^^2ZV5è[i]",32fPart(sum(expr(sub("L1L2L3L4L5",I,1))10^5-cumSum(binomcdf(4,0))))/32)+1,1
End
sub(Ans,2,5
I know it could be modified to parse faster and not destroy the lists, but that made it larger and involved destroying [A], which I feel is more valuable than L1-L5.
Title: Re: Text sprite finder
Post by: boot2490 on October 07, 2011, 06:47:14 pm
Cool! I think I might use it.
Title: Re: Text sprite finder
Post by: JustCause on October 07, 2011, 06:47:16 pm
Wow! That's crazy fast and crazy small. Thanks for the code! If I ever get around to finishing my DM utility I'll definitely use this. One question: how does it handle impossible text sprites?
Title: Re: Text sprite finder
Post by: Deep Toaster on October 07, 2011, 06:48:12 pm
They're outputted as a ?. There are exactly three as far as I know (including the two that have equivalents that aren't three chars wide, which is standard).
Title: Re: Text sprite finder
Post by: meishe91 on October 07, 2011, 06:56:50 pm
Nice. I think there is only one impossible column though, unless you're counting sixth row ones too. I should probably go back and look over my (http://ourl.ca/6889/113822) text sprite maker and see if I can change anything. It's over a year old now and in the depth of the projects forum :P
Title: Re: Text sprite finder
Post by: Deep Toaster on October 07, 2011, 07:00:59 pm
Lol I still remember yours -- you posted it just as I was posting my first version of mine, and when I saw yours I thought "oh well" XD
Title: Re: Text sprite finder
Post by: meishe91 on October 07, 2011, 07:04:35 pm
Ah okay :P Well cool. I need to look at my sprite maker (http://ourl.ca/6631/109089) too. I never did add the things I wanted :P
Title: Re: Text sprite finder
Post by: Builderboy on October 07, 2011, 07:08:08 pm
I thought there was only 1 combination that didn't have a character equivalent?
Title: Re: Text sprite finder
Post by: JustCause on October 07, 2011, 07:09:26 pm
I thought there was only 1 combination that didn't have a character equivalent?
I think they all have character equivalents, but not every available character equivalent is three pixels wide. That might break display in a program that assumes that width.
Title: Re: Text sprite finder
Post by: meishe91 on October 07, 2011, 07:12:46 pm
I thought there was only 1 combination that didn't have a character equivalent?
I think they all have character equivalents, but not every available character equivalent is three pixels wide. That might break display in a program that assumes that width.

You're partly right. Every combination has one but there are two others that are more than three pixels wide. I think that's what he means.
Title: Re: Text sprite finder
Post by: JustCause on October 07, 2011, 07:13:33 pm
I thought there was only 1 combination that didn't have a character equivalent?
I think they all have character equivalents, but not every available character equivalent is three pixels wide. That might break display in a program that assumes that width.

You're partly right. Every combination has one but there are two others that are more than three pixels wide. I think that's what he means.
I thought that was what I said. Which is, in retrospect, wrong, as I believe there's one combination without an equivalent. *headdesk* :P
Title: Re: Text sprite finder
Post by: Deep Toaster on October 07, 2011, 07:15:18 pm
01011 (vertically) doesn't have a character equivalents. There are two others that have equivalents that are more than three columns wide, but I gave them ?s because I personally don't use anything more than three columns wide. You can always add it in yourself if you want.
Title: Re: Text sprite finder
Post by: Builderboy on October 07, 2011, 07:48:13 pm
true i suppose, although I would have included them, and then allowed people to remove them if they wanted to impose restrictions, as removing or excluding tokens is much easier than adding them in :P
Title: Re: Text sprite finder
Post by: meishe91 on October 08, 2011, 10:59:50 am
true i suppose, although I would have included them, and then allowed people to remove them if they wanted to impose restrictions, as removing or excluding tokens is much easier than adding them in :P

Well it's only really hard to add things if it is a hidden token.
Title: Re: Text sprite finder
Post by: mrmprog on October 08, 2011, 11:14:56 am
Wow! That is really good. This will make textsprites much easier.
Title: Re: Text sprite finder
Post by: boot2490 on October 08, 2011, 10:41:05 pm
[sarcasm]
Naw, really?
[/sarcasm]
Title: Re: Text sprite finder
Post by: Deep Toaster on October 09, 2011, 01:28:12 am
Hmm? I guess I'll take that as a compliment o.O