Minor changes

This commit is contained in:
Sergio Martin 2024-01-13 21:09:52 +01:00
parent 75a58247c0
commit 040d7f3939
3 changed files with 12 additions and 43 deletions

View File

@ -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 <cstdint>
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

View File

@ -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

View File

@ -6,7 +6,7 @@
#ifndef NES_CPU_H
#define NES_CPU_H
#include <stdint.h>
#include <cstdint>
#include "blargg_common.h"
typedef long nes_time_t; // clock cycle count