All: Add clang-format options and run them

This commit is contained in:
Jeffrey Pfau 2015-06-29 20:10:02 -07:00
parent 3ba13e9286
commit 908e61f415
54 changed files with 449 additions and 346 deletions

34
.clang-format Normal file
View File

@ -0,0 +1,34 @@
Language: Cpp
BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
ConstructorInitializerIndentWidth: 4
IndentCaseLabels: false
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PointerAlignment: Left
SpaceAfterCStyleCast: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpacesInContainerLiterals: true
SpaceInEmptyParentheses: false
SpacesInAngles: false
Standard: Cpp11
TabWidth: 4
UseTab: ForIndentation

View File

@ -42,30 +42,29 @@ void ARMSetPrivilegeMode(struct ARMCore* cpu, enum PrivilegeMode mode) {
cpu->bankedSPSRs[oldBank] = cpu->spsr.packed;
cpu->spsr.packed = cpu->bankedSPSRs[newBank];
}
cpu->privilegeMode = mode;
}
static inline enum RegisterBank _ARMSelectBank(enum PrivilegeMode mode) {
switch (mode) {
case MODE_USER:
case MODE_SYSTEM:
// No banked registers
return BANK_NONE;
case MODE_FIQ:
return BANK_FIQ;
case MODE_IRQ:
return BANK_IRQ;
case MODE_SUPERVISOR:
return BANK_SUPERVISOR;
case MODE_ABORT:
return BANK_ABORT;
case MODE_UNDEFINED:
return BANK_UNDEFINED;
default:
// This should be unreached
return BANK_NONE;
case MODE_USER:
case MODE_SYSTEM:
// No banked registers
return BANK_NONE;
case MODE_FIQ:
return BANK_FIQ;
case MODE_IRQ:
return BANK_IRQ;
case MODE_SUPERVISOR:
return BANK_SUPERVISOR;
case MODE_ABORT:
return BANK_ABORT;
case MODE_UNDEFINED:
return BANK_UNDEFINED;
default:
// This should be unreached
return BANK_NONE;
}
}
@ -308,7 +307,7 @@ void ARMRunLoop(struct ARMCore* cpu) {
}
void ARMRunFake(struct ARMCore* cpu, uint32_t opcode) {
if (cpu->executionMode== MODE_ARM) {
if (cpu->executionMode == MODE_ARM) {
cpu->gprs[ARM_PC] -= WORD_SIZE_ARM;
} else {
cpu->gprs[ARM_PC] -= WORD_SIZE_THUMB;

View File

@ -101,8 +101,10 @@ struct ARMMemory {
void (*store16)(struct ARMCore*, uint32_t address, int16_t value, int* cycleCounter);
void (*store8)(struct ARMCore*, uint32_t address, int8_t value, int* cycleCounter);
uint32_t (*loadMultiple)(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction, int* cycleCounter);
uint32_t (*storeMultiple)(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction, int* cycleCounter);
uint32_t (*loadMultiple)(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction,
int* cycleCounter);
uint32_t (*storeMultiple)(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction,
int* cycleCounter);
uint32_t* activeRegion;
uint32_t activeMask;

View File

@ -13,11 +13,11 @@
#include <stdio.h>
#include <string.h>
#define LOAD_CYCLES \
#define LOAD_CYCLES \
info->iCycles = 1; \
info->nDataCycles = 1;
#define STORE_CYCLES \
#define STORE_CYCLES \
info->sInstructionCycles = 0; \
info->nInstructionCycles = 1; \
info->nDataCycles = 1;

View File

@ -209,7 +209,8 @@ struct ARMInstructionInfo {
void ARMDecodeARM(uint32_t opcode, struct ARMInstructionInfo* info);
void ARMDecodeThumb(uint16_t opcode, struct ARMInstructionInfo* info);
bool ARMDecodeThumbCombine(struct ARMInstructionInfo* info1, struct ARMInstructionInfo* info2, struct ARMInstructionInfo* out);
bool ARMDecodeThumbCombine(struct ARMInstructionInfo* info1, struct ARMInstructionInfo* info2,
struct ARMInstructionInfo* out);
int ARMDisassemble(struct ARMInstructionInfo* info, uint32_t pc, char* buffer, int blen);
#endif

View File

@ -15,5 +15,4 @@ struct ARMCore;
typedef void (*ARMInstruction)(struct ARMCore*, uint32_t opcode);
const ARMInstruction _armTable[0x1000];
#endif

View File

@ -35,37 +35,37 @@
#define ARM_V_ADDITION(M, N, D) (!(ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D))) && (ARM_SIGN((N) ^ (D))))
#define ARM_V_SUBTRACTION(M, N, D) ((ARM_SIGN((M) ^ (N))) && (ARM_SIGN((M) ^ (D))))
#define ARM_WAIT_MUL(R) \
{ \
int32_t wait; \
if ((R & 0xFFFFFF00) == 0xFFFFFF00 || !(R & 0xFFFFFF00)) { \
wait = 1; \
#define ARM_WAIT_MUL(R) \
{ \
int32_t wait; \
if ((R & 0xFFFFFF00) == 0xFFFFFF00 || !(R & 0xFFFFFF00)) { \
wait = 1; \
} else if ((R & 0xFFFF0000) == 0xFFFF0000 || !(R & 0xFFFF0000)) { \
wait = 2; \
wait = 2; \
} else if ((R & 0xFF000000) == 0xFF000000 || !(R & 0xFF000000)) { \
wait = 3; \
} else { \
wait = 4; \
} \
currentCycles += cpu->memory.stall(cpu, wait); \
wait = 3; \
} else { \
wait = 4; \
} \
currentCycles += cpu->memory.stall(cpu, wait); \
}
#define ARM_STUB cpu->irqh.hitStub(cpu, opcode)
#define ARM_ILL cpu->irqh.hitIllegal(cpu, opcode)
#define ARM_WRITE_PC \
cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_ARM); \
cpu->memory.setActiveRegion(cpu, cpu->gprs[ARM_PC]); \
#define ARM_WRITE_PC \
cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_ARM); \
cpu->memory.setActiveRegion(cpu, cpu->gprs[ARM_PC]); \
LOAD_32(cpu->prefetch[0], cpu->gprs[ARM_PC] & cpu->memory.activeMask, cpu->memory.activeRegion); \
cpu->gprs[ARM_PC] += WORD_SIZE_ARM; \
cpu->gprs[ARM_PC] += WORD_SIZE_ARM; \
LOAD_32(cpu->prefetch[1], cpu->gprs[ARM_PC] & cpu->memory.activeMask, cpu->memory.activeRegion); \
currentCycles += 2 + cpu->memory.activeNonseqCycles32 + cpu->memory.activeSeqCycles32;
#define THUMB_WRITE_PC \
cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_THUMB); \
cpu->memory.setActiveRegion(cpu, cpu->gprs[ARM_PC]); \
#define THUMB_WRITE_PC \
cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_THUMB); \
cpu->memory.setActiveRegion(cpu, cpu->gprs[ARM_PC]); \
LOAD_16(cpu->prefetch[0], cpu->gprs[ARM_PC] & cpu->memory.activeMask, cpu->memory.activeRegion); \
cpu->gprs[ARM_PC] += WORD_SIZE_THUMB; \
cpu->gprs[ARM_PC] += WORD_SIZE_THUMB; \
LOAD_16(cpu->prefetch[1], cpu->gprs[ARM_PC] & cpu->memory.activeMask, cpu->memory.activeRegion); \
currentCycles += 2 + cpu->memory.activeNonseqCycles16 + cpu->memory.activeSeqCycles16;

View File

@ -82,7 +82,7 @@ static struct CLIDebuggerCommandSummary _debuggerCommands[] = {
{ "print/t", _printBin, CLIDVParse, "Print a value as binary" },
{ "print/x", _printHex, CLIDVParse, "Print a value as hexadecimal" },
{ "q", _quit, 0, "Quit the emulator" },
{ "quit", _quit, 0, "Quit the emulator" },
{ "quit", _quit, 0, "Quit the emulator" },
{ "reset", _reset, 0, "Reset the emulation" },
{ "r/1", _readByte, CLIDVParse, "Read a byte from a specified offset" },
{ "r/2", _readHalfword, CLIDVParse, "Read a halfword from a specified offset" },
@ -103,13 +103,13 @@ static struct CLIDebuggerCommandSummary _debuggerCommands[] = {
static inline void _printPSR(union PSR psr) {
printf("%08X [%c%c%c%c%c%c%c]\n", psr.packed,
psr.n ? 'N' : '-',
psr.z ? 'Z' : '-',
psr.c ? 'C' : '-',
psr.v ? 'V' : '-',
psr.i ? 'I' : '-',
psr.f ? 'F' : '-',
psr.t ? 'T' : '-');
psr.n ? 'N' : '-',
psr.z ? 'Z' : '-',
psr.c ? 'C' : '-',
psr.v ? 'V' : '-',
psr.i ? 'I' : '-',
psr.f ? 'F' : '-',
psr.t ? 'T' : '-');
}
static void _handleDeath(int sig) {
@ -196,7 +196,7 @@ static void _disassembleMode(struct CLIDebugger* debugger, struct CLIDebugVector
static void _print(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
UNUSED(debugger);
for ( ; dv; dv = dv->next) {
for (; dv; dv = dv->next) {
printf(" %u", dv->intValue);
}
printf("\n");
@ -204,7 +204,7 @@ static void _print(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
static void _printBin(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
UNUSED(debugger);
for ( ; dv; dv = dv->next) {
for (; dv; dv = dv->next) {
printf(" 0b");
int i = 32;
while (i--) {
@ -216,7 +216,7 @@ static void _printBin(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
static void _printHex(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
UNUSED(debugger);
for ( ; dv; dv = dv->next) {
for (; dv; dv = dv->next) {
printf(" 0x%08X", dv->intValue);
}
printf("\n");
@ -289,10 +289,10 @@ static void _printStatus(struct CLIDebugger* debugger, struct CLIDebugVector* dv
int r;
for (r = 0; r < 4; ++r) {
printf("%08X %08X %08X %08X\n",
debugger->d.cpu->gprs[r << 2],
debugger->d.cpu->gprs[(r << 2) + 1],
debugger->d.cpu->gprs[(r << 2) + 2],
debugger->d.cpu->gprs[(r << 2) + 3]);
debugger->d.cpu->gprs[r << 2],
debugger->d.cpu->gprs[(r << 2) + 1],
debugger->d.cpu->gprs[(r << 2) + 2],
debugger->d.cpu->gprs[(r << 2) + 3]);
}
_printPSR(debugger->d.cpu->cpsr);
int instructionLength;

View File

@ -108,7 +108,7 @@ static uint32_t _hex2int(const char* hex, int maxDigits) {
letter = *hex - '0';
if (letter > 9) {
letter = *hex - 'a';
if (letter > 5) {
if (letter > 5) {
break;
}
value *= 0x10;

View File

@ -118,8 +118,8 @@ size_t lexExpression(struct LexVector* lv, const char* string, size_t length) {
break;
case LEX_EXPECT_BINARY:
switch (token) {
case '0':
case '1':
case '0':
case '1':
// TODO: handle overflow
next <<= 1;
next += token - '0';

View File

@ -41,7 +41,7 @@ void GBAAudioInit(struct GBAAudio* audio, size_t samples) {
audio->left = blip_new(BLIP_BUFFER_SIZE);
audio->right = blip_new(BLIP_BUFFER_SIZE);
// Guess too large; we hang producing extra samples if we guess too low
blip_set_rates(audio->left, GBA_ARM7TDMI_FREQUENCY, 96000);
blip_set_rates(audio->left, GBA_ARM7TDMI_FREQUENCY, 96000);
blip_set_rates(audio->right, GBA_ARM7TDMI_FREQUENCY, 96000);
#endif
CircleBufferInit(&audio->chA.fifo, GBA_AUDIO_FIFO_SIZE);

View File

@ -279,7 +279,8 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles);
#if RESAMPLE_LIBRARY != RESAMPLE_BLIP_BUF
unsigned GBAAudioCopy(struct GBAAudio* audio, void* left, void* right, unsigned nSamples);
unsigned GBAAudioResampleNN(struct GBAAudio*, float ratio, float* drift, struct GBAStereoSample* output, unsigned nSamples);
unsigned GBAAudioResampleNN(struct GBAAudio*, float ratio, float* drift, struct GBAStereoSample* output,
unsigned nSamples);
#endif
struct GBASerializedState;

View File

@ -175,7 +175,7 @@ static void _Div(struct GBA* gba, int32_t num, int32_t denom) {
void GBASwi16(struct ARMCore* cpu, int immediate) {
struct GBA* gba = (struct GBA*) cpu->master;
GBALog(gba, GBA_LOG_SWI, "SWI: %02X r0: %08X r1: %08X r2: %08X r3: %08X",
immediate, cpu->gprs[0], cpu->gprs[1], cpu->gprs[2], cpu->gprs[3]);
immediate, cpu->gprs[0], cpu->gprs[1], cpu->gprs[2], cpu->gprs[3]);
if (gba->memory.fullBios) {
ARMRaiseSWI(cpu);
@ -192,8 +192,8 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
GBAHalt(gba);
break;
case 0x05:
// VBlankIntrWait
// Fall through:
// VBlankIntrWait
// Fall through:
case 0x04:
// IntrWait
ARMRaiseSWI(cpu);
@ -236,14 +236,14 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
break;
}
switch (cpu->gprs[1] >> BASE_OFFSET) {
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad LZ77 destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unLz77(gba, immediate == 0x11 ? 1 : 2);
break;
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad LZ77 destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unLz77(gba, immediate == 0x11 ? 1 : 2);
break;
}
break;
case 0x13:
@ -252,14 +252,14 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
break;
}
switch (cpu->gprs[1] >> BASE_OFFSET) {
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad Huffman destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unHuffman(gba);
break;
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad Huffman destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unHuffman(gba);
break;
}
break;
case 0x14:
@ -269,14 +269,14 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
break;
}
switch (cpu->gprs[1] >> BASE_OFFSET) {
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad RL destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unRl(gba, immediate == 0x14 ? 1 : 2);
break;
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad RL destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unRl(gba, immediate == 0x14 ? 1 : 2);
break;
}
break;
case 0x16:
@ -287,14 +287,14 @@ void GBASwi16(struct ARMCore* cpu, int immediate) {
break;
}
switch (cpu->gprs[1] >> BASE_OFFSET) {
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad UnFilter destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unFilter(gba, immediate == 0x18 ? 2 : 1, immediate == 0x16 ? 1 : 2);
break;
default:
GBALog(gba, GBA_LOG_GAME_ERROR, "Bad UnFilter destination");
// Fall through
case REGION_WORKING_RAM:
case REGION_WORKING_IRAM:
case REGION_VRAM:
_unFilter(gba, immediate == 0x18 ? 2 : 1, immediate == 0x16 ? 1 : 2);
break;
}
break;
case 0x1F:
@ -457,7 +457,6 @@ static void _unHuffman(struct GBA* gba) {
block = 0;
}
}
}
cpu->gprs[0] = source;
cpu->gprs[1] = dest;

View File

@ -198,7 +198,7 @@ bool GBACheatAddGameShark(struct GBACheatSet* set, uint32_t op1, uint32_t op2) {
switch (set->gsaVersion) {
case 0:
GBACheatSetGameSharkVersion(set, 1);
// Fall through
// Fall through
case 1:
GBACheatDecryptGameShark(&o1, &o2, set->gsaSeeds);
return GBACheatAddGameSharkRaw(set, o1, o2);

View File

@ -298,7 +298,7 @@ bool GBACheatAddProActionReplay(struct GBACheatSet* set, uint32_t op1, uint32_t
switch (set->gsaVersion) {
case 0:
GBACheatSetGameSharkVersion(set, 3);
// Fall through
// Fall through
case 1:
GBACheatDecryptGameShark(&o1, &o2, set->gsaSeeds);
return GBACheatAddProActionReplayRaw(set, o1, o2);

View File

@ -203,7 +203,8 @@ void GBAHalt(struct GBA* gba);
void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
void GBADetachDebugger(struct GBA* gba);
void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t address, enum ExecutionMode mode,
uint32_t* opcode);
void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname);
@ -220,7 +221,7 @@ void GBAGetGameTitle(struct GBA* gba, char* out);
void GBAFrameStarted(struct GBA* gba);
void GBAFrameEnded(struct GBA* gba);
ATTRIBUTE_FORMAT(printf,3,4)
ATTRIBUTE_FORMAT(printf, 3, 4)
void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...);
ATTRIBUTE_FORMAT(printf, 3, 4)

View File

@ -3,49 +3,49 @@
#include "gba/memory.h"
const uint8_t hleBios[SIZE_BIOS] = {
0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x07, 0x00, 0x00, 0xea,
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
0x28, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x02, 0xf3, 0xa0, 0xe3,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x29, 0xe1, 0x00, 0x00, 0x5d, 0xe3,
0x01, 0xd3, 0xa0, 0x03, 0x20, 0xd0, 0x4d, 0x02, 0x00, 0x58, 0x2d, 0xe9,
0x02, 0xb0, 0x5e, 0xe5, 0x8c, 0xc0, 0xa0, 0xe3, 0x0b, 0xb1, 0x9c, 0xe7,
0x00, 0x00, 0x5b, 0xe3, 0x00, 0xc0, 0x4f, 0xe1, 0x00, 0x10, 0x2d, 0xe9,
0x80, 0xc0, 0x0c, 0xe2, 0x1f, 0xc0, 0x8c, 0xe3, 0x0c, 0xf0, 0x29, 0xe1,
0x00, 0x40, 0x2d, 0xe9, 0x0f, 0xe0, 0xa0, 0xe1, 0x1b, 0xff, 0x2f, 0x11,
0x00, 0x40, 0xbd, 0xe8, 0x93, 0xf0, 0x29, 0xe3, 0x00, 0x10, 0xbd, 0xe8,
0x0c, 0xf0, 0x69, 0xe1, 0x00, 0x58, 0xbd, 0xe8, 0x0e, 0xf0, 0xb0, 0xe1,
0x00, 0x00, 0x00, 0x00, 0x04, 0x20, 0xa0, 0xe3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe8, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00,
0x0f, 0x50, 0x2d, 0xe9, 0x01, 0x03, 0xa0, 0xe3, 0x00, 0xe0, 0x8f, 0xe2,
0x04, 0xf0, 0x10, 0xe5, 0x0f, 0x50, 0xbd, 0xe8, 0x04, 0xf0, 0x5e, 0xe2,
0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x5e, 0xe5, 0x01, 0x00, 0xa0, 0xe3,
0x01, 0x10, 0xa0, 0xe3, 0x0c, 0x40, 0x2d, 0xe9, 0x01, 0xc3, 0xa0, 0xe3,
0x00, 0x00, 0x50, 0xe3, 0x00, 0x00, 0xa0, 0xe3, 0x01, 0x20, 0xa0, 0xe3,
0x03, 0x00, 0x00, 0x0a, 0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0xc3, 0xe1,
0xb8, 0x30, 0x4c, 0xe1, 0x01, 0x03, 0xcc, 0xe5, 0x08, 0x02, 0xcc, 0xe5,
0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0x13, 0xe0, 0x01, 0x30, 0x23, 0x10,
0xb8, 0x30, 0x4c, 0x11, 0x08, 0x22, 0xcc, 0xe5, 0xf7, 0xff, 0xff, 0x0a,
0x0c, 0x80, 0xbd, 0xe8, 0x00, 0x40, 0x2d, 0xe9, 0x02, 0x36, 0xa0, 0xe1,
0x01, 0x04, 0x12, 0xe3, 0x0f, 0x00, 0x00, 0x0a, 0x01, 0x03, 0x12, 0xe3,
0x05, 0x00, 0x00, 0x0a, 0x23, 0x35, 0x81, 0xe0, 0x04, 0x00, 0xb0, 0xe8,
0x03, 0x00, 0x51, 0xe1, 0x04, 0x00, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba,
0x16, 0x00, 0x00, 0xea, 0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3,
0xa3, 0x35, 0x81, 0xe0, 0xb0, 0x20, 0xd0, 0xe1, 0x03, 0x00, 0x51, 0xe1,
0xb2, 0x20, 0xc1, 0xb0, 0xfc, 0xff, 0xff, 0xba, 0x0e, 0x00, 0x00, 0xea,
0x01, 0x03, 0x12, 0xe3, 0x05, 0x00, 0x00, 0x0a, 0x23, 0x35, 0x81, 0xe0,
0x03, 0x00, 0x51, 0xe1, 0x04, 0x00, 0xb0, 0xb8, 0x04, 0x00, 0xa1, 0xb8,
0xfb, 0xff, 0xff, 0xba, 0x06, 0x00, 0x00, 0xea, 0xa3, 0x35, 0x81, 0xe0,
0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3, 0x03, 0x00, 0x51, 0xe1,
0xb2, 0x20, 0xd0, 0xb0, 0xb2, 0x20, 0xc1, 0xb0, 0xfb, 0xff, 0xff, 0xba,
0x00, 0x80, 0xbd, 0xe8, 0xf0, 0x47, 0x2d, 0xe9, 0x01, 0x04, 0x12, 0xe3,
0x02, 0x36, 0xa0, 0xe1, 0x23, 0x25, 0x81, 0xe0, 0x0b, 0x00, 0x00, 0x0a,
0x00, 0x30, 0x90, 0xe5, 0x03, 0x40, 0xa0, 0xe1, 0x03, 0x50, 0xa0, 0xe1,
0x03, 0x60, 0xa0, 0xe1, 0x03, 0x70, 0xa0, 0xe1, 0x03, 0x80, 0xa0, 0xe1,
0x03, 0x90, 0xa0, 0xe1, 0x03, 0xa0, 0xa0, 0xe1, 0x02, 0x00, 0x51, 0xe1,
0xf8, 0x07, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba, 0x03, 0x00, 0x00, 0xea,
0x02, 0x00, 0x51, 0xe1, 0xf8, 0x07, 0xb0, 0xb8, 0xf8, 0x07, 0xa1, 0xb8,
0xfb, 0xff, 0xff, 0xba, 0xf0, 0x87, 0xbd, 0xe8
0x06, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x07, 0x00, 0x00, 0xea,
0xfe, 0xff, 0xff, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x00, 0x00, 0xa0, 0xe1,
0x28, 0x00, 0x00, 0xea, 0xfe, 0xff, 0xff, 0xea, 0x02, 0xf3, 0xa0, 0xe3,
0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x29, 0xe1, 0x00, 0x00, 0x5d, 0xe3,
0x01, 0xd3, 0xa0, 0x03, 0x20, 0xd0, 0x4d, 0x02, 0x00, 0x58, 0x2d, 0xe9,
0x02, 0xb0, 0x5e, 0xe5, 0x8c, 0xc0, 0xa0, 0xe3, 0x0b, 0xb1, 0x9c, 0xe7,
0x00, 0x00, 0x5b, 0xe3, 0x00, 0xc0, 0x4f, 0xe1, 0x00, 0x10, 0x2d, 0xe9,
0x80, 0xc0, 0x0c, 0xe2, 0x1f, 0xc0, 0x8c, 0xe3, 0x0c, 0xf0, 0x29, 0xe1,
0x00, 0x40, 0x2d, 0xe9, 0x0f, 0xe0, 0xa0, 0xe1, 0x1b, 0xff, 0x2f, 0x11,
0x00, 0x40, 0xbd, 0xe8, 0x93, 0xf0, 0x29, 0xe3, 0x00, 0x10, 0xbd, 0xe8,
0x0c, 0xf0, 0x69, 0xe1, 0x00, 0x58, 0xbd, 0xe8, 0x0e, 0xf0, 0xb0, 0xe1,
0x00, 0x00, 0x00, 0x00, 0x04, 0x20, 0xa0, 0xe3, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe8, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00,
0x0f, 0x50, 0x2d, 0xe9, 0x01, 0x03, 0xa0, 0xe3, 0x00, 0xe0, 0x8f, 0xe2,
0x04, 0xf0, 0x10, 0xe5, 0x0f, 0x50, 0xbd, 0xe8, 0x04, 0xf0, 0x5e, 0xe2,
0x00, 0x00, 0x00, 0x00, 0x02, 0xc0, 0x5e, 0xe5, 0x01, 0x00, 0xa0, 0xe3,
0x01, 0x10, 0xa0, 0xe3, 0x0c, 0x40, 0x2d, 0xe9, 0x01, 0xc3, 0xa0, 0xe3,
0x00, 0x00, 0x50, 0xe3, 0x00, 0x00, 0xa0, 0xe3, 0x01, 0x20, 0xa0, 0xe3,
0x03, 0x00, 0x00, 0x0a, 0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0xc3, 0xe1,
0xb8, 0x30, 0x4c, 0xe1, 0x01, 0x03, 0xcc, 0xe5, 0x08, 0x02, 0xcc, 0xe5,
0xb8, 0x30, 0x5c, 0xe1, 0x01, 0x30, 0x13, 0xe0, 0x01, 0x30, 0x23, 0x10,
0xb8, 0x30, 0x4c, 0x11, 0x08, 0x22, 0xcc, 0xe5, 0xf7, 0xff, 0xff, 0x0a,
0x0c, 0x80, 0xbd, 0xe8, 0x00, 0x40, 0x2d, 0xe9, 0x02, 0x36, 0xa0, 0xe1,
0x01, 0x04, 0x12, 0xe3, 0x0f, 0x00, 0x00, 0x0a, 0x01, 0x03, 0x12, 0xe3,
0x05, 0x00, 0x00, 0x0a, 0x23, 0x35, 0x81, 0xe0, 0x04, 0x00, 0xb0, 0xe8,
0x03, 0x00, 0x51, 0xe1, 0x04, 0x00, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba,
0x16, 0x00, 0x00, 0xea, 0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3,
0xa3, 0x35, 0x81, 0xe0, 0xb0, 0x20, 0xd0, 0xe1, 0x03, 0x00, 0x51, 0xe1,
0xb2, 0x20, 0xc1, 0xb0, 0xfc, 0xff, 0xff, 0xba, 0x0e, 0x00, 0x00, 0xea,
0x01, 0x03, 0x12, 0xe3, 0x05, 0x00, 0x00, 0x0a, 0x23, 0x35, 0x81, 0xe0,
0x03, 0x00, 0x51, 0xe1, 0x04, 0x00, 0xb0, 0xb8, 0x04, 0x00, 0xa1, 0xb8,
0xfb, 0xff, 0xff, 0xba, 0x06, 0x00, 0x00, 0xea, 0xa3, 0x35, 0x81, 0xe0,
0x01, 0x00, 0xc0, 0xe3, 0x01, 0x10, 0xc1, 0xe3, 0x03, 0x00, 0x51, 0xe1,
0xb2, 0x20, 0xd0, 0xb0, 0xb2, 0x20, 0xc1, 0xb0, 0xfb, 0xff, 0xff, 0xba,
0x00, 0x80, 0xbd, 0xe8, 0xf0, 0x47, 0x2d, 0xe9, 0x01, 0x04, 0x12, 0xe3,
0x02, 0x36, 0xa0, 0xe1, 0x23, 0x25, 0x81, 0xe0, 0x0b, 0x00, 0x00, 0x0a,
0x00, 0x30, 0x90, 0xe5, 0x03, 0x40, 0xa0, 0xe1, 0x03, 0x50, 0xa0, 0xe1,
0x03, 0x60, 0xa0, 0xe1, 0x03, 0x70, 0xa0, 0xe1, 0x03, 0x80, 0xa0, 0xe1,
0x03, 0x90, 0xa0, 0xe1, 0x03, 0xa0, 0xa0, 0xe1, 0x02, 0x00, 0x51, 0xe1,
0xf8, 0x07, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba, 0x03, 0x00, 0x00, 0xea,
0x02, 0x00, 0x51, 0xe1, 0xf8, 0x07, 0xb0, 0xb8, 0xf8, 0x07, 0xa1, 0xb8,
0xfb, 0xff, 0xff, 0xba, 0xf0, 0x87, 0xbd, 0xe8
};

View File

@ -51,7 +51,9 @@ void GBAInputProfileSave(const struct GBAInputMap*, uint32_t type, struct Config
const char* GBAInputGetPreferredDevice(const struct Configuration*, uint32_t type, int playerId);
void GBAInputSetPreferredDevice(struct Configuration*, uint32_t type, int playerId, const char* deviceName);
const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t type, const char* key, const char* profile);
void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const char* key, const char* value, const char* profile);
const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t type, const char* key,
const char* profile);
void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const char* key, const char* value,
const char* profile);
#endif

View File

@ -273,7 +273,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
if ((address & (SIZE_CART0 - 1)) < memory->romSize) {
break;
}
// Fall through
// Fall through
default:
memory->activeRegion = -1;
cpu->memory.activeRegion = _deadbeef;
@ -481,7 +481,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
LOAD_16(value, address & (SIZE_CART0 - 2), memory->rom);
} else {
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
value = (address >> 1) & 0xFFFF; \
value = (address >> 1) & 0xFFFF;
}
break;
case REGION_CART2_EX:
@ -492,7 +492,7 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
LOAD_16(value, address & (SIZE_CART0 - 2), memory->rom);
} else {
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load16: 0x%08X", address);
value = (address >> 1) & 0xFFFF; \
value = (address >> 1) & 0xFFFF;
}
break;
case REGION_CART_SRAM:
@ -576,7 +576,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
value = ((uint8_t*) memory->rom)[address & (SIZE_CART0 - 1)];
} else {
GBALog(gba, GBA_LOG_GAME_ERROR, "Out of bounds ROM Load8: 0x%08X", address);
value = (address >> 1) & 0xFF; \
value = (address >> 1) & 0xFF;
}
break;
case REGION_CART_SRAM:
@ -1266,7 +1266,7 @@ void GBAAdjustWaitstates(struct GBA* gba, uint16_t parameters) {
int ws2seq = (parameters & 0x0400) >> 10;
int prefetch = parameters & 0x4000;
memory->waitstatesNonseq16[REGION_CART_SRAM] = memory->waitstatesNonseq16[REGION_CART_SRAM_MIRROR] = GBA_ROM_WAITSTATES[sram];
memory->waitstatesNonseq16[REGION_CART_SRAM] = memory->waitstatesNonseq16[REGION_CART_SRAM_MIRROR] = GBA_ROM_WAITSTATES[sram];
memory->waitstatesSeq16[REGION_CART_SRAM] = memory->waitstatesSeq16[REGION_CART_SRAM_MIRROR] = GBA_ROM_WAITSTATES[sram];
memory->waitstatesNonseq32[REGION_CART_SRAM] = memory->waitstatesNonseq32[REGION_CART_SRAM_MIRROR] = 2 * GBA_ROM_WAITSTATES[sram] + 1;
memory->waitstatesSeq32[REGION_CART_SRAM] = memory->waitstatesSeq32[REGION_CART_SRAM_MIRROR] = 2 * GBA_ROM_WAITSTATES[sram] + 1;

View File

@ -86,7 +86,6 @@ enum DMATiming {
DMA_TIMING_CUSTOM = 3
};
DECL_BITFIELD(GBADMARegister, uint16_t);
DECL_BITS(GBADMARegister, DestControl, 5, 2);
DECL_BITS(GBADMARegister, SrcControl, 7, 2);
@ -159,8 +158,10 @@ void GBAPatch32(struct ARMCore* cpu, uint32_t address, int32_t value, int32_t* o
void GBAPatch16(struct ARMCore* cpu, uint32_t address, int16_t value, int16_t* old);
void GBAPatch8(struct ARMCore* cpu, uint32_t address, int8_t value, int8_t* old);
uint32_t GBALoadMultiple(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction, int* cycleCounter);
uint32_t GBAStoreMultiple(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction, int* cycleCounter);
uint32_t GBALoadMultiple(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction,
int* cycleCounter);
uint32_t GBAStoreMultiple(struct ARMCore*, uint32_t baseAddress, int mask, enum LSMDirection direction,
int* cycleCounter);
void GBAAdjustWaitstates(struct GBA* gba, uint16_t parameters);

View File

@ -14,11 +14,16 @@
#define VIDEO_CHECKS true
#endif
void GBAVideoSoftwareRendererDrawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode2(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode3(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode4(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode5(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer,
struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode2(struct GBAVideoSoftwareRenderer* renderer,
struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode3(struct GBAVideoSoftwareRenderer* renderer,
struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode4(struct GBAVideoSoftwareRenderer* renderer,
struct GBAVideoSoftwareBackground* background, int y);
void GBAVideoSoftwareRendererDrawBackgroundMode5(struct GBAVideoSoftwareRenderer* renderer,
struct GBAVideoSoftwareBackground* background, int y);
int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj* sprite, int y);
void GBAVideoSoftwareRendererPostprocessSprite(struct GBAVideoSoftwareRenderer* renderer, unsigned priority);
@ -58,22 +63,24 @@ static inline void _compositeBlendNoObjwin(struct GBAVideoSoftwareRenderer* rend
*pixel = color;
}
static inline void _compositeNoBlendObjwin(struct GBAVideoSoftwareRenderer* renderer, uint32_t* pixel, uint32_t color, uint32_t current) {
static inline void _compositeNoBlendObjwin(struct GBAVideoSoftwareRenderer* renderer, uint32_t* pixel, uint32_t color,
uint32_t current) {
UNUSED(renderer);
if (color < current) {
*pixel = color | (current & FLAG_OBJWIN);
}
}
static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* renderer, uint32_t* pixel, uint32_t color, uint32_t current) {
static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* renderer, uint32_t* pixel, uint32_t color,
uint32_t current) {
UNUSED(renderer);
if (color < current) {
*pixel = color;
}
}
#define COMPOSITE_16_OBJWIN(BLEND) \
if (objwinForceEnable || !(current & FLAG_OBJWIN) == objwinOnly) { \
#define COMPOSITE_16_OBJWIN(BLEND) \
if (objwinForceEnable || !(current & FLAG_OBJWIN) == objwinOnly) { \
unsigned color = (current & FLAG_OBJWIN) ? objwinPalette[paletteData | pixelData] : palette[pixelData]; \
unsigned mergedFlags = flags; \
if (current & FLAG_OBJWIN) { \
@ -115,78 +122,86 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
tileData >>= 8;
// TODO: Remove UNUSEDs after implementing OBJWIN for modes 3 - 5
#define PREPARE_OBJWIN \
int objwinSlowPath = GBARegisterDISPCNTIsObjwinEnable(renderer->dispcnt); \
int objwinOnly = 0; \
int objwinForceEnable = 0; \
UNUSED(objwinForceEnable); \
color_t* objwinPalette = renderer->normalPalette; \
UNUSED(objwinPalette); \
if (objwinSlowPath) { \
if (background->target1 && GBAWindowControlIsBlendEnable(renderer->objwin.packed) && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN)) { \
objwinPalette = renderer->variantPalette; \
} \
switch (background->index) { \
case 0: \
objwinForceEnable = GBAWindowControlIsBg0Enable(renderer->objwin.packed) && GBAWindowControlIsBg0Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg0Enable(renderer->objwin.packed); \
break; \
case 1: \
objwinForceEnable = GBAWindowControlIsBg1Enable(renderer->objwin.packed) && GBAWindowControlIsBg1Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg1Enable(renderer->objwin.packed); \
break; \
case 2: \
objwinForceEnable = GBAWindowControlIsBg2Enable(renderer->objwin.packed) && GBAWindowControlIsBg2Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg2Enable(renderer->objwin.packed); \
break; \
case 3: \
objwinForceEnable = GBAWindowControlIsBg3Enable(renderer->objwin.packed) && GBAWindowControlIsBg3Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg3Enable(renderer->objwin.packed); \
break; \
} \
#define PREPARE_OBJWIN \
int objwinSlowPath = GBARegisterDISPCNTIsObjwinEnable(renderer->dispcnt); \
int objwinOnly = 0; \
int objwinForceEnable = 0; \
UNUSED(objwinForceEnable); \
color_t* objwinPalette = renderer->normalPalette; \
UNUSED(objwinPalette); \
if (objwinSlowPath) { \
if (background->target1 && GBAWindowControlIsBlendEnable(renderer->objwin.packed) && \
(renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN)) { \
objwinPalette = renderer->variantPalette; \
} \
switch (background->index) { \
case 0: \
objwinForceEnable = GBAWindowControlIsBg0Enable(renderer->objwin.packed) && \
GBAWindowControlIsBg0Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg0Enable(renderer->objwin.packed); \
break; \
case 1: \
objwinForceEnable = GBAWindowControlIsBg1Enable(renderer->objwin.packed) && \
GBAWindowControlIsBg1Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg1Enable(renderer->objwin.packed); \
break; \
case 2: \
objwinForceEnable = GBAWindowControlIsBg2Enable(renderer->objwin.packed) && \
GBAWindowControlIsBg2Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg2Enable(renderer->objwin.packed); \
break; \
case 3: \
objwinForceEnable = GBAWindowControlIsBg3Enable(renderer->objwin.packed) && \
GBAWindowControlIsBg3Enable(renderer->currentWindow.packed); \
objwinOnly = !GBAWindowControlIsBg3Enable(renderer->objwin.packed); \
break; \
} \
}
#define BACKGROUND_BITMAP_INIT \
int32_t x = background->sx + (renderer->start - 1) * background->dx; \
int32_t y = background->sy + (renderer->start - 1) * background->dy; \
int mosaicH = 0; \
int mosaicWait = 0; \
if (background->mosaic) { \
int mosaicV = GBAMosaicControlGetBgV(renderer->mosaic) + 1; \
y -= (inY % mosaicV) * background->dmy; \
x -= (inY % mosaicV) * background->dmx; \
mosaicH = GBAMosaicControlGetBgH(renderer->mosaic); \
mosaicWait = renderer->start % (mosaicH + 1); \
} \
int32_t localX; \
int32_t localY; \
\
#define BACKGROUND_BITMAP_INIT \
int32_t x = background->sx + (renderer->start - 1) * background->dx; \
int32_t y = background->sy + (renderer->start - 1) * background->dy; \
int mosaicH = 0; \
int mosaicWait = 0; \
if (background->mosaic) { \
int mosaicV = GBAMosaicControlGetBgV(renderer->mosaic) + 1; \
y -= (inY % mosaicV) * background->dmy; \
x -= (inY % mosaicV) * background->dmx; \
mosaicH = GBAMosaicControlGetBgH(renderer->mosaic); \
mosaicWait = renderer->start % (mosaicH + 1); \
} \
int32_t localX; \
int32_t localY; \
\
int flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \
flags |= FLAG_TARGET_2 * background->target2; \
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \
objwinFlags |= flags; \
flags |= FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed)); \
if (renderer->blda == 0x10 && renderer->bldb == 0) { \
flags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
objwinFlags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
} \
int variant = background->target1 && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); \
color_t* palette = renderer->normalPalette; \
if (variant) { \
palette = renderer->variantPalette; \
} \
UNUSED(palette); \
flags |= FLAG_TARGET_2 * background->target2; \
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \
GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \
objwinFlags |= flags; \
flags |= FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \
GBAWindowControlIsBlendEnable(renderer->currentWindow.packed)); \
if (renderer->blda == 0x10 && renderer->bldb == 0) { \
flags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
objwinFlags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
} \
int variant = background->target1 && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && \
(renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); \
color_t* palette = renderer->normalPalette; \
if (variant) { \
palette = renderer->variantPalette; \
} \
UNUSED(palette); \
PREPARE_OBJWIN;
#define BACKGROUND_BITMAP_ITERATE(W, H) \
x += background->dx; \
y += background->dy; \
\
#define BACKGROUND_BITMAP_ITERATE(W, H) \
x += background->dx; \
y += background->dy; \
\
if (x < 0 || y < 0 || (x >> 8) >= W || (y >> 8) >= H) { \
continue; \
} else { \
localX = x; \
localY = y; \
continue; \
} else { \
localX = x; \
localY = y; \
}
static inline unsigned _brighten(unsigned color, int y) {

View File

@ -291,20 +291,20 @@ bool GBASaveStateNamed(struct GBA* gba, struct VFile* vf, bool screenshot) {
vf->unmap(vf, state, sizeof(struct GBASerializedState));
return true;
}
#ifdef USE_PNG
#ifdef USE_PNG
else {
return _savePNGState(gba, vf);
}
#endif
#endif
return false;
}
bool GBALoadStateNamed(struct GBA* gba, struct VFile* vf) {
#ifdef USE_PNG
#ifdef USE_PNG
if (isPNG(vf)) {
return _loadPNGState(gba, vf);
}
#endif
#endif
if (vf->size(vf) < (ssize_t) sizeof(struct GBASerializedState)) {
return false;
}

View File

@ -123,7 +123,7 @@ bool GBASavedataImportSharkPort(struct GBA* gba, struct VFile* vf, bool testChec
if (copySize > SIZE_CART_FLASH512) {
GBASavedataForceType(&gba->memory.savedata, SAVEDATA_FLASH1M, gba->memory.savedata.realisticTiming);
}
// Fall through
// Fall through
case SAVEDATA_FLASH1M:
if (copySize > SIZE_CART_FLASH1M) {
copySize = SIZE_CART_FLASH1M;
@ -149,7 +149,6 @@ cleanup:
return false;
}
bool GBASavedataExportSharkPort(const struct GBA* gba, struct VFile* vf) {
union {
char c[0x1C];

View File

@ -8,7 +8,7 @@
#include "gba/gba.h"
#include "gba/hardware.h"
#include "util/configuration.h"
#include "util/configuration.h"
static const struct GBACartridgeOverride _overrides[] = {
// Advance Wars

View File

@ -108,7 +108,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
struct Patch patch;
struct GBACheatDevice cheatDevice;
struct GBAThread* threadContext = context;
struct ARMComponent* components[GBA_COMPONENT_MAX] = {0};
struct ARMComponent* components[GBA_COMPONENT_MAX] = { 0 };
struct GBARRContext* movie = 0;
int numComponents = GBA_COMPONENT_MAX;
@ -701,7 +701,7 @@ void GBAThreadReplaceROM(struct GBAThread* threadContext, const char* fname) {
}
GBAThreadLoadROM(threadContext, fname);
if(threadContext->gameDir) {
if (threadContext->gameDir) {
_loadGameDir(threadContext);
}

View File

@ -253,7 +253,6 @@ static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, un
// Nothing to do
}
void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* state) {
memcpy(state->vram, video->renderer->vram, SIZE_VRAM);
memcpy(state->oam, video->oam.raw, SIZE_OAM);

View File

@ -65,7 +65,6 @@ DECL_BIT(GBAObjAttributesA, Mosaic, 12);
DECL_BIT(GBAObjAttributesA, 256Color, 13);
DECL_BITS(GBAObjAttributesA, Shape, 14, 2);
DECL_BITFIELD(GBAObjAttributesB, uint16_t);
DECL_BITS(GBAObjAttributesB, X, 0, 9);
DECL_BITS(GBAObjAttributesB, MatIndex, 9, 5);

View File

@ -46,7 +46,8 @@ struct GraphicsOpts {
struct GBAThread;
bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int argc, char* const* argv, struct SubParser* subparser);
bool parseArguments(struct GBAArguments* opts, struct GBAConfig* config, int argc, char* const* argv,
struct SubParser* subparser);
void freeArguments(struct GBAArguments* opts);
void usage(const char* arg0, const char* extraOptions);

View File

@ -248,9 +248,9 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) {
avcodec_fill_audio_frame(encoder->audioFrame, encoder->audio->channels, encoder->audio->sample_fmt, (const uint8_t*) encoder->postaudioBuffer, encoder->postaudioBufferSize, 0);
if (encoder->audio->codec->id == AV_CODEC_ID_AAC &&
(strcasecmp(encoder->containerFormat, "mp4") ||
strcasecmp(encoder->containerFormat, "m4v") ||
strcasecmp(encoder->containerFormat, "mov"))) {
(strcasecmp(encoder->containerFormat, "mp4") ||
strcasecmp(encoder->containerFormat, "m4v") ||
strcasecmp(encoder->containerFormat, "mov"))) {
// MP4 container doesn't support the raw ADTS AAC format that the encoder spits out
encoder->absf = av_bitstream_filter_init("aac_adtstoasc");
}
@ -292,19 +292,19 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) {
encoder->scaleContext = sws_getContext(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS,
#ifdef COLOR_16_BIT
#ifdef COLOR_5_6_5
AV_PIX_FMT_RGB565,
AV_PIX_FMT_RGB565,
#else
AV_PIX_FMT_BGR555,
AV_PIX_FMT_BGR555,
#endif
#else
#ifndef USE_LIBAV
AV_PIX_FMT_0BGR32,
AV_PIX_FMT_0BGR32,
#else
AV_PIX_FMT_BGR32,
AV_PIX_FMT_BGR32,
#endif
#endif
encoder->videoFrame->width, encoder->videoFrame->height, encoder->video->pix_fmt,
SWS_POINT, 0, 0, 0);
encoder->videoFrame->width, encoder->videoFrame->height, encoder->video->pix_fmt,
SWS_POINT, 0, 0, 0);
av_image_alloc(encoder->videoFrame->data, encoder->videoFrame->linesize, encoder->video->width, encoder->video->height, encoder->video->pix_fmt, 32);
avio_open(&encoder->context->pb, outfile, AVIO_FLAG_WRITE);
@ -378,8 +378,8 @@ void _ffmpegPostAudioFrame(struct GBAAVStream* stream, int16_t left, int16_t rig
int channelSize = 2 * av_get_bytes_per_sample(encoder->audio->sample_fmt);
avresample_convert(encoder->resampleContext,
0, 0, 0,
(uint8_t**) &encoder->audioBuffer, 0, encoder->audioBufferSize / 4);
0, 0, 0,
(uint8_t**) &encoder->audioBuffer, 0, encoder->audioBufferSize / 4);
if (avresample_available(encoder->resampleContext) < encoder->audioFrame->nb_samples) {
return;
}
@ -402,8 +402,8 @@ void _ffmpegPostAudioFrame(struct GBAAVStream* stream, int16_t left, int16_t rig
if (encoder->absf) {
AVPacket tempPacket = packet;
int success = av_bitstream_filter_filter(encoder->absf, encoder->audio, 0,
&tempPacket.data, &tempPacket.size,
packet.data, packet.size, 0);
&tempPacket.data, &tempPacket.size,
packet.data, packet.size, 0);
if (success > 0) {
#if LIBAVUTIL_VERSION_MAJOR >= 53
tempPacket.buf = av_buffer_create(tempPacket.data, tempPacket.size, av_buffer_default_free, 0, 0);

View File

@ -58,7 +58,7 @@ static void _magickPostVideoFrame(struct GBAAVStream* stream, struct GBAVideoRen
renderer->getPixels(renderer, &stride, (void**) &pixels);
size_t row;
for (row = 0; row < VIDEO_VERTICAL_PIXELS; ++row) {
memcpy(&encoder->frame[row * VIDEO_HORIZONTAL_PIXELS], &pixels[row * 4 *stride], VIDEO_HORIZONTAL_PIXELS * 4);
memcpy(&encoder->frame[row * VIDEO_HORIZONTAL_PIXELS], &pixels[row * 4 * stride], VIDEO_HORIZONTAL_PIXELS * 4);
}
MagickConstituteImage(encoder->wand, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, "RGBP", CharPixel, encoder->frame);

View File

@ -78,7 +78,7 @@ void GBAGLContextDrawFrame(struct VideoBackend* v) {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_INT, 0, _glVertices);
glTexCoordPointer(2, GL_INT, 0, _glTexCoords);
glMatrixMode (GL_PROJECTION);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);

View File

@ -104,7 +104,7 @@ QModelIndex CheatsModel::parent(const QModelIndex& index) const {
return QModelIndex();
}
Qt::ItemFlags CheatsModel::flags(const QModelIndex &index) const {
Qt::ItemFlags CheatsModel::flags(const QModelIndex& index) const {
if (!index.isValid()) {
return 0;
}
@ -152,7 +152,6 @@ void CheatsModel::removeAt(const QModelIndex& index) {
GBACheatSetDeinit(set);
delete set;
endInsertRows();
}
QString CheatsModel::toString(const QModelIndexList& indices) const {

View File

@ -27,7 +27,7 @@ public:
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
GBACheatSet* itemAt(const QModelIndex& index);
void removeAt(const QModelIndex& index);

View File

@ -80,7 +80,7 @@ void ConfigOption::setValue(const char* value) {
void ConfigOption::setValue(const QVariant& value) {
QPair<QAction*, QVariant> action;
foreach(action, m_actions) {
foreach (action, m_actions) {
bool signalsEnabled = action.first->blockSignals(true);
action.first->setChecked(value == action.second);
action.first->blockSignals(signalsEnabled);

View File

@ -46,7 +46,8 @@ protected:
private:
class FileDialog : public QFileDialog {
public:
FileDialog(GBAApp* app, QWidget* parent = nullptr, const QString& caption = QString(), const QString& filter = QString());
FileDialog(GBAApp* app, QWidget* parent = nullptr, const QString& caption = QString(),
const QString& filter = QString());
virtual int exec() override;
private:

View File

@ -205,7 +205,7 @@ void GBAKeyEditor::refresh() {
}
void GBAKeyEditor::lookupBinding(const GBAInputMap* map, KeyEditor* keyEditor, GBAKey key) {
#ifdef BUILD_SDL
#ifdef BUILD_SDL
if (m_type == SDL_BINDING_BUTTON) {
int value = GBAInputQueryBinding(map, m_type, key);
if (value != GBA_NO_MAPPING) {
@ -213,7 +213,7 @@ void GBAKeyEditor::lookupBinding(const GBAInputMap* map, KeyEditor* keyEditor, G
}
return;
}
#endif
#endif
keyEditor->setValueKey(GBAInputQueryBinding(map, m_type, key));
}
@ -304,5 +304,6 @@ KeyEditor* GBAKeyEditor::keyById(GBAKey key) {
void GBAKeyEditor::setLocation(QWidget* widget, qreal x, qreal y) {
QSize s = size();
QSize hint = widget->sizeHint();
widget->setGeometry(s.width() * x - hint.width() / 2.0, s.height() * y - hint.height() / 2.0, hint.width(), hint.height());
widget->setGeometry(s.width() * x - hint.width() / 2.0, s.height() * y - hint.height() / 2.0, hint.width(),
hint.height());
}

View File

@ -44,7 +44,7 @@ void GDBController::attach() {
ARMDebuggerEnter(&m_gdbStub.d, DEBUGGER_ENTER_ATTACHED, 0);
} else {
QObject::disconnect(m_autoattach);
m_autoattach = connect(m_gameController, &GameController::gameStarted, [this] () {
m_autoattach = connect(m_gameController, &GameController::gameStarted, [this]() {
QObject::disconnect(m_autoattach);
ARMDebuggerEnter(&m_gdbStub.d, DEBUGGER_ENTER_ATTACHED, 0);
});

View File

@ -106,9 +106,8 @@ void GDBWindow::stopped() {
}
void GDBWindow::failed() {
QMessageBox* failure = new QMessageBox(QMessageBox::Warning, tr("Crash"),
tr("Could not start GDB server"),
QMessageBox::Ok, this, Qt::Sheet);
QMessageBox* failure = new QMessageBox(QMessageBox::Warning, tr("Crash"), tr("Could not start GDB server"),
QMessageBox::Ok, this, Qt::Sheet);
failure->setAttribute(Qt::WA_DeleteOnClose);
failure->show();
}

View File

@ -70,12 +70,12 @@ GameController::GameController(QObject* parent)
m_threadContext.logLevel = GBA_LOG_ALL;
m_lux.p = this;
m_lux.sample = [] (GBALuminanceSource* context) {
m_lux.sample = [](GBALuminanceSource* context) {
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
lux->value = 0xFF - lux->p->m_luxValue;
};
m_lux.readLuminance = [] (GBALuminanceSource* context) {
m_lux.readLuminance = [](GBALuminanceSource* context) {
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
return lux->value;
};
@ -83,8 +83,8 @@ GameController::GameController(QObject* parent)
m_rtc.p = this;
m_rtc.override = GameControllerRTC::NO_OVERRIDE;
m_rtc.sample = [] (GBARTCSource* context) { };
m_rtc.unixTime = [] (GBARTCSource* context) -> time_t {
m_rtc.sample = [](GBARTCSource* context) {};
m_rtc.unixTime = [](GBARTCSource* context) -> time_t {
GameControllerRTC* rtc = static_cast<GameControllerRTC*>(context);
switch (rtc->override) {
case GameControllerRTC::NO_OVERRIDE:
@ -97,7 +97,7 @@ GameController::GameController(QObject* parent)
}
};
m_threadContext.startCallback = [] (GBAThread* context) {
m_threadContext.startCallback = [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
controller->m_audioProcessor->setInput(context);
context->gba->luminanceSource = &controller->m_lux;
@ -108,12 +108,12 @@ GameController::GameController(QObject* parent)
controller->gameStarted(context);
};
m_threadContext.cleanCallback = [] (GBAThread* context) {
m_threadContext.cleanCallback = [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
controller->gameStopped(context);
};
m_threadContext.frameCallback = [] (GBAThread* context) {
m_threadContext.frameCallback = [](GBAThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
if (controller->m_pauseAfterFrame.testAndSetAcquire(true, false)) {
GBAThreadPauseFromThread(context);
@ -126,7 +126,7 @@ GameController::GameController(QObject* parent)
}
};
m_threadContext.logHandler = [] (GBAThread* context, enum GBALogLevel level, const char* format, va_list args) {
m_threadContext.logHandler = [](GBAThread* context, enum GBALogLevel level, const char* format, va_list args) {
static const char* stubMessage = "Stub software interrupt";
if (!context) {
return;
@ -324,7 +324,6 @@ void GameController::yankPak() {
threadContinue();
}
void GameController::replaceGame(const QString& path) {
if (!m_gameOpen) {
return;

View File

@ -16,7 +16,7 @@ namespace QGBA {
class InputController;
class GamepadAxisEvent : public QEvent {
class GamepadAxisEvent : public QEvent {
public:
enum Direction {
NEUTRAL = 0,

View File

@ -16,7 +16,7 @@ namespace QGBA {
class InputController;
class GamepadButtonEvent : public QEvent {
class GamepadButtonEvent : public QEvent {
public:
GamepadButtonEvent(Type pressType, int button, int type, InputController* controller = nullptr);

View File

@ -195,9 +195,12 @@ void MemoryModel::paintEvent(QPaintEvent* event) {
static QString arg("%0");
QSizeF letterSize = QSizeF(m_letterWidth, m_cellHeight);
painter.drawStaticText(QPointF((m_margins.left() - m_regionName.size().width() - 1) / 2.0, 0), m_regionName);
painter.drawText(QRect(QPoint(viewport()->size().width() - m_margins.right(), 0), QSize(m_margins.right(), m_margins.top())), Qt::AlignHCenter, tr("ASCII"));
painter.drawText(
QRect(QPoint(viewport()->size().width() - m_margins.right(), 0), QSize(m_margins.right(), m_margins.top())),
Qt::AlignHCenter, tr("ASCII"));
for (int x = 0; x < 16; ++x) {
painter.drawText(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), 0), m_cellSize), Qt::AlignHCenter, QString::number(x, 16).toUpper());
painter.drawText(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), 0), m_cellSize), Qt::AlignHCenter,
QString::number(x, 16).toUpper());
}
int height = (viewport()->size().height() - m_cellHeight) / m_cellHeight;
for (int y = 0; y < height; ++y) {
@ -209,38 +212,56 @@ void MemoryModel::paintEvent(QPaintEvent* event) {
for (int x = 0; x < 16; x += 2) {
uint32_t address = (y + m_top) * 16 + x + m_base;
if (isInSelection(address)) {
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp), QSizeF(m_cellSize.width() * 2, m_cellSize.height())), palette.highlight());
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp),
QSizeF(m_cellSize.width() * 2, m_cellSize.height())),
palette.highlight());
painter.setPen(palette.color(QPalette::HighlightedText));
if (isEditing(address)) {
drawEditingText(painter, QPointF(m_cellSize.width() * (x + 1.0) - 2 * m_letterWidth + m_margins.left(), yp));
drawEditingText(
painter,
QPointF(m_cellSize.width() * (x + 1.0) - 2 * m_letterWidth + m_margins.left(), yp));
continue;
}
} else {
painter.setPen(palette.color(QPalette::WindowText));
}
uint16_t b = m_cpu->memory.load16(m_cpu, address, nullptr);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 1.0) - 2 * m_letterWidth + m_margins.left(), yp), m_staticNumbers[(b >> 8) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 1.0) + m_margins.left(), yp), m_staticNumbers[b & 0xFF]);
painter.drawStaticText(
QPointF(m_cellSize.width() * (x + 1.0) - 2 * m_letterWidth + m_margins.left(), yp),
m_staticNumbers[(b >> 8) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 1.0) + m_margins.left(), yp),
m_staticNumbers[b & 0xFF]);
}
break;
case 4:
for (int x = 0; x < 16; x += 4) {
uint32_t address = (y + m_top) * 16 + x + m_base;
if (isInSelection(address)) {
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp), QSizeF(m_cellSize.width() * 4, m_cellSize.height())), palette.highlight());
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp),
QSizeF(m_cellSize.width() * 4, m_cellSize.height())),
palette.highlight());
painter.setPen(palette.color(QPalette::HighlightedText));
if (isEditing(address)) {
drawEditingText(painter, QPointF(m_cellSize.width() * (x + 2.0) - 4 * m_letterWidth + m_margins.left(), yp));
drawEditingText(
painter,
QPointF(m_cellSize.width() * (x + 2.0) - 4 * m_letterWidth + m_margins.left(), yp));
continue;
}
} else {
painter.setPen(palette.color(QPalette::WindowText));
}
uint32_t b = m_cpu->memory.load32(m_cpu, address, nullptr);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 2.0) - 4 * m_letterWidth + m_margins.left(), yp), m_staticNumbers[(b >> 24) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 2.0) - 2 * m_letterWidth + m_margins.left(), yp), m_staticNumbers[(b >> 16) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 2.0) + m_margins.left(), yp), m_staticNumbers[(b >> 8) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 2.0) + 2 * m_letterWidth + m_margins.left(), yp), m_staticNumbers[b & 0xFF]);
painter.drawStaticText(
QPointF(m_cellSize.width() * (x + 2.0) - 4 * m_letterWidth + m_margins.left(), yp),
m_staticNumbers[(b >> 24) & 0xFF]);
painter.drawStaticText(
QPointF(m_cellSize.width() * (x + 2.0) - 2 * m_letterWidth + m_margins.left(), yp),
m_staticNumbers[(b >> 16) & 0xFF]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 2.0) + m_margins.left(), yp),
m_staticNumbers[(b >> 8) & 0xFF]);
painter.drawStaticText(
QPointF(m_cellSize.width() * (x + 2.0) + 2 * m_letterWidth + m_margins.left(), yp),
m_staticNumbers[b & 0xFF]);
}
break;
case 1:
@ -248,28 +269,34 @@ void MemoryModel::paintEvent(QPaintEvent* event) {
for (int x = 0; x < 16; ++x) {
uint32_t address = (y + m_top) * 16 + x + m_base;
if (isInSelection(address)) {
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp), m_cellSize), palette.highlight());
painter.fillRect(QRectF(QPointF(m_cellSize.width() * x + m_margins.left(), yp), m_cellSize),
palette.highlight());
painter.setPen(palette.color(QPalette::HighlightedText));
if (isEditing(address)) {
drawEditingText(painter, QPointF(m_cellSize.width() * (x + 0.5) - m_letterWidth + m_margins.left(), yp));
drawEditingText(painter,
QPointF(m_cellSize.width() * (x + 0.5) - m_letterWidth + m_margins.left(), yp));
continue;
}
} else {
painter.setPen(palette.color(QPalette::WindowText));
}
uint8_t b = m_cpu->memory.load8(m_cpu, address, nullptr);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 0.5) - m_letterWidth + m_margins.left(), yp), m_staticNumbers[b]);
painter.drawStaticText(QPointF(m_cellSize.width() * (x + 0.5) - m_letterWidth + m_margins.left(), yp),
m_staticNumbers[b]);
}
break;
}
painter.setPen(palette.color(QPalette::WindowText));
for (int x = 0; x < 16; ++x) {
uint8_t b = m_cpu->memory.load8(m_cpu, (y + m_top) * 16 + x + m_base, nullptr);
painter.drawStaticText(QPointF(viewport()->size().width() - (16 - x) * m_margins.right() / 17.0 - m_letterWidth * 0.5, yp), b < 0x80 ? m_staticAscii[b] : m_staticAscii[0]);
painter.drawStaticText(
QPointF(viewport()->size().width() - (16 - x) * m_margins.right() / 17.0 - m_letterWidth * 0.5, yp),
b < 0x80 ? m_staticAscii[b] : m_staticAscii[0]);
}
}
painter.drawLine(m_margins.left(), 0, m_margins.left(), viewport()->size().height());
painter.drawLine(viewport()->size().width() - m_margins.right(), 0, viewport()->size().width() - m_margins.right(), viewport()->size().height());
painter.drawLine(viewport()->size().width() - m_margins.right(), 0, viewport()->size().width() - m_margins.right(),
viewport()->size().height());
painter.drawLine(0, m_margins.top(), viewport()->size().width(), m_margins.top());
}
@ -282,13 +309,15 @@ void MemoryModel::wheelEvent(QWheelEvent* event) {
}
void MemoryModel::mousePressEvent(QMouseEvent* event) {
if (event->x() < m_margins.left() || event->y() < m_margins.top() || event->x() > size().width() - m_margins.right()) {
if (event->x() < m_margins.left() || event->y() < m_margins.top() ||
event->x() > size().width() - m_margins.right()) {
m_selection = qMakePair(0, 0);
return;
}
QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top()));
uint32_t address = int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
uint32_t address =
int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
if (event->button() == Qt::RightButton && isInSelection(address)) {
return;
}
@ -301,12 +330,14 @@ void MemoryModel::mousePressEvent(QMouseEvent* event) {
}
void MemoryModel::mouseMoveEvent(QMouseEvent* event) {
if (event->x() < m_margins.left() || event->y() < m_margins.top() || event->x() > size().width() - m_margins.right()) {
if (event->x() < m_margins.left() || event->y() < m_margins.top() ||
event->x() > size().width() - m_margins.right()) {
return;
}
QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top()));
uint32_t address = int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
uint32_t address =
int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base;
if ((address & ~(m_align - 1)) < m_selectionAnchor) {
m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align);
} else {

View File

@ -87,7 +87,8 @@ void OverrideView::updateOverrides() {
m_override.idleLoop = parsedIdleLoop;
}
if (m_override.savetype != SAVEDATA_AUTODETECT || m_override.hardware != HW_NO_OVERRIDE || m_override.idleLoop != IDLE_LOOP_NONE) {
if (m_override.savetype != SAVEDATA_AUTODETECT || m_override.hardware != HW_NO_OVERRIDE ||
m_override.idleLoop != IDLE_LOOP_NONE) {
m_controller->setOverride(m_override);
} else {
m_controller->clearOverride();
@ -119,7 +120,6 @@ void OverrideView::gameStarted(GBAThread* thread) {
m_ui.idleLoop->setText(QString::number(thread->gba->idleLoop, 16));
} else {
m_ui.idleLoop->clear();
}
GBAGetGameCode(thread->gba, m_override.id);

View File

@ -84,7 +84,8 @@ void PaletteView::exportPalette(int start, int length) {
length = 512 - start;
}
m_controller->threadInterrupt();
QFileDialog* dialog = GBAApp::app()->getSaveFileDialog(this, tr("Export palette"), tr("Windows PAL (*.pal);;Adobe Color Table (*.act)"));
QFileDialog* dialog = GBAApp::app()->getSaveFileDialog(this, tr("Export palette"),
tr("Windows PAL (*.pal);;Adobe Color Table (*.act)"));
if (!dialog->exec()) {
m_controller->threadContinue();
return;

View File

@ -91,7 +91,8 @@ bool SensorView::eventFilter(QObject*, QEvent* event) {
void SensorView::updateSensors() {
m_controller->threadInterrupt();
if (m_rotation->sample && (!m_controller->isLoaded() || !(m_controller->thread()->gba->memory.hw.devices & (HW_GYRO | HW_TILT)))) {
if (m_rotation->sample &&
(!m_controller->isLoaded() || !(m_controller->thread()->gba->memory.hw.devices & (HW_GYRO | HW_TILT)))) {
m_rotation->sample(m_rotation);
m_rotation->sample(m_rotation);
m_rotation->sample(m_rotation);

View File

@ -118,10 +118,12 @@ void ShortcutController::addAction(QMenu* menu, QAction* action, const QString&
if (m_config) {
loadShortcuts(item);
}
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item), createIndex(smenu->items().count() - 1, 2, item));
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item),
createIndex(smenu->items().count() - 1, 2, item));
}
void ShortcutController::addFunctions(QMenu* menu, std::function<void ()> press, std::function<void ()> release, const QKeySequence& shortcut, const QString& visibleName, const QString& name) {
void ShortcutController::addFunctions(QMenu* menu, std::function<void()> press, std::function<void()> release,
const QKeySequence& shortcut, const QString& visibleName, const QString& name) {
ShortcutItem* smenu = m_menuMap[menu];
if (!smenu) {
return;
@ -137,7 +139,8 @@ void ShortcutController::addFunctions(QMenu* menu, std::function<void ()> press,
loadShortcuts(item);
}
m_heldKeys[shortcut] = item;
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item), createIndex(smenu->items().count() - 1, 2, item));
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item),
createIndex(smenu->items().count() - 1, 2, item));
}
void ShortcutController::addMenu(QMenu* menu, QMenu* parentMenu) {
@ -155,7 +158,8 @@ void ShortcutController::addMenu(QMenu* menu, QMenu* parentMenu) {
smenu->addSubmenu(menu);
endInsertRows();
ShortcutItem* item = &smenu->items().last();
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item), createIndex(smenu->items().count() - 1, 2, item));
emit dataChanged(createIndex(smenu->items().count() - 1, 0, item),
createIndex(smenu->items().count() - 1, 2, item));
m_menuMap[menu] = item;
}
@ -211,7 +215,8 @@ void ShortcutController::updateKey(const QModelIndex& index, const QKeySequence&
if (m_config) {
m_config->setQtOption(item->name(), keySequence.toString(), KEY_SECTION);
}
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()), createIndex(index.row(), 2, index.internalPointer()));
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()),
createIndex(index.row(), 2, index.internalPointer()));
}
void ShortcutController::updateButton(const QModelIndex& index, int button) {
@ -235,7 +240,8 @@ void ShortcutController::updateButton(const QModelIndex& index, int button) {
if (m_config) {
m_config->setQtOption(item->name(), button, BUTTON_SECTION);
}
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()), createIndex(index.row(), 2, index.internalPointer()));
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()),
createIndex(index.row(), 2, index.internalPointer()));
}
void ShortcutController::updateAxis(const QModelIndex& index, int axis, GamepadAxisEvent::Direction direction) {
@ -267,7 +273,8 @@ void ShortcutController::updateAxis(const QModelIndex& index, int axis, GamepadA
}
m_config->setQtOption(item->name(), QString("%1%2").arg(d).arg(axis), AXIS_SECTION);
}
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()), createIndex(index.row(), 2, index.internalPointer()));
emit dataChanged(createIndex(index.row(), 0, index.internalPointer()),
createIndex(index.row(), 2, index.internalPointer()));
}
void ShortcutController::clearKey(const QModelIndex& index) {
@ -473,7 +480,9 @@ void ShortcutController::ShortcutItem::addAction(QAction* action, const QString&
m_items.append(ShortcutItem(action, name, this));
}
void ShortcutController::ShortcutItem::addFunctions(ShortcutController::ShortcutItem::Functions functions, const QKeySequence& shortcut, const QString& visibleName, const QString& name) {
void ShortcutController::ShortcutItem::addFunctions(ShortcutController::ShortcutItem::Functions functions,
const QKeySequence& shortcut, const QString& visibleName,
const QString& name) {
m_items.append(ShortcutItem(functions, shortcut, visibleName, name, this));
}

View File

@ -35,7 +35,8 @@ private:
typedef QPair<std::function<void ()>, std::function<void ()>> Functions;
ShortcutItem(QAction* action, const QString& name, ShortcutItem* parent = nullptr);
ShortcutItem(Functions functions, const QKeySequence& shortcut, const QString& visibleName, const QString& name, ShortcutItem* parent = nullptr);
ShortcutItem(Functions functions, const QKeySequence& shortcut, const QString& visibleName, const QString& name,
ShortcutItem* parent = nullptr);
ShortcutItem(QMenu* action, ShortcutItem* parent = nullptr);
QAction* action() { return m_action; }
@ -51,7 +52,8 @@ private:
ShortcutItem* parent() { return m_parent; }
const ShortcutItem* parent() const { return m_parent; }
void addAction(QAction* action, const QString& name);
void addFunctions(Functions functions, const QKeySequence& shortcut, const QString& visibleName, const QString& name);
void addFunctions(Functions functions, const QKeySequence& shortcut, const QString& visibleName,
const QString& name);
void addSubmenu(QMenu* menu);
int button() const { return m_button; }
void setShortcut(const QKeySequence& sequence);
@ -60,7 +62,9 @@ private:
GamepadAxisEvent::Direction direction() const { return m_direction; }
void setAxis(int axis, GamepadAxisEvent::Direction direction);
bool operator==(const ShortcutItem& other) const { return m_menu == other.m_menu && m_action == other.m_action; }
bool operator==(const ShortcutItem& other) const {
return m_menu == other.m_menu && m_action == other.m_action;
}
private:
QAction* m_action;
@ -91,7 +95,8 @@ public:
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
void addAction(QMenu* menu, QAction* action, const QString& name);
void addFunctions(QMenu* menu, std::function<void ()> press, std::function<void()> release, const QKeySequence& shortcut, const QString& visibleName, const QString& name);
void addFunctions(QMenu* menu, std::function<void()> press, std::function<void()> release,
const QKeySequence& shortcut, const QString& visibleName, const QString& name);
void addMenu(QMenu* menu, QMenu* parent = nullptr);
QKeySequence shortcutAt(const QModelIndex& index) const;

View File

@ -104,10 +104,10 @@ void ShortcutView::updateButton(int button) {
m_controller->updateButton(m_ui.shortcutTable->selectionModel()->currentIndex(), button);
}
void ShortcutView::updateAxis(int axis, int direction) {
if (!m_controller || m_controller->isMenuAt(m_ui.shortcutTable->selectionModel()->currentIndex())) {
return;
}
m_controller->updateAxis(m_ui.shortcutTable->selectionModel()->currentIndex(), axis, static_cast<GamepadAxisEvent::Direction>(direction));
m_controller->updateAxis(m_ui.shortcutTable->selectionModel()->currentIndex(), axis,
static_cast<GamepadAxisEvent::Direction>(direction));
}

View File

@ -509,7 +509,7 @@ void Window::gameStarted(GBAThread* context) {
attachWidget(m_display);
#ifndef Q_OS_MAC
if(isFullScreen()) {
if (isFullScreen()) {
menuBar()->hide();
}
#endif
@ -532,16 +532,16 @@ void Window::gameStopped() {
void Window::gameCrashed(const QString& errorMessage) {
QMessageBox* crash = new QMessageBox(QMessageBox::Critical, tr("Crash"),
tr("The game has crashed with the following error:\n\n%1").arg(errorMessage),
QMessageBox::Ok, this, Qt::Sheet);
tr("The game has crashed with the following error:\n\n%1").arg(errorMessage),
QMessageBox::Ok, this, Qt::Sheet);
crash->setAttribute(Qt::WA_DeleteOnClose);
crash->show();
}
void Window::gameFailed() {
QMessageBox* fail = new QMessageBox(QMessageBox::Warning, tr("Couldn't Load"),
tr("Could not load game. Are you sure it's in the correct format?"),
QMessageBox::Ok, this, Qt::Sheet);
tr("Could not load game. Are you sure it's in the correct format?"),
QMessageBox::Ok, this, Qt::Sheet);
fail->setAttribute(Qt::WA_DeleteOnClose);
fail->show();
}
@ -552,9 +552,10 @@ void Window::unimplementedBiosCall(int call) {
}
m_hitUnimplementedBiosCall = true;
QMessageBox* fail = new QMessageBox(QMessageBox::Warning, tr("Unimplemented BIOS call"),
tr("This game uses a BIOS call that is not implemented. Please use the official BIOS for best experience."),
QMessageBox::Ok, this, Qt::Sheet);
QMessageBox* fail = new QMessageBox(
QMessageBox::Warning, tr("Unimplemented BIOS call"),
tr("This game uses a BIOS call that is not implemented. Please use the official BIOS for best experience."),
QMessageBox::Ok, this, Qt::Sheet);
fail->setAttribute(Qt::WA_DeleteOnClose);
fail->show();
}
@ -628,7 +629,8 @@ void Window::setupMenu(QMenuBar* menubar) {
QMenu* fileMenu = menubar->addMenu(tr("&File"));
m_shortcutController->addMenu(fileMenu);
installEventFilter(m_shortcutController);
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open), "loadROM");
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &ROM..."), this, SLOT(selectROM()), QKeySequence::Open),
"loadROM");
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &BIOS..."), this, SLOT(selectBIOS())), "loadBIOS");
addControlledAction(fileMenu, fileMenu->addAction(tr("Load &patch..."), this, SLOT(selectPatch())), "loadPatch");
addControlledAction(fileMenu, fileMenu->addAction(tr("Boot BIOS"), m_controller, SLOT(bootBIOS())), "bootBIOS");
@ -733,7 +735,8 @@ void Window::setupMenu(QMenuBar* menubar) {
connect(m_controller, &GameController::gamePaused, [this, pause]() {
pause->setChecked(true);
QImage currentImage(reinterpret_cast<const uchar*>(m_controller->drawContext()), VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGB32);
QImage currentImage(reinterpret_cast<const uchar*>(m_controller->drawContext()), VIDEO_HORIZONTAL_PIXELS,
VIDEO_VERTICAL_PIXELS, 1024, QImage::Format_RGB32);
QPixmap pixmap;
pixmap.convertFromImage(currentImage.rgbSwapped());
m_screenWidget->setPixmap(pixmap);
@ -1010,8 +1013,10 @@ void Window::setupMenu(QMenuBar* menubar) {
#endif
toolsMenu->addSeparator();
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())), "settings");
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Edit shortcuts..."), this, SLOT(openShortcutWindow())), "shortcuts");
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())),
"settings");
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Edit shortcuts..."), this, SLOT(openShortcutWindow())),
"shortcuts");
QAction* keymap = new QAction(tr("Remap keyboard..."), toolsMenu);
connect(keymap, SIGNAL(triggered()), this, SLOT(openKeymapWindow()));

View File

@ -9,12 +9,12 @@
#ifdef QT_STATIC
#include <QtPlugin>
#ifdef _WIN32
Q_IMPORT_PLUGIN (QWindowsIntegrationPlugin);
Q_IMPORT_PLUGIN (QWindowsAudioPlugin);
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
Q_IMPORT_PLUGIN(QWindowsAudioPlugin);
#endif
#endif
int main(int argc, char* argv[]) {
QGBA::GBAApp application(argc, argv);
return application.exec();
QGBA::GBAApp application(argc, argv);
return application.exec();
}

View File

@ -76,7 +76,6 @@ void GBASDLPauseAudio(struct GBASDLAudio* context) {
UNUSED(context);
SDL_PauseAudio(1);
#endif
}
void GBASDLResumeAudio(struct GBASDLAudio* context) {

View File

@ -65,7 +65,7 @@ bool GBASDLSWInit(struct SDLSoftwareRenderer* renderer) {
pixman_format_code_t format = PIXMAN_x8b8g8r8;
#endif
renderer->pix = pixman_image_create_bits(format, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS,
renderer->d.outputBuffer, renderer->d.outputBufferStride * BYTES_PER_PIXEL);
renderer->d.outputBuffer, renderer->d.outputBufferStride * BYTES_PER_PIXEL);
renderer->screenpix = pixman_image_create_bits(format, renderer->viewportWidth, renderer->viewportHeight, surface->pixels, surface->pitch);
pixman_transform_t transform;
@ -104,8 +104,8 @@ void GBASDLSWRunloop(struct GBAThread* context, struct SDLSoftwareRenderer* rend
#ifdef USE_PIXMAN
if (renderer->ratio > 1) {
pixman_image_composite32(PIXMAN_OP_SRC, renderer->pix, 0, renderer->screenpix,
0, 0, 0, 0, 0, 0,
renderer->viewportWidth, renderer->viewportHeight);
0, 0, 0, 0, 0, 0,
renderer->viewportWidth, renderer->viewportHeight);
}
#else
switch (renderer->ratio) {

View File

@ -110,7 +110,6 @@ static inline Socket SocketOpenTCP(int port, const struct Address* bindAddress)
bindInfo.sin6_port = htons(port);
memcpy(bindInfo.sin6_addr.s6_addr, bindAddress->ipv6, sizeof(bindInfo.sin6_addr.s6_addr));
err = bind(sock, (const struct sockaddr*) &bindInfo, sizeof(bindInfo));
}
if (err) {
close(sock);

View File

@ -70,8 +70,10 @@ struct VDir* VDirOpenZip(const char* path, int flags);
struct VDir* VDirOpen7z(const char* path, int flags);
#endif
struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix, int mode);
struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix, const char* infix, const char* suffix, int mode);
struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix,
int mode);
struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix,
const char* infix, const char* suffix, int mode);
ssize_t VFileReadline(struct VFile* vf, char* buffer, size_t size);