Author Topic: SEGA Master System level modifying  (Read 35291 times)

0 Members and 1 Guest are viewing this topic.

Offline Pooty

  • Posts: 359
    • View Profile
SEGA Master System level modifying
« on: July 25, 2011, 11:35:40 PM »
Attached to this post is a tool you may use to create Master System Lemmings levels, along with its source code.

The tool included is not an actual level editor. It simply copies the ROM, then "injects" the level you designed using Mappy into the copy. You may download Mappy at http://tilemap.co.uk/mappy.php. Mappy is designed for Windows, but Linux users should be able to run it under Wine. It won't work on Macs, unfortunately. I need more programming experience before considering making a fully functional, portable level editor.

You can choose which level you wish to overwrite, but you can only overwrite one level right now. Also, the game will automatically modify some levels, such as Tricky 04, Tricky 21 (massively), Taxing 24, Mayhem 03, Mayhem 13, and Mayhem 27 (there are likely others). This is a "feature" of the game itself. I plan on updating this program to cancel these effects if you choose to overwrite those levels. Also, let me know if you find some others. That would be great.  :thumbsup:

One other thing, and it's about the use of Mappy. The tile size is 8x8, the map size is 112x19, and the tilesets you need to use are included in the zip file. After you've designed your level, you need to go to Custom -> Export binary file. When asked about adjusting exported values, set it to 0.

That's all I can think of right now. Let me know if there's anything you need help with. Hopefully nothing along the lines of "This program doesn't work" or "My computer burst into flames after running your program". That shouldn't happen. :scared:

