Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
24 May, 2013, 10:36:59 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: 1 ... 24 25 [26] 27 28 ... 42   Go Down
  Print  
Author Topic: Routines -  (Read 42568 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
calcdude84se
Needs Motivation
Members
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 16:12:14
Date Registered: 21 April, 2010, 04:20:59
Posts: 2207


Total Post Ratings: +62

View Profile
« Reply #375 on: 26 July, 2010, 22:47:55 »
0

Nice. However, I think I should tell you that RLE is typically done slightly differently, with a reserved number to indicate runs. For example:

1
2
3
4
5
6
7
8
9
10
.Uncompressed (each tile is a half-byte)
[567222220874999F
[033AAAAAAAAAAAAA
[AAA23279BBBBB8FF
.24 bytes
.Compressed
[567F520874999F1F
[033F0A23279F5B8F
[2F
.17 bytes
Where normal data is just inserted, and a run (more than three here) is indicated by 'F' followed by the run length (one nibble, 0 is length 16) followed by the tile number. An 'F' tile is always recorded in run format because it would otherwise be treated as the start of a run.
I'll try to get some code up in a bit.
Logged

"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Bug me about PartesOS. I might just need reminding.
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 05:59:46
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #376 on: 26 July, 2010, 22:54:11 »
0

Interesting CalcDude, i've never encountered RLE implemented in that way.  I use it in the same way as Nemo did when i wrote Portal and PortalX, i shall have to do some tests to see if your method offers more compression.  Its too bad that it would take 3 bytes to represent a single F though, whereas Nemo's method it only takes 1.  It would seem that they are both suited for slightly different kinds of data?  Nemo's method where there are longer runs and less random data, and Calcdudes method where there is runs and random data mixed together.
Logged

calcdude84se
Needs Motivation
Members
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 16:12:14
Date Registered: 21 April, 2010, 04:20:59
Posts: 2207


Total Post Ratings: +62

View Profile
« Reply #377 on: 26 July, 2010, 22:57:23 »
0

Mine takes three nibbles, while his takes one byte, or two nibbles. It's only 50% larger Grin Not to mention I'm assuming the 'F' tile won't be used as often.
* calcdude goes off to code this
Logged

"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Bug me about PartesOS. I might just need reminding.
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 05:59:46
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #378 on: 26 July, 2010, 23:00:46 »
0

Ah yes thats right, good catch.  Its also good to note that in both methods, tiles can only go up to 4bit, so Nemo's representation of his original data in 8bit adds on twice the amount of data then can be compressed.  There is only 12 bytes of information being compressed.
Logged

nemo
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 04 April, 2013, 01:12:57
Date Registered: 16 May, 2010, 03:55:30
Posts: 1198

Total Post Ratings: +83

View Profile
« Reply #379 on: 26 July, 2010, 23:09:50 »
0

builderboy, i could make the routine compress half-byte tilemaps, but it would be more complicated, so i just stuck with one tile as being equal to one byte, though my compression is preferably used in maps that have 15 or less tiles, and have long runs of the same data. if you need more than 15 tiles and have very, very long runs of the same data,  you could use a method where one byte holds frequency, and the next holds the tile number.
so [43050320] would represent tile 5 67 times, then tile 32 3 times. but that can be very memory inefficient unless you have many runs of data, specifically runs of data that last more than 4 tiles.
Logged


Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 05:59:46
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #380 on: 26 July, 2010, 23:12:41 »
0

Ah gotcha, yeah that makes sense.  Yeah i was just commenting on uncompressed vs compressed sizes Smiley
Logged

nemo
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 04 April, 2013, 01:12:57
Date Registered: 16 May, 2010, 03:55:30
Posts: 1198

Total Post Ratings: +83

View Profile
« Reply #381 on: 27 July, 2010, 21:17:51 »
0

calcdude, wouldn't RLE under your example only allow tiles 0-E, since F is reserved for indicating a run? and sometimes you could end up with an odd number of nibbles. regardless, i like that type of RLE and i'll probably post some de/compression routines about it.

edit: and my routines will have the uncompressed map data as each tile being one byte.

edit2: compression is working.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
.ROUTINE
0->C->D
"0123456789ABCDE0->Str1    .Make sure you have 0 at the end, not F.
For(Y,0,S                  .Replace S with the height of your uncompressed map minus 1
For(X,0,T                  .Replace T with the width of your uncompressed map minus 1
If {T+1*Y+X+GDB1}->A={T+1*Y+X+GDB1+1} and (C!=14)
C+1->C
Else
If C>3
70->{L1+D}
{Str1+C+1}->{L1+D+1}
{Str1+A}->{L1+D+2}
D+3->D
Else
For(Z,0,C
{Str1+A}->{L1+D}
D+1->D
End:End:0->C:End:End:End
GetCalc("Str4",D^2+D)->I
For(Z,0,D-1
{L1+Z}->{I+Z}
End
If D^2
70->{I+Z+1}
End

that was much more difficult to write... i wonder how decompression will be.
« Last Edit: 27 July, 2010, 23:00:44 by nemo » Logged


calcdude84se
Needs Motivation
Members
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 16:12:14
Date Registered: 21 April, 2010, 04:20:59
Posts: 2207


Total Post Ratings: +62

View Profile
« Reply #382 on: 27 July, 2010, 22:34:18 »
0

As I said, you always have to use the 'F' tile in run form, no matter what. But it is possible. As for an odd number of nibbles, you could always just add an extra 'F'. Now to write this, since I have the time. We're doing this by row, right?
* calcdude goes and codes
« Last Edit: 09 October, 2010, 23:32:09 by calcdude84se » Logged

"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Bug me about PartesOS. I might just need reminding.
nemo
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 04 April, 2013, 01:12:57
Date Registered: 16 May, 2010, 03:55:30
Posts: 1198

Total Post Ratings: +83

View Profile
« Reply #383 on: 27 July, 2010, 22:52:33 »
0

yes, mine works by row. i think decompression will be harder, though. because if you run into an F, all your arithmetic has to change to compensate for reading the bytes differently. i think it'd be easiest to make the sequence for starting a run be a full byte, like FF, unless you've found an easy way to decompress already.
Logged


calcdude84se
Needs Motivation
Members
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 16:12:14
Date Registered: 21 April, 2010, 04:20:59
Posts: 2207


Total Post Ratings: +62

View Profile
« Reply #384 on: 27 July, 2010, 22:56:49 »
0

Hm... I'll write it both ways. One that always uses one 'F', or one that uses one or two to get it to a full byte. But I'll start with my way Wink
Logged

"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Bug me about PartesOS. I might just need reminding.
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: Today at 05:59:46
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5642


Total Post Ratings: +589

View Profile
« Reply #385 on: 27 July, 2010, 22:58:22 »
0

Maybe it would make it easier to write a quick subroutine that extracts each nibble from the data and returns them one at a time?  That way you dont even have to think about the half byte compression going on?
Logged

nemo
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 04 April, 2013, 01:12:57
Date Registered: 16 May, 2010, 03:55:30
Posts: 1198

Total Post Ratings: +83

View Profile
« Reply #386 on: 27 July, 2010, 22:58:39 »
0

i'm going to try to write decompression your way, and we can compare afterwards. and i'm going to edit my RLE compression routine so that if you have an odd number of nibbles, it tacks on an 'F' at the end of the hex string.

great success?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.BB
[F71011011100F810]->GDB1
Zeroes(8)->Pic1
[FFFFFFFFFFFFFFFF]
0->X->Y
For(Z,0,15
  If sub(GN,Z)->N=15
    For(U,1,sub(GN,Z+1)
      Pt-On(X*8,Y*8,sub(GN,Z+2)*8+Pic1
      !If X+1->X^6
        0->X:Y+1->Y
      End
    End
    Z+2->Z
  Else
    Pt-On(X*8,Y*8,N*8+Pic1
    !If X+1->X^6
      0->X:Y+1->Y
    End
  End
End
DispGraph
Lbl GN
{r1/2+GDB1}->T
If r1^2
  T^16
Else
  T/16
End

as you can tell, i used builderboy's idea of having a subroutine to get a specific nibble.

edit: edited some whitespace in for readability
« Last Edit: 27 July, 2010, 23:51:49 by nemo » Logged


Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 07:42:41
Date Registered: 02 July, 2009, 06:38:05
Posts: 1680


Total Post Ratings: +493

View Profile
« Reply #387 on: 24 August, 2010, 01:53:23 »
0

This thread shouldn't be floating down this far! And since I just answered a question in the main thread about how to retrieve data from OS matrices, I may as well post these two routines here:


1
2
3
4
5
.Returns an element of OS matrix (pointer to matrix, 0-based column, 0-based row)
Lbl M
  float{r₃*{r₁-2}+r₂*9+r₁}
Return


1
2
3
4
5
.Returns an element of OS matrix (pointer to matrix, 1-based column, 1-based row)
Lbl M
  float{r₃-1*{r₁-2}+(r₂-1)*9+r₁}
Return


1
2
3
4
5
.Returns an element of OS list (pointer to list, 0-based entry)
Lbl L
  float{r₂*9+r₁}
Return


1
2
3
4
5
.Returns an element of OS list (pointer to list, 1-based entry)
Lbl L
  float{r₂-1*9+r₁}
Return
« Last Edit: 24 August, 2010, 01:54:14 by Runer112 » Logged
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Offline Offline

Gender: Male
Last Login: Today at 08:21:29
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50232


Total Post Ratings: +2615

View Profile WWW
« Reply #388 on: 24 August, 2010, 03:08:34 »
0

darn, I am really out of the loop on new functions, I really need to re-read the command index when I get some time x.x (I last did on 0.2.6)
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
_player1537
Guest
« Reply #389 on: 27 August, 2010, 04:09:01 »
0

darn, I am really out of the loop on new functions, I really need to re-read the command index when I get some time x.x (I last did on 0.2.6)

Lol, I know the feeling Tongue
Logged
Pages: 1 ... 24 25 [26] 27 28 ... 42   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.208 seconds with 30 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.