Added rudamentry Between-Frames input display code for adelikat to customize. He said he had everything except the keyboard query done, so this should make it simple for him to pretty it up.

This commit is contained in:
ugetab 2010-05-13 19:33:27 +00:00
parent f04cb475a4
commit e9bb9102ae
6 changed files with 153 additions and 9 deletions

View File

@ -1,3 +1,4 @@
12-may-2010 - ugetab - Win32 - Added rudamentry Between-Frames input display code for adelikat to customize.
12-may-2010 - adelikat - Input Display - displays a silver color when input is from a movie rather than the user
12-may-2010 - ugetab - Win32 - With special scaler in window mode, it's possible to resize to anything above the minimum.
12-may-2010 - adelikat - Movies now have a "finished" option. If a playback stops the movie isn't cleared from memory, and can be replayed or a state loaded. Similar functionality as DeSmuME and GENS rerecording

View File

@ -34,6 +34,7 @@ static int HavePolled[MAX_JOYSTICKS];
static int background = 0;
static DIJOYSTATE2 StatusSave[MAX_JOYSTICKS];
static DIJOYSTATE2 StatusSaveImmediate[MAX_JOYSTICKS];
static int FindByGUID(GUID how)
{
@ -190,6 +191,79 @@ int DTestButtonJoy(ButtConfig *bc)
return(0);
}
// Ugetab: I can't test this. It may be inefficient, or even ineffective
int DTestButtonJoyImmediate(ButtConfig *bc)
{
uint32 x; //mbg merge 7/17/06 changed to uint
for(x=0;x<bc->NumC;x++)
{
HRESULT dival;
int n = bc->DeviceNum[x];
if(n == 0xFF)
continue;
if(bc->ButtType[x] != BUTTC_JOYSTICK) continue;
if(n >= numjoysticks) continue;
while((dival = IDirectInputDevice7_Poll(Joysticks[n])) != DI_OK)
{
if(dival == DI_NOEFFECT) break;
if(!JoyAutoRestore(dival,Joysticks[n]))
{
return(0);
}
}
IDirectInputDevice7_GetDeviceState(Joysticks[n],sizeof(DIJOYSTATE2),&StatusSaveImmediate[n]);
HavePolled[n] = 1;
if(bc->ButtonNum[x]&0x8000) /* Axis "button" */
{
int sa = bc->ButtonNum[x]&3;
long source;
if(sa == 0) source=((int64)StatusSaveImmediate[n].lX - ranges[n].MinX) * 262144 /
(ranges[n].MaxX - ranges[n].MinX) - 131072;
else if(sa == 1) source=((int64)StatusSaveImmediate[n].lY - ranges[n].MinY) * 262144 /
(ranges[n].MaxY - ranges[n].MinY) - 131072;
else if(sa == 2) source=((int64)StatusSaveImmediate[n].lZ - ranges[n].MinZ) * 262144 /
(ranges[n].MaxZ - ranges[n].MinZ) - 131072;
/* Now, source is of the range -131072 to 131071. Good enough. */
if(bc->ButtonNum[x] & 0x4000)
{
if(source <= (0 - 262144/4))
return(1);
}
else
{
if(source >= (262144/4))
return(1);
}
}
else if(bc->ButtonNum[x]&0x2000) /* Hat "button" */
{
int wpov = StatusSaveImmediate[n].rgdwPOV[(bc->ButtonNum[x] >> 4) &3];
int tpov = bc->ButtonNum[x] & 3;
if(POVFix(wpov, 0) == tpov || POVFix(wpov, 1) == tpov)
return(1);
}
else /* Normal button */
{
if(StatusSaveImmediate[n].rgbButtons[bc->ButtonNum[x] & 127]&0x80)
return(1);
}
}
return(0);
}
static int canax[MAX_JOYSTICKS][3];
/* Now the fun configuration test begins. */

View File

@ -17,6 +17,7 @@ void JoyClearBC(ButtConfig *bc);
void UpdateJoysticks(void);
int DTestButtonJoy(ButtConfig *bc);
int DTestButtonJoyImmediate(ButtConfig *bc);
#define JOYBACKACCESS_OLDSTYLE 1
#define JOYBACKACCESS_TASEDIT 2

View File

