dbks Posted January 20, 2011 Share Posted January 20, 2011 Quick intro: I am new here and this is my first post. Awesome site. So a few days ago I started a quick 2600 project in bB. From googling I was eventually led here and I've enjoyed reading all these topics. I am a decently experienced programmer who has used a variety of languages and bB was easy to jump into. However, I am still murky about bankswitching. Basically, how does one utilize it efficiently? I understand the mechanics behind it so I realize that it's best to be organized and efficient, but how? Should I view the situation as each bank should be self contained, ie process only one 'mini' game where these 'mini' games are tied together to form the complete game? For example, let's say someone wanted to make a simple, retro rpg. Would world navigation subroutines be on one bank and inventory screen on another and, let's say, entering buildings and navigating the building on another, etc? That seems logical and it would cut down on the bankswitching. But what if each time thru the game loop, you averaged n bankswitches. For what n is too high? Do you ever intentionally duplicate subroutines on different banks just so you could avoid bankswitching? I am trying to plan things well to avoid bankswitching, but sometimes it is unavoidable it seems. I realize that I will have to test these things as I progress, but some words of advice will greatly aid my learning curve, if someone cares to enlighten me. Thanks. 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted January 20, 2011 Share Posted January 20, 2011 Don't know about efficient, but if you are working on a fairly large game, the code for your main loop won't fit in one bank. For example, I had everything in one bank at the beginning, then I had to move all of my sound effects into another bank. After that, I had to start putting chunks of code from my main loop into a third bank. Now I'm using 3 banks for my code, one bank for the title screen, and the last bank is left empty for bB to use. That's 5 banks and I'll probably have to include other banks as my game gets larger. 2 Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted January 20, 2011 Share Posted January 20, 2011 When I made Nitebear on Sleepystreet for Neotokeo2001 I tried to keep each game mode into separate banks. Also, keeping large but not time sensitive code in its own bank may be a good idea. 2 Quote Link to comment Share on other sites More sharing options...
RevEng Posted January 20, 2011 Share Posted January 20, 2011 (edited) Welcome! First, there's no hard and fast rule how to organize things. You'll probably start out one way, and then later you'll reorganize, and then reorganize again. That's natural, and a consequence of each game being different. If your game has a bunch of very different levels, then sticking each level's code in a bank of it's own is a good way to start. Not all games are like that. RT's advice is a good default way to go. I keep a similar structure: one bank for the kernel, one for the titlescreen, one that contains the main game loop, and one or more for routines the other banks can call. Yes, you should keep the bankswitches to a minimum. This can be accomplished by rolling a bunch of related routines together - instead of calling 3 different routines, call one and let it do the deciding in the other bank. This also helps with rom space, because bankswitching gosubs use a lot more rom than a regular gosub. Duplicate subroutines in each bank is a common enough strategy, though you should try to avoid it if you can, due to the wasted space. [edit - last thought. You can check if you're using too many cycles in Stella with Alt+L. If the scanline count moves over 262, you've used too many.] Edited January 20, 2011 by RevEng 3 Quote Link to comment Share on other sites More sharing options...
dbks Posted January 21, 2011 Author Share Posted January 21, 2011 Thank you all for the good advice and welcome. I already knew about the alt+L thing (as well as the other methods) mentioned on the bB info page, but it's good to keep this in mind as I progress on this project. So thank you all very much. I think I have some good direction now and hope to show it off soon. Best wishes. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.