mirror of https://github.com/mgba-emu/mgba.git
Core: Add getPeripheral function
This commit is contained in:
parent
6561223536
commit
294470d940
|
@ -120,6 +120,7 @@ struct mCore {
|
|||
void (*getGameCode)(const struct mCore*, char* title);
|
||||
|
||||
void (*setPeripheral)(struct mCore*, int type, void*);
|
||||
void* (*getPeripheral)(struct mCore*, int type);
|
||||
|
||||
uint32_t (*busRead8)(struct mCore*, uint32_t address);
|
||||
uint32_t (*busRead16)(struct mCore*, uint32_t address);
|
||||
|
|
|
@ -795,6 +795,20 @@ static void _GBCoreSetPeripheral(struct mCore* core, int type, void* periph) {
|
|||
}
|
||||
}
|
||||
|
||||
static void* _GBCoreGetPeripheral(struct mCore* core, int type) {
|
||||
struct GB* gb = core->board;
|
||||
switch (type) {
|
||||
case mPERIPH_ROTATION:
|
||||
return gb->memory.rotation;
|
||||
case mPERIPH_RUMBLE:
|
||||
return gb->memory.rumble;
|
||||
case mPERIPH_IMAGE_SOURCE:
|
||||
return gb->memory.cam;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t _GBCoreBusRead8(struct mCore* core, uint32_t address) {
|
||||
struct SM83Core* cpu = core->cpu;
|
||||
return cpu->memory.load8(cpu, address);
|
||||
|
@ -1306,6 +1320,7 @@ struct mCore* GBCoreCreate(void) {
|
|||
core->getGameTitle = _GBCoreGetGameTitle;
|
||||
core->getGameCode = _GBCoreGetGameCode;
|
||||
core->setPeripheral = _GBCoreSetPeripheral;
|
||||
core->getPeripheral = _GBCoreGetPeripheral;
|
||||
core->busRead8 = _GBCoreBusRead8;
|
||||
core->busRead16 = _GBCoreBusRead16;
|
||||
core->busRead32 = _GBCoreBusRead32;
|
||||
|
|
|
@ -844,6 +844,20 @@ static void _GBACoreSetPeripheral(struct mCore* core, int type, void* periph) {
|
|||
}
|
||||
}
|
||||
|
||||
static void* _GBACoreGetPeripheral(struct mCore* core, int type) {
|
||||
struct GBA* gba = core->board;
|
||||
switch (type) {
|
||||
case mPERIPH_ROTATION:
|
||||
return gba->rotationSource;
|
||||
case mPERIPH_RUMBLE:
|
||||
return gba->rumble;
|
||||
case mPERIPH_GBA_LUMINANCE:
|
||||
return gba->luminanceSource;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t _GBACoreBusRead8(struct mCore* core, uint32_t address) {
|
||||
struct ARMCore* cpu = core->cpu;
|
||||
return cpu->memory.load8(cpu, address, 0);
|
||||
|
@ -1431,6 +1445,7 @@ struct mCore* GBACoreCreate(void) {
|
|||
core->getGameTitle = _GBACoreGetGameTitle;
|
||||
core->getGameCode = _GBACoreGetGameCode;
|
||||
core->setPeripheral = _GBACoreSetPeripheral;
|
||||
core->getPeripheral = _GBACoreGetPeripheral;
|
||||
core->busRead8 = _GBACoreBusRead8;
|
||||
core->busRead16 = _GBACoreBusRead16;
|
||||
core->busRead32 = _GBACoreBusRead32;
|
||||
|
|
Loading…
Reference in New Issue