1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-10 12:29:01 +00:00

Made DAA work sufficiently well for the FUSE test.

This commit is contained in:
Thomas Harte 2017-05-25 22:41:05 -04:00
parent ea0ad9fd87
commit 83ee92af1a

View File

@ -550,6 +550,13 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
const MicroOp *operation = &scheduled_programs_[schedule_programs_read_pointer_][schedule_program_program_counter_]; const MicroOp *operation = &scheduled_programs_[schedule_programs_read_pointer_][schedule_program_program_counter_];
schedule_program_program_counter_++; schedule_program_program_counter_++;
#define set_parity(v) \
parity_overflow_flag_ = v^1;\
parity_overflow_flag_ ^= parity_overflow_flag_ >> 4;\
parity_overflow_flag_ ^= parity_overflow_flag_ << 2;\
parity_overflow_flag_ ^= parity_overflow_flag_ >> 1;\
parity_overflow_flag_ &= Flag::Parity;
switch(operation->type) { switch(operation->type) {
case MicroOp::BusOperation: case MicroOp::BusOperation:
if(number_of_cycles_ < operation->machine_cycle.length) { schedule_program_program_counter_--; return; } if(number_of_cycles_ < operation->machine_cycle.length) { schedule_program_program_counter_--; return; }
@ -583,13 +590,6 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
#pragma mark - Logical #pragma mark - Logical
#define set_parity(v) \
parity_overflow_flag_ = v^1;\
parity_overflow_flag_ ^= parity_overflow_flag_ >> 4;\
parity_overflow_flag_ ^= parity_overflow_flag_ << 2;\
parity_overflow_flag_ ^= parity_overflow_flag_ >> 1;\
parity_overflow_flag_ &= Flag::Parity;
case MicroOp::And: case MicroOp::And:
a_ &= *(uint8_t *)operation->source; a_ &= *(uint8_t *)operation->source;
sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_; sign_result_ = zero_result_ = bit5_result_ = bit3_result_ = a_;
@ -611,8 +611,6 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
set_parity(a_); set_parity(a_);
break; break;
#undef set_parity
#pragma mark - Relative jumps #pragma mark - Relative jumps
case MicroOp::DJNZ: case MicroOp::DJNZ:
@ -769,18 +767,17 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
{ {
if(half_carry_flag_) if(half_carry_flag_)
{ {
amountToAdd = (highNibble > 0x9) ? 0x66 : 0x06; if(lowNibble > 0x9)
amountToAdd = (highNibble > 0x8) ? 0x66 : 0x06;
else
amountToAdd = (highNibble > 0x9) ? 0x66 : 0x06;
} }
else else
{ {
if(lowNibble > 0x9) if(lowNibble > 0x9)
{
amountToAdd = (highNibble > 0x8) ? 0x66 : 0x06; amountToAdd = (highNibble > 0x8) ? 0x66 : 0x06;
}
else else
{
amountToAdd = (highNibble > 0x9) ? 0x60 : 0x00; amountToAdd = (highNibble > 0x9) ? 0x60 : 0x00;
}
} }
} }
@ -799,7 +796,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
if(subtract_flag_) if(subtract_flag_)
{ {
a_ -= amountToAdd; a_ -= amountToAdd;
if(half_carry_flag_ && lowNibble < 0x6) half_carry_flag_ = 0; half_carry_flag_ = (half_carry_flag_ && lowNibble < 0x6) ? Flag::HalfCarry : 0;
} }
else else
{ {
@ -808,14 +805,9 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
} }
sign_result_ = zero_result_ = bit3_result_ = bit5_result_ = a_; sign_result_ = zero_result_ = bit3_result_ = bit5_result_ = a_;
uint8_t parity = a_;
parity ^= (parity >> 4);
parity ^= (parity >> 2);
parity ^= (parity >> 1);
parity_overflow_flag_ = (parity & 1) << 3;
} break;
set_parity(a_);
} break;
#pragma mark - 16-bit arithmetic #pragma mark - 16-bit arithmetic
@ -981,6 +973,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
// printf("Unhandled Z80 operation %d\n", operation->type); // printf("Unhandled Z80 operation %d\n", operation->type);
return; return;
} }
#undef set_parity
} }
} }