essenbee/z80emu

2 Bitmasks in IncrementRefreshRegister (Z80.cs) are wrong.

Closed this issue · 3 comments

the 0b01111111 masks to clear bit 7 (both of them) have a 1 too many (0b011111111)

Thanks for finding this, I will fix asap

You're welcome!

Made my own fix like this:

            // get lower 7 bits of R
            var refresh = R & 0b01111111;

            // add steps and remove msb from result
            refresh = (refresh+steps) &0x01111111;

            // update only lower 7 bits of R
            R = (byte) ((R & 0b10000000) | refresh);

can also be one line, but I prefer readability.

Fixed and NuGet package updated