Let's make our game more official and give it a title screen! First, copy the tileset and tilemap found here and paste it at the end of your code. This will make a title screen that looks like so:
Then copy and paste the following after waiting for VBlank:
{{#include ../../unbricked/title-screen/main.asm:title_screen}}
Note that we are using our MemCopy function from the Functions lesson! Isn't it handy to have reusable code? We are also using our UpdateKeys function from the Input lesson to determine when to stop displaying the title screen and move on to the game itself. To do so, we loop until the start button has been pressed.
And just like that we have ourselves a title screen!
Our project is getting quite large with all the functionality we're building in! Let's briefly go over how to better organize things. Until now, we have always added new code into the same assembly file (main.asm). This file can get pretty large if we're not careful, making it harder to read and maintain. Instead, RGBDS has a handy feature for making functions or other labels visible to external files. This will help our codebase be nice and clean, making it more manageable (in the case where one might collaborate with others, this is essential!). As an example, let's take everything we added in our input lesson, and put it in a separate file named input.asm.
Notice the use of the double colon (::) after the function and variable names. This is how we can export a label to other files, also known as broadening its scope. Now that we have all of the input-related code in a separate file, and everything else in main, all that is left is to build the ROM. Now that we have multiple files, we have to assemble each assembly file, then link them together in one ROM, like so:
{{#include ../../unbricked/title-screen/build.sh:multibuild}}Try doing the same with other assembly files to keep your code nice and tidy. Break up separate functionality into other files, don't forget to assemble them separately, then link them all together!
