I have taken the approach of having code in the same bank as the data the code needs to access. I’m not sure that is the best approach so I’m curious how other people structure their programs.
I do this as well. There is no need to complicate things when not needed. But, switching bank configurations is instantanious. Having code that adresses both memory blocks in the common memory area should be enough to manipulate all 128K.
I think it is quite complicated to manage memory. I choose which bank to place graphics in and then place all graphics related code in that bank. If there is a lot of other types of data I place that in the other bank, along with all code specific to manipulate that data. I use one shared area and keep it as small as possible for code that needs to bridge data and graphics in some ways, like sprite irq code or jump vectors. I have an interrupt junction in the stack because it will always there even if I turn off common RAM. It proved to be quite effective.
As soon as I move things between banks or write new systems that manipulate both banks I get a couple of mmu related crashes. It seems impossible to get it right the first time. At least for me it is quite difficult.
I curious to know how 64TASS doesn't do forward references and conditional compilation, it is N pass, I've done sheer voodoo with it.
Anyway. I think the Program in in Bank 0 and Variables are in Bank 1. I have 5 banking Macros, 13 if you include VIC banking.
Typically I use up BANK 0 until it is full, then I stash stuff into BANK 1. Unless I'm doing a C64 conversion. I load into BANK 0, then fast deflate into BANK 1, this means I don't have to worry about any overlap or other issues. The Fast method also lets me get around FF00 issues. Or I use BANK 0 for actual code, and build speed code, tables etc in BANK 1, as you can't load a single file that will enter both banks. So I try to keep what I need to load in Bank 0 and let it make the stuff I don't need to load into Bank 1. Any stuff that is deflated is easier to do to Bank 1 as well. Putting the VIC banks in the same location but in different 64K banks, makes code so much easier as they have the same locations, you just change which Bank the VIC sees and which Bank your code writes to, and all the other vectors stay the same.
Putting the VIC banks in the same location but in different 64K banks, makes code so much easier as they have the same locations, you just change which Bank the VIC sees and which Bank your code writes to, and all the other vectors stay the same.
Yes, that’s s a nice feature! I have been using single buffering for a while now. It works well for some projects without too much movement.
I use bank 0 for BASIC, mostly for loading programs. As to how I actually use it, when I SYS to my program in bank 1, it saves the current $FF00 before switching to almost all bank 1, then restores it when passing back to BASIC. Then BASIC does a Bank 15. This way it is very easy to use both the 40 and 80 columns at the same time with two monitors.