Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - abstauber

#1201
I hope this is right place to ask: I'd like to speed up the file operations in my tile engine. And since now the engine itself is fast again, this calls for bigger maps ;D. Unfortunately that also increases loading times dramatically, so I wonder if anyone could help me out and put these functions into native C code.

Code: ags

int noloopcheck Readword(this File*) {  
  char c1 = this.ReadRawChar();
  char c2 = this.ReadRawChar();
  return c2*256+c1;
}

int noloopcheck ReadDoubleword(this File*) {
  int i1 = this.Readword();
  int i2 = this.Readword();
  // cut 16th bit due to int being signed
  i2 = i2%16;
  return i2*65536+i1;
}

String noloopcheck BitString(int i, int bits) {
  int p = bits - 1,are;
  String s="";
  int q;
  while (p > -1) {
    q = FloatToInt(Maths.RaiseToPower(2.0, IntToFloat(p)), eRoundNearest);
   are = i/q;
    i = i -are*q;
    s = String.Format("%d%s",are, s);
    p--;
  }
  return s;
}

int noloopcheck BitStringToInt(String s) {
  int l = s.Length,are;
  int i;
  String ss;
  int add = 1;
  while (i < l) {
    ss = s.Substring(i, 1);
    if (ss == "1")are =are + add; 
    i++;
    add = add * 2;
  }
  returnare;
}


There's also a second thing I'd die to see as a plugin and that's a way to save data structures (whole arrays and/or structs) to a file. Currently I serialize everything into giant strings and save those. Of course it takes forever to finish ;)


Imagine the game turns out to be great if it weren' for the loading times...?  That would ruin your fun too! See.. it's a win/win situation  :=
Seriously, if anyone could lend a me helping hand, that would be totally great!
Eternal gratitude assured  ;D
#1202
I really feel like a noob, but still can't get it to run, I'm on Intel 10.6 btw.

Code: ags

dirks-computer:ags-runtime_321-osx-alpha1 dirk$ ls -la
total 221680
drwxr-xr-x  11 dirk  staff        374 25 Mai 17:45 .
drwx------  18 dirk  staff        612 25 Mai 17:45 ..
-rwxr-xr-x   1 dirk  staff        294 22 Mai 18:20 acsetup.cfg
-rwxr-xr-x   1 dirk  staff    2038780 22 Mai 18:43 ags
-rware-are--   1 dirk  staff        315 22 Mai 20:36 changes.txt
-rwxr-xr-x   1 dirk  staff  110460416 22 Mai 19:31 jumpnrun_ascii.exe
-rwxr-xr-x   1 dirk  staff        366 17 Apr  2010 level1.txt
-rwxr-xr-x   1 dirk  staff     924452 12 Mai 01:08 liballeg.4.4.1.dylib
-rware-are--    1 dirk  staff       2502 22 Mai 20:35 readme.txt
drwxr-xr-x  11 dirk  staff        374 31 Mär 19:51 tilemaps
-rwxr-xr-x   1 dirk  staff      53279 22 Mai 19:31 winsetup.exe
dirks-computer:ags-runtime_321-osx-alpha1 dirk$ ./ags jumpnrun_ascii.exe 
dyld: Library not loaded: liballeg.4.4.dylib
  Referenced from: /Users/dirk/Desktop/ags-runtime_321-osx-alpha1/./ags
  Reason: image not found
Trace/BPT trap
dirks-computer:ags-runtime_321-osx-alpha1 dirk$ 



edit: SMF drives me crazy, the filemask of course is not -rw-are--are--  but feel free to write  "read-write,read, read" on this board :o
#1203
À propos "No Euest for the wicked", music from those fellas would make a nice soundtrack:
http://www.youtube.com/watch?v=tLk9uKuOGGo

Or at least it's nice to hear while working for the swarm.


Btw. as soon as there are written character portraits for the vampire twins, I'd like to draw their portraits as well.

#1204
oooooooOOOhh!  Thanks for pointing my nose on this. I totally underestimated that snippet!

That's witchcraft indeed. 


managed structs are nestable... yaytards!  :=
#1205
Critics' Lounge / Re: Arcade-y music
Tue 24/05/2011 19:36:19
Yeah, can't help you either, to me it's really good.
#1206
Quote from: Ryan Timothy on Tue 24/05/2011 19:29:47
Maybe I'll do a speed test one of these days.
+1 :D


@Calin:
Since the rectangle now works, I've removed the addition if-clauses and draw checks inside the tile drawing functions. On the one hand this is good, because the function isn't so cluttered anymore. But on the speed side it's not noticable.

