Skip to content

Commit

Permalink
fix BFFFO bitfield operation (fixes ViroCop AGA)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Nov 22, 2018
1 parent 2c7db9b commit 1412469
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 77)
set(VERSION_MINOR 78)

if(BUILD_PSP2)
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
Expand Down
10 changes: 6 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
Changes in this Version
======
1.77
1.78

- increase max files per dir from 3072 to 10240
- on Switch, in split JoyCon mode, make SL/SR act as L/R also in menu
- on Switch, in split JoyCon mode, disable L/R/ZL/ZR in menu
- fix 68020+ bitfield instructions (fixes crash in Virocop AGA)

Description
=====
Expand Down Expand Up @@ -214,6 +212,10 @@ Compiling

CHANGELOG
=====
1.78

- fix 68020+ bitfield instructions (fixes crash in Virocop AGA)

1.77

- increase max files per dir from 3072 to 10240
Expand Down
12 changes: 10 additions & 2 deletions src/m68k/fame/famec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ static void TRAPCC_EXECUTE (u32 Opcode)
/* Width 0 -> 32 */ \
WIDTH = (((EXTRA & 0x20 ? DREG(EXTRA & 7) : EXTRA) - 1) & 0x1F) + 1; \

#define BF_FFO(SRC, MASK, OFFSET, WIDTH) \
#define BF_FFO(SRC, MASK, OFFSET, WIDTH, EXTRA) \
{ \
MASK = 1 << (WIDTH - 1); \
while (MASK) { \
Expand All @@ -1074,7 +1074,7 @@ static void TRAPCC_EXECUTE (u32 Opcode)
OFFSET++; \
MASK >>= 1; \
} \
DREGu32(Opcode >> 12) = OFFSET; \
DREGu32((EXTRA >> 12) & 7) = OFFSET; \
}

#define BF_REG_GET(EXTRA, DATA, OFFSET, WIDTH) \
Expand All @@ -1084,6 +1084,14 @@ static void TRAPCC_EXECUTE (u32 Opcode)
BF_SHIFT_DOWN(DATA, OFFSET, WIDTH) \
BF_SET_FLAGS(DATA, WIDTH)

#define BF_REG_GET_BFFFO(EXTRA, DATA, OFFSET, OFFSET2, WIDTH) \
DATA = DREG((Opcode /*>> 0*/) & 7); \
BF_GET_PARM(EXTRA, OFFSET, WIDTH) \
OFFSET2 = OFFSET; \
OFFSET &= 0x1F; \
BF_SHIFT_DOWN(DATA, OFFSET, WIDTH) \
BF_SET_FLAGS(DATA, WIDTH)

static __inline__ void BF_MEM_GET(u32 *adr, u32 *dst, s32 *offset, u32 width, u32 *bf0, u32 *bf1)
{
/* adr = base byte address
Expand Down
29 changes: 19 additions & 10 deletions src/m68k/fame/famec_opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46349,11 +46349,13 @@ OPCODE(0xEDC0)
{
u32 adr, res;
u32 src, dst;
u32 mask, offset, width;
u32 mask, width;
s32 offset;
u32 offset2;

FETCH_WORD(res)
BF_REG_GET(res, src, offset, width)
BF_FFO(src, mask, offset, width)
BF_REG_GET_BFFFO(res, src, offset, offset2, width)
BF_FFO(src, mask, offset2, width, res)
RET(18)
}

Expand All @@ -46369,9 +46371,10 @@ OPCODE(0xEDD0)
FETCH_WORD(res)
adr = AREG((Opcode /*>> 0*/) & 7);
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(28)
}

Expand All @@ -46388,9 +46391,10 @@ OPCODE(0xEDE8)
FETCH_SWORD(adr)
adr += AREG((Opcode /*>> 0*/) & 7);
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(34)
}

Expand All @@ -46407,9 +46411,10 @@ OPCODE(0xEDF0)
adr = AREG((Opcode /*>> 0*/) & 7);
DECODE_EXT_WORD(&adr);
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(30)
}

Expand All @@ -46425,9 +46430,10 @@ OPCODE(0xEDF8)
FETCH_WORD(res)
FETCH_SWORD(adr)
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(28)
}

Expand All @@ -46443,9 +46449,10 @@ OPCODE(0xEDF9)
FETCH_WORD(res)
FETCH_LONG(adr)
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(28)
}

Expand All @@ -46462,9 +46469,10 @@ OPCODE(0xEDFA)
adr = GET_SWORD + ((hostptr)(PC) - BasePC);
PC++;
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(34)
}

Expand All @@ -46481,9 +46489,10 @@ OPCODE(0xEDFB)
adr = (hostptr)(PC) - BasePC;
DECODE_EXT_WORD(&adr);
BF_GET_PARM(res, offset, width)
u32 offset2 = offset;
BF_MEM_GET(&adr, &src, &offset, width, &bf0, &bf1);
BF_SET_FLAGS(src, width)
BF_FFO(src, mask, dst, width)
BF_FFO(src, mask, offset2, width, res)
RET(30)
}

Expand Down

0 comments on commit 1412469

Please sign in to comment.