sdl: code cleanup; pre-release code review (in progress)
This commit is contained in:
parent
118b82544c
commit
b0c2758324
|
@ -54,5 +54,5 @@ void InputCfg(const std::string &);
|
||||||
|
|
||||||
std::string GetUserText(const char* title);
|
std::string GetUserText(const char* title);
|
||||||
const char* ButtonName(const ButtConfig* bc, int which);
|
const char* ButtonName(const ButtConfig* bc, int which);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ DTestButtonJoy(ButtConfig *bc)
|
||||||
if(SDL_JoystickGetHat(s_Joysticks[bc->DeviceNum[x]],
|
if(SDL_JoystickGetHat(s_Joysticks[bc->DeviceNum[x]],
|
||||||
((bc->ButtonNum[x] >> 8) & 0x1F)) &
|
((bc->ButtonNum[x] >> 8) & 0x1F)) &
|
||||||
(bc->ButtonNum[x]&0xFF))
|
(bc->ButtonNum[x]&0xFF))
|
||||||
return(1);
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(bc->ButtonNum[x] & 0x8000)
|
else if(bc->ButtonNum[x] & 0x8000)
|
||||||
{
|
{
|
||||||
|
@ -61,16 +60,16 @@ DTestButtonJoy(ButtConfig *bc)
|
||||||
pos = SDL_JoystickGetAxis(s_Joysticks[bc->DeviceNum[x]],
|
pos = SDL_JoystickGetAxis(s_Joysticks[bc->DeviceNum[x]],
|
||||||
bc->ButtonNum[x] & 16383);
|
bc->ButtonNum[x] & 16383);
|
||||||
if ((bc->ButtonNum[x] & 0x4000) && pos <= -16383) {
|
if ((bc->ButtonNum[x] & 0x4000) && pos <= -16383) {
|
||||||
return(1);
|
return 1;
|
||||||
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
|
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(SDL_JoystickGetButton(s_Joysticks[bc->DeviceNum[x]],
|
else if(SDL_JoystickGetButton(s_Joysticks[bc->DeviceNum[x]],
|
||||||
bc->ButtonNum[x]))
|
bc->ButtonNum[x]))
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +81,7 @@ KillJoysticks()
|
||||||
int n; /* joystick index */
|
int n; /* joystick index */
|
||||||
|
|
||||||
if(!s_jinited) {
|
if(!s_jinited) {
|
||||||
return(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(n = 0; n < MAX_JOYSTICKS; n++) {
|
for(n = 0; n < MAX_JOYSTICKS; n++) {
|
||||||
|
@ -92,7 +91,7 @@ KillJoysticks()
|
||||||
s_Joysticks[n]=0;
|
s_Joysticks[n]=0;
|
||||||
}
|
}
|
||||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,5 +119,5 @@ InitJoysticks()
|
||||||
}
|
}
|
||||||
|
|
||||||
s_jinited = 1;
|
s_jinited = 1;
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,5 +289,5 @@ InitOpenGL(int l,
|
||||||
p_glClear(GL_COLOR_BUFFER_BIT);
|
p_glClear(GL_COLOR_BUFFER_BIT);
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
|
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,6 @@ fillaudio(void *udata,
|
||||||
{
|
{
|
||||||
int16 *tmps = (int16*)stream;
|
int16 *tmps = (int16*)stream;
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
// debug code
|
|
||||||
//printf("s_BufferIn: %i s_BufferWrite = %i s_BufferRead = %i s_BufferSize = %i\n",
|
|
||||||
// s_BufferIn, s_BufferWrite, s_BufferRead, s_BufferSize);
|
|
||||||
|
|
||||||
while(len) {
|
while(len) {
|
||||||
int16 sample = 0;
|
int16 sample = 0;
|
||||||
if(s_BufferIn) {
|
if(s_BufferIn) {
|
||||||
|
@ -89,7 +85,7 @@ InitSound()
|
||||||
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
|
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
|
||||||
puts(SDL_GetError());
|
puts(SDL_GetError());
|
||||||
KillSound();
|
KillSound();
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
char driverName[8];
|
char driverName[8];
|
||||||
SDL_AudioDriverName(driverName, 8);
|
SDL_AudioDriverName(driverName, 8);
|
||||||
|
@ -125,12 +121,11 @@ InitSound()
|
||||||
return 0;
|
return 0;
|
||||||
s_BufferRead = s_BufferWrite = s_BufferIn = 0;
|
s_BufferRead = s_BufferWrite = s_BufferIn = 0;
|
||||||
|
|
||||||
//printf("SDL Size: %d, Internal size: %d\n",spec.samples,s_BufferSize);
|
if(SDL_OpenAudio(&spec, 0) < 0)
|
||||||
|
{
|
||||||
if(SDL_OpenAudio(&spec, 0) < 0) {
|
|
||||||
puts(SDL_GetError());
|
puts(SDL_GetError());
|
||||||
KillSound();
|
KillSound();
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
SDL_PauseAudio(0);
|
SDL_PauseAudio(0);
|
||||||
|
|
||||||
|
@ -142,7 +137,7 @@ InitSound()
|
||||||
FCEUI_SetSquare2Volume(soundsquare2volume);
|
FCEUI_SetSquare2Volume(soundsquare2volume);
|
||||||
FCEUI_SetNoiseVolume(soundnoisevolume);
|
FCEUI_SetNoiseVolume(soundnoisevolume);
|
||||||
FCEUI_SetPCMVolume(soundpcmvolume);
|
FCEUI_SetPCMVolume(soundpcmvolume);
|
||||||
return(1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +209,7 @@ KillSound(void)
|
||||||
free((void *)s_Buffer);
|
free((void *)s_Buffer);
|
||||||
s_Buffer = 0;
|
s_Buffer = 0;
|
||||||
}
|
}
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,5 @@ bool FCEUI_AviEnableHUDrecording();
|
||||||
void FCEUI_SetAviEnableHUDrecording(bool enable);
|
void FCEUI_SetAviEnableHUDrecording(bool enable);
|
||||||
bool FCEUI_AviDisableMovieMessages();
|
bool FCEUI_AviDisableMovieMessages();
|
||||||
void FCEUI_SetAviDisableMovieMessages(bool disable);
|
void FCEUI_SetAviDisableMovieMessages(bool disable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,8 @@ FCEUD_NetworkConnect(void)
|
||||||
//memcpy(sendbuf, &data, sizeof(data));
|
//memcpy(sendbuf, &data, sizeof(data));
|
||||||
en32(sendbuf, sblen - 4);
|
en32(sendbuf, sblen - 4);
|
||||||
|
|
||||||
if(key.size()) {
|
if(key.size())
|
||||||
|
{
|
||||||
struct md5_context md5;
|
struct md5_context md5;
|
||||||
uint8 md5out[16];
|
uint8 md5out[16];
|
||||||
|
|
||||||
|
@ -191,7 +192,8 @@ FCEUD_NetworkConnect(void)
|
||||||
md5_update(&md5, (uint8 *)key.c_str(), key.size());
|
md5_update(&md5, (uint8 *)key.c_str(), key.size());
|
||||||
md5_finish(&md5, md5out);
|
md5_finish(&md5, md5out);
|
||||||
memcpy(sendbuf + 4, md5out, 16);
|
memcpy(sendbuf + 4, md5out, 16);
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
memcpy(sendbuf + 4, (uint8*)&GameInfo->MD5.data, 16);
|
memcpy(sendbuf + 4, (uint8*)&GameInfo->MD5.data, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +273,8 @@ FCEUD_RecvData(void *data,
|
||||||
int size;
|
int size;
|
||||||
NoWaiting &= ~2;
|
NoWaiting &= ~2;
|
||||||
|
|
||||||
for(;;) {
|
for(;;)
|
||||||
|
{
|
||||||
fd_set funfun;
|
fd_set funfun;
|
||||||
struct timeval popeye;
|
struct timeval popeye;
|
||||||
|
|
||||||
|
@ -283,7 +286,7 @@ FCEUD_RecvData(void *data,
|
||||||
|
|
||||||
switch(select(s_Socket + 1,&funfun,0,0,&popeye)) {
|
switch(select(s_Socket + 1,&funfun,0,0,&popeye)) {
|
||||||
case 0: continue;
|
case 0: continue;
|
||||||
case -1:return(0);
|
case -1:return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FD_ISSET(s_Socket,&funfun)) {
|
if(FD_ISSET(s_Socket,&funfun)) {
|
||||||
|
@ -305,11 +308,10 @@ FCEUD_RecvData(void *data,
|
||||||
// if(beefie)
|
// if(beefie)
|
||||||
{
|
{
|
||||||
NoWaiting|=2;
|
NoWaiting|=2;
|
||||||
//puts("Yaya");
|
|
||||||
}
|
}
|
||||||
return(1);
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return(0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue