예제 #1
0
파일: common.c 프로젝트: Falaina/cspspemu
void emulatorEmitScreenshot() {
	int file;

	if (RUNNING_ON_EMULATOR) {
		sceIoDevctl("kemulator:", EMULATOR_DEVCTL__EMIT_SCREENSHOT, NULL, 0, NULL, 0);
	}
	else
	{
		uint topaddr;
		int bufferwidth;
		int pixelformat;

		sceDisplayGetFrameBuf((void **)&topaddr, &bufferwidth, &pixelformat, 0);
		
        if (topaddr & 0x80000000) {
            topaddr |= 0xA0000000;
        } else {
            topaddr |= 0x40000000;
        }
	
		if ((file = sceIoOpen("__screenshot.bmp", PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC, 0777)) >= 0) {
			int y, x;
			uint c;
			uint* vram_row;
			uint* row_buf = (uint *)malloc(512 * 4);
			sceIoWrite(file, &bmpHeader, sizeof(bmpHeader));
			for (y = 0; y < 272; y++) {
				vram_row = (uint *)(topaddr + 512 * 4 * (271 - y));
				for (x = 0; x < 512; x++) {
					c = vram_row[x];
					/*
					row_buf[x] = (
						((extractBits(c,  0, 8)) <<  0) |
						((extractBits(c,  8, 8)) <<  8) |
						((extractBits(c, 16, 8)) << 16) |
						((                0x00 ) << 24) |
					0);
					*/
					row_buf[x] = (
						((extractBits(c, 16, 8)) <<  0) |
						((extractBits(c,  8, 8)) <<  8) |
						((extractBits(c,  0, 8)) << 16) |
						((                0x00 ) << 24) |
					0);
				}
				sceIoWrite(file, row_buf, 512 * 4);
			}
			free(row_buf);
			//sceIoWrite(file, (void *)topaddr, bufferwidth * 272 * 4);
			//sceIoFlush();
			sceIoClose(file);
		}
	}
}
예제 #2
0
static int lua_getTSize(lua_State *L)
{
    if (lua_gettop(L) != 1) return luaL_error(L, "System.getTotalSize takes one argument.");
    const char *dev = luaL_checkstring(L,1);
    SystemDevCtl devctl;
    memset(&devctl, 0, sizeof(SystemDevCtl));
    SystemDevCommand command;
    command.pdevinf = &devctl;
    sceIoDevctl(dev, 0x02425818, &command, sizeof(SystemDevCommand), NULL, 0);
    u64 size = (devctl.maxclusters * devctl.sectorcount) * devctl.sectorsize;  
    lua_pushnumber(L,(float)size/1048576.0f);
    return 1;
}
예제 #3
0
파일: common.c 프로젝트: Falaina/cspspemu
int main(int argc, char *argv[]) {
	int retval = 0;

	//KprintfFd = sceIoOpen("emulator:/Kprintf", O_WRONLY, 0777);
	//RUNNING_ON_EMULATOR = (KprintfFd > 0);
	
	if (sceIoDevctl("kemulator:", EMULATOR_DEVCTL__IS_EMULATOR, NULL, 0, NULL, 0) == 0) {
		RUNNING_ON_EMULATOR = 1;
	}
	
	// TEMP HACK
	//RUNNING_ON_EMULATOR = 0;

	if (RUNNING_ON_EMULATOR) {
		sceIoDevctl("kemulator:", EMULATOR_DEVCTL__GET_HAS_DISPLAY, NULL, 0, &HAS_DISPLAY, sizeof(HAS_DISPLAY));
	}
	
	#ifdef GRAPHIC_TEST
		HAS_DISPLAY = 0;
	#endif

	//if (strncmp(argv[0], START_WITH, strlen(START_WITH)) == 0) RUNNING_ON_EMULATOR = 1;

	if (!RUNNING_ON_EMULATOR) {
		test_psp_setup_callbacks();
	}
	atexit(sceKernelExitGame);

	test_begin();
	{
		pspDebugScreenPrintf("RUNNING_ON_EMULATOR: %s - %s\n", RUNNING_ON_EMULATOR ? "yes" : "no", argv[0]);
		retval = test_main(argc, argv);
	}
	test_end();
	
	return retval;
}
예제 #4
0
파일: mstick.c 프로젝트: Falaina/cspspemu
int ms_callback(int arg1, int arg2, void *arg)
{
	SizeInfoStruct sizeInfo = {0};
	SizeInfoStruct *sizeInfoPointer = &sizeInfo;

	printf("ms_callback: %08X, %08X, %08X\n", (unsigned int)arg1, (unsigned int)arg2, (unsigned int)arg);
	
	sceIoDevctl("fatms0:", 0x02425818, (void *)&sizeInfoPointer, sizeof(void*), 0, 0);
	
	printf(
		"sizeInfo:: maxClusters=%d, freeClusters=%d, maxSectors=%d, sectorSize=%d, sectorCount=%d\n",
		sizeInfo.maxClusters,
		sizeInfo.freeClusters,
		sizeInfo.maxSectors,
		sizeInfo.sectorSize,
		sizeInfo.sectorCount
	);

    return 0;
}
예제 #5
0
int ms_callback(int arg1, int arg2, void *arg)
{
	SizeInfoStruct sizeInfo = {0};
	SizeInfoStruct *sizeInfoPointer = &sizeInfo;

	printf("ms_callback: %08X, %08X, %08X\n", (unsigned int)arg1, (unsigned int)arg2, (unsigned int)arg);
	
	sceIoDevctl("fatms0:", 0x02425818, (void *)&sizeInfoPointer, sizeof(void*), 0, 0);

	// No need to match exactly, let's call 256 MB "enough" and 128 GB "too much."
	// Remember that storage uses SI units.
	int acceptableMinClusters = (256 * 1000 * 1000) / (512 * 64);
	int acceptableMaxClusters = (128 * 1000 * 1000 * 1000) / (512 * 64) - 1;

	if (sizeInfo.maxClusters >= acceptableMinClusters && sizeInfo.maxClusters <= acceptableMaxClusters) {
		printf("sizeInfo:: maxClusters: OK\n");
	} else {
		printf("sizeInfo:: maxClusters: Unexpected %d\n", sizeInfo.maxClusters);
	}

	if (sizeInfo.freeClusters >= acceptableMinClusters && sizeInfo.freeClusters <= acceptableMaxClusters) {
		printf("sizeInfo:: freeClusters: OK\n");
	} else {
		printf("sizeInfo:: freeClusters: Unexpected %d\n", sizeInfo.freeClusters);
	}

	if (sizeInfo.maxSectors >= acceptableMinClusters && sizeInfo.maxSectors <= acceptableMaxClusters) {
		printf("sizeInfo:: maxSectors: OK\n");
	} else {
		printf("sizeInfo:: maxSectors: Unexpected %d\n", sizeInfo.maxSectors);
	}

	printf(
		"sizeInfo:: sectorSize=%d, sectorCount=%d\n",
		sizeInfo.sectorSize,
		sizeInfo.sectorCount
	);

    return 0;
}
예제 #6
0
파일: common.c 프로젝트: Falaina/cspspemu
static int writeStdoutHook(struct _reent *ptr, void *cookie, const char *buf, int buf_len) {
	char temp[1024 + 1];

	//if (KprintfFd > 0) sceIoWrite(KprintfFd, buf, buf_len);
	if (RUNNING_ON_EMULATOR) {
		sceIoDevctl("emulator:", EMULATOR_DEVCTL__SEND_OUTPUT, (void *)buf, buf_len, NULL, 0);
	}

	if (buf_len < sizeof(temp)) {
		if (HAS_DISPLAY) {
			memcpy(temp, buf, buf_len);
			temp[buf_len] = 0;

			//Kprintf("%s", temp);
			pspDebugScreenPrintf("%s", temp);
		}
	}
	
	if (stdout_back._write != NULL) {
		return stdout_back._write(ptr, cookie, buf, buf_len);
	} else {
		return buf_len;
	}
}
예제 #7
0
파일: common.c 프로젝트: Falaina/cspspemu
void emulatorSendSceCtrlData(SceCtrlData* pad_data) {
	sceIoDevctl("kemulator:", EMULATOR_DEVCTL__SEND_CTRLDATA, pad_data, sizeof(SceCtrlData), NULL, 0);
}
예제 #8
0
static __inline__ int MScmUnregisterMSInsertEjectCallback(SceUID cbid)
{
	return sceIoDevctl("fatms0:", 0x02415822, &cbid, sizeof(cbid), 0, 0);
}