The first things you have to do when you start your CPU is:
1. Map the PRG banks to
$8000 and
$C000.
In your mapper code you might do something like this:
Code:
void init_mapper()
{
if(prg_bank_count == 1) { set prg 0 bank to both $8000 - $BFFF AND $C000 - $FFFF }
else { set prg 0 bank to $8000 - $BFFF; set prg 1 bank to $C000 - $FFFF; }
}
Essentially you'll have some kind of pointer (or whatever) to the PRG banks which indicates which banks are mapped to which memory area, i.e. in this case having 1 or 2 x 16KB banks mapped to a certain CPU memory space. "Mapping" means that you let your CPU point to the correct bank.
2. Read the first address from
$FFFC and
$FFFD and set your CPU's PC to that value:
Code:
PC = mem_read(0xFFFC) | (mem_read(0xFFFD) << 8);
And that is where your program will start executing the first opcode.
I don't know how I can explain the principle better, but then again I often suck at teaching so meh. You should go check out the first few
6502 assembly tutorials on this page which might help you understand better how 6502 banks and vectors work.