Added code to drop frames when sound buffer is critically low. Prevents

obnoxious sound distortion when using vsync due to sound card clock being faster than video clock.
(FCEU had this same issue)

New joypad key lists for upcoming implementation of multi-assignment options a-la Mame 
(e.g. assign either Joy Up, Joy Hat Up, OR Key Up to up).  Current limitations are annoying, and current behavior of 
dropping joystick settings altogether when a joystick isn't plugged in is even worse.
This commit is contained in:
DJRobX 2007-10-31 08:47:27 +00:00
parent c5049e7a5d
commit fca8f9f480
6 changed files with 222 additions and 290 deletions

View File

@ -670,20 +670,6 @@ void DirectDrawDisplay::checkFullScreen()
void DirectDrawDisplay::render()
{
// hack - some systems seem to render audio too
// fast. This means the audio buffer will slowly drain
// if vsync is on. If we drop one out of 800 frames
// it will keep us "ahead" of the sound. Better
// way to handle this is to skip frames when the sound
// buffer is low.
static int ctr = 0;
ctr++;
if (ctr == 800)
{
ctr = 0;
return;
}
// end hack
HRESULT hret;
if(pDirectDraw == NULL ||

View File

@ -19,6 +19,7 @@
#include "stdafx.h"
#include "Reg.h"
#include "WinResUtil.h"
#include "Input.h"
#define DIRECTINPUT_VERSION 0x0500
#include <dinput.h>
@ -84,7 +85,11 @@ static LPDIRECTINPUT pDirectInput = NULL;
static int joyDebug = 0;
static int axisNumber = 0;
USHORT joypad[4][13] = {
KeyList joypad[JOYPADS * KEYS_PER_PAD + MOTION_KEYS];
USHORT defvalues[JOYPADS * KEYS_PER_PAD + MOTION_KEYS] =
{
DIK_LEFT, DIK_RIGHT,
DIK_UP, DIK_DOWN,
@ -92,121 +97,111 @@ USHORT joypad[4][13] = {
DIK_RETURN,DIK_BACK,
DIK_A, DIK_S,
DIK_SPACE, DIK_F12,
DIK_C
},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
DIK_C,
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,
DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
};
USHORT motion[4] = {
DIK_NUMPAD4, DIK_NUMPAD6, DIK_NUMPAD8, DIK_NUMPAD2
};
static int winReadKey(char *name, int num)
void winReadKey(const char *name, KeyList& Keys)
{
CString TxtKeyList = regQueryStringValue(name, "");
int curPos= 0;
CString resToken=TxtKeyList.Tokenize(",",curPos);
while (resToken != "")
{
Keys.AddTail(atoi(resToken));
resToken= TxtKeyList.Tokenize(",",curPos);
};
}
void winReadKey(const char *name, int num, KeyList& Keys)
{
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
return regQueryDwordValue(buffer, (DWORD)-1);
winReadKey(name, Keys);
}
void winReadKeys()
{
int key = -1;
for(int i = 0; i < 4; i++) {
key = winReadKey("Left", i);
if(key != -1)
joypad[i][KEY_LEFT] = key;
key = winReadKey("Right", i);
if(key != -1)
joypad[i][KEY_RIGHT] = key;
key = winReadKey("Up", i);
if(key != -1)
joypad[i][KEY_UP] = key;
key = winReadKey("Down", i);
if(key != -1)
joypad[i][KEY_DOWN] = key;
key = winReadKey("A", i);
if(key != -1)
joypad[i][KEY_BUTTON_A] = key;
key = winReadKey("B", i);
if(key != -1)
joypad[i][KEY_BUTTON_B] = key;
key = winReadKey("L", i);
if(key != -1)
joypad[i][KEY_BUTTON_L] = key;
key = winReadKey("R", i);
if(key != -1)
joypad[i][KEY_BUTTON_R] = key;
key = winReadKey("Start", i);
if(key != -1)
joypad[i][KEY_BUTTON_START] = key;
key = winReadKey("Select", i);
if(key != -1)
joypad[i][KEY_BUTTON_SELECT] = key;
key = winReadKey("Speed", i);
if(key != -1)
joypad[i][KEY_BUTTON_SPEED] = key;
key = winReadKey("Capture", i);
if(key != -1)
joypad[i][KEY_BUTTON_CAPTURE] = key;
key = winReadKey("GS", i);
if(key != -1)
joypad[i][KEY_BUTTON_GS] = key;
for(int i = 0; i < JOYPADS; i++) {
winReadKey("Left", i, joypad[JOYPAD(i,KEY_LEFT)]);
winReadKey("Right", i, joypad[JOYPAD(i, KEY_RIGHT)]);
winReadKey("Up", i, joypad[JOYPAD(i,KEY_UP)]);
winReadKey("Down", i, joypad[JOYPAD(i,KEY_DOWN)]);
winReadKey("A", i, joypad[JOYPAD(i,KEY_BUTTON_A)]);
winReadKey("B", i, joypad[JOYPAD(i,KEY_BUTTON_B)]);
winReadKey("L", i, joypad[JOYPAD(i,KEY_BUTTON_L)]);
winReadKey("R", i, joypad[JOYPAD(i,KEY_BUTTON_R)]);
winReadKey("Start", i, joypad[JOYPAD(i,KEY_BUTTON_START)]);
winReadKey("Select", i, joypad[JOYPAD(i,KEY_BUTTON_SELECT)]);
winReadKey("Speed", i, joypad[JOYPAD(i,KEY_BUTTON_SPEED)]);
winReadKey("Capture", i, joypad[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
winReadKey("GS", i, joypad[JOYPAD(i,KEY_BUTTON_GS)]);
}
key = regQueryDwordValue("Motion_Left", (DWORD)-1);
if(key != -1)
motion[KEY_LEFT] = key;
key = regQueryDwordValue("Motion_Right", (DWORD)-1);
if(key != -1)
motion[KEY_RIGHT] = key;
key = regQueryDwordValue("Motion_Up", (DWORD)-1);
if(key != -1)
motion[KEY_UP] = key;
key = regQueryDwordValue("Motion_Down", (DWORD)-1);
if(key != -1)
motion[KEY_DOWN] = key;
winReadKey("Motion_Left", joypad[MOTION(KEY_LEFT)]);
winReadKey("Motion_Right", joypad[MOTION(KEY_RIGHT)]);
winReadKey("Motion_Up", joypad[MOTION(KEY_UP)]);
winReadKey("Motion_Down", joypad[MOTION(KEY_DOWN)]);
}
static void winSaveKey(char *name, int num, USHORT value)
void winSaveKey(char *name, KeyList &value)
{
CString txtKeys;
POSITION p = value.GetHeadPosition();
while(p!=NULL)
{
CString tmp;
tmp.Format("%d", value.GetNext(p));
txtKeys+=tmp;
if (p!=NULL)
txtKeys+=",";
}
regSetStringValue(name, txtKeys);
}
static void winSaveKey(char *name, int num, KeyList& value)
{
char buffer[80];
sprintf(buffer, "Joy%d_%s", num, name);
regSetDwordValue(buffer, value);
winSaveKey(buffer, value);
}
void winSaveKeys()
{
for(int i = 0; i < 4; i++) {
winSaveKey("Left", i, joypad[i][KEY_LEFT]);
winSaveKey("Right", i, joypad[i][KEY_RIGHT]);
winSaveKey("Up", i, joypad[i][KEY_UP]);
winSaveKey("Speed", i, joypad[i][KEY_BUTTON_SPEED]);
winSaveKey("Capture", i, joypad[i][KEY_BUTTON_CAPTURE]);
winSaveKey("GS", i, joypad[i][KEY_BUTTON_GS]);
winSaveKey("Down", i, joypad[i][KEY_DOWN]);
winSaveKey("A", i, joypad[i][KEY_BUTTON_A]);
winSaveKey("B", i, joypad[i][KEY_BUTTON_B]);
winSaveKey("L", i, joypad[i][KEY_BUTTON_L]);
winSaveKey("R", i, joypad[i][KEY_BUTTON_R]);
winSaveKey("Start", i, joypad[i][KEY_BUTTON_START]);
winSaveKey("Select", i, joypad[i][KEY_BUTTON_SELECT]);
for(int i = 0; i < JOYPADS; i++) {
winSaveKey("Left", i, joypad[JOYPAD(i,KEY_LEFT)]);
winSaveKey("Right", i, joypad[JOYPAD(i,KEY_RIGHT)]);
winSaveKey("Up", i, joypad[JOYPAD(i,KEY_UP)]);
winSaveKey("Speed", i, joypad[JOYPAD(i,KEY_BUTTON_SPEED)]);
winSaveKey("Capture", i, joypad[JOYPAD(i,KEY_BUTTON_CAPTURE)]);
winSaveKey("GS", i, joypad[JOYPAD(i,KEY_BUTTON_GS)]);
winSaveKey("Down", i, joypad[JOYPAD(i,KEY_DOWN)]);
winSaveKey("A", i, joypad[JOYPAD(i,KEY_BUTTON_A)]);
winSaveKey("B", i, joypad[JOYPAD(i,KEY_BUTTON_B)]);
winSaveKey("L", i, joypad[JOYPAD(i,KEY_BUTTON_L)]);
winSaveKey("R", i, joypad[JOYPAD(i,KEY_BUTTON_R)]);
winSaveKey("Start", i, joypad[JOYPAD(i,KEY_BUTTON_START)]);
winSaveKey("Select", i, joypad[JOYPAD(i,KEY_BUTTON_SELECT)]);
}
regSetDwordValue("joyVersion", 1);
regSetDwordValue("Motion_Left",
motion[KEY_LEFT]);
regSetDwordValue("Motion_Right",
motion[KEY_RIGHT]);
regSetDwordValue("Motion_Up",
motion[KEY_UP]);
regSetDwordValue("Motion_Down",
motion[KEY_DOWN]);
winSaveKey("Motion_Left",
joypad[MOTION(KEY_LEFT)]);
winSaveKey("Motion_Right",
joypad[MOTION(KEY_RIGHT)]);
winSaveKey("Motion_Up",
joypad[MOTION(KEY_UP)]);
winSaveKey("Motion_Down",
joypad[MOTION(KEY_DOWN)]);
}
static BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,
@ -335,112 +330,18 @@ static void checkKeys()
int dev = 0;
int i;
for(i = 0; i < numDevices; i++)
pDevices[i].needed = 0;
for(i = 0; i < 4; i++) {
dev = joypad[i][KEY_LEFT] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_LEFT] = DIK_LEFT;
dev = joypad[i][KEY_RIGHT] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_RIGHT] = DIK_RIGHT;
dev = joypad[i][KEY_UP] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_UP] = DIK_UP;
dev = joypad[i][KEY_DOWN] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_DOWN] = DIK_DOWN;
dev = joypad[i][KEY_BUTTON_A] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_A] = DIK_Z;
dev = joypad[i][KEY_BUTTON_B] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_B] = DIK_X;
dev = joypad[i][KEY_BUTTON_L] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_L] = DIK_A;
dev = joypad[i][KEY_BUTTON_R] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_R] = DIK_S;
dev = joypad[i][KEY_BUTTON_START] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_START] = DIK_RETURN;
dev = joypad[i][KEY_BUTTON_SELECT] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_SELECT] = DIK_BACK;
dev = joypad[i][KEY_BUTTON_SPEED] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_SPEED] = DIK_SPACE;
dev = joypad[i][KEY_BUTTON_CAPTURE] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_CAPTURE] = DIK_F12;
dev = joypad[i][KEY_BUTTON_GS] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
joypad[i][KEY_BUTTON_GS] = DIK_C;
for(i = 0; i < (sizeof(joypad) / sizeof(joypad[0])); i++)
{
if (joypad[i].IsEmpty() && defvalues[i])
joypad[i].AddTail(defvalues[i]);
POSITION p = joypad[i].GetHeadPosition();
while(p!=NULL)
{
USHORT k = joypad[i].GetNext(p);
if (k > 0 && DEVICEOF(k) < numDevices)
pDevices[DEVICEOF(k)].needed = true;
}
}
dev = motion[KEY_UP] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
motion[KEY_UP] = DIK_NUMPAD8;
dev = motion[KEY_DOWN] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
motion[KEY_DOWN] = DIK_NUMPAD2;
dev = motion[KEY_LEFT] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
motion[KEY_LEFT] = DIK_NUMPAD4;
dev = motion[KEY_RIGHT] >> 8;
if(dev < numDevices && dev >= 0)
pDevices[dev].needed = 1;
else
motion[KEY_RIGHT] = DIK_NUMPAD6;
}
#define KEYDOWN(buffer,key) (buffer[key] & 0x80)
@ -623,9 +524,8 @@ static void checkJoypads()
BOOL checkKey(int key)
{
int dev = (key >> 8);
int k = (key & 255);
int dev = DEVICEOF(key);
int k = KEYOF(key);
if(dev == 0) {
return KEYDOWN(pDevices[0].data,k);
@ -690,6 +590,17 @@ BOOL checkKey(int key)
return FALSE;
}
BOOL checkKey(KeyList &k)
{
POSITION p = k.GetHeadPosition();
while(p!=NULL)
{
if (checkKey(k.GetNext(p)))
return TRUE;
}
return FALSE;
}
DirectInput::DirectInput()
{
dinputDLL = NULL;
@ -848,28 +759,28 @@ u32 DirectInput::readDevice(int which)
if(which >= 0 && which <= 3)
i = which;
if(checkKey(joypad[i][KEY_BUTTON_A]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_A)]))
res |= 1;
if(checkKey(joypad[i][KEY_BUTTON_B]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_B)]))
res |= 2;
if(checkKey(joypad[i][KEY_BUTTON_SELECT]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_SELECT)]))
res |= 4;
if(checkKey(joypad[i][KEY_BUTTON_START]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_START)]))
res |= 8;
if(checkKey(joypad[i][KEY_RIGHT]))
if(checkKey(joypad[JOYPAD(i,KEY_RIGHT)]))
res |= 16;
if(checkKey(joypad[i][KEY_LEFT]))
if(checkKey(joypad[JOYPAD(i,KEY_LEFT)]))
res |= 32;
if(checkKey(joypad[i][KEY_UP]))
if(checkKey(joypad[JOYPAD(i,KEY_UP)]))
res |= 64;
if(checkKey(joypad[i][KEY_DOWN]))
if(checkKey(joypad[JOYPAD(i,KEY_DOWN)]))
res |= 128;
if(checkKey(joypad[i][KEY_BUTTON_R]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_R)]))
res |= 256;
if(checkKey(joypad[i][KEY_BUTTON_L]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_L)]))
res |= 512;
if(checkKey(joypad[i][KEY_BUTTON_GS]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_GS)]))
res |= 4096;
if(theApp.autoFire) {
@ -902,9 +813,9 @@ u32 DirectInput::readDevice(int which)
res = theApp.movieLastJoypad;
}
// we don't record speed up or screen capture buttons
if(checkKey(joypad[i][KEY_BUTTON_SPEED]) || theApp.speedupToggle)
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_SPEED)]) || theApp.speedupToggle)
res |= 1024;
if(checkKey(joypad[i][KEY_BUTTON_CAPTURE]))
if(checkKey(joypad[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
res |= 2048;
return res;
@ -984,13 +895,13 @@ void DirectInput::checkKeys()
void DirectInput::checkMotionKeys()
{
if(checkKey(motion[KEY_LEFT])) {
if(checkKey(joypad[MOTION(KEY_LEFT)])) {
theApp.sensorX += 3;
if(theApp.sensorX > 2197)
theApp.sensorX = 2197;
if(theApp.sensorX < 2047)
theApp.sensorX = 2057;
} else if(checkKey(motion[KEY_RIGHT])) {
} else if(checkKey(joypad[MOTION(KEY_RIGHT)])) {
theApp.sensorX -= 3;
if(theApp.sensorX < 1897)
theApp.sensorX = 1897;
@ -1006,13 +917,13 @@ void DirectInput::checkMotionKeys()
theApp.sensorX = 2047;
}
if(checkKey(motion[KEY_UP])) {
if(checkKey(joypad[MOTION(KEY_UP)])) {
theApp.sensorY += 3;
if(theApp.sensorY > 2197)
theApp.sensorY = 2197;
if(theApp.sensorY < 2047)
theApp.sensorY = 2057;
} else if(checkKey(motion[KEY_DOWN])) {
} else if(checkKey(joypad[MOTION(KEY_DOWN)])) {
theApp.sensorY -= 3;
if(theApp.sensorY < 1897)
theApp.sensorY = 1897;

View File

@ -30,6 +30,8 @@
#include <mmreg.h>
#include <Dsound.h> //DirectSound
extern bool soundBufferLow;
class DirectSound : public ISound
{
private:
@ -323,12 +325,18 @@ void DirectSound::write()
DWORD play;
while(true) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ?
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if(play < soundNextPosition ||
play > soundNextPosition+soundBufferLen) {
break;
}
if(BufferLeft > soundBufferLen)
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}

View File

@ -23,6 +23,17 @@
#define JOYCONFIG_MESSAGE (WM_USER + 1000)
typedef CList<USHORT,USHORT> KeyList;
#define JOYPADS 4
#define MOTION_KEYS 4
#define KEYS_PER_PAD 13
#define MOTION(i) ((JOYPADS*KEYS_PER_PAD)+i)
#define JOYPAD(i,j) ((i*KEYS_PER_PAD)+j)
#define DEVICEOF(key) (key >> 8)
#define KEYOF(key) (key & 255)
enum {
KEY_LEFT, KEY_RIGHT,
KEY_UP, KEY_DOWN,

View File

@ -24,14 +24,27 @@
#include "Joypad.h"
#include "Input.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern USHORT joypad[4][13];
extern USHORT motion[4];
extern KeyList joypad[JOYPADS * KEYS_PER_PAD + MOTION_KEYS];
// Todo: Expand UI to allow user to enter multiple keys here.
int TempReadFirst(KeyList &Key)
{
return Key.GetHead();
}
void TempWriteFirst(KeyList &Key, int Out)
{
Key.RemoveAll();
Key.AddTail(Out);
}
/////////////////////////////////////////////////////////////////////////////
// JoypadEditControl
@ -165,44 +178,44 @@ BOOL JoypadConfig::OnInitDialog()
timerId = SetTimer(0,200,NULL);
SetWindowLong(up, GWL_USERDATA,joypad[which][KEY_UP]);
up.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_UP]));
SetWindowLong(up, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_UP)]));
up.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_UP)])));
SetWindowLong(down, GWL_USERDATA,joypad[which][KEY_DOWN]);
down.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_DOWN]));
SetWindowLong(down, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_DOWN)]));
down.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_DOWN)])));
SetWindowLong(left, GWL_USERDATA,joypad[which][KEY_LEFT]);
left.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_LEFT]));
SetWindowLong(left, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_LEFT)]));
left.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_LEFT)])));
SetWindowLong(right, GWL_USERDATA,joypad[which][KEY_RIGHT]);
right.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_RIGHT]));
SetWindowLong(right, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_RIGHT)]));
right.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_RIGHT)])));
SetWindowLong(buttonA, GWL_USERDATA,joypad[which][KEY_BUTTON_A]);
buttonA.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_A]));
SetWindowLong(buttonA, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_A)]));
buttonA.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_A)])));
SetWindowLong(buttonB, GWL_USERDATA,joypad[which][KEY_BUTTON_B]);
buttonB.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_B]));
SetWindowLong(buttonB, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_B)]));
buttonB.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_B)])));
SetWindowLong(buttonL, GWL_USERDATA,joypad[which][KEY_BUTTON_L]);
buttonL.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_L]));
SetWindowLong(buttonL, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_L)]));
buttonL.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_L)])));
SetWindowLong(buttonR, GWL_USERDATA,joypad[which][KEY_BUTTON_R]);
buttonR.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_R]));
SetWindowLong(buttonR, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_R)]));
buttonR.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_R)])));
SetWindowLong(buttonSelect, GWL_USERDATA,joypad[which][KEY_BUTTON_SELECT]);
buttonSelect.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SELECT]));
SetWindowLong(buttonSelect, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_SELECT)]));
buttonSelect.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_SELECT)])));
SetWindowLong(buttonStart, GWL_USERDATA,joypad[which][KEY_BUTTON_START]);
buttonStart.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_START]));
SetWindowLong(buttonStart, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_START)]));
buttonStart.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_START)])));
SetWindowLong(speed, GWL_USERDATA,joypad[which][KEY_BUTTON_SPEED]);
speed.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_SPEED]));
SetWindowLong(speed, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_SPEED)]));
speed.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_SPEED)])));
SetWindowLong(capture, GWL_USERDATA,joypad[which][KEY_BUTTON_CAPTURE]);
capture.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_CAPTURE]));
SetWindowLong(capture, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)]));
capture.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)])));
SetWindowLong(buttonGS, GWL_USERDATA,joypad[which][KEY_BUTTON_GS]);
buttonGS.SetWindowText(theApp.input->getKeyName(joypad[which][KEY_BUTTON_GS]));
SetWindowLong(buttonGS, GWL_USERDATA,TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_GS)]));
buttonGS.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[JOYPAD(which,KEY_BUTTON_GS)])));
CenterWindow();
@ -214,43 +227,43 @@ void JoypadConfig::assignKey(int id, int key)
{
switch(id) {
case IDC_EDIT_LEFT:
joypad[which][KEY_LEFT] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_LEFT)],key);
break;
case IDC_EDIT_RIGHT:
joypad[which][KEY_RIGHT] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_RIGHT)],key);
break;
case IDC_EDIT_UP:
joypad[which][KEY_UP] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_UP)],key);
break;
case IDC_EDIT_SPEED:
joypad[which][KEY_BUTTON_SPEED] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_SPEED)],key);
break;
case IDC_EDIT_CAPTURE:
joypad[which][KEY_BUTTON_CAPTURE] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_CAPTURE)],key);
break;
case IDC_EDIT_DOWN:
joypad[which][KEY_DOWN] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_DOWN)],key);
break;
case IDC_EDIT_BUTTON_A:
joypad[which][KEY_BUTTON_A] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_A)],key);
break;
case IDC_EDIT_BUTTON_B:
joypad[which][KEY_BUTTON_B] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_B)],key);
break;
case IDC_EDIT_BUTTON_L:
joypad[which][KEY_BUTTON_L] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_L)],key);
break;
case IDC_EDIT_BUTTON_R:
joypad[which][KEY_BUTTON_R] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_R)],key);
break;
case IDC_EDIT_BUTTON_START:
joypad[which][KEY_BUTTON_START] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_START)],key);
break;
case IDC_EDIT_BUTTON_SELECT:
joypad[which][KEY_BUTTON_SELECT] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_SELECT)],key);
break;
case IDC_EDIT_BUTTON_GS:
joypad[which][KEY_BUTTON_GS] = key;
TempWriteFirst(joypad[JOYPAD(which,KEY_BUTTON_GS)],key);
break;
}
}
@ -370,17 +383,17 @@ BOOL MotionConfig::OnInitDialog()
timerId = SetTimer(0,200,NULL);
SetWindowLong(up, GWL_USERDATA,motion[KEY_UP]);
up.SetWindowText(theApp.input->getKeyName(motion[KEY_UP]));
SetWindowLong(up, GWL_USERDATA,TempReadFirst(joypad[MOTION(KEY_UP)]));
up.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[MOTION(KEY_UP)])));
SetWindowLong(down, GWL_USERDATA,motion[KEY_DOWN]);
down.SetWindowText(theApp.input->getKeyName(motion[KEY_DOWN]));
SetWindowLong(down, GWL_USERDATA,TempReadFirst(joypad[MOTION(KEY_DOWN)]));
down.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[MOTION(KEY_DOWN)])));
SetWindowLong(left, GWL_USERDATA,motion[KEY_LEFT]);
left.SetWindowText(theApp.input->getKeyName(motion[KEY_LEFT]));
SetWindowLong(left, GWL_USERDATA,TempReadFirst(joypad[MOTION(KEY_LEFT)]));
left.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[MOTION(KEY_LEFT)])));
SetWindowLong(right, GWL_USERDATA,motion[KEY_RIGHT]);
right.SetWindowText(theApp.input->getKeyName(motion[KEY_RIGHT]));
SetWindowLong(right, GWL_USERDATA,TempReadFirst(joypad[MOTION(KEY_RIGHT)]));
right.SetWindowText(theApp.input->getKeyName(TempReadFirst(joypad[MOTION(KEY_RIGHT)])));
CenterWindow();
@ -403,16 +416,16 @@ void MotionConfig::assignKey(int id, int key)
{
switch(id) {
case IDC_EDIT_LEFT:
motion[KEY_LEFT] = key;
TempWriteFirst(joypad[MOTION(KEY_LEFT)],key);
break;
case IDC_EDIT_RIGHT:
motion[KEY_RIGHT] = key;
TempWriteFirst(joypad[MOTION(KEY_RIGHT)],key);
break;
case IDC_EDIT_UP:
motion[KEY_UP] = key;
TempWriteFirst(joypad[MOTION(KEY_UP)],key);
break;
case IDC_EDIT_DOWN:
motion[KEY_DOWN] = key;
TempWriteFirst(joypad[MOTION(KEY_DOWN)],key);
break;
}
}

View File

@ -147,7 +147,7 @@ int systemColorDepth = 16;
int systemVerbose = 0;
int systemDebug = 0;
int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
bool soundBufferLow = 0;
void winSignal(int,int);
void winOutput(char *, u32);
@ -943,8 +943,11 @@ void systemDrawScreen()
theApp.ifbFunction(pix+theApp.filterWidth*4+4, theApp.filterWidth*4+4,
theApp.filterWidth, theApp.filterHeight);
}
theApp.display->render();
if(!soundBufferLow)
theApp.display->render();
else
soundBufferLow = false;
}
void systemScreenCapture(int captureNumber)