- Speed optimizations

- Carry Flag bugfix
This commit is contained in:
Tamas Rudnai 2019-09-12 00:30:22 -07:00
parent 08327ef0a4
commit f2e5b49a6e
5 changed files with 13 additions and 9 deletions

View File

@ -56,7 +56,7 @@ static inline void set_flags_Z( const uint8_t test ) {
dbgPrintf("%c", m6502.flags.Z ? 'Z' : 'z');
}
static inline void set_flags_C( const int test ) {
static inline void set_flags_C( const int16_t test ) {
m6502.flags.C = test >= 0;
dbgPrintf("%c", m6502.flags.C ? 'C' : 'c');
}
@ -76,7 +76,7 @@ static inline void set_flags_NVZ( const uint8_t test ) {
set_flags_V(test);
}
static inline void set_flags_NZC( const int test ) {
static inline void set_flags_NZC( const int16_t test ) {
set_flags_NZ(test);
set_flags_C(test);
}

View File

@ -31,7 +31,11 @@
**/
static inline void ADC( uint8_t imm ) {
dbgPrintf("ADC(%02X) A:%02X + %02X ", imm, m6502.A, imm);
set_flags_NZCV( m6502.A += imm + m6502.flags.C );
int16_t tmp;
set_flags_NVZ( m6502.A = tmp = (int16_t)m6502.A + imm + m6502.flags.C );
m6502.flags.C = tmp > 0xFF;
dbgPrintf("-> A:%02X ", m6502.A);
}

View File

@ -49,7 +49,7 @@ static inline void BIT( uint8_t imm ) {
**/
static inline void CMP( uint8_t imm ) {
dbgPrintf("CMP(%02X) ", imm);
set_flags_NZC( (int)m6502.A - imm );
set_flags_NZC( (int16_t)m6502.A - imm );
}
/**
@ -66,7 +66,7 @@ static inline void CMP( uint8_t imm ) {
**/
static inline void CPX( uint8_t imm ) {
dbgPrintf("CPX(%02X) ", imm);
set_flags_NZC( (int)m6502.X - imm );
set_flags_NZC( (int16_t)m6502.X - imm );
}
/**
@ -83,7 +83,7 @@ static inline void CPX( uint8_t imm ) {
**/
static inline void CPY( uint8_t imm ) {
dbgPrintf("CPY(%02X) ", imm);
set_flags_NZC( (int)m6502.Y - imm );
set_flags_NZC( (int16_t)m6502.Y - imm );
}
#endif // __6502_INSTR_COMPARE_TEST_H__