I am working on a small project with 5 levels. 3 of them require bidirectional horizontal scrolling and 1 require bidirectional vertical scroll.
I think scrolling depends on "mirroring" of the cart and that remains same throughout the execution of an nes program(please correct me if I am not). If this is true what is an easy way to implement both types of scrolling in my program?
All mirroring types can be used for all types of scrolling, but in some cases it's possible to see some glitches close to the edges of the screen.
You see, when scrolling you ideally want to use a hidden area as a buffer, a place to overwrite the old tiles (the ones that get out of the view) with the new ones (the ones that enter the screen). However, the NES has only two screen-sized name tables, so depending on how you arrange them (vertically or horizontally), one of the axis will have one whole screen to be used as this buffer while the other axis doesn't have any hidden parts at all, so the tile overlapping must happen on screen.
If you use a mapper that allows you to select the type of mirroring, it's possible to get 100% glitch-free scrolling as long as you scroll in only one axis at a time.
If you mirroring is hardwired, the consensus seems to be that glitches at the top and bottom of the screen are less noticeable because most TV end up hiding a lot of scanlines in those areas, so it's probably better to go with vertical mirroring (horizontal layout).
Of course there is 4-screen mirroring (i.e. no mirroring) too, where extra RAM on the cart allows for 4 name tables, so there are plenty of hidden areas for perfect scrolling. Carts with 4-screen mirroring are not very common though, so if you decide to make actual carts you'll probably have to modify existing carts quite a bit.