sdl: code cleanup; pre-release code review (in progress)

This commit is contained in:
punkrockguy318 2012-03-06 11:12:28 +00:00
parent 118b82544c
commit b0c2758324
22 changed files with 8298 additions and 8302 deletions

View File

@ -54,5 +54,5 @@ void InputCfg(const std::string &);
std::string GetUserText(const char* title);
const char* ButtonName(const ButtConfig* bc, int which);
#endif

View File

@ -51,8 +51,7 @@ DTestButtonJoy(ButtConfig *bc)
if(SDL_JoystickGetHat(s_Joysticks[bc->DeviceNum[x]],
((bc->ButtonNum[x] >> 8) & 0x1F)) &
(bc->ButtonNum[x]&0xFF))
return(1);
return 1;
}
else if(bc->ButtonNum[x] & 0x8000)
{
@ -61,16 +60,16 @@ DTestButtonJoy(ButtConfig *bc)
pos = SDL_JoystickGetAxis(s_Joysticks[bc->DeviceNum[x]],
bc->ButtonNum[x] & 16383);
if ((bc->ButtonNum[x] & 0x4000) && pos <= -16383) {
return(1);
return 1;
} else if (!(bc->ButtonNum[x] & 0x4000) && pos >= 16363) {
return(1);
return 1;
}
}
else if(SDL_JoystickGetButton(s_Joysticks[bc->DeviceNum[x]],
bc->ButtonNum[x]))
return(1);
return 1;
}
return(0);
return 0;
}
/**
@ -82,7 +81,7 @@ KillJoysticks()
int n; /* joystick index */
if(!s_jinited) {
return(-1);
return -1;
}
for(n = 0; n < MAX_JOYSTICKS; n++) {
@ -92,7 +91,7 @@ KillJoysticks()
s_Joysticks[n]=0;
}
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return(0);
return 0;
}
/**
@ -120,5 +119,5 @@ InitJoysticks()
}
s_jinited = 1;
return(1);
return 1;
}

View File

@ -289,5 +289,5 @@ InitOpenGL(int l,
p_glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
return(1);
return 1;
}

View File

@ -51,10 +51,6 @@ fillaudio(void *udata,
{
int16 *tmps = (int16*)stream;
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) {
int16 sample = 0;
if(s_BufferIn) {
@ -89,7 +85,7 @@ InitSound()
if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
puts(SDL_GetError());
KillSound();
return(0);
return 0;
}
char driverName[8];
SDL_AudioDriverName(driverName, 8);
@ -125,12 +121,11 @@ InitSound()
return 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());
KillSound();
return(0);
return 0;
}
SDL_PauseAudio(0);
@ -142,7 +137,7 @@ InitSound()
FCEUI_SetSquare2Volume(soundsquare2volume);
FCEUI_SetNoiseVolume(soundnoisevolume);
FCEUI_SetPCMVolume(soundpcmvolume);
return(1);
return 1;
}
@ -214,7 +209,7 @@ KillSound(void)
free((void *)s_Buffer);
s_Buffer = 0;
}
return(0);
return 0;
}

View File

@ -8,5 +8,5 @@ bool FCEUI_AviEnableHUDrecording();
void FCEUI_SetAviEnableHUDrecording(bool enable);
bool FCEUI_AviDisableMovieMessages();
void FCEUI_SetAviDisableMovieMessages(bool disable);
#endif

View File

@ -182,7 +182,8 @@ FCEUD_NetworkConnect(void)
//memcpy(sendbuf, &data, sizeof(data));
en32(sendbuf, sblen - 4);
if(key.size()) {
if(key.size())
{
struct md5_context md5;
uint8 md5out[16];
@ -191,7 +192,8 @@ FCEUD_NetworkConnect(void)
md5_update(&md5, (uint8 *)key.c_str(), key.size());
md5_finish(&md5, md5out);
memcpy(sendbuf + 4, md5out, 16);
} else {
} else
{
memcpy(sendbuf + 4, (uint8*)&GameInfo->MD5.data, 16);
}
@ -271,7 +273,8 @@ FCEUD_RecvData(void *data,
int size;
NoWaiting &= ~2;
for(;;) {
for(;;)
{
fd_set funfun;
struct timeval popeye;
@ -283,7 +286,7 @@ FCEUD_RecvData(void *data,
switch(select(s_Socket + 1,&funfun,0,0,&popeye)) {
case 0: continue;
case -1:return(0);
case -1:return 0;
}
if(FD_ISSET(s_Socket,&funfun)) {
@ -305,11 +308,10 @@ FCEUD_RecvData(void *data,
// if(beefie)
{
NoWaiting|=2;
//puts("Yaya");
}
return(1);
return 1;
} else {
return(0);
return 0;
}
}
}