Core: Const correctness fixes
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Sep 2016 16:21:52 -0700
7 files changed,
29 insertions(+),
29 deletions(-)
M
src/core/core.h
→
src/core/core.h
@@ -49,7 +49,7 @@
bool (*init)(struct mCore*); void (*deinit)(struct mCore*); - enum mPlatform (*platform)(struct mCore*); + enum mPlatform (*platform)(const struct mCore*); void (*setSync)(struct mCore*, struct mCoreSync*); void (*loadConfig)(struct mCore*, const struct mCoreConfig*);@@ -90,12 +90,12 @@ void (*setKeys)(struct mCore*, uint32_t keys);
void (*addKeys)(struct mCore*, uint32_t keys); void (*clearKeys)(struct mCore*, uint32_t keys); - int32_t (*frameCounter)(struct mCore*); - int32_t (*frameCycles)(struct mCore*); - int32_t (*frequency)(struct mCore*); + int32_t (*frameCounter)(const struct mCore*); + int32_t (*frameCycles)(const struct mCore*); + int32_t (*frequency)(const struct mCore*); - void (*getGameTitle)(struct mCore*, char* title); - void (*getGameCode)(struct mCore*, char* title); + void (*getGameTitle)(const struct mCore*, char* title); + void (*getGameCode)(const struct mCore*, char* title); void (*setRTC)(struct mCore*, struct mRTCSource*); void (*setRotation)(struct mCore*, struct mRotationSource*);@@ -106,7 +106,7 @@ uint32_t (*busRead16)(struct mCore*, uint32_t address);
uint32_t (*busRead32)(struct mCore*, uint32_t address); void (*busWrite8)(struct mCore*, uint32_t address, uint8_t); -void (*busWrite16)(struct mCore*, uint32_t address, uint16_t); + void (*busWrite16)(struct mCore*, uint32_t address, uint16_t); void (*busWrite32)(struct mCore*, uint32_t address, uint32_t); uint32_t (*rawRead8)(struct mCore*, uint32_t address, int segment);
M
src/gb/core.c
→
src/gb/core.c
@@ -82,7 +82,7 @@ mCoreConfigFreeOpts(&core->opts);
free(core); } -static enum mPlatform _GBCorePlatform(struct mCore* core) { +static enum mPlatform _GBCorePlatform(const struct mCore* core) { UNUSED(core); return PLATFORM_GB; }@@ -313,27 +313,27 @@ struct GBCore* gbcore = (struct GBCore*) core;
gbcore->keys &= ~keys; } -static int32_t _GBCoreFrameCounter(struct mCore* core) { - struct GB* gb = core->board; +static int32_t _GBCoreFrameCounter(const struct mCore* core) { + const struct GB* gb = core->board; return gb->video.frameCounter; } -static int32_t _GBCoreFrameCycles(struct mCore* core) { +static int32_t _GBCoreFrameCycles(const struct mCore* core) { UNUSED(core); return GB_VIDEO_TOTAL_LENGTH; } -static int32_t _GBCoreFrequency(struct mCore* core) { +static int32_t _GBCoreFrequency(const struct mCore* core) { UNUSED(core); // TODO: GB differences return DMG_LR35902_FREQUENCY; } -static void _GBCoreGetGameTitle(struct mCore* core, char* title) { +static void _GBCoreGetGameTitle(const struct mCore* core, char* title) { GBGetGameTitle(core->board, title); } -static void _GBCoreGetGameCode(struct mCore* core, char* title) { +static void _GBCoreGetGameCode(const struct mCore* core, char* title) { GBGetGameCode(core->board, title); }
M
src/gb/gb.c
→
src/gb/gb.c
@@ -613,7 +613,7 @@ }
return true; } -void GBGetGameTitle(struct GB* gb, char* out) { +void GBGetGameTitle(const struct GB* gb, char* out) { const struct GBCartridge* cart = NULL; if (gb->memory.rom) { cart = (const struct GBCartridge*) &gb->memory.rom[0x100];@@ -631,7 +631,7 @@ memcpy(out, cart->titleShort, 11);
} } -void GBGetGameCode(struct GB* gb, char* out) { +void GBGetGameCode(const struct GB* gb, char* out) { memset(out, 0, 8); const struct GBCartridge* cart = NULL; if (gb->memory.rom) {
M
src/gb/gb.h
→
src/gb/gb.h
@@ -129,8 +129,8 @@ struct Patch;
void GBApplyPatch(struct GB* gb, struct Patch* patch); bool GBIsROM(struct VFile* vf); -void GBGetGameTitle(struct GB* gba, char* out); -void GBGetGameCode(struct GB* gba, char* out); +void GBGetGameTitle(const struct GB* gba, char* out); +void GBGetGameCode(const struct GB* gba, char* out); void GBFrameEnded(struct GB* gb);
M
src/gba/core.c
→
src/gba/core.c
@@ -96,7 +96,7 @@ mCoreConfigFreeOpts(&core->opts);
free(core); } -static enum mPlatform _GBACorePlatform(struct mCore* core) { +static enum mPlatform _GBACorePlatform(const struct mCore* core) { UNUSED(core); return PLATFORM_GBA; }@@ -329,26 +329,26 @@ struct GBACore* gbacore = (struct GBACore*) core;
gbacore->keys &= ~keys; } -static int32_t _GBACoreFrameCounter(struct mCore* core) { - struct GBA* gba = core->board; +static int32_t _GBACoreFrameCounter(const struct mCore* core) { + const struct GBA* gba = core->board; return gba->video.frameCounter; } -static int32_t _GBACoreFrameCycles(struct mCore* core) { +static int32_t _GBACoreFrameCycles(const struct mCore* core) { UNUSED(core); return VIDEO_TOTAL_LENGTH; } -static int32_t _GBACoreFrequency(struct mCore* core) { +static int32_t _GBACoreFrequency(const struct mCore* core) { UNUSED(core); return GBA_ARM7TDMI_FREQUENCY; } -static void _GBACoreGetGameTitle(struct mCore* core, char* title) { +static void _GBACoreGetGameTitle(const struct mCore* core, char* title) { GBAGetGameTitle(core->board, title); } -static void _GBACoreGetGameCode(struct mCore* core, char* title) { +static void _GBACoreGetGameCode(const struct mCore* core, char* title) { GBAGetGameCode(core->board, title); }
M
src/gba/gba.c
→
src/gba/gba.c
@@ -742,7 +742,7 @@ }
return true; } -void GBAGetGameCode(struct GBA* gba, char* out) { +void GBAGetGameCode(const struct GBA* gba, char* out) { memset(out, 0, 8); if (!gba->memory.rom) { return;@@ -752,7 +752,7 @@ memcpy(out, "AGB-", 4);
memcpy(&out[4], &((struct GBACartridge*) gba->memory.rom)->id, 4); } -void GBAGetGameTitle(struct GBA* gba, char* out) { +void GBAGetGameTitle(const struct GBA* gba, char* out) { if (gba->memory.rom) { memcpy(out, &((struct GBACartridge*) gba->memory.rom)->title, 12); return;
M
src/gba/gba.h
→
src/gba/gba.h
@@ -173,8 +173,8 @@
bool GBAIsROM(struct VFile* vf); bool GBAIsMB(struct VFile* vf); bool GBAIsBIOS(struct VFile* vf); -void GBAGetGameCode(struct GBA* gba, char* out); -void GBAGetGameTitle(struct GBA* gba, char* out); +void GBAGetGameCode(const struct GBA* gba, char* out); +void GBAGetGameTitle(const struct GBA* gba, char* out); void GBAFrameStarted(struct GBA* gba); void GBAFrameEnded(struct GBA* gba);