示例#1
0
void texcache_syncmemcache(void)
{
    int32_t len = Bfilelength(texcache.filehandle);

    if (!texcache.memcache.ptr || texcache.filehandle == -1 || len <= (int32_t)texcache.memcache.size)
        return;

    texcache.memcache.ptr = (uint8_t *)Brealloc(texcache.memcache.ptr, len);

    if (!texcache.memcache.ptr)
    {
        texcache_clearmemcache();
        initprintf("Failed syncing memcache to texcache, disabling memcache.\n");
        texcache.memcache.noalloc = 1;
    }
    else
    {
        initprintf("Syncing memcache to texcache\n");
        Blseek(texcache.filehandle, texcache.memcache.size, BSEEK_SET);
        if (Bread(texcache.filehandle, texcache.memcache.ptr + texcache.memcache.size, len - texcache.memcache.size) != (bssize_t)(len-texcache.memcache.size))
        {
            initprintf("polymost_cachesync: Failed reading texcache into memcache!\n");
            texcache_clearmemcache();
            texcache.memcache.noalloc = 1;
        }
        else
        {
            texcache.memcache.size = len;
        }
    }
}
示例#2
0
int scriptfile_getbraces(scriptfile *sf, char **braceend)
{
	int bracecnt;
	char *bracestart;

	skipoverws(sf);
	if (sf->textptr >= sf->eof)
	{
		initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr));
		return -1;
	}

	if (sf->textptr[0] != '{') {
		initprintf("Error on line %s:%d: expecting '{'\n",sf->filename,scriptfile_getlinum(sf,sf->textptr));
		return -1;
	}
	bracestart = ++sf->textptr; bracecnt = 1;
	while (1)
	{
		if (sf->textptr >= sf->eof) return(0);
		if (sf->textptr[0] == '{') bracecnt++;
		if (sf->textptr[0] == '}') { bracecnt--; if (!bracecnt) break; }
		sf->textptr++;
	}
	(*braceend) = sf->textptr;
	sf->textptr = bracestart;
	return 0;
}
示例#3
0
void texcache_openfiles(void)
{
    Bstrcpy(ptempbuf,TEXCACHEFILE);
    Bstrcat(ptempbuf,".cache");
    texcache.index = Bfopen(ptempbuf, "at+");
    texcache.filehandle = Bopen(TEXCACHEFILE, BO_BINARY|BO_CREAT|BO_APPEND|BO_RDWR, BS_IREAD|BS_IWRITE);

    if (!texcache.index || texcache.filehandle < 0)
    {
        initprintf("Unable to open cache file \"%s\" or \"%s\": %s\n", TEXCACHEFILE, ptempbuf, strerror(errno));
        texcache_closefiles();
        glusetexcache = 0;
        return;
    }

    Bfseek(texcache.index, 0, BSEEK_END);
    if (!Bftell(texcache.index))
    {
        Brewind(texcache.index);
        Bfprintf(texcache.index,"// automatically generated by EDuke32, DO NOT MODIFY!\n");
    }
    else Brewind(texcache.index);

    initprintf("Opened \"%s\" as cache file\n", TEXCACHEFILE);
}
示例#4
0
/*
= RTS_AddFile
=
= All files are optional, but at least one file must be found
= Files with a .rts extension are wadlink files with multiple lumps
= Other files are single lumps with the base filename for the lump name
*/
static int32_t RTS_AddFile(const char *filename)
{
    wadinfo_t  header;
    int32_t i, handle, length, startlump;
    filelump_t *fileinfo, *fileinfoo;

    // read the entire file in
    //      FIXME: shared opens

    handle = kopen4loadfrommod(filename, 0);
    if (handle < 0)
    {
        initprintf("RTS file \"%s\" was not found\n",filename);
        return -1;
    }

    startlump = rts_numlumps;

    // WAD file
    i = kread(handle, &header, sizeof(header));
    if (i != sizeof(header) || Bmemcmp(header.identification, "IWAD", 4))
    {
        initprintf("RTS file \"%s\" too short or doesn't have IWAD id\n", filename);
        kclose(handle);
        return -1;
    }

    header.numlumps = B_LITTLE32(header.numlumps);
    header.infotableofs = B_LITTLE32(header.infotableofs);

    length = header.numlumps*sizeof(filelump_t);
    fileinfo = fileinfoo = (filelump_t *)Xmalloc(length);

    klseek(handle, header.infotableofs, SEEK_SET);
    kread(handle, fileinfo, length);

    {
        lumpinfo_t *lump_p = (lumpinfo_t *)Xrealloc(
            rts_lumpinfo, (rts_numlumps + header.numlumps)*sizeof(lumpinfo_t));

        rts_lumpinfo = lump_p;
    }

    rts_numlumps += header.numlumps;

    for (i=startlump; i<rts_numlumps; i++, fileinfo++)
    {
        lumpinfo_t *lump = &rts_lumpinfo[i];

        lump->handle = handle;  // NOTE: cache1d-file is not closed!
        lump->position = B_LITTLE32(fileinfo->filepos);
        lump->size = B_LITTLE32(fileinfo->size);

        Bstrncpy(lump->name, fileinfo->name, 8);
    }

    Bfree(fileinfoo);

    return 0;
}
示例#5
0
void texcache_setupmemcache(void)
{
    if (!glusememcache || texcache.memcache.noalloc || !texcache_enabled())
        return;

    texcache.memcache.size = Bfilelength(texcache.filehandle);

    if (texcache.memcache.size <= 0)
        return;

    texcache.memcache.ptr = (uint8_t *)Brealloc(texcache.memcache.ptr, texcache.memcache.size);

    if (!texcache.memcache.ptr)
    {
        initprintf("Failed allocating %d bytes for memcache, disabling memcache.\n", (int)texcache.memcache.size);
        texcache_clearmemcache();
        texcache.memcache.noalloc = 1;
        return;
    }

    if (Bread(texcache.filehandle, texcache.memcache.ptr, texcache.memcache.size) != (bssize_t)texcache.memcache.size)
    {
        initprintf("Failed reading texcache into memcache!\n");
        texcache_clearmemcache();
        texcache.memcache.noalloc = 1;
    }
}
示例#6
0
文件: grpscan.c 项目: dahlor/Duke3DS
int32_t ScanGroups(void)
{
    CACHE1D_FIND_REC *srch;
    struct grpcache *fg, *fgg;

    initprintf("Searching for game data...\n");

    LoadGameList();
    LoadGroupsCache();

    srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);
    ProcessGroups(srch);
    klistfree(srch);

    srch = klistpath("/", "*.ssi", CACHE1D_FIND_FILE);
    ProcessGroups(srch);
    klistfree(srch);

    FreeGroupsCache();

    for (grpfile_t *grp = foundgrps; grp; grp=grp->next)
    {
        if (grp->type->dependency)
        {
            if (FindGroup(grp->type->dependency) == NULL) // couldn't find dependency
            {
                //initprintf("removing %s\n", grp->name);
                RemoveGroup(grp);
                grp = foundgrps;
                // start from the beginning so we can remove anything that depended on this grp
                continue;
            }
        }
    }

    if (usedgrpcache)
    {
        int32_t i = 0;
        FILE *fp;
        fp = fopen(GRPCACHEFILE, "wt");
        if (fp)
        {
            for (fg = usedgrpcache; fg; fg=fgg)
            {
                fgg = fg->next;
                fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
                Bfree(fg);
                i++;
            }
            fclose(fp);
        }
//        initprintf("Found %d recognized GRP %s.\n",i,i>1?"files":"file");

        return 0;
    }

    initprintf("Found no recognized game data!\n");

    return 0;
}
示例#7
0
//
// initsystem() -- init SDL systems
//
int32_t initsystem(void)
{
#if defined NOSDLPARACHUTE
    const int sdlinitflags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
#else
    const int sdlinitflags = SDL_INIT_VIDEO;
#endif

    mutex_init(&m_initprintf);

#ifdef _WIN32
    win_init();
#endif

    if (sdlayer_checkversion())
        return -1;

    if (SDL_Init(sdlinitflags))
    {
        initprintf("Initialization failed! (%s)\nNon-interactive mode enabled\n", SDL_GetError());
        novideo = 1;
#ifdef USE_OPENGL
        nogl = 1;
#endif
    }

    atexit(uninitsystem);

    frameplace = 0;
    lockcount = 0;


    if (!novideo)
    {
        char drvname[32];

#ifdef USE_OPENGL
        if (loadgldriver(getenv("BUILD_GLDRV")))
        {
            initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
            nogl = 1;
        }
#endif

        if (SDL_VideoDriverName(drvname, 32))
            initprintf("Using \"%s\" video driver\n", drvname);

        wm_setapptitle(apptitle);
    }

#if defined GEKKO
    SDL_ShowCursor(SDL_DISABLE);
#endif

    return 0;
}
示例#8
0
// Duke3D-specific.  --ryan.
// void MUSIC_PlayMusic(char *_filename)
int32_t MUSIC_PlaySong(char *song, int32_t loopflag)
{
//	initprintf("MUSIC_PlaySong");
    MUSIC_StopSong();

    if (external_midi)
    {
        FILE *fp;

#if defined FORK_EXEC_MIDI
        static int32_t sigchld_handler_set = 0;

        if (!sigchld_handler_set)
        {
            struct sigaction sa;
            sa.sa_handler=sigchld_handler;
            sa.sa_flags=0;
            sigemptyset(&sa.sa_mask);

            if (sigaction(SIGCHLD, &sa, NULL)==-1)
                initprintf("%s: sigaction: %s\n", __func__, strerror(errno));

            sigchld_handler_set = 1;
        }
#endif

        fp = Bfopen(external_midi_tempfn, "wb");
        if (fp)
        {
            fwrite(song, 1, g_musicSize, fp);
            Bfclose(fp);

#if defined FORK_EXEC_MIDI
            external_midi_restart = loopflag;
            playmusic();
#else
            music_musicchunk = Mix_LoadMUS(external_midi_tempfn);
            if (!music_musicchunk)
                initprintf("Mix_LoadMUS: %s\n", Mix_GetError());
#endif
        }
        else initprintf("%s: fopen: %s\n", __func__, strerror(errno));
    }
    else
        music_musicchunk = Mix_LoadMUS_RW(SDL_RWFromMem((char *) song, g_musicSize)
#if (SDL_MAJOR_VERSION > 1)
            , SDL_FALSE
#endif
            );

    if (music_musicchunk != NULL)
        if (Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_LoopSong)?-1:0) == -1)
            initprintf("Mix_PlayMusic: %s\n", Mix_GetError());

    return MUSIC_Ok;
}
示例#9
0
void S_MusicStartup(void)
{
    initprintf("Initializing music...\n");

    if (MUSIC_Init(0, 0) == MUSIC_Ok || MUSIC_Init(1, 0) == MUSIC_Ok)
    {
        MUSIC_SetVolume(MASTER_VOLUME(ud.config.MusicVolume));
        return;
    }

    initprintf("S_MusicStartup(): failed initializing\n");
}
示例#10
0
文件: winbits.c 项目: clobber/eduke32
static void win_printversion(void)
{
    const char *ver = "";

    switch (osv.dwPlatformId)
    {
    case VER_PLATFORM_WIN32_NT:
        if (osv.dwMajorVersion == 5)
        {
            switch (osv.dwMinorVersion)
            {
            case 1:
                ver = "XP";
                break;
            case 2:
                ver = osv.wProductType == VER_NT_WORKSTATION ? "XP x64" : "Server 2003";
                break;
            }
            break;
        }

        if (osv.dwMajorVersion == 6)
        {
            switch (osv.dwMinorVersion)
            {
            case 0:
                ver = osv.wProductType == VER_NT_WORKSTATION ? "Vista" : "Server 2008";
                break;
            case 1:
                ver = osv.wProductType == VER_NT_WORKSTATION ? "7" : "Server 2008 R2";
                break;
            case 2:
                ver = osv.wProductType == VER_NT_WORKSTATION ? "8" : "Server 2012";
                break;
            case 3:
                ver = osv.wProductType == VER_NT_WORKSTATION ? "8.1" : "Server 2012 R2";
                break;
            }
            break;
        }
        break;
    }

    initprintf("Windows %s", ver);
    if (osv.szCSDVersion && osv.szCSDVersion[0])
        initprintf(" %s", osv.szCSDVersion);
    initprintf(" (build %lu.%lu.%lu)\n", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
}
示例#11
0
static int osdcmd_vidmode(const osdfuncparm_t *parm)
{
	int newbpp = ScreenBPP, newwidth = ScreenWidth,
		newheight = ScreenHeight, newfs = ScreenMode;
	if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;

	switch (parm->numparms) {
		case 1:	// bpp switch
			newbpp = Batol(parm->parms[0]);
			break;
		case 2: // res switch
			newwidth = Batol(parm->parms[0]);
			newheight = Batol(parm->parms[1]);
			break;
		case 3:	// res & bpp switch
		case 4:
			newwidth = Batol(parm->parms[0]);
			newheight = Batol(parm->parms[1]);
			newbpp = Batol(parm->parms[2]);
			if (parm->numparms == 4)
				newfs = (Batol(parm->parms[3]) != 0);
			break;
	}

	if (setgamemode(newfs,newwidth,newheight,newbpp)) {
		initprintf("vidmode: Mode change failed!\n");
		if (setgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP))
			gameexit("vidmode: Reset failed!\n");
	}
	ScreenBPP = newbpp; ScreenWidth = newwidth; ScreenHeight = newheight;
	ScreenMode = newfs;
	onvideomodechange(ScreenBPP>8);
	vscrn();
	return OSDCMD_OK;
}
void BuildRHITextureDirect3D11::UploadRegion(int x, int y, int width, int height, const void *buffer) const
{
	ID3D11Resource *resourceToUpdate = NULL;

	if (texture1D)
		resourceToUpdate = texture1D;
	else if (texture2D)
		resourceToUpdate = texture2D;

	if (resourceToUpdate == NULL)
	{
		initprintf("UploadRegion: resourceToUpdate == NULL\n");
		return;
	}

	D3D11_MAPPED_SUBRESOURCE mappedResource;
	DX::RHIGetD3DDeviceContext()->Map(resourceToUpdate, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);

	BYTE* mappedData = reinterpret_cast<BYTE*>(mappedResource.pData);
	byte *buffer2 = (byte *)buffer;
	int rowSpan = rhi.GetImagePitchFromTextureFormat(format, width);
	for (UINT i = 0; i < height; ++i)
	{
		memcpy(mappedData, buffer2, rowSpan);
		mappedData += mappedResource.RowPitch;
		buffer2 += rowSpan;
	}
//	memcpy(mappedResource.pData, buffer, (width * height * rhi.GetImageBitsFromTextureFormat(format)));

	DX::RHIGetD3DDeviceContext()->Unmap(resourceToUpdate, 0);
}
示例#13
0
char testcd( char *fn, long testsiz )
{
	DWORD driveletters;
	int i, fil, dalen;
	char name[32]="x:\\SUPPORT\\",driv[4]="x:\\";

	strcat(name,fn);

	driveletters = GetLogicalDrives();
	for (i=2; i<26; i++) {
		if (!(driveletters & (1ul<<i))) continue;
		driv[0] = 'A'+i;
		if (GetDriveType(driv) != DRIVE_CDROM) continue;

		name[0] = 'A'+i;
		fil = Bopen(name,O_RDONLY,S_IREAD);
		if (fil<0) continue;
		dalen = Bfilelength(fil);
		Bclose(fil);

		if (dalen == testsiz) {
			initprintf("Copy Protection: Found CDROM in drive %c:\n", driv[0]);
			return 0;
		}
	}

	wm_msgbox("Duke Nukem 3D","Copy Protection: Failed to find CDROM");
	return 1;
}
示例#14
0
void MusicStartup( void )
   {
   int32 status;
   int musicdevicetype;

   // if they chose None lets return
   if (MusicDevice < 0) {
      return;
   } else if (MusicDevice == 0) {
      musicdevicetype = ASS_AutoDetect;
   } else {
      musicdevicetype = MusicDevice - 1;
   }
   
   status = MUSIC_Init( musicdevicetype, 0 );

   if ( status == MUSIC_Ok )
      {
      MUSIC_SetVolume( MusicVolume );
      }
   else
   {
      initprintf("Couldn't find selected sound card, or, error w/ sound card itself.\n");

      SoundShutdown();
      uninittimer();
      uninitengine();
      CONTROL_Shutdown();
      CONFIG_WriteSetup();
      KB_Shutdown();
      uninitgroupfile();
      //unlink("duke3d.tmp");
      exit(-1);
   }
}
示例#15
0
void initcache(intptr_t dacachestart, int32_t dacachesize)
{
    int32_t i;

    for (i=1; i<200; i++) lockrecip[i] = (1<<28)/(200-i);

    // The following code was relocated here from engine.c, since this
    // function is only ever called once (from there), and it seems to
    // really belong here:
    //
    //   initcache((FP_OFF(pic)+15)&0xfffffff0,(cachesize-((-FP_OFF(pic))&15))&0xfffffff0);
    //
    // I'm not sure why it's necessary, but the code is making sure the
    // cache starts on a multiple of 16 bytes?  -- SA

//printf("BEFORE: cachestart = %x, cachesize = %d\n", dacachestart, dacachesize);
    cachestart = ((uintptr_t)dacachestart+15)&~(uintptr_t)0xf;
    cachesize = (dacachesize-(((uintptr_t)(dacachestart))&0xf))&~(uintptr_t)0xf;
//printf("AFTER : cachestart = %x, cachesize = %d\n", cachestart, cachesize);

    cac[0].leng = cachesize;
    cac[0].lock = &zerochar;
    cacnum = 1;

    initprintf("Initialized %.1fM cache\n", (float)(dacachesize/1024.f/1024.f));
}
示例#16
0
void S_MusicShutdown(void)
{
    S_StopMusic();

    if (MUSIC_Shutdown() != MUSIC_Ok)
        initprintf("%s\n", MUSIC_ErrorString(MUSIC_ErrorCode));
}
示例#17
0
void SafeRead(int32_t handle, void *buffer, int32_t count)
{
    int32_t b;

    b = read(handle, buffer, count);
    if (b != count)
    {
        close(handle);
        if (handle < MaxFiles)
            initprintf("File read failure %s reading %d bytes from file %s.",
                  strerror(errno), count, FileNames[handle]);
        else
            initprintf("File read failure %s reading %d bytes.",
                  strerror(errno), count);
        return;
    }
}
示例#18
0
int32_t MUSIC_StopSong(void)
{
#if defined FORK_EXEC_MIDI
    if (external_midi)
    {
        if (external_midi_pid > 0)
        {
            int32_t ret;
            struct timespec ts;

            external_midi_restart = 0;  // make SIGCHLD handler a no-op

            ts.tv_sec = 0;
            ts.tv_nsec = 5000000;  // sleep 5ms at most

            kill(external_midi_pid, SIGTERM);
            nanosleep(&ts, NULL);
            ret = waitpid(external_midi_pid, NULL, WNOHANG|WUNTRACED);
//            printf("(%d)", ret);

            if (ret != external_midi_pid)
            {
                if (ret==-1)
                    perror("waitpid");
                else
                {
                    // we tried to be nice, but no...
                    kill(external_midi_pid, SIGKILL);
                    initprintf("%s: wait for SIGTERM timed out.\n", __func__);
                    if (waitpid(external_midi_pid, NULL, WUNTRACED)==-1)
                        perror("waitpid (2)");
                }
            }

            external_midi_pid = -1;
        }

        return(MUSIC_Ok);
    }
#endif

    //if (!fx_initialized)
    if (!Mix_QuerySpec(NULL, NULL, NULL))
    {
        setErrorMessage("Need FX system initialized, too. Sorry.");
        return(MUSIC_Error);
    } // if

    if ((Mix_PlayingMusic()) || (Mix_PausedMusic()))
        Mix_HaltMusic();

    if (music_musicchunk)
        Mix_FreeMusic(music_musicchunk);

    music_musicchunk = NULL;

    return(MUSIC_Ok);
} // MUSIC_StopSong
示例#19
0
void netsendpacket(int ind, char *buf, int len)
{
	char bbuf[ sizeof(packbuf) + sizeof(PACKET_PROXY) ];
	PACKET_PROXYp prx = (PACKET_PROXYp)bbuf;
	int i;

	// send via master if in M/S mode and we are not the master, and the recipient is not the master and not ourselves
	if (!NetBroadcastMode && myconnectindex != connecthead && ind != myconnectindex && ind != connecthead) {
		if ((unsigned)len > sizeof(packbuf)) {
			initprintf("netsendpacket(): packet length > %d!\n",sizeof(packbuf));
			len = sizeof(packbuf);
		}

		initprintf("netsendpacket() sends proxy to %d\nPlayerIndex=%d Contents:",connecthead,ind);
		for (i=0; i<len; i++)
			initprintf(" %02x", buf[i]);
		initprintf("\n");
		
		prx->PacketType = PACKET_TYPE_PROXY;
		prx->PlayerIndex = (BYTE)ind;
		memcpy(&prx[1], buf, len);	// &prx[1] == (char*)prx + sizeof(PACKET_PROXY)
		len += sizeof(PACKET_PROXY);

		sendpacket(connecthead, bbuf, len);
		return;
	}

	sendpacket(ind, buf, len);

	initprintf("netsendpacket() sends normal to %d\nContents:",ind);
	for (i=0; i<len; i++)
		initprintf(" %02x", buf[i]);
	initprintf("\n");
}
示例#20
0
void SafeClose(int32_t handle)
{
    if (handle < 0) return;
    if (close(handle) < 0)
    {
        if (handle < MaxFiles)
            initprintf("Unable to close file %s", FileNames[handle]);
        else
            initprintf("Unable to close file");
        return;
    }

    if (handle < MaxFiles && FileNames[handle])
    {
        Bfree(FileNames[handle]);
        FileNames[handle] = NULL;
    }
}
示例#21
0
int scriptfile_getstring(scriptfile *sf, char **retst)
{
	(*retst) = scriptfile_gettoken(sf);
	if (*retst == NULL)
	{
		initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr));
		return(-2);
	}
	return(0);
}
示例#22
0
文件: sdlayer.c 项目: TermiT/sw-redux
//
// initinput() -- init input system
//
int initinput(void)
{
	int i,j;
	
#ifdef __APPLE__
	// force OS X to operate in >1 button mouse mode so that LMB isn't adulterated
	if (!getenv("SDL_HAS3BUTTONMOUSE")) putenv("SDL_HAS3BUTTONMOUSE=1");
#endif
	
	if (SDL_EnableKeyRepeat(250, 30)) initprintf("Error enabling keyboard repeat.\n");
	inputdevices = 1|2;	// keyboard (1) and mouse (2)
	mouseacquired = 0;

	SDL_EnableUNICODE(1);	// let's hope this doesn't hit us too hard

	memset(keynames,0,sizeof(keynames));
	for (i=0; i<SDLK_LAST; i++) {
		if (!keytranslation[i]) continue;
		strncpy((char *)keynames[ keytranslation[i] ], SDL_GetKeyName(i), sizeof(keynames[i])-1);
	}

	if (!SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
		i = SDL_NumJoysticks();
		initprintf("%d joystick(s) found\n",i);
		for (j=0;j<i;j++) initprintf("  %d. %s\n", j+1, SDL_JoystickName(j));
		joydev = SDL_JoystickOpen(0);
		if (joydev) {
			SDL_JoystickEventState(SDL_ENABLE);
			inputdevices |= 4;

			joynumaxes    = SDL_JoystickNumAxes(joydev);
			joynumbuttons = min(32,SDL_JoystickNumButtons(joydev));
			joynumhats    = SDL_JoystickNumHats(joydev);
			initprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n",
				joynumaxes,joynumbuttons,joynumhats);

			joyaxis = (long *)Bcalloc(joynumaxes, sizeof(long));
			joyhat = (long *)Bcalloc(joynumhats, sizeof(long));
		}
	}

	return 0;
}
示例#23
0
int32_t sdlayer_checkversion(void)
{
    const SDL_version *linked = SDL_Linked_Version();
    SDL_version compiled;

    SDL_VERSION(&compiled);

    initprintf("Initializing SDL system interface "
               "(compiled against SDL version %d.%d.%d, found version %d.%d.%d)\n",
               compiled.major, compiled.minor, compiled.patch, linked->major, linked->minor, linked->patch);

    if (SDL_VERSIONNUM(linked->major, linked->minor, linked->patch) < SDL_REQUIREDVERSION)
    {
        /*reject running under SDL versions older than what is stated in sdl_inc.h */
        initprintf("You need at least v%d.%d.%d of SDL to run this game\n", SDL_MIN_X, SDL_MIN_Y, SDL_MIN_Z);
        return -1;
    }

    return 0;
}
示例#24
0
void S_SoundStartup(void)
{
    void *initdata = NULL;

#ifdef MIXERTYPEWIN
    initdata = (void *) win_gethwnd(); // used for DirectSound
#endif

    initprintf("Initializing sound... ");

    if (FX_Init(ASS_AutoDetect, ud.config.NumVoices, ud.config.NumChannels, ud.config.MixRate, initdata) != FX_Ok)
    {
        initprintf("failed! %s\n", FX_ErrorString(FX_Error));
        return;
    }

    initprintf("%d voices, %d channels, %d-bit %d Hz\n", ud.config.NumVoices, ud.config.NumChannels,
        ud.config.NumBits, ud.config.MixRate);

    for (int i=0; i<g_maxSoundPos; ++i)
    {
        for (int j = 0; j<MAXSOUNDINSTANCES; ++j)
        {
            g_sounds[i].num = 0;
            g_sounds[i].SoundOwner[j].voice = 0;
            g_sounds[i].SoundOwner[j].ow = -1;
            g_sounds[i].SoundOwner[j].sndist = UINT32_MAX;
            g_sounds[i].SoundOwner[j].clock = 0;
        }

        g_soundlocks[i] = 199;
    }

    FX_SetVolume(ud.config.MasterVolume);
    S_MusicVolume(MASTER_VOLUME(ud.config.MusicVolume));

    FX_SetReverseStereo(ud.config.ReverseStereo);
    FX_SetCallBack(S_Callback);
    FX_SetPrintf(initprintf);
    mutex_init(&s_mutex);
}
示例#25
0
文件: compat.c 项目: dahlor/Duke3DS
uint32_t Bgetsysmemsize(void)
{
#ifdef _WIN32
    uint32_t siz = UINT32_MAX;
    HMODULE lib = LoadLibrary("KERNEL32.DLL");

    if (lib)
    {
        aGlobalMemoryStatusExType aGlobalMemoryStatusEx =
            (aGlobalMemoryStatusExType)GetProcAddress(lib, "GlobalMemoryStatusEx");

        if (aGlobalMemoryStatusEx)
        {
            //WinNT
            MEMORYSTATUSEX memst;
            memst.dwLength = sizeof(MEMORYSTATUSEX);
            if (aGlobalMemoryStatusEx(&memst))
                siz = (uint32_t)min(UINT32_MAX, memst.ullTotalPhys);
        }
        else
        {
            // Yeah, there's enough Win9x hatred here that a perfectly good workaround
            // has been replaced by an error message.  Oh well, we don't support 9x anyway.
            initprintf("Bgetsysmemsize(): error determining system memory size!\n");
        }

        FreeLibrary(lib);
    }

    return siz;
#elif defined _3DS
    return 16*1024*1024;
#elif (defined(_SC_PAGE_SIZE) || defined(_SC_PAGESIZE)) && defined(_SC_PHYS_PAGES) && !defined(GEKKO)
    uint32_t siz = UINT32_MAX;
    int64_t scpagesiz, scphyspages;

#ifdef _SC_PAGE_SIZE
    scpagesiz = sysconf(_SC_PAGE_SIZE);
#else
    scpagesiz = sysconf(_SC_PAGESIZE);
#endif
    scphyspages = sysconf(_SC_PHYS_PAGES);
    if (scpagesiz >= 0 && scphyspages >= 0)
        siz = (uint32_t)min(UINT32_MAX, (int64_t)scpagesiz * (int64_t)scphyspages);

    //initprintf("Bgetsysmemsize(): %d pages of %d bytes, %d bytes of system memory\n",
    //		scphyspages, scpagesiz, siz);

    return siz;
#else
    return UINT32_MAX;
#endif
}
示例#26
0
HWND win_gethwnd(void)
{
    struct SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);

    if (SDL_GetWMInfo(&wmInfo) != 1)
    {
        initprintf("win_gethwnd: SDL_GetWindowWMInfo() failed: %s\n", SDL_GetError());
        return 0;
    }

    return wmInfo.window;
}
示例#27
0
int32_t SafeOpenRead(const char *filename, int32_t filetype)
{
    switch (filetype)
    {
    case filetype_binary:
        return SafeOpen(filename, O_RDONLY|O_BINARY, BS_IREAD);
    case filetype_text:
        return SafeOpen(filename, O_RDONLY|O_TEXT, BS_IREAD);
    default:
        initprintf("SafeOpenRead: Illegal filetype specified");
        return -1;
    }
}
示例#28
0
int scriptfile_getnumber(scriptfile *sf, int *num)
{
	skipoverws(sf);
	if (sf->textptr >= sf->eof)
	{
		initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr));
		return -1;
	}

	while ((sf->textptr[0] == '0') && (sf->textptr[1] >= '0') && (sf->textptr[1] <= '9'))
		sf->textptr++; //hack to treat octal numbers like decimal
	
	sf->ltextptr = sf->textptr;
	(*num) = strtol((const char *)sf->textptr,&sf->textptr,0);
	if (!ISWS(*sf->textptr) && *sf->textptr) {
		char *p = sf->textptr;
		skipovertoken(sf);
		initprintf("Error on line %s:%d: expecting int, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p);
		return -2;
	}
	return 0;
}
示例#29
0
int scriptfile_getdouble(scriptfile *sf, double *num)
{
	skipoverws(sf);
	if (sf->textptr >= sf->eof)
	{
		initprintf("Error on line %s:%d: unexpected eof\n",sf->filename,scriptfile_getlinum(sf,sf->textptr));
		return -1;
	}
	
	sf->ltextptr = sf->textptr;

	// On Linux, locale settings interfere with interpreting x.y format numbers
	//(*num) = strtod((const char *)sf->textptr,&sf->textptr);
	(*num) = parsedouble(sf->textptr, &sf->textptr);
	
	if (!ISWS(*sf->textptr) && *sf->textptr) {
		char *p = sf->textptr;
		skipovertoken(sf);
		initprintf("Error on line %s:%d: expecting float, got \"%s\"\n",sf->filename,scriptfile_getlinum(sf,sf->ltextptr),p);
		return -2;
	}
	return 0;
}
示例#30
0
文件: winbits.c 项目: clobber/eduke32
static void ToggleDesktopComposition(BOOL compEnable)
{
    static HMODULE              hDWMApiDLL        = NULL;
    static HRESULT(WINAPI *aDwmEnableComposition)(UINT);

    if (!hDWMApiDLL && (hDWMApiDLL = LoadLibrary("DWMAPI.DLL")))
        aDwmEnableComposition = (HRESULT(WINAPI *)(UINT))GetProcAddress(hDWMApiDLL, "DwmEnableComposition");

    if (aDwmEnableComposition)
    {
        aDwmEnableComposition(compEnable);
        if (!silentvideomodeswitch)
            initprintf("%sabling desktop composition...\n", (compEnable) ? "En" : "Dis");
    }
}