diff --git a/CMakeLists.txt b/CMakeLists.txt index a75c86e6e..df03278a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(GBAc) -set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -Wno-unused -Werror") -set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra -Wno-unused -Werror") +set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Wextra -Wno-unused -Werror --std=gnu99") +set(CMAKE_C_FLAGS_RELEASE "-O3 -Wall -Wextra -Wno-unused -Werror --std=gnu99") file(GLOB ARM_SRC ${CMAKE_SOURCE_DIR}/src/arm/*.c) file(GLOB GBA_SRC ${CMAKE_SOURCE_DIR}/src/gba/*.c) file(GLOB RENDERER_SRC ${CMAKE_SOURCE_DIR}/src/gba/renderers/*.c) diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index edf196aa0..ffb5b16b1 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -250,7 +250,7 @@ void ARMStep(struct ARMCore* cpu) { #define ADDR_MODE_3_ADDRESS ADDR_MODE_2_ADDRESS #define ADDR_MODE_3_RN ADDR_MODE_2_RN #define ADDR_MODE_3_RM ADDR_MODE_2_RM -#define ADDR_MODE_3_IMMEDIATE ((opcode & 0x00000F00) >> 4) | (opcode & 0x0000000F) +#define ADDR_MODE_3_IMMEDIATE (((opcode & 0x00000F00) >> 4) | (opcode & 0x0000000F)) #define ADDR_MODE_3_INDEX(U_OP, M) ADDR_MODE_2_INDEX(U_OP, M) #define ADDR_MODE_3_WRITEBACK(ADDR) ADDR_MODE_2_WRITEBACK(ADDR) diff --git a/src/arm/isa-thumb.c b/src/arm/isa-thumb.c index 37372a13f..64e41fd89 100644 --- a/src/arm/isa-thumb.c +++ b/src/arm/isa-thumb.c @@ -281,8 +281,8 @@ DEFINE_DATA_FORM_5_INSTRUCTION_THUMB(MVN, cpu->gprs[rd] = ~cpu->gprs[rn]; THUMB_ #define DEFINE_INSTRUCTION_WITH_HIGH_EX_THUMB(NAME, H1, H2, BODY) \ DEFINE_INSTRUCTION_THUMB(NAME, \ - int rd = opcode & 0x0007 | H1; \ - int rm = (opcode >> 3) & 0x0007 | H2; \ + int rd = (opcode & 0x0007) | H1; \ + int rm = ((opcode >> 3) & 0x0007) | H2; \ BODY;) #define DEFINE_INSTRUCTION_WITH_HIGH_THUMB(NAME, BODY) \ @@ -461,7 +461,7 @@ DEFINE_INSTRUCTION_THUMB(BX, if (rm == ARM_PC) { misalign = cpu->gprs[rm] & 0x00000002; } - cpu->gprs[ARM_PC] = cpu->gprs[rm] & 0xFFFFFFFE - misalign; + cpu->gprs[ARM_PC] = (cpu->gprs[rm] & 0xFFFFFFFE) - misalign; if (cpu->executionMode == MODE_THUMB) { THUMB_WRITE_PC; } else { diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 651ae6f5e..71e90c895 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "linenoise.h" diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 7b21d2dc9..8c43b32dc 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -5,6 +5,7 @@ #include "gba-memory.h" #include +#include static void _unLz77(struct GBAMemory* memory, uint32_t source, uint8_t* dest); diff --git a/src/gba/gba-video.c b/src/gba/gba-video.c index 4ba717af5..8b9a80192 100644 --- a/src/gba/gba-video.c +++ b/src/gba/gba-video.c @@ -161,6 +161,5 @@ static void GBAVideoDummyRendererDrawScanline(struct GBAVideoRenderer* renderer, static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer) { (void)(renderer); - printf("Drawing a frame\n"); // Nothing to do } diff --git a/src/gba/gba.c b/src/gba/gba.c index f03cfceb9..3cd5b706d 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -228,7 +228,7 @@ void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger) { } void GBALoadROM(struct GBA* gba, int fd) { - gba->memory.rom = mmap(0, SIZE_CART0, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, fd, 0); + gba->memory.rom = mmap(0, SIZE_CART0, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); // TODO: error check } diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index 85ebdb2a4..d4aa58147 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -18,7 +18,8 @@ static void GBAVideoSoftwareRendererWriteBLDCNT(struct GBAVideoSoftwareRenderer* static void _compositeBackground(struct GBAVideoSoftwareRenderer* renderer, int offset, int entry, struct PixelFlags flags); static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int y); -static void _drawSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj* spritem, int y); +static void _drawTransformedSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBATransformedObj* sprite, int y); +static void _drawSprite(struct GBAVideoSoftwareRenderer* renderer, struct GBAObj* sprite, int y); static void _updatePalettes(struct GBAVideoSoftwareRenderer* renderer); static inline uint16_t _brighten(uint16_t color, int y); diff --git a/src/main.c b/src/main.c index db86bfaff..74e07a784 100644 --- a/src/main.c +++ b/src/main.c @@ -3,8 +3,12 @@ #include "gba.h" #include "renderers/video-software.h" -#include +#include +#ifdef __APPLE__ #include +#else +#include +#endif #include #include