All: Fix some undefined behavior warnings

This commit is contained in:
Jeffrey Pfau 2015-10-20 22:29:59 -07:00
parent cd2443356b
commit a442933bbf
9 changed files with 10 additions and 9 deletions

View File

@ -47,6 +47,7 @@ Misc:
- SDL: Allow GBASDLAudio to be used without a thread context - SDL: Allow GBASDLAudio to be used without a thread context
- All: Improved PowerPC support - All: Improved PowerPC support
- All: Add --version flag - All: Add --version flag
- All: Fix some undefined behavior warnings
0.3.0: (2015-08-16) 0.3.0: (2015-08-16)
Features: Features:

View File

@ -308,7 +308,7 @@ DEFINE_LOAD_STORE_MULTIPLE_THUMB(STMIA,
#define DEFINE_CONDITIONAL_BRANCH_THUMB(COND) \ #define DEFINE_CONDITIONAL_BRANCH_THUMB(COND) \
DEFINE_INSTRUCTION_THUMB(B ## COND, \ DEFINE_INSTRUCTION_THUMB(B ## COND, \
if (ARM_COND_ ## COND) { \ if (ARM_COND_ ## COND) { \
int8_t immediate = opcode; \ uint8_t immediate = opcode; \
cpu->gprs[ARM_PC] += immediate << 1; \ cpu->gprs[ARM_PC] += immediate << 1; \
THUMB_WRITE_PC; \ THUMB_WRITE_PC; \
}) })

View File

@ -523,7 +523,7 @@ void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) {
channel->dmaSource = 0; channel->dmaSource = 0;
} }
} }
CircleBufferRead8(&channel->fifo, &channel->sample); CircleBufferRead8(&channel->fifo, (int8_t*) &channel->sample);
} }
#if RESAMPLE_LIBRARY != RESAMPLE_BLIP_BUF #if RESAMPLE_LIBRARY != RESAMPLE_BLIP_BUF

View File

@ -135,7 +135,7 @@ struct GBAAudioChannel4 {
struct GBAAudioFIFO { struct GBAAudioFIFO {
struct CircleBuffer fifo; struct CircleBuffer fifo;
int dmaSource; int dmaSource;
int8_t sample; uint8_t sample;
}; };
DECL_BITFIELD(GBARegisterSOUNDCNT_LO, uint16_t); DECL_BITFIELD(GBARegisterSOUNDCNT_LO, uint16_t);

View File

@ -468,7 +468,7 @@ void GBAVideoSoftwareRendererDrawBackgroundMode0(struct GBAVideoSoftwareRenderer
unsigned xBase; unsigned xBase;
int flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND;
flags |= FLAG_TARGET_2 * background->target2; flags |= FLAG_TARGET_2 * background->target2;
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->objwin.packed)); int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->objwin.packed));
objwinFlags |= flags; objwinFlags |= flags;

View File

@ -140,7 +140,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re
uint32_t flags = GBAObjAttributesCGetPriority(sprite->c) << OFFSET_PRIORITY; uint32_t flags = GBAObjAttributesCGetPriority(sprite->c) << OFFSET_PRIORITY;
flags |= FLAG_TARGET_1 * ((GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && renderer->target1Obj && renderer->blendEffect == BLEND_ALPHA) || GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_SEMITRANSPARENT); flags |= FLAG_TARGET_1 * ((GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && renderer->target1Obj && renderer->blendEffect == BLEND_ALPHA) || GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_SEMITRANSPARENT);
flags |= FLAG_OBJWIN * (GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_OBJWIN); flags |= FLAG_OBJWIN * (GBAObjAttributesAGetMode(sprite->a) == OBJ_MODE_OBJWIN);
int32_t x = GBAObjAttributesBGetX(sprite->b) << 23; int32_t x = (uint32_t) GBAObjAttributesBGetX(sprite->b) << 23;
x >>= 23; x >>= 23;
uint16_t* vramBase = &renderer->d.vram[BASE_TILE >> 1]; uint16_t* vramBase = &renderer->d.vram[BASE_TILE >> 1];
unsigned charBase = GBAObjAttributesCGetTile(sprite->c) * 0x20; unsigned charBase = GBAObjAttributesCGetTile(sprite->c) * 0x20;

View File

@ -177,7 +177,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
int32_t localX; \ int32_t localX; \
int32_t localY; \ int32_t localY; \
\ \
int flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \ uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \
flags |= FLAG_TARGET_2 * background->target2; \ flags |= FLAG_TARGET_2 * background->target2; \
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \ int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \
GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \ GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \

View File

@ -772,7 +772,7 @@ static void _drawScanline(struct GBAVideoSoftwareRenderer* renderer, int y) {
} }
} }
int priority; unsigned priority;
for (priority = 0; priority < 4; ++priority) { for (priority = 0; priority < 4; ++priority) {
renderer->end = 0; renderer->end = 0;
for (w = 0; w < renderer->nWindows; ++w) { for (w = 0; w < renderer->nWindows; ++w) {

View File

@ -23,9 +23,9 @@ struct GBAVideoSoftwareSprite {
}; };
struct GBAVideoSoftwareBackground { struct GBAVideoSoftwareBackground {
int index; unsigned index;
int enabled; int enabled;
int priority; unsigned priority;
uint32_t charBase; uint32_t charBase;
int mosaic; int mosaic;
int multipalette; int multipalette;