Пример #1
0
void es_peepEvents(sdl_data *sd, int len, char *bp)
{
  SDL_Event events[256];
  int numevents, res;
  Uint32 mask;
  char *start;

  if (len == 0) {
    mask = SDL_ALLEVENTS;
    numevents = 16;
  } else {
    mask = * (Uint32 *) bp; bp += sizeof(Uint32);
    numevents = *bp++;
  }
  SDL_PumpEvents();
  res = SDL_PeepEvents(events, numevents, SDL_GETEVENT, mask);
  if (res > 0) {
    int sendlen, i;
    bp = start = sdl_get_temp_buff(sd, res*MAX_EVENT_SIZE);
    for (i = 0; i < res; i++) {
      bp = encode_event(&(events[i]), bp);
    }
    sendlen = bp - start;
    sdl_send(sd, sendlen);
  }
}
Пример #2
0
void mygl_alloc(sdl_data *sd, int len, char *bp)
{
   char *start;
   unsigned size;

   size = * (unsigned *) bp;
   bp = start = sdl_getbuff(sd, size);
   sdl_send(sd, size);
}
Пример #3
0
/* API */
void es_audioDriverName(sdl_data *sd, int len, char *bp)
{
  int sendlen = 0;
    
  bp = sdl_get_temp_buff(sd, 256);
  if (SDL_AudioDriverName(bp, 256) != NULL) {
      sendlen = (int) strlen(bp);
  }
  sdl_send(sd, sendlen);
}
Пример #4
0
void es_getAppState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 state;

   bp = start = sdl_get_temp_buff(sd, 1);
   state = SDL_GetAppState();
   put8(bp, state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #5
0
void es_getCursor(sdl_data *sd, int len,char *buff)
{
   char *bp, *start;
   SDL_Cursor *c;
   int sendlen;
   
   bp = start = sdl_get_temp_buff(sd, 8);
   c = SDL_GetCursor();
   PUSHGLPTR(c, bp);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #6
0
void es_getAudioStatus(sdl_data *sd, int len, char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_audiostatus s;
   
   s = SDL_GetAudioStatus();
   start = bp = sdl_getbuff(sd, 1);
   put8(bp, s);
   sendlen = (int) (bp - start);
   sdl_send(sd, sendlen);
}
Пример #7
0
void es_getError(sdl_data *sd, int len, char *buff)
{
    char * err, *bp, *start;
    int length;
    err = SDL_GetError();
    length = strlen(err);
    bp = start = sdl_getbuff(sd, length);
    while(*err != '\0') {
        put8(bp, *err++);
    }
    sdl_send(sd, bp - start);
}
Пример #8
0
void es_getKeyState(sdl_data *sd, int len,char *buff)
{
   Uint8 * keys;
   char *bp, *start;
   int length, sendlen, i;

   keys = SDL_GetKeyState(&length);
   bp = start = sdl_get_temp_buff(sd, length);
   for(i=0; i<length; i++)
      put8(bp, keys[i]);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #9
0
void es_getModState(sdl_data *sd, int len,char *buff)
{
   Uint16 state;

   if ((state = SDL_GetModState()) != 0) {
     int sendlen;
     char *bp, *start;
     bp = start = sdl_get_temp_buff(sd, 2);
     put16be(bp, state);
     sendlen = bp - start;
     sdl_send(sd, sendlen);
   }
}
Пример #10
0
void es_numJoysticks(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int joys;

   bp = buff;
   bp = start = sdl_get_temp_buff(sd, 1);
   joys = SDL_NumJoysticks();
   put8(bp, joys);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #11
0
void es_showCursor(sdl_data *sd, int len, char *bp)
{
   int sendlen;
   char *start;
   Uint8 bool;

   bool = (Uint8) *bp;
   bool = SDL_ShowCursor(bool);
   bp = start = sdl_get_temp_buff(sd, 1);
   put8(bp, bool);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #12
0
void es_enableUNICODE(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 enable;

   bp = buff;
   enable = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   enable = SDL_EnableUNICODE(enable);
   put8(bp, enable);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #13
0
void es_joystick_eventState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int state;
   
   bp = buff;
   state = get32be(bp);
   bp = start = sdl_get_temp_buff(sd, 4);
   state = SDL_JoystickEventState(state);
   put32be(bp, state);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #14
0
void es_pollEvent(sdl_data *sd, int len, char *buff)
{
  SDL_Event event;
  
  if (SDL_PollEvent(&event)) {
    int sendlen;
    char *bp, *start;

    bp = start = sdl_get_temp_buff(sd, MAX_EVENT_SIZE);
    bp = encode_event(&event, bp);
    sendlen = bp - start;
    sdl_send(sd, sendlen);
  }
}
Пример #15
0
void es_enableKeyRepeat(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint16 delay, intv, res;
   bp = buff;
   delay = get16be(bp);
   intv  = get16be(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   res = SDL_EnableKeyRepeat(delay, intv);
   put8(bp, res);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #16
0
void es_waitEvent(sdl_data *sd, int len,char *buff)
{
    SDL_Event event;
    int sendlen;
    char *bp, *start;
    
    bp = start = sdl_get_temp_buff(sd, MAX_EVENT_SIZE);
    SDL_WaitEvent(&event);
    bp = encode_event(&event, bp);
    if (*start != SDL_NOEVENT) {
      sendlen = bp - start;
      sdl_send(sd, sendlen);
    }
}
Пример #17
0
void es_joystick_opened(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int index, bool;
   
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 1);
   bool = SDL_JoystickOpened(index);
   put8(bp, bool);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #18
0
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);
}
Пример #19
0
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);
}
Пример #20
0
void es_getRelativeMouseState(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   Uint8 state;
   int x, y;

   bp = start = sdl_get_temp_buff(sd, 5);
   state = SDL_GetRelativeMouseState(&x, &y);
   put8(bp, state);
   put16be(bp, x);
   put16be(bp, y);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #21
0
void es_eventState(sdl_data *sd, int len, char *bp) 
{
   Uint8 type, res;
   int sendlen, state;
   char *start;
    
   type  = get8(bp);
   state = get8(bp);

   res = SDL_EventState(type, state);
   bp = start = sdl_get_temp_buff(sd, 1);
   put8(bp, res);
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #22
0
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);
}
Пример #23
0
void es_joystick_open(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   SDL_Joystick *joy;
   int index;
   
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 8);
   if((joy = SDL_JoystickOpen(index)) != NULL) {
      PUSHGLPTR(joy, bp);
   }
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #24
0
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);
}
Пример #25
0
void es_joystick_name(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start;
   int index;
   const char * name;
   bp = buff;
   index = get8(bp);
   bp = start = sdl_get_temp_buff(sd, 256);
   name = SDL_JoystickName(index);
   index = 0;
   while(*name != '\0' && index++ < 256) {
      put8(bp, *name);
      name++;
   }
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #26
0
void es_getKeyName(sdl_data *sd, int len,char *buff)
{
   int sendlen;
   char *bp, *start, *name;
   Uint16 key;
   
   bp = buff;
   key = get16be(bp);
   bp = start = sdl_get_temp_buff(sd, 128);
   name = SDL_GetKeyName(key);
   while(*name != '\0') {
      put8(bp, *name);
      name++;
   }
   
   sendlen = bp - start;
   sdl_send(sd, sendlen);
}
Пример #27
0
void es_openAudio(sdl_data *sd, int len, char *buff)
{
   int sendlen;
   char *bp, *start;
   int ff;
   SDL_AudioSpec desired, obtained, *obptr;
   bp = buff;
   ff = get8(bp);
   desired.freq     = get32be(bp);
   desired.format   = get16be(bp);
   desired.channels = get8(bp);
   desired.samples  = get16be(bp);
   desired.padding  = get16be(bp);
   desired.callback = myaudiomixer;

   /* Init the global data structures */
   wave.sound = NULL;
   wave.soundpos = 0;
   wave.soundlen = 0;

   if(ff == 1)  /* Force the requested format */
      obptr = NULL;
   else 
      obptr = &obtained;
   
   bp = start = sdl_getbuff(sd, 16);
   if( SDL_OpenAudio(&desired, obptr) < 0 ) {
      fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());		
   } else {
      if(ff == 1) 
	  obptr = &desired;
       put32be(bp, obptr->freq);
       put16be(bp, obptr->format);
       put8(bp, obptr->channels);
       put8(bp, obptr->silence);
       put16be(bp, obptr->samples);
       put16be(bp, obptr->padding);
       put32be(bp, obptr->size);
       wave.silence = obptr->silence;
   } 
  
   sendlen = (int) (bp - start);
   sdl_send(sd, sendlen);
}
Пример #28
0
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);
}
Пример #29
0
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);
}
Пример #30
0
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);
}