mamedev / mame

MAME
https://www.mamedev.org/
Other
7.96k stars 1.98k forks source link

Musashi/M68k: bfins data for 5th byte is wrong #573

Closed harbaum closed 8 years ago

harbaum commented 8 years ago

This bug is related to the previous https://github.com/mamedev/mame/issues/327 which fixed shifting for the mask of the fifth byte.

The data has a similar problem. Example: test: dc.l $ffffffff, $ffffffff move.l #$12345678,d0 bfins d0,test{4:32}

In musashi the result is f1234567 7fffffff but it should be f1234567 8fffffff. Furthermore the zreo flag is not properly set as it needs to be derived from the value to be inserted and not from the previous contents. The code dealing with the previous 4 bytes does this correctly.

The reason is that for bfins the data to be inserted has to be shifted like the mask:

    if((width + offset) > 32)
    {
        mask_byte = MASK_OUT_ABOVE_8(mask_base) << (8-offset);
        // insert_byte = MASK_OUT_ABOVE_8(insert_base);  // broken!!!
        insert_byte = MASK_OUT_ABOVE_8(insert_base) << (8-offset);  // fixed
        data_byte = m68ki_read_8(ea+4);
        // FLAG_Z |= (data_byte & mask_byte);   // broken!!
        FLAG_Z |= (insert_byte & mask_byte);   // fixed
        m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte);
    }
rb6502 commented 8 years ago

Thanks! I'll take a look.

rb6502 commented 8 years ago

Thanks! The fix is applied to MAME trunk, and it fixes a long-standing bug where the MacOS Jigsaw Puzzle applet would freak out and create impossible puzzles.

galibert commented 8 years ago

Way cool :-)

OG.

On Sun, Jan 24, 2016 at 8:21 PM, R. Belmont notifications@github.com wrote:

Thanks! The fix is applied to MAME trunk, and it fixes a long-standing bug where the MacOS Jigsaw Puzzle applet would freak out and create impossible puzzles.

— Reply to this email directly or view it on GitHub https://github.com/mamedev/mame/issues/573#issuecomment-174332580.

DopefishJustin commented 8 years ago

http://mametesters.org/view.php?id=5411

harbaum commented 8 years ago

Cool! Thanks for the feedback.