I think I see something...
Druzyek wrote:
If LDA and STA reference static 20-bit addresses, why not store the highest 4 bits in a second EEPROM? A whole section of code could be marked to work referring to a certain 64k page.
I think the idea here is that the code being run is in one ROM (byte-wide, of course) and there's another shadow ROM next to it. So, for each of the 3 bytes of a LDA or STA with an absolute address, there's another 8 bits of information available. Now, Jeff is right to point out that we have to understand what happens cycle by cycle. There are 3 cycles in which we read from the main ROM, and the second one, and then (soon) there's a cycle (or so) when the 6502 puts out the absolute address and reads or writes the data we're referencing.
We need to store some part of the extra information somehow and bring it into play exactly during the cycle(s) that the absolute address is in use. Jeff's concern is in keeping track of which cycles those are: in all other cycles we need to put zero out on the extra bank-select addresses, in order to keep running the code we want and with the zero page, stack and i/o devices that we have.
Here's the idea: use the 6502's SYNC signal to detect the opcode fetch. That's a single unambiguous cycle in which we can capture the extra 8 bits of address information. (We're assuming all along that the extra address info is static.) But we still have to figure out exactly when to use it...
OK, so we upgrade to a 65C02 or an '816 in emulation mode, and now we have the VPA and VDA outputs. We AND then to detect the instruction fetch, and store the extra info in our latch. Now we can use
(VDA and not VPA)
to detect data accesses - accesses which are not opcode or operands - and augment the address bus with the contents of the latch, instead of with zero.
All code will run from bank zero, and almost all of the auxiliary ROM will be zeros too, but where we want to access other banks we can do it by putting the bank number next to the opcode in question.
Is that something like what you had in mind, Druzyek?
Now we can bring into play the other ideas: supply ourselves with a second latch, which we write to as an I/O device, and use a fifth bit from the auxiliary ROM to choose between the original latch for static bank selection and the new latch for dynamic bank selection. (We're heading towards having a few latches and calling them segment selectors, perhaps...)
(It's still true that the '816 is cleaner, and indeed you can use static 24-bit addressing even in emulation mode, but that doesn't spoil the idea.)
Cheers
Ed