03-06-2013, 03:29 AM
03-06-2013, 03:54 AM
Sorry man, I've been having an unexpectedly small amount of free time on the PC recently, mum needed it for work the whole afternoon for the last 3 days. Hopefully today I'll be able to get to work on this though. As I said earlier the format looks kind of different than what Previous described so it might take some extra work to figure it out, but it should be fairly easy.
Again sorry for the delay, I was totally not expecting this. I'll post an update once I've managed to arrange a map.
(Also no problem Petie, glad to do the site a service )
Again sorry for the delay, I was totally not expecting this. I'll post an update once I've managed to arrange a map.
(Also no problem Petie, glad to do the site a service )
03-06-2013, 05:36 AM
(03-06-2013, 03:29 AM)Hammster Wrote: [ -> ]Any luck with this Puggsoy or Previous?
I haven't done anything as I thought Puggsoy wanted to do it (what is the case, but it's also the case that things happen).
Looks like I was wrong about the map width, yes, but what can you expect from me in the middle of the night?
I'm still right about the tile IDs, though. You start counting at zero, not one, so the white tile is 0, the one after it 1. Since the map in question doesn't use the white tile, the first used tile is number 1.
The map width appears to be 14 tiles for all maps (448px) and what I assumed to be the map width is actually the map height (in tiles). At least the maps look totally fine this way!
(0x14 -> 20 -> 640px which is twice the height of your image from earlier, but as you already figured out the tiles are in the list twice, too, so that's a perfect match)
The easy/hard/normal folders apparently all have the exact same maps so converting those of one should be enough. Map 03-01 seems to be slightly different coloured on hard, but not noticably. Oh, the bridge is a tiny bit different on hard, too, so aside from every "easy" map, you should get that one, too.
SuperLaser .MAP (Windows .EXE) - you can drag&drop .MAP files (or the whole "map" folder) into it. When the program gets a .map file, it will look for the .png to go with it and then assemble the map, which will be saved in a new "assembled_maps" subfolder.
Code:
{
vTilesBmp and vMapBmp are TBitmap objects, vPng is a TPNGObject (from the pngimage library). mOut is a TMemo.
}
procedure TfMain.handleFile(filename : string);
var hExt, hFileName, hTilesFile, hDir, hOutDir : String;
instream : TFileStream;
head, unknown, tile, w, h : Word;
dataSize, hX, hY, hTileX, hTileY, hTilesPerRow : Integer;
const
cTileWidth = 32;
cTileHeight = 32;
begin
hExt := ExtractFileExt(filename);
if hExt = '.map' then
begin
hDir := ExtractFileDir(filename);
hOutDir := hDir + '\assembled_maps\';
hFileName := ChangeFileExt(ExtractFileName(filename), '');
hTilesFile := ChangeFileExt(filename, '.png');
if FileExists(hTilesFile) then
begin
vPng.LoadFromFile(hTilesFile);
vTilesBmp.Assign(vPng);
hTilesPerRow := vTilesBmp.Width div cTileWidth;
instream := TFileStream.Create(filename, fmOpenRead);
try
mOut.Lines.Add('-- Processing File: ' + filename);
instream.Read(head, 2);
if head = $000E then
begin
instream.Read(unknown, 2);
dataSize := instream.Size - instream.Position;
w := 14;
h := dataSize div (2 * w);
vMapBmp.Width := w * cTileWidth;
vMapBmp.Height := h * cTileHeight;
hX := 0;
hY := 0;
while instream.Position < instream.Size do
begin
instream.Read(tile, 2);
hTileX := (tile mod hTilesPerRow) * cTileWidth;
hTileY := (tile div hTilesPerRow) * cTileHeight;
vMapBmp.Canvas.CopyRect(Rect(hX, hY, hX + cTileWidth, hY + cTileHeight), vTilesBmp.Canvas, Rect(hTileX, hTileY, hTileX + cTileWidth, hTileY + cTileHeight));
hX := hX + cTileWidth;
if hX >= vMapBmp.Width then
begin
hX := 0;
hY := hY + cTileHeight;
end;
end;
vPng.Assign(vMapBmp);
if not DirectoryExists(hOutDir) then CreateDir(hOutDir);
vPng.SaveToFile(hOutDir + hFileName + '_map.png');
end else mOut.Lines.Add('ERR: .MAP header mismatch (' + IntToHex(head, 4) + ')');
mOut.Lines.Add(' Done.');
finally
instream.Free;
end;
end else mOut.Lines.Add('ERR: Tiles PNG not found (' + hTilesFile + ')');
end; // else: not a .MAP file (yes I check extensions here, haha)
end;
(Sorry Puggsoy but it was really just a super-quick thing for me to do).
03-06-2013, 06:27 AM
No problem man. I'm gonna finish my program just for fun anyway, kind of like Palettifier. It'll be cross-platform too
Anyway there you go Hammster! Sorry I couldn't have done this quicker but at least Previous was here to save the day
Anyway there you go Hammster! Sorry I couldn't have done this quicker but at least Previous was here to save the day
03-06-2013, 07:16 AM
Holy CRAP thats awesome guys! Thanks so much Previous! Works perfectly! Thanks for your effort too Puggsoy, there is no way I could have made a program to do that. If it wasn't for you guys I would've had to piece it together manually block by block in Photoshop... You guys are the best!
03-06-2013, 12:24 PM
I look forward to seeing your submission!