Important Announcement
Forum has been made read-only. Please click here for more information or here to return to The Spriters Resource.

IOS map rip
#33
(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? Tongue

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! Tongue
(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.

[spoiler=Source Code (Delphi Pascal)]
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;
[/spoiler]


(Sorry Puggsoy but it was really just a super-quick thing for me to do).


Messages In This Thread
IOS map rip - by Hammster - 02-26-2013, 04:47 AM
RE: IOS map rip - by puggsoy - 02-26-2013, 05:07 AM
RE: IOS map rip - by Hammster - 02-26-2013, 10:41 AM
RE: IOS map rip - by puggsoy - 02-26-2013, 11:20 AM
RE: IOS map rip - by Hammster - 02-26-2013, 06:07 PM
RE: IOS map rip - by Hammster - 02-27-2013, 05:15 AM
RE: IOS map rip - by puggsoy - 02-27-2013, 06:27 AM
RE: IOS map rip - by Previous - 02-27-2013, 06:39 AM
RE: IOS map rip - by Hammster - 02-27-2013, 07:04 AM
RE: IOS map rip - by puggsoy - 02-27-2013, 10:48 AM
RE: IOS map rip - by Hammster - 02-27-2013, 04:10 PM
RE: IOS map rip - by puggsoy - 02-27-2013, 04:44 PM
RE: IOS map rip - by Hammster - 02-28-2013, 12:28 AM
RE: IOS map rip - by puggsoy - 02-28-2013, 05:54 AM
RE: IOS map rip - by Hammster - 02-28-2013, 09:59 PM
RE: IOS map rip - by puggsoy - 03-01-2013, 05:47 AM
RE: IOS map rip - by Previous - 03-01-2013, 02:00 PM
RE: IOS map rip - by Previous - 03-01-2013, 05:45 PM
RE: IOS map rip - by Garamonde - 03-01-2013, 06:18 PM
RE: IOS map rip - by Hammster - 03-01-2013, 06:19 PM
RE: IOS map rip - by Garamonde - 03-01-2013, 06:28 PM
RE: IOS map rip - by puggsoy - 03-02-2013, 06:45 AM
RE: IOS map rip - by Hammster - 03-02-2013, 11:31 PM
RE: IOS map rip - by Garamonde - 03-02-2013, 11:33 PM
RE: IOS map rip - by Hammster - 03-03-2013, 12:14 AM
RE: IOS map rip - by Petie - 03-03-2013, 12:57 AM
RE: IOS map rip - by Hammster - 03-05-2013, 04:20 AM
RE: IOS map rip - by Petie - 03-05-2013, 10:10 AM
RE: IOS map rip - by Garamonde - 03-03-2013, 08:20 AM
RE: IOS map rip - by Hammster - 03-06-2013, 03:29 AM
RE: IOS map rip - by puggsoy - 03-06-2013, 03:54 AM
RE: IOS map rip - by Previous - 03-06-2013, 05:36 AM
RE: IOS map rip - by puggsoy - 03-06-2013, 06:27 AM
RE: IOS map rip - by Hammster - 03-06-2013, 07:16 AM
RE: IOS map rip - by Garamonde - 03-06-2013, 12:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)