[Edit: Oh yeah. Don't forget to modify the leveldata.txt file. It should all be explained in the readme.]

[Edit 2: Updated the program to allow .mlm files to be used, which uses the same file format as within the ROM.]

[Edit 3: Lemming maps for the original game now available.]
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #1 on: July 26, 2011, 01:53:36 AM »
Brilliant, just brilliant, Pooty!

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #2 on: July 26, 2011, 08:58:41 AM »
Hm, what modifications exactly? I can understand with some levels (especially Mayhem 13, as it's a repeat with slightly modified terrain)...

Also, on that note: Do repeats get replaced at the same time?

Finally, one suggestion that should be quite simple: Allowing importing of more than one level at a time (for level packs, etc).
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #3 on: July 26, 2011, 04:00:59 PM »
Hm, what modifications exactly? I can understand with some levels (especially Mayhem 13, as it's a repeat with slightly modified terrain)...

The levels I mentioned are all modified terrain. Tricky 04 has a terrain piece between the one-way wall and the end of the platform on the right that isn't actually in the level data (The same is true for Taxing 07, since it points to the same data). It's added during a process between pressing 1 to preview/2 to play and the level loading. I know where it happens in the ROM, so I'll update the program soon to counter this.

Tricky 21 cuts the top third of the level off, so unless your level is low enough, don't use that one.

Also, on that note: Do repeats get replaced at the same time?

Nope. The repeated levels remain completely intact.

Finally, one suggestion that should be quite simple: Allowing importing of more than one level at a time (for level packs, etc).

I really, really want to do this, but the ROM is very tightly packed, making it difficult to modify without breaking it. The only reason I was able to get the ball rolling is because there is a fairly large amount of empty space near the end of the ROM that I was able to take advantage of. Might be able to fit 2 or 3 levels in there. I need a deeper understanding of how the game works before I can affect the rest of the game.

Implementing repeated versions of the custom levels, on the other hand, is much easier, and far less risky. All it requires is changing a couple of pointers, and you're done.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #4 on: July 26, 2011, 09:17:30 PM »
Just about made a workable version of Save Me using this editor.. will keep everyone updated.


Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #5 on: July 27, 2011, 09:08:49 AM »
Wow that is awesome. :thumbsup: I gotta get me an SMS emulator and Lemmings ROM one of these days...... ;P

[edit: hmm, looks like the tile nature of SMS levels means you might never get the final part of "Save Me" to work the way it's intended (it looks like you can just use blockers instead of build + block)]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #6 on: July 27, 2011, 02:50:17 PM »
Yup, that's a big issue with the SMS version - you're fixed to the 8x8 tiles, which makes doing the final part of Save Me pretty darn annoying.

Here's a video of Save Me in action..
Sega Master System - Lemmings Mayhem 29 - Save Me

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #7 on: July 27, 2011, 04:28:59 PM »
I have an idea on how to retain the spirit of the original puzzle. There are two tiles in the tileset that feature only one pixel; a pixel in the top-right corner, and a pixel in the bottom-left. They are part of the curved pillars. If you place one to the left side of the platform above the exit, and the other to the right of the platform the exit is on, you should be forced to use builders. It might look slightly odd (especially the one to the right of the exit), but it keeps the puzzle intact.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #8 on: July 27, 2011, 04:40:53 PM »
I've just tested that out, and unfortunately, the same problems still exist. Nice idea, though, and it does make doing the puzzle without builders a little bit harder.

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #9 on: July 27, 2011, 09:37:30 PM »
Hmm, I kinda want to see it in action, what you said about your idea not working. ???

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #10 on: July 27, 2011, 10:03:32 PM »
I'll quickly redo the level with the little single-pixel blocks to show you then! :)

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #11 on: July 27, 2011, 10:23:54 PM »
Okay.. two videos here.

Firstly, as per ccexplore's request..
Sega Master System - Lemmings Mayhem 29 - Save Me (Backroute)

And secondly, here's Cascade..
Sega Master System - Lemmings Tricky 25 - Cascade

Enjoy!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #12 on: July 27, 2011, 10:52:40 PM »
Ah, I see what's happened there. What I meant was to bring the metal platforms in line with each other, then do the modifications so that the left pixel tile appears next to the middle platform, and the right pixel is next to the bottom one (in other words, lower each pixel tile you set up to the platform below).

And nice work on Cascade. :)
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #13 on: July 27, 2011, 10:58:20 PM »
Just tried that, Pooty - it definitely works, but, well, it ups the difficulty an awful lot.. even using the backroute, it's bloody difficult!!

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #14 on: July 27, 2011, 11:06:33 PM »
For reference, in the "Save Me" on the PC etc. versions, IIRC the platforms are offset 2 pixels from each other.  So it's slightly more forgiving than Pooty's idea which is 1-pixel offset, but it was never totally easy to start with.  Does the controls on the SMS also make things harder, or is that not in play here?

Incidentally, I'm also curious:  while not the most useful move here, does the SMS has the same steel digging bug where if you decide to dig down at the specially placed pixels, it will take out the edge of the steel?  Or does the steel prevent digging?

[edit: sorry, maybe a better way to phrase is simply this:  is it possible to dig out a little bit of the steel edge, by building a little (or not) from the edge and then dig down?]

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #15 on: July 27, 2011, 11:07:56 PM »
Well it's about time there's a hard level on there. :P

But yeah, I was worried that might happen. There's a trick I use to assign tasks as soon as possible, and that's by holding the 2 button down before the lemming arrives. As soon as the lemming hits the crosshairs (or as soon as the lemming lands from a fall), you'll use whatever skill you've selected on him.

I've also updated the program to fix a bug that prevented grass-type levels from being converted.

[Edit] The steel digging bug doesn't work. The game refuses to edit tiles that are flagged as steel.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #16 on: July 27, 2011, 11:11:14 PM »
You use the same trick that I use, Pooty! :D

I'll upload the map files, if you like - <minirant> I can't really distribute the ROM because it's apparently illegal, even though a quick Google search gets you the ROM instantly, and I'm sure Sony aren't planning on raking in on the Master System port of Lemmings, but I don't want to get sued. </minirant>

Steel is indestructable on the Master System version - nothing can destroy it, although you *can* get trapped in it.

How are you finding the embedding of YouTube videos? All you need to do is link to a video and it becomes embedded.

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #17 on: July 27, 2011, 11:18:17 PM »
I'm loving my double-posts tonight, but sometimes, they've gotta be done.

I've messed about with Save Me, and have found a pretty easy way to separate the Lemmings so the final part is easy. Unfortunately, the backroute over the water is going to eliminate a lot of the difficulty.

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #18 on: July 27, 2011, 11:37:34 PM »
Given that some versions like the PC also has that kind of backroute (though obviously through different means), one can argue that it's not a big deal.  But if it is for you, I guess you can always kill it for sure by adding some steel blocks to completely block the way going left.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #19 on: July 27, 2011, 11:46:28 PM »
Yeah. The only fix I can think of is getting rid of the water. It might make the level look a bit bland, though. :/

I've had a quick scan of the ROM, and the game seems to modify the following levels in some way. Hard to say what the changes are exactly until I investigate further. There may be one or two false alarms, and some levels could be missing, just to wind you (and me) up. :P

Fun 9, 15, 17, 20, 21, 26
Tricky 4, 7, 21, 25, 26, 28
Taxing 1, 2, 6, 7, 11, 12, 13, 21, 24, 29
Mayhem 3, 9, 12, 13, 18, 23, 26, 28

[Edit: Removed Mayhem 27.]
[Edit 2: Added Fun 9 and Tricky 26]
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #20 on: July 27, 2011, 11:56:29 PM »
I'm pretty sure Fun 15, 17, 20, 21, 26; Tricky 25; Taxing 1, 2, 6, 11, 21; Mayhem 9, 12, 13, 18 and 26 are all trap modifications.

And, I think that Tricky 4, 21; Taxing 7; Mayhem 3 and 13 are all terrain modifications which are fairly well-known.

Tricky 7 and Taxing 11 shove the furthest right pillar further right by 1 tile.

Tricky 28 has no exit without the modifications.

Taxing 12 shoves the first block right by 1 tile.

Taxing 13 changes the terrain to the left of the one-way wall:


Taxing 24 reduces the three-tile gap between the steel before the exit and the platform above the exit to a one-tile gap.

Taxing 29 completely flattens the right-hand wall after the water.

Mayhem 28 modifies the terrain in three places:

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #21 on: July 28, 2011, 10:43:35 AM »
Nice work!  :thumbsup:

I also noticed that Mayhem 23 moves the island the lemmings land on (after bashing through the long wall) to the right by two tiles.

Mayhem 27 was an accidental inclusion after I forgot to add the 1 to make it 28 (then I added Mayhem 28 after a double check >.<). That means all listed levels are accounted for.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #22 on: July 28, 2011, 11:18:41 AM »
You can't dig if you're touching any part of a steel tile.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #23 on: July 28, 2011, 11:24:05 AM »
Still haven't downloaded SMS emulator/ROM yet, or even mappy (though I visited its webpage), but I did have a quick look at your program's readme etc.

Wow, you really mean it when you said tileset.  It's really just a set of the 8x8 tiles.   Makes it all the more amazing that Adam manages to put together so much so quickly (though I imagine Mappy probably has some features that really help in this regard, like cut and paste, and possibly creating "assemblies" of tiles so you can add something more akin to whole objects than individual tiles?)

One thought I have is that, if you can convert from mappy back to ROM format, seems like you should also be able to extract a level stored in ROM and convert it into mappy format?  Perhaps not a big deal right now, but it could be useful to be able to start in mappy with the map of an existing level, instead of from scratch.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #24 on: July 28, 2011, 01:29:49 PM »
That's one way of doing it. Unfortunately, the Mappy binary exported format isn't suitable for importing back into Mappy. Daft, I know.

However, I've just realised that Mappy supports Lua scripts, so I'm going to write two functions for it; one to save the file into the format the Master System uses, and the other to load such files into Mappy. You'll still have to load the tileset image into Mappy, mind you, but that shouldn't be a problem.

So my current plan is to write the two functions out, update my program so that it can use these new files, and then extract the levels from the ROM. It should be done by the end of the day.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #25 on: July 28, 2011, 01:37:44 PM »
That's one way of doing it. Unfortunately, the Mappy binary exported format isn't suitable for importing back into Mappy. Daft, I know.

I'm able to import the binary files exported from Mappy. :\

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #26 on: July 28, 2011, 01:57:10 PM »
Oh right. When I try it, it appears all garbaged by shifting the tile numbers up by 1.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #27 on: July 28, 2011, 01:59:32 PM »
Oh right. When I try it, it appears all garbaged by shifting the tile numbers up by 1.

I import, then shift the values down by 1 - it's worked so far!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #28 on: July 28, 2011, 10:28:08 PM »
Oh, I see what's happening. I have to import the tileset first before importing. Doing it the other way around produces unpredictable effects.

I've updated again. There's a new file format in use, called .mlm (Master [System] Lemmings Map). The data contained is exactly the same as the map data used in the game, making it easier to import and export maps.

Well, I say "easier", but there is some setup involved. The zip file contains two Lua scripts that you need to copy to the luascr folder where you installed Mappy. You then need to edit the MAPWIN.INI as described in the readme; or if you're feeling lazy, you can overwrite the original because I've included one in the zip file.

I'll begin extracting the map files from the ROM, and post them up as a separate download when they're ready.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #29 on: July 28, 2011, 10:34:53 PM »
Thanks Pooty! :D

On a slightly unrelated note.. I've just made a hideous looking conversion of Lemmings' Ark. I'll release this if there is demand, but I will warn you in advance, it will make you vomit whilst playing.


Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #30 on: July 28, 2011, 10:40:20 PM »
Ooh, nice! I'll definitely have to give that a go.  :thumbsup:
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #31 on: July 28, 2011, 10:55:45 PM »
Quote from: Pooty on 2011-07-28 16:40:20
Quote
Ooh, nice! I'll definitely have to give that a go. 
I've attached the mlm and leveldata files for anyone who wants to play this level. Obviously, you have to fill in your ROM details.
Edit: Updated the 'mlm' file.
Edit2: This level may not be possible with some tweaks.. leave it with me.


Mod Edit: Restored attachments.
« Last Edit: December 28, 2014, 09:37:34 PM by Prob Lem »

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #32 on: July 29, 2011, 12:12:52 AM »
On a slightly unrelated note.. I've just made a hideous looking conversion of Lemmings' Ark.  I'll release this if there is demand, but I will warn you in advance, it will make you vomit whilst playing.

Hmm, frankly I now wonder how anyone can play any of the levels in that tileset without vomitting or going blind. ;P  There's something about that neon-blue color that just doesn't work for me.  Were they really unable to come up with a better color scheme?

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #33 on: July 29, 2011, 12:45:20 AM »
I do sorta agree there, ccexplore - the colours are a little bit garish, but I'm used to them - the other brick styles look bland to me!!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #34 on: July 29, 2011, 01:24:01 AM »
I've converted all the levels now. You'll find them on the original post. :)
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #35 on: July 29, 2011, 02:06:52 AM »
Thanks, Pooty! I've just applauded you - I hope others do the same! :D

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #36 on: July 29, 2011, 06:41:38 PM »
I'm having real trouble getting this level to look half-decent, and solveable.. I may have to give up work on this level for now!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #37 on: July 29, 2011, 07:00:37 PM »
Yeah, it definitely looks hard to get right. The way builders stop building when in contact with the terrain is very different from the other versions.

I've been creating a level today, and it seems just about ready. You might recognise this level from somewhere...
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #38 on: July 29, 2011, 07:13:27 PM »
Ooh, very interesting! :D

This level's nasty, in a good way! My first instinct was to use the water glitch, but it doesn't work! ¬_¬

How're you getting on with the traps?

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #39 on: July 29, 2011, 07:47:50 PM »
I haven't been working on it today, so the situation is roughly the same. Now that I know where the traps are implemented (in the set of processes from address $2248 onwards), I might be able to work it out if I load a level that uses traps, and watch the debugger on MEKA.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #40 on: July 29, 2011, 08:13:08 PM »
Ah, I see!

Not sure how I can help there, but if there is a way, let me know.

Video of my (possible backroute) solution for Moon Glow is now up:
MoonGlow

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #41 on: July 30, 2011, 09:59:19 PM »
Yeah, it's a backroute. Then again, when I made that level as my forum avatar, the solution I had in mind would rescue 90%. I plan on redesigning the level slightly to make it look less cramped, and try to implement the original solution once more.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #42 on: July 30, 2011, 10:22:16 PM »
Yeah, it's a backroute. Then again, when I made that level as my forum avatar, the solution I had in mind would rescue 90%. I plan on redesigning the level slightly to make it look less cramped, and try to implement the original solution once more.

Looking forward to it, Pooty!

Currently working on making an SMS version of every missing level (bar the special levels) - so far, I've got The Far Side, Cascade, Stepping Stones and Save Me done.

I'm also needing a level to replace Sega Five (Taxing 30) - I can't use We All Fall Down, but want to use an existing level, due to my lack of imagination!

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #43 on: July 31, 2011, 04:48:03 AM »
A repeat of Fun 3, or perhaps Going Their Seperate Ways?

EDIT: Also, why can't the space of the default levels be used for new ones?
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #44 on: August 04, 2011, 01:06:23 PM »
Anyway, here's an addition to the topic. It's nothing new, but I've remade one of the more noticable levels from Lemmings Plus DOS Project... no, not Oblivion (I seriously doubt that'd work on SMS, getting it to work on DOS was hard enough)... Variety Day! (PSYCHO 1)

It actually looks quite decent on SMS, as far as I can tell even with having to modify the level to avoid glitches there's no new backroutes (in fact, I think at least one old one is impossible on this version), and the original solution is 100% intact. I didn't even have to scale it down to less lemmings since the original level already only had 20 (although to be fair, the intended solution can be enforced with as few as 4 lemmings, so it wouldn't've mattered if the amount had to be reduced anyway).

Enjoy!


...by the way, out of interest, what would happen if you set (in the game data) an 'illegal' number of lemmings?
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #45 on: August 05, 2011, 03:14:12 PM »
If you set the number of lemmings to another value, the percentages will be wrong. How it works in-game at the moment is that when you rescue a lemming, the game will increase the "In" percentage by a value supplied in the level data. The number of lemmings is not considered.

So if there are 20 lemmings in the level, you set this value to 05, meaning every lemming you rescue will increase the "In" percentage by 5%.

If there are 3 lemmings, on the other hand, setting the value to 33 means you'll only rescue 99% if all lemmings are rescued. I'd like to fix that somehow. Three ideas spring to mind; either by removing any mention of percentages and replacing it with units (e.g. Number of Lemmings 20, 19 to be saved), by implementing a lookup table, or by implementing a division subroutine, active when each lemming is rescued.

Also, if you use more than 20 lemmings, a 21st lemming will increase the "out" counter to 21, but that lemming will not actually exist. The ghost lemming cannot be nuked, so you have to wait for the time to expire.

About overwriting the space the original levels use, it's very risky to do because the data is compressed. It's fine if the resulting file size is smaller or equal to the level you're overwriting. If it's larger, however, it's very likely that you'll spoil the data for a different level, or maybe interfere with some of the game's graphics, depending on which level you overwrite.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Simon

  • Administrator
  • Posts: 3877
    • View Profile
    • Lix
Re: SEGA Master System level modifying
« Reply #46 on: August 05, 2011, 03:51:46 PM »
If you're really able to fix the game's binary code in different ways, then consider the absolute count (save 19 out of 20). This has been done in several games similar to Lemmings, and it appears to be the most usable solution.

-- Simon

Offline finlay

  • Posts: 543
    • View Profile
Re: SEGA Master System level modifying
« Reply #47 on: August 05, 2011, 05:05:18 PM »
And indeed in many ports of Lemmings itself, especially newer ones like the various playstation versions. I guess the only thing that can be said for the percentage system is that it makes comparison between levels easier in some ways – like highlighting 100% levels easily – but it's useless for determining the permissible loss rate for a level easily...

Offline Mr. K

  • Posts: 793
  • Former admin, always Lemmings fan
    • View Profile
    • Wafflenet
Re: SEGA Master System level modifying
« Reply #48 on: August 05, 2011, 05:51:29 PM »
If you set the number of lemmings to another value, the percentages will be wrong. How it works in-game at the moment is that when you rescue a lemming, the game will increase the "In" percentage by a value supplied in the level data. The number of lemmings is not considered.

So if there are 20 lemmings in the level, you set this value to 05, meaning every lemming you rescue will increase the "In" percentage by 5%.

If there are 3 lemmings, on the other hand, setting the value to 33 means you'll only rescue 99% if all lemmings are rescued. I'd like to fix that somehow. Three ideas spring to mind; either by removing any mention of percentages and replacing it with units (e.g. Number of Lemmings 20, 19 to be saved), by implementing a lookup table, or by implementing a division subroutine, active when each lemming is rescued.

Also, if you use more than 20 lemmings, a 21st lemming will increase the "out" counter to 21, but that lemming will not actually exist. The ghost lemming cannot be nuked, so you have to wait for the time to expire.

About overwriting the space the original levels use, it's very risky to do because the data is compressed. It's fine if the resulting file size is smaller or equal to the level you're overwriting. If it's larger, however, it's very likely that you'll spoil the data for a different level, or maybe interfere with some of the game's graphics, depending on which level you overwrite.

Sounds like a tall task; you're going to need a disassembly of the game.  (I haven't been watching the thread like a hawk, so if we actually do already, I apologize for not realizing it)  On the plus side, if we had one, it could make editing a lot easier-- a split disassembly would allow individual levels to be edited more freely without having to inject them back into the ROM, and they would not have to be the exact same size as the original level, because the pointers would be automatically rearranged and the ROM expanded to make room when the code is reassembled.  The Sonic hacking community has had great success with this method.  I don't know if you know Z80 ASM though.  I know I don't.

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #49 on: August 07, 2011, 09:16:12 AM »
Out of interest, if you cleared the whole space of default levels and just used it for new levels, how much space would be available, and approximately how many levels would fit in that?
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline The Doctor

  • Posts: 301
  • Jason the Human
    • View Profile
    • zapzupnz.com
