Exemplo n.º 1
0
//==============================================================
//		Process of 1 Event
//--------------------------------------------------------------
//	Input
//		Nothing
//	Output
//		Nothing
//	Memo
//		SeqTrack::LoadTrack() から call される。
//==============================================================
bool HOSATrack::ReadEvent(void)
{

	//==================================
	//	[ Local 変数 ]
	//----------------------------------
	const		ULONG	beginOffset	= curOffset;					//start offset point

	const		BYTE	cCommand	= GetByte(curOffset++);			//command (op-code)
	const		BYTE	cCom_bit0	= (cCommand & 0x1F);			//length / contents
	const		BYTE	cCom_bit5	= (cCommand & 0x60) >> 5;		//Delta times
	const		BYTE	cCom_bit7	= (cCommand & 0x80) >> 7;		//0=Notes / 1=Controls

//	unsigned 	int					iMinLengthCounter;				//デルタタイム最小値
//				int					i;		//general
//	vector<char>::iterator			it_note;
//	vector<int unsigned >::iterator	it_Length;



	//==================================
	//	[ Process of "Delta time" and "Note off Event" ]
	//----------------------------------
	//Command用の(DeltaCounter==0)まで繰り返し。
	//while(iDeltaTimeCounter!=0){

	//	//Search the minimum length time [ticks]
	//	iMinLengthCounter	=	iDeltaTimeCounter;
	//	for(i=0;i<listLength.size();i++){
	//		if(iMinLengthCounter > listLength[i]){
	//			iMinLengthCounter = listLength[i];
	//		}
	//	}

	//	//Writing delta time.
	//	AddDelta(iMinLengthCounter);
	//	
	//	//Subtract the minimum length time from "Delta time" and "Length times"
	//	iDeltaTimeCounter	-=	iMinLengthCounter;
	//	for(i=0;i<listNote.size();i++){
	//		listLength[i] -= iMinLengthCounter;
	//	}

	//	//Search the ("Length times" == 0)
	//	it_note		= listNote.begin();
	//	it_Length	= listLength.begin();
	//	while(it_Length != listLength.end()){
	//		if(*it_Length==0){
	//			//Write "Note-off Event"
	//			AddNoteOffNoItem(*it_note);
	//			//Erase note-information from vector.
	//			it_note		= listNote.erase(it_note);
	//			it_Length	= listLength.erase(it_Length);
	//		} else {
	//			it_note++;
	//			it_Length++;
	//		}
	//	}
	//}



	//==================================
	//	[ Process of command (note / control) ]
	//----------------------------------

	//----------------------------------
	//	Command: Notes  (cCommand == 0x00 - 0x7F)
	if(cCom_bit7==0){

		//--------
		//[2]Update the default Note Number
		cNoteNum	= GetByte(curOffset++);

		//--------
		//[3]Update the default Delta time
		ReadDeltaTime(cCom_bit5, &iDeltaTimeCom);

		//--------
		//[4]Update the default Length
		iLengthTimeNote = GetShort(parentSeq->dwOffset + 0x10 + cCom_bit0*2);
		if(iLengthTimeNote==0){
//			iLengthTimeNote = ReadVarLen(curOffset);		//No count curOffset
			iLengthTimeNote = DecodeVariable();
		};

		//--------
		//[5]Update the default Velocity
		if(cNoteNum & 0x80){
			cNoteNum &= 0x7F;
			cVelocity = GetByte(curOffset++);
		};

		//--------
		//[3]Update the default Delta time (continuation)
		if(cCom_bit5==1){
			iDeltaTimeCom = iLengthTimeNote;	//Delta time is the same as note length.
		};
		iDeltaTimeNote = iDeltaTimeCom;			//Default delta time for Note.

		//--------
		//Write Note-On Event
		AddNoteByDur(beginOffset, curOffset-beginOffset, cNoteNum, cVelocity, iLengthTimeNote);


	//----------------------------------
	//	Command: Controls  (cCommand == 0x80 - 0x9F, 0xC0 - 0xFF)
	} else {
		if(cCom_bit5!=1){
			switch(cCom_bit0){
				//------------
				//End of Track
				case(0x00):
					AddEndOfTrack(beginOffset, curOffset-beginOffset);
					return false;
					break;
				//------------
				//Tempo
				case(0x01):
					cTempo = GetByte(curOffset++);
					AddTempoBPM(beginOffset, curOffset-beginOffset, cTempo);
					break;
				//------------
				//Reverb
				case(0x02):
					curOffset++;
					AddGenericEvent(beginOffset, curOffset-beginOffset, L"Reverb Depth", NULL, CLR_REVERB);
					break;
				//------------
				//Instrument
				case(0x03):
					cInstrument = GetByte(curOffset++);
					AddProgramChange(beginOffset, curOffset-beginOffset, cInstrument);
					break;
				//------------
				//Volume
				case(0x04):
					cVolume = GetByte(curOffset++);
					AddVol(beginOffset, curOffset-beginOffset, cVolume);
					break;
				//------------
				//Panpot
				case(0x05):
					cPanpot = GetByte(curOffset++);
					AddPan(beginOffset, curOffset-beginOffset, cPanpot);
					break;
				//------------
				//Expression
				case(0x06):
					cExpression = GetByte(curOffset++);
					AddExpression(beginOffset, curOffset-beginOffset, cExpression);
					break;
				//------------
				//Unknown
				case(0x07):
					curOffset++;
					curOffset++;
					AddUnknown(beginOffset, curOffset-beginOffset);
					break;
				//------------
				//Dal Segno. (Loop)
				case(0x09):
					curOffset++;
					AddGenericEvent(beginOffset, curOffset-beginOffset, L"Dal Segno.(Loop)", NULL, CLR_LOOP);
					break;
				//------------
				//Unknown
				case(0x0F):
					AddUnknown(beginOffset, curOffset-beginOffset);
					break;
				//------------
				//Unknowns
				default:
					curOffset++;
					AddUnknown(beginOffset, curOffset-beginOffset);
					break;
			}

			//--------
			//[3]Delta time
			ULONG	beginOffset2 = curOffset;
			ReadDeltaTime(cCom_bit5, &iDeltaTimeCom);
			if(curOffset != beginOffset2){
				AddGenericEvent(beginOffset2,curOffset-beginOffset2, L"Delta time", NULL, CLR_CHANGESTATE);
			};

	//----------------------------------
	//	Command: Notes  (cCommand == 0xA0 - 0xBF)
		} else {
			if(cCom_bit0 & 0x10){
				//Add (Command = 0xB0 - 0xBF)
				cNoteNum+=(cCom_bit0 & 0x0F);
			}else{
				//Sub (Command = 0xA0 - 0xAF)
				cNoteNum-=(cCom_bit0 & 0x0F);
			};
			//--------
			//Write Note-On Event
			AddNoteByDur(beginOffset, curOffset-beginOffset, cNoteNum, cVelocity, iLengthTimeNote);
			iDeltaTimeCom		= iDeltaTimeNote;
		}
	}

	//==================================
	//	[ Process of "Note" with note length ]
	//----------------------------------
	//if(fNoteOutput!=0){
	//	//Write "Note-on Event"
	//	AddNoteOn(beginOffset, curOffset-beginOffset, fNoteOutput, cVelocity);
	//	//Add note-information to vector.
	//	listNote.push_back(fNoteOutput);		//Note Number
	//	listLength.push_back(iLengthTimeNote);	//Length
	//	//Next delta time
	//	iDeltaTimeCom		= iDeltaTimeNote;
	//}



	//==================================
	//	[ Process of "Setting Delta time" ]
	//----------------------------------
	//iDeltaTimeCounter = iDeltaTimeCom;
	AddTime(iDeltaTimeCom);



	return true;

}
Exemplo n.º 2
0
// I'm going to try to follow closely to the original Salamander 2 code at 0x30C6
bool KonamiGXTrack::ReadEvent(void)
{
	ULONG beginOffset = curOffset;
	ULONG deltatest = GetTime();
	//AddDelta(ReadVarLen(curOffset));

	BYTE status_byte = GetByte(curOffset++);

	if (status_byte == 0xFF)
	{
		if (bInJump)
		{
			bInJump = false;
			curOffset = jump_return_offset;
		}
		else
		{
			AddEndOfTrack(beginOffset, curOffset-beginOffset);
			return 0;
		}
	}
	else if (status_byte == 0x60)
	{
		return 1;
	}
	else if (status_byte == 0x61)
	{
		return 1;
	}
	else if (status_byte < 0xC0)		//note event
	{
		BYTE note, delta;
		if (status_byte < 0x62)
		{
			delta = GetByte(curOffset++);
			note = status_byte;
			prevDelta = delta;
		}
		else
		{
			delta = prevDelta;
			note = status_byte - 0x62;
		}
		
		BYTE nextDataByte = GetByte(curOffset++);
		BYTE dur, vel;
		if (nextDataByte < 0x80)
		{
			dur = nextDataByte;
			prevDur = dur;
			vel = GetByte(curOffset++);
		}
		else
		{
			dur = prevDur;
			vel = nextDataByte - 0x80;
		}
		
		//AddNoteOn(beginOffset, curOffset-beginOffset, note, vel);
		//AddDelta(dur);
		//AddNoteOffNoItem(note);
		UINT newdur = (delta*dur)/0x64;
		if (newdur == 0)
			newdur = 1;
		AddNoteByDur(beginOffset, curOffset-beginOffset, note, vel, newdur);
		AddTime(delta);
		if (newdur > delta)
			ATLTRACE("newdur > delta.  %X > %X.  occurring at %X\n", newdur, delta, beginOffset);
		//AddDelta(dur);
	}
	else switch (status_byte)
	{
	case 0xC0:
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xCE:
		curOffset+=2;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xD0:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xD1:
	case 0xD2:
	case 0xD3:
	case 0xD4:
	case 0xD5:
	case 0xD6:
		curOffset+=2;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xDE:
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE0:		//Rest
		{
			BYTE delta = GetByte(curOffset++);
			AddTime(delta);
		}
		break;
	case 0xE1:		//Hold
		{
			BYTE delta = GetByte(curOffset++);
			BYTE dur = GetByte(curOffset++);
			UINT newdur = (delta*dur)/0x64;
			AddTime(newdur);
			this->MakePrevDurNoteEnd();
			AddTime(delta-newdur);
		}
		break;
	case 0xE2:			//program change
		{
			BYTE progNum = GetByte(curOffset++);
			AddProgramChange(beginOffset, curOffset-beginOffset, progNum);
		}
		break;
	case 0xE3:			//stereo related
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE4:
	case 0xE5:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE6:
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE7:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE8:
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xE9:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xEA:			//tempo
		{
			BYTE bpm = GetByte(curOffset++);
			AddTempoBPM(beginOffset, curOffset-beginOffset, bpm);
		}
		break;
	case 0xEC:
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xEE:			//master vol
		{
			BYTE vol = GetByte(curOffset++);
			//AddMasterVol(beginOffset, curOffset-beginOffset, vol);
		}
		break;
	case 0xEF:
		curOffset+=2;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF0:
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF1:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF2:
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF3:
		curOffset+=3;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF6:
	case 0xF7:
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xF8:
		curOffset+=2;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xFA:			//release rate
		curOffset++;
		AddUnknown(beginOffset, curOffset-beginOffset);
		break;
	case 0xFD:
		curOffset += 4;
		AddGenericEvent(beginOffset, curOffset-beginOffset, L"Loop", NULL, CLR_LOOP);
		break;
	case 0xFE:
		bInJump = true;
		jump_return_offset = curOffset+4;
		AddGenericEvent(beginOffset, jump_return_offset-beginOffset, L"Jump", NULL, CLR_LOOP);
		curOffset = GetWordBE(curOffset);
		//if (curOffset > 0x100000)
		//	return 0;
		break;
	default:
		AddEndOfTrack(beginOffset, curOffset-beginOffset);
		return false;
	}
	return true;
}
Exemplo n.º 3
0
bool CompileSnesTrack::ReadEvent(void)
{
	CompileSnesSeq* parentSeq = (CompileSnesSeq*)this->parentSeq;

	uint32_t beginOffset = curOffset;
	if (curOffset >= 0x10000) {
		return false;
	}

	uint8_t statusByte = GetByte(curOffset++);
	bool bContinue = true;

	std::wstringstream desc;

	CompileSnesSeqEventType eventType = (CompileSnesSeqEventType)0;
	std::map<uint8_t, CompileSnesSeqEventType>::iterator pEventType = parentSeq->EventMap.find(statusByte);
	if (pEventType != parentSeq->EventMap.end()) {
		eventType = pEventType->second;
	}

	switch (eventType)
	{
	case EVENT_UNKNOWN0:
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;

	case EVENT_UNKNOWN1:
	{
		uint8_t arg1 = GetByte(curOffset++);
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte
			<< std::dec << std::setfill(L' ') << std::setw(0)
			<< L"  Arg1: " << (int)arg1;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;
	}

	case EVENT_UNKNOWN2:
	{
		uint8_t arg1 = GetByte(curOffset++);
		uint8_t arg2 = GetByte(curOffset++);
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte
			<< std::dec << std::setfill(L' ') << std::setw(0)
			<< L"  Arg1: " << (int)arg1
			<< L"  Arg2: " << (int)arg2;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;
	}

	case EVENT_UNKNOWN3:
	{
		uint8_t arg1 = GetByte(curOffset++);
		uint8_t arg2 = GetByte(curOffset++);
		uint8_t arg3 = GetByte(curOffset++);
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte
			<< std::dec << std::setfill(L' ') << std::setw(0)
			<< L"  Arg1: " << (int)arg1
			<< L"  Arg2: " << (int)arg2
			<< L"  Arg3: " << (int)arg3;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;
	}

	case EVENT_UNKNOWN4:
	{
		uint8_t arg1 = GetByte(curOffset++);
		uint8_t arg2 = GetByte(curOffset++);
		uint8_t arg3 = GetByte(curOffset++);
		uint8_t arg4 = GetByte(curOffset++);
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte
			<< std::dec << std::setfill(L' ') << std::setw(0)
			<< L"  Arg1: " << (int)arg1
			<< L"  Arg2: " << (int)arg2
			<< L"  Arg3: " << (int)arg3
			<< L"  Arg4: " << (int)arg4;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;
	}

	case EVENT_UNKNOWN5:
	{
		uint8_t arg1 = GetByte(curOffset++);
		uint8_t arg2 = GetByte(curOffset++);
		uint8_t arg3 = GetByte(curOffset++);
		uint8_t arg4 = GetByte(curOffset++);
		uint8_t arg5 = GetByte(curOffset++);
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte
			<< std::dec << std::setfill(L' ') << std::setw(0)
			<< L"  Arg1: " << (int)arg1
			<< L"  Arg2: " << (int)arg2
			<< L"  Arg3: " << (int)arg3
			<< L"  Arg4: " << (int)arg4
			<< L"  Arg5: " << (int)arg5;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		break;
	}

	case EVENT_GOTO:
	{
		uint16_t dest = GetShort(curOffset); curOffset += 2;
		desc << L"Destination: $" << std::hex << std::setfill(L'0') << std::setw(4) << std::uppercase << (int)dest;
		uint32_t length = curOffset - beginOffset;

		curOffset = dest;
		if (!IsOffsetUsed(dest)) {
			AddGenericEvent(beginOffset, length, L"Jump", desc.str().c_str(), CLR_LOOPFOREVER);
		}
		else {
			bContinue = AddLoopForever(beginOffset, length, L"Jump");
		}
		break;
	}

	case EVENT_LOOP_END:
	{
		uint8_t repeatNest = GetByte(curOffset++);
		uint16_t dest = GetShort(curOffset); curOffset += 2;

		desc << L"Nest Level: " << (int)repeatNest << L"  Destination: $" << std::hex << std::setfill(L'0') << std::setw(4) << std::uppercase << (int)dest;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Repeat End", desc.str().c_str(), CLR_LOOP, ICON_ENDREP);

		repeatCount[repeatNest]--;
		if (repeatCount[repeatNest] != 0) {
			curOffset = dest;
		}
		break;
	}

	case EVENT_END:
	{
		AddEndOfTrack(beginOffset, curOffset-beginOffset);
		bContinue = false;
		break;
	}

	case EVENT_VIBRATO:
	{
		uint8_t envelopeIndex = GetByte(curOffset++);
		desc << L"Envelope Index: " << (int)envelopeIndex;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Vibrato", desc.str().c_str(), CLR_MODULATION, ICON_CONTROL);
		break;
	}

	case EVENT_PORTAMENTO_TIME:
	{
		uint8_t rate = GetByte(curOffset++);
		desc << L"Rate: " << (int)rate;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Portamento Time", desc.str().c_str(), CLR_PORTAMENTOTIME, ICON_CONTROL);
		break;
	}

	case EVENT_VOLUME:
	{
		uint8_t newVolume = GetByte(curOffset++);
		spcVolume = newVolume;
		uint8_t midiVolume = Convert7bitPercentVolValToStdMidiVal(spcVolume / 2);
		AddVol(beginOffset, curOffset - beginOffset, midiVolume);
		break;
	}

	case EVENT_VOLUME_ENVELOPE:
	{
		uint8_t envelopeIndex = GetByte(curOffset++);
		desc << L"Envelope Index: " << (int)envelopeIndex;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Volume Envelope", desc.str().c_str(), CLR_VOLUME, ICON_CONTROL);
		break;
	}

	case EVENT_TRANSPOSE:
	{
		int8_t delta = (int8_t)GetByte(curOffset++);
		spcTranspose += delta;
		AddTranspose(beginOffset, curOffset - beginOffset, spcTranspose, L"Transpose (Relative)");
		break;
	}

	case EVENT_VOLUME_REL:
	{
		int8_t delta = (int8_t)GetByte(curOffset++);
		spcVolume += delta;
		uint8_t midiVolume = Convert7bitPercentVolValToStdMidiVal(spcVolume / 2);
		AddVol(beginOffset, curOffset - beginOffset, midiVolume, L"Volume (Relative)");
		break;
	}

	case EVENT_NOTE:
	{
		bool rest = (statusByte == 0x00);

		uint8_t duration;
		bool hasDuration = ReadDurationBytes(curOffset, duration);
		if (hasDuration) {
			spcNoteDuration = duration;
			desc << L"Duration: " << (int)duration;
		}

		if (rest) {
			AddRest(beginOffset, curOffset - beginOffset, spcNoteDuration);
		}
		else {
			uint8_t noteNumber = statusByte - 1;
			AddNoteByDur(beginOffset, curOffset - beginOffset, noteNumber, 100, spcNoteDuration,
				hasDuration ? L"Note with Duration" : L"Note");
			AddTime(spcNoteDuration);
		}
		break;
	}

	case EVENT_LOOP_COUNT:
	{
		uint8_t repeatNest = GetByte(curOffset++);
		uint8_t times = GetByte(curOffset++);
		int actualTimes = (times == 0) ? 256 : times;

		desc << L"Nest Level: " << (int)repeatNest << L"  Times: " << actualTimes;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Loop Count", desc.str().c_str(), CLR_LOOP, ICON_STARTREP);

		repeatCount[repeatNest] = times;
		break;
	}

	case EVENT_FLAGS:
	{
		uint8_t flags = GetByte(curOffset++);
		spcFlags = flags;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Flags", desc.str().c_str(), CLR_CHANGESTATE, ICON_CONTROL);
		break;
	}

	case EVENT_TEMPO:
	{
		uint8_t newTempo = GetByte(curOffset++);
		spcTempo = newTempo;
		AddTempoBPM(beginOffset, curOffset - beginOffset, parentSeq->GetTempoInBPM(newTempo));
		break;
	}

	case EVENT_TUNING:
	{
		int16_t newTuning;
		if (parentSeq->version == COMPILESNES_ALESTE || parentSeq->version == COMPILESNES_JAKICRUSH) {
			newTuning = (int8_t)GetByte(curOffset++);
		}
		else {
			newTuning = (int16_t)GetShort(curOffset); curOffset += 2;
		}

		desc << L"Pitch Register Delta: " << (int)newTuning;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Tuning", desc.str().c_str(), CLR_CHANGESTATE, ICON_CONTROL);
		break;
	}

	case EVENT_CALL:
	{
		uint16_t dest = GetShort(curOffset); curOffset += 2;
		desc << L"Destination: $" << std::hex << std::setfill(L'0') << std::setw(4) << std::uppercase << (int)dest;

		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Pattern Play", desc.str().c_str(), CLR_LOOP, ICON_STARTREP);

		subReturnAddress = curOffset;
		curOffset = dest;
		break;
	}

	case EVENT_RET:
	{
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"End Pattern", desc.str().c_str(), CLR_TRACKEND, ICON_ENDREP);
		curOffset = subReturnAddress;
		break;
	}

	case EVENT_PROGCHANGE:
	{
		uint8_t newProg = GetByte(curOffset++);
		AddProgramChange(beginOffset, curOffset - beginOffset, newProg, true);
		break;
	}

	case EVENT_ADSR:
	{
		uint8_t envelopeIndex = GetByte(curOffset++);
		desc << L"Envelope Index: " << (int)envelopeIndex;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"ADSR", desc.str().c_str(), CLR_VOLUME, ICON_CONTROL);
		break;
	}

	case EVENT_PORTAMENTO_ON:
	{
		spcFlags |= COMPILESNES_FLAGS_PORTAMENTO;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Portamento On", desc.str().c_str(), CLR_PORTAMENTO, ICON_CONTROL);
		break;
	}

	case EVENT_PORTAMENTO_OFF:
	{
		spcFlags &= ~COMPILESNES_FLAGS_PORTAMENTO;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Portamento Off", desc.str().c_str(), CLR_PORTAMENTO, ICON_CONTROL);
		break;
	}

	case EVENT_PANPOT_ENVELOPE:
	{
		uint8_t envelopeIndex = GetByte(curOffset++);
		desc << L"Envelope Index: " << (int)envelopeIndex;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Panpot Envelope", desc.str().c_str(), CLR_PAN, ICON_CONTROL);
		break;
	}

	case EVENT_PAN:
	{
		int8_t newPan = GetByte(curOffset++);
		spcPan = newPan;

		double volumeScale;
		uint8_t midiPan = Convert7bitLinearPercentPanValToStdMidiVal((uint8_t)(newPan + 0x80) / 2, &volumeScale);
		AddExpressionNoItem(ConvertPercentAmpToStdMidiVal(volumeScale));
		AddPan(beginOffset, curOffset - beginOffset, midiPan);
		break;
	}

	case EVENT_LOOP_BREAK:
	{
		uint8_t repeatNest = GetByte(curOffset++);
		uint16_t dest = GetShort(curOffset); curOffset += 2;

		desc << L"Nest Level: " << (int)repeatNest << L"  Destination: $" << std::hex << std::setfill(L'0') << std::setw(4) << std::uppercase << (int)dest;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Repeat Break", desc.str().c_str(), CLR_LOOP, ICON_ENDREP);

		repeatCount[repeatNest]--;
		if (repeatCount[repeatNest] == 0) {
			curOffset = dest;
		}
		break;
	}

	case EVENT_DURATION_DIRECT:
	{
		uint8_t duration;
		if (!ReadDurationBytes(curOffset, duration)) {
			// address out of range
			return false;
		}
		spcNoteDuration = duration;

		desc << L"Duration: " << (int)duration;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Duration (Direct)", desc.str().c_str(), CLR_DURNOTE, ICON_CONTROL);
		break;
	}

	case EVENT_DURATION:
	{
		uint8_t duration;
		if (!ReadDurationBytes(curOffset, duration)) {
			// address out of range
			return false;
		}
		spcNoteDuration = duration;

		desc << L"Duration: " << (int)duration;
		AddGenericEvent(beginOffset, curOffset - beginOffset, L"Duration", desc.str().c_str(), CLR_DURNOTE, ICON_CONTROL);
		break;
	}

	case EVENT_PERCUSSION_NOTE:
	{
		uint8_t duration;
		bool hasDuration = ReadDurationBytes(curOffset, duration);
		if (hasDuration) {
			spcNoteDuration = duration;
			desc << L"Duration: " << (int)duration;
		}

		uint8_t percNoteNumber = statusByte - parentSeq->STATUS_PERCUSSION_NOTE_MIN;
		AddPercNoteByDur(beginOffset, curOffset - beginOffset, percNoteNumber, 100, spcNoteDuration,
			hasDuration ? L"Percussion Note with Duration" : L"Percussion Note");
		AddTime(spcNoteDuration);
		break;
	}

	default:
		desc << L"Event: 0x" << std::hex << std::setfill(L'0') << std::setw(2) << std::uppercase << (int)statusByte;
		AddUnknown(beginOffset, curOffset-beginOffset, L"Unknown Event", desc.str().c_str());
		pRoot->AddLogItem(new LogItem((std::wstring(L"Unknown Event - ") + desc.str()).c_str(), LOG_LEVEL_ERR, L"CompileSnesSeq"));
		bContinue = false;
		break;
	}

	//wostringstream ssTrace;
	//ssTrace << L"" << std::hex << std::setfill(L'0') << std::setw(8) << std::uppercase << beginOffset << L": " << std::setw(2) << (int)statusByte  << L" -> " << std::setw(8) << curOffset << std::endl;
	//OutputDebugString(ssTrace.str().c_str());

	return bContinue;
}