From bf209d05b81cf45d7b1a1ab007f32a2ffaad68e2 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Mon, 27 Sep 2010 02:56:14 -0500 Subject: [PATCH] As seen at http://board.byuu.org/viewtopic.php?f=3&t=881 Fix for Mega Man X2's "weapon get" screen. (Jonas Quinn) --- c4emu.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/c4emu.cpp b/c4emu.cpp index a7c009cb..65e0f553 100644 --- a/c4emu.cpp +++ b/c4emu.cpp @@ -1013,9 +1013,16 @@ void S9xSetC4 (uint8 byte, uint16 Address) printf("$7f4d=%02x, expected 02 for command 10 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); #endif int32 tmp; - tmp = SAR((int32) READ_WORD(Memory.C4RAM + 0x1f83) * C4CosTable[READ_WORD(Memory.C4RAM + 0x1f80) & 0x1ff] * 2, 16); + int32 r1; + r1 = READ_WORD(Memory.C4RAM + 0x1f83); + if (r1 & 0x8000) + r1 |= ~0x7fff; + else + r1 &= 0x7fff; + + tmp = SAR(r1 * C4CosTable[READ_WORD(Memory.C4RAM + 0x1f80) & 0x1ff] * 2, 16); WRITE_3WORD(Memory.C4RAM + 0x1f86, tmp); - tmp = SAR((int32) READ_WORD(Memory.C4RAM + 0x1f83) * C4SinTable[READ_WORD(Memory.C4RAM + 0x1f80) & 0x1ff] * 2, 16); + tmp = SAR(r1 * C4SinTable[READ_WORD(Memory.C4RAM + 0x1f80) & 0x1ff] * 2, 16); WRITE_3WORD(Memory.C4RAM + 0x1f89, (tmp - SAR(tmp, 6))); break; }