예제 #1
0
uint8_t  loadsound(uint16_t num)
{
    int32_t   fp, l;

    if (num >= NUM_SOUNDS || SoundToggle == 0) {
        return 0;
    }
    if (FXDevice == NumSoundCards) {
        return 0;
    }

    fp = TCkopen4load(sounds[num],0);
    if (fp == -1) {
        sprintf(&fta_quotes[113][0],"Sound %s(#%d) not found.",sounds[num],num);
        FTA(113,&ps[myconnectindex],1);
        return 0;
    }

    l = kfilelength( fp );
    soundsiz[num] = l;

    Sound[num].lock = 200;

    allocache(&Sound[num].ptr,l,(uint8_t *)&Sound[num].lock);
    kread( fp, Sound[num].ptr , l);
    kclose( fp );
    return 1;
}
예제 #2
0
char * LoadAnm ( short anim_num )
{
    long handle;
    char *animbuf, *palptr;
    long i, j, k;
    DSPRINTF ( ds, "LoadAnm" );
    MONO_PRINT ( ds );
    // this seperate allows the anim to be precached easily
    ANIMnum = anim_num;
    // lock it
    walock[ANIM_TILE ( ANIMnum )] = 219;
    
    if ( anm_ptr[anim_num] == 0 )
    {
        handle = kopen4load ( ANIMname[ANIMnum], 0 );
        
        if ( handle == -1 )
        {
            return ( NULL );
        }
        
        length = kfilelength ( handle );
        allocache ( ( intptr_t * ) &anm_ptr[anim_num], length + sizeof ( anim_t ), &walock[ANIM_TILE ( ANIMnum )] );
        animbuf = ( char * ) ( FP_OFF ( anm_ptr[anim_num] ) + sizeof ( anim_t ) );
        kread ( handle, animbuf, length );
        kclose ( handle );
    }
    
    else
    {
        animbuf = ( char * ) ( FP_OFF ( anm_ptr[anim_num] ) + sizeof ( anim_t ) );
    }
    
    return ( animbuf );
}
예제 #3
0
// returns number of bytes read
int32_t S_LoadSound(uint32_t num)
{

    if (num > (unsigned)g_maxSoundPos || !ud.config.SoundToggle ) return 0;

    if (EDUKE32_PREDICT_FALSE(g_sounds[num].filename == NULL))
    {
        OSD_Printf(OSD_ERROR "Sound (#%d) not defined!\n",num);
        return 0;
    }

    int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly, 0);
    if (EDUKE32_PREDICT_FALSE(fp == -1))
    {
        OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
        return 0;
    }

    int32_t l = kfilelength(fp);
    g_soundlocks[num] = 200;
    g_sounds[num].soundsiz = l;
    allocache((intptr_t *)&g_sounds[num].ptr, l, (char *)&g_soundlocks[num]);
    l = kread(fp, g_sounds[num].ptr, l);
    kclose(fp);

    return l;
}
예제 #4
0
char loadsound(unsigned short num)
{
    long   fp, l;

    if(num >= NUM_SOUNDS || SoundToggle == 0) return 0;
    if (FXDevice < 0) return 0;

    fp = kopen4load(sounds[num],loadfromgrouponly);
    if(fp == -1)
    {
        sprintf(&fta_quotes[113][0],"Sound %s(#%d) not found.",sounds[num],num);
        FTA(113,&ps[myconnectindex]);
        return 0;
    }

    l = kfilelength( fp );
    soundsiz[num] = l;

    Sound[num].lock = 200;

    allocache((long *)&Sound[num].ptr,l,(char *)&Sound[num].lock);
    kread( fp, Sound[num].ptr , l);
    kclose( fp );
    return 1;
}
예제 #5
0
void
SMK_playFlic(char *path)
{
#if 0
     int  frames=0,i;

     if (access(path,F_OK) != 0) {
          return;
     }
     if (!noSoundFlag) {
          smk=SmackOpen(path,SMACKTRACKS,SMACKAUTOEXTRA);
     }
     else {
          smk=SmackOpen(path,0,SMACKAUTOEXTRA);
     }
     if (smk) {
          GFX_fadeOut(255);        // make sure game palette is faded
          walock[SMACKTILE]=200;
          allocache(&waloff[SMACKTILE],320L*200L,&walock[SMACKTILE]);
          tilesizx[SMACKTILE]=200;
          tilesizy[SMACKTILE]=320;
          SmackToBuffer(smk,0L,0L,320L,200L,(void *)waloff[SMACKTILE],0);
          keystatus[1]=0;
          keystatus[28]=0;
          keystatus[57]=0;
          while (1) {
               if (smk->NewPalette) {
                    SMK_loadPalette(smk->Palette);
               }
               SmackDoFrame(smk);
               SmackNextFrame(smk);
               rotatesprite(320L<<15,200L<<15,65536L,512,SMACKTILE,0,0,2+4+64,
                            0L,0L,xdim-1L,ydim-1L);
               nextpage();
               SMK_setPalette();
               while (SmackWait(smk)) {
                    if (keystatus[1] || keystatus[57] || keystatus[28]) {
                         goto done;
                    }
               }
               if (keystatus[1] || keystatus[57] || keystatus[28]) {
                    goto done;
               }
               frames++;
               if (frames == smk->Frames) {
                    goto done;
               }
          }
done:
          walock[SMACKTILE]=1;
          SmackClose(smk);
          for (i = 0 ; i < MAXRADBUFFS ; i++) {
               radbuf[i].cache_lock=1;
          }
     }
#endif
}
예제 #6
0
파일: rts.c 프로젝트: Arc0re/dukenukem3d
/*
====================
=
= RTS_GetSound
=
====================
*/
void *RTS_GetSound (int32 lump)
{
   lump++;
   if ((uint32)lump >= numlumps)
      Error ("RTS_GetSound: %i >= %i\n",lump,numlumps);

   if (lumpcache[lump] == NULL)
   {
      lumplockbyte[lump] = 200;
      allocache((char *)&lumpcache[lump],(long)RTS_SoundLength(lump-1),&lumplockbyte[lump]);
      RTS_ReadLump(lump, lumpcache[lump]);
   }
   else
   {
      if (lumplockbyte[lump] < 200)
         lumplockbyte[lump] = 200;
      else
         lumplockbyte[lump]++;
   }
   return lumpcache[lump];
}
예제 #7
0
void PTR4 *RADLINK
radmalloc(u32 numbytes)
{
     int  i;

     for (i = 0; i < MAXRADBUFFS; i++) {
          if (radbuf[i].cache_ptr == 0L) {
               break;
          }
     }
     if (i == MAXRADBUFFS) {
          crash("no more radbuff pointers");
     }
     radbuf[i].cache_lock = 200;
     radbuf[i].cache_length = numbytes;
     allocache(&(radbuf[i].cache_ptr), radbuf[i].cache_length,
               &(radbuf[i].cache_lock));
     if (radbuf[i].cache_ptr == 0L) {
          crash("radmalloc failed");
     }
     return((void PTR4 *) radbuf[i].cache_ptr);
}
예제 #8
0
파일: rts.c 프로젝트: SilkyPantsDan/eduke32
void *RTS_GetSound(int32_t lump)
{
    lump++;

    if (RTS_BAD_LUMP(lump))
        return NULL;

    if (rts_lumpcache[lump] == NULL)
    {
        rts_lumplockbyte[lump] = 200;
        allocache((intptr_t *)&rts_lumpcache[lump], RTS_SoundLength(lump-1), &rts_lumplockbyte[lump]);  // JBF 20030910: char * => int32_t *
        RTS_ReadLump(lump, rts_lumpcache[lump]);
    }
    else
    {
        if (rts_lumplockbyte[lump] < 200)
            rts_lumplockbyte[lump] = 200;
        else
            rts_lumplockbyte[lump]++;
    }

    return rts_lumpcache[lump];
}
예제 #9
0
SWBOOL CacheSound(int num, int type)
{
    VOC_INFOp vp = &voc[num];

    PRODUCTION_ASSERT(num >= 0 && num < DIGI_MAX);

    // if no data we need to cache it in
    if (!vp->data)
    {
        int handle;
        int length;

        if (!OpenSound(vp, &handle, &length))
        {
            sprintf(ds,"Could not open sound %s, num %d, priority %d\n",vp->name,num,vp->priority);
            CON_ConMessage(ds);
            return FALSE;
        }

        if (vp != NULL)
        {
            //FILE *fp;

            /*
            if (type == CACHE_SOUND_PLAY)
                // start it out locked at the min
                vp->lock = CACHE_LOCK_START;
            else
            if (type == CACHE_SOUND_PRECACHE)
                // start it out unlocked at the max
            */
            vp->lock = CACHE_UNLOCK_MAX;

            allocache((intptr_t*)&vp->data, length, &vp->lock);

#if 0
            // DEBUG
            globsndata[num] = AllocMem(length);
            glength[num] = length;

            fp = fopen(vp->name, "rb");
            if (fp != NULL)
            {
                fread(globsndata[num], length, 1, fp);
                ASSERT(globsndata[num] != NULL);
                fclose(fp);
            }
#endif
            ///////

            ASSERT(vp->data);
            ReadSound(handle, vp, length);

#if 0
            //DEBUG
            globvpdata[num] = vp->data;
            CheckSndData(__FILE__, __LINE__);
#endif
        }
    }

    return TRUE;
}