Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: leafy on February 03, 2011, 09:46:50 pm
-
I'e searched it up, but i can't find out how to compress tilemaps using RLE. I saw how to decompress using the routine though.
-
Here, [ctrl] [f] "RLE" on this page: http://ourl.ca/7818
Good luck! ;D
-
Yeah I saw that, but it stores the compressed map into an appvar - How do I just get it to display the compressed map data?
EDIT: NEVAR MIND I SEE.
-
How do you determine the size of the compressed map beforehand? I keep getting gibberish when i try to compress a 18 by 12 tilemap
-
Which routine are you using?
-
This one http://www.omnimaga.org/index.php?PHPSESSID=42e30a9bce8fdd375ed37eb181ff9432&topic=1532.msg50859#msg50859
-
This one http://www.omnimaga.org/index.php?PHPSESSID=42e30a9bce8fdd375ed37eb181ff9432&topic=1532.msg50859#msg50859
you could fill a safe ram area with 0's and then rather than export to an appvar, export to the safe ram and then use length([saferam]). or you just could keep a byte counter, everytime you write to the appvar, increment the counter accordingly.
-
I don't quite get it - could you write some pseudocode or something?
-
actually, just kidding. my routine already keeps track of the size. variable D should contain the size.
-
Wait, you create the str1 appvar BEFORE D is calculated - so how does this work again?
-
Try instead of creating the appvar beforehand, compressing the map into L1, or a large piece of memory. After you finish compression, you know the size and you can create the right sized appvar :)
-
So store compressed map into L1 --> Create appvar with size D --> Store L1 into appvar?
-
Yep, that should work :) That is, are you able to write the compression routine in itself? or do you need some pointers?
-
Okay, I modified Nemo's compression routine so it works fine except for one thing - it glitches whenever there are more than 16 of any hexadecimal value in a row, at which point it reads off the hex string into char randomness.
How to fix?
-
Okay, I modified Nemo's compression routine so it works fine except for one thing - it glitches whenever there are more than 16 of any hexadecimal value in a row, at which point it reads off the hex string into char randomness.
How to fix?
the routine compresses data into two nibbles. the first is frequency, the second is the tile number. though that shouldn't be happening because my routine does check to see if you're trying to put more than 14 (why 14? i can't say, i wrote that a long time ago.) into frequency. if you can give me uncompressed and compressed data, i could better identify the bug.
-
.ROUTINE
mapdata->GDB1
"0123456789ABCDEF"->Str1
"Str1"->Str2
0->C->D
For(G,0,23) .23 is the size of the map minus one.
If {GDB1+G}->A={GDB1+G+1} and (C!=14) . "!=" is the does not equal sign
C+1->C
Else
{Str1+C+1}->{L1+D}
{Str1+A}->{L1+D+1}
D+2->D
0->C
End
End
GetCalc(Str2,C)->M
Copy(L1,M,C)
Return
But when there's more than 16 of any character it screws up. I think this could be solved, for instance, if there were 20 zeros just make it F040 or something.
-
.ROUTINE
mapdata->GDB1
"0123456789ABCDEF"->Str1
"Str1"->Str2
0->C->D
For(G,0,23) .23 is the size of the map minus one.
If {GDB1+G}->A={GDB1+G+1} and (C!=14) . "!=" is the does not equal sign
C+1->C
Else
{Str1+C+1}->{L1+D}
{Str1+A}->{L1+D+1}
D+2->D
0->C
End
End
GetCalc(Str2,C)->M
Copy(L1,M,C)
Return
But when there's more than 16 of any character it screws up. I think this could be solved, for instance, if there were 20 zeros just make it F040 or something.
that's because this compresses into a tilemap where the first nibble is the length of the run, and the second nibble is the tile number. it shouldn't mess up for a run of length 16+. it should mess up if you have more than 16 tiles, yes.
here's a modified routine [untested] which will RLE compress map data when you have < 256 tiles and the length of the runs are < 256.
.COMPRESSION
mapdata->GDB1
"0123456789ABCDEF"->Str1
0->C->D
For(I,0,XX) .XX is the size of the uncompressed map minus 1.
If {GDB1+I}->A={GDB1+I+1} and I != XX
C+1->C
Else
Copy(C>Hex,L1+D,2)
Copy(A>Hex,L1+2+D,2)
D+4->D
0->C
End
End
GetCalc("Str1",D)->A
Copy(L1,A,D)
excuse me if it's inefficient, i haven't coded in axe in awhile.