- pretty much done commenting... might have a chance to start cleanup tonight

- had to change the name of the 'brk' variable name again... please don't change it back... brk is a reserved word in *nix.
This commit is contained in:
gimmedonutnow 2006-08-03 00:31:31 +00:00
parent 8d2dfca52c
commit c39de3f8a8
4 changed files with 650 additions and 422 deletions

View File

@ -21,13 +21,14 @@
#include "mapinc.h" #include "mapinc.h"
#include "mmc3.h" #include "mmc3.h"
static uint8 chrcmd[8], prg0, prg1, brk, latc, mirr; // brk is a system call in *nix, and is an illegal variable name - soules
static uint8 chrcmd[8], prg0, prg1, bbrk, latc, mirr;
static SFORMAT StateRegs[]= static SFORMAT StateRegs[]=
{ {
{chrcmd, 8, "CHRCMD"}, {chrcmd, 8, "CHRCMD"},
{&prg0, 1, "PRG0"}, {&prg0, 1, "PRG0"},
{&prg1, 1, "PRG1"}, {&prg1, 1, "PRG1"},
{&brk, 1, "BRK"}, {&bbrk, 1, "BRK"},
{&mirr, 1, "MIRR"}, {&mirr, 1, "MIRR"},
{0} {0}
}; };
@ -47,9 +48,9 @@ static void Sync(void)
static void UNLSL1632CW(uint32 A, uint8 V) static void UNLSL1632CW(uint32 A, uint8 V)
{ {
int cbase=(MMC3_cmd&0x80)<<5; int cbase=(MMC3_cmd&0x80)<<5;
int page0=(brk&0x08)<<5; int page0=(bbrk&0x08)<<5;
int page1=(brk&0x20)<<3; int page1=(bbrk&0x20)<<3;
int page2=(brk&0x80)<<1; int page2=(bbrk&0x80)<<1;
setchr1(cbase^0x0000,page0|(DRegBuf[0]&(~1))); setchr1(cbase^0x0000,page0|(DRegBuf[0]&(~1)));
setchr1(cbase^0x0400,page0|DRegBuf[0]|1); setchr1(cbase^0x0400,page0|DRegBuf[0]|1);
setchr1(cbase^0x0800,page0|(DRegBuf[1]&(~1))); setchr1(cbase^0x0800,page0|(DRegBuf[1]&(~1)));
@ -64,10 +65,10 @@ static DECLFW(UNLSL1632CMDWrite)
{ {
if((A&0xA131)==0xA131) if((A&0xA131)==0xA131)
{ {
brk=V; bbrk=V;
latc = brk; latc = bbrk;
} }
if(brk&2) if(bbrk&2)
{ {
FixMMC3PRG(MMC3_cmd); FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd); FixMMC3CHR(MMC3_cmd);
@ -99,7 +100,7 @@ static DECLFW(UNLSL1632CMDWrite)
static void StateRestore(int version) static void StateRestore(int version)
{ {
if(brk&2) if(bbrk&2)
{ {
FixMMC3PRG(MMC3_cmd); FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd); FixMMC3CHR(MMC3_cmd);

View File

@ -35,14 +35,23 @@ static int cspec=0;
extern int gametype; extern int gametype;
/* Necessary for proper GUI functioning(configuring when a game isn't loaded). */ /**
void InputUserActiveFix(void) * Necessary for proper GUI functioning (configuring when a game isn't loaded).
*/
void
InputUserActiveFix()
{ {
int x; int x;
for(x=0;x<3;x++) InputType[x]=UsrInputType[x]; for(x = 0; x < 3; x++) {
InputType[x] = UsrInputType[x];
}
} }
void ParseGIInput(FCEUGI *gi) /**
* Parse game information and configure the input devices accordingly.
*/
void
ParseGIInput(FCEUGI *gi)
{ {
gametype=gi->type; gametype=gi->type;
@ -50,12 +59,15 @@ void ParseGIInput(FCEUGI *gi)
InputType[1] = UsrInputType[1]; InputType[1] = UsrInputType[1];
InputType[2] = UsrInputType[2]; InputType[2] = UsrInputType[2];
if(gi->input[0]>=0) if(gi->input[0]>=0) {
InputType[0] = gi->input[0]; InputType[0] = gi->input[0];
if(gi->input[1]>=0) }
if(gi->input[1]>=0) {
InputType[1] = gi->input[1]; InputType[1] = gi->input[1];
if(gi->inputfc>=0) }
if(gi->inputfc>=0) {
InputType[2] = gi->inputfc; InputType[2] = gi->inputfc;
}
cspec = gi->cspecial; cspec = gi->cspecial;
} }
@ -79,7 +91,12 @@ static void UpdateTopRider(void);
static uint32 JSreturn=0; static uint32 JSreturn=0;
int NoWaiting=1; int NoWaiting=1;
static void DoCheatSeq(void) /**
* Configure cheat devices (game genie, etc.). Restarts the keyboard
* and video subsystems.
*/
static void
DoCheatSeq()
{ {
SilenceSound(1); SilenceSound(1);
KillKeyboard(); KillKeyboard();
@ -98,18 +115,17 @@ static int DIPS=0;
static uint8 keyonce[MKK_COUNT]; static uint8 keyonce[MKK_COUNT];
#define KEY(__a) keys[MKK(__a)] #define KEY(__a) keys[MKK(__a)]
static int _keyonly(int a) static int
{ _keyonly(int a)
if(keys[a])
{
if(!keyonce[a])
{ {
if(keys[a]) {
if(!keyonce[a]) {
keyonce[a] = 1; keyonce[a] = 1;
return(1); return(1);
} }
} } else {
else
keyonce[a] = 0; keyonce[a] = 0;
}
return(0); return(0);
} }
@ -117,89 +133,144 @@ static int _keyonly(int a)
static int cidisabled=0; static int cidisabled=0;
static void KeyboardCommands(void) /**
* Parse keyboard commands and execute accordingly.
*/
static void
KeyboardCommands()
{ {
int is_shift, is_alt; int is_shift, is_alt;
// get the keyboard input
keys = GetKeyboard(); keys = GetKeyboard();
if(InputType[2]==SIFC_FKB) // check if the family keyboard is enabled
{ if(InputType[2] == SIFC_FKB) {
if(keyonly(SCROLLLOCK)) if(keyonly(SCROLLLOCK)) {
{
cidisabled ^= 1; cidisabled ^= 1;
FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis"); FCEUI_DispMessage("Family Keyboard %sabled.",
cidisabled ? "en" : "dis");
} }
#ifdef SDL
SDL_WM_GrabInput(cidisabled ? SDL_GRAB_ON : SDL_GRAB_OFF); SDL_WM_GrabInput(cidisabled ? SDL_GRAB_ON : SDL_GRAB_OFF);
#endif if(cidisabled) {
if(cidisabled) return; return;
}
} }
is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT); is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT);
is_alt = KEY(LEFTALT) | KEY(RIGHTALT); is_alt = KEY(LEFTALT) | KEY(RIGHTALT);
if(keyonly(F4)) // f4 controls rendering
{ if(keyonly(F4)) {
if(is_shift) FCEUI_SetRenderDisable(-1, 2); if(is_shift) {
else FCEUI_SetRenderDisable(2, -1); FCEUI_SetRenderDisable(-1, 2);
} else {
FCEUI_SetRenderDisable(2, -1);
}
} }
#ifdef SDL
if(keyonly(ENTER) && is_alt) ToggleFS();
#endif
// Alt-Enter to toggle full-screen
if(keyonly(ENTER) && is_alt) {
ToggleFS();
}
// Toggle throttling
NoWaiting &= ~1; NoWaiting &= ~1;
if(KEY(GRAVE)) if(KEY(GRAVE)) {
NoWaiting |= 1; NoWaiting |= 1;
if(gametype==GIT_FDS)
{
if(keyonly(F6)) FCEUI_FDSSelect();
if(keyonly(F8)) FCEUI_FDSInsert();
} }
if(keyonly(F9)) FCEUI_SaveSnapshot(); // Famicom disk-system games
if(gametype!=GIT_NSF) if(gametype==GIT_FDS) {
{ if(keyonly(F6)) {
if(keyonly(F2)) DoCheatSeq(); FCEUI_FDSSelect();
if(keyonly(F5)) }
{ if(keyonly(F8)) {
if(is_shift) FCEUI_FDSInsert();
}
}
// f9 is save snapshot key
if(keyonly(F9)) {
FCEUI_SaveSnapshot();
}
// if not NES Sound Format
if(gametype != GIT_NSF) {
// f2 to enable cheats
if(keyonly(F2)) {
DoCheatSeq();
}
// f5 to save state, Shift-f5 to save movie
if(keyonly(F5)) {
if(is_shift) {
FCEUI_SaveMovie(NULL,0,NULL); FCEUI_SaveMovie(NULL,0,NULL);
else } else {
FCEUI_SaveState(NULL); FCEUI_SaveState(NULL);
} }
if(keyonly(F7)) }
{
if(is_shift) // f7 to load state, Shift-f7 to load movie
FCEUI_LoadMovie(NULL,0,0); //mbg merge 7/23/06 loadmovie takes another arg now if(keyonly(F7)) {
else if(is_shift) {
//mbg merge 7/23/06 loadmovie takes another arg now
FCEUI_LoadMovie(NULL,0,0);
} else {
FCEUI_LoadState(NULL); FCEUI_LoadState(NULL);
} }
} }
}
if(keyonly(F1)) FCEUI_ToggleTileView(); // f1 to toggle tile view
if(keyonly(F1)) {
FCEUI_ToggleTileView();
}
if(keyonly(MINUS)) DecreaseEmulationSpeed(); // - to decrease speed, = to increase speed
if(keyonly(EQUAL)) IncreaseEmulationSpeed(); if(keyonly(MINUS)) {
if(keyonly(BACKSPACE)) FCEUI_MovieToggleFrameDisplay(); DecreaseEmulationSpeed();
if(keyonly(BACKSLASH)) FCEUI_ToggleEmulationPause(); }
if(keyonly(RIGHTCONTROL)) FCEUI_FrameAdvance(); if(keyonly(EQUAL)) {
IncreaseEmulationSpeed();
}
if(keyonly(F10)) FCEUI_ResetNES(); if(keyonly(BACKSPACE)) {
if(keyonly(F11)) FCEUI_PowerNES(); FCEUI_MovieToggleFrameDisplay();
}
if(keyonly(BACKSLASH)) {
FCEUI_ToggleEmulationPause();
}
if(keyonly(RIGHTCONTROL)) {
FCEUI_FrameAdvance();
}
if(KEY(F12) || KEY(ESCAPE)) CloseGame(); // f10 reset, f11 power
if(keyonly(F10)) {
FCEUI_ResetNES();
}
if(keyonly(F11)) {
FCEUI_PowerNES();
}
if(gametype==GIT_VSUNI) // F12 or Esc close game
{ if(KEY(F12) || KEY(ESCAPE)) {
CloseGame();
}
// VS Unisystem games
if(gametype == GIT_VSUNI) {
// insert coin
if(keyonly(F8)) FCEUI_VSUniCoin(); if(keyonly(F8)) FCEUI_VSUniCoin();
if(keyonly(F6))
{ // toggle dipswitch display
if(keyonly(F6)) {
DIPS^=1; DIPS^=1;
FCEUI_VSUniToggleDIPView(); FCEUI_VSUniToggleDIPView();
} }
if(!(DIPS&1)) goto DIPSless; if(!(DIPS&1)) goto DIPSless;
// toggle the various dipswitches
if(keyonly(1)) FCEUI_VSUniToggleDIP(0); if(keyonly(1)) FCEUI_VSUniToggleDIP(0);
if(keyonly(2)) FCEUI_VSUniToggleDIP(1); if(keyonly(2)) FCEUI_VSUniToggleDIP(1);
if(keyonly(3)) FCEUI_VSUniToggleDIP(2); if(keyonly(3)) FCEUI_VSUniToggleDIP(2);
@ -208,9 +279,7 @@ static void KeyboardCommands(void)
if(keyonly(6)) FCEUI_VSUniToggleDIP(5); if(keyonly(6)) FCEUI_VSUniToggleDIP(5);
if(keyonly(7)) FCEUI_VSUniToggleDIP(6); if(keyonly(7)) FCEUI_VSUniToggleDIP(6);
if(keyonly(8)) FCEUI_VSUniToggleDIP(7); if(keyonly(8)) FCEUI_VSUniToggleDIP(7);
} } else {
else
{
static uint8 bbuf[32]; static uint8 bbuf[32];
static int bbuft; static int bbuft;
static int barcoder = 0; static int barcoder = 0;
@ -220,32 +289,42 @@ static void KeyboardCommands(void)
if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC(); if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC();
if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC(); if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC();
if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) {
{ if(keyonly(F8)) {
if(keyonly(F8))
{
barcoder ^= 1; barcoder ^= 1;
if(!barcoder) if(!barcoder) {
{ if(InputType[2] == SIFC_BWORLD) {
if(InputType[2] == SIFC_BWORLD)
{
strcpy((char *)&BWorldData[1], (char *)bbuf); strcpy((char *)&BWorldData[1], (char *)bbuf);
BWorldData[0] = 1; BWorldData[0] = 1;
} } else {
else
FCEUI_DatachSet(bbuf); FCEUI_DatachSet(bbuf);
}
FCEUI_DispMessage("Barcode Entered"); FCEUI_DispMessage("Barcode Entered");
} else {
bbuft = 0;
FCEUI_DispMessage("Enter Barcode");
} }
else { bbuft = 0; FCEUI_DispMessage("Enter Barcode");}
} }
} else barcoder = 0; } else {
barcoder = 0;
}
#define SSM(x) \ #define SSM(x) \
{ if(barcoder) { if(bbuft < 13) {bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0;} FCEUI_DispMessage("Barcode: %s",bbuf);} \ do { \
else { \ if(barcoder) { \
if(is_shift) FCEUI_SelectMovie(x,1); \ if(bbuft < 13) { \
else FCEUI_SelectState(x,1); \ bbuf[bbuft++] = '0' + x; \
} } bbuf[bbuft] = 0; \
} \
FCEUI_DispMessage("Barcode: %s", bbuf); \
} else { \
if(is_shift) { \
FCEUI_SelectMovie(x,1); \
} else { \
FCEUI_SelectState(x,1); \
} \
} \
} while(0)
DIPSless: DIPSless:
if(keyonly(0)) SSM(0); if(keyonly(0)) SSM(0);
@ -287,10 +366,16 @@ ButtConfig GamePadConfig[4][10]={
}; };
static void UpdateGamepad(void) /**
* Update the gamepad button configurations.
*/
static void
UpdateGamepad(void)
{ {
if(FCEUI_IsMovieActive()<0) // don't update during movie playback
if(FCEUI_IsMovieActive() < 0) {
return; return;
}
static int rapid=0; static int rapid=0;
uint32 JS=0; uint32 JS=0;
@ -299,17 +384,24 @@ static void UpdateGamepad(void)
rapid ^= 1; rapid ^= 1;
for(wg=0;wg<4;wg++) // go through each of the four game pads
{ for(wg = 0; wg < 4; wg++) {
for(x=0;x<8;x++) // the 4 directional buttons, start, select, a, b
if(DTestButton(&GamePadConfig[wg][x])) for(x = 0; x < 8; x++) {
if(DTestButton(&GamePadConfig[wg][x])) {
JS |= (1 << x) << (wg << 3); JS |= (1 << x) << (wg << 3);
}
}
if(rapid) // rapid-fire a, rapid-fire b
for(x=0;x<2;x++) if(rapid) {
if(DTestButton(&GamePadConfig[wg][8+x])) for(x = 0; x < 2; x++) {
if(DTestButton(&GamePadConfig[wg][8+x])) {
JS |= (1 << x) << (wg << 3); JS |= (1 << x) << (wg << 3);
} }
}
}
}
// for(x=0;x<32;x+=8) /* Now, test to see if anything weird(up+down at same time) // for(x=0;x<32;x+=8) /* Now, test to see if anything weird(up+down at same time)
// is happening, and correct */ // is happening, and correct */
@ -338,17 +430,27 @@ ButtConfig powerpadsc[2][12]={
static uint32 powerpadbuf[2]={0,0}; static uint32 powerpadbuf[2]={0,0};
static uint32 UpdatePPadData(int w) /**
* Update power pad button configuration.
*/
static uint32
UpdatePPadData(int w)
{ {
if(FCEUI_IsMovieActive()<0) // don't update if a movie is playing
if(FCEUI_IsMovieActive() < 0) {
return 0; return 0;
}
uint32 r = 0; uint32 r = 0;
ButtConfig *ppadtsc = powerpadsc[w]; ButtConfig *ppadtsc = powerpadsc[w];
int x; int x;
for(x=0;x<12;x++) // update each of the 12 buttons
if(DTestButton(&ppadtsc[x])) r|=1<<x; for(x = 0; x < 12; x++) {
if(DTestButton(&ppadtsc[x])) {
r |= 1 << x;
}
}
return r; return r;
} }
@ -356,7 +458,11 @@ static uint32 UpdatePPadData(int w)
static uint32 MouseData[3]={0,0,0}; static uint32 MouseData[3]={0,0,0};
static uint8 fkbkeys[0x48]; static uint8 fkbkeys[0x48];
void FCEUD_UpdateInput(void) /**
* Update all of the input devices required for the active game.
*/
void
FCEUD_UpdateInput()
{ {
int x; int x;
int t = 0; int t = 0;
@ -364,39 +470,71 @@ void FCEUD_UpdateInput(void)
UpdatePhysicalInput(); UpdatePhysicalInput();
KeyboardCommands(); KeyboardCommands();
for(x=0;x<2;x++) for(x = 0; x < 2; x++) {
switch(InputType[x]) switch(InputType[x]) {
{ case SI_GAMEPAD:
case SI_GAMEPAD:t|=1;break; t |= 1;
case SI_ARKANOID:t|=2;break; break;
case SI_ZAPPER:t|=2;break; case SI_ARKANOID:
t |= 2;
break;
case SI_ZAPPER:
t |= 2;
break;
case SI_POWERPADA: case SI_POWERPADA:
case SI_POWERPADB:powerpadbuf[x]=UpdatePPadData(x);break; case SI_POWERPADB:
powerpadbuf[x] = UpdatePPadData(x);
break;
}
} }
switch(InputType[2]) switch(InputType[2]) {
{ case SIFC_ARKANOID:
case SIFC_ARKANOID:t|=2;break; t |= 2;
case SIFC_SHADOW:t|=2;break; break;
case SIFC_FKB:if(cidisabled) UpdateFKB();break; case SIFC_SHADOW:
case SIFC_HYPERSHOT: UpdateHyperShot();break; t |= 2;
case SIFC_MAHJONG: UpdateMahjong();break; break;
case SIFC_QUIZKING: UpdateQuizKing();break; case SIFC_FKB:
if(cidisabled) {
UpdateFKB();
}
break;
case SIFC_HYPERSHOT:
UpdateHyperShot();
break;
case SIFC_MAHJONG:
UpdateMahjong();
break;
case SIFC_QUIZKING:
UpdateQuizKing();
break;
case SIFC_FTRAINERB: case SIFC_FTRAINERB:
case SIFC_FTRAINERA: UpdateFTrainer();break; case SIFC_FTRAINERA:
case SIFC_TOPRIDER: UpdateTopRider();break; UpdateFTrainer();
case SIFC_OEKAKIDS:t|=2;break; break;
case SIFC_TOPRIDER:
UpdateTopRider();
break;
case SIFC_OEKAKIDS:
t |= 2;
break;
} }
if(t&1) if(t & 1) {
UpdateGamepad(); UpdateGamepad();
}
if(t&2) if(t & 2) {
GetMouseData(MouseData); GetMouseData(MouseData);
} }
}
void InitOtherInput(void) /**
* Initialize "other" input devices? Not entirely sure what this does yet.
*/
void
InitOtherInput()
{ {
void *InputDPtr; void *InputDPtr;
@ -404,17 +542,24 @@ void InitOtherInput(void)
int x; int x;
int attrib; int attrib;
for(t=0,x=0;x<2;x++) for(t = 0, x = 0; x < 2; x++) {
{
attrib = 0; attrib = 0;
InputDPtr = 0; InputDPtr = 0;
switch(InputType[x])
{ switch(InputType[x]) {
case SI_POWERPADA: case SI_POWERPADA:
case SI_POWERPADB:InputDPtr=&powerpadbuf[x];break; case SI_POWERPADB:
case SI_GAMEPAD:InputDPtr=&JSreturn;break; InputDPtr = &powerpadbuf[x];
case SI_ARKANOID:InputDPtr=MouseData;t|=1;break; break;
case SI_ZAPPER:InputDPtr=MouseData; case SI_GAMEPAD:
InputDPtr = &JSreturn;
break;
case SI_ARKANOID:
InputDPtr = MouseData;
t |= 1;
break;
case SI_ZAPPER:
InputDPtr = MouseData;
t |= 1; t |= 1;
attrib = 1; attrib = 1;
break; break;
@ -424,27 +569,52 @@ void InitOtherInput(void)
attrib = 0; attrib = 0;
InputDPtr = 0; InputDPtr = 0;
switch(InputType[2]) switch(InputType[2]) {
{ case SIFC_SHADOW:
case SIFC_SHADOW:InputDPtr=MouseData;t|=1;attrib=1;break; InputDPtr = MouseData;
case SIFC_OEKAKIDS:InputDPtr=MouseData;t|=1;attrib=1;break; t |= 1;
case SIFC_ARKANOID:InputDPtr=MouseData;t|=1;break; attrib = 1;
case SIFC_FKB:InputDPtr=fkbkeys;break; break;
case SIFC_HYPERSHOT:InputDPtr=&HyperShotData;break; case SIFC_OEKAKIDS:
case SIFC_MAHJONG:InputDPtr=&MahjongData;break; InputDPtr = MouseData;
case SIFC_QUIZKING:InputDPtr=&QuizKingData;break; t |= 1;
case SIFC_TOPRIDER:InputDPtr=&TopRiderData;break; attrib = 1;
case SIFC_BWORLD:InputDPtr=BWorldData;break; break;
case SIFC_ARKANOID:
InputDPtr = MouseData;
t |= 1;
break;
case SIFC_FKB:
InputDPtr = fkbkeys;
break;
case SIFC_HYPERSHOT:
InputDPtr = &HyperShotData;
break;
case SIFC_MAHJONG:
InputDPtr = &MahjongData;
break;
case SIFC_QUIZKING:
InputDPtr = &QuizKingData;
break;
case SIFC_TOPRIDER:
InputDPtr = &TopRiderData;
break;
case SIFC_BWORLD:
InputDPtr = BWorldData;
break;
case SIFC_FTRAINERA: case SIFC_FTRAINERA:
case SIFC_FTRAINERB:InputDPtr=&FTrainerData;break; case SIFC_FTRAINERB:
InputDPtr = &FTrainerData;
break;
} }
FCEUI_SetInputFC(InputType[2], InputDPtr, attrib); FCEUI_SetInputFC(InputType[2], InputDPtr, attrib);
FCEUI_DisableFourScore(eoptions & EO_NOFOURSCORE); FCEUI_DisableFourScore(eoptions & EO_NOFOURSCORE);
if(t) if(t) {
InitMouse(); InitMouse();
} }
}
ButtConfig fkbmap[0x48]= ButtConfig fkbmap[0x48]=
@ -462,35 +632,43 @@ ButtConfig fkbmap[0x48]=
MK(CURSORUP),MK(CURSORLEFT),MK(CURSORRIGHT),MK(CURSORDOWN) MK(CURSORUP),MK(CURSORLEFT),MK(CURSORRIGHT),MK(CURSORDOWN)
}; };
static void UpdateFKB(void) /**
* Update the button configuration for the Family KeyBoard.
*/
static void
UpdateFKB()
{ {
int x; int x;
for(x=0;x<0x48;x++) for(x = 0; x < 0x48; x++) {
{
fkbkeys[x] = 0; fkbkeys[x] = 0;
if(DTestButton(&fkbmap[x])) if(DTestButton(&fkbmap[x])) {
fkbkeys[x] = 1; fkbkeys[x] = 1;
} }
} }
}
static ButtConfig HyperShotButtons[4]= static ButtConfig HyperShotButtons[4]=
{ {
MK(Q),MK(W),MK(E),MK(R) MK(Q),MK(W),MK(E),MK(R)
}; };
static void UpdateHyperShot(void) /**
* Update the button configuration for the HyperShot input device.
*/
static void
UpdateHyperShot()
{ {
int x; int x;
HyperShotData=0; HyperShotData=0;
for(x=0;x<0x4;x++) for(x = 0; x < 0x4; x++) {
{ if(DTestButton(&HyperShotButtons[x])) {
if(DTestButton(&HyperShotButtons[x]))
HyperShotData |= 1 << x; HyperShotData |= 1 << x;
} }
} }
}
static ButtConfig MahjongButtons[21]= static ButtConfig MahjongButtons[21]=
{ {
@ -499,35 +677,42 @@ static ButtConfig MahjongButtons[21]=
MK(Z),MK(X),MK(C),MK(V),MK(B),MK(N),MK(M) MK(Z),MK(X),MK(C),MK(V),MK(B),MK(N),MK(M)
}; };
static void UpdateMahjong(void) /**
* Update the button configuration for the Mahjong input device.
*/
static void
UpdateMahjong()
{ {
int x; int x;
MahjongData=0; MahjongData=0;
for(x=0;x<21;x++) for(x = 0; x < 21; x++) {
{ if(DTestButton(&MahjongButtons[x])) {
if(DTestButton(&MahjongButtons[x]))
MahjongData |= 1 << x; MahjongData |= 1 << x;
} }
} }
}
ButtConfig QuizKingButtons[6]= ButtConfig QuizKingButtons[6]=
{ {
MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y) MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y)
}; };
static void UpdateQuizKing(void) /**
* Update the button configuration for the QuizKing input device.
*/
static void
UpdateQuizKing()
{ {
int x; int x;
QuizKingData=0; QuizKingData=0;
for(x=0;x<6;x++) for(x = 0; x < 6; x++) {
{ if(DTestButton(&QuizKingButtons[x])) {
if(DTestButton(&QuizKingButtons[x]))
QuizKingData |= 1 << x; QuizKingData |= 1 << x;
} }
}
} }
ButtConfig TopRiderButtons[8]= ButtConfig TopRiderButtons[8]=
@ -535,13 +720,19 @@ ButtConfig TopRiderButtons[8]=
MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y),MK(U),MK(I) MK(Q),MK(W),MK(E),MK(R),MK(T),MK(Y),MK(U),MK(I)
}; };
static void UpdateTopRider(void) /**
* Update the button configuration for the TopRider input device.
*/
static void
UpdateTopRider()
{ {
int x; int x;
TopRiderData=0; TopRiderData=0;
for(x=0;x<8;x++) for(x = 0; x < 8; x++) {
if(DTestButton(&TopRiderButtons[x])) if(DTestButton(&TopRiderButtons[x])) {
TopRiderData|=1<<x; TopRiderData |= (1 << x);
}
}
} }
ButtConfig FTrainerButtons[12]= ButtConfig FTrainerButtons[12]=
@ -552,75 +743,86 @@ ButtConfig FTrainerButtons[12]=
MK(M),MK(COMMA),MK(PERIOD),MK(SLASH) MK(M),MK(COMMA),MK(PERIOD),MK(SLASH)
}; };
static void UpdateFTrainer(void) /**
* Update the button configuration for the FTrainer input device.
*/
static void
UpdateFTrainer()
{ {
int x; int x;
FTrainerData = 0; FTrainerData = 0;
for(x=0;x<12;x++) for(x = 0; x < 12; x++) {
{ if(DTestButton(&FTrainerButtons[x])) {
if(DTestButton(&FTrainerButtons[x])) FTrainerData |= (1 << x);
FTrainerData|=1<<x; }
} }
} }
static void subcon(char *text, ButtConfig *bc) /**
* I think this function takes in button inputs until either it sees
* two of the same button presses in a row or gets four inputs and
* then saves the total number of button presses. Needs an overhaul.
*/
static void
subcon(char *text,
ButtConfig *bc)
{ {
uint8 buf[256]; uint8 buf[256];
int wc; int wc;
for(wc=0;wc<MAXBUTTCONFIG;wc++) for(wc = 0; wc < MAXBUTTCONFIG; wc++) {
{
sprintf((char *)buf, "%s (%d)", text, wc + 1); sprintf((char *)buf, "%s (%d)", text, wc + 1);
DWaitButton(buf, bc, wc); DWaitButton(buf, bc, wc);
if(wc && bc->ButtType[wc]==bc->ButtType[wc-1] && bc->DeviceNum[wc]==bc->DeviceNum[wc-1] && if(wc &&
bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) bc->ButtType[wc] == bc->ButtType[wc - 1] &&
bc->DeviceNum[wc] == bc->DeviceNum[wc - 1] &&
bc->ButtonNum[wc]==bc->ButtonNum[wc-1]) {
break; break;
} }
}
bc->NumC = wc; bc->NumC = wc;
} }
void ConfigDevice(int which, int arg) /**
* Update the button configuration for a specified device.
*/
void
ConfigDevice(int which,
int arg)
{ {
uint8 buf[256]; uint8 buf[256];
int x; int x;
char *str[10]={"A","B","SELECT","START","UP","DOWN","LEFT","RIGHT","Rapid A","Rapid B"};
ButtonConfigBegin(); ButtonConfigBegin();
switch(which) switch(which) {
{
case FCFGD_QUIZKING: case FCFGD_QUIZKING:
for(x=0;x<6;x++) for(x = 0; x < 6; x++) {
{
sprintf((char *)buf, "Quiz King Buzzer #%d", x+1); sprintf((char *)buf, "Quiz King Buzzer #%d", x+1);
subcon((char *)buf, &QuizKingButtons[x]); subcon((char *)buf, &QuizKingButtons[x]);
} }
break; break;
case FCFGD_HYPERSHOT: case FCFGD_HYPERSHOT:
for(x=0;x<4;x++) for(x = 0; x < 4; x++) {
{ sprintf((char *)buf, "Hyper Shot %d: %s",
sprintf((char *)buf,"Hyper Shot %d: %s",((x&2)>>1)+1,(x&1)?"JUMP":"RUN"); ((x & 2) >> 1) + 1, (x & 1) ? "JUMP" : "RUN");
subcon((char *)buf, &HyperShotButtons[x]); subcon((char *)buf, &HyperShotButtons[x]);
} }
break; break;
case FCFGD_POWERPAD: case FCFGD_POWERPAD:
for(x=0;x<12;x++) for(x = 0; x < 12; x++) {
{
sprintf((char *)buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11); sprintf((char *)buf, "PowerPad %d: %d", (arg & 1) + 1, x + 11);
subcon((char *)buf, &powerpadsc[arg&1][x]); subcon((char *)buf, &powerpadsc[arg&1][x]);
} }
break; break;
case FCFGD_GAMEPAD: case FCFGD_GAMEPAD:
{ for(x = 0; x < 10; x++) {
char *str[10]={"A","B","SELECT","START","UP","DOWN","LEFT","RIGHT","Rapid A","Rapid B"};
for(x=0;x<10;x++)
{
sprintf((char *)buf, "GamePad #%d: %s", arg + 1, str[x]); sprintf((char *)buf, "GamePad #%d: %s", arg + 1, str[x]);
subcon((char *)buf, &GamePadConfig[arg][x]); subcon((char *)buf, &GamePadConfig[arg][x]);
} }
}
break; break;
} }
@ -641,23 +843,29 @@ CFGSTRUCT InputConfig[]={
}; };
static void InputCfg(char *text) /**
{ * Update the button configuration for a device, specified by a text string.
if(!strncasecmp(text,"gamepad",strlen("gamepad"))) */
static void
InputCfg(char *text)
{ {
if(!strncasecmp(text, "gamepad", strlen("gamepad"))) {
ConfigDevice(FCFGD_GAMEPAD, (text[strlen("gamepad")] - '1') & 3); ConfigDevice(FCFGD_GAMEPAD, (text[strlen("gamepad")] - '1') & 3);
} } else if(!strncasecmp(text, "powerpad", strlen("powerpad"))) {
else if(!strncasecmp(text,"powerpad",strlen("powerpad")))
{
ConfigDevice(FCFGD_POWERPAD, (text[strlen("powerpad")] - '1') & 1); ConfigDevice(FCFGD_POWERPAD, (text[strlen("powerpad")] - '1') & 1);
} } else if(!strcasecmp(text,"hypershot")) {
else if(!strcasecmp(text,"hypershot"))
ConfigDevice(FCFGD_HYPERSHOT, 0); ConfigDevice(FCFGD_HYPERSHOT, 0);
else if(!strcasecmp(text,"quizking")) } else if(!strcasecmp(text,"quizking")) {
ConfigDevice(FCFGD_QUIZKING, 0); ConfigDevice(FCFGD_QUIZKING, 0);
} }
}
static void FCExp(char *text) /**
* Specify a FamiCom Expansion device as the 3rd input device. Takes
* a text string describing the device.
*/
static void
FCExp(char *text)
{ {
static char *fccortab[11]={"none","arkanoid","shadow","4player","fkb","hypershot", static char *fccortab[11]={"none","arkanoid","shadow","4player","fkb","hypershot",
"mahjong","quizking","ftrainera","ftrainerb","oekakids"}; "mahjong","quizking","ftrainera","ftrainerb","oekakids"};
@ -665,33 +873,50 @@ static void FCExp(char *text)
static int fccortabi[11]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW, static int fccortabi[11]={SIFC_NONE,SIFC_ARKANOID,SIFC_SHADOW,
SIFC_4PLAYER,SIFC_FKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING, SIFC_4PLAYER,SIFC_FKB,SIFC_HYPERSHOT,SIFC_MAHJONG,SIFC_QUIZKING,
SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS}; SIFC_FTRAINERA,SIFC_FTRAINERB,SIFC_OEKAKIDS};
int y; int y;
for(y=0;y<11;y++) for(y = 0; y < 11; y++) {
if(!strcmp(fccortab[y],text)) if(!strcmp(fccortab[y], text)) {
UsrInputType[2] = fccortabi[y]; UsrInputType[2] = fccortabi[y];
} }
}
}
static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"}; static char *cortab[6]={"none","gamepad","zapper","powerpada","powerpadb","arkanoid"};
static int cortabi[6]={SI_NONE,SI_GAMEPAD, static int cortabi[6]={SI_NONE,SI_GAMEPAD,
SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID}; SI_ZAPPER,SI_POWERPADA,SI_POWERPADB,SI_ARKANOID};
static void Input1(char *text) /**
* Set the 1st user-specified input device. Specified as a text
* string.
*/
static void
Input1(char *text)
{ {
int y; int y;
for(y=0;y<6;y++) for(y = 0; y < 6; y++) {
if(!strcmp(cortab[y],text)) if(!strcmp(cortab[y], text)) {
UsrInputType[0] = cortabi[y]; UsrInputType[0] = cortabi[y];
} }
}
}
static void Input2(char *text) /**
* Set the 2nd user-specified input device. Specified as a text
* string.
*/
static void
Input2(char *text)
{ {
int y; int y;
for(y=0;y<6;y++) for(y = 0; y < 6; y++) {
if(!strcmp(cortab[y],text)) if(!strcmp(cortab[y], text)) {
UsrInputType[1] = cortabi[y]; UsrInputType[1] = cortabi[y];
} }
}
}
ARGPSTRUCT InputArgs[]={ ARGPSTRUCT InputArgs[]={
{"-inputcfg",0,(void *)InputCfg,0x2000}, {"-inputcfg",0,(void *)InputCfg,0x2000},

View File

@ -18,6 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/// \file
/// \brief A set of functions for dealing with the main execution loop. Much of this code will likely be dispersed to sdl.cpp and other files since we no longer support non-SDL and non-Windows builds.
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>

View File

@ -33,8 +33,7 @@
static SDL_Joystick *Joysticks[MAX_JOYSTICKS] = {NULL}; static SDL_Joystick *Joysticks[MAX_JOYSTICKS] = {NULL};
/** /**
* Updates a single input button configuration on the joystick. Note: * Updates a single input button configuration on the joystick?
* I'm not fully sure that this is what the function does - soules.
*/ */
int int
DTestButtonJoy(ButtConfig *bc) DTestButtonJoy(ButtConfig *bc)