Example #1
0
//
//	local functions
//
static void AddMenuItem(
	HMENU			hMenu,
	UINT			uPos,
	UINT			uFlags,
	UINT			uCmd,
	UINT			uText)
{
	PSTR text = ModuleMessage(uText);

	if (text) {
		InsertMenu(hMenu, uPos, uFlags, uCmd, text);
		LocalFree(text);
	}
}
Example #2
0
//
//	Open dropped file with VFD
//
DWORD CVfdShExt::DoVfdDrop(
	HWND			hParent)
{
	HANDLE			hDevice;
	DWORD			file_attr;
	ULONG			file_size;
	VFD_FILETYPE	file_type;

	VFD_DISKTYPE	disk_type;
	VFD_MEDIA		media_type;

	DWORD			ret;

	VFDTRACE(0, ("CVfdShExt::DoVfdDropOpen()\n"));

	//	check if dropped file is a valid image

	ret = VfdCheckImageFile(
		m_sTarget, &file_attr, &file_type, &file_size);

	if (ret != ERROR_SUCCESS) {
		return ret;
	}

	//	check file size
	media_type = VfdLookupMedia(file_size);

	if (!media_type) {
		PSTR msg = ModuleMessage(MSG_FILE_TOO_SMALL);

		MessageBox(hParent, msg ? msg : "Bad size",
			VFD_MSGBOX_TITLE, MB_ICONSTOP);

		if (msg) {
			LocalFree(msg);
		}

		return ERROR_CANCELLED;
	}

	if ((file_type == VFD_FILETYPE_ZIP) ||
		(file_attr & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_ENCRYPTED))) {

		disk_type = VFD_DISKTYPE_RAM;
	}
	else {
		disk_type = VFD_DISKTYPE_FILE;
	}

	//	close current image (if opened)

	ret = DoVfdClose(hParent);

	if (ret != ERROR_SUCCESS &&
		ret != ERROR_NOT_READY) {
		return ret;
	}

	//	open dropped file

	hDevice = VfdOpenDevice(m_nDevice);

	if (hDevice == INVALID_HANDLE_VALUE) {
		return GetLastError();
	}

	ret = VfdOpenImage(
		hDevice, m_sTarget, disk_type, media_type, FALSE);

	CloseHandle(hDevice);

	return ret;
}
Example #3
0
int gameloop(void)
{
	struct Buffer *buffer;
	int ticks;
	int c = 0;
	int cmd1, cmd2;
	int done = NO;
	time_t t;
	struct tm *tp;

	buffer = NewBuffer();
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);

	if (ModuleStatus() != MODULE_OK)
		DisplayMessage(ModuleMessage());

	gameIsPaused = NO;

	missionTime = 0;
	//screenShaking = 0;
	while (!done) {
		frames++;

		Ticks_FrameBegin();

		ticks = Ticks_Synchronize();

		if (gOptions.displaySlices)
			SetColorZero(32, 0, 0);

		DrawScreen(buffer, gPlayer1, gPlayer2);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		if (screenShaking) {
			screenShaking -= ticks;
			if (screenShaking < 0)
				screenShaking = 0;
		}

		debug(D_VERBOSE, "frames... %d\n", frames);

		if (Ticks_TimeElapsed(TICKS_PER_SEC)) {
			fps = frames;
			debug(D_NORMAL, "fps = %d\n", fps);
			frames = 0;

			t = time(NULL);
			tp = localtime(&t);
			timeHours = tp->tm_hour;
			timeMinutes = tp->tm_min;
		}

		if (messageTicks > 0)
			messageTicks -= ticks;

		StatusDisplay();

		if (!gameIsPaused) {
			missionTime += ticks;
			if ((gPlayer1 || gPlayer2) && MissionCompleted()) {
				if (gMission.pickupTime == PICKUP_LIMIT)
					PlaySound(SND_DONE, 0, 255);
				gMission.pickupTime -= ticks;
				if (gMission.pickupTime <= 0)
					done = YES;
			} else
				gMission.pickupTime = PICKUP_LIMIT;
		}

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 32);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		CopyToScreen();

		if (!gameIsPaused) {
			if (!gOptions.slowmotion || (frames & 1) == 0) {
				UpdateAllActors(ticks);
				UpdateMobileObjects();

				GetPlayerInput(&cmd1, &cmd2);

				if (gPlayer1 && !PlayerSpecialCommands(
							gPlayer1, cmd1, &gPlayer1Data)) {
					CommandActor(gPlayer1, cmd1);
				}
				if (gPlayer2 && !PlayerSpecialCommands(
							gPlayer2, cmd2, &gPlayer2Data)) {
					CommandActor(gPlayer2, cmd2);
				}

				if (gOptions.badGuys)
					CommandBadGuys();

				UpdateWatches();
			}
		} else {
			GetPlayerInput(&cmd1, &cmd2);
		}

		if (!gPlayer1 && !gPlayer2) {
			done = YES;
			c = 0;
		} else {
			c = HandleKey(&done, cmd1 | cmd2);
		}

		Ticks_FrameEnd();
	}
	free(buffer);

	return c != keyEsc;
}