Exemple #1
0
void SlideShow::Render()
{
	if (enabled)
	{
		if (SlideShow::_files->FileCount() > 0)
		{
		sceRtcGetCurrentClockLocalTime(timed);
		if ((LastTime < 50 && LastTime + 10 < timed->seconds) && TimerEnabled)
		{
			LoadNextPicture(_files->GetNextFile());
			LastTime = timed->seconds;
			return;
		}
		else if (LastTime > 49 && timed->seconds > (LastTime - 50) && timed->seconds < 50 && TimerEnabled)
		{
			LoadNextPicture(_files->GetNextFile());
			LastTime = timed->seconds;
			return;
		}
		}
		else
		{
			Font::PrintImage("No suitable images found.", sizex / 2 - 100, (sizey / 2) - 15, wnd->Screen, 0xFFFFFFFF, 3);
			Font::PrintImage("Supported: JPG, PNG", sizex / 2 - 75, (sizey / 2) - 5 , wnd->Screen, 0xFFFFFFFF, 3);
		}
	}
}
static int lua_GetDate(lua_State *L)
{
if (lua_gettop(L) != 1) return luaL_error(L, "System.getDate takes one argument (1 for the Day , 2 for the month , 3 for the year).");
int Param = luaL_checkint(L, 1);
if (Param > 3)
{
char* Error;
sprintf(Error, "Invalid argument #1 in 'System.getDate'. %d is not a valid value.", Param);
return luaL_error(L, Error);
}
pspTime psptime;
int Day, Month, Year;
sceRtcGetCurrentClockLocalTime(&psptime);
if (Param == 1) { 
Day = psptime.day;
lua_pushnumber(L, Day);
return 1;
}
if (Param == 2) {
Month = psptime.month;
lua_pushnumber(L, Month);
return 1;
}
if (Param == 3) {
Year = psptime.year;
lua_pushnumber(L, Year);
return 1;
}
return 0;
}
static int lua_GetTime(lua_State *L)
{
if (lua_gettop(L) != 1) return luaL_error(L, "System.getTime takes one argument (1 for the Hour , 2 for the Minutes , 3 for the Seconds).");
int Param = luaL_checkint(L, 1);
if (Param > 3)
{
char* Error;
sprintf(Error, "Invalid argument #1 in 'System.getTime'. %d is not a valid value.", Param);
return luaL_error(L, Error);
}
pspTime psptime;
int Hour, Minutes, Seconds;
sceRtcGetCurrentClockLocalTime(&psptime);
if (Param == 1) { 
Hour = psptime.hour;
lua_pushnumber(L, Hour);
return 1;
}
if (Param == 2) {
Minutes = psptime.minutes;
lua_pushnumber(L, Minutes);
return 1;
}
if (Param == 3) {
Seconds = psptime.seconds;
lua_pushnumber(L, Seconds);
return 1;
}
return 0;
}
Exemple #4
0
Image* LCD::GetLCDScreen()
{
	if (_init == 1)
	{
		sceRtcGetCurrentClockLocalTime(_timed);
			
		if (!_textBuffer.empty() || _message == 1)
		{
			if (_lastTime < 55 && _lastTime + 5 < _timed->seconds)
				RenderLCD();
			else if (_lastTime > 54 && _timed->seconds > (_lastTime - 55) && _timed->seconds < 55)
				RenderLCD();
			return _buffer;
		}
		else if (!_screens.empty())
			return ((LCDScreen*)*_screen)->GetLCDScreen();
		else
		{
			if (_showmode == 0)
				RenderDateTime();
			else if (_showmode == 1)
				RenderStatusBattery();
			else if (_showmode == 2)
				RenderStatusCPU();
			else if (_showmode == 3)
				RenderStatusConnections();
			else if (_showmode == 4)
				RenderStatusTheme();
		}
	}
	else
		return NULL;
		
	return _buffer;
}
Exemple #5
0
int module_start(SceSize args, void *argp){
	pspTime ori,me;
	sceRtcGetCurrentClock(&ori,0);
	sceRtcGetCurrentClockLocalTime(&me);
	timeZone = 60*(me.hour-ori.hour)+(me.minutes-ori.minutes);//daylight included
	js_addClass(NULL,NULL,Date,0,NULL,date_methods,NULL,NULL,"Date",
		JSCLASS_NEW_RESOLVE,0,0,0,0,0,0,0,0,JSCLASS_NO_OPTIONAL_MEMBERS,NULL);
	return 0;
}
Exemple #6
0
void checkGetCurrentClockLocalTime() {
	printf("Checking sceRtcGetCurrentClockLocalTime\n");
	pspTime pt;

	// Crash.
	//printf("NULL: %08x\n", sceRtcGetCurrentClockLocalTime(NULL));
	// Not much to test here...
	printf("Normal: %08x\n", sceRtcGetCurrentClockLocalTime(&pt));

	checkPspTime(pt);
}
Exemple #7
0
void PspSpeedTests::tickSpeed() {
	uint32 ticksPerSecond = sceRtcGetTickResolution();
	PSP_INFO_PRINT("ticksPerSecond[%d]\n", ticksPerSecond);

	uint32 currentTicks1[2];
	uint32 currentTicks2[2];

	sceRtcGetCurrentTick((u64 *)currentTicks1);
	sceRtcGetCurrentTick((u64 *)currentTicks2);
	PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks1[0], currentTicks1[1], currentTicks1[0], currentTicks1[1]);
	PSP_INFO_PRINT("current tick[%x %x][%u %u]\n", currentTicks2[0], currentTicks2[1], currentTicks2[0], currentTicks2[1]);

	pspTime time;
	sceRtcSetTick(&time, (u64 *)currentTicks2);
	PSP_INFO_PRINT("current tick in time, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time.year, time.month, time.day, time.hour, time.minutes, time.seconds, time.microseconds);

	pspTime time1;
	pspTime time2;
	sceRtcGetCurrentClockLocalTime(&time1);
	sceRtcGetCurrentClockLocalTime(&time2);
	PSP_INFO_PRINT("time1, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time1.year, time1.month, time1.day, time1.hour, time1.minutes, time1.seconds, time1.microseconds);
	PSP_INFO_PRINT("time2, year[%d] month[%d] day[%d] hour[%d] minutes[%d] seconds[%d] us[%d]\n", time2.year, time2.month, time2.day, time2.hour, time2.minutes, time2.seconds, time2.microseconds);
}
Exemple #8
0
core::stringw CSystem::GetData()
{

    sceRtcGetCurrentClockLocalTime(&psptime);

    anno = psptime.year;

    mese = psptime.month;

    giorno = psptime.day;

    ore = psptime.hour;

    minuti = psptime.minutes;

    core::stringw Data;

    Data  = giorno;
    Data += "/";
    Data += mese;
    Data += "/";
    Data += anno;

    if (ore < 10)
    {
        Data += " - ";
        Data += "0";
        Data += ore;
        Data += ":";
    }
    else
    {
        Data += " - ";
        Data += ore;
        Data += ":";
    }
    if (minuti < 10)
    {
        Data += "0";
        Data += minuti;
    }
    else
    {
        Data += minuti;
    }

    return Data;

}
Exemple #9
0
int dbg_printf(DBG * d, const char *fmt, ...)
{
	char *buf;
	va_list ap;
	int l, size;
	size_t i;
	pspTime tm;
	char timestr[80];
	int timelen;

	if (!d)
		return -1;
	if (!d->on)
		return 0;

	va_start(ap, fmt);

	sceRtcGetCurrentClockLocalTime(&tm);

	SPRINTF_S(timestr, "%u-%u-%u %02u:%02u:%02u", tm.year, tm.month, tm.day, tm.hour, tm.minutes, tm.seconds);

	timelen = strlen(timestr);

	size = DBG_BUFSIZE;
	buf = malloc(size + timelen + 2);
	strcpy_s(buf, size + timelen + 2, timestr);
	strcat_s(buf, size + timelen + 2, ": ");
	l = vsnprintf(buf + timelen + 2, size, fmt, ap);
	buf[size + timelen + 2 - 1] = '\0';
	while (strlen(buf) == size - 1) {
		size *= 2 + 16;
		buf = safe_realloc(buf, size + timelen + 2);
		if (!buf)
			return 0;
		strcpy_s(buf, size + timelen + 2, timestr);
		strcat_s(buf, size + timelen + 2, ": ");
		l = vsnprintf(buf + timelen + 2, size, fmt, ap);
		buf[size + timelen + 2 - 1] = '\0';
	}
	strcat_s(buf, size + timelen + 2, "\n");
	va_end(ap);
	for (i = 0; i < d->otsize; ++i) {
		if (d->ot[i].write)
			(*d->ot[i].write) (d->ot[i].arg, buf);
	}
	free(buf);
	return l;
}
Exemple #10
0
char *psp_get_status_line(void)
{
	static char buff[64];
	int ret, bat_percent, bat_time;
	pspTime time;

	ret = sceRtcGetCurrentClockLocalTime(&time);
	bat_percent = scePowerGetBatteryLifePercent();
	bat_time = scePowerGetBatteryLifeTime();
	if (ret < 0 || bat_percent < 0 || bat_time < 0) return NULL;

	snprintf(buff, sizeof(buff), "%02i:%02i  bat: %3i%%", time.hour, time.minutes, bat_percent);
	if (!scePowerIsPowerOnline())
		snprintf(buff+strlen(buff), sizeof(buff)-strlen(buff), " (%i:%02i)", bat_time/60, bat_time%60);
	return buff;
}
Exemple #11
0
void syscallLog(const SyscallInfo *syscallInfo, const u32 *parameters, u64 result, u32 ra, const char *prefix) {
	char buffer[300];
	char *s = buffer;
	int i, j, k;
	int length;
	int lineStart;

	// Don't log out own sceIoWrites.
	if (syscallInfo->nid == 0x42EC03AC && parameters[0] == commonInfo->logFd) {
		return;
	}

	if (logTimestamp) {
		pspTime time;
		if (sceRtcGetCurrentClockLocalTime(&time) == 0) {
			s = appendInt(s, time.hour, 2);
			*s++ = ':';
			s = appendInt(s, time.minutes, 2);
			*s++ = ':';
			s = appendInt(s, time.seconds, 2);
			*s++ = '.';
			s = appendInt(s, time.microseconds, 6);
			*s++ = ' ';
		}
	}

	if (logThreadName) {
		SceKernelThreadInfo currentThreadInfo;
		currentThreadInfo.size = sizeof(currentThreadInfo);
		currentThreadInfo.name[0] = '\0';
		sceKernelReferThreadStatus(0, &currentThreadInfo);

		s = append(s, currentThreadInfo.name);
		*s++ = ' ';
		*s++ = '-';
		*s++ = ' ';
	}

	if (logRa) {
		s = appendHex(s, ra, 0);
		*s++ = ' ';
	}

	s = append(s, prefix);
	s = append(s, syscallInfo->name);
	int types = syscallInfo->paramTypes;
	for (i = 0; i < syscallInfo->numParams; i++, types >>= 4) {
		if (i > 0) {
			*s++ = ',';
		}
		*s++ = ' ';
		int parameter = parameters[i];
		switch (types & 0xF) {
			case TYPE_HEX32:
				s = appendHex(s, parameter, 0);
				break;
			case TYPE_INT32:
				s = appendInt(s, parameter, 0);
				break;
			case TYPE_STRING:
				s = appendHex(s, parameter, 8);
				if (parameter != 0) {
					*s++ = '(';
					*s++ = '\'';
					s = append(s, (char *) parameter);
					*s++ = '\'';
					*s++ = ')';
				}
				break;
			case TYPE_POINTER32:
				s = appendHex(s, parameter, 8);
				if (parameter != 0) {
					*s++ = '(';
					s = appendHex(s, _lw(parameter), 0);
					*s++ = ')';
				}
				break;
			case TYPE_POINTER64:
				s = appendHex(s, parameter, 8);
				if (parameter != 0) {
					*s++ = '(';
					s = appendHex(s, _lw(parameter), 8);
					*s++ = ' ';
					s = appendHex(s, _lw(parameter + 4), 8);
					*s++ = ')';
				}
				break;
			case TYPE_VARSTRUCT:
				s = appendHex(s, parameter, 8);
				if (parameter != 0) {
					*s++ = ':';
					*s++ = '\n';
					writeLog(buffer, s - buffer);
					s = buffer;
					length = _lw(parameter);
					lineStart = 0;
					for (j = 0; j < length; j += 4) {
						if (j > 0) {
							if ((j % 16) == 0) {
								s = append(s, "  >");
								for (k = lineStart; k < j; k++) {
									char c = _lb(parameter + k);
									if (c < ' ' || c > '~') {
										c = '.';
									}
									*s++ = c;
								}
								s = append(s, "<\n");
								writeLog(buffer, s - buffer);
								s = buffer;
								lineStart = j;
							} else {
								*s++ = ',';
								*s++ = ' ';
							}
						}
						s = appendHex(s, _lw(parameter + j), 8);
					}
				}
				break;
			case TYPE_FIXSTRUCT:
				s = appendHex(s, parameter, 8);
				if (parameter != 0) {
					*s++ = ':';
					*s++ = '\n';
					writeLog(buffer, s - buffer);
					s = buffer;
					length = FIXSTRUCT_SIZE;
					lineStart = 0;
					for (j = 0; j < length; j += 4) {
						if (j > 0) {
							if ((j % 16) == 0) {
								s = append(s, "  >");
								for (k = lineStart; k < j; k++) {
									char c = _lb(parameter + k);
									if (c < ' ' || c > '~') {
										c = '.';
									}
									*s++ = c;
								}
								s = append(s, "<\n");
								writeLog(buffer, s - buffer);
								s = buffer;
								lineStart = j;
							} else {
								*s++ = ',';
								*s++ = ' ';
							}
						}
						s = appendHex(s, _lw(parameter + j), 8);
					}
				}
				break;
		}
	}
	*s++ = ' ';
	*s++ = '=';
	*s++ = ' ';
	s = appendHex(s, (int) result, 0);

	#if DEBUG_MUTEX
	s = mutexLog(s, syscallInfo, parameters, result);
	#endif

	*s++ = '\n';
	writeLog(buffer, s - buffer);

	#if DEBUG_UTILITY_SAVEDATA
	utilitySavedataLog(buffer, syscallInfo, parameters[0]);
	#endif
}
Exemple #12
0
void neogeo_driver_reset(void)
{
#ifdef ADHOC
	if (adhoc_enable)
	{
		pd4990a.seconds = 0;
		pd4990a.minutes = 0;
		pd4990a.hours   = 0;
		pd4990a.days    = 0;
		pd4990a.month   = 0;
		pd4990a.year    = 0;
		pd4990a.weekday = 0;
	}
	else
#endif
	{
		pspTime today;
		int y, m, d;

		sceRtcGetCurrentClockLocalTime(&today);

		pd4990a.seconds = ((today.seconds / 10) << 4) + (today.seconds % 10);
		pd4990a.minutes = ((today.minutes / 10) << 4) + (today.minutes % 10);
		pd4990a.hours   = ((today.hour    / 10) << 4) + (today.hour    % 10);
		pd4990a.days    = ((today.day     / 10) << 4) + (today.day     % 10);
		pd4990a.month   = today.month;
		pd4990a.year    = (((today.year % 100) / 10) << 4) + (today.year % 10);

		y = today.year;
		m = today.month;
		d = today.day;
		if (m == 1 || m == 2) { y--; m += 12; }
		pd4990a.weekday = (y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7;
	}

	memset(neogeo_ram, 0, 0x10000);

	memcpy(memory_region_cpu1, neogeo_vectors[0], 0x80);	// bios vector
	main_cpu_vector_table_source = 0;

	watchdog_reset_w(0, 0, 0);

	raster_counter = RASTER_COUNTER_START;
	scanline_read = 0;

	display_position_interrupt_counter = 0;
	display_position_interrupt_control = 0;
	display_counter = 0;

	vblank_interrupt_pending = 0;
	display_position_interrupt_pending = 0;

	sound_code = 0;
	result_code = 0;
	pending_command = 0;

	auto_animation_frame_counter = 0;
	auto_animation_speed = 0;
	auto_animation_disabled = 0;
	auto_animation_counter = 0;

	neogeo_rng = 0x2345;
	save_ram_unlocked = 0;

	controller_select = 0;

	neogeo_reset_driver_type();

	if (machine_init_type == INIT_ms5pcb
	||	machine_init_type == INIT_svcpcb)
	{
		memcpy(memory_region_user1, memory_region_user1 + 0x20000 + neogeo_hard_dipsw * 0x20000, 0x20000);
	}
#if !RELEASE
	if (machine_init_type == INIT_kog)
	{
		memory_region_cpu1[0x1ffffc/2] = neogeo_hard_dipsw;
	}
#endif

	m68000_reset();
	z80_reset();
}
Exemple #13
0
int state_save(int slot)
{
	SceUID fd = -1;
	pspTime nowtime;
	char path[MAX_PATH];
	char error_mes[128];
	char buf[128];
#if (EMU_SYSTEM == NCDZ)
	UINT8 *inbuf, *outbuf;
	unsigned long insize, outsize;
#else
#ifndef ADHOC
	UINT8 *state_buffer_base;
#endif
	UINT32 size;
#endif

	sprintf(path, "%sstate/%s.sv%d", launchDir, game_name, slot);
	sceIoRemove(path);

	sprintf(buf, TEXT(STATE_SAVING), game_name, slot);
	init_progress(6, buf);

	sceRtcGetCurrentClockLocalTime(&nowtime);

	if ((fd = sceIoOpen(path, PSP_O_WRONLY|PSP_O_CREAT, 0777)) >= 0)
#if (EMU_SYSTEM == NCDZ)
	{
		if ((inbuf = memalign(MEM_ALIGN, STATE_BUFFER_SIZE)) == NULL)
		{
			strcpy(error_mes, TEXT(COULD_NOT_ALLOCATE_STATE_BUFFER));
			goto error;
		}
		memset(inbuf, 0, STATE_BUFFER_SIZE);
		state_buffer = inbuf;

		state_save_byte(current_version_str, 8);
		state_save_byte(&nowtime, 16);
		update_progress();

		save_thumbnail();
		update_progress();

		sceIoWrite(fd, inbuf, (UINT32)state_buffer - (UINT32)inbuf);
		update_progress();

		memset(inbuf, 0, STATE_BUFFER_SIZE);
		state_buffer = inbuf;

		state_save_memory();
		state_save_m68000();
		state_save_z80();
		state_save_input();
		state_save_timer();
		state_save_driver();
		state_save_video();
		state_save_ym2610();
		state_save_cdda();
		state_save_cdrom();
		update_progress();

		insize = (UINT32)state_buffer - (UINT32)inbuf;
		outsize = insize * 1.1 + 12;
		if ((outbuf = memalign(MEM_ALIGN, outsize)) == NULL)
		{
			strcpy(error_mes, TEXT(COULD_NOT_ALLOCATE_STATE_BUFFER));
			free(inbuf);
			goto error;
		}
		memset(outbuf, 0, outsize);

		if (compress(outbuf, &outsize, inbuf, insize) != Z_OK)
		{
			strcpy(error_mes, TEXT(COULD_NOT_COMPRESS_STATE_DATA));
			free(inbuf);
			free(outbuf);
			goto error;
		}
		free(inbuf);
		update_progress();

		sceIoWrite(fd, &outsize, 4);
		sceIoWrite(fd, outbuf, outsize);
		sceIoClose(fd);
		free(outbuf);
		update_progress();

		show_progress(buf);
		return 1;
	}
#else
	{
#ifdef ADHOC
		state_buffer = state_buffer_base;
#else
#if (EMU_SYSTEM == CPS1 || (EMU_SYSTEM == CPS2 && defined(PSP_SLIM)))
		state_buffer = state_buffer_base = memalign(MEM_ALIGN, STATE_BUFFER_SIZE);
#else
		state_buffer = state_buffer_base = cache_alloc_state_buffer(STATE_BUFFER_SIZE);
#endif
		if (!state_buffer)
		{
			strcpy(error_mes, TEXT(COULD_NOT_ALLOCATE_STATE_BUFFER));
			goto error;
		}
#endif
		memset(state_buffer, 0, STATE_BUFFER_SIZE);
		update_progress();

		state_save_byte(current_version_str, 8);
		state_save_byte(&nowtime, 16);
		update_progress();

		save_thumbnail();
		update_progress();

		state_save_memory();
		state_save_m68000();
		state_save_z80();
		state_save_input();
		state_save_timer();
		state_save_driver();
		state_save_video();
#if (EMU_SYSTEM == CPS1)
		state_save_coin();
		switch (machine_driver_type)
		{
		case MACHINE_qsound:
			state_save_qsound();
			state_save_eeprom();
			break;

		case MACHINE_pang3:
			state_save_eeprom();

		default:
			state_save_ym2151();
			break;
		}
#elif (EMU_SYSTEM == CPS2)
		state_save_coin();
		state_save_qsound();
		state_save_eeprom();
#elif (EMU_SYSTEM == MVS)
		state_save_ym2610();
		state_save_pd4990a();
#endif
		update_progress();

		size = (UINT32)state_buffer - (UINT32)state_buffer_base;
		sceIoWrite(fd, state_buffer_base, size);
		sceIoClose(fd);
		update_progress();

#ifndef ADHOC
#if (EMU_SYSTEM == CPS1 || (EMU_SYSTEM == CPS2 && defined(PSP_SLIM)))
		free(state_buffer_base);
#else
		cache_free_state_buffer(STATE_BUFFER_SIZE);
#endif
#endif
		update_progress();

		show_progress(buf);
		return 1;
	}
#endif
	else
	{
Exemple #14
0
int music_init(void)
{
	u32 seed;

	cache_init();

	seed = sctrlKernelRand();

	if (seed == 0x8002013A) {
		pspTime tm;

		sceRtcGetCurrentClockLocalTime(&tm);
		seed = tm.microseconds;
	}

	srand(seed);
	xr_lock_init(&music_l);

#ifdef ENABLE_MPC
	mpc_init();
#endif

#ifdef ENABLE_WAV
	wav_init();
#endif

#ifdef ENABLE_TTA
	tta_init();
#endif

#ifdef ENABLE_APE
	ape_init();
#endif

#ifdef ENABLE_MP3
	mp3_init();
#endif

#ifdef ENABLE_FLAC
	flac_init();
#endif

#ifdef ENABLE_OGG
	ogg_init();
#endif

#ifdef ENABLE_WMA
	wmadrv_init();
#endif

#ifdef ENABLE_WAVPACK
	wv_init();
#endif

#ifdef ENABLE_AT3
	at3_init();
#endif

#ifdef ENABLE_M4A
	m4a_init();
#endif

#ifdef ENABLE_AAC
	aac_init();
#endif

#ifdef ENABLE_AA3
	aa3_init();
#endif

	musiclist_init(&g_music_list);
	memset(&g_list, 0, sizeof(g_list));
	g_list.first_time = true;
	stack_init(&g_played);
	g_music_thread = sceKernelCreateThread("Music Thread", music_thread, 0x12, 0x10000, 0, NULL);

	if (g_music_thread < 0) {
		return -EBUSY;
	}

	sceKernelStartThread(g_music_thread, 0, 0);

	return 0;
}