I hate Binary Coded Decimal :smith::
INS(adc)
{
unsigned short total = (unsigned short)cpu->regs.a + (unsigned short)param + (GET_FLAG(cpu, FCARRY) ? 1 : 0);
if(GET_FLAG(cpu, FBCD))
{
cpu->regs.a += (param & 255) + (GET_FLAG(cpu, FCARRY) ? 1 : 0);
FLAG_IF(cpu, FCARRY, total > 255);
FLAG_IF(cpu, FZERO, cpu->regs.a == 0);
FLAG_IF(cpu, FNEG, cpu->regs.a & 128);
FLAG_IF(cpu, FOFLOW, (cpu->regs.a > 0) != (total > 0));
}
else
{
// binary coded decimal mode eeek
cpu->regs.a = (total / 10) << 4 + (total % 10);
}
}