(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).