@ -37,7 +37,11 @@ word mapper_resolve_write(word address, byte data){ //info about what regions ar
voidbus_write8(wordaddress,worddata){
voidbus_write8(wordaddress,worddata){
if(!mapper000_write(address,data,false)){//first thing we do is we hand the operation to the mapper to resolve any cartridge-side bank switching and mirroring, if the address we wanna write to isnt on the cartridge, we return false and we write to the bus normally
if(!mapper000_write(address,data,false)){//first thing we do is we hand the operation to the mapper to resolve any cartridge-side bank switching and mirroring, if the address we wanna write to isnt on the cartridge, we return false and we write to the bus normally
address=mapper_resolve_write(address,data);//a lot of regions on the NES bus are mirrored/synced, this just ensures we are always writing to the parent region, not to a empty cloned one
address=mapper_resolve_write(address,data);//a lot of regions on the NES bus are mirrored/synced, this just ensures we are always writing to the parent region, not to a empty cloned one
#ifdef DEBUG
printf("\nwrite-ram 0x%04X at 0x%04X\n; old_val 0x%04X",data,address,bus_read8(address));
printf("\nwrite-ram 0x%04X at 0x%04X\n; old_val 0x%04X",data,address,bus_read8(address));
#endif
bus[address]=(unsignedchar)data;
bus[address]=(unsignedchar)data;
}
}
}
}
@ -106,6 +110,7 @@ int main(int argc, char * argv[]){
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
#endif
#endif
init_cpu(cpu);//put new CPU in starting mode and dock it to the bus
init_cpu(cpu);//put new CPU in starting mode and dock it to the bus
cpu->PC=PROG_START_ADDR;
cpu->PC=PROG_START_ADDR;
@ -116,28 +121,33 @@ int main(int argc, char * argv[]){
//load the CHR and PRG banks from the .nes file (argv[1]), also loads the header for mapper construction
//load the CHR and PRG banks from the .nes file (argv[1]), also loads the header for mapper construction
init_banks(argv[1]);
init_banks(argv[1]);
debug=true;
#ifdef DEBUG
#ifdef DEBUG
//Test to see if writing to the bus is working correctly
//Test to see if writing to the bus is working correctly