Re: SEGA Master System level modifying
« Reply #50 on: August 08, 2011, 12:41:13 PM »
This Lemmings forum is simply *fabulous*!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #51 on: August 08, 2011, 02:26:55 PM »
Nice one! :thumbsup: So all that's needed is either a map tool that can write custom file formats, or a tool that converts a map file format into the MLM format, and it'll be possible to get this fully functional on the Mac.

I've just about finished moving, so I can get back to working on dissecting the ROM and stuff.

Out of interest, if you cleared the whole space of default levels and just used it for new levels, how much space would be available, and approximately how many levels would fit in that?

At a rough guess, the levels take up just under 72KB. The average level size is just under 1KB, but level sizes vary greatly. The largest level is "I've Lost That Lemming Feeling" at 1.9KB (the second largest is "SEGA Five" (1.56KB)), and the smallest is "Tightrope City", which is a mere 98 bytes (the next smallest level is "Lemming Sanctuary in Sight" (336 bytes)). Your Variety Day map takes up 576 bytes, so you could fit maps of that size more than 120 times.

Sounds like a tall task; you're going to need a disassembly of the game.  (I haven't been watching the thread like a hawk, so if we actually do already, I apologize for not realizing it)  On the plus side, if we had one, it could make editing a lot easier-- a split disassembly would allow individual levels to be edited more freely without having to inject them back into the ROM, and they would not have to be the exact same size as the original level, because the pointers would be automatically rearranged and the ROM expanded to make room when the code is reassembled.  The Sonic hacking community has had great success with this method.  I don't know if you know Z80 ASM though.  I know I don't.

