Language…
9 users online:  Anorakun, ASMagician Maks, Big Goomba, Buflen, igor9000_, Monhamd muaed1000, Plagrizr, playagmes169, Solivan1889 - Guests: 147 - Bots: 119
Users: 67,412 (2,049 active)
Latest user: Dhruvkoundal1994

How to put the Layer 3 behind the Layer 2 without weird side-effects (and some L3-Related questions) [Case Closed.]

After comming back from school, I was thinking in a way to unbland my BG... so I created a Layer 3 BG.
How it looks? Well, you can see in this screenshot:

"Oh boy, the clouds are in front of Layer 2... damn"

After some searchs, I found this thread. And I found this code:
Code
LDA #$17
STA $212C

"Yahoo! Clouds behind Layer 2! But wait... some sprites are hiding in Layer 2, but this can be fixed with IceMan's HDMA Pack... I think. And it lacks Horizontal and Vertical scrolling..."
I found this another code, in the same thread:
Code
REP #$20	;Make A 16 bits wide
LDA $1462 ;Load the layer 1 x position
LSR ;Divide by 2.
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.
LSR
SEC
SBC #$0038
STA $24	;Store to the layer 3 y position
SEP #$20 ;Make A 8 bits wide


And at the end, my Layer 3 GFX desappeared and showed a weird Status Bar copy... (No, I'm not using Sprite Status Bar.)
What is causing this problem?
(Also, if it matters, I'm using LevelASMTool; http://pastebin.com/u0AMGYUy)
This one is pretty simple. You don't need my HDMA bug fixes for that at all but a proper code for the main and sub screen designation.

Try this code to be executed on levelinit.asm

Code
	LDA #$11			;\ Layer 1 & Sprites
	STA $212C			;| are on main screen
	LDA #$06			;| Layer 2 & 3
	STA $212D			;| are on sub screen


And make sure the "Force layer 3 to be above all layers" is unchecked.
Note: if your going to do it iceman's way you may want to use this old patch I made to force the status bar in the main screen, otherwise it may show up under layer 1 and sprites. If you do use that patch, change $212C to $0D9D and $212D to $0D9E.
Your layout has been removed.
I never used that patch and the status bar is still on top of all layers because IRQ wasn't touched at all. But yeah, that works, too.
The Layer 3 showed behind the Layer 2... that's cool... but a odd thing happened:
That's quite normal if you have layer 3 scrolling vertically in any fashion. Make sure it stays at a set y position.
*nods*

Or hide the status bar with Ersan's IRQ patch by changing it to $FF for that level. That way you can have vertical scrolling layer 3 backgrounds, too. That is, if you don't need the status bar (graphics) for that level. The counters and item box should still be active though.
I'll give up. Unbland a BG with a HDMA is easier...
Thanks for the help, nevertheless.
Giving up?

What the heck?!

If you're trying to fix the Status Bar being shown, then just edit this part of your code:
Code
LDA $1464		;Load the layer 1 y position
LSR			;Same as above, but vertically.
LSR
SEC
SBC #$0038
STA $24		;Store to the layer 3 y position

Specifically, you'll want to change the value in the SBC #$0038
Changed that #$0038 to #$0B4A... AND IT WORKED!
Thank you Ladida, IceMan, KilloZapit and Kaijyuu.

Edit: when I inserted HDMA (and IceMan's HDMA Fix patch), the Layer 1 and Sprites still going in front of the status bar...

And yes, I've inserted Killo's patch. Maybe the Killo's patch have conflicted with IceMan's patch, because both patches hijack the NMI routine...?
Sorry about the double-post, but I need some help here. (See last post)
First of all, use the latest HDMA bug fixes available for download here.

It fixes a few more bugs, especially with power ups.

Also, my HDMA patch and Killo's IRQ patch use two different hijack spots, so there shouldn't be any complications, however, I can imagine that his patch somehow removes the status bar priority which it originally had. Try removing his patch for now and see, if it does make a difference.
I have installed your patch... it fixed the sprites' priority, but a thing haven't changed...

And this time, I didn't have installed the Killo's patch...
Have you patched Ersan's IRQ trigger patch or anything else that hijacks the status bar or IRQ routine around $8292 (IRQ) and $8DAC (status bar).

Also, mind posting the full code used for your layer 3 background?
Originally posted by IceMan
Have you patched Ersan's IRQ trigger patch or anything else that hijacks the status bar or IRQ routine around $8292 (IRQ) and $8DAC (status bar)?

No, I've patched just this patches:
Originally posted by Patches List.txt, from my hack folder.
> Classic Fireball - Alcaro ($148000)
> Disable Score Sprites - Smallhacker ($158000)
> Raccoon Leaf Powerup - Neosz ($168000)
> Classic Piranha Plant Fix - Fakescaper ($178000)
> Powerdown - Alcaro ($188000)
> SMB3-Styled Koopas - Matrizzle ($198000)
> SMB3 Bricks - BMF54123, KPhoenix and Ersanio ($1A8000)
> Smoke image patch - Sonikku ($1B8000)
> HDMA Fix - IceMan ($218000)

Originally posted by IceMan
Also, mind posting the full code used for your layer 3 background?

I don't. (it's a link)

Edit: Ice Man have sended a piece of code via PM, and it works well. Thanks a bunch, Ice Man!
For anyone who is interested as how we fixed it:

Code
LDA #$17	;\ Layer 1,2,3 & Sprites
STA $212C	;| are on main screen
LDA #$02	;| but put layer 2 on
STA $212D	;/ sub screen as well.
Originally posted by JowTH
I have installed your patch... it fixed the sprites' priority, but a thing haven't changed...

And this time, I didn't have installed the Killo's patch...


My patch is designed to fix that exact issue. Given though it's more for my private use and as a template to install additional irq functions then an actual public patch.

As a side note if anyone ever has the 'double status bar' problem, one thing I tried experimenting with is fiddling with $2109 to split the layer 3 tilemap up during the IRQ functions. Setting it to #$50 in PreStatusBar and #$59 in PostStatusBar will essentially make it so the layer 3 background and the status bar count as different tilemaps, making it impossible for layer three to scroll up that far.

Anyway...

Originally posted by Ice Man
For anyone who is interested as how we fixed it:

Code
LDA #$17	;\ Layer 1,2,3 & Sprites
STA $212C	;| are on main screen
LDA #$02	;| but put layer 2 on
STA $212D	;/ sub screen as well.


This probably works better, provided the priority issue is taken care of (which I assume it is). The issue with this is, as I assume you know, you cannot put sprites between layer 1 and 2 if the tiles have the same priority. There are still cases I think where this will be a slight problem though. BTW, Is this designed with transparency in mind? I wonder why layer 2 is on both the sub and main screen...
Your layout has been removed.
Actually no, this is not designed to be transparency. The main reason layer 2 is on both screens is priority related. Would it only be on the sub screen then we'd have the old problem again. Oddly enough, leaving the sub screen empty wouldn't work either with layer 3, if I remember correctly.
Yeah I mean I can't think of a reason why it wouldn't work with the subscreen empty. Not that it makes a difference, I just wonder why it wouldn't, unless the subscreen needs to have one layer on it for the bg color to work or something, but I doubt that.

There are some fun tricks you can do by putting layers on both screens though. Like putting sprites on both screens and all the layers on the main screen with transparency enabled. Then lowest priority sprites will always be transparent regardless of color (since they would be covered up on the main screen but not on the subscreen)
Your layout has been removed.