c++ side setup for setting any devices on snes input ports

This commit is contained in:
zeromus 2017-04-09 16:45:05 -05:00
parent 934e588a61
commit 23fb06a0cd
7 changed files with 32 additions and 4 deletions

View File

@ -205,6 +205,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public int port, device, index, slot; public int port, device, index, slot;
public int width, height; public int width, height;
public int scanline; public int scanline;
public fixed int inports[2];
//this should always be used in pairs //this should always be used in pairs
public void* buf0, buf1; public void* buf0, buf1;
@ -242,6 +243,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
comm->layerEnables = enables; comm->layerEnables = enables;
QUERY_set_layer_enable(); QUERY_set_layer_enable();
} }
public void SetInputPortBeforeInit(int port, SNES_INPUT_PORT type)
{
comm->inports[port] = (int)type;
}
} }
} }

View File

@ -73,6 +73,18 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
eStatus_BRK eStatus_BRK
}; };
public enum SNES_INPUT_PORT : int
{
None,
Joypad,
Multitap,
Mouse,
SuperScope,
Justifier,
Justifiers,
USART
}
public enum SNES_REG : int public enum SNES_REG : int
{ {
//$2105 //$2105

View File

@ -66,6 +66,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
ScanlineHookManager = new MyScanlineHookManager(this); ScanlineHookManager = new MyScanlineHookManager(this);
//TODO: set correct port inputs from sync settings
api.SetInputPortBeforeInit(0, LibsnesApi.SNES_INPUT_PORT.Joypad);
api.SetInputPortBeforeInit(1, LibsnesApi.SNES_INPUT_PORT.Joypad);
api.CMD_init(); api.CMD_init();
api.QUERY_set_video_refresh(snes_video_refresh); api.QUERY_set_video_refresh(snes_video_refresh);

View File

@ -263,9 +263,6 @@ void snes_init(void) {
//zero 26-aug-2013 - yup. still more //zero 26-aug-2013 - yup. still more
reconstruct(&GameBoy::cpu); GameBoy::cpu.initialize(); reconstruct(&GameBoy::cpu); GameBoy::cpu.initialize();
SNES::input.connect(SNES::Controller::Port1, SNES::Input::Device::Joypad);
SNES::input.connect(SNES::Controller::Port2, SNES::Input::Device::Joypad);
} }
void snes_term(void) { void snes_term(void) {

View File

@ -147,6 +147,7 @@ struct CommStruct
int32 port, device, index, slot; int32 port, device, index, slot;
int32 width, height; int32 width, height;
int32 scanline; int32 scanline;
SNES::Input::Device inports[2];
//always used in pairs //always used in pairs
void* buf[2]; void* buf[2];
@ -373,6 +374,14 @@ void CMD_LoadCartridgeSGB()
Analyze(); Analyze();
} }
void CMD_init()
{
snes_init();
SNES::input.connect(SNES::Controller::Port1, comm.inports[0]);
SNES::input.connect(SNES::Controller::Port2, comm.inports[1]);
}
void CMD_serialize() void CMD_serialize()
{ {
int size = comm.buf_size[0]; int size = comm.buf_size[0];
@ -511,7 +520,7 @@ void QUERY_serialize_size() {
} }
const Action kHandlers_CMD[] = { const Action kHandlers_CMD[] = {
snes_init, CMD_init,
snes_power, snes_power,
snes_reset, snes_reset,
snes_run, snes_run,