@ -23,6 +23,7 @@
#include "input.h"
#include "keyboard.h"
#include "joystick.h"
static HRESULT ddrval; //mbg merge 7/17/06 made static
static int background = 0;
@ -40,6 +41,58 @@ static unsigned int keys_jd[256] = {0,}; // just-down
static unsigned int keys_jd_lock[256] = {0,}; // just-down released lock
int autoHoldKey = 0, autoHoldClearKey = 0;
int ctr=0;
// Test button state using current keyboard data.
// Clone of DTestButton, but uses local variables.
int DTestButtonImmediate(ButtConfig *bc)
{
uint32 x;//mbg merge 7/17/06 changed to uint
for(x=0;x<bc->NumC;x++)
{
if(bc->ButtType[x]==BUTTC_KEYBOARD)
{
if(keys_nr[bc->ButtonNum[x]])
{
return(1);
}
}
}
if(DTestButtonJoyImmediate(bc)) return(1); // Needs joystick.h
return(0);
}
uint32 GetGamepadPressedImmediate()
{
// Get selected joypad buttons, ignoring NES polling
// Basically checks for immediate joypad input.
extern ButtConfig GamePadConfig[4][10];
extern int allowUDLR;
uint32 JSButtons=0;
int x;
int wg;
for(wg=0;wg<4;wg++)
{
for(x=0;x<8;x++)
if(DTestButtonImmediate(&GamePadConfig[wg][x]))
JSButtons|=(1<<x)<<(wg<<3);
// Check if U+D/L+R is disabled
if(!allowUDLR)
{
for(x=0;x<32;x+=8)
{
if((JSButtons & (0xC0<<x) ) == (0xC0<<x) ) JSButtons&=~(0xC0<<x);
if((JSButtons & (0x30<<x) ) == (0x30<<x) ) JSButtons&=~(0x30<<x);
}
}
}
return JSButtons;
}
void KeyboardUpdateState(void)
{
unsigned char tk[256];
@ -117,6 +170,9 @@ void KeyboardUpdateState(void)
extern uint8 autoHoldOn, autoHoldReset;
autoHoldOn = autoHoldKey && keys[autoHoldKey] != 0;
autoHoldReset = autoHoldClearKey && keys[autoHoldClearKey] != 0;
extern uint32 JSImmediate;
JSImmediate = GetGamepadPressedImmediate();
}
unsigned int *GetKeyboard(void)

View File

@ -82,6 +82,9 @@ bool frameAdvanceLagSkip = false; //If this is true, frame advance will skip ove
bool AutoSS = false; //Flagged true when the first auto-savestate is made while a game is loaded, flagged false on game close
bool movieSubtitles = true; //Toggle for displaying movie subtitles
// GetGamepadPressedImmediate() transfer is being a pain to access.
uint32 JSImmediate=0;
FCEUGI::FCEUGI()
: filename(0)
, archiveFilename(0)

View File

@ -245,9 +245,10 @@ void FCEU_PutImage(void)
//Fancy input display code
if(input_display)
{
int controller, c, color;
int controller, c, ci, color;
int i, j;
uint32 on = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0x90:0xA7; //0xB7 possible light color
uint32 oni = 0x90; //Color for immediate keyboard buttons
static uint32 off = 0xCF;
uint8 *t = XBuf+(FSettings.LastSLine-9)*256 + 20; //mbg merge 7/17/06 changed t to uint8*
if(input_display > 4) input_display = 4;
@ -260,10 +261,18 @@ void FCEU_PutImage(void)
for(j = 3; j< 6; j++)
t[i+j*256] = 0xCF;
c = cur_input_display >> (controller * 8);
extern uint32 JSImmediate;
// This doesn't work in anything except windows for now.
// It doesn't get set anywhere in other ports.
ci = FCEUMOV_Mode(MOVIEMODE_PLAY) ? 0:JSImmediate >> (controller * 8);
c &= 255;
ci &= 255;
//A
color = c&1?on:off;
color = c&1?on:ci&1?oni:off;
for(i=0; i < 4; i++)
{
for(j = 0; j < 4; j++)
@ -274,7 +283,7 @@ void FCEU_PutImage(void)
}
}
//B
color = c&2?on:off;
color = c&2?on:ci&2?oni:off;
for(i=0; i < 4; i++)
{
for(j = 0; j < 4; j++)
@ -285,21 +294,21 @@ void FCEU_PutImage(void)
}
}
//Select
color = c&4?on:off;
color = c&4?on:ci&4?oni:off;
for(i = 0; i < 4; i++)
{
t[11+5*256+i] = color;
t[11+6*256+i] = color;
}
//Start
color = c&8?on:off;
color = c&8?on:ci&8?oni:off;
for(i = 0; i < 4; i++)
{
t[17+5*256+i] = color;
t[17+6*256+i] = color;
}
//Up
color = c&16?on:off;
color = c&16?on:ci&16?oni:off;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
@ -308,7 +317,7 @@ void FCEU_PutImage(void)
}
}
//Down
color = c&32?on:off;
color = c&32?on:ci&32?oni:off;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
@ -317,7 +326,7 @@ void FCEU_PutImage(void)
}
}
//Left
color = c&64?on:off;
color = c&64?on:ci&64?oni:off;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
@ -326,7 +335,7 @@ void FCEU_PutImage(void)
}
}
//Right
color = c&128?on:off;
color = c&128?on:ci&128?oni:off;
for(i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)