Example #1
0
static int openprinter_ps (void)
{
	TCHAR *gsargv[] = {
		L"-dNOPAUSE", L"-dBATCH", L"-dNOPAGEPROMPT", L"-dNOPROMPT", L"-dQUIET", L"-dNoCancel",
		L"-sDEVICE=mswinpr2", NULL
	};
	int gsargc, gsargc2, i;
	TCHAR *tmpparms[100];
	TCHAR tmp[MAX_DPATH];
	char *gsparms[100];

	if (ptr_gsapi_new_instance (&gsinstance, NULL) < 0)
		return 0;
	cmdlineparser (currprefs.ghostscript_parameters, tmpparms, 100 - 10);

	gsargc2 = 0;
	gsparms[gsargc2++] = ua (L"WinUAE");
	for (gsargc = 0; gsargv[gsargc]; gsargc++) {
		gsparms[gsargc2++] = ua (gsargv[gsargc]);
	}
	for (i = 0; tmpparms[i]; i++)
		gsparms[gsargc2++] = ua (tmpparms[i]);
	if (currprefs.prtname[0]) {
		_stprintf (tmp, L"-sOutputFile=%%printer%%%s", currprefs.prtname);
		gsparms[gsargc2++] = ua (tmp);
	}
	if (postscript_print_debugging) {
		for (i = 0; i < gsargc2; i++) {
			TCHAR *parm = au (gsparms[i]);
			write_log (L"GSPARM%d: '%s'\n", i, parm);
			xfree (parm);
		}
	}
	__try {
		int rc = ptr_gsapi_init_with_args (gsinstance, gsargc2, gsparms);
		for (i = 0; i < gsargc2; i++) {
			xfree (gsparms[i]);
		}
		if (rc != 0) {
			write_log (L"GS failed, returncode %d\n", rc);
			return 0;
		}
		ptr_gsapi_run_string_begin (gsinstance, 0, &gs_exitcode);
	} __except (ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
		write_log (L"GS crashed\n");
		return 0;
	}
	psmode = 1;
	return 1;
}
Example #2
0
static uint32_t REGPARAM2 uaeexe_server (TrapContext *context)
{
	int32_t len;
	TCHAR *cmd;
	char *dst, *s;

	if (ARG (0) && !running) {
		running = 1;
		write_log (_T("Remote CLI started.\n"));
	}

	cmd = get_cmd ();
	if (!cmd)
		return 0;
	if (!ARG (0)) {
		running = 0;
		return 0;
	}

	dst = (char*)get_real_address (ARG (0));
	len = ARG (1);
	s = ua (cmd);
	strncpy (dst, s, len);
	write_log (_T("Sending '%s' to remote cli\n"), cmd);
	xfree (s);
	xfree (cmd);
	return ARG (0);
}
Example #3
0
void UniverseArray_Test::applyGM()
{
    UniverseArray ua(1);

    QCOMPARE(ua.m_gMIntensityChannels.size(), 0);
    QCOMPARE(ua.m_gMNonIntensityChannels.size(), 0);
    QCOMPARE(ua.applyGM(0, 50, QLCChannel::Intensity), uchar(50));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Colour), uchar(200));

    ua.setGMValue(127);
    QCOMPARE(ua.applyGM(0, 50, QLCChannel::Intensity), uchar(25));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Intensity), uchar(100));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Colour), uchar(200));

    ua.setGMValueMode(UniverseArray::GMLimit);
    QCOMPARE(ua.applyGM(0, 50, QLCChannel::Intensity), uchar(50));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Intensity), uchar(127));
    QCOMPARE(ua.applyGM(0, 255, QLCChannel::Colour), uchar(255));

    ua.setGMChannelMode(UniverseArray::GMAllChannels);
    QCOMPARE(ua.applyGM(0, 50, QLCChannel::Intensity), uchar(50));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Intensity), uchar(127));
    QCOMPARE(ua.applyGM(0, 255, QLCChannel::Colour), uchar(127));

    ua.setGMValueMode(UniverseArray::GMReduce);
    QCOMPARE(ua.applyGM(0, 50, QLCChannel::Intensity), uchar(25));
    QCOMPARE(ua.applyGM(0, 200, QLCChannel::Intensity), uchar(100));
    QCOMPARE(ua.applyGM(0, 255, QLCChannel::Colour), uchar(127));

    QCOMPARE(ua.m_gMIntensityChannels.size(), 1);
    QCOMPARE(ua.m_gMNonIntensityChannels.size(), 1);
}
Example #4
0
void UniverseArray_Test::write()
{
    UniverseArray ua(10);

    QVERIFY(ua.write(10, 255, QLCChannel::Intensity) == false);
    QCOMPARE(ua.postGMValues()->at(9), char(0));
    QCOMPARE(ua.postGMValues()->at(4), char(0));
    QCOMPARE(ua.postGMValues()->at(0), char(0));

    QVERIFY(ua.write(9, 255, QLCChannel::Intensity) == true);
    QCOMPARE(ua.postGMValues()->at(9), char(255));
    QCOMPARE(ua.postGMValues()->at(4), char(0));
    QCOMPARE(ua.postGMValues()->at(0), char(0));

    QVERIFY(ua.write(0, 255, QLCChannel::Intensity) == true);
    QCOMPARE(ua.postGMValues()->at(9), char(255));
    QCOMPARE(ua.postGMValues()->at(4), char(0));
    QCOMPARE(ua.postGMValues()->at(0), char(255));

    ua.setGMValue(127);
    QCOMPARE(ua.postGMValues()->at(9), char(127));
    QCOMPARE(ua.postGMValues()->at(4), char(0));
    QCOMPARE(ua.postGMValues()->at(0), char(127));

    QVERIFY(ua.write(4, 200, QLCChannel::Intensity) == true);
    QCOMPARE(ua.postGMValues()->at(9), char(127));
    QCOMPARE(ua.postGMValues()->at(4), char(100));
    QCOMPARE(ua.postGMValues()->at(0), char(127));
}
Example #5
0
void GenericFader_Test::writeLoop()
{
    UniverseArray ua(512);
    GenericFader fader(m_doc);

    FadeChannel fc;
    fc.setFixture(0);
    fc.setChannel(5);
    fc.setStart(0);
    fc.setTarget(250);
    fc.setFadeTime(1000);
    fader.add(fc);

    QCOMPARE(ua.preGMValues()[15], (char) 0);

    int expected = 0;
    for (int i = MasterTimer::tick(); i <= 1000; i += MasterTimer::tick())
    {
        ua.zeroIntensityChannels();
        fader.write(&ua);

        int actual = uchar(ua.preGMValues()[15]);
        expected += 5;
        QCOMPARE(actual, expected);
    }
}
Example #6
0
int32_t uaenet_open (struct uaenetdata *sd, struct netdriverdata *tc, struct s2devstruct *user,
				uaenet_gotfunc *gotfunc, uaenet_getfunc *getfunc, int32_t promiscuous)
{
	char *s;

	s = ua (tc->name);
	sd->fp = pcap_open_live (s, 65536, promiscuous, 100, sd->errbuf);
	xfree (s);
	if (sd->fp == NULL) {
		TCHAR *ss = au (sd->errbuf);
		write_log ("'%s' failed to open: %s\n", tc->name, ss);
		xfree (ss);
		return 0;
	}
	sd->tc = tc;
	sd->user = user;
	sd->mtu = tc->mtu;
	sd->readbuffer = xmalloc (uint8_t, sd->mtu);
	sd->writebuffer = xmalloc (uint8_t, sd->mtu);
	sd->gotfunc = gotfunc;
	sd->getfunc = getfunc;

	uae_sem_init (&sd->change_sem, 0, 1);
	uae_sem_init (&sd->sync_semr, 0, 0);
	uae_start_thread ("uaenet_r", uaenet_trap_threadr, sd, &sd->tidr);
	uae_sem_wait (&sd->sync_semr);
	uae_sem_init (&sd->sync_semw, 0, 0);
	uae_start_thread ("uaenet_w", uaenet_trap_threadw, sd, &sd->tidw);
	uae_sem_wait (&sd->sync_semw);
	write_log ("uaenet initialized\n");
	return 1;
}
Example #7
0
File: fsdb.c Project: engur/PUAE
a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname)
{
	FILE *f;
	char *s;

	f = get_fsdb (base, _T("r+b"));
	if (f == 0) {
//		if (currprefs.filesys_custom_uaefsdb && (base->volflags & MYVOLUMEINFO_STREAMS))
//			return custom_fsdb_lookup_aino_nname (base, nname);
		return 0;
	}
	s = ua (nname);
	for (;;) {
		uae_u8 buf[1 + 4 + 257 + 257 + 81];
		if (fread (buf, 1, sizeof buf, f) < sizeof buf)
			break;
		if (buf[0] != 0 && strcmp ((char*)buf + 5 + 257, s) == 0) {
			long pos = ftell (f) - sizeof buf;
			fclose (f);
			xfree (s);
			return aino_from_buf (base, buf, pos);
		}
	}
	xfree (s);
	fclose (f);
	return 0;
}
Example #8
0
QString HttpUserAgent::userAgent()
// ----------------------------------------------------------------------------
//    HTTP User-Agent string
// ----------------------------------------------------------------------------
{
    QString ua("Tao3D/%1 (%2; %3; %4)");
    return ua.arg(version).arg(Application::editionStr()).arg(edition)
             .arg(target);
}
Example #9
0
void UniverseArray_Test::initial()
{
    UniverseArray ua(127);
    QCOMPARE(ua.size(), 127);
    QCOMPARE(ua.gMChannelMode(), UniverseArray::GMIntensity);
    QCOMPARE(ua.gMValueMode(), UniverseArray::GMReduce);
    QCOMPARE(ua.gMValue(), uchar(255));
    QCOMPARE(ua.gMFraction(), double(1.0));
}
Example #10
0
void Win32MidiOutputDevice::writeChannel(ushort channel, uchar value)
{
    if (channel < m_universe.size())
    {
        QByteArray ua(m_universe);
        ua[channel] = value;
        writeUniverse(ua);
    }
}
Example #11
0
// Exercise almost every LocalArray method (but not LocalPointerBase).
void LocalPointerTest::TestLocalArray() {
    // constructor
    LocalArray<UnicodeString> a(new UnicodeString[2]);
    // operator[]()
    a[0].append((UChar)0x61);
    a[1].append((UChar32)0x60006);
    if(a[0].length()!=1 || a[1].length()!=2) {
        errln("LocalArray access failure");
    }
    // adoptInstead()
    a.adoptInstead(new UnicodeString[4]);
    a[3].append((UChar)0x62).append((UChar)0x63).reverse();
    if(a[3].length()!=2 || a[3][1]!=0x62) {
        errln("LocalArray adoptInstead() failure");
    }

    // LocalArray(p, errorCode) sets U_MEMORY_ALLOCATION_ERROR if p==NULL.
    UErrorCode errorCode = U_ZERO_ERROR;
    LocalArray<UnicodeString> ua(new UnicodeString[3], errorCode);
    if(ua.isNull() && U_SUCCESS(errorCode)) {
        errln("LocalArray(p, errorCode) failure");
        return;
    }
    errorCode = U_ZERO_ERROR;
    UnicodeString *u4 = new UnicodeString[4];
    ua.adoptInsteadAndCheckErrorCode(u4, errorCode);
    if(ua.isNull() && U_SUCCESS(errorCode)) {
        errln("adoptInsteadAndCheckErrorCode(p, errorCode) failure");
        return;
    }
    // Incoming failure: Keep the current object and delete the input object.
    errorCode = U_ILLEGAL_ARGUMENT_ERROR;
    ua.adoptInsteadAndCheckErrorCode(new UnicodeString[5], errorCode);
    if(ua.isValid() && ua.getAlias() != u4) {
        errln("adoptInsteadAndCheckErrorCode(p, U_FAILURE) did not retain the old array");
        return;
    }
    errorCode = U_ZERO_ERROR;
    ua.adoptInsteadAndCheckErrorCode(NULL, errorCode);
    if(errorCode != U_MEMORY_ALLOCATION_ERROR) {
        errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR");
        return;
    }
    if(ua.isValid()) {
        errln("adoptInsteadAndCheckErrorCode(NULL, errorCode) kept the array");
        return;
    }
    errorCode = U_ZERO_ERROR;
    LocalArray<UnicodeString> null(NULL, errorCode);
    if(errorCode != U_MEMORY_ALLOCATION_ERROR) {
        errln("LocalArray(NULL, errorCode) did not set U_MEMORY_ALLOCATION_ERROR");
        return;
    }

    // destructor
}
void ChaserRunner_Test::writeNoSteps()
{
    Chaser chaser(m_doc);
    ChaserRunner cr(m_doc, &chaser);

    UniverseArray ua(512);
    MasterTimerStub timer(m_doc, ua);

    QVERIFY(cr.write(&timer, &ua) == false);
}
Example #13
0
void Script_Test::initial()
{
    Doc doc(this);
    UniverseArray ua(512 * 4);

    Script scr(&doc);
    scr.setData(script0);

    for (int i = 0; i < 9; i++)
        scr.executeCommand(i, doc.masterTimer(), &ua);
}
Example #14
0
void UniverseArray_Test::setGMValue()
{
    UniverseArray ua(5);

    ua.write(0, 10, QLCChannel::Intensity);
    ua.write(1, 20, QLCChannel::Intensity);
    ua.write(2, 30, QLCChannel::Pan);
    ua.write(3, 40, QLCChannel::Tilt);
    ua.write(4, 50, QLCChannel::Intensity);

    ua.setGMValue(63);
    QCOMPARE(ua.postGMValues()->at(0), char(2));
    QCOMPARE(ua.postGMValues()->at(1), char(5));
    QCOMPARE(ua.postGMValues()->at(2), char(30));
    QCOMPARE(ua.postGMValues()->at(3), char(40));
    QCOMPARE(ua.postGMValues()->at(4), char(12));

    ua.setGMChannelMode(UniverseArray::GMAllChannels);
    QCOMPARE(ua.postGMValues()->at(0), char(2));
    QCOMPARE(ua.postGMValues()->at(1), char(5));
    QCOMPARE(ua.postGMValues()->at(2), char(7));
    QCOMPARE(ua.postGMValues()->at(3), char(10));
    QCOMPARE(ua.postGMValues()->at(4), char(12));

    ua.setGMChannelMode(UniverseArray::GMIntensity);
    QCOMPARE(ua.postGMValues()->at(0), char(2));
    QCOMPARE(ua.postGMValues()->at(1), char(5));
    QCOMPARE(ua.postGMValues()->at(2), char(30));
    QCOMPARE(ua.postGMValues()->at(3), char(40));
    QCOMPARE(ua.postGMValues()->at(4), char(12));

    ua.setGMValueMode(UniverseArray::GMLimit);
    QCOMPARE(ua.postGMValues()->at(0), char(10));
    QCOMPARE(ua.postGMValues()->at(1), char(20));
    QCOMPARE(ua.postGMValues()->at(2), char(30));
    QCOMPARE(ua.postGMValues()->at(3), char(40));
    QCOMPARE(ua.postGMValues()->at(4), char(50));

    ua.setGMValue(5);
    QCOMPARE(ua.postGMValues()->at(0), char(5));
    QCOMPARE(ua.postGMValues()->at(1), char(5));
    QCOMPARE(ua.postGMValues()->at(2), char(30));
    QCOMPARE(ua.postGMValues()->at(3), char(40));
    QCOMPARE(ua.postGMValues()->at(4), char(5));

    ua.setGMChannelMode(UniverseArray::GMAllChannels);
    QCOMPARE(ua.postGMValues()->at(0), char(5));
    QCOMPARE(ua.postGMValues()->at(1), char(5));
    QCOMPARE(ua.postGMValues()->at(2), char(5));
    QCOMPARE(ua.postGMValues()->at(3), char(5));
    QCOMPARE(ua.postGMValues()->at(4), char(5));
}
Example #15
0
static void premsg (void)
{
#if 0
	static int done;
	char *as;
	char ast[32];
	TCHAR *ws;

	if (done)
		return;
	done = 1;

	ast[0] = 'A';
	ast[1] = 0x7f;
	ast[2] = 0x80;
	ast[3] = 0x81;
	ast[4] = 0x9f;
	ast[5] = 0;
	ws = au_fs (ast);

	MessageBoxA(NULL, "español", "ANSI", MB_OK);
	MessageBoxW(NULL, _T("español"), _T("UTF-16"), MB_OK);

	as = ua (_T("español"));
	MessageBoxA(NULL, as, "ANSI:2", MB_OK);
	ws = au (as);
	MessageBoxW(NULL, ws, _T("UTF-16:2"), MB_OK);
	xfree (ws);
	xfree (as);

	ws = au ("español");
	MessageBoxW(NULL, ws, _T("UTF-16:3"), MB_OK);
	as = ua (ws);
	MessageBoxA(NULL, as, "ANSI:3", MB_OK);
	xfree (ws);
	xfree (as);
#endif
}
Example #16
0
void Chaser_Test::postRun()
{
    Chaser* c = new Chaser(m_doc);
    m_doc->addFunction(c);

    UniverseArray ua(512);
    MasterTimerStub timer(m_doc, ua);

    c->preRun(&timer);
    QCOMPARE(c->isRunning(), true);

    // The chaser has no steps so ChaserRunner::postrun() shouldn't do much
    c->postRun(&timer, &ua);
    QCOMPARE(c->isRunning(), false); // Make sure Function::postRun() is called
}
Example #17
0
/*!
 * \brief LAArmadillo::svd
 * Compute singular value decomposition of x
 * \param u
 * \param d
 * \param v
 * \param x
 * \return
 */
