X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=input.c;h=e4223bcea20b94a4b3113a97d7f39e14c2ecb73e;hb=890e37ba2b8ea1c7593dc05926d7431e3bd00bfb;hp=be6b360591ca6460ca6d429993e0f3c4012eece7;hpb=c62d28102c77e19c291c78bf6bf7f0a81abd54b9;p=fceu.git diff --git a/input.c b/input.c index be6b360..e4223bc 100644 --- a/input.c +++ b/input.c @@ -1,7 +1,7 @@ /* FCE Ultra - NES/Famicom Emulator * * Copyright notice for this file: - * Copyright (C) 1998 BERO + * Copyright (C) 1998 BERO * Copyright (C) 2002 Ben Parnell * * This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - +#include #include "types.h" #include "x6502.h" @@ -28,6 +28,10 @@ #include "svga.h" #include "input.h" +#include "state.h" +#include "movie.h" + +#include "dprintf.h" extern INPUTC *FCEU_InitZapper(int w); extern INPUTC *FCEU_InitPowerpad(int w); @@ -37,7 +41,8 @@ extern INPUTCFC *FCEU_InitArkanoidFC(void); extern INPUTCFC *FCEU_InitSpaceShadow(void); extern INPUTCFC *FCEU_InitFKB(void); static uint8 joy_readbit[2]; -static uint16 joy[2]={0,0}; +static uint8 joy[4]={0,0,0,0}; +static uint8 LastStrobe; extern int coinon; @@ -73,7 +78,7 @@ static uint8 FP_FASTAPASS(1) ReadGPVS(int w) static uint8 FP_FASTAPASS(1) ReadGP(int w) { uint8 ret; - //if(JoyMulti) + //if(JoyMulti) //{ //ret = ((joy[w]>>(joy_readbit[w]))&1)| //(((joy[w]>>(joy_readbit[w]+8))&1)<<1); @@ -98,12 +103,13 @@ static DECLFR(JPRead) if(JPorts[A&1]->Read) ret|=JPorts[A&1]->Read(A&1); - + if(FCExp) if(FCExp->Read) ret=FCExp->Read(A&1,ret); ret|=X.DB&0xC0; + dprintf("JPRead %02x", ret); return(ret); } @@ -118,7 +124,7 @@ static DECLFW(B4016) if(JPorts[1]->Write) JPorts[1]->Write(V&1); - if((PSG[0x16]&1) && (!(V&1))) + if((LastStrobe&1) && (!(V&1))) { /* This strobe code is just for convenience. If it were with the code in input / *.c, it would more accurately represent @@ -133,7 +139,7 @@ static DECLFW(B4016) if(FCExp->Strobe) FCExp->Strobe(); } - PSG[0x16]=V; + LastStrobe=V&1; } static void FP_FASTAPASS(1) StrobeGP(int w) @@ -188,6 +194,7 @@ void UpdateInput(void) #ifdef NETWORK if(netplay) NetplayUpdate(&joy[0],&joy[1]); #endif + if (current < 0) FCEUMOV_AddJoy(joy); FlushCommandQueue(); } @@ -221,7 +228,7 @@ static void SLHLHook(uint8 *buf, int line) for(x=0;x<2;x++) if(JPorts[x]->SLHook) JPorts[x]->SLHook(x,buf,line); - if(FCExp) + if(FCExp) if(FCExp->SLHook) FCExp->SLHook(buf,line); } @@ -290,9 +297,10 @@ static void SetInputStuffFC(void) // rewrite code to make this more sane? void InitializeInput(void) -{ +{ memset(joy_readbit,0,sizeof(joy_readbit)); memset(joy,0,sizeof(joy)); + LastStrobe=0; if(FCEUGameInfo.type==GIT_VSUNI) { @@ -328,3 +336,38 @@ void FCEUI_SetInputFC(int type, void *ptr, int attrib) InputDataPtrFC=ptr; SetInputStuffFC(); } + +// quick paste +#define FCEUNPCMD_RESET 0x01 +#define FCEUNPCMD_POWER 0x02 + +#define FCEUNPCMD_VSUNICOIN 0x07 +#define FCEUNPCMD_VSUNIDIP0 0x08 +#define FCEUNPCMD_FDSINSERT 0x18 +#define FCEUNPCMD_FDSSELECT 0x1A + + +void FCEU_DoSimpleCommand(int cmd) +{ + switch(cmd) + { +// case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; +// case FCEUNPCMD_FDSSELECT: FCEU_FDSSelect();break; +// case FCEUNPCMD_FDSEJECT: FCEU_FDSEject();break; +// case FCEUNPCMD_VSUNICOIN: FCEU_VSUniCoin(); break; +// case FCEUNPCMD_VSUNIDIP0 ... (FCEUNPCMD_VSUNIDIP0 + 7): FCEU_VSUniToggleDIP(cmd - FCEUNPCMD_VSUNIDIP0);break; + case FCEUNPCMD_POWER: PowerNES();break; + case FCEUNPCMD_RESET: ResetNES();break; + default: printf("FCEU_DoSimpleCommand: can't handle cmd %i\n", cmd); break; + } +} + + +SFORMAT FCEUCTRL_STATEINFO[]={ + { joy_readbit, 2, "JYRB"}, + { joy, 4, "JOYS"}, + { &LastStrobe, 1, "LSTS"}, + { 0 } +}; + +