void es_freeCursor(sdl_data *sd, int len, char *bp) { SDL_Cursor *c; POPGLPTR(c, bp); SDL_FreeCursor(c); }
void es_joystick_close(sdl_data *sd, int len,char *buff) { char *bp; SDL_Joystick *joy; bp = buff; POPGLPTR(joy, bp); SDL_JoystickClose(joy); }
void es_freeWAV(sdl_data *sd, int len, char *buff) { char *bp; void *ptr; bp = buff; POPGLPTR(ptr, bp); SDL_FreeWAV(ptr); }
void es_joystick_getAxis(sdl_data *sd, int len,char *buff) { int sendlen; char *bp, *start; SDL_Joystick *joy; int state, axis; bp = buff; POPGLPTR(joy, bp); axis = get8(bp); bp = start = sdl_get_temp_buff(sd, 4); state = SDL_JoystickGetAxis(joy, axis); put32be(bp, state); sendlen = bp - start; sdl_send(sd, sendlen); }
void es_joystick_numButtons(sdl_data *sd, int len,char *buff) { int sendlen; char *bp, *start; SDL_Joystick *joy; int buttons; bp = buff; POPGLPTR(joy, bp); bp = start = sdl_get_temp_buff(sd, 1); buttons = SDL_JoystickNumButtons(joy); put8(bp,buttons); sendlen = bp - start; sdl_send(sd, sendlen); }
void es_joystick_index(sdl_data *sd, int len,char *buff) { int sendlen; char *bp, *start; SDL_Joystick *joy; int index; bp = buff; POPGLPTR(joy, bp); bp = start = sdl_get_temp_buff(sd, 1); index = SDL_JoystickIndex(joy); put8(bp,index); sendlen = bp - start; sdl_send(sd, sendlen); }
void es_joystick_getButton(sdl_data *sd, int len,char *buff) { int sendlen; char *bp, *start; SDL_Joystick *joy; int state; Uint8 button; bp = buff; POPGLPTR(joy, bp); button = get8(bp); bp = start = sdl_get_temp_buff(sd, 1); state = SDL_JoystickGetButton(joy, button); put8(bp,state); sendlen = bp - start; sdl_send(sd, sendlen); }
void es_joystick_getBall(sdl_data *sd, int len,char *buff) { int sendlen; char *bp, *start; SDL_Joystick *joy; int dx, dy; Uint8 ball; bp = buff; POPGLPTR(joy, bp); ball = get8(bp); bp = start = sdl_get_temp_buff(sd, 8); if(0 == SDL_JoystickGetBall(joy, ball, &dx, &dy)) { put32be(bp, dx); put32be(bp, dy); } sendlen = bp - start; sdl_send(sd, sendlen); }
void play_audio(sdl_data *sd, int len, char *buff) { char *bp, *start; int sendlen; void * sbuff; bp = buff; SDL_LockAudio(); POPGLPTR(sbuff, bp); wave.sound = sbuff; wave.soundlen = get32be(bp); wave.repeat = get32be(bp); wave.soundpos = 0; SDL_UnlockAudio(); bp = start = sdl_getbuff(sd, 0); sendlen = (int) (bp - start); sdl_send(sd, sendlen); }
void es_convertAudio(sdl_data *sd, int len, char *buff) { char *bp, *start; void *mptr; Uint16 oformat, nformat; Uint8 ochannels, nchannels; int ofreq, nfreq, osize, nsize; SDL_AudioCVT wav_cvt; int sendlen; bp = buff; oformat = get16be(bp); ochannels = get8(bp); ofreq = get32be(bp); nformat = get16be(bp); nchannels = get8(bp); nfreq = get32be(bp); POPGLPTR(mptr, bp); osize = get32be(bp); bp = start = sdl_getbuff(sd, 12); /* Build AudioCVT */ if(SDL_BuildAudioCVT(&wav_cvt,oformat, ochannels, ofreq, nformat, nchannels, nfreq) >= 0) { /* Setup for conversion */ nsize = osize*wav_cvt.len_mult; wav_cvt.buf=(Uint8 *)malloc(nsize); if(wav_cvt.buf != NULL) { wav_cvt.len=osize; memcpy(wav_cvt.buf, mptr, osize); if (SDL_ConvertAudio(&wav_cvt) >= 0) { PUSHGLPTR(wav_cvt.buf, bp); put32be(bp, nsize); } } } sendlen = (int) (bp - start); sdl_send(sd, sendlen); }
void copySdlImage2GLArray(sdl_data *sd, int len, char * buff) { Uint8 *rowhi, *rowlo, type; SDL_Surface *image; GLubyte * mem; char *bp, *start; int i, j = 0, k, sendlen; Uint8 rs,bs,gs,as; bp = buff; POPGLPTR(image, bp); type = *bp; if (sd->next_bin == 1) { mem = (GLubyte *) sd->bin[0].base; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rs = (2 - image->format->Rshift/8); gs = (2 - image->format->Gshift/8); bs = (2 - image->format->Bshift/8); as = (2 - image->format->Ashift/8); #else rs = image->format->Rshift/8; gs = image->format->Gshift/8; bs = image->format->Bshift/8; as = image->format->Ashift/8; #endif /* GL surfaces are upsidedown (according to SDL examples)?? */ k = 0; rowhi = (Uint8 *)image->pixels; rowlo = rowhi + (image->h * image->pitch) - image->pitch; for(i=0; i<image->h; ++i ) { for(j=0; j<image->w; ++j ) { switch(image->format->BytesPerPixel) { case 1: mem[k++] = image->format->palette->colors[rowlo[j]].r; mem[k++] = image->format->palette->colors[rowlo[j]].g; mem[k++] = image->format->palette->colors[rowlo[j]].b; if(type == 4) mem[k++] = 0; break; case 3: mem[k++] = rowlo[j*3 + rs]; mem[k++] = rowlo[j*3 + gs]; mem[k++] = rowlo[j*3 + bs]; if(type == 4) mem[k++] = 0; break; case 4: mem[k++] = rowlo[j*4 + rs]; mem[k++] = rowlo[j*4 + gs]; mem[k++] = rowlo[j*4 + bs]; if(type == 4) mem[k++] = rowlo[j*4 + as]; break; } } rowlo -= image->pitch; } /* fprintf(stderr, "i %d, j %d k%d\n\r", i, j, k); */ bp = start = sdl_getbuff(sd, 1); put8(bp, 1); sendlen = bp - start; sdl_send(sd, sendlen); sdl_free_binaries(sd); } }