Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/core/gba/gba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3637,9 +3637,6 @@ void applyTimer()
timerOnOffDelay = 0;
}

uint8_t cpuBitsSet[256];
uint8_t cpuLowestBitSet[256];

void CPUInit(const char* biosFileName, bool useBiosFile)
{
#ifdef WORDS_BIGENDIAN
Expand Down Expand Up @@ -3677,7 +3674,7 @@ void CPUInit(const char* biosFileName, bool useBiosFile)
biosProtected[2] = 0x29;
biosProtected[3] = 0xe1;

for (i = 0; i < 256; i++) {
/*for (i = 0; i < 256; i++) {
int count = 0;
int j;
for (j = 0; j < 8; j++)
Expand All @@ -3689,7 +3686,7 @@ void CPUInit(const char* biosFileName, bool useBiosFile)
if (i & (1 << j))
break;
cpuLowestBitSet[i] = DowncastU8(j);
}
}*/

for (i = 0; i < 0x400; i++)
ioReadable[i] = true;
Expand Down
22 changes: 20 additions & 2 deletions src/core/gba/gbaCpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ extern int thumbExecute();

#define THUMB_PREFETCH_NEXT cpuPrefetch[1] = CPUReadHalfWordQuick(armNextPC + 2);

constexpr uint8_t cpuBitsSet[256] =
{
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
};

extern int SWITicks;
extern uint32_t mastercode;
extern bool busPrefetch;
Expand All @@ -58,8 +78,6 @@ extern uint8_t memoryWait[16];
extern uint8_t memoryWait32[16];
extern uint8_t memoryWaitSeq[16];
extern uint8_t memoryWaitSeq32[16];
extern uint8_t cpuBitsSet[256];
extern uint8_t cpuLowestBitSet[256];
extern void CPUSwitchMode(int mode, bool saveState, bool breakLoop);
extern void CPUSwitchMode(int mode, bool saveState);
extern void CPUUpdateCPSR();
Expand Down
2 changes: 1 addition & 1 deletion src/core/gba/gbaCpuArm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ static void count(uint32_t opcode, int cond_res)
#ifndef SETCOND_MULL
#define SETCOND_MULL \
N_FLAG = (reg[dest].I & 0x80000000) ? true : false; \
Z_FLAG = reg[dest].I || reg[acc].I ? false : true;
Z_FLAG = (reg[dest].I | reg[acc].I) ? false : true;
#endif

#ifndef ALU_FINISH
Expand Down
4 changes: 2 additions & 2 deletions src/core/gba/gbaCpuThumb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ static INSN_REGPARM void thumb48(uint32_t opcode)
if (busPrefetchCount == 0)
busPrefetch = busPrefetchEnable;
uint32_t address = (reg[15].I & 0xFFFFFFFC) + ((opcode & 0xFF) << 2);
reg[regist].I = CPUReadMemoryQuick(address);
reg[regist].I = CPUReadMemory(address);
busPrefetchCount = 0;
clockTicks = 3 + dataTicksAccess32(address) + codeTicksAccess16(armNextPC);
}
Expand Down Expand Up @@ -1480,7 +1480,7 @@ static INSN_REGPARM void thumb98(uint32_t opcode)
if (busPrefetchCount == 0)
busPrefetch = busPrefetchEnable;
uint32_t address = reg[13].I + ((opcode & 255) << 2);
reg[regist].I = CPUReadMemoryQuick(address);
reg[regist].I = CPUReadMemory(address);
clockTicks = 3 + dataTicksAccess32(address) + codeTicksAccess16(armNextPC);
}

Expand Down
Loading