@ -97,7 +97,7 @@ static inline void debug_print_instruction(CPU* __restrict__ cpu, byte opcode){
opcode ,
opcode ,
cpu - > PC ,
cpu - > PC ,
cpu - > opcodes [ opcode ] . bytes ,
cpu - > opcodes [ opcode ] . bytes ,
& cpu - > opcodes [ opcode ] . microcode
cpu - > opcodes [ opcode ] . microcode
) ;
) ;
}
}
@ -107,9 +107,6 @@ void activateCpuNmi(){
}
}
# define PROG_START_ADDR 0xC000
int main ( int argc , char * argv [ ] ) {
int main ( int argc , char * argv [ ] ) {
# ifdef DEBUG
# ifdef DEBUG
@ -132,7 +129,6 @@ int main(int argc, char * argv[]){
# endif
# endif
initCpu ( cpu ) ; //put new CPU in starting mode and dock it to the bus
initCpu ( cpu ) ; //put new CPU in starting mode and dock it to the bus
cpu - > PC = PROG_START_ADDR ;
if ( argc < = 1 ) { //Check to see if a rom was given
if ( argc < = 1 ) { //Check to see if a rom was given
fprintf ( stderr , " ERR: No Rom file Specified in Arguments \n " ) ;
fprintf ( stderr , " ERR: No Rom file Specified in Arguments \n " ) ;
@ -141,6 +137,7 @@ 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
initBanks ( argv [ 1 ] ) ;
initBanks ( argv [ 1 ] ) ;
cpu - > PC = rom_start_address ;
# 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
@ -171,14 +168,12 @@ int main(int argc, char * argv[]){
# endif
# endif
for ( long iterations = 0 ; iterations ! = 9000 ; iterations + + ) {
while ( true ) {
# ifdef DEBUG
# ifdef DEBUG
fprintf ( PClogFILE , " %4X \n " , cpu - > PC ) ;
fprintf ( PClogFILE , " %4X \n " , cpu - > PC ) ;
debug_print_instruction ( cpu , busRead8 ( cpu - > PC ) ) ;
debug_print_instruction ( cpu , busRead8 ( cpu - > PC ) ) ;
printRegisters ( cpu ) ;
printRegisters ( cpu ) ;
printCpu ( cpu ) ;
printCpu ( cpu ) ;
printf ( " \n \n ---- \n %i \n ----- " , iterations ) ;
# endif
# endif
if ( activateCpuNmiBool ) {
if ( activateCpuNmiBool ) {
@ -187,6 +182,9 @@ int main(int argc, char * argv[]){
}
}
//RUN THE CPU CLOCK ONE TIME
//RUN THE CPU CLOCK ONE TIME
cpuClock ( cpu ) ;
cpuClock ( cpu ) ;
# ifdef DEBUG
getchar ( ) ;
# endif
}
}
# ifdef DEBUG
# ifdef DEBUG