From 5a24012e8a780fd94f373238cddf4e1bb1f1f3b8 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 20 Sep 2016 16:21:52 -0700 Subject: [PATCH] Core: Const correctness fixes --- src/core/core.h | 14 +++++++------- src/gb/core.c | 14 +++++++------- src/gb/gb.c | 4 ++-- src/gb/gb.h | 4 ++-- src/gba/core.c | 14 +++++++------- src/gba/gba.c | 4 ++-- src/gba/gba.h | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/core/core.h b/src/core/core.h index a9146d035..3682b35bf 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -49,7 +49,7 @@ struct mCore { 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 @@ struct mCore { 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 @@ struct mCore { 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); diff --git a/src/gb/core.c b/src/gb/core.c index f4000a867..269865985 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -82,7 +82,7 @@ static void _GBCoreDeinit(struct mCore* core) { 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 @@ static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) { 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); } diff --git a/src/gb/gb.c b/src/gb/gb.c index 154aa2dfe..72d5e6c5c 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -613,7 +613,7 @@ bool GBIsROM(struct VFile* vf) { 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 @@ void GBGetGameTitle(struct GB* gb, char* out) { } } -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) { diff --git a/src/gb/gb.h b/src/gb/gb.h index b1fce80d3..5b8be0735 100644 --- a/src/gb/gb.h +++ b/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); diff --git a/src/gba/core.c b/src/gba/core.c index 5b31030a5..2cb991719 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -96,7 +96,7 @@ static void _GBACoreDeinit(struct mCore* core) { 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 @@ static void _GBACoreClearKeys(struct mCore* core, uint32_t keys) { 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); } diff --git a/src/gba/gba.c b/src/gba/gba.c index a39ba72cd..5596a0c50 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -742,7 +742,7 @@ bool GBAIsBIOS(struct VFile* vf) { 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 @@ void GBAGetGameCode(struct GBA* gba, char* out) { 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; diff --git a/src/gba/gba.h b/src/gba/gba.h index d7de413b7..38dff3f99 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -173,8 +173,8 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf); 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);