Пример #1
0
Файл: mvs.c Проект: AMSMM/NJEMU
static void apply_cheat()
{
	gamecheat_t *a_cheat = NULL;
	cheat_option_t *a_cheat_option = NULL;
	cheat_value_t *a_cheat_value = NULL;
	int c,j;

   for( c = 0; c < cheat_num; c++)
   { //arreglo de cheats
	a_cheat = gamecheat[c];
    if( a_cheat == NULL)
		break; //seguro

    if( a_cheat->curr_option == 0)//se asume que el option 0 es el disable
		continue;

    //Se busca cual es el option habilitado
    a_cheat_option = a_cheat->cheat_option[ a_cheat->curr_option];
    if( a_cheat_option == NULL)
		break; //seguro

		//Se ejecutan todos los value del cheat option
		for(  j = 0; j< a_cheat_option->num_cheat_values; j++)
		{
		a_cheat_value = a_cheat_option->cheat_value[j];
			if( a_cheat_value == NULL)
				break;//seguro
				m68000_write_memory_8(a_cheat_value->address,  a_cheat_value->value);

		}
    }
}
Пример #2
0
static void copy_to_memory (int cpu, int addr, const unsigned char *source, int num_bytes)
{
	int i;
	for (i=0; i<num_bytes; i++)
	{
		//computer_writemem_byte (cpu, addr+i, source[i]);
		m68000_write_memory_8(addr+i, source[i]);
	}
}
Пример #3
0
/* call hs_open once after loading a game */
void hs_open (void)
{
	FILE *f = NULL;
	char path[MAX_PATH];
#ifdef N900
        sprintf(path, "%s%s", "/opt/cps2emu/config/", db_filename);
#else
        sprintf(path, "%s%s", launchDir, db_filename);
#endif
	if ((f = fopen(path, "rb")) == NULL) {
		msg_printf("High score DB file is broken.\n");
	} else {
		char buffer[MAX_CONFIG_LINE_SIZE];
		enum { FIND_NAME, FIND_DATA, FETCH_DATA } mode;
		mode = FIND_NAME;

		hs_free();
		state.hiscore_file_size = 0;
		//LOG(("hs_open: '%s'\n", game_name));
		while (fgets (buffer, MAX_CONFIG_LINE_SIZE, f))
		{
			if (mode==FIND_NAME)
			{
				if (matching_game_name (buffer))
				{
					mode = FIND_DATA;
					//LOG(("hs config found!\n"));
				}
			}
			else if (is_mem_range (buffer))
			{
				const char *pBuf = buffer;
				struct mem_range *mem_range = malloc(sizeof(struct mem_range));
				if (mem_range)
				{
					mem_range->cpu = hexstr2num (&pBuf);
					mem_range->addr = hexstr2num (&pBuf);
					mem_range->num_bytes = hexstr2num (&pBuf);
					mem_range->start_value = hexstr2num (&pBuf);
					mem_range->end_value = hexstr2num (&pBuf);
					state.hiscore_file_size += mem_range->num_bytes;

					mem_range->next = NULL;
					{
						struct mem_range *last = state.mem_range;
						while (last && last->next) last = last->next;
						if (last == NULL)
							state.mem_range = mem_range;
						else
							last->next = mem_range;
					}

					mode = FETCH_DATA;
				}
				else
				{
					hs_free();
					break;
				}
			}
			else
			{
				/* line is a game name */
				if (mode == FETCH_DATA) break;
			}
		}
		fclose (f);
	}

	state.hiscores_have_been_loaded = 0;
	if (state.mem_range) {
		struct mem_range *mem_range = state.mem_range;

		while (mem_range)
		{
			//computer_writemem_byte(
			//	mem_range->cpu,
			//	mem_range->addr,
			//	~mem_range->start_value
			//);
			m68000_write_memory_8(mem_range->addr, ~mem_range->start_value);
	
			//computer_writemem_byte(
			//	mem_range->cpu,
			//	mem_range->addr + mem_range->num_bytes-1,
			//	~mem_range->end_value
			//);
			m68000_write_memory_8(mem_range->addr + mem_range->num_bytes-1,~mem_range->end_value);
			mem_range = mem_range->next;
		}

		//printf ("cpu:%d, addr:%d, bytes:%d, start_value:%d, end_value:%d\n", state.mem_range->cpu, state.mem_range->addr, state.mem_range->num_bytes, state.mem_range->start_value, state.mem_range->end_value);
	} else {
		option_hiscore = 0;
	}
}