My understanding of Z80 assembly is okay, but I still have some shortcomings with it. A disassembly of the game would be very helpful, and I will need to make one soon to at least allow trap deployment and palette swapping, but it's going to take a while to get it ready.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #52 on: August 08, 2011, 07:22:59 PM »
Some great info coming out again today!

Just done a recording of Namida's Variety Day - not sure if it's the intended solution or a backroute - but I enjoyed the level!
Custom Level - Variety Day

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #53 on: August 08, 2011, 08:25:28 PM »
Nicely done. :thumbsup:

I've done a very rough automated disassembly of the ROM using SMSExamine, and reading that instead of machine code is a lot easier. I've found that the game also modifies Fun 09 and Tricky 26 by dropping the height of the two lower spinning fiery... things by one tile.

Trap modifications to the levels seem to begin happening at address $1F9F, and the code for deciding which levels have them begin at $1F13. So, I'm making progress. Just need to understand exactly what's going on there. :P

[Edit]: The game writes a number related to traps in $DB97. The number written seems to be consistent across repeated levels. I just don't understand what this number is supposed to represent. E.g. Fun 15/Taxing 01 writes 01, Fun 21/Fun 26 writes 03. Taxing 02 writes 06. Odd, considering that that's the same trap.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #54 on: August 08, 2011, 08:42:41 PM »
Nice, Pooty!

Just FMI, how easy would it be to make a flamethrower pointing the opposite way in the Fire Style?

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #55 on: August 08, 2011, 09:00:25 PM »
At the moment, it'll be difficult. The flame thrower takes up 8 tile spaces, and there's only 3 spaces available on the Fire style, which looks like is being taken by some game data. It's possible to just flip the tiles the other way, but that would affect all levels that use it.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #56 on: August 08, 2011, 10:21:04 PM »
[Edit]: The game writes a number related to traps in $DB97. The number written seems to be consistent across repeated levels. I just don't understand what this number is supposed to represent. E.g. Fun 15/Taxing 01 writes 01, Fun 21/Fun 26 writes 03. Taxing 02 writes 06. Odd, considering that that's the same trap.

The most obvious next steps is to search the disassembly for all places that seem to use the DB97 address, in hopes of finding code fragments that read from it and therefore getting more insight into what it does.  You can also fudge around with the number (ie. change it from the original value in the ROM) to see what effects it has.

At some point you may also want to Google for technical documents on the SMS.  Although perhaps too early at this point, and also perhaps not ultimately necessary for your task at hand, you might at some point need to understand the interfaces between the CPU and other peripherals (which for a console can refer to the many other specialized chipsets, typically at least one for graphics and another for sound), in order to understand some code fragment or the meaning of some data (though the "fudge the number" approach may also be viable).  These interfaces typically come in the form of "registers" accessible to the CPU via special memory locations, and it's almost impractical to have to figure out the semantics of these interfaces yourself, rather than learning them from docs.

Anyway, keep up the good work! :thumbsup:  It can be a long tedious road ahead, as I have known from my own experience.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #57 on: August 09, 2011, 01:03:04 AM »
Playing with $DB97 produces some interesting results. Changing it to 00 disables the level's trap. Also, if you load up Tricky 04 and change $DB97 to 03, lemmings will die as they cross the metal platform just before the exit. You don't see the trap animation, but the trap is there.

