15 users online: Dan2point5, Dark Prince,  idol, Lmao, Mario's GameBase, ocked, prisvag,  Segment1Zone2, sio-kedelic, sL0Thiie, The_Uber_Camper, underway,  yogui, Zavok, Zute - Guests: 103 - Bots: 323
Users: 65,986 (2,170 active)
Latest user: LuanVIIIR

Ripping Graphics with Lunar Magic (Bitmap pasting)

ExGFXRipping/DrawingLunar Magic

In 2011, Lunar Magic introduced a feature called "Convert and Paste Bitmap", which allows you to paste any image into the Map16 editor and have it converted into ExGFX files and Map16 tiles. It's actually an easter egg (and therefore undocumented), which explains why not many people know about it.
The reason it's not an official feature is that FuSoYa isn't satisfied with the output, presumably with the way it reduces colors. That means it's not the end-all solution to graphics ripping yet — but if you don't need to worry about color reduction and just want to turn an image into ExGFX and Map16, it's an immensely useful and time-saving feature.

This is something we all could benefit from knowing about, though the lack of documentation kind of makes it unlikely to even have heard about it. I've played around a bit, and I thought I'd share what I've found out — this tutorial won't cover each and every option, but it's enough to get you started ripping your own graphics in LM.

This tutorial assumes you're familiar with inserting ExGFX, and ideally, with making them as well.

1. Unlocking the feature

As mentioned, the "Convert and Paste Bitmap" feature is an easter egg for the time being, meaning it's hidden and won't be usable right away. There are two ways to unlock it:
  1. Wait for December 25. The feature unlocks itself on Christmas Day. Changing your system clock works as well.
  2. Use a cheat code to unlock it whenever you want.

Here's how to do the latter:

Make sure you haven't opened the Map16 editor yet (#lm{16x}). If you have, restart Lunar Magic.
Now open the overworld editor (#lm{ow}) and bring up the "Change Events Passed" dialog (Overworld → Change Events Passed…). In the text box, enter Give me presents! (case sensitive), then hit Esc.

If you did it right, the status bar at the bottom of the overworld editor window will say Oh, is it that time of year again already?. (You made LM think it's Christmas Day, after all.) The bitmap pasting feature will now be unlocked — open the Map16 editor and verify that the previously grayed-out #lm{?} button is now clickable.

2. Prerequisites

The neat thing about the bitmap pasting feature is that Lunar Magic will optimize the 8x8 tiles and automatically create ExGFX files so you don't have to. The one thing you still have to do, though, is tell LM which ExGFX files to create and which slots to use.

If you haven't already, install LM's 4BPP hack by extracting and re-inserting all graphics (#lm{extgfx}#lm{insgfx}#lm{extexgfx}#lm{insexgfx}).

Next, enable Super GFX Bypass (#lm{sgfxby}). Now choose the ExGFX files you want to create and the slots to insert them. (It's best to choose ExGFX files that don't exist yet, since Lunar Magic will just create them then.) For this tutorial, we're using ExGFXFFF in the BG3 slot, ExGFXFFE in the BG2 slot, and ExGFXFFD in the BG1 slot.

When you close the Super GFX Bypass dialog, you'll probably be warned of ExGFX files not existing. Ignore those warnings.

Now, the thing is: When ripping, Lunar Magic won't overwrite any tiles that already exist. That means that if you want to assign a non-existent ExGFX file to a slot that already contains graphics, you'll have to clear that one first.
In our case, that's the BG1 slot, where we want to insert ExGFXFFD. We can't just put FFD in there, because if the ExGFX file doesn't exist, the original graphics will be left in that slot, and Lunar Magic won't use it to put its own tiles there. To properly clear the lot, you can first put 7F there, then reopen the dialog and change it to the file you actually want (FFD in our case).
If you've created a new, empty ExGFX file, you can put that in directly and won't need to use this workaround.

3. Ripping an image

Now that we're all set up, let's get to ripping an image.

Lunar Magic will reduce the color palette of an image to fit the SNES's palette, but it may not always do a good job at it. If you have an image that uses a large amount of different colors, you might want to first use another tool to reduce the palette — however, if your image already only uses a handful of different colors, you'll have very few problems on that front.

For this tutorial, we'll be using the snow background from Sutte Hakkun:

All you need to do to rip this image is to paste it into the Map16 editor. Open it in an image editing program (MS Paint will do), select it and copy it (Ctrl-C). Now head back to Lunar Magic, open the Map16 editor, and with that window active, press Ctrl-V. This will open the "Convert and Paste Bitmap" dialog:

The top two images show the original image (left) and the way it'll look when converted by Lunar Magic (right). Already this doesn't look terribly bad — though if we take a closer look at the trees and the gradient in the sky, some colors are still off. Let's see what we can do about that!

4. The "Bitmap Pasting Color Options" dialog

Clicking "Color Options" will bring up the "Bitmap Pasting Color Options" dialog. (You can also open it by clicking the #lm{?} button — yep, that is what it does.)

You can tamper with the options on the left to fine-tune the color reduction process. I don't know how exactly all of these work, but feel free to play with them and see if that gives better results.

We'll be focusing on the right side. There you can see the top half of the current level's palette, that is, all the colors available for foreground and background tiles.

Some colors in this view are crossed out or marked with a star, which is explained in the dialog: squares with an X on top mean this color won't be used for ripping; squares with a star on top means the color may be used for ripping, but not modified. Finally, a blank square indicates that the color can be used by Lunar Magic for ripping — and indeed, you can see it's already put its custom colors there.
The key is that you can change this configuration — you can tell Lunar Magic which colors to use and which to leave intact. Left-clicking on a color switches between "blank" and "X", right-clicking switches between "blank" and "star". You can click the small buttons next to a palette row to change all of its colors in bulk (to "blank", "X" and "star" respectively).
The slider on the bottom left controls how quickly Lunar Magic will resort to using a "starred" color (i.e. how picky it will be about the starred color being the same as the color it needs).

By default, Lunar Magic treats the pasted image as a background, which means it'll default to using palette rows 0 and 1 (minus the status bar colors, of course). This is fine with us, since we do want to insert the image as a background. If you want to rip a foreground image instead, it may or may not be wise to make LM use palettes 2 and 3 instead. The right half of the palette is especially expendable.

Back to our case: to improve the quality of the ripped image, let's free up some more colors for LM to use!

Looking back at the previous dialog ("Convert and Paste Bitmap"), you can see that the original image has 24 different colors, but LM only had 21 modifiable colors to work with, so its output is also reduced to 21 colors. (The numbers in parentheses are in decimal.) Depending on the image you're using this might not always be noticeable, but in this case, it kind of is. It seems that if you just gave LM three more colors to work with, it could use the image without having to reduce the colors — but in reality it might be more than that, since each 8x8 tile can only use one palette row. If you freed up just one color all the way down in palette 7, that would essentially be useless. Freeing up a color is only useful when all the other colors in an 8x8 tile are also in the same palette row. The more colors can be in a single row, the better.
That means you'll need to free up more than three colors - but luckily, there's plenty of space left.

(As an aside: in theory, it might be better to swap palette rows 4 and 7 with 0 and 1 respectively, so you can use the entirety of rows 4 and 7 without worrying about overwriting status bar colors, as explained in the "Making better use of palettes" diagram in this thread. Let's keep it simple here, though, and just add on to the default palette rows.)

Free up some of the right half of the palette by left-clicking on the colors.

Hit OK and you'll get the following result:

Still not perfect, looking at the gradient (you may be able to fix this by making more clever use of colors), but not too shabby! Let's go with this.

5. The "Bitmap Pasting Other Options" dialog

Clicking "Other Options" will bring up the "Bitmap Pasting Other Options" dialog:

Most options in here are self-explanatory and can probably be left unchanged. (If you don't want LM to automatically paste the image into the background, unheck the third box from the top.)

Take a closer look at the first text box, though ("Insert starting at 8x8 tile #"). Lunar Magic needs free 8x8 tiles to place the ripped image in, and this tells it where to start looking for free tiles. By default it starts at tile 200, which is the BG2 slot.

Looking back at the previous dialog ("Convert and Paste Bitmap"), you can see that the ripped image needs 0x177 tiles, but LM only found 0x100 free tiles to use. (The original image had a whopping 0xB80, but that's because a lot of them were duplicates, which LM is smart enough to use the same tile for.) If you try and hit OK in that dialog, you'll get an error message saying not enough free tiles were found.
The reason why LM can't find more than 0x100 tiles is because it starts looking at 200, and thus overlooks the BG1 slot. Change that number to 100, and it'll take that slot into account. (If it still doesn't, make sure the BG1 slot is in fact empty [#lm{8x}].)

If you want, you can also change on which Map16 page the tiles are inserted by editing the third option ("Insert starting at 16x16 tile #"). By default it's 4200 (the top of page 42), which is fine in this case.

6. Finishing the insertion

Hit OK in both open dialogs, and if everything went right, you should see the kind of magic that LM's done:

It's automatically filled your ExGFX files, made Map16 tiles, and even inserted them into the background editor! Now that's comfortable. Imagine the hassle of doing that with an external tool (that is, coyping and importing half a dozen files).

Now all you need to do is save your work. Make sure to save not only the level and the Map16 data (#lm{save} in LM and the Map16 editor respectively), but also the ExGFX files! That's easily overlooked. To save the ExGFX, hit F9 in the 8x8 editor, click "Yes", then re-insert the ExGFX (#lm{insexgfx}).

In this particular case, you may also want to move the background image down a bit in the background editor (#lm{bg}).

Let's have a look at the in-game result:

Pretty good, isn't it? Worth the effort in my opinion — and it's less effort than any other way, too.

...and that's about it for this tutorial. I really hope this helps spread the word about Lunar Magic's Bitmap Pasting feature. #tb{:]} Do try it out for yourself! If you have additional information, found a mistake you want to point out, or want me to reword a part for the sake of clarity, please let me know.

How did you even find out how to unlock this?
Cool stuff btw. Seems like all your research paid off
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
Huh, the feature seems pretty complete to me, and it's really damn neat. I wonder when will FuSoYa make it officially available.


Originally posted by WhiteYoshiEgg
In the text box, enter Give me presents! (case sensitive), then click Cancel or hit Esc.

Not sure if it's just me, but I couldn't get it to work with the Cancel button. Hitting Esc works fine though.
Can this only rip backgrounds? Sorry, I haven't tried this out yet.
Thanks for the replies! #tb{:D}

Originally posted by JackTheSpades
How did you even find out how to unlock this?

Several cheats I knew about work the same way ("Amy is cute!", "The world is not enough!", and the like). I found the "Give me presents!" string in a hex editor, tried using it in the same way, and huzzah. How people originally found out about that, though, is beyond me.

Originally posted by Masterlink
Not sure if it's just me, but I couldn't get it to work with the Cancel button. Hitting Esc works fine though.

Seems like it. Thanks, I updated that part.

Originally posted by Cynook
Can this only rip backgrounds? Sorry, I haven't tried this out yet.

You can rip foregrounds no problem - just have LM put the tiles on a foreground Map16 page, prevent it from inserting the tiles in the background editor, and you're good to go. #tb{:)}

This is awesome, thanks for the tutorial!
Rest in peace, SnesGFX.
Originally posted by WhiteYoshiEgg
Several cheats I knew about work the same way ("Amy is cute!", "The world is not enough!", and the like).

Is there a full list of these cheats?
Kinda in hibernation for a while. I hope to be back in full swing soon.
(better late than never, right?)

Originally posted by Footsteps_of_Coins
Is there a full list of these cheats?

There's a list in the Documents section, but that's way outdated and possibly incomplete. Word of mouth, searching through the Data Repository forum and googling for "lunar magic easter eggs" might reveal a few more, and/or background info.

To answer your actual question, no, I don't think there is one. Someone should probably go and make one, or better yet, a wiki article.

With some things, LM is bad
Sorry, I had to. This is a really cool feature. I'm still not getting where you guys find these things out. Also, @SNESGFX:


get it? rip?!
I just discovered this tutorial today thanks to a post by Berkay. This will save so much time for me...!
Thank you for this thread, WYE!

Current project: working on a personal website and a portfolio.
Wow, this tutorial really helps with high-quality rips if you know what I mean.

Seriously this is going to help a LOT since I'm tired of using the same hills and clouds backgrounds in my levels.
What size is the BG you are using?#tb{:?}
Your layout has been removed.
Dimension-wise? I'm using the exact image I posted at the beginning, so 512×368.

Why this?

Niente da dire.
Did you reinsert GFX (#lm{insgfx}) immediately after extracting (#lm{extgfx}) for the first time? You need to do that in order to Lunar Magic to convert SMW's graphics from 3bpp to 4bpp, otherwise you'll garble all the graphics in the game (the program shows a message to warn you of that) and I think that is what is happening to you here.
Also, don't forget to save:

Originally posted by WhiteYoshiEgg
Make sure to save not only the level and the Map16 data (#lm{save} in LM and the Map16 editor respectively), but also the ExGFX files! That's easily overlooked. To save the ExGFX, hit F9 in the 8x8 editor, click "Yes", then re-insert the ExGFX (#lm{insexgfx}).

It just doesn't want to save. I saved game + map16 + exgx with the F9 thing, and it deletes everything when I go in another level and come back. So annoying, borderline infuriating.
Super Mario Pants World
Luigi's Lost Levels
New Super Mario Pants World
Luigi's Lost Levels 2 - Back With A Revenge
Luigi's Lost Levels 3 - Electrik Boogaloo
VLDC12 - 72HoKaizo#1
Have you reinserted the graphics after saving the ExGFX? (#lm{insexgfx})

Yea... Does the same to me. Reinserting the graphics doesn't seem to help anything, but I think the reason for this problem is that LM isn't actually updating the ExGFX files.
I'm looking for playtesters for Super Mario Starlight! Please check out this thread for info:

ExGFXRipping/DrawingLunar Magic