diff --git a/source/core/Nes_Apu.h b/source/core/Nes_Apu.h index 60c1983..da9ee5a 100644 --- a/source/core/Nes_Apu.h +++ b/source/core/Nes_Apu.h @@ -1,10 +1,10 @@ +#pragma once // NES 2A03 APU sound chip emulator // Nes_Snd_Emu 0.1.7 -#ifndef NES_APU_H -#define NES_APU_H +#include typedef long nes_time_t; // CPU clock cycle count typedef unsigned nes_addr_t; // 16-bit memory address @@ -172,4 +172,3 @@ inline nes_time_t Nes_Dmc::next_read_time() const inline nes_time_t Nes_Apu::next_dmc_read_time() const { return dmc.next_read_time(); } -#endif diff --git a/source/core/Nes_Cpu.cpp b/source/core/Nes_Cpu.cpp index 4814fe7..4aa920f 100644 --- a/source/core/Nes_Cpu.cpp +++ b/source/core/Nes_Cpu.cpp @@ -255,18 +255,19 @@ Nes_Cpu::result_t Nes_Cpu::run( nes_time_t end ) SET_STATUS( temp ); } + uint32_t data; + uint8_t const* page; + uint8_t opcode; + loop: - uint8_t const* page = code_map [pc >> page_bits]; - uint8_t opcode = page [pc]; - pc++; - - if ( clock_count >= clock_limit ) - goto stop; + page = code_map [pc >> page_bits]; + opcode = page [pc++]; + data = page [pc]; + + if ( clock_count >= clock_limit ) [[unlikely]] goto stop; clock_count += clock_table [opcode]; - unsigned data; - data = page [pc]; switch ( opcode ) { @@ -367,35 +368,6 @@ loop: nz = data; goto loop; -#if 0 - case 0xA1: // LDA (ind,X) - IND_X - goto lda_ptr; - - case 0xB1: // LDA (ind),Y - IND_Y(true,true) - goto lda_ptr; - - case 0xB9: // LDA abs,Y - data += y; - goto lda_ind_common; - - case 0xBD: // LDA abs,X - data += x; - lda_ind_common: { - HANDLE_PAGE_CROSSING( data ); - int temp = data; - ADD_PAGE - if ( temp & 0x100 ) - READ( data - 0x100 ); - } - lda_ptr: - a = nz = READ( data ); - pc++; - goto loop; -#else - // optimization of most commonly used memory read instructions - case 0xB9:// LDA abs,Y data += y; data -= x; @@ -440,8 +412,6 @@ loop: pc++; goto loop; -#endif - // Branch case 0x50: // BVC diff --git a/source/core/Nes_Cpu.h b/source/core/Nes_Cpu.h index 96b2660..14e5389 100644 --- a/source/core/Nes_Cpu.h +++ b/source/core/Nes_Cpu.h @@ -6,7 +6,7 @@ #ifndef NES_CPU_H #define NES_CPU_H -#include +#include #include "blargg_common.h" typedef long nes_time_t; // clock cycle count