Also, if you go to Taxing 30, set $DB97 to 06, and get a lemming to stand in the circled area in the attached image, the lemming will die, but you'll see a beartrap animation scattered throughout the level. So the number seems to determine what trap is used, where it is, and which tiles the animation overwrites.

And yeah, I've spent a lot of time studying Master System and Z80 technical documents. I don't know enough just yet to make my own games from scratch, but I'm getting a good idea of how everything links together. It's good fun, but it can be frustrating sometimes.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #58 on: August 09, 2011, 08:50:01 AM »
That's very close to the intended solution, but it is still a backroute as it takes out the best trick of the level.
This should fix it.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #59 on: August 10, 2011, 02:19:07 AM »
I've done a very rough automated disassembly of the ROM using SMSExamine, and reading that instead of machine code is a lot easier. I've found that the game also modifies Fun 09 and Tricky 26 by dropping the height of the two lower spinning fiery... things by one tile.

Trap modifications to the levels seem to begin happening at address $1F9F, and the code for deciding which levels have them begin at $1F13. So, I'm making progress. Just need to understand exactly what's going on there. :P

[Edit]: The game writes a number related to traps in $DB97. The number written seems to be consistent across repeated levels. I just don't understand what this number is supposed to represent. E.g. Fun 15/Taxing 01 writes 01, Fun 21/Fun 26 writes 03. Taxing 02 writes 06. Odd, considering that that's the same trap.

No promises whatsoever, but since I've finally got past the more soul-sucking phase of my real-life work schedule :-\, I might be able to spare some time here and there to help with diassembly, but only if you can provide me the full or partial disassembly you already have in text file format.  (In any case, you are probably much more knowledge at this point anyway, so I'm probably not going to be of much help, but we'll see.)

It also sounds like you have a pretty good handle on the level format and other things in SMS Lemmings, perhaps it should be documented to benefit others who may want to further create tools for custom levels and/or tilesets?

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #60 on: August 10, 2011, 11:12:48 AM »
Out of interest, if you cleared the whole space of default levels and just used it for new levels, how much space would be available, and approximately how many levels would fit in that?

At a rough guess, the levels take up just under 72KB.

