SEGA Master System level modifying

Started by Pooty, July 25, 2011, 11:35:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Pooty

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]

Simon

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

finlay

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

Mr. K

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.

namida

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 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)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

The Doctor

This Lemmings forum is simply *fabulous*!

Pooty

Nice one! http://www.lemmingsforums.com/Smileys/lemmings/thumbsup.gif" alt=":thumbsup:" title="Thumbs Up" class="smiley" /> 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]

Adam

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!
http://www.youtube.com/watch?v=sXAlyLHqKyo#ws" class="bbc_link" target="_blank">Custom Level - Variety Day

Pooty

Nicely done. http://www.lemmingsforums.com/Smileys/lemmings/thumbsup.gif" alt=":thumbsup:" title="Thumbs Up" class="smiley" />

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. http://www.lemmingsforums.com/Smileys/lemmings/tongue.gif" alt=":P" title="Tongue" class="smiley" />

[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]

Adam

Nice, Pooty!

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

Pooty

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]

ccexplore

[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! http://www.lemmingsforums.com/Smileys/lemmings/thumbsup.gif" alt=":thumbsup:" title="Thumbs Up" class="smiley" />  It can be a long tedious road ahead, as I have known from my own experience.

Pooty

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]

namida

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 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)
Non-Lemmings: Commander Keen: Galaxy Reimagined (a Commander Keen fangame)

ccexplore

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. http://www.lemmingsforums.com/Smileys/lemmings/tongue.gif" alt=":P" title="Tongue" class="smiley" />

[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 http://www.lemmingsforums.com/Smileys/lemmings/undecided.gif" alt=":-\" title="Undecided" class="smiley" />, 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?