0 Members and 1 Guest are viewing this topic.
"0"->Str1For(A,0,71->XY+offset->YFor(B,0,7X+offset->XIf pxl-Test(X,Y:Then"1"+Str1->Str1Else"0"+Str1->Str1EndEndEndsub(Str1,2,length(Str1->Str1
GetCalc("Str1",16)->I .I points to the start of the data at Str1For(P,0,15 .16 half-bytes0->C .CounterFor(T,0,3 .4 pixels per half byte. e^(3-T)*pxl-Test(P^2*4+T,P/2)+C->C End{"0123456789ABCDEF"+C}->{I+P} .store corresponding hex character intoEnd
"_?Str2For(A,0,7For(B,0,7,48pxl-Test(A,B)+4pxl-Test(A,B+1)+2pxl-Test(A,B+2)+pxl-Test(A,B+3Str2+sub("0123456789ABCDEF",Ans+1,1?Str2EndEndsub(Ans,2,16?Str2Disp Ans
got you there, meishe (:by the way, the BASIC version i linked to probably shouldn't be used if speed is important. it's slow. i think i timed it at 3 seconds, and it's about 92 bytes. then i clocked one that was about 120 bytes but it was twice as fast.
pxl-Test(X, Y)+"Str1"->Str1
qwerty, may i suggest real-time hex display? the hex routine i wrote in this thread would take a few seconds to execute under TI-Basic, but with Axe it's not even humanly noticeable. maybe you could get hex to display every time you change a pixel on the screen? if you do this, you'll find flipping/rotating much easier, since you can then use the built-in functions for it.
Hey that's cool! Porting a program an excellent way to learn Axe given a background in BASIC.By the way, would a >Hex command be useful? I already have a >Dec, >Char, and >Tok so in a similar way I can add a >Hex. There is even a really cool optimization for it that uses the daa instruction which is something I've never used but always wanted to.
That sounds exactly like my sprite editor. But thanks for reminding me about it, I should work on it a bit more.
By the way, would a >Hex command be useful? I already have a >Dec, >Char, and >Tok so in a similar way I can add a >Hex. There is even a really cool optimization for it that uses the daa instruction which is something I've never used but always wanted to.
GetCalc("Str1",16)->I .GetCalc() is used to write to external variables. it reads "Str1" and locates the OS variable Str1.It then makes Str1 16 bytes (which is equivalent to 16 characters) long..Storing this to pointer "I" will allow us to read and write to the data currently in OS var Str1.For(P,0,15 ..Loop through 16 times, as an 8x8 sprite has 16 hex characters0->C .A holder variable, to get each value of the hex string. a better explanation below.For(T,0,3 .there are 4 pixels needed to test to determine. why 4 pixels?.because a hex character can hold values 0-F, or 0-15. .if you take 4 pixels as a binary string of 0's and 1's, the highest value.possible is 16, or 2^4.e^(3-T)*pxl-Test(P^2*4+T,P/2)+C->C .This is tricky. first, the correct power of two is calculated. e^(3-T).which returns either a 8, 4, 2, or 1 depending on the value of T..pxl-Test() returns a 1 or a 0. if there's no pixel, the value won't be added..If there's a pixel, e^(3-T) will be multiplied by 1, added to C giving the value of the half-byte..P^2*4+T,P/2 is some arithmetic explained below.End{"0123456789ABCDEF"+C}->{I+P} .the part in quotation marks is 16 characters long. this means it's 16 bytes long..the curly {} brackets get the byte (in this case, a character) at a pointer.."0123456789ABCDEF" is a pointer, and so is the variable C..Since C contains the value of the halfbyte, when you add the part in quotations to C,.you get the corresponding character in the string to the value of the half-byte..Remember how I points to our OS var Str1? now it's storing our hex character.into the string. P shifts the characters along the string.End