How much space is left at the end of the ROM (presumably where you're currently sticking the injected level)?

Actually, from browsing technical docs on smspower, SMS supports largest ROM size of 512 KB, while the Lemmings ROM is apparently only 256 KB.  So can we simply expand the ROM size to 512 KB, and then we're left with tons of space for maps?

It also sounds like you have a pretty good handle on the level format and other things in SMS Lemmings, perhaps it should be documented to benefit others who may want to further create tools for custom levels and/or tilesets?

As it turns out, so far from just reading your source code, I've been able to work out a lot of things myself, so I guess it's enough to just document things that aren't captured in your tools and programs.

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #61 on: August 10, 2011, 11:30:13 AM »
That's very close to the intended solution, but it is still a backroute as it takes out the best trick of the level.
This should fix it.

I very distinctly remember playing DOS version of this level, but have totally forgotten the solution by now and pretty much re-solve it from scratch (which took a bit of work, so nice puzzle!).  I think you can solve it without using every single skill though, so I don't know if this is the right solution or not (attached zipped screenshot).

Offline Clam

  • Posts: 2187
  • Smiley: :8():
    • View Profile
Re: SEGA Master System level modifying
« Reply #62 on: August 10, 2011, 11:39:31 PM »
Following a little persuasion, I've decided to join in the fun and convert one of my own levels. This is "Play Bridge" from my 05 pack. Thanks Pooty for making the converter, it's already quite a usable setup :thumbsup:

I tried one of my earlier levels first ("Hello, Goodbye"), but I ran into some difficulty - putting crystals together from little tiles is a real mission, and there doesn't seem to be a tile that connects crystals to the pipe terrain. Just a disadvantage of having a fixed set of square tiles, it seems - certain terrain configurations just aren't possible. This really bugged me about L2 as well :(. On that note, IIRC L2 had a set of predefined terrain structures - does SMS have these as well, or do they need to be built from scratch?

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #63 on: August 11, 2011, 12:22:00 AM »
On that note, IIRC L2 had a set of predefined terrain structures - does SMS have these as well, or do they need to be built from scratch?

I guess it's up to Pooty to see if he can find such data in the ROM, but I'm leaning towards no.  For obvious reasons, it's much more likely for activities like level editing and graphics design to be done on an actual computer and then at the end the finished results incorporated into the ROM, rather than actually creating an editor that runs on the console itself.  So any data in the ROM would have to be explicitly selected to be copied from computer to ROM.  Plus back in the days ROM space would be somewhat at a premium.  So the bottom line is, while conceivable, it seems unlikely that they would include into the ROM the extra data that defines terrain structures from tiles, seeing as they have no role in the actual game.

No that I'm sure it'd help you much even if it exists.  I know the Mappy editor supports creating "brushes" from combinations of tiles, but I haven't used it enough to know whether it supports saving/loading "brush sets", or whether the file format for such things (if exist) is documented or not (so that one can convert whatever ROM data that defines terrain structures into the "brush" format consumable by Mappy).

Ignoring that important point, it may be possible however to build up a set of terrain structures through statistical means, analyzing the in-game maps to come up with good candidates for terrain structures, and then hand-refine them into a usable set.

Offline namida

  • Administrator
  • Posts: 12399
    • View Profile
    • NeoLemmix Website
Re: SEGA Master System level modifying
« Reply #64 on: August 11, 2011, 08:00:33 AM »
That's very close to the intended solution, but it is still a backroute as it takes out the best trick of the level.
This should fix it.

I very distinctly remember playing DOS version of this level, but have totally forgotten the solution by now and pretty much re-solve it from scratch (which took a bit of work, so nice puzzle!).  I think you can solve it without using every single skill though, so I don't know if this is the right solution or not (attached zipped screenshot).

From what I can tell of that shot, I'm pretty sure it's the right one.
You are correct about not needing every skill - the floater has no use.
My Lemmings projects
2D Lemmings: NeoLemmix (engine) | Lemmings Plus Series (level packs) | Doomsday Lemmings (level pack)
3D Lemmings: Loap (engine) | L3DEdit (level / graphics editor) | L3DUtils (replay / etc utility) | Lemmings Plus 3D (level pack)

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #65 on: August 11, 2011, 12:53:11 PM »
How much space is left at the end of the ROM (presumably where you're currently sticking the injected level)?

Actually, from browsing technical docs on smspower, SMS supports largest ROM size of 512 KB, while the Lemmings ROM is apparently only 256 KB.  So can we simply expand the ROM size to 512 KB, and then we're left with tons of space for maps?

There is just under 4KB (4064 bytes) beginning from $3B020. Actually, the zeroes at that part of the ROM begin at $3B01B, but I'm not sure if those zeroes are being used for anything. I don't think they do, but I didn't want to risk it.

And I also thought about expanding the ROM size. It can be done, and certainly works on emulators. Not sure about on real Master Systems, but I don't see why it won't, as long as the data is written into a 4 megabit cartridge with a suitable mapper.

SMSPower is an amazing website. I couldn't have done a lot of this stuff without it. :)

I've attached the automated disassembly of the game, but I've blanked out page 04, which only contains maps. This removes all grass-style levels (except "Hunt the Nessy" and "One Way or Another"), "Lend a Helping Hand", "The Ascending Pillar Scenario", "Tailor-made for Blockers", "Call In the Bomb Squad" and "Now Use Miners and Climbers". If you need this data, you can yoink it straight from the ROM. The data begins from $10000 - $13FFF, and save this data to Lemmings.dat.40. The downloads you need and the instructions to set up the assembly of the game are at http://www.smspower.org/maxim/HowToProgram/DownloadingStuff.

On that note, IIRC L2 had a set of predefined terrain structures - does SMS have these as well, or do they need to be built from scratch?

There isn't, unfortunately. I'm certain that the level designers had such data on them, but it's not in the ROM. All we have are the tiles. Although now you mention it, a possible future project may be to make Lemmings 2: The Tribes tilesets work on this game. The colours would almost certainly have to be modified, mind you. The Master System can only render 64 different colours. But I'm getting a bit too far ahead of myself with that suggestion. :P
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #66 on: August 12, 2011, 11:08:47 AM »
Although now you mention it, a possible future project may be to make Lemmings 2: The Tribes tilesets work on this game. The colours would almost certainly have to be modified, mind you. The Master System can only render 64 different colours. But I'm getting a bit too far ahead of myself with that suggestion. :P

Interesting idea. :thumbsup: Although I'm thinking it might be also be interesting to go the opposite direction, porting the Sega tilesets (especially the SEGA one) over to Lemmings 2 (taking advantage of more skills and more traps in that game).  But again, as you said, way ahead of ourselves.

When the time comes, I can help with color reduction algorithms if needed.  Does SMS use a fixed set of 64 colors, or a palette of 64 colors selectable out of a much larger color space?  For comparison, Lemmings 2 uses a 256-color-palette graphics mode out of an 18-bit color space, although looking at its tilesets, I kinda think each don't even necessarily use up all 256 palette entries.  64 may well be enough.

I think actually the number of tiles in Lemmings 2 tilesets might be more problematic.  I don't remember anything concrete off top of my head, but I have a feeling the tilesets in Lemmings 2 probably use up more tiles than what you can fit into a Sega tileset.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #67 on: August 12, 2011, 04:50:02 PM »
The Master System has two active palettes of 16 colours, for a total of up to 32 colours. The first palette is used for background tiles only. The second palette can be used for both background tiles and sprites.

The colours available is from a selection of 64 6-bit colours, meaning there are four shades of red, green and blue (0, 85, 170, 255).

Lemmings uses the same set of colours throughout the game, and is duplicated between both palettes. I think this is done because of the way the game draws more than 8 lemmings on the same scanline by pasting the lemming sprites into the background. That said, it isn't really necessary to duplicate the entire palette. I've attached an image of the palette used by the game, and identified eight colours that are used by the lemmings (marked with red circles), and would therefore need to be identical in both palettes. The two shades of grey are only really used during the splatting animation (as well as the cursor), so they could be edited to free those colours.

The colours I marked with green pluses are only used in maps, and they could be edited. The orange colour is a duplicate, and the black colour is the solid black that lemmings can stand on.

The remaining colours are used as part of the trapdoor.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #68 on: August 13, 2011, 01:45:58 AM »
I see.  So the color space itself is only 64 colors (I should've known, we're talking about the SMS silly me ;P).  This definitely will make automated porting of colors from Lemmings 2 over to SMS a little tricky, especially with sets like Shadow where everything are just shades of dark blue ;P :-\.

Anyway, on better news, I believe I've figured out trap modification, or enough of it for Pooty to start experiment supporting traps in custom levels.

The $DB97 value is actually an array index into a table that actually specifies the trap modification.  This array starts at $3B1B (under 0-based indexing) with each element being 4 bytes.  As you noted, 0 for $DB97 is treated special as "no trap modifications".  A $DB97 value of for example 3 would therefore refer to the 4 bytes starting from $3B1B + 3*4 = $3B27.  The $DB97 must be between 1-8 since right after the 8th entry of the array are more code, so there's only room for 8 entries.

The 4 bytes within an entry break down as follows:
  byte 0: which type of trap. Must be 1-4 (all other values ignored by game programming):
        1=squish (ie. Fun17)
        2=noose (ie. Fun15)
        3=beartrap (ie. Fun21)
        4=the trap in the various Sega levels
  byte 1,2: little-endian WORD specifying x-position (in pixels) of trap trigger location
  byte 3: specifying y-position (in pixels) of trap trigger location

I haven't drilled deeply into the code the game does for detecting whether a lemming hits a trap trigger or not, but based on preliminary reading, I think the trap trigger is always 4x1 pixels, ranging from (trapx, trapy) to (trapx+3,trapy).  It's easiest to see the relation by simply looking at the original values in the table, and see what location it corresponds to in the tilemap for the level.  Below is the $3B1B table in the unmodified ROM:

Code: [Select]
$3B1B: 0, 0000, 0,  (not used: 0 in $DB97 causes all the trap-related code to be skipped)
       2, 02EC, 88,  (Fun15/Taxing1)
       1, 0160, 88,  (Fun17/Taxing6)
       3, 02A0, 80,  (Fun21/Mayhem26)
       4, 00CC, 80,  (Fun20/Mayhem9)
       4, 0224, 80,  (Fun26/Mayhem12)
       3, 02D0, 38,  (Taxing2)
       4, 0334, 70,  (Tricky25/Mayhem13)
       4, 0034, 60,  (Tricky21/Mayhem18)

In case it isn't clear, the Sega programming's support for traps is extremely limited:
  1) at most one triggered trap in the level.
  2) it only has programming to explicitly support 4 different types of traps, namely the ones listed above.

So at this point (and likely well into the near future), please don't ask for changes to remove these limitations, as it will require major code surgery. ;) :-\

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #69 on: August 13, 2011, 01:55:50 AM »
I should note that I haven't yet figured out where the game actually stores the tiles for the animation frames of the traps.  But given that the game only supports 4 types of traps anyway, you might as well just use an emulator and screen capture to capture the necessary graphics (especially since we really only need one frame for use in level editing).  I'm not sure, but it looks like the game uses a specific set of tiles in the tilemap for the tiles of a trap, so maybe Pooty can just modify the tilemap PNG files to incorporate the actual graphics for one frame of the trap (so it shows up correctly in Mappy), and then have his program recognize the usage of these specific tiles as a way to determine where the trap is located, and therefore how to modify the 3B1B table correctly to make the trap work.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #70 on: August 13, 2011, 12:02:36 PM »
Ah-ha! Thanks for that. :thumbsup:

And.. err.. darn. That's going to complicate trap implementation a bit, since all but one trap (Taxing 2) is used in a repeated level. Unless you overwrite Taxing 2 and use the 6th trap entry, there's no way you can get away with placing a trap in your level without affecting the rest of the game. For one-shot levels like we're using at the moment, that's not a problem, but I'm not exactly a fan of destroying games.

As for the location of the trap frames, they're stored uncompressed from $343C6 (page D, in-game offset $83C6). You'll also find other animated features, such as the home fires, waters, and an unused one-way wall animation, which is unimplementable. There's also some unused frames in there, which is an unfortunate waste of ROM.

The trap frame pointers are stored in little-endian from $3CB4, and they are stored in order. Again, they can point to the unused trap frames. However, the dripping tap trap's default frame points to the same one as the bear trap's ("F", $8C in the disassembly, which should read $46, $8C), since they are both completely blank.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #71 on: August 13, 2011, 01:30:25 PM »
And.. err.. darn. That's going to complicate trap implementation a bit, since all but one trap (Taxing 2) is used in a repeated level. Unless you overwrite Taxing 2 and use the 6th trap entry, there's no way you can get away with placing a trap in your level without affecting the rest of the game. For one-shot levels like we're using at the moment, that's not a problem, but I'm not exactly a fan of destroying games.

I think I may have a way that lets you use the unused $3B1B slot (0th entry).  That slot normally isn't used because the game treats a 0 in $DB97 specially.  But, due to the exact way they calculate the array indexing, it looks like a value of 64 (decimal, or $40 hex) for $DB97 will end up wrapping back to the $3B1B address, but unlike 0 will not cause the game to disable traps.

Making use of this extra slot, plus some additional hacking of the $DB97-writing code, would then allow you to pick any of the 15 existing trap-enabled levels to be replaced with your custom level, without affecting any other levels (including the repeat of the level you replaced, if any), instead of Taxing 2 being your only "safe" replacement option.

Of course, this still isn't really a good long term solution for when you want to potentially support any number of the 120 levels being trap-enabled.  Unfortunately that sort of change would require a little more code surgery like anything else significant with traps. :-\

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #72 on: August 13, 2011, 02:38:43 PM »
Sounds good to me. And with that, I think I may have enough information to implement a trap in a custom level without damaging the rest of the game. There's only one way to find out. :D

[Edit] Damn. Good feeling's gone. I'm not sure about how to change the subroutine beginning from $1F0C to get the trap implemented in the custom level. I think I need to plan this out better.

[Edit 2] Hold that thought. I might be able to get somewhere if I attack the subroutine call at $3EC5.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #73 on: August 13, 2011, 03:30:39 PM »
Great stuff! I'm in awe at how much you two have been able to do in such a short space of time.

This could just be me being stupid, but I can't recall seeing the trap on the seventh row down in your image.. it looks like it fits in the Ice style, but I'm probably wrong!


Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #74 on: August 13, 2011, 03:47:04 PM »
That's actually the tap trap in the SEGA levels. That said, the ice levels really could do with a trap. An animation of a lemming getting zapped would be a start.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #75 on: August 13, 2011, 03:55:59 PM »
Indeed, it would.. I'm crap at drawing things from scratch, but I'm sure it could be possible to attempt to find one from another port and modify it to the SMS' specs.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #76 on: August 13, 2011, 06:43:02 PM »
Good news. The traps are working now. I just need to update the tilesets to clearly indicate the trapped tiles, and then I can release it. I'm going to try and get it done within the hour. So you can expect it in two hours. :P
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #77 on: August 13, 2011, 07:09:01 PM »
Good news. The traps are working now. I just need to update the tilesets to clearly indicate the trapped tiles, and then I can release it. I'm going to try and get it done within the hour. So you can expect it in two hours. :P
Okay, so that's three hours? :P

Seriously.. great work, Pooty! :D

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #78 on: August 13, 2011, 07:40:15 PM »
Okay, an ONML level here - Havoc 9 - AAAAAARRRRRRGGGGGGHHHHHH!!!!!!.

Changed the skills and time here to make the level harder, but it is still possible to pass the level.


Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #79 on: August 13, 2011, 07:50:21 PM »
...and it's done! Not ARRRRGGGHHH!! I'll check it out in a minute. ;)

