Exemplo n.º 1
0
void ArrowLineComp::Read (istream& in) {
    LineComp::Read(in);
    Line* line = GetLine();
    Coord x0, y0, x1, y1;
    int h, t;
    float scale;
    
    line->GetOriginal(x0, y0, x1, y1);

    in >> h >> t >> scale;

    ArrowLine* arrow = new ArrowLine(x0, y0, x1, y1, h, t, scale, line);
    arrow->SetPattern(ReadPattern(in));

    SetGraphic(arrow);
    delete line;
}
Exemplo n.º 2
0
Arquivo: rect.cpp Projeto: PNCG/neuron
void RectComp::Read (istream& in) {
    GraphicComp::Read(in);
    Coord x0, y0, x1, y1;

    in >> x0 >> y0 >> x1 >> y1;
    SF_Rect* rect = new SF_Rect(x0, y0, x1, y1);

    rect->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    rect->SetColors(fg, bg);
    rect->SetBrush(ReadBrush(in));
    rect->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    rect->SetTransformer(t);
    Unref(t);

    SetGraphic(rect);
}
Exemplo n.º 3
0
void EllipseComp::Read (istream& in) {
    GraphicComp::Read(in);
    Coord x0, y0;
    int r1, r2;

    in >> x0 >> y0 >> r1 >> r2;
    SF_Ellipse* ellipse = new SF_Ellipse(x0, y0, r1, r2);

    ellipse->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    ellipse->SetColors(fg, bg);
    ellipse->SetBrush(ReadBrush(in));
    ellipse->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    ellipse->SetTransformer(t);
    Unref(t);

    SetGraphic(ellipse);
}
Exemplo n.º 4
0
Arquivo: line.cpp Projeto: PNCG/neuron
void MultiLineComp::Read (istream& in) {
    VerticesComp::Read(in);
    Coord* x, *y;
    int count;

    ReadVertices(in, x, y, count);
    SF_MultiLine* ml = new SF_MultiLine(x, y, count);
    delete x;
    delete y;

    ml->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    ml->SetColors(fg, bg);
    ml->SetBrush(ReadBrush(in));
    ml->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    ml->SetTransformer(t);
    Unref(t);

    SetGraphic(ml);
}
Exemplo n.º 5
0
void SplineComp::Read (istream& in) {
    VerticesComp::Read(in);
    Coord* x, *y;
    int count;

    ReadVertices(in, x, y, count);
    SFH_OpenBSpline* spline = new SFH_OpenBSpline(x, y, count);
    delete x;
    delete y;

    spline->FillBg(ReadBgFilled(in));
    PSColor* fg = ReadColor(in);
    PSColor* bg = ReadColor(in);
    spline->SetColors(fg, bg);
    spline->SetBrush(ReadBrush(in));
    spline->SetPattern(ReadPattern(in));

    Transformer* t = ReadTransformer(in);
    spline->SetTransformer(t);
    Unref(t);

    SetGraphic(spline);
}
Exemplo n.º 6
0
unsigned int PreloaderCmd::CMD_BootAsFastboot(BOOT_ARG_S * pArg)
{
	unsigned int iRet = S_DONE;

	//Check parameters
	if(NULL == pArg)
	{
		printf( "Incorrect parameters!(NULL pointer)\n");
		return S_INVALID_ARGUMENTS;
	}

	//Set parameters and open/configure port
	SetParameters(pArg);
	if(0 != (iRet = SetPort(pArg)))
	{
		printf("Set port fail!\n");
		return iRet;
	}


	//printf("Start handshake with Preloader...\n");

	//Read pattern "READY"
	PATTERN_INFO_S stPattern;
	stPattern.m_uStatus = S_DONE;
	stPattern.m_uLen = strlen(kStrReady);
	strcpy(stPattern.m_szPattern, kStrReady);
	iRet = ReadPattern(&stPattern, 1);
	if(S_DONE == iRet)
	{
		//printf("PreloaderCmd::CMD_BootAsFastboot(): Receive READY succeed!\n");
	}
	else
	{
		printf( "Cannot receive pattern wanted!Ret(%u).\n", iRet);
		m_cPort.Close();
		return iRet;
	}


	//Write pattern "FASTBOOT" and its parameters
	PL_MODE_PARA_S tModePara;
	PARA_VALUE_S_V1 tValue;

	tValue.m_cKernelUSBType = (pArg->m_bIsCompositeDeviceEnable) ? (0) : (1);
	tValue.m_cKernelUSBNum= 0;
	tValue.dummy1= 0;
	tValue.dummy2= 0;

	memcpy(tModePara.m_aMode, kStrFBTReq, strlen(kStrFBTReq));    
	tModePara.m_uParaLen = sizeof(PARA_VALUE_S_V1);
	tModePara.m_uParaVer = 1;
	tModePara.m_nParaVal.m_tParaV1 = tValue;


	//iRet = WritePattern(kStrFBTReq, strlen(kStrFBTReq));
	iRet = WritePattern((char *)&tModePara, sizeof(PL_MODE_PARA_S));
	if(S_DONE == iRet)
	{
		//printf( "Send Request.\n");
	}
	else
	{
		printf("Send request fail. Ret(%u).\n", iRet);
		m_cPort.Close();
		return iRet;
	}

	//Read pattern "TOOBTSAF"
	PATTERN_INFO_S stFBTPattern[1];
	stFBTPattern[0].m_uStatus = S_DONE;
	stFBTPattern[0].m_uLen = strlen(kStrFBTSuccess);
	strcpy(stFBTPattern[0].m_szPattern, kStrFBTSuccess);

	//stFBTPattern[1].m_uStatus = S_PL_MODE_FORBIDDEN;
	//stFBTPattern[1].m_uLen = strlen(kStrFBTInvalid);
	//strcpy(stFBTPattern[1].m_szPattern, kStrFBTInvalid);
	iRet = ReadPattern(stFBTPattern, 1);
#if 0
	stPattern.m_uStatus = S_DONE;
	stPattern.m_uLen = strlen(kStrFBTSuccess);
	strcpy(stPattern.m_szPattern, kStrFBTSuccess);
	iRet = ReadPattern(&stPattern, 1);
#endif

	if(S_DONE == iRet)
	{
		//printf("Receive confirm succeed.\n");
	}   
	else if(S_PL_MODE_INVALID_ARGUMETS == iRet)
	{
		printf("FASTBOOT mode arguments is invalid!\n");
	}
	else
	{
		printf("Cannot receive pattern wanted!Err(%u).\n", iRet);
	}

	m_cPort.Close();
	return iRet;    
}
Exemplo n.º 7
0
ap_result MikSTX::ModuleConverter(APAgent_ConvertModule *convInfo)
{
	int32 t, u, track = 0;
	int32 version = 0;
	SAMPLE *q;
	PFile *file = convInfo->moduleFile;
	ap_result retVal = AP_OK;

	try
	{
		// Clear the buffer pointers
		mh        = NULL;
		stxBuf    = NULL;
		posLookup = NULL;
		paraPtr   = NULL;

		// Allocate buffers
		if ((mh = new STXHEADER) == NULL)
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		if ((stxBuf = new STXNOTE[4 * 64]) == NULL)
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		if ((posLookup = new uint8[256]) == NULL)
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		// Clear the buffers
		memset(mh, 0, sizeof(STXHEADER));
		memset(stxBuf, 0, sizeof(STXNOTE) * 4 * 64);
		memset(posLookup, -1, 256);

		// Try to read module header
		file->ReadString(mh->songName, 20);
		file->ReadString(mh->trackerName, 8);

		mh->patSize    = file->Read_L_UINT16();
		mh->unknown1   = file->Read_L_UINT16();
		mh->patPtr     = file->Read_L_UINT16();
		mh->insPtr     = file->Read_L_UINT16();
		mh->chnPtr     = file->Read_L_UINT16();
		mh->unknown2   = file->Read_L_UINT16();
		mh->unknown3   = file->Read_L_UINT16();
		mh->masterMult = file->Read_UINT8();
		mh->initSpeed  = file->Read_UINT8() >> 4;
		mh->unknown4   = file->Read_L_UINT16();
		mh->unknown5   = file->Read_L_UINT16();
		mh->patNum     = file->Read_L_UINT16();
		mh->insNum     = file->Read_L_UINT16();
		mh->ordNum     = file->Read_L_UINT16();
		mh->unknown6   = file->Read_L_UINT16();
		mh->unknown7   = file->Read_L_UINT16();
		mh->unknown8   = file->Read_L_UINT16();
		file->Read(mh->scrm, 4);

		if (file->IsEOF())
		{
			ShowError(IDS_MIKC_ERR_LOADING_HEADER);
			throw PUserException();
		}

		// Set module variables
		of.songName.SetString(mh->songName, &charSet850);
		of.numPat    = mh->patNum;
		of.repPos    = 0;
		of.numIns    = of.numSmp = mh->insNum;
		of.initSpeed = mh->initSpeed;
		of.initTempo = 125;
		of.numChn    = 4;
		of.flags    |= UF_S3MSLIDES;
		of.bpmLimit  = 32;

		if ((paraPtr = new uint16[of.numIns + of.numPat]) == NULL)
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		// Read the instrument + patterns parapointers
		file->Seek(mh->insPtr << 4, PFile::pSeekBegin);
		file->ReadArray_L_UINT16s(paraPtr, of.numIns);

		file->Seek(mh->patPtr << 4, PFile::pSeekBegin);
		file->ReadArray_L_UINT16s(paraPtr + of.numIns, of.numPat);

		// Check module version
		file->Seek(paraPtr[of.numIns] << 4, PFile::pSeekBegin);
		version = file->Read_L_UINT16();
		if (version == mh->patSize)
		{
			version = 0x10;
			convInfo->modKind.LoadString(res, IDS_MIKC_NAME_STX_10);
		}
		else
		{
			version = 0x11;
			convInfo->modKind.LoadString(res, IDS_MIKC_NAME_STX_11);
		}

		convInfo->fileType.LoadString(res, IDS_MIKC_MIME_STX);

		// Read the order data
		file->Seek((mh->chnPtr << 4) + 32, PFile::pSeekBegin);

		if (!(AllocPositions(mh->ordNum)))
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		for (t = 0; t < mh->ordNum; t++)
		{
			of.positions[t] = file->Read_UINT8();
			file->Seek(4, PFile::pSeekCurrent);
		}

		of.numPos    = 0;
		posLookupCnt = mh->ordNum;

		for (t = 0; t < mh->ordNum; t++)
		{
			int32 order = of.positions[t];
			if (order == 255)
				order = LAST_PATTERN;

			of.positions[of.numPos] = order;
			posLookup[t] = of.numPos;		// Bug fix for freaky S3Ms

			if (of.positions[t] < 254)
				of.numPos++;
			else
			{
				// Special end of song pattern
				if ((order == LAST_PATTERN) && (!curious))
					break;
			}
		}

		if (file->IsEOF())
		{
			ShowError(IDS_MIKC_ERR_LOADING_HEADER);
			throw PUserException();
		}

		// Load samples
		if (!(AllocSamples()))
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		for (q = of.samples, t = 0; t < of.numIns; t++, q++)
		{
			STXSAMPLE s;

			// Seek to instrument position
			file->Seek(((int32)paraPtr[t]) << 4, PFile::pSeekBegin);

			// And load sample info
			s.type = file->Read_UINT8();

			file->ReadString(s.fileName, 12);

			s.memSegH = file->Read_UINT8();
			s.memSegL = file->Read_L_UINT16();
			s.length  = file->Read_L_UINT32();
			s.loopBeg = file->Read_L_UINT32();
			s.loopEnd = file->Read_L_UINT32();
			s.volume  = file->Read_UINT8();
			s.dsk     = file->Read_UINT8();
			s.pack    = file->Read_UINT8();
			s.flags   = file->Read_UINT8();
			s.c2Spd   = file->Read_L_UINT32();

			file->Read(s.unused, 12);
			file->ReadString(s.sampName, 28);
			file->Read(s.scrs, 4);

			if (file->IsEOF())
			{
				ShowError(IDS_MIKC_ERR_LOADING_SAMPLEINFO);
				throw PUserException();
			}

			q->sampleName.SetString(s.sampName, &charSet850);
			q->speed      = (s.c2Spd * 8363) / 8448;
			q->length     = s.length;
			q->loopStart  = s.loopBeg;
			q->loopEnd    = s.loopEnd;
			q->volume     = s.volume;
			q->seekPos    = (((int32)s.memSegH) << 16 | s.memSegL) << 4;
			q->flags     |= SF_SIGNED;

			if (s.flags & 1)
				q->flags |= SF_LOOP;

			if (s.flags & 4)
				q->flags |= SF_16BITS;
		}

		// Load pattern info
		of.numTrk = of.numPat * of.numChn;

		if (!(AllocTracks()))
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		if (!(AllocPatterns()))
		{
			ShowError(IDS_MIKC_ERR_MEMORY);
			throw PUserException();
		}

		for (t = 0; t < of.numPat; t++)
		{
			// Seek to pattern position (+2 skip pattern length)
			file->Seek((((int32)paraPtr[of.numIns + t]) << 4) + (version == 0x10 ? 2 : 0), PFile::pSeekBegin);
			ReadPattern(file);

			for (u = 0; u < of.numChn; u++)
			{
				if (!(of.tracks[track++] = ConvertTrack(&stxBuf[u * 64])))
				{
					ShowError(IDS_MIKC_ERR_INITIALIZE);
					throw PUserException();
				}
			}
		}
	}
	catch(PUserException e)
	{
		retVal = AP_ERROR;
	}

	// Clean up again
	delete[] stxBuf;
	stxBuf = NULL;

	delete[] paraPtr;
	paraPtr = NULL;

	delete[] posLookup;
	posLookup = NULL;

	delete mh;
	mh = NULL;

	return (retVal);
}