Issues with NBCD instruction
The implementation of NBCD doesn’t seem to be correct.
To verify this instruction, I’ve written four test cases:
https://github.com/dirkwhoffmann/vAmigaTS/tree/master/CPU/NBCD
nbcd1
Draws two 16 x 16 squares. In each square, the NBCD command is run for all 256 possible source values. The left square has the X flag cleared and the right square set. Each 8 x 8 pixel box shows the bit pattern of value computed by the instruction under test.
nbcd2
Displays the value of the N flag after NBCD has been executed.
nbcd3
Displays the value of the V flag after NBCD has been executed.
nbcd4
Displays the value of the X,Z, and V flag after NBCD has been executed.
Here are the results:
Musashi (vAmiga):
A real Amiga (A500+ 🥰):

The left image (NBCD executed with X = 0) seems to be correct. The right image differs.
The flags show discrepancies, too:
Musashi (vAmiga):
A500+:

I've also run the test cases in UAE. As far as I could see, UAE does it right. I didn't look into the UAE code yet, but it might help to fix the instruction.