Core: Add getKeys API

This commit is contained in:
Vicki Pfau 2022-05-16 01:06:48 -07:00
parent 8a60cd8c47
commit af043e0792
3 changed files with 13 additions and 0 deletions

View File

@ -105,6 +105,7 @@ struct mCore {
void (*setKeys)(struct mCore*, uint32_t keys);
void (*addKeys)(struct mCore*, uint32_t keys);
void (*clearKeys)(struct mCore*, uint32_t keys);
uint32_t (*getKeys)(struct mCore*);
uint32_t (*frameCounter)(const struct mCore*);
int32_t (*frameCycles)(const struct mCore*);

View File

@ -688,6 +688,11 @@ static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) {
gbcore->keys &= ~keys;
}
static uint32_t _GBCoreGetKeys(struct mCore* core) {
struct GBCore* gbcore = (struct GBCore*) core;
return gbcore->keys;
}
static uint32_t _GBCoreFrameCounter(const struct mCore* core) {
const struct GB* gb = core->board;
return gb->video.frameCounter;
@ -1091,6 +1096,7 @@ struct mCore* GBCoreCreate(void) {
core->setKeys = _GBCoreSetKeys;
core->addKeys = _GBCoreAddKeys;
core->clearKeys = _GBCoreClearKeys;
core->getKeys = _GBCoreGetKeys;
core->frameCounter = _GBCoreFrameCounter;
core->frameCycles = _GBCoreFrameCycles;
core->frequency = _GBCoreFrequency;

View File

@ -723,6 +723,11 @@ static void _GBACoreClearKeys(struct mCore* core, uint32_t keys) {
GBATestKeypadIRQ(gba);
}
static uint32_t _GBACoreGetKeys(struct mCore* core) {
struct GBA* gba = core->board;
return gba->keysActive;
}
static uint32_t _GBACoreFrameCounter(const struct mCore* core) {
const struct GBA* gba = core->board;
return gba->video.frameCounter;
@ -1209,6 +1214,7 @@ struct mCore* GBACoreCreate(void) {
core->setKeys = _GBACoreSetKeys;
core->addKeys = _GBACoreAddKeys;
core->clearKeys = _GBACoreClearKeys;
core->getKeys = _GBACoreGetKeys;
core->frameCounter = _GBACoreFrameCounter;
core->frameCycles = _GBACoreFrameCycles;
core->frequency = _GBACoreFrequency;