Traps are now available, downloadable in the opening post of this thread. I've attached an image to show how you're supposed to lay them out in Mappy. The highlighted tile is the one you use to feed the co-ordinates into leveldata.txt. Note the co-ordinates it lies on, and type them in.

Setting the <Trap Type> to 0 prevents the implementation of traps. This has the added benefit of fixing that glitch that made holes in your level if there was a trap in that level in the original game.

One other thing. The co-ordinates you feed it are tile co-ordinates by default. You can override this so you can provide it with pixel co-ordinates instead by using the x,y prefixes. So if you want to place your trap trigger at the pixel location 256, 64 in your level, you enter...

Code: [Select]
<Trap X> x256
<Trap Y> y64
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline Adam

  • Posts: 424
  • Just one more level....
    • View Profile
    • Lemmings Forums
Re: SEGA Master System level modifying
« Reply #80 on: August 13, 2011, 10:40:24 PM »
Traps work brilliantly, thanks Pooty! Gonna try and add a couple of traps into levels where they need them.. leave it with me!

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #81 on: August 14, 2011, 12:35:00 AM »
[Edit] Damn. Good feeling's gone. I'm not sure about how to change the subroutine beginning from $1F0C to get the trap implemented in the custom level. I think I need to plan this out better.

[Edit 2] Hold that thought. I might be able to get somewhere if I attack the subroutine call at $3EC5.

I see.  So where did you find the space to fit your new code in?

I just took a brief look at the $1F0C routine, and I know how you can rewrite that whole thing to it smaller, so that you could fit one more set of instructions for the custom level.   But I guess it's even better anyway if you can already find extra space somewhere else to insert the extra instructions.  Good job!

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #82 on: August 14, 2011, 12:58:05 AM »
I'm using the free space between $7670 and $7A7F as if it were a coding sandbox, since it's guaranteed to be accessible at all times. That space is only being used for two things at the moment: the trap subroutine I just implemented, and the custom level's map data (although I've since realised I could have used the empty space at $716F - $7173 for that purpose).
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #83 on: August 14, 2011, 10:34:46 AM »
It looks like there's a bug in your calculation for the trap implementation in your converter, at least based on the included source code (Level Data\traps.h):

