예제 #1
0
VECTOR* handFingerPos (ENTITY* entHand, BOOL bLeftHand, int fingerId, VECTOR* vecFingerPos, VECTOR* vecFingerDir)
{
	VECTOR vecFinger0, vecFinger1;
	
	char* j0 = _chr((g_handBoneFarNames->pstring)[fingerId]);
	char* j1 = _chr((g_handBoneNearNames->pstring)[fingerId]);		
	
	vec_for_bone(&vecFinger0, entHand, j0);
	vec_for_bone(&vecFinger1, entHand, j1);
	
	if (bLeftHand)
	{
		vec_to_ent(&vecFinger0, entHand);
		vecFinger0.x *= -1;
		vec_for_ent(&vecFinger0, entHand);	
		
		vec_to_ent(&vecFinger1, entHand);
		vecFinger1.x *= -1;
		vec_for_ent(&vecFinger1, entHand);
	}	
	
	vec_lerp(vecFingerPos, &vecFinger0, &vecFinger1, 0.5);
	vec_diff(vecFingerDir, &vecFinger1, &vecFinger0);
	
	return vecFingerPos;
}
예제 #2
0
int ini_read(STRING *targetValue, STRING *filename, char* section, STRING *entry, STRING *defaultValue)
{	
	int length = GetPrivateProfileString(section, _chr(entry), _chr(defaultValue), iniBuffer, 2047, _chr(filename));
	if(targetValue != NULL)
		str_cpy(targetValue, iniBuffer);
	return length;
}
예제 #3
0
파일: la_loader.c 프로젝트: JustSid/Lite-C
int la_checkFile(STRING *file)
{
	STRING	*filepath;
	la_asset *asset;

	filepath = str_create(work_dir);
	str_cat(filepath, "\\");
	str_cat(filepath, file);
	
	la_lock();
	
	asset = la_assetForFile(_chr(file), _chr(filepath));
	switch(asset->state)
    {
        case LA_ASSET_STATE_LOADED:
        {
            la_unlock();
            ptr_remove(filepath);
            
            return 1;
        }
            break;
        
        case LA_ASSET_STATE_NOSUCHFILE:
        {
            printf("No such file or directory \"%s\"", asset->file);
            
            la_unlock();
            ptr_remove(filepath);
            
            return -1;
        }
            break;
        
        case LA_ASSET_STATE_READFAIL:
        {
            printf("Failed to load \"%s\"", asset->file);
            
            la_unlock();
            ptr_remove(filepath);
            
            return -2;
        }
            break;
        
        default:
            break;
    }
	
	la_unlock();
	ptr_remove(filepath);
	
	return 0;
}
예제 #4
0
파일: level.c 프로젝트: MasterQ32/SQEditor
ActionInformation *actinfo_add(List *list, STRING *name)
{
	ActionInformation *info = NULL;
	for(info = list_first(list); info != NULL; info = list_next(list, info))
	{
		if(strcmp(info->actionname, _chr(name)) == 0)		
			return NULL;
	}
	info = sys_malloc(sizeof(ActionInformation));
	strcpy(info->actionname, _chr(name));
	list_insert_last(list, info);
	return info;
}
예제 #5
0
ChapterData *ChapterDataCreate(const char *name, const char *internal_name,
                               const STRING *thumbnail_name, const COLOR *vsun_color,
						       const COLOR *vfog_color, const VECTOR *vfog_range,
						       const float vsun_light)
{
	ASSERT(internal_name, _chr("Fatal error in ChapterDataCreate(): A null char * pointer was given to the function, cannot create the data block."));
	ASSERT(strlen(internal_name) < CHAPTER_INAME_MAX_LENGTH, _chr("Fatal error in ChapterDataCreate(): Chapter name's length exceeds CHAPTER_INAME_MAX_LENGTH."));

	ChapterData *data     = (ChapterData *) sys_malloc(sizeof(ChapterData));
	data->chapter_name    = (char *)        sys_malloc(CHAPTER_NAME_MAX_LENGTH * sizeof(char));
	data->chapter_iname   = (char *)        sys_malloc(CHAPTER_INAME_MAX_LENGTH * sizeof(char));
	data->pad             = (float *)       sys_malloc(CHAPTER_PAD_VARS_MAX_LENGTH * sizeof(float));
	data->sun_light       = -1.0;

	// The chapter name can be left blank, whilist the chapter's internal name (its scene file)
	// must not be blank - each ChapterData struct has to be linked to a scene in some way.
	if(name)
		if(strlen(name) <= CHAPTER_NAME_MAX_LENGTH)
			strcpy(data->chapter_name, name);

	strcpy(data->chapter_iname, internal_name);

	// Continue to allocate and set up any additional parameters.
	if(thumbnail_name)
		if(file_exists(thumbnail_name))
			data->thumbnail = bmap_create(thumbnail_name);

	if(vsun_color)
	{
		data->sun_color     = (COLOR *) sys_malloc(sizeof(COLOR));
		vec_set(data->sun_color, vsun_color);
	}

	if(vfog_color)
	{
		data->fog_color     = (COLOR *) sys_malloc(sizeof(COLOR));
		vec_set(data->fog_color, vfog_color);

		if(vfog_range)
		{
			data->fog_range = (VECTOR *) sys_malloc(sizeof(VECTOR));
			vec_set(data->fog_range, vfog_range);
		}
	}

	if(vsun_light >= 0.0)
		data->sun_light = vsun_light;

	return data;
}
예제 #6
0
파일: level.c 프로젝트: MasterQ32/SQEditor
RegAction *action_register(STRING *name, void *ptr)
{
	if(registeredActions == NULL) registeredActions = list_create();
	
	RegAction *info = NULL;
	for(info = list_first(registeredActions); info != NULL; info = list_next(registeredActions, info))
	{
		if(strcmp(info->actionname, _chr(name)) == 0)
			return NULL;
	}
	info = sys_malloc(sizeof(RegAction));
	strcpy(info->actionname, _chr(name));
	info->ptr = ptr;
	list_insert_last(registeredActions, info);
	return info;
}
예제 #7
0
// Initializes the scene list, the scenes, and push them into the list.
void nov_scene_list_init()
{
	on_level = __level_load_event;

	// Open the scene list.
	scene_new();

	// Creates the scene nodes.
	day[0] = scene_data_new("Fragment #1",                              // Name of the chapter.
								_chr(game_asset_get_scene("fragment1.wmb")), // Internal name of the chapter. (scene name)
								NULL,                                        // Name of the thumbnail image.
								NULL,                                        // Sun color.
								NULL,                                        // Fog color.
								NULL,                                        // Fog range.
								150.0);                                      // Sun light intensity.

	day[1] = scene_data_new("Fragment #2", _chr(game_asset_get_scene("fragment2.wmb")), NULL, NULL, NULL, NULL, 150.0);
	day[2] = scene_data_new("Fragment #3", _chr(game_asset_get_scene("fragment3.wmb")), NULL, NULL, NULL, NULL, 150.0);
	day[3] = scene_data_new("Fragment #4", _chr(game_asset_get_scene("fragment4.wmb")), NULL, NULL, NULL, NULL, 150.0);
	day[4] = scene_data_new("Fragment #5", _chr(game_asset_get_scene("fragment5.wmb")), NULL, NULL, NULL, NULL, 150.0);
	day[5] = scene_data_new("Fragment #6", _chr(game_asset_get_scene("fragment6.wmb")), NULL, NULL, NULL, NULL, 150.0);
	day[6] = scene_data_new("Fragment #7", _chr(game_asset_get_scene("empty.wmb")), NULL, NULL, NULL, NULL, 150.0);

	int i = 0;
	for(; i < TOTAL_DAYS; i++)
		scene_add( day[i] );
}
예제 #8
0
파일: level.c 프로젝트: MasterQ32/SQEditor
void *actinfo_remove(List *list, STRING *name)
{
	ActionInformation *info = NULL;
	for(info = list_first(list); info != NULL; )
	{
		if(strcmp(info->actionname, _chr(name)) == 0)
			info = list_remove(list, info);
		else
			info = list_next(list, info);
	}
}
예제 #9
0
// Creates a volume texture from the given filename
LPDIRECT3DVOLUMETEXTURE9 sc_volumeTexture_create(STRING *filename)
{
	LPDIRECT3DVOLUMETEXTURE9 temptex;
	HRESULT res = D3DXCreateVolumeTextureFromFile((LPDIRECT3DDEVICE9)pd3ddev, _chr(filename), &temptex);
	if(res != S_OK)
	{
		printf("error: %x", res);
		return NULL;
	}
	return temptex;
}
예제 #10
0
파일: level.c 프로젝트: MasterQ32/SQEditor
void *action_getptr(STRING *name)
{
	if(registeredActions == NULL) registeredActions = list_create();
	
	RegAction *info = NULL;
	for(info = list_first(registeredActions); info != NULL; info = list_next(registeredActions, info))
	{
		if(strcmp(info->actionname, _chr(name)) == 0)
			return info->ptr;
	}
	return NULL;
}
예제 #11
0
int ini_read_sections(TEXT *txt, STRING *filename)
{	
	int length = GetPrivateProfileString(NULL, NULL, NULL, iniBuffer, 2047, _chr(filename));
	int i = 0;
	char *str = iniBuffer;
	while(str < (iniBuffer + length))
	{
		(txt->pstring)[i] = str_create(str);
		str = str + strlen(str) + 1;
		i++;
	}
	return i;
}
예제 #12
0
void ebCreateHandJoints (ENTITY* entHand)
{
	if (entHand == NULL)
		return;
		
	BOOL* arr = NULL;
	
	if (entHand->skill20 == 1) // left
		arr = g_handChopL;
	else // right
		arr = g_handChopR;
		
	int i;
	for (i = 0; i < HAND_FINGERS; i++)
	{
		if (arr[i] == false)
		{
			char* j0 = _chr((g_handBoneFarNames->pstring)[i]);
			char* j1 = _chr((g_handBoneNearNames->pstring)[i]);
			
			VECTOR v0, v1, v;
			vec_for_bone(&v0, entHand, j0);
			vec_for_bone(&v1, entHand, j1);
			vec_lerp(&v, &v0, &v1, 0.5);
			
			if (entHand->skill20 != 0)
			{
				vec_to_ent(&v, entHand);
				v.x *= -1;
				vec_for_ent(&v, entHand);
			}
			
			ENTITY* e = ent_create("handjoint.mdl", &v, ebHandJoint);
			e->skill1 = i;
			e->skill2 = entHand;
		}
	}
}
/**
 * Changes the grayscale mode
 * 
 * mode
 *    Grayscale mode, see modes-section in the file "ppFxGrayscale.h"
 */