The engine currently runs with about 60 fps, no matter if the clauses are in or not.
#1207
Quick and dirty would be to increase the tile size, that way the active tilecount drops a lot :)
#1208
First of all, I have to apologize. Khris was right, there was a simple i=0 hidden inside the spaghetti loop. And instead of being rational I wanted to believe in coding voodoo   ::)

So thanks to you all, the framerate is once again stable at 40 fps and I can finally start looking for real optimizations.
Merging tiles into supertiles is an definitely an option, but then I suppose I'd have to ditch tile animation and destrucion support - or at least I can't imagine how this would work with prerendered chunks.

But it's giant relief that this has nothing to do with array sizes!
#1209
Yeah, the initial coordinate is calculated when I load the map. But due to scrolling I've calculate an offset and apply that to the position.

The scrolling algorithm is also pretty unoptimized, but that's a different story ;)

I've now switched the order of the two loops, now the outer loop is y and the inner loop is x. That helped a lot: a 200x80 tilemap (16px tiles)  now runs without significant fps drops.

Now I just need a way to simulate an atom processor so I can add optimizations and actually see the result.

edit: Argh, switching loops just swapped the problem from bottom right to top left.
#1210
Hmm... I'm pretty sure that accessing array values at the end of the array is just painfully slow.

Even if the player is spawned at the bottom right corner and doesn't move at all (no collision checks interfering), the framerate is down.

But could it be that accessing tiles[7000].id takes longer than accessing tiles[70].id
#1211
@TomatosInTheHead
Thanks a million! I'll try that ASAP :D

@Calin
Oh, I didn't know that. In that particular function I also check if the tile is animating, emitting particles and so on. Let's see what's faster. If Tomatos' snippet works that check will be needless anyway.


Thanks you two!


edit: Framerate stabilized a lot, but there's still room for improvement. The framerate at the bottom right corner is still dropping very low (20 fps on a 2Ghz Intel C2D). So the next thing I'll try is caching.
#1212
Hi there,

I'm currently trying to optimize my tile engine, but I'm out of thoughts right now.
Here's a sample tilemap:



I'm currently looping through my tile array like this:
Code: ags

    i = 0;
    k = 1; // please ignore ;)

    while ( i < num_tiles_x )
    {
      j = 0;
      
      while ( j < num_tiles_y )
      {
        int index = j * num_tiles_x + i; 
        if (tile[index].tileno[k] != 0) {
          // and so on...



Now this works fine and it  loops from index 0 to index 1380 all the time. But it would be only necessary to loop through the indices inside the red square, which is the viewpoint of the player.
(the tiles aren't drawn anyway, because I check the tile's coordinates inside the loop and compare it to the player's coordinates.)


My question is now: Is it possible to modify these two loops to consider only the tiles inside the red square? I do have the index of the player's tile, so it could be a starting point to calculate the index. But I'm terribly clueless at the moment.


Any help is appreciated :)




#1213
Find it out yourself you say?

Fine!



it works.


:D



(sorry for double posting)
#1214
Sweeet!
Great that this is being developed again, thanks a lot!

After a quick try
Code: ags

dyld: Library not loaded: liballeg.4.4.dylib
  Referenced from: /Users/dirk/Desktop/ags-runtime_321-osx-alpha1/./ags
  Reason: image not found
Trace/BPT trap


#1215
QuoteSo please, if you are posting an animation please also post the frames (or link to a file folder) so that whoever ends up with this job (probably me.....) can have an easy go at collecting everything.

Huh? What's wrong with importing .gif frames? That's the fastest thing you can have.
#1216
Is this still possible? I mean in the good ol' days (tm) you just used playmusic(10) and AGS found the file itself.
But since now all music files are treated as objects, does that still work?
#1217
The Rumpus Room / Re: Happy Birthday Thread!
Sat 21/05/2011 17:07:34
Happy birthday Matti & Mr Pudding!

@Ryan: best way to spend a mid-week birthday :)
#1218
haha, lot's going on in your post Tabata :) Nice!

I've also invested a few more hours to better fit the project's style:





#1219
Somebody needs to mention that the Bonsai in front left corner is simply awesome. Well done!

Sorry for cluttering this thread even more ;)
#1220
The Rumpus Room / Re: Happy Birthday Thread!
Wed 18/05/2011 07:15:36
Happy Birthday, Ryan and Travis.
SMF spam blocked by CleanTalk