# 13. Scrolling up

This was much harder than scrolling right. If I had chosen to scroll downward, it might have been easier, because scrolling up is like going backwards in the code.

Skipping over the y values of 0xf0-ff wasn’t that bad as long as you use my functions add\_scroll\_y() and sub\_scroll\_y() that handles this for you. But, I also had to add them to the BG collision code, since you can be half in one nametable and half in another. And, the code assumes that Y position is between 0 and $ef.

Since scrolling up is going backwards, I’m starting at the maximum scroll position, and going backwards to 0.

I had to build the array of room arrays backwards too.

const unsigned char \* const Rooms\[]= {\
Room5, Room4, Room3, Room2, Room1\
};

Anyway, I made 5 more rooms, in Tiled, and exported 5 more csv files, converted to C arrays, and imported those into the code.

![16\_Tiled](https://nesdoug.files.wordpress.com/2018/09/16_tiled.png?w=924)

And after a few days of debugging (yikes) it finally works. I have to give some due respect to the guys who made games like Kid Icarus, or Metroid, or Ice Climber, because scrolling upward is not easy.

![16\_scroll\_up](https://nesdoug.files.wordpress.com/2018/09/16_scroll_up.png?w=924)

[https://github.com/nesdoug/16\_Scroll\_Up/blob/master/scroll\_up.c](https://github.com/nesdoug/16_Scroll_Up/blob/master/scroll_up.c)

[https://github.com/nesdoug/16\_Scroll\_Up](https://github.com/nesdoug/16_Scroll_Up)
