コード例 #1
0
Psp2Ui::Psp2Ui(int width, int height) :
	BaseUi() {
	
	starttick = sceKernelGetProcessTimeWide() / 1000;
	frame = 0;
	zoom_state = 0;
	trigger_state = false;
	vita2d_init();
	vita2d_texture_set_alloc_memblock_type(SCE_KERNEL_MEMBLOCK_TYPE_USER_RW);
	current_display_mode.width = width;
	current_display_mode.height = height;
	current_display_mode.bpp = 32;
	const DynamicFormat format(
		32,
		0x000000FF,
		0x0000FF00,
		0x00FF0000,
		0xFF000000,
		PF::Alpha);
	main_texture = vita2d_create_empty_texture_format(
												width, height,
												SCE_GXM_TEXTURE_FORMAT_A8B8G8R8);
	Bitmap::SetFormat(Bitmap::ChooseFormat(format));
	main_surface = Bitmap::Create(vita2d_texture_get_datap(main_texture),width, height, vita2d_texture_get_stride(main_texture), format);
	
	#ifdef SUPPORT_AUDIO
		audio_.reset(new Psp2Audio());
	#endif
	
	scePowerSetArmClockFrequency(444);
	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
	
}
コード例 #2
0
ファイル: psp2_ui.cpp プロジェクト: EasyRPG/Player
Psp2Ui::Psp2Ui(int width, int height) :
	BaseUi() {
	
	starttick = sceKernelGetProcessTimeWide() / 1000;
	frame = 0;
	zoom_state = 0;
	in_use_shader = 0;
	touch_x_start = -1;
	trigger_state = false;
	set_shader = true;
	vita2d_init();
	vita2d_set_vblank_wait(0);
	shaders[0] = vita2d_create_shader((SceGxmProgram*) opaque_v, (SceGxmProgram*) texture_f);
	shaders[1] = vita2d_create_shader((SceGxmProgram*) sharp_bilinear_v, (SceGxmProgram*) sharp_bilinear_f);
	shaders[2] = vita2d_create_shader((SceGxmProgram*) lcd3x_v, (SceGxmProgram*) lcd3x_f);
	shaders[3] = vita2d_create_shader((SceGxmProgram*) xbr_2x_fast_v, (SceGxmProgram*) xbr_2x_fast_f);
	gpu_texture = vita2d_create_empty_texture_format(
												width, height,
												SCE_GXM_TEXTURE_FORMAT_A8B8G8R8);
	vita2d_texture_set_alloc_memblock_type(SCE_KERNEL_MEMBLOCK_TYPE_USER_RW);
	current_display_mode.width = width;
	current_display_mode.height = height;
	current_display_mode.bpp = 32;
	const DynamicFormat format(
		32,
		0x000000FF,
		0x0000FF00,
		0x00FF0000,
		0xFF000000,
		PF::Alpha);
	main_texture = vita2d_create_empty_texture_format(
												width, height,
												SCE_GXM_TEXTURE_FORMAT_A8B8G8R8);
	next_texture = vita2d_create_empty_texture_format(
												width, height,
												SCE_GXM_TEXTURE_FORMAT_A8B8G8R8);
	Bitmap::SetFormat(Bitmap::ChooseFormat(format));
	main_surface = Bitmap::Create(vita2d_texture_get_datap(main_texture),width, height, vita2d_texture_get_stride(main_texture), format);
	
	#ifdef SUPPORT_AUDIO
		audio_.reset(new Psp2Audio());
	#endif
	
	scePowerSetArmClockFrequency(444);
	scePowerSetBusClockFrequency(222);
	scePowerSetGpuClockFrequency(222);
	scePowerSetGpuXbarClockFrequency(222);
	
	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
	sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
	
	GPU_Mutex = sceKernelCreateSema("GPU Mutex", 0, 1, 1, NULL);
	GPU_Cleanup_Mutex = sceKernelCreateSema("GPU Cleanup Mutex", 0, 1, 1, NULL);
	GPU_Thread = sceKernelCreateThread("GPU Thread", &renderThread, 0x10000100, 0x10000, 0, 0, NULL);
	sceKernelStartThread(GPU_Thread, sizeof(GPU_Thread), &GPU_Thread);
	
}
コード例 #3
0
ファイル: in_psp2.c プロジェクト: Rinnegatamante/vitaQuake
void IN_StartRumble (void)
{
	if (!pstv_rumble.value) return;
	SceCtrlActuator handle;
	handle.small = 100;
	handle.large = 100;
	sceCtrlSetActuator(1, &handle);
	rumble_tick = sceKernelGetProcessTimeWide();
}
コード例 #4
0
ファイル: luaTimer.cpp プロジェクト: Applelo/lpp-vita-mod
uint64_t osGetTime(void){
	return (sceKernelGetProcessTimeWide() / 1000);
}
コード例 #5
0
ファイル: psp2_ui.cpp プロジェクト: EasyRPG/Player
uint32_t Psp2Ui::GetTicks() const {
	return (sceKernelGetProcessTimeWide() / 1000 - starttick);
}
コード例 #6
0
ファイル: gboy_frame.c プロジェクト: 3375967/realboy-vita
int
frame_skip()
{
	static int frame_rate_cnt = FRAME_RATE;

#ifdef VITA

	if (u_base == 0) {
		u_base = sceKernelGetProcessTimeWide();
		return 0;
	}

	u_base+=u_frm;

	if (num_skips>=10)
	{
		num_skips=0;
		frame_reset();
		return 1;
	}

	if (num_skips) {
		num_skips--;
		return 1;
	}

	u_ref = sceKernelGetProcessTimeWide();

	/* If not there yet */
	if (u_ref<u_base)
	{
		sceKernelDelayThread((u_base-u_ref));
		if ((frame_rate_cnt-=frames_per_second)<=0)
		{
			frame_rate_cnt+=FRAME_RATE;
			return 0;
		}
		else
			return 1;
	}
	else {
		num_skips=(u_ref-u_base)/u_frm;
		return 0;
	}
#else

	if (base.tv_sec==0)
	{
		gettimeofday(&base, NULL);
		u_base=(base.tv_sec*USC)+base.tv_usec;
		return 0;
	}

	u_base+=u_frm;

	if (num_skips>=10)
	{
		num_skips=0;
		frame_reset();
		return 1;
	}

	if (num_skips) {
		num_skips--;
		return 1;
	}

	gettimeofday(&ref, NULL);
	u_ref=(ref.tv_sec*USC)+ref.tv_usec;

	/* If not there yet */
	if (u_ref<u_base)
	{
		usleep((u_base-u_ref));
		if ((frame_rate_cnt-=frames_per_second)<=0)
		{
			frame_rate_cnt+=FRAME_RATE;
			return 0;
		}
		else
			return 1;
	}
	else {
		num_skips=(u_ref-u_base)/u_frm;
		return 0;
	}
#endif
}
コード例 #7
0
ファイル: main.c プロジェクト: xerpi/vitahelloworld
int main()
{
	init_video();

	/* Enable analog stick */
	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);

	/* Enable front touchscreen */
	sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, 1);

	/* FPS counting */
	SceUInt64 cur_micros = 0, delta_micros = 0, last_micros = 0;
	uint32_t frames = 0;
	float fps = 0.0f;

	/* Square variables */
	int w = 60;
	int h = 60;
	int x = SCREEN_W/2 - w/2;
	int y = SCREEN_H/2 - h/2;
	int speed = 2;
	uint32_t color = RGBA8(255, 0, 0, 255);

	/* Input variables */
	SceCtrlData pad;
	SceTouchData touch;
	signed char lx, ly, rx, ry;

	while (1) {
		clear_screen();

		/* Read controls and touchscreen */
		sceCtrlPeekBufferPositive(0, &pad, 1);
		sceTouchPeek(0, &touch, 1);

		if (pad.buttons & SCE_CTRL_START) {
			break;
		}

		font_draw_string(10, 10, RGBA8(0, 0, 255, 255), "PSVita sample by xerpi!");
		font_draw_stringf(SCREEN_W - 160, 10, RGBA8(0, 255, 0, 255), "FPS: %.2f", fps);
		font_draw_stringf(10, 30, RGBA8(255, 0, 0, 255),
			"(%3d, %3d) size: (%d, %d) speed: %d\n", x, y, w, h, speed);

		/* Move the rectangle */
		if (pad.buttons & SCE_CTRL_UP) {
			y -= speed;
		} else 	if (pad.buttons & SCE_CTRL_DOWN) {
			y += speed;
		}
		if (pad.buttons & SCE_CTRL_LEFT) {
			x -= speed;
		} else 	if (pad.buttons & SCE_CTRL_RIGHT) {
			x += speed;
		}

		if (pad.buttons & SCE_CTRL_LTRIGGER) {
			speed--;
			if (speed < 0) speed = 0;
		} else 	if (pad.buttons & SCE_CTRL_RTRIGGER) {
			speed++;
			if (speed > 100) speed = 100;
		}

		if (pad.buttons & SCE_CTRL_CROSS) {
			color = RGBA8(rand()%255, rand()%255, rand()%255, 255);
		}

		/* Update joystick values */
		lx = (signed char)pad.lx - 128;
		ly = (signed char)pad.ly - 128;
		rx = (signed char)pad.rx - 128;
		ry = (signed char)pad.ry - 128;

		/* Move using the left yoystick */
		if (abs(lx) > 50) {
			x += speed * lx/50.0f;
		}
		if (abs(ly) > 50) {
			y += speed * ly/50.0f;
		}

		/* Resize using the right yoystick */
		if (abs(rx) > 50) {
			w += rx/15.0f;
			if (w < 5) {
				w = 5;
			} else if (w > SCREEN_W) {
				w = SCREEN_W;
			}
		}
		if (abs(ry) > 50) {
			h += ry/15.0f;
			if (h < 5) {
				h = 5;
			} if (h > SCREEN_H) {
				h = SCREEN_H;
			}
		}

		/* Move using the touchscreen! */
		if (touch.reportNum > 0) {
			/* Front touchscreen: 1920x1088 */
			x = lerp(touch.report[0].x, 1920, SCREEN_W) - w/2;
			y = lerp(touch.report[0].y, 1088, SCREEN_H) - h/2;
		}

		/* Check left and right collisions */
		if (x < 0) {
			x = 0;
		} else if ((x + w) > SCREEN_W) {
			x = SCREEN_W - w;
		}

		/* Check top and bottom collisions */
		if (y < 0) {
			y = 0;
		} else if ((y + h) > SCREEN_H) {
			y = SCREEN_H - h;
		}

		/* Draw the rectangle */
		draw_rectangle(x, y, w, h, color);

		/* Draw a circle */
		draw_circle(SCREEN_W / 2, SCREEN_H / 2, 50, RGBA8(0,0,255,255));

		/* Calculate FPS */
		cur_micros = sceKernelGetProcessTimeWide();

		if (cur_micros >= (last_micros + 1000000)) {
			delta_micros = cur_micros - last_micros;
			last_micros = cur_micros;
			fps = (frames/(double)delta_micros)*1000000.0f;
			frames = 0;
		}

		swap_buffers();
		sceDisplayWaitVblankStart();
		frames++;
	}

	end_video();
	sceKernelExitProcess(0);
	return 0;
}