📄 k6502.cpp
字号:
static void instruct_85(void)
{
STA( AA_ZP ); CLK( 3 );
}
static void instruct_86(void)
{
STX( AA_ZP ); CLK( 3 );
}
static void instruct_88(void)
{
--Y; TEST( Y ); CLK( 2 );
}
static void instruct_8a(void)
{
A = X; TEST( A ); CLK( 2 );
}
static void instruct_8c(void)
{
STY( AA_ABS ); CLK( 4 );
}
static void instruct_8d(void)
{
STA( AA_ABS ); CLK( 4 );
}
static void instruct_8e(void)
{
STX( AA_ABS ); CLK( 4 );
}
static void instruct_90(void)
{
BRA( !( F & FLAG_C ) );
}
static void instruct_91(void)
{
STA( AA_IY ); CLK( 6 );
}
static void instruct_94(void)
{
STY( AA_ZPX ); CLK( 4 );
}
static void instruct_95(void)
{
STA( AA_ZPX ); CLK( 4 );
}
static void instruct_96(void)
{
STX( AA_ZPY ); CLK( 4 );
}
static void instruct_98(void)
{
A = Y; TEST( A ); CLK( 2 );
}
static void instruct_99(void)
{
STA( AA_ABSY ); CLK( 5 );
}
static void instruct_9a(void)
{
SP = X; CLK( 2 );
}
static void instruct_9d(void)
{
STA( AA_ABSX ); CLK( 5 );
}
static void instruct_a0(void)
{
LDY( A_IMM ); CLK( 2 );
}
static void instruct_a1(void)
{
LDA( A_IX ); CLK( 6 );
}
static void instruct_a2(void)
{
LDX( A_IMM ); CLK( 2 );
}
static void instruct_a4(void)
{
LDY( A_ZP ); CLK( 3 );
}
static void instruct_a5(void)
{
LDA( A_ZP ); CLK( 3 );
}
static void instruct_a6(void)
{
LDX( A_ZP ); CLK( 3 );
}
static void instruct_a8(void)
{
Y = A; TEST( A ); CLK( 2 );
}
static void instruct_a9(void)
{
LDA( A_IMM ); CLK( 2 );
}
static void instruct_aa(void)
{
X = A; TEST( A ); CLK( 2 );
}
static void instruct_ac(void)
{
LDY( A_ABS ); CLK( 4 );
}
static void instruct_ad(void)
{
LDA( A_ABS ); CLK( 4 );
}
static void instruct_ae(void)
{
LDX( A_ABS ); CLK( 4 );
}
static void instruct_b0(void)
{
BRA( F & FLAG_C );
}
static void instruct_b1(void)
{
LDA( A_IY ); CLK( 5 );
}
static void instruct_b4(void)
{
LDY( A_ZPX ); CLK( 4 );
}
static void instruct_b5(void)
{
LDA( A_ZPX ); CLK( 4 );
}
static void instruct_b6(void)
{
LDX( A_ZPY ); CLK( 4 );
}
static void instruct_b8(void)
{
RSTF( FLAG_V ); CLK( 2 );
}
static void instruct_b9(void)
{
LDA( A_ABSY ); CLK( 4 );
}
static void instruct_ba(void)
{
X = SP; TEST( X ); CLK( 2 );
}
static void instruct_bc(void)
{
LDY( A_ABSX ); CLK( 4 );
}
static void instruct_bd(void)
{
LDA( A_ABSX ); CLK( 4 );
}
static void instruct_be(void)
{
LDX( A_ABSY ); CLK( 4 );
}
static void instruct_c0(void)
{
CPY( A_IMM ); CLK( 2 );
}
static void instruct_c1(void)
{
CMP( A_IX ); CLK( 6 );
}
static void instruct_c4(void)
{
CPY( A_ZP ); CLK( 3 );
}
static void instruct_c5(void)
{
CMP( A_ZP ); CLK( 3 );
}
static void instruct_c6(void)
{
DEC( AA_ZP ); CLK( 5 );
}
static void instruct_c8(void)
{
++Y; TEST( Y ); CLK( 2 );
}
static void instruct_c9(void)
{
CMP( A_IMM ); CLK( 2 );
}
static void instruct_ca(void)
{
--X; TEST( X ); CLK( 2 );
}
static void instruct_cc(void)
{
CPY( A_ABS ); CLK( 4 );
}
static void instruct_cd(void)
{
CMP( A_ABS ); CLK( 4 );
}
static void instruct_ce(void)
{
DEC( AA_ABS ); CLK( 6 );
}
static void instruct_d0(void)
{
BRA( !( F & FLAG_Z ) );
}
static void instruct_d1(void)
{
CMP( A_IY ); CLK( 5 );
}
static void instruct_d5(void)
{
CMP( A_ZPX ); CLK( 4 );
}
static void instruct_d6(void)
{
DEC( AA_ZPX ); CLK( 6 );
}
static void instruct_d8(void)
{
RSTF( FLAG_D ); CLK( 2 );
}
static void instruct_d9(void)
{
CMP( A_ABSY ); CLK( 4 );
}
static void instruct_dd(void)
{
CMP( A_ABSX ); CLK( 4 );
}
static void instruct_de(void)
{
DEC( AA_ABSX ); CLK( 7 );
}
static void instruct_e0(void)
{
CPX( A_IMM ); CLK( 2 );
}
static void instruct_e1(void)
{
SBC( A_IX ); CLK( 6 );
}
static void instruct_e4(void)
{
CPX( A_ZP ); CLK( 3 );
}
static void instruct_e5(void)
{
SBC( A_ZP ); CLK( 3 );
}
static void instruct_e6(void)
{
INC( AA_ZP ); CLK( 5 );
}
static void instruct_e8(void)
{
++X; TEST( X ); CLK( 2 );
}
static void instruct_e9(void)
{
SBC( A_IMM ); CLK( 2 );
}
static void instruct_ea(void)
{
CLK( 2 );
}
static void instruct_ec(void)
{
CPX( A_ABS ); CLK( 4 );
}
static void instruct_ed(void)
{
SBC( A_ABS ); CLK( 4 );
}
static void instruct_ee(void)
{
INC( AA_ABS ); CLK( 6 );
}
static void instruct_f0(void)
{
BRA( F & FLAG_Z );
}
static void instruct_f1(void)
{
SBC( A_IY ); CLK( 5 );
}
static void instruct_f5(void)
{
SBC( A_ZPX ); CLK( 4 );
}
static void instruct_f6(void)
{
INC( AA_ZPX ); CLK( 6 );
}
static void instruct_f8(void)
{
SETF( FLAG_D ); CLK( 2 );
}
static void instruct_f9(void)
{
SBC( A_ABSY ); CLK( 4 );
}
static void instruct_fd(void)
{
SBC( A_ABSX ); CLK( 4 );
}
static void instruct_fe(void)
{
INC( AA_ABSX ); CLK( 7 );
}
static void instruct_NULL(void)
{
CLK( 2 );
}
typedef void (*pInstruct)();
pInstruct instruct[] =
{
instruct_00,
instruct_01,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_05,
instruct_06,
instruct_NULL,
instruct_08,
instruct_09,
instruct_0a,
instruct_NULL,
instruct_NULL,
instruct_0d,
instruct_0e,
instruct_NULL,
instruct_10,
instruct_11,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_15,
instruct_16,
instruct_NULL,
instruct_18,
instruct_19,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_1d,
instruct_1e,
instruct_NULL,
instruct_20,
instruct_21,
instruct_NULL,
instruct_NULL,
instruct_24,
instruct_25,
instruct_26,
instruct_NULL,
instruct_28,
instruct_29,
instruct_2a,
instruct_NULL,
instruct_2c,
instruct_2d,
instruct_2e,
instruct_NULL,
instruct_30,
instruct_31,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_35,
instruct_36,
instruct_NULL,
instruct_38,
instruct_39,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_3d,
instruct_3e,
instruct_NULL,
instruct_40,
instruct_41,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_45,
instruct_46,
instruct_NULL,
instruct_48,
instruct_49,
instruct_4a,
instruct_NULL,
instruct_4c,
instruct_4d,
instruct_4e,
instruct_NULL,
instruct_50,
instruct_51,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_55,
instruct_56,
instruct_NULL,
instruct_58,
instruct_59,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_5d,
instruct_5e,
instruct_NULL,
instruct_60,
instruct_61,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_65,
instruct_66,
instruct_NULL,
instruct_68,
instruct_69,
instruct_6a,
instruct_NULL,
instruct_6c,
instruct_6d,
instruct_6e,
instruct_NULL,
instruct_70,
instruct_71,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_75,
instruct_76,
instruct_NULL,
instruct_78,
instruct_79,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_7d,
instruct_7e,
instruct_NULL,
instruct_NULL,
instruct_81,
instruct_NULL,
instruct_NULL,
instruct_84,
instruct_85,
instruct_86,
instruct_NULL,
instruct_88,
instruct_NULL,
instruct_8a,
instruct_NULL,
instruct_8c,
instruct_8d,
instruct_8e,
instruct_NULL,
instruct_90,
instruct_91,
instruct_NULL,
instruct_NULL,
instruct_94,
instruct_95,
instruct_96,
instruct_NULL,
instruct_98,
instruct_99,
instruct_9a,
instruct_NULL,
instruct_NULL,
instruct_9d,
instruct_NULL,
instruct_NULL,
instruct_a0,
instruct_a1,
instruct_a2,
instruct_NULL,
instruct_a4,
instruct_a5,
instruct_a6,
instruct_NULL,
instruct_a8,
instruct_a9,
instruct_aa,
instruct_NULL,
instruct_ac,
instruct_ad,
instruct_ae,
instruct_NULL,
instruct_b0,
instruct_b1,
instruct_NULL,
instruct_NULL,
instruct_b4,
instruct_b5,
instruct_b6,
instruct_NULL,
instruct_b8,
instruct_b9,
instruct_ba,
instruct_NULL,
instruct_bc,
instruct_bd,
instruct_be,
instruct_NULL,
instruct_c0,
instruct_c1,
instruct_NULL,
instruct_NULL,
instruct_c4,
instruct_c5,
instruct_c6,
instruct_NULL,
instruct_c8,
instruct_c9,
instruct_ca,
instruct_NULL,
instruct_cc,
instruct_cd,
instruct_ce,
instruct_NULL,
instruct_d0,
instruct_d1,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_d5,
instruct_d6,
instruct_NULL,
instruct_d8,
instruct_d9,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_dd,
instruct_de,
instruct_NULL,
instruct_e0,
instruct_e1,
instruct_NULL,
instruct_NULL,
instruct_e4,
instruct_e5,
instruct_e6,
instruct_NULL,
instruct_e8,
instruct_e9,
instruct_ea,
instruct_NULL,
instruct_ec,
instruct_ed,
instruct_ee,
instruct_NULL,
instruct_f0,
instruct_f1,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_f5,
instruct_f6,
instruct_NULL,
instruct_f8,
instruct_f9,
instruct_NULL,
instruct_NULL,
instruct_NULL,
instruct_fd,
instruct_fe,
instruct_NULL,
};/*===================================================================*//* *//* K6502_Step() : *//* Only the specified number of the clocks execute Op. *//* *//*===================================================================*/void K6502_Step( WORD wClocks ){/** Only the specified number of the clocks execute Op.** Parameters* WORD wClocks (Read)* The number of the clocks */ /* Dispose of it if there is an interrupt requirement */ if ( NMI_State != NMI_Wiring ) { /* NMI Interrupt */ CLK( 7 ); PUSHW( PC ); PUSH( F & ~FLAG_B ); RSTF( FLAG_D ); PC = K6502_ReadW_Code( VECTOR_NMI ); } else if ( IRQ_State != IRQ_Wiring ) { /* IRQ Interrupt */ /* Execute IRQ if an I flag isn't being set */ if ( !( F & FLAG_I ) ) { CLK( 7 ); PUSHW( PC ); PUSH( F & ~FLAG_B ); RSTF( FLAG_D ); SETF( FLAG_I ); PC = K6502_ReadW_Code( VECTOR_IRQ ); } } NMI_State = NMI_Wiring; IRQ_State = IRQ_Wiring; /* It has a loop until a constant clock passes */ while ( g_wPassedClocks < wClocks ) { /* Read an instruction */ byCode = K6502_Read_Code( PC++ ); /* Execute an instruction. */
instruct[byCode](); } /* end of while ... */ /* Correct the number of the clocks */ g_wPassedClocks -= wClocks;}/* Addressing Op. *//* Data *//* Absolute,X */static BYTE K6502_ReadAbsX(){ WORD wA0, wA1; wA0 = AA_ABS; wA1 = wA0 + X; CLK( ( wA0 & 0x0100 ) != ( wA1 & 0x0100 ) ); return K6502_Read( wA1 ); };
/* Absolute,Y */static BYTE K6502_ReadAbsY(){ WORD wA0, wA1; wA0 = AA_ABS; wA1 = wA0 + Y; CLK( ( wA0 & 0x0100 ) != ( wA1 & 0x0100 ) ); return K6502_Read( wA1 ); };/* (Indirect),Y */static BYTE K6502_ReadIY(){ WORD wA0, wA1; wA0 = K6502_ReadZpW( K6502_Read_Code( PC++ ) ); wA1 = wA0 + Y; CLK( ( wA0 & 0x0100 ) != ( wA1 & 0x0100 ) ); return K6502_Read( wA1 ); };/*===================================================================*//* *//* 6502 Reading/Writing Operation *//* *//*===================================================================*/
#include "K6502_rw.h"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -