mirror of https://github.com/mgba-emu/mgba.git
GB Core: Return the current number of banks for ROM/SRAM, not theoretical max
This commit is contained in:
parent
bca8cb918f
commit
cab1415d07
1
CHANGES
1
CHANGES
|
@ -96,6 +96,7 @@ Misc:
|
||||||
- Core: Improve support for ROM patch cheats, supporting disabling overlapping patches
|
- Core: Improve support for ROM patch cheats, supporting disabling overlapping patches
|
||||||
- GB: Allow pausing event loop while CPU is blocked
|
- GB: Allow pausing event loop while CPU is blocked
|
||||||
- GB: Add support for sleep and shutdown callbacks
|
- GB: Add support for sleep and shutdown callbacks
|
||||||
|
- GB Core: Return the current number of banks for ROM/SRAM, not theoretical max
|
||||||
- GB I/O: Implement preliminary support for PCM12/PCM34 (closes mgba.io/i/1468)
|
- GB I/O: Implement preliminary support for PCM12/PCM34 (closes mgba.io/i/1468)
|
||||||
- GBA: Allow pausing event loop while CPU is blocked
|
- GBA: Allow pausing event loop while CPU is blocked
|
||||||
- GBA BIOS: Division by zero should emit a FATAL error
|
- GBA BIOS: Division by zero should emit a FATAL error
|
||||||
|
|
|
@ -75,6 +75,7 @@ struct GBCore {
|
||||||
const struct Configuration* overrides;
|
const struct Configuration* overrides;
|
||||||
struct mDebuggerPlatform* debuggerPlatform;
|
struct mDebuggerPlatform* debuggerPlatform;
|
||||||
struct mCheatDevice* cheatDevice;
|
struct mCheatDevice* cheatDevice;
|
||||||
|
struct mCoreMemoryBlock memoryBlocks[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _GBCoreInit(struct mCore* core) {
|
static bool _GBCoreInit(struct mCore* core) {
|
||||||
|
@ -96,6 +97,7 @@ static bool _GBCoreInit(struct mCore* core) {
|
||||||
#ifndef MINIMAL_CORE
|
#ifndef MINIMAL_CORE
|
||||||
gbcore->logContext = NULL;
|
gbcore->logContext = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
memcpy(gbcore->memoryBlocks, _GBMemoryBlocks, sizeof(_GBMemoryBlocks));
|
||||||
|
|
||||||
GBCreate(gb);
|
GBCreate(gb);
|
||||||
memset(gbcore->components, 0, sizeof(gbcore->components));
|
memset(gbcore->components, 0, sizeof(gbcore->components));
|
||||||
|
@ -559,6 +561,26 @@ static void _GBCoreReset(struct mCore* core) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (gb->model < GB_MODEL_CGB) {
|
||||||
|
memcpy(gbcore->memoryBlocks, _GBMemoryBlocks, sizeof(_GBMemoryBlocks));
|
||||||
|
} else {
|
||||||
|
memcpy(gbcore->memoryBlocks, _GBCMemoryBlocks, sizeof(_GBCMemoryBlocks));
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < sizeof(gbcore->memoryBlocks) / sizeof(*gbcore->memoryBlocks); ++i) {
|
||||||
|
if (gbcore->memoryBlocks[i].id == GB_REGION_CART_BANK0) {
|
||||||
|
gbcore->memoryBlocks[i].maxSegment = gb->memory.romSize / GB_SIZE_CART_BANK0;
|
||||||
|
} else if (gbcore->memoryBlocks[i].id == GB_REGION_EXTERNAL_RAM) {
|
||||||
|
gbcore->memoryBlocks[i].maxSegment = gb->sramSize / GB_SIZE_EXTERNAL_RAM;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (gbcore->memoryBlocks[i].maxSegment) {
|
||||||
|
--gbcore->memoryBlocks[i].maxSegment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SM83Reset(core->cpu);
|
SM83Reset(core->cpu);
|
||||||
|
|
||||||
if (core->opts.skipBios) {
|
if (core->opts.skipBios) {
|
||||||
|
@ -732,20 +754,9 @@ static void _GBCoreRawWrite32(struct mCore* core, uint32_t address, int segment,
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t _GBListMemoryBlocks(const struct mCore* core, const struct mCoreMemoryBlock** blocks) {
|
size_t _GBListMemoryBlocks(const struct mCore* core, const struct mCoreMemoryBlock** blocks) {
|
||||||
const struct GB* gb = core->board;
|
struct GBCore* gbcore = (struct GBCore*) core;
|
||||||
switch (gb->model) {
|
*blocks = gbcore->memoryBlocks;
|
||||||
case GB_MODEL_DMG:
|
return sizeof(gbcore->memoryBlocks) / sizeof(*gbcore->memoryBlocks);
|
||||||
case GB_MODEL_MGB:
|
|
||||||
case GB_MODEL_SGB:
|
|
||||||
case GB_MODEL_SGB2:
|
|
||||||
default:
|
|
||||||
*blocks = _GBMemoryBlocks;
|
|
||||||
return sizeof(_GBMemoryBlocks) / sizeof(*_GBMemoryBlocks);
|
|
||||||
case GB_MODEL_CGB:
|
|
||||||
case GB_MODEL_AGB:
|
|
||||||
*blocks = _GBCMemoryBlocks;
|
|
||||||
return sizeof(_GBCMemoryBlocks) / sizeof(*_GBCMemoryBlocks);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* _GBGetMemoryBlock(struct mCore* core, size_t id, size_t* sizeOut) {
|
void* _GBGetMemoryBlock(struct mCore* core, size_t id, size_t* sizeOut) {
|
||||||
|
|
Loading…
Reference in New Issue