Code:
:DelVar WDelVarQDelVarUAns→Str0
:::"BASIC SPRITES
:For(I,0,length(Str0)-1
:sub(Str0,I+1,1
:If Ans="8" or Ans="9" or Ans="A" or Ans="B" or Ans="C" or Ans="D" or Ans="E" or Ans="F"
:Pxl-On(Q,X+W
:If Ans="4" or Ans="5" or Ans="6" or Ans="7" or Ans="C" or Ans="D" or Ans="E" or Ans="F"
:Pxl-On(Q,X+1+W
:If Ans="2" or Ans="3" or Ans="6" or Ans="7" or Ans="A" or Ans="B" or Ans="E" or Ans="F"
:Pxl-On(Q,X+2+W
:If Ans="1" or Ans="3" or Ans="5" or Ans="7" or Ans="9" or Ans="B" or Ans="D" or Ans="F"
:Pxl-On(Q,X+3+W
:1→U
:If W=4 and U
:Then
:DelVarUDelVarWQ+1→Q
:End
:4(U→W
:End


Basically, you use it like

Code:
"EDF12315AC910562":prgmSPRITE

Each character represents a set of 4 pixels constructed by its binary equivalent (EX. D=13=1101)

Is there anyway to make it work faster?

Code:
If inString("89ABCDEF",Ans

etc.
This looks -b-u-g-g-y- inefficient to me. Modified use of var U.


Code:
:DelVar WDelVarQDelVarUAns→Str0
:::"BASIC SPRITES
:For(I,0,length(Str0)-1
:sub(Str0,I+1,1
:If inString("89ABCDEF",Ans
:Pxl-On(Q,X+W
:If inString("4567CDEF",Ans
:Pxl-On(Q,X+1+W
:If inString("2367ABEF",Ans
:Pxl-On(Q,X+2+W
:If inString("13579BDF",Ans
:Pxl-On(Q,X+3+W
:U+1→U:4→W
:If U-1:Then
:DelVarUDelVarWQ+1→Q
:End:
:End
You can use inString like that? :\
Thanks a lot though!
Reapex wrote:
You can use inString like that? :\
Thanks a lot though!
Yup, it returns false when the needle does not exist in the haystack, or a positive index (true) when the needle does exist in the haystack.
Does it test for if Ans is in the string or that 1 char of the string is found in ans?
I'm glad I'm not at this level yet cuz I'm so lost right now.
Lol, you'll get there Razz
http://www.ticalc.org/archives/files/fileinfo/385/38508.html

About as optimized as you are going to get, thanks to Weregoose. =]
tifreak8x wrote:
http://www.ticalc.org/archives/files/fileinfo/385/38508.html

About as optimized as you are going to get, thanks to Weregoose. =]
Just for easy reference, here's the source code of that:

BASIC Code wrote:
:
:I→C:J→U
:length(Str4
:Ans/(2+2(Ans>16)+4(Ans>64→Z
:If min(Ans≠{8,16,32
:Then
:¦ "FFC3A59999A5C3FF→Str4
:¦ 8→Z
:End
:For(B,1,length(Str4
:¦ inString("123456789ABCDEF",sub(Str4,B,1
:¦ If 7<Ans
:¦ Pxl-On(U,C
:¦ If 3<8fPart(Ans/8
:¦ Pxl-On(U,C+1
:¦ If 1<4fPart(Ans/4
:¦ Pxl-On(U,C+2
:¦ If fPart(Ans/2
:¦ Pxl-On(U,C+3
:¦ C+4→C
:¦ U+(C=I+Z→U
:¦ If C=I+Z:I→C:End
Generated by SourceCoder, © 2005 Cemetech
yeah, sorry for the lazyness on that, was just hoping to get some more dls. XD =p

Can't blame a guy for tryin.

Also, you can take out a portion of the code if you want, that does error checking and if the sprite is not an 8x8, 16x16, or 32x32, then it replaces with a small boxed x, like the broken image sign IE uses I think.

Which should be:


Code:
:If min(Ans≠{8,16,32
:Then
:¦ "FFC3A59999A5C3FF→Str4
:¦ 8→Z
:End
KermMartian wrote:
tifreak8x wrote:
http://www.ticalc.org/archives/files/fileinfo/385/38508.html

About as optimized as you are going to get, thanks to Weregoose. =]
Just for easy reference, here's the source code of that:

BASIC Code wrote:
:
:I→C:J→U
:length(Str4
:Ans/(2+2(Ans>16)+4(Ans>64→Z
:If min(Ans≠{8,16,32
:Then
:¦ "FFC3A59999A5C3FF→Str4
:¦ 8→Z
:End
:For(B,1,length(Str4
:¦ inString("123456789ABCDEF",sub(Str4,B,1
:¦ If 7<Ans
:¦ Pxl-On(U,C
:¦ If 3<8fPart(Ans/8
:¦ Pxl-On(U,C+1
:¦ If 1<4fPart(Ans/4
:¦ Pxl-On(U,C+2
:¦ If fPart(Ans/2
:¦ Pxl-On(U,C+3
:¦ C+4→C
:¦ U+(C=I+Z→U
:¦ If C=I+Z:I→C:End
Generated by SourceCoder, © 2005 Cemetech


This might be a complete waste of time, but if you are picky about memory optimization you can save yourself a very small amount by making the 2+2 in the line 3 to 2².
tribal wrote:
KermMartian wrote:
tifreak8x wrote:
http://www.ticalc.org/archives/files/fileinfo/385/38508.html

About as optimized as you are going to get, thanks to Weregoose. =]
Just for easy reference, here's the source code of that:

BASIC Code wrote:
:
:I→C:J→U
:length(Str4
:Ans/(2+2(Ans>16)+4(Ans>64→Z
:If min(Ans≠{8,16,32
:Then
:¦ "FFC3A59999A5C3FF→Str4
:¦ 8→Z
:End
:For(B,1,length(Str4
:¦ inString("123456789ABCDEF",sub(Str4,B,1
:¦ If 7<Ans
:¦ Pxl-On(U,C
:¦ If 3<8fPart(Ans/8
:¦ Pxl-On(U,C+1
:¦ If 1<4fPart(Ans/4
:¦ Pxl-On(U,C+2
:¦ If fPart(Ans/2
:¦ Pxl-On(U,C+3
:¦ C+4→C
:¦ U+(C=I+Z→U
:¦ If C=I+Z:I→C:End
Generated by SourceCoder, © 2005 Cemetech


This might be a complete waste of time, but if you are picky about memory optimization you can save yourself a very small amount by making the 2+2 in the line 3 to 2².


If that were the case, couldn't you just make it 4? However, math doesn't follow that sort of magic. You can't just ignore multiplication.
Thanks for beating me to the punch, Foamy, I was about to say the same thing. Razz Order of operations is somewhat significant.
Woops, I don't know what I was thinking, sorry Razz
I made a smaller (possible rival) program :O
Now it can do any sprite size.
tifreak, I used the code you used to render the pixels.. but the rest is my coding Razz
It's only a tad bit slower (3 seconds slower on a 32x32 sprite)
Only 217 bytes.
Format is like this:
"(2 digit sprite size)(2 digit X coords)(2 digit Y coords)(sprite)":prgmSPRITE


Code:
:DelVar QAns→Str0
:expr(sub(Str0,3,2→D
:expr(sub(Str0,5,2→J
:D→U
:expr(sub(Str0,1,2→Z
:If length(Str0)≠Z2/4+6
:Return
:For(I,0,length(Str0)-7
:Q+J→S
:sub(Str0,I+7,1
:inString("123456789ABCDEF",Ans
:If Ans>7
:Pxl-On(S,D
:If 3<8fPart(Ans/8
:Pxl-On(S,D+1
:If 1<4fPart(Ans/4
:Pxl-On(S,D+2
:If fPart(Ans/2
:Pxl-On(S,D+3
:D+4→D
:If D≥U+Z
:Then
:U→D
:Q+1→Q
:End
:End

What do you guys think? :O
Just checked, on calc, it is 213 bytes. Without error checking, it is.. 171 bytes. =]
I could make mine smaller if it didn't use substrings for coords and size Razz
Then you have to limit the size of the sprites to known values. At which point, you would have to have something there that would be able to interpret said sizes automatically, etc. =p

Mine loses -no- usability when dropping the error checking. =p
What do you mean?
Mine just quits out if the length is incorrect 0.o
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement