Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: C Map Encoder  (Read 1713 times)

Corona688

  • Bay Watcher
    • View Profile
C Map Encoder
« on: July 15, 2009, 08:43:30 am »

For the last while I've been working on a new map encoder.  I had three goals:
  • Write it purely in C instead of requiring software dependencies to Mono(and thereby the entire known universe).  Low-level image processing ought to run natively!
  • Handle memory smarter.  Most computers can load 80meg files wholesale these days, but that doesn't make it efficient.
  • Find a faster way of comparing tiles.
Yesterday I had a breakthrough.  The map came through all discolored and scrambled but I kept it for the laughs.  Since then I've fixed the color, tile, and map bugs and added multilayer support.

It can process 14 layers of 288-tile by 288-tile, 16x16-tiled bmp maps in one minute, ten seconds on a 2GHz Turion.  It lops sixty seconds off that if the files are already in cache, so that's mostly unavoidable disk wait that can't be improved without a faster one.  I haven't had much luck with the C# or Java encoders so I'm not sure how this compares on speed(comments, please?), but even if its not vastly faster it should at least be a whole lot more portable.

Right now it runs in Linux but there aren't any real barriers to porting it to Windows(or x86 mac.  ppc would be harder.)  I want to do a bit more code cleanup first, but I hope to release Windows and Linux versions plus source code soon.
« Last Edit: July 15, 2009, 08:46:04 am by Corona688 »
Logged
You never know when you might need a berserk dwarf to set loose somewhere.

Calculus

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #1 on: July 15, 2009, 12:14:02 pm »

Very cool!
Logged

TheDJ17

  • Bay Watcher
  • [SWAG]
    • View Profile
Re: C Map Encoder
« Reply #2 on: July 15, 2009, 12:20:53 pm »

So does this make the game run faster? Or is it a tile set?
Logged
The spinning =<*Free Form Jazz*>= strikes the Poster in all the senses, ya' dig, utterly blowing the mind!
The Status Quo has been struck down!

Corona688

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #3 on: July 15, 2009, 06:55:09 pm »

So does this make the game run faster? Or is it a tile set?
Neither, its a map encoder.  It reads in the giant .bmp files Dwarf Fortress exports for map layers, processes and converts them into the kind of maps the Dwarf Fortress Map Archive accepts for upload.
Logged
You never know when you might need a berserk dwarf to set loose somewhere.

xtank5

  • Bay Watcher
  • [STEM_CELL_TRANSPLANT]
    • View Profile
Re: C Map Encoder
« Reply #4 on: July 16, 2009, 12:31:17 am »

I must have it because the regular map encoder doesn't work on my computer for some reason. :-[
Logged
IT'S ALWAYS BEEN WANKERSHIM
Can't get enough Bolo.

Corona688

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #5 on: July 16, 2009, 01:07:20 am »

Here is v0.1 of the linux version.  I hope to have it ported to Windows in the next two to three days.
Logged
You never know when you might need a berserk dwarf to set loose somewhere.

xtank5

  • Bay Watcher
  • [STEM_CELL_TRANSPLANT]
    • View Profile
Re: C Map Encoder
« Reply #6 on: July 28, 2009, 07:07:33 pm »

YAY!! :D

I kinda need the windows version cause I can't get a Linux VM working on my PC.  F%#&ing VMWare.  >:(
Logged
IT'S ALWAYS BEEN WANKERSHIM
Can't get enough Bolo.

MP2E

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #7 on: July 28, 2009, 09:09:45 pm »

I realize I'm new and such, but I have a lot of experience with compiling Linux programs on Windows(I have GCC 4.4.0 set up with a full MinGW toolset, not to mention VC++ 2008 and the Intel Compiler 10.1 :P). Though if it needs anything more than simple changes to the coding, I'm sadly lacking in that department though...
Logged

Itnetlolor

  • Bay Watcher
    • View Profile
    • Steam ID
Re: C Map Encoder
« Reply #8 on: July 28, 2009, 11:58:51 pm »

I hope it can read multi-dashed/cut-off names. I'm getting tired of renaming all of my map exports from Bloodfist-Sky-Fo-##-##### to Bloodfist-##-#####. Especially when I have tons of layers to process.

For some odd reason, the default encoder can't take care of it. It keeps on reading the first in line, and only processes that one, when there are roughly 20+ most the time, and I want it all done in one shot. It's one of the other reasons it takes me a bit longer to update than preferable.

Alternative to that is guiding me to a proper renaming program if possible, otherwise I'll just fight the carp, and keep going my old method.

EDIT:
By mean of renaming, kinda a universal renamer that allows renaming of sections of same/similar named files. Much like the map series images. All this, but not renaming the rest of the files. Much like the example I provided above. Basically, edit the constant, but not affect the variable with file names.
« Last Edit: July 29, 2009, 12:08:42 am by Itnetlolor »
Logged

mattmoss

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #9 on: July 29, 2009, 03:11:40 pm »

Here is v0.1 of the linux version.  I hope to have it ported to Windows in the next two to three days.

Oh, thank Armok! I'd been trying for a while to code a map generator working on Mac OS X, and I kept getting stuck on RLE, trying for a long while to match what the docs indicated without any luck.

I'm going to compile this on the Mac, see how it goes! 

 ;D
Logged

mattmoss

  • Bay Watcher
    • View Profile
Re: C Map Encoder
« Reply #10 on: July 29, 2009, 03:28:48 pm »

Here is v0.1 of the linux version.  I hope to have it ported to Windows in the next two to three days.

Oh, thank Armok! I'd been trying for a while to code a map generator working on Mac OS X, and I kept getting stuck on RLE, trying for a long while to match what the docs indicated without any luck.

I'm going to compile this on the Mac, see how it goes! 

 ;D

Corona688: I unpacked your v0.1 source code and ran make (on Intel Mac OS X) without any changes whatsoever. (I did already have SDL libs installed on my machine.) Build generated only a single warning, and worked perfectly (aside from needing a better default output filename) on a few test bitmaps.

This was the warning:
fma-enc.c: In function ‘dfma_savemap’:
dfma-enc.c:199: warning: pointer targets in passing argument 2 of ‘dfma_writelayer’ differ in signedness

And here is the sample I generated on the Mac:
http://mkv25.net/dfma/map-6566-soulburn


EDIT: Aha... I see you haven't gotten to the RLE portion. Good luck with that! I'll be interested to see if you can figure it out.
« Last Edit: July 29, 2009, 05:49:29 pm by mattmoss »
Logged