Author Topic: Routines  (Read 316199 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #360 on: July 19, 2010, 09:51:59 pm »
mhmm interesting. I would like to see it in action in a program. I wonder how fast is it? It would be useful for extremly large maps with large areas filled with the same tile over and over
« Last Edit: July 19, 2010, 09:52:43 pm by DJ Omnimaga »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #361 on: July 19, 2010, 09:54:08 pm »
i sent you my axe parser contest entry awhile ago, didn't i? it uses a similar algorithm, modified because of the tile size. i'd say the maps loaded pretty fast. my newly improved contest entry has the slightest pause between levels.


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #362 on: July 19, 2010, 11:13:31 pm »
Oh wait! I remember now. There have been just so many people joining in the past few months and active users that I have an hard time remembering who's working on what Axe project anymore, now XD

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #363 on: July 19, 2010, 11:18:38 pm »
lol i see. and yeah, if you're wondering if you could use it to scroll on the fly, i highly doubt it. it'd be better to decompress the whole map into a free RAM area, then scroll off the RAM area.


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #364 on: July 19, 2010, 11:21:52 pm »
Yeah I guessed that scrolling may be a bit overkill. I heard half-byte compression with scrolling required a 15 MHz calc to get a speed similar to my ball game. Often, decompressing the entire map will be necessary, but then, what if the maps are like 16 KB each? x.x

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #365 on: July 19, 2010, 11:27:31 pm »
RLE compression is not for you  ::)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #366 on: July 20, 2010, 12:18:10 am »
Could you explain what did I said wrong and why would RLE compression would not be for me? I am not sure what you imply by that.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #367 on: July 20, 2010, 12:47:10 am »
i mean, if you need a 16KB tilemap to be decompressed on a calculator there are a few issues. 1) it would take awhile to decompress, leaving your user waiting. not good. 2) i doubt there's enough room for an uncompressed version of the map on a calculator. so you'd need to decompress the map on the fly while executing the game. this would be very difficult with RLE. making RLE not a realistic compression choice, aka "not for you". "you" being whoever wants to decompress 16KB maps with RLE on a calculator.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #368 on: July 20, 2010, 12:50:51 am »
Well maybe 16 KB was a bit overkill as an example. Let's say 5-6 KB. The game would most likely require the entire remainder of the calc RAM for the uncompressing.

If it's slow, I think it may be best to keep RLE for stuff that requires no constant refreshing of the map during gameplay.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #369 on: July 20, 2010, 01:31:24 am »
The problem for using RLE for large maps is that it is not random access.  Meaning that if you want to access the 213th tile, you have to computer all 212 tiles before it, which makes it not the best for large maps unless you decompress the entire thing when you load the game.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #370 on: July 20, 2010, 01:40:53 am »
Yeah, I guess RLE is out of the question, then x.x, especially when collision detection needs to be added.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #371 on: July 20, 2010, 01:53:51 am »
Yeah, i use it for PortalX and i use almost all of L4 to store the tilemap when its decompressed, so i couldnt even do something like scrolling using RLE because there isnt anywhere to put the tilemap data x.x

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Routines
« Reply #372 on: July 20, 2010, 06:09:18 am »
There actually is a way to decompress RLE on the fly for gigantic maps.  It's not as efficient as the original RLE, but it allows random access (well random-er at least) to the data in the structure.  Its a little complicated, but here is what I am thinking:

First of all, for this to be worth it, each row has to save more than 2 bytes on average, or 4 tiles if you're using this as an alternative to half byte encoding.  The way this works, is you only compress each row or column with RLE instead of the entire data.  You then keep a list of pointers that each point to the individual rows of the data.  The rows themselves are small compared to the whole thing so they can be decompressed on the fly.

Here are some phony numbers:
Maps size: 100x100
Tiles: 10,000
Half Byte compression size: 5,000 bytes
Each row given RLE compression: 3,000 bytes
List of pointers: 200 bytes
Combined total size: 3,200 bytes

Average bytes in a row: 30
Average worst case number of operations to get to intended data: 30
^ This is definitely fast enough for on the fly decompression.

This is valid syntax when defined in this order:

[RLE row 1]->Str0
[RLE row 2]->Str1
[RLE row 3]->Str2
...
[RLE row 100]->Str99
{Str0r,Str1r,...,Str99r}->GDB1


Unfortunately, that list already uses 100 out of the 150 names you're allowed so it might be better to keep track of the cumulative size and use Str0+Offset so that you're only using one name.
« Last Edit: July 20, 2010, 06:13:20 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Routines
« Reply #373 on: July 20, 2010, 02:19:49 pm »
Mhmm sounds interesting, it would be nice if someone made an example routine using this method

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Routines
« Reply #374 on: July 26, 2010, 04:28:04 pm »
RLE compression. compresses as the first half-byte is the frequency, and the second is the tile number. this routine exports the data as a hex string in Str1.

Code: (map data) [Select]
.Uncompressed (24 bytes. each pair is a byte.)
[010101010101
[010303000001
[010200000201
[010101010101
.Compressed (8 bytes. each pair is a byte.)
[7123202112201271->GDB1

Code: (Routine) [Select]
.ROUTINE
[010101010101->GDB1
[010303000001
[010200000201
[010101010101
"0123456789ABCDEF"->Str1
"Str1"->Str2
GetCalc(Str2,16)->M    .16 is the size because our compressed map is 8 bytes, which is 16 half-bytes.
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}->{M+D}
{Str1+A}->{M+D+1}
D+2->D
0->C
End
End