Code: [Select]
    //Writing the most significant bit in the little-endian value.
    if (trapX > 256)
    {
        if (trapX > 512) romData[offset++] = (unsigned char) 2; else romData[offset++] = (unsigned char) 1;
    }
    else
    {
        romData[offset++] = (unsigned char) 0;
    }

But given the map area's width, trapX can get up to $37F, so the most significant byte can range from 0-3 rather than 0-2 as in your code.

You can actually get the most significant byte much more easily by using either the right-shift operator >> or just a division, ie.:

romData[offset++] = (unsigned char)(trapX >> 8);   or
romData[offset++] = (unsigned char)(trapX / 256);

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #84 on: August 14, 2011, 11:23:09 AM »
Balls! How did I manage that? I must have done something stupid when working out the maximum X co-ordinate. I'll fix that right away.

[Edit] Fixed using the bit shift method because... I love bit shifts. :D
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #85 on: August 14, 2011, 11:25:22 AM »
If there are 3 lemmings, on the other hand, setting the value to 33 means you'll only rescue 99% if all lemmings are rescued. I'd like to fix that somehow. Three ideas spring to mind; either by removing any mention of percentages and replacing it with units (e.g. Number of Lemmings 20, 19 to be saved), by implementing a lookup table, or by implementing a division subroutine, active when each lemming is rescued.

Since most people don't mind showing number of lemmings instead of percentage, I'll definitely put my vote on doing that, because it is most definitely the simplest way to fix the problem.  You see, all you'd have to do is basically to replace the graphics for the "%" with a blank and you're almost done!  This game doesn't even bother with any special messages if you do get 100% or any other "special" % values, you basically just get a "rock bottom" message, a "try harder" message (if you reach at least half of the goal), and then no congratulatory messages (!) if you meet or exceed the goal.

With this approach, you basically set the "% increment" value in the level data to 1 for every level, and similarly adjust all goals in all level data from percentage value to actual number of lemmings.  In effect we switch units from "percentage" to "number of lemmings".  Removing the "%" character then completes the picture.  Since the game doesn't check for specific percentage values, the fact that we've switch units will not affect anything.

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #86 on: August 14, 2011, 11:43:09 AM »
This game doesn't even bother with any special messages if you do get 100% or any other "special" % values, you basically just get a "rock bottom" message, a "try harder" message (if you reach at least half of the goal), and then no congratulatory messages (!) if you meet or exceed the goal.

Well... you get a password.

...

Anyway, this does seem like the most popular idea, so I think it should be done. This would make levels such as "Five Alive" possible, rather than "Five Strive to Survive". :-\
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #87 on: August 16, 2011, 12:16:06 PM »
I've attached the automated disassembly of the game, but I've blanked out page 04, which only contains maps. This removes all grass-style levels (except "Hunt the Nessy" and "One Way or Another"), "Lend a Helping Hand", "The Ascending Pillar Scenario", "Tailor-made for Blockers", "Call In the Bomb Squad" and "Now Use Miners and Climbers". If you need this data, you can yoink it straight from the ROM. The data begins from $10000 - $13FFF, and save this data to Lemmings.dat.40. The downloads you need and the instructions to set up the assembly of the game are at http://www.smspower.org/maxim/HowToProgram/DownloadingStuff.

Okay, curious about the basher glitch, I'm current at the section in your attached disassembly marked "; Data from 3604 to 37CA (455 bytes)", except I can tell it's actually code from $362C onwards, and thus I need that "data" disassembled.  I tried your URL but am not sure any of its numerous links lead directly to a disassembler program (I guess the "Lesson" sections did mention an assembler but I don't know if it does disasembly).  Any chance you can quickly point me to a disassembler download page or better yet, just get that small part disassembled :)?  Don't bother if it's too much trouble though, I guess I can find a way later this week on my own.  Thanks in any case. 8)

Offline Maxim

  • Posts: 2
    • View Profile
Re: SEGA Master System level modifying
« Reply #88 on: August 16, 2011, 04:04:56 PM »
This is excellent stuff, I just posted about it over at SMS Power! and I'm happy to provide advice on SMS hacking in general. I may not be a super-regular visitor so feel free to harass me by email...

SMSExamine tries to figure out the executed bits of code and leaves the rest out, marked as data, but it often gets things wrong (especially when there are table lookups). For disassembling, I usually use z80dasm which you can find here: http://www.smspower.org/Development/Tools#Disassemblers

Offline Pooty

  • Posts: 359
    • View Profile
Re: SEGA Master System level modifying
« Reply #89 on: August 16, 2011, 05:42:13 PM »
Hello, Maxim! Thanks for dropping by and giving us a shout at SMS Power! SMS Power and your little corner of that website has helped me get to grips with how the Master System and its games work, so thank you, Bock, and everyone else involved. :thumbsup:

z80dasm worked really well, so I'm definitely going to use it more often. Disassembling that part has, as expected, opened up a fairly large rabbit hole, where more Z80 instructions have been mistaken for data. Looks like I'm going to be busy tonight. 8)

[Edit] In the meantime, here's a disassembly of the part ccexplore requested. Copy and pasting it into the source should be sufficient to make it work.
SEGA Master System version
100% on 110/120 levels (92%). Other levels [Lemmings lost]:
Fun 03 [3], 06 [2], 18 [5]   
Taxing 19 [5], 27 [1], 28 [3]
Tricky 15 [5], 17 [2]
Mayhem 19 [7], 26 [10]

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: SEGA Master System level modifying
« Reply #90 on: August 16, 2011, 09:31:51 PM »
SMSExamine tries to figure out the executed bits of code and leaves the rest out, marked as data, but it often gets things wrong (especially when there are table lookups). For disassembling, I usually use z80dasm which you can find here: http://www.smspower.org/Development/Tools#Disassemblers

Thanks! :thumbsup:  Will give that a try later tonight.

Offline petaQ

  • Posts: 20
    • View Profile
Re: SEGA Master System level modifying
« Reply #91 on: January 15, 2020, 02:47:43 AM »
I only just realised that this is a real thing in the same way that L++ and Lemmix are, no idea how I didn't twig for so long but I'll take some time to get the hang of it and the vagaries of the tiles, then get to work on a series of levels. Requests welcome since I have plenty of time to make a whole bunch! If anyone ever wants to set challenges for either speedrunning levels or just causing me some chaos, I'd be quite happy to take on allcomers and post the results to my Youtube or even in future stream me playing a pack of SMS levels blind like they do with mario maker. Who knows, a community built pack of 30 might become a category on Speedrun.com one day!