bool LAArmadillo::svd(OiMat &u, OiVec &d, OiMat &v, const OiMat &x){
    int matSize = x.getRowCount();
    arma::mat ua(matSize, matSize), va(matSize, matSize), xa(matSize, matSize);
    arma::vec da(matSize);

    this->oiMat2Arma(xa, x);

    arma::svd(ua, da, va, xa);

    this->arma2OiMat(u, ua);
    this->arma2OiMat(v, va);
    this->arma2OiVec(d, da);

    return true;
}
Example #18
0
void Chaser_Test::preRun()
{
    Chaser* c = new Chaser(m_doc);
    m_doc->addFunction(c);

    UniverseArray ua(512);
    MasterTimerStub timer(m_doc, ua);

    c->m_stop = true;

    c->preRun(&timer);
    QVERIFY(c->m_runner != NULL);
    QCOMPARE(c->isRunning(), true); // Make sure Function::preRun() is called
    QCOMPARE(c->m_runner->m_elapsed, uint(0)); // Make sure ChaserRunner::reset() is called
    c->postRun(&timer, &ua);
}
Example #19
0
void GenericFader_Test::writeZeroFade()
{
    UniverseArray ua(512);
    GenericFader fader(m_doc);

    FadeChannel fc;
    fc.setFixture(0);
    fc.setChannel(5);
    fc.setStart(0);
    fc.setTarget(255);
    fc.setFadeTime(0);

    fader.add(fc);
    QCOMPARE(ua.preGMValues()[15], (char) 0);
    fader.write(&ua);
    QCOMPARE(ua.preGMValues()[15], (char) 255);
}
Example #20
0
int uaenet_open (void *vsd, struct netdriverdata *tc, void *user, uaenet_gotfunc *gotfunc, uaenet_getfunc *getfunc, int promiscuous, const uae_u8 *mac)
{
	struct uaenetdatawin32 *sd = (struct uaenetdatawin32*)vsd;
	char *s;

	s = ua (tc->name);
	if (mac)
		memcpy(tc->mac, mac, 6);
	if (memcmp(tc->mac, tc->originalmac, 6)) {
		promiscuous = 1;
	}
	sd->fp = ppcap_open(s, 65536, (promiscuous ? PCAP_OPENFLAG_PROMISCUOUS : 0) | PCAP_OPENFLAG_MAX_RESPONSIVENESS, 100, NULL, sd->errbuf);
	xfree (s);
	if (sd->fp == NULL) {
		TCHAR *ss = au (sd->errbuf);
		write_log (_T("'%s' failed to open: %s\n"), tc->name, ss);
		xfree (ss);
		return 0;
	}
	sd->tc = tc;
	sd->user = user;
	sd->evttw = CreateEvent (NULL, FALSE, FALSE, NULL);

	if (!sd->evttw)
		goto end;
	sd->mtu = tc->mtu;
	sd->readbuffer = xmalloc (uae_u8, sd->mtu);
	sd->writebuffer = xmalloc (uae_u8, sd->mtu);
	sd->gotfunc = gotfunc;
	sd->getfunc = getfunc;

	uae_sem_init (&sd->change_sem, 0, 1);
	uae_sem_init (&sd->sync_semr, 0, 0);
	uae_start_thread (_T("uaenet_win32r"), uaenet_trap_threadr, sd, &sd->tidr);
	uae_sem_wait (&sd->sync_semr);
	uae_sem_init (&sd->sync_semw, 0, 0);
	uae_start_thread (_T("uaenet_win32w"), uaenet_trap_threadw, sd, &sd->tidw);
	uae_sem_wait (&sd->sync_semw);
	write_log (_T("uaenet_win32 initialized\n"));
	return 1;

end:
	uaenet_close (sd);
	return 0;
}
Example #21
0
void UniverseArray_Test::gMValueMode()
{
    UniverseArray ua(1);

    ua.setGMValueMode(UniverseArray::GMLimit);
    QCOMPARE(ua.gMValueMode(), UniverseArray::GMLimit);

    ua.setGMValueMode(UniverseArray::GMReduce);
    QCOMPARE(ua.gMValueMode(), UniverseArray::GMReduce);

    QCOMPARE(UniverseArray::stringToGMValueMode("Limit"), UniverseArray::GMLimit);
    QCOMPARE(UniverseArray::stringToGMValueMode("Reduce"), UniverseArray::GMReduce);
    QCOMPARE(UniverseArray::stringToGMValueMode("xyzzy"), UniverseArray::GMReduce);

    QCOMPARE(UniverseArray::gMValueModeToString(UniverseArray::GMLimit), QString("Limit"));
    QCOMPARE(UniverseArray::gMValueModeToString(UniverseArray::GMReduce), QString("Reduce"));
    QCOMPARE(UniverseArray::gMValueModeToString(UniverseArray::GMValueMode(31337)), QString("Reduce"));
}
Example #22
0
void UniverseArray_Test::gMChannelMode()
{
    UniverseArray ua(1);

    ua.setGMChannelMode(UniverseArray::GMAllChannels);
    QCOMPARE(ua.gMChannelMode(), UniverseArray::GMAllChannels);

    ua.setGMChannelMode(UniverseArray::GMIntensity);
    QCOMPARE(ua.gMChannelMode(), UniverseArray::GMIntensity);

    QCOMPARE(UniverseArray::stringToGMChannelMode("All"), UniverseArray::GMAllChannels);
    QCOMPARE(UniverseArray::stringToGMChannelMode("Intensity"), UniverseArray::GMIntensity);
    QCOMPARE(UniverseArray::stringToGMChannelMode("foobar"), UniverseArray::GMIntensity);

    QCOMPARE(UniverseArray::gMChannelModeToString(UniverseArray::GMAllChannels), QString("All"));
    QCOMPARE(UniverseArray::gMChannelModeToString(UniverseArray::GMIntensity), QString("Intensity"));
    QCOMPARE(UniverseArray::gMChannelModeToString(UniverseArray::GMChannelMode(42)), QString("Intensity"));
}
Example #23
0
void UniverseArray_Test::gMValue()
{
    UniverseArray ua(1);

    for (int i = 0; i < UCHAR_MAX; i++)
    {
        ua.setGMValue(uchar(i));
        QCOMPARE(ua.gMValue(), uchar(i));
        QCOMPARE(ua.gMFraction(), (double(i) / double(UCHAR_MAX)));
    }

    ua.setGMValue(0);
    QCOMPARE(ua.gMValue(), uchar(0));
    QCOMPARE(ua.gMFraction(), double(0));

    ua.setGMValue(255);
    QCOMPARE(ua.gMValue(), uchar(255));
    QCOMPARE(ua.gMFraction(), double(1));
}
Example #24
0
void GenericFader_Test::adjustIntensity()
{
    UniverseArray ua(512);
    GenericFader fader(m_doc);

    FadeChannel fc;

    // HTP channel
    fc.setFixture(0);
    fc.setChannel(5);
    fc.setStart(0);
    fc.setTarget(250);
    fc.setFadeTime(1000);
    fader.add(fc);

    // LTP channel
    fc.setChannel(0);
    fader.add(fc);

    qreal intensity = 0.5;
    fader.adjustIntensity(intensity);
    QCOMPARE(fader.intensity(), intensity);

    int expected = 0;
    for (int i = MasterTimer::tick(); i <= 1000; i += MasterTimer::tick())
    {
        ua.zeroIntensityChannels();
        fader.write(&ua);

        expected += 5;

        // GenericFader should apply intensity only to HTP channels
        int actual = uchar(ua.preGMValues()[15]);
        int expectedWithIntensity = floor((qreal(expected) * intensity) + 0.5);
        QVERIFY(actual == expectedWithIntensity);

        // No intensity adjustment on LTP channels
        actual = uchar(ua.preGMValues()[10]);
        QVERIFY(actual == expected);
    }
}
Example #25
0
void Chaser_Test::adjustIntensity()
{
    Chaser* c = new Chaser(m_doc);
    m_doc->addFunction(c);

    UniverseArray ua(512);
    MasterTimerStub timer(m_doc, ua);

    c->preRun(&timer);
    c->adjustAttribute(0.5, Function::Intensity);
    QCOMPARE(c->m_runner->m_intensity, qreal(0.5));
    c->adjustAttribute(0.8, Function::Intensity);
    QCOMPARE(c->m_runner->m_intensity, qreal(0.8));
    c->adjustAttribute(1.5, Function::Intensity);
    QCOMPARE(c->m_runner->m_intensity, qreal(1.0));
    c->adjustAttribute(-0.1, Function::Intensity);
    QCOMPARE(c->m_runner->m_intensity, qreal(0.0));
    c->postRun(&timer, &ua);

    // Mustn't crash after postRun
    c->adjustAttribute(1.0, Function::Intensity);
}
Example #26
0
void ppc_map_banks(uae_u32 start, uae_u32 size, const TCHAR *name, void *addr, bool remove)
{
	if (ppc_state == PPC_STATE_INACTIVE || !impl.map_memory)
		return;

	PPCMemoryRegion r;
	r.start = start;
	r.size = size;
	r.name = ua(name);
	r.alias = remove ? 0xffffffff : 0;
	r.memory = addr;

	if (impl.in_cpu_thread() == false) {
		/* map_memory will acquire the qemu global lock, so we must ensure
		 * the PPC CPU can finish any I/O requests and release the lock. */
		uae_ppc_spinlock_release();
	}
	impl.map_memory(&r, -1);
	if (impl.in_cpu_thread() == false) {
		uae_ppc_spinlock_get();
	}
	free((void*)r.name);
}
Example #27
0
void UniverseArray_Test::reset()
{
    UniverseArray ua(128);
    int i;

    for (i = 0; i < 128; i++)
    {
        ua.write(i, 200, QLCChannel::Intensity);
        QCOMPARE(ua.postGMValues()->at(i), char(200));
    }

    // Reset channels 10-127 (512 shouldn't cause a crash)
    ua.reset(10, 512);
    for (i = 0; i < 10; i++)
        QCOMPARE(ua.postGMValues()->at(i), char(200));
    for (i = 10; i < 128; i++)
        QCOMPARE(ua.postGMValues()->at(i), char(0));

    // Reset all
    ua.reset();
    for (i = 0; i < 128; i++)
        QCOMPARE(ua.postGMValues()->at(i), char(0));
}
Example #28
0
void ItemHandle::doLaunch(Helper::ItemLaunchHelperI* helper)
{
	preLaunchCheck();
	
	bool needElevation = false;

	size_t x=0;
	while (g_ElevatedGames[x].isOk())
	{
		if (getItemInfo()->getId() == g_ElevatedGames[x] || getItemInfo()->getParentId() == g_ElevatedGames[x])
		{
			needElevation = true;
			break;
		}

		x++;
	}
	
	UserCore::Item::Misc::ExeInfoI* ei = getItemInfo()->getActiveExe();

	gcString args;
	gcString ea(ei->getExeArgs());
	gcString ua(ei->getUserArgs());
	
	if (ea.size() > 0)
		args += " " + ea;

	if (ua.size() > 0)
		args += " " + ua;

	m_pUserCore->getItemManager()->setRecent(getItemInfo()->getId());

	bool res = UTIL::WIN::launchExe(ei->getExe(), args.c_str(), needElevation, m_pUserCore->getMainWindowHandle());

	if (!res)
		throw gcException(ERR_LAUNCH, GetLastError(), gcString("Failed to create {0} process. [{1}: {2}].\n", getItemInfo()->getName(), GetLastError(), ei->getExe()));
}
Example #29
0
static void map_banks(void)
{
	if (impl.map_memory == NULL) {
		return;
	}
	/*
	 * Use NULL for memory to get callbacks for read/write. Use real
	 * memory address for direct access to RAM banks (looks like this
	 * is needed by JIT, or at least more work is needed on QEmu Side
	 * to allow all memory access to go via callbacks).
	 */

	PPCMemoryRegion regions[UAE_MEMORY_REGIONS_MAX];
	UaeMemoryMap map;
	uae_memory_map(&map);

	for (int i = 0; i < map.num_regions; i++) {
		UaeMemoryRegion *r = &map.regions[i];
		regions[i].start = r->start;
		regions[i].size = r->size;
		regions[i].name = ua(r->name);
		regions[i].alias = r->alias;
		regions[i].memory = r->memory;
	}

	if (impl.in_cpu_thread && impl.in_cpu_thread() == false) {
		uae_ppc_spinlock_release();
	}
	impl.map_memory(regions, map.num_regions);
	if (impl.in_cpu_thread && impl.in_cpu_thread() == false) {
		uae_ppc_spinlock_get();
	}

	for (int i = 0; i < map.num_regions; i++) {
		free(regions[i].name);
	}
}
Example #30
0
/*Movie Info Downloader*/
QString QMKOmdbApi::download_movie_info(QUrl &url){
    QNetworkAccessManager *qnam = new QNetworkAccessManager();
    QByteArray ua(this->ua.toUtf8());


    QNetworkRequest qnr;
    qnr.setUrl(url);
    qnr.setRawHeader("User-Agent",ua);

    QNetworkReply *reply= qnam->get(qnr);

    QEventLoop loop;
    QObject::connect(reply, SIGNAL(finished()),&loop, SLOT(quit()));
    loop.exec();

    QString result = reply->readAll();


    /*Cleaning Memory*/
    delete reply;
    delete qnam;

    return result;
}