Author Topic: RLE compression  (Read 9104 times)

0 Members and 1 Guest are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
RLE compression
« 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.
In-progress: Graviter (...)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: RLE compression
« Reply #1 on: February 03, 2011, 10:25:01 pm »
Here, [ctrl] [f] "RLE" on this page: http://ourl.ca/7818

Good luck! ;D

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #2 on: February 03, 2011, 10:47:48 pm »
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.
« Last Edit: February 03, 2011, 10:48:42 pm by leafiness0 »
In-progress: Graviter (...)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #3 on: February 04, 2011, 12:04:54 pm »
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
In-progress: Graviter (...)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: RLE compression
« Reply #4 on: February 04, 2011, 04:13:22 pm »
Which routine are you using?

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
In-progress: Graviter (...)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: RLE compression
« Reply #6 on: February 04, 2011, 06:06:37 pm »
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.


Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #7 on: February 04, 2011, 06:09:11 pm »
I don't quite get it - could you write some pseudocode or something?
In-progress: Graviter (...)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: RLE compression
« Reply #8 on: February 04, 2011, 06:11:20 pm »
actually, just kidding. my routine already keeps track of the size. variable D should contain the size.


Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #9 on: February 07, 2011, 02:01:06 am »
Wait, you create the str1 appvar BEFORE D is calculated - so how does this work again?
In-progress: Graviter (...)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: RLE compression
« Reply #10 on: February 07, 2011, 02:03:16 am »
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 :)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #11 on: February 07, 2011, 02:04:18 am »
So store compressed map into L1 --> Create appvar with size D --> Store L1 into appvar?
In-progress: Graviter (...)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: RLE compression
« Reply #12 on: February 07, 2011, 02:07:48 am »
Yep, that should work :) That is, are you able to write the compression routine in itself?  or do you need some pointers?

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: RLE compression
« Reply #13 on: February 14, 2011, 08:35:36 pm »
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?
In-progress: Graviter (...)

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: RLE compression
« Reply #14 on: February 15, 2011, 12:12:37 am »
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.