void ppGrayscaleSetMode (MATERIAL* m, int mode)
{
	if (m == NULL)
		return NULL;

	if (m->PP_GRAYSCALE_MTL_MODE == mode)
		return m;

	char* strTechnique = _chr((txt_ppGrayscaleTechniques->pstring)[clamp(mode, 0, PP_GRAYSCALE_MODE_CNT)]);

	MATERIAL* m = ppMtlLoad(m, PP_GRAYSCALE_MTL_FX, strTechnique);
	m->PP_GRAYSCALE_MTL_MODE = mode;

	return m;
}
예제 #14
0
// Picks a language and perform string initialization based on the chosen language.
void nov_region_init(const char *language)
{
	ASSERT(language != NULL, "Crash in nov_region_init() due to empty parameters being passed. This should not happen!");

	// Detect supported languages.
	region_new();
	region_scan();

	bool b = region_set_language(language);
	if(b) {
		game_log_write( str_printf( NULL, "Language successfully set to %s", _chr(region_get_language()) ) );
	}

	localized_init();
}
예제 #15
0
파일: rom.cpp 프로젝트: crust/nes
InlinePolymorph<ROM> load_ROM(IBus *bus, const char *path)
{
    std::ifstream file(path);

    if (!(
            file.get() == 'N' &&
            file.get() == 'E' &&
            file.get() == 'S' &&
            file.get() == 0x1A))
    {

        throw std::runtime_error("Not iNES format");
    }

    uint8_t prg_rom_size = file.get();
    uint8_t chr_rom_size = file.get();
    uint8_t flag6 = file.get();
    uint8_t flag7 = file.get();

    // int prg_ram_size = file.get();
    // flag9 = file.get();
    // flag10 = file.get();

    file.seekg(0x10);

    bool four_screen = flag6 & 4;
    bool horizontal_mirroring = !(flag6 & 1);

    int mapper_id{ (flag6 >> 4) | (flag7 & 0xf0) };

    std::cout << "Mapper " << mapper_id << '\n';
    std::cout << "_prg banks: " << (int)prg_rom_size << '\n';
    std::cout << "_chr banks: " << (int)chr_rom_size << '\n';

    InlinePolymorph<ROM> rom;
    switch (mapper_id)
    {
    case 0:
        rom.emplace<NROM>();
        break;
    case 1:
        rom.emplace<SxROM>();
        break;
    case 2:
        rom.emplace<UxROM>();
        break;
    case 3:
        rom.emplace<CNROM>();
        break;
    case 4:
        rom.emplace<MMC3>(bus);
        break;
    case 71:
        rom.emplace<Camerica>();
        break;
    default:
        throw std::runtime_error("Unsupported mapper");
    }

    rom->set_mirroring(four_screen ? ROM::MirrorMode::FOUR_SCREEN : horizontal_mirroring ? ROM::MirrorMode::HORIZONTAL : ROM::MirrorMode::VERTICAL);
    // rom->write_prg(0xc, 0x8000); // fixme: move "set_prg" stuff to constructor?

    std::shared_ptr<std::vector<uint8_t>> _prg(new std::vector<uint8_t>(rom->get_prg_size_for_count(prg_rom_size)));
    std::shared_ptr<std::vector<uint8_t>> _chr(new std::vector<uint8_t>(rom->get_chr_size_for_count(chr_rom_size)));

    file.read(reinterpret_cast<char *>(_prg->data()), _prg->size());
    file.read(reinterpret_cast<char *>(_chr->data()), _chr->size());

    rom->set_prg(prg_rom_size, _prg);
    rom->set_chr(chr_rom_size, _chr);

    return rom;
}
예제 #16
0
void ini_write(STRING *filename, char* section, STRING *entry, STRING *value)
{	
	WritePrivateProfileString(section, _chr(entry), _chr(value), _chr(filename));
}
예제 #17
0
void creditsText ()
{
	static char strIni [256];
	sprintf(strIni, "%s\\credits.ini", _chr(work_dir));
	
	// start music and lyrics
	{
		snd_stop(g_fhCreditsSong);
		g_fhCreditsSong = snd_play(g_musicCredits, 100, 0);
		
		lyricsStart(NULL, g_txtCreditsLyrics, g_fhCreditsSong);
	}
	
	int pos = 0;
	int count = ini_read_int(strIni, "Credits", "max", "0");
	var duration = ini_read_int(strIni, "Credits", "duration", "15");
	
	var itemDuration = duration / (var)count;
	
	creditsHead1.flags |= SHOW;
	creditsBody1.flags |= SHOW;
	creditsHead2.flags |= SHOW;
	creditsBody2.flags |= SHOW;
	
	creditsHead2.pos_y = screen_size.y - g_lyricsBarHeight - 150;
	creditsBody2.pos_y = screen_size.y - g_lyricsBarHeight - 100;
		
	int size1 = 300;
	int size2 = 600;
	
	var x = 0;
	var len = 0;
	
	while (snd_playing(g_fhCreditsSong) != 0 && !g_bCreditsAllExplode)
	{
		static char section [256];
		sprintf(section, "Credit%d", pos + 1);

		ini_read(creditsText1Head, strIni, section, "Head1", " ");
		ini_read(creditsText1Body, strIni, section, "Body1", " ");
		ini_read(creditsText2Head, strIni, section, "Head2", " ");
		ini_read(creditsText2Body, strIni, section, "Body2", " ");
		
		str_replaceall(creditsText1Body, "##", "\n");
		str_replaceall(creditsText2Body, "##", "\n");
		
		creditsHead1.pos_x = -size1;
		creditsBody1.pos_x = -size1;
		
		creditsHead2.pos_x = screen_size.x + size2;
		creditsBody2.pos_x = screen_size.x + size2;
		
		var fadetime = 0.22 * itemDuration;
		
		var fade = 0;
		var fadespeed = 16 / fadetime;
		
		for (fade = 0; fade < 100; fade += fadespeed * time_step)
		{
			creditsHead1.pos_x = -size1 + 1.5 * size1 * (1 - pow(1 - 0.01 * fade, 2));
			creditsBody1.pos_x = -size1 + 1.7 * size1 * (1 - pow(1 - 0.01 * fade, 2));
			
			if (g_bCreditsAllExplode)
				break;
			
			wait(1);
		}
		
		for (fade = 0; fade < 100; fade += fadespeed * time_step)
		{
			creditsHead2.pos_x = screen_size.x + size2 - 1.2 * size2 * (1 - pow(1 - 0.01 * fade, 2));
			creditsBody2.pos_x = screen_size.x + size2 - 1.3 * size2 * (1 - pow(1 - 0.01 * fade, 2));
			
			if (g_bCreditsAllExplode)
				break;
			
			wait(1);
		}
		
		var t_id = 0.6 * itemDuration * 16;
		
		while (t_id > 0 && !g_bCreditsAllExplode)
		{
			t_id -= time_step;
			wait(1);
		}
		
		var scrollspeed = 100;
		
		for (fade = 0; fade < 100; fade += fadespeed * time_step)
		{
			creditsHead1.pos_x += scrollspeed * time_step;
			
			if (fade > 20)
				creditsBody1.pos_x += scrollspeed * time_step;
				
			if (g_bCreditsAllExplode)
				break;
				
			wait(1);
		}
		
		for (fade = 0; fade < 100; fade += fadespeed * time_step)
		{
			creditsHead2.pos_x -= scrollspeed * time_step;
			
			if (fade > 20)
				creditsBody2.pos_x -= scrollspeed * time_step;
				
			if (g_bCreditsAllExplode)
				break;
				
			wait(1);
		}
		
		pos += 1;
		
		wait(1);
	} 
	
	snd_stopall(4);
	
	creditsHead1.flags &= ~SHOW;
	creditsBody1.flags &= ~SHOW;
	creditsHead2.flags &= ~SHOW;
	creditsBody2.flags &= ~SHOW;
	
	g_bCreditsAllExplode = true;
	
	creditsFinished = true;
	
	var et = 5 * 16;
	
	while (et > 0)
	{
		camera->tilt += time_step * 0.2;
		camera->arc += time_step * 0.2;
		
		et -= time_step;
		wait(1);
	}
	
	// show space text
	{
		set(g_txtCreditsSpace, SHOW);
		g_txtCreditsSpace->pos_x = screen_size.x / 2;
		g_txtCreditsSpace->pos_y = screen_size.y * 0.8;
		
		on_space = creditsSpace;
	}
}
예제 #18
0
파일: level.c 프로젝트: MasterQ32/SQEditor
void qlevel_export(char *filename)
{
	FILE *f = fopen(filename, "wb+");
	
	TQLevelHeader header;
	header.a = 42;
	header.b = 1337;
	header.c = -55;
	fwrite(&header, sizeof(TQLevelHeader), 1, f);
	fflush(f);
	
	TQLevelItemHeader item;
	for(you = ent_next(NULL); you != NULL; you = ent_next(you))
	{
		switch(you->group)
		{
			case GROUP_LEVEL:
				item.type = GROUP_LEVEL;
				item.length = sizeof(TQLevelEntity);
				fwrite(&item, sizeof(TQLevelItemHeader), 1, f);
				
				TQLevelEntity entityEntry;
				strcpy(entityEntry.filename, _chr(you->type));
				vec_set(&entityEntry.pos, &you->x);
				vec_set(&entityEntry.angle, &you->pan);
				vec_set(&entityEntry.scale, &you->scale_x);
				entityEntry.actioncount = 0;
				ActionInformation *entry;
				for(entry = list_first(you->string1); entry != NULL; entry = list_next(you->string1, entry))
				{
					entityEntry.actioncount++;
				}
				fwrite(&entityEntry, sizeof(TQLevelEntity), 1, f);
				
				ActionInformation *entry;
				for(entry = list_first(you->string1); entry != NULL; entry = list_next(you->string1, entry))
				{
					TQLevelAction entryAction;
					strcpy(entryAction.actionname, entry->actionname);
					fwrite(&entryAction, sizeof(TQLevelAction), 1, f);					
				}
				break;
			case GROUP_LIGHT:
				item.type = GROUP_LIGHT;
				item.length = sizeof(TQLevelLight);
				fwrite(&item, sizeof(TQLevelItemHeader), 1, f);
				
				TQLevelLight lightEntry;
				
				vec_set(&lightEntry.pos, &you->x);
				vec_set(&lightEntry.angle, &you->pan);
				vec_set(&lightEntry.color, &you->blue);
				lightEntry.range = you->lightrange;
				
				if(you->string2 != NULL)
				{
					strcpy(lightEntry.lightmap, _chr(you->string2));
				}
				
				fwrite(&lightEntry, sizeof(TQLevelLight), 1, f);	
				break;
		}
	}
	
	item.type = -1;
	item.length = 0;
	fwrite(&item, sizeof(TQLevelItemHeader), 1, f);
	
	fclose(f);
}