Tired of not no one else putting up a tutorial on this, I decided to teach myself how to do it and write a tutorial on it. Note that this is a rushed job since I don't have a lot of time right now. If anyone has any problems or doesn't understand something please post here and I'll try to help. Also note that this covers the Stripe Image method instead of the .bin method. The advantage to the .bin method is that it saves a bit of space, but I haven't used it enough to know exactly how it works.
What you will need:
Creating a Tilemap
1. Open the game that has your layer 3 background and create a save state when that background comes into view.
2. Open up that save state with Racing Stripe.
3. Select BG3 from the list box (or any other 4-color background if your game isn't using mode 1). You should see the background you want to rip.
4. Go to Options -> Convert 16x16 tilemap to 8x8. If this option is not available then it means your tilemap is already 8x8 and you can skip this step. At this point you can make any modifications you want to the background. Go to Window -> Tile Selector to view all the possible tiles you can insert.
5. Go to File -> Save Tilemap/Stripe As and save it in the same directory as your ROM.
6. In the dialog that appears, select $A000 as the starting address.
Inserting your Stripe
7. Open up stim.asm
8. Define your freespace, etc.
9. Look at the table named LevelTable. Each bit represents one level, if the bit is set then the level uses a layer 3 background. Set the bits for the levels you're using.
10.Scroll down to the bottom of the file. Where it says "LayerImg1: incbin stim.stim" replace LayerImg1 with some sort of a one word descriptive name for your background and replace stim.stim with your actual background filename; the .stim file you saved earlier. You can add more, just follow same pattern of "name: incbin background.stim"
11.Look at the table named LayerPointerTable. Each entry represents the background used for one level. Replace LayerImg1 for the levels you want with the label you've given your background in the previous step.
Inserting the Graphics
12.Rip the layer 3 background's graphics. The best way to do this is to open up your save state with YY-CHR, and then to find the background's tileset. Once you've found it, paste it into a 2kb ExGFX file (it MUST be 2kb, not the normal 4kb! If you need a 2kb file, export SMW's default graphics in Lunar Magic, making sure to not use joined GFX files. Files 28, 29, 2A, and 2B are all 2kb; paste the new graphics over the old and save it as an ExGFX file.).
13.Insert your ExGFX with Lunar Magic. Be sure to take note of the number you inserted it as, you'll need it in a moment.
13.Open up Layer3ExGFX.asm
14.You'll see tables like the ones you've seen before, except now there are four of them per level. For whatever level you're using you'll have to replace the default graphics with your ExGFX file you created earlier. Which table to use, though, is pretty much trial and error.
15.Patch stim.asm and layer3ExGFX.asm to your ROM.
16.If you chose the correct table, you now have a layer 3 background! If not, then try a different one. Once you've gotten it correct, read on for optional details on making it look a bit nicer.
This will make your background scroll, as opposed to being fixed on the screen at all times. You'll need levelASM for this.
REP #$20 ;Make A 16 bits wide
LDA $1462 ;Load the layer 1 x position
LSR ;Divide by 2. The more times you use LSR the slower the background will scroll horizontally.
LSR ;If you use ASL (multiply by 2) instead the background will scroll faster than the foreground.
STA $22 ;Store to the layer 3 x position
LDA $1464 ;Load the layer 1 y position
LSR ;Same as above, but vertically.
SEC ;These two lines are for shifting your background vertically.
SBC #$0038 ;If you're using a background that loops you probably won't have to use this.
STA $24 ;Store to the layer 3 y position
SEP #$20 ;Make A 8 bits wide
Just paste that into levelASM (both level and init) and you're good to go!
If you want to place your background behind layer 2, place the following in Levelinitcode:
Alternatively, use level modes 2, 8, or 11.
You might have noticed that your background cuts off at the status bar line. To fix this, you'll have to use Edit's Sprite Status Bar
. Just take note of its limitations.
Credit to Ripperon-X for this code:
This will, according to him, allow windowing effects to work properly with layer three backgrounds. Just put that in levelINIT.asm
Incorrect Background Size
If you're having trouble getting your background to align or scroll correctly and your .STIM file is abnormally large (larger than 256x256), insert this code, courtesy of Ripperon-X and Edit:
post for more details.
Hopefully this helps somebody out there, if not, post here